copilot-sdk README

项目的 README,来自 github.com/microsoft/copilot-sdk。合并为一个 markdown 文件:README.md。

Microsoft Copilot SDK

[!IMPORTANT] GitHub Copilot SDK is becoming Microsoft Copilot SDK, the programmable interface for the Microsoft Copilot harness, the shared agent foundation used across Microsoft and GitHub products.

The SDK repository will move to the Microsoft organization as part of a phased transition. Existing package names, namespaces, and some documentation may continue to reference GitHub Copilot SDK during the transition. No immediate changes are required for existing users. Learn more about the transition.

Support for the Copilot SDK remains the same. For more information: SUPPORT.md

NPM Downloads PyPI - Downloads NuGet Downloads Go Reference crates.io Maven Central

Agents for every app.

Embed Copilot's agentic workflows in your application with the Microsoft Copilot SDK for Python, TypeScript, Go, .NET, Java, and Rust.

The Microsoft Copilot SDK exposes the same engine behind Copilot CLI: a production-tested agent runtime you can invoke programmatically. No need to build your own orchestration—you define agent behavior, Copilot handles planning, tool invocation, file edits, and more.

Available SDKs

SDK Location Cookbook Installation API docs
Node.js / TypeScript nodejs/ Cookbook npm install @microsoft/copilot-sdk
Python python/ Cookbook pip install microsoft-copilot-sdk
Go go/ Cookbook go get github.com/microsoft/copilot-sdk/go/v2 API docs
.NET dotnet/ Cookbook dotnet add package Microsoft.Copilot.SDK
Rust rust/ — cargo add copilot-sdk API docs
Java java/ Cookbook Maven coordinates
com.microsoft:copilot-sdk
See instructions for Maven and Gradle
API docs

See the individual SDK READMEs for installation, usage examples, and API reference.

Getting Started

For a complete walkthrough, see the Getting Started Guide.

Quick steps:

  1. (Optional) Install the Copilot CLI

A separate CLI installation is not required. Node.js and .NET include platform runtime artifacts, Python downloads them, and Rust bundles them with its default features. Go applications must run the bundler or provide a compatible runtime package; Java applications must add their platform runtime classifier. Follow the language README before starting a client.

  1. Install your preferred SDK using the commands above.

  2. See the SDK README for usage examples and API documentation.

Architecture

All SDKs drive the Copilot agent runtime over protocol-4 JSON-RPC. By default, SDK v2 loads the native Rust runtime into your application through a C ABI and carries framed JSON-RPC messages over an in-memory connection. It does not embed a Node.js interpreter or start a CLI process:

Your Application
       ↓
  SDK Client
       ↓ JSON-RPC (in memory, C ABI)
  Native Copilot runtime

The SDK manages its runtime host, but the native library remains loaded for the application process lifetime. In-process hosting provides neither crash isolation nor a sandbox. Explicit stdio/TCP subprocess connections and external servers remain supported; see Run the Copilot runtime in process for requirements and v2 migration options.

Portable elicitation schemas

For form elicitation callbacks, the portable schema contract is an object form with modeled properties and optional required fields (type: "object" on the wire; an SDK may represent the object type implicitly). Applications that support multiple SDK languages must use the modeled property definitions and must not depend on additional schema metadata (such as a top-level title) or on the insertion order of properties.

Node.js and Rust pass through the wire schema, including additional metadata and property order. Python, Go, .NET, and Java reconstruct the callback schema from the modeled fields and do not offer that same preservation guarantee. Treat wire-schema preservation as a language-specific capability, not a cross-language requirement.

Agent Finder Skill installation APIs

Runtimes that grant skill-confirmed-installation expose skills.planInstall, skills.applyInstall, skills.planUninstall, skills.applyUninstall, skills.installations.list/recover/status/cancel, and skills.installations.setEnabled. Skill install reviews include the full verified SKILL.md content up to 256 KiB, catalogue identity, file manifest, and non-absolute personal target location. Summaries report ownershipState, configuredEnabled, sessionState, retained catalogue identity and installedAt.

FAQ

Do I need a GitHub Copilot subscription to use the SDK?

Yes, a GitHub Copilot subscription is required to use the Microsoft Copilot SDK, unless you are using BYOK (Bring Your Own Key). With BYOK, you can use the SDK without GitHub authentication by configuring your own API keys from supported LLM providers. For standard usage (non-BYOK), refer to the GitHub Copilot pricing page, which includes a free tier with limited usage.

How does billing work for SDK usage?

Billing for the Microsoft Copilot SDK is based on the same model as the Copilot CLI, with each prompt being counted towards your usage allowance. For more information on Copilot usage billing, see Usage in GitHub Copilot.

Does it support BYOK (Bring Your Own Key)?

Yes, the Microsoft Copilot SDK supports BYOK (Bring Your Own Key). You can configure the SDK to use your own API keys from supported LLM providers (e.g. OpenAI, Microsoft Foundry, Anthropic) to access models through those providers. See the BYOK documentation for setup instructions and examples.

