npx skills add https://github.com/doggy8088/agent-skills --skill copilot-sdkGitHub Copilot SDK 是一个多平台代理运行时,可将 Copilot 的代理工作流嵌入到应用程序中。它公开了 Copilot CLI 背后的相同引擎,无需开发自定义编排即可进行编程式调用。
状态: 技术预览版(适用于开发和测试)
支持的语言: TypeScript/Node.js、Python、Go、.NET
The GitHub Copilot SDK is a multi-platform agent runtime that embeds Copilot's agentic workflows into applications. It exposes the same engine behind Copilot CLI, enabling programmatic invocation without requiring custom orchestration development.
Status: Technical Preview (suitable for development and testing)
Supported Languages: TypeScript/Node.js, Python, Go, .NET
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
copilot --version)| 语言 | 命令 |
|---|---|
| TypeScript/Node.js | npm install @github/copilot-sdk |
| Python | pip install github-copilot-sdk |
| Go | go get github.com/github/copilot-sdk/go |
| .NET | dotnet add package GitHub.Copilot.SDK |
Application → SDK Client → JSON-RPC → Copilot CLI (server mode)
SDK 自动管理 CLI 生命周期。支持通过 cliUrl / cli_url 进行外部服务器连接。
import { CopilotClient } from "@github/copilot-sdk";
const client = new CopilotClient();
await client.start();
const session = await client.createSession({ model: "gpt-5" });
// 在 send() 之前注册处理程序
session.on((event) => {
if (event.type === "assistant.message") {
console.log(event.data.content);
}
});
await session.send({ prompt: "What is 2 + 2?" });
await session.destroy();
await client.stop();
关键点: 在调用 send() 之前 注册事件处理程序,以捕获所有事件。
有关所有语言的完整示例,请参阅 references/working-examples.md。
主要入口点。管理 CLI 服务器生命周期和会话创建。
操作: start()、stop()、createSession()、resumeSession()
配置: cliPath、cliUrl、port、useStdio、autoStart、autoRestart
包含消息历史的独立对话上下文。
操作: send()、sendAndWait()、on()、abort()、getMessages()、destroy()
配置: model、streaming、tools、systemMessage
处理过程中的关键事件:
| 事件 | 用途 |
|---|---|
assistant.message | 完整响应 |
assistant.message_delta | 流式传输片段 |
session.idle | 准备接收下一个提示 |
tool.execution_start/end | 工具调用 |
有关完整的事件生命周期和 SessionEvent 结构,请参阅 references/event-system.md。
streaming: false (默认) - 内容一次性到达streaming: true - 内容通过 assistant.message_delta 增量到达无论流式传输设置如何,最终的 assistant.message 事件 总会触发。
完整列表请参阅 支持的 AI 模型。
| 提供商 | 模型 ID | 备注 |
|---|---|---|
| OpenAI | gpt-4.1, gpt-5, gpt-5-mini | 已包含 |
| OpenAI | gpt-5.1, gpt-5.1-codex, gpt-5.2 | 高级版 |
| Anthropic | claude-sonnet-4.5 | 高级版 (CLI 默认) |
| Anthropic | claude-opus-4.5 | 高级版 (3 倍乘数) |
gemini-3-pro-preview | 高级版 |
TypeScript (Zod):
const tool = defineTool("lookup_issue", {
description: "Fetch issue details",
parameters: z.object({ id: z.string() }),
handler: async ({ id }) => fetchIssue(id),
});
Python (Pydantic):
@define_tool(description="Fetch issue details")
async def lookup_issue(params: IssueParams) -> dict:
return fetch_issue(params.id)
有关所有语言的完整工具示例,请参阅 references/working-examples.md。
| 概念 | TypeScript | Python | Go | .NET |
|---|---|---|---|---|
| 创建会话 | createSession() | create_session() | CreateSession() | CreateSessionAsync() |
| 增量内容 | deltaContent | delta_content | DeltaContent | DeltaContent |
完整的约定表格,请参阅 references/event-system.md。
配置存储在 ~/.copilot/ 目录下:
config.json - 通用配置mcp-config.json - MCP 服务器定义有关自定义代理和 MCP 设置,请参阅 references/cli-agents-mcp.md。
| 问题 | 解决方案 |
|---|---|
| 事件触发但内容为空 | 使用 event.data.content,而不是 event.content |
| 处理程序从未触发 | 在 send() 之前 注册 |
| Python 枚举问题 | 使用 event.type.value |
| Go 空指针 | 在解引用前检查 != nil |
调试技巧,请参阅 references/troubleshooting.md。
本技能中的详细文档:
references/working-examples.md - 所有语言的完整示例,自定义工具references/event-system.md - 事件生命周期、SessionEvent 结构、语言约定references/troubleshooting.md - 常见问题、调试技巧references/cli-agents-mcp.md - CLI 配置、自定义代理、MCP 服务器设置每周安装量
204
仓库
首次出现
2026 年 1 月 29 日
安全审计
安装于
github-copilot198
gemini-cli98
codex88
opencode55
claude-code40
antigravity39
copilot --version)| Language | Command |
|---|---|
| TypeScript/Node.js | npm install @github/copilot-sdk |
| Python | pip install github-copilot-sdk |
| Go | go get github.com/github/copilot-sdk/go |
| .NET | dotnet add package GitHub.Copilot.SDK |
Application → SDK Client → JSON-RPC → Copilot CLI (server mode)
The SDK manages CLI lifecycle automatically. External server connections supported via cliUrl / cli_url.
import { CopilotClient } from "@github/copilot-sdk";
const client = new CopilotClient();
await client.start();
const session = await client.createSession({ model: "gpt-5" });
// Register handler BEFORE send()
session.on((event) => {
if (event.type === "assistant.message") {
console.log(event.data.content);
}
});
await session.send({ prompt: "What is 2 + 2?" });
await session.destroy();
await client.stop();
Critical: Register event handlers before calling send() to capture all events.
For complete examples in all languages, see references/working-examples.md.
Main entry point. Manages CLI server lifecycle and session creation.
Operations: start(), stop(), createSession(), resumeSession()
Config: cliPath, cliUrl, port, useStdio, autoStart, autoRestart
Individual conversation context with message history.
Operations: send(), sendAndWait(), on(), abort(), getMessages(), destroy()
Config: model, streaming, tools, systemMessage
Key events during processing:
| Event | Purpose |
|---|---|
assistant.message | Complete response |
assistant.message_delta | Streaming chunk |
session.idle | Ready for next prompt |
tool.execution_start/end | Tool invocations |
For full event lifecycle and SessionEvent structure, see references/event-system.md.
streaming: false (default) - Content arrives all at oncestreaming: true - Content arrives incrementally via assistant.message_deltaFinal assistant.message always fires regardless of streaming setting.
See Supported AI Models for full list.
| Provider | Model ID | Notes |
|---|---|---|
| OpenAI | gpt-4.1, gpt-5, gpt-5-mini | Included |
| OpenAI | gpt-5.1, gpt-5.1-codex, gpt-5.2 | Premium |
| Anthropic | claude-sonnet-4.5 | Premium (CLI default) |
| Anthropic | claude-opus-4.5 | Premium (3× multiplier) |
gemini-3-pro-preview | Premium |
TypeScript (Zod):
const tool = defineTool("lookup_issue", {
description: "Fetch issue details",
parameters: z.object({ id: z.string() }),
handler: async ({ id }) => fetchIssue(id),
});
Python (Pydantic):
@define_tool(description="Fetch issue details")
async def lookup_issue(params: IssueParams) -> dict:
return fetch_issue(params.id)
For complete tool examples in all languages, see references/working-examples.md.
| Concept | TypeScript | Python | Go | .NET |
|---|---|---|---|---|
| Create session | createSession() | create_session() | CreateSession() | CreateSessionAsync() |
| Delta content | deltaContent | delta_content | DeltaContent | DeltaContent |
For full conventions table, see references/event-system.md.
Config stored in ~/.copilot/:
config.json - General configurationmcp-config.json - MCP server definitionsFor custom agents and MCP setup, see references/cli-agents-mcp.md.
| Problem | Solution |
|---|---|
| Events fire but content empty | Use event.data.content, not event.content |
| Handler never fires | Register before send() |
| Python enum issues | Use event.type.value |
| Go nil pointer | Check != nil before dereferencing |
For debugging techniques, see references/troubleshooting.md.
Detailed documentation in this skill:
references/working-examples.md - Complete examples for all languages, custom toolsreferences/event-system.md - Event lifecycle, SessionEvent structure, language conventionsreferences/troubleshooting.md - Common issues, debugging techniquesreferences/cli-agents-mcp.md - CLI configuration, custom agents, MCP server setupWeekly Installs
204
Repository
First Seen
Jan 29, 2026
Security Audits
Installed on
github-copilot198
gemini-cli98
codex88
opencode55
claude-code40
antigravity39
agent-browser 浏览器自动化工具 - Vercel Labs 命令行网页操作与测试
150,000 周安装