Loading...
Loading...
Compare original and translation side by side
copilot --versioncopilot --version| Language | Command |
|---|---|
| TypeScript/Node.js | |
| Python | |
| Go | |
| .NET | |
| 语言 | 命令 |
|---|---|
| TypeScript/Node.js | |
| Python | |
| Go | |
| .NET | |
Application → SDK Client → JSON-RPC → Copilot CLI (server mode)cliUrlcli_urlApplication → SDK Client → JSON-RPC → Copilot CLI (server mode)cliUrlcli_urlimport { 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();send()references/working-examples.mdimport { 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();send()references/working-examples.mdstart()stop()createSession()resumeSession()cliPathcliUrlportuseStdioautoStartautoRestartstart()stop()createSession()resumeSession()cliPathcliUrlportuseStdioautoStartautoRestartsend()sendAndWait()on()abort()getMessages()destroy()modelstreamingtoolssystemMessagesend()sendAndWait()on()abort()getMessages()destroy()modelstreamingtoolssystemMessage| Event | Purpose |
|---|---|
| Complete response |
| Streaming chunk |
| Ready for next prompt |
| Tool invocations |
references/event-system.md| 事件 | 用途 |
|---|---|
| 完整响应 |
| 流式响应片段 |
| 准备好接收下一个提示 |
| 工具调用 |
references/event-system.mdstreaming: falsestreaming: trueassistant.message_deltaassistant.messagestreaming: falsestreaming: trueassistant.message_deltaassistant.message| Provider | Model ID | Notes |
|---|---|---|
| OpenAI | | Included |
| OpenAI | | Premium |
| Anthropic | | Premium (CLI default) |
| Anthropic | | Premium (3× multiplier) |
| Premium |
| 提供商 | 模型ID | 说明 |
|---|---|---|
| OpenAI | | 包含在订阅内 |
| OpenAI | | 高级版 |
| Anthropic | | 高级版(CLI默认) |
| Anthropic | | 高级版(3倍倍率) |
| 高级版 |
const tool = defineTool("lookup_issue", {
description: "Fetch issue details",
parameters: z.object({ id: z.string() }),
handler: async ({ id }) => fetchIssue(id),
});@define_tool(description="Fetch issue details")
async def lookup_issue(params: IssueParams) -> dict:
return fetch_issue(params.id)references/working-examples.mdconst tool = defineTool("lookup_issue", {
description: "Fetch issue details",
parameters: z.object({ id: z.string() }),
handler: async ({ id }) => fetchIssue(id),
});@define_tool(description="Fetch issue details")
async def lookup_issue(params: IssueParams) -> dict:
return fetch_issue(params.id)references/working-examples.md| Concept | TypeScript | Python | Go | .NET |
|---|---|---|---|---|
| Create session | | | | |
| Delta content | | | | |
references/event-system.md| 概念 | TypeScript | Python | Go | .NET |
|---|---|---|---|---|
| 创建会话 | | | | |
| 增量内容 | | | | |
references/event-system.md~/.copilot/config.jsonmcp-config.jsonreferences/cli-agents-mcp.md~/.copilot/config.jsonmcp-config.jsonreferences/cli-agents-mcp.md| Problem | Solution |
|---|---|
| Events fire but content empty | Use |
| Handler never fires | Register before |
| Python enum issues | Use |
| Go nil pointer | Check |
references/troubleshooting.md| 问题 | 解决方案 |
|---|---|
| 事件触发但内容为空 | 使用 |
| 处理程序从未触发 | 在调用 |
| Python枚举问题 | 使用 |
| Go空指针问题 | 解引用前检查 |
references/troubleshooting.mdreferences/working-examples.mdreferences/event-system.mdreferences/troubleshooting.mdreferences/cli-agents-mcp.mdreferences/working-examples.mdreferences/event-system.mdreferences/troubleshooting.mdreferences/cli-agents-mcp.md