{"meta":{"title":"API를 통해 Copilot 클라우드 에이전트 사용","intro":"REST API를 사용하여 프로그래밍 방식으로 작업을 시작하고 관리할 Copilot cloud agent 수 있습니다.","product":"GitHub Copilot","breadcrumbs":[{"href":"/ko/copilot","title":"GitHub Copilot"},{"href":"/ko/copilot/how-tos","title":"방법"},{"href":"/ko/copilot/how-tos/use-copilot-agents","title":"Copilot 에이전트 사용"},{"href":"/ko/copilot/how-tos/use-copilot-agents/cloud-agent","title":"Cloud agent"},{"href":"/ko/copilot/how-tos/use-copilot-agents/cloud-agent/use-cloud-agent-via-the-api","title":"API를 통해 클라우드 에이전트 사용"}],"documentType":"article"},"body":"# API를 통해 Copilot 클라우드 에이전트 사용\n\nREST API를 사용하여 프로그래밍 방식으로 작업을 시작하고 관리할 Copilot cloud agent 수 있습니다.\n\n에이전트 작업 API를 사용하여 고유한 도구 및 워크플로에 통합 cloud agent 할 수 있습니다. 예를 들어 새 작업을 시작하거나, 기존 작업을 나열하거나, 작업의 상태를 확인할 수 있습니다.\n\n또한 이슈에 대한 REST 및 GraphQL API를 사용하여 이슈를 Copilot에 할당할 수 있습니다.\n\n## 에이전트 작업 API 사용\n\n> \\[!NOTE]\n> 에이전트 작업 API는 공개 미리 보기 상태에 있으며 변경될 수 있습니다.\n\n### 인증\n\n에이전트 작업 API는 사용자-서버 토큰만 지원합니다.\npersonal access token를 사용하거나, OAuth app 토큰 또는 GitHub App 사용자-서버 토큰을 사용하여 인증할 수 있습니다.\n\n설치 액세스 토큰과 같은 GitHub App 서버-서버 토큰은 지원되지 않습니다.\n\n### API를 통해 작업 시작\n\n새로운 cloud agent 작업을 시작하려면 `POST`에 `/agents/repos/{owner}/{repo}/tasks` 요청을 보냅니다. 유일한 필수 매개 변수는 `prompt`에이전트에 대한 프롬프트인 매개 변수입니다.\n\n```shell copy\ncurl -X POST \\\n  -H \"Accept: application/vnd.github+json\" \\\n  -H \"X-GitHub-Api-Version: 2022-11-28\" \\\n  -H \"Authorization: Bearer YOUR-TOKEN\" \\\n  https://api.github.com/agents/repos/OWNER/REPO/tasks \\\n  -d '{\n    \"prompt\": \"Fix the login button on the homepage\",\n    \"base_ref\": \"main\"\n  }'\n```\n\n다음 자리 표시자 값을 바꿉다.\n\n* `YOUR-TOKEN`: personal access token 또는 GitHub App 사용자-서버 토큰입니다.\n* `OWNER`: 리포지토리의 계정 소유자입니다.\n* `REPO`: 리포지토리의 이름입니다.\n\n요청 본문에 다음 선택적 매개 변수를 포함할 수도 있습니다.\n\n* `base_ref`: 새 브랜치 및 풀 리퀘스트에 대한 기본 브랜치입니다.\n* `model`: 작업에 사용할 AI 모델입니다. 생략하면 auto model selection 사용됩니다. 지원되는 모델에 대한 자세한 내용은 [에이전트 작업에 대한 REST API 엔드포인트](/ko/rest/agent-tasks/agent-tasks)을 참조하세요.\n* `create_pull_request`: 작업에 대한 끌어오기 요청을 생성할지 여부를 결정하는 불리언입니다.\n\n### 작업 목록\n\n특정 리포지토리 또는 액세스 권한이 있는 모든 리포지토리에 대한 작업을 나열할 수 있습니다.\n\n특정 리포지토리에 대한 작업을 나열하려면 다음을 수행합니다.\n\n```shell copy\ncurl -H \"Accept: application/vnd.github+json\" \\\n  -H \"X-GitHub-Api-Version: 2022-11-28\" \\\n  -H \"Authorization: Bearer YOUR-TOKEN\" \\\n  https://api.github.com/agents/repos/OWNER/REPO/tasks\n```\n\n모든 리포지토리에서 작업을 나열하려면 다음을 수행합니다.\n\n```shell copy\ncurl -H \"Accept: application/vnd.github+json\" \\\n  -H \"X-GitHub-Api-Version: 2022-11-28\" \\\n  -H \"Authorization: Bearer YOUR-TOKEN\" \\\n  https://api.github.com/agents/tasks\n```\n\n### 작업의 상태 확인\n\n특정 작업의 상태를 확인하려면 작업 ID를 사용하여 `GET` 요청을 보냅니다.\n\n```shell copy\ncurl -H \"Accept: application/vnd.github+json\" \\\n  -H \"X-GitHub-Api-Version: 2022-11-28\" \\\n  -H \"Authorization: Bearer YOUR-TOKEN\" \\\n  https://api.github.com/agents/repos/OWNER/REPO/tasks/TASK-ID\n```\n\n`TASK-ID`를 확인할 작업의 ID로 바꿉니다. 작업을 만들거나 작업을 나열할 때 응답에서 이 ID를 가져올 수 있습니다. 응답에는 작업의 현재 `state`항목이 포함되며, `queued``in_progress``completed``failed``idle``waiting_for_user``timed_out`다음 중 `cancelled`하나일 수 있습니다.\n\n## 이슈 API 사용하기\n\n> \\[!NOTE]\n> 이 기능은 공개 미리 보기에서 사용 중이며 변경될 수 있습니다.\n\nGraphQL API 또는 REST API를 사용하여 Copilot에 문제를 할당할 수 있습니다. 두 API 모두 선택적 에이전트 할당 입력을 지원하여 작업을 사용자 지정합니다.\n\n| GraphQL 매개 변수        | REST 매개 변수            | Description          |\n| -------------------- | --------------------- | -------------------- |\n| `targetRepositoryId` | `target_repo`         |                      |\n| Copilot가 작동할 리포지토리   |                       |                      |\n| `baseRef`            | `base_branch`         | Copilot가 분기될 지점      |\n| `customInstructions` | `custom_instructions` |                      |\n| Copilot에 대한 추가 지침    |                       |                      |\n| `customAgent`        | `custom_agent`        | 작업에 사용할 custom agent |\n| `model`              | `model`               | 사용할 모델 Copilot       |\n\n### GraphQL API 사용\n\n> \\[!NOTE]\n> `GraphQL-Features` 헤더에 값 `issues_copilot_assignment_api_support` 및 `coding_agent_model_selection`을 포함해야 합니다.\n\n다음 GraphQL 변형을 사용하여 문제를 할당할 Copilot수 있습니다.\n\n* [`updateIssue`](/ko/graphql/reference/issues#mutation-updateissue)\n* [`createIssue`](/ko/graphql/reference/issues#mutation-createissue)\n* [`addAssigneesToAssignable`](/ko/graphql/reference/issues#mutation-addassigneestoassignable)\n* [`replaceActorsForAssignable`](/ko/graphql/reference/issues#mutation-replaceactorsforassignable)\n\n#### 새 이슈 만들기 및 할당\n\n1. 사용자 토큰(예: 사용자-서버 토큰)을 사용하여 API personal access tokenGitHub App 로 인증하고 있는지 확인합니다.\n\n   > \\[!NOTE]\n   > 사용하는 fine-grained personal access token가 있는 경우, Copilot을(를) 문제에 할당하려면 다음 권한이 필요합니다.\n   >\n   > * 메타데이터에 대한 읽기 액세스\n   > * 작업, 콘텐츠, 문제 및 끌어오기 요청에 대한 읽기 및 쓰기 접근 권한.\n   >\n   > 만약 personal access token (classic)를 사용하려면 문제에 `repo`를 할당하기 위해 Copilot 범위가 필요합니다.\n\n2. 리포지토리의 Copilot cloud agent가 GraphQL API에 `suggestedActors`를 포함하는지 확인하여 리포지토리에서 Copilot가 사용 설정되어 있는지 검증하십시오.\n   `octo-org` 를 리포지토리 소유자로, `octo-repo` 를 리포지토리 이름으로 변경합니다.\n\n   ```graphql copy\n   query {\n     repository(owner: \"octo-org\", name: \"octo-repo\") {\n       suggestedActors(capabilities: [CAN_BE_ASSIGNED], first: 100) {\n         nodes {\n           login\n           __typename\n\n           ... on Bot {\n             id\n           }\n\n           ... on User {\n             id\n           }\n         }\n       }\n     }\n   }\n   ```\n\n   리포지토리 및 사용자에 대해 Copilot cloud agent가 사용 설정되어 있는 경우, 쿼리에서 반환된 첫 번째 노드는 `login` 값으로 `copilot-swe-agent`를 가집니다.\n\n3. 이 로그인에 대한 `id` 값을 기록해 둡니다.\n\n4. 이슈를 생성하려는 리포지토리의 GraphQL 전역 ID를 가져온 다음, `octo-org` 를 리포지토리 소유자로, `octo-repo` 를 리포지토리 이름으로 변경합니다.\n\n   ```graphql copy\n   query {\n     repository(owner: \"octo-org\", name: \"octo-repo\") {\n       id\n     }\n   }\n   ```\n\n5. `createIssue` 변형을 통해 이슈를 생성합니다.\n   `REPOSITORY_ID`는 이전 단계에서 반환된 ID로, `BOT_ID`는 그보다 앞 단계에서 반한된 ID로 바꿉니다. 필요에 따라 입력을 `agentAssignment` 포함하여 작업을 사용자 지정할 수 있습니다.\n\n   ```shell copy\n   gh api graphql -f query='mutation {\n     createIssue(input: {\n       repositoryId: \"REPOSITORY_ID\",\n       title: \"Implement comprehensive unit tests\",\n       body: \"DETAILS\",\n       assigneeIds: [\"BOT_ID\"],\n       agentAssignment: {\n         targetRepositoryId: \"REPOSITORY_ID\",\n         baseRef: \"main\",\n         customInstructions: \"Add comprehensive test coverage\",\n         customAgent: \"\",\n         model: \"\"\n       }\n     }) {\n       issue {\n         id\n         title\n         assignees(first: 10) {\n           nodes {\n             login\n           }\n         }\n       }\n     }\n   }' -H 'GraphQL-Features: issues_copilot_assignment_api_support,coding_agent_model_selection'\n   ```\n\n#### 기존 이슈 할당\n\n1. 사용자 토큰(예: 사용자-서버 토큰)을 사용하여 API personal access tokenGitHub App 로 인증하고 있는지 확인합니다.\n\n2. 리포지토리의 Copilot cloud agent가 GraphQL API에 `suggestedActors`를 포함하는지 확인하여 리포지토리에서 Copilot가 사용 설정되어 있는지 검증하십시오.\n   `octo-org` 를 리포지토리 소유자로, `octo-repo` 를 리포지토리 이름으로 변경합니다.\n\n   ```graphql copy\n   query {\n     repository(owner: \"monalisa\", name: \"octocat\") {\n       suggestedActors(capabilities: [CAN_BE_ASSIGNED], first: 100) {\n         nodes {\n           login\n           __typename\n\n           ... on Bot {\n             id\n           }\n\n           ... on User {\n             id\n           }\n         }\n       }\n     }\n   }\n   ```\n\n   리포지토리 및 사용자에 대해 Copilot cloud agent가 사용 설정되어 있는 경우, 쿼리에서 반환된 첫 번째 노드는 `login` 값으로 `copilot-swe-agent`를 가집니다.\n\n3. 할당하려는 문제의 GraphQL 전역 ID를 가져와 Copilot를 리포지토리 소유자로, `monalisa`를 이름으로, `octocat`를 문제 번호로 바꾸세요.\n\n   ```graphql copy\n   query {\n     repository(owner: \"monalisa\", name: \"octocat\") {\n       issue(number: 9000) {\n         id\n         title\n       }\n     }\n   }\n   ```\n\n4. 기존 문제를 Copilot에게 `replaceActorsForAssignable` 변형을 사용하여 할당합니다. 이전 단계에서 반환된 ID로 `ISSUE_ID`을(를), 그 전 단계에서 반환된 ID로 `BOT_ID`을(를), 리포지토리 ID로 `REPOSITORY_ID`을(를) 바꿉니다. 필요에 따라 입력을 `agentAssignment` 포함하여 작업을 사용자 지정할 수 있습니다.\n\n   ```shell copy\n   gh api graphql -f query='mutation {\n     replaceActorsForAssignable(input: {\n       assignableId: \"ISSUE_ID\",\n       actorIds: [\"BOT_ID\"],\n       agentAssignment: {\n         targetRepositoryId: \"REPOSITORY_ID\",\n         baseRef: \"main\",\n         customInstructions: \"Fix the reported bug\",\n         customAgent: \"\",\n         model: \"\"\n       }\n     }) {\n       assignable {\n         ... on Issue {\n           id\n           title\n           assignees(first: 10) {\n             nodes {\n               login\n             }\n           }\n         }\n       }\n     }\n   }' -H 'GraphQL-Features: issues_copilot_assignment_api_support,coding_agent_model_selection'\n   ```\n\n5. 또는 `updateIssue` 변경 메서드를 사용하여 기존 문제를 업데이트하고 Copilot에 할당할 수 있습니다. 문제 ID로 `ISSUE_ID`를 바꾸고, 봇 ID로 `BOT_ID`를 바꾸십시오.\n\n   ```shell copy\n   gh api graphql -f query='mutation {\n     updateIssue(input: {\n       id: \"ISSUE_ID\",\n       assigneeIds: [\"BOT_ID\"],\n       agentAssignment: {\n         targetRepositoryId: \"REPOSITORY_ID\",\n         baseRef: \"main\",\n         customInstructions: \"Update feature implementation\",\n         customAgent: \"\",\n         model: \"\"\n       }\n     }) {\n       issue {\n         id\n         title\n         assignees(first: 10) {\n           nodes {\n             login\n           }\n         }\n       }\n     }\n   }' -H 'GraphQL-Features: issues_copilot_assignment_api_support,coding_agent_model_selection'\n   ```\n\n6. 기존 문제에 다른 담당자를 유지하면서 `addAssigneesToAssignable` 변경을 사용하여 Copilot를 추가할 수도 있습니다. 문제 ID로 `ISSUE_ID`를 바꾸고, 봇 ID로 `BOT_ID`를 바꾸십시오.\n\n   ```shell copy\n   gh api graphql -f query='mutation {\n     addAssigneesToAssignable(input: {\n       assignableId: \"ISSUE_ID\",\n       assigneeIds: [\"BOT_ID\"],\n       agentAssignment: {\n         targetRepositoryId: \"REPOSITORY_ID\",\n         baseRef: \"main\",\n         customInstructions: \"Collaborate on this task\",\n         customAgent: \"\",\n         model: \"\"\n       }\n     }) {\n       assignable {\n         ... on Issue {\n           id\n           title\n           assignees(first: 10) {\n             nodes {\n               login\n             }\n           }\n         }\n       }\n     }\n   }' -H 'GraphQL-Features: issues_copilot_assignment_api_support,coding_agent_model_selection'\n   ```\n\n### REST API 사용\n\n다음 REST API 엔드포인트를 사용하여 문제를 할당할 Copilot수 있습니다.\n\n* [문제에 할당자 추가](/ko/rest/issues/assignees#add-assignees-to-an-issue)\n* [문제 만들기](/ko/rest/issues/issues#create-an-issue)\n* [문제 업데이트](/ko/rest/issues/issues#update-an-issue)\n\n#### 기존 문제에 담당자 추가\n\n```shell copy\ngh api \\\n  --method POST \\\n  -H \"Accept: application/vnd.github+json\" \\\n  -H \"X-GitHub-Api-Version: 2022-11-28\" \\\n  /repos/OWNER/REPO/issues/ISSUE_NUMBER/assignees \\\n  --input - <<< '{\n  \"assignees\": [\"copilot-swe-agent[bot]\"],\n  \"agent_assignment\": {\n    \"target_repo\": \"OWNER/REPO\",\n    \"base_branch\": \"main\",\n    \"custom_instructions\": \"\",\n    \"custom_agent\": \"\",\n    \"model\": \"\"\n  }\n}'\n```\n\n#### 새 문제 만들기\n\n```shell copy\ngh api \\\n  --method POST \\\n  -H \"Accept: application/vnd.github+json\" \\\n  -H \"X-GitHub-Api-Version: 2022-11-28\" \\\n  /repos/OWNER/REPO/issues \\\n  --input - <<< '{\n  \"title\": \"Issue title\",\n  \"body\": \"Issue description.\",\n  \"assignees\": [\"copilot-swe-agent[bot]\"],\n  \"agent_assignment\": {\n    \"target_repo\": \"OWNER/REPO\",\n    \"base_branch\": \"main\",\n    \"custom_instructions\": \"\",\n    \"custom_agent\": \"\",\n    \"model\": \"\"\n  }\n}'\n```\n\n#### 기존 문제 업데이트\n\n```shell copy\ngh api \\\n  --method PATCH \\\n  -H \"Accept: application/vnd.github+json\" \\\n  -H \"X-GitHub-Api-Version: 2022-11-28\" \\\n  /repos/OWNER/REPO/issues/ISSUE_NUMBER \\\n  --input - <<< '{\n  \"assignees\": [\"copilot-swe-agent[bot]\"],\n  \"agent_assignment\": {\n    \"target_repo\": \"OWNER/REPO\",\n    \"base_branch\": \"main\",\n    \"custom_instructions\": \"\",\n    \"custom_agent\": \"\",\n    \"model\": \"\"\n  }\n}'\n```\n\n## 추가 읽기\n\n* [에이전트 작업에 대한 REST API 엔드포인트](/ko/rest/agent-tasks/agent-tasks)\n* [GitHub Copilot 클라우드 에이전트 정보](/ko/copilot/concepts/agents/cloud-agent/about-cloud-agent)\n* [GitHub Copilot 세션 시작](/ko/copilot/how-tos/use-copilot-agents/cloud-agent/start-copilot-sessions)"}