Note: BYOK uses key-based authentication only. Microsoft Entra ID (Azure AD), managed identities, and third-party identity providers are not supported.

What authentication methods are supported?

The SDK supports multiple authentication methods:

See the Authentication documentation for details on each method.

Do I need to install the Copilot CLI separately?

No. The default needs a compatible native runtime, not a separately running CLI. Node.js, .NET, Python, and Rust provide acquisition or bundling; Go needs application-level bundling or an explicit runtime package, and Java needs the platform classifier dependency.

Advanced: You can override the CLI binary or connect to an external server. See the individual SDK README for language-specific options.

What tools are enabled by default?

By default, the SDK exposes the Copilot CLI's first-party tools, similar to running the CLI with --allow-all. Tool execution is still governed by each SDK's permission handler, so applications can approve, deny, or customize tool calls. You can customize tool availability by configuring the SDK client options to enable and disable specific tools. Refer to the individual SDK documentation for details on tool configuration and to the Copilot CLI documentation for the list of available tools.

Can I use custom agents, skills or tools?

Yes, the Microsoft Copilot SDK allows you to define custom agents, skills, and tools. You can extend the functionality of the agents by implementing your own logic and integrating additional tools as needed. Refer to the SDK documentation of your preferred language for more details.

Are there instructions or SDK guidance for Copilot to speed up development?

Yes, check out the custom instructions and SDK-specific guidance:

What models are supported?

All models available via Copilot CLI are supported in the SDK. The SDK also exposes a method which will return the models available so they can be accessed at runtime.

Is the SDK production-ready?

The Microsoft Copilot SDK is generally available and follows semantic versioning. See CHANGELOG.md for release notes.

How do I report issues or request features?

Please use the GitHub Issues page to report bugs or request new features. We welcome your feedback to help improve the SDK.

Unofficial, Community-maintained SDKs

⚠️ Disclaimer: These are unofficial, community-driven SDKs and they are not supported by GitHub. Use at your own risk.

SDK Location
Clojure copilot-community-sdk/copilot-sdk-clojure
C++ 0xeb/copilot-sdk-cpp

License

MIT

copilot-sdk (microsoft/copilot-sdk)

正在搜索数据库…

这是什么?这是 GitHub 官方的 Copilot SDK,让开发者可以把 GitHub Copilot 的智能体工作流程(规划、调用工具、编辑文件)直接嵌入自己的应用和服务中,提供 Python、TypeScript、Go、.NET、Java 和 Rust 的实现。
这是一个我要导入的库,还是独立应用?这是一个你用自己选择的语言加到自己代码库中的库或 SDK。它底层通过 JSON-RPC 与 Copilot CLI 使用的同一引擎通信,因此你不必自己搭建智能体编排逻辑。
怎么把它加到我的项目里?先为你的语言安装 SDK:npm install @github/copilot-sdk、pip install github-copilot-sdk、go get github.com/github/copilot-sdk/go、dotnet add package GitHub.Copilot.SDK、cargo add github-copilot-sdk,Java 则使用 Maven 或 Gradle。然后参照入门指南和该 SDK 的 README 中的使用示例。
我需要先单独安装 Copilot CLI 吗?Node.js、Python 或 .NET 不需要,Copilot CLI 会作为依赖项自动安装。Go、Java 和 Rust 则需要你自己安装 CLI,并确保它在 PATH 中。另外你还需要一个 GitHub Copilot 订阅,除非你使用 BYOK(自带密钥)并自备大模型服务商的密钥。
使用 BYOK 能完全跳过 GitHub 认证吗?能。BYOK 允许你使用 OpenAI、Microsoft Foundry、Anthropic 等服务商提供的自有 API 密钥,无需 GitHub 认证。但它只支持基于密钥的认证,不支持 Entra ID、托管身份及其他身份提供方。
这个 SDK 支持哪些认证方式?支持以下几种:GitHub 已登录用户(使用 Copilot CLI 登录时保存的 OAuth 凭据)、带用户令牌的 OAuth GitHub App 流程、GITHUBTOKEN 等环境变量,或使用服务商 API 密钥的 BYOK(无需 GitHub 认证)。
我能控制智能体可以使用哪些工具吗?可以。SDK 默认开放 Copilot CLI 的官方工具(相当于使用 --allow-all 运行)。权限处理程序可以让你的应用批准、拒绝或自定义每一次工具调用,客户端选项则可以启用或禁用特定工具。
这个能用于正式生产环境吗?可以。该 SDK 已正式发布,遵循语义化版本规范,并通过 CHANGELOG.md 记录发布说明。
除了官方的六种语言,还有其他语言的 SDK 吗?有。Clojure 和 C++ 有非官方的、由社区维护的 SDK,但 GitHub 明确表示不支持,也不为其背书。
它属于哪些主题?byok, github-copilot, dotnet, oauth, github, java, sdk, coding-agent, go, rust, agent, api
作者
microsoft
大小
73.3 MB
星标
10.7K
时长
10个月
提交 · 90 天