Token导航 LogoToken导航TokenDH.com
研究检索执行命令github未标认证来源可访问clear审计提醒

copilot-sdkGitHub Copilot SDK 测试

Agent Skill

copilot-sdk 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

7,268

周安装

309

GitHub Stars

253

下载量

2,546
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:copilot-sdk(GitHub Copilot SDK 测试)
来源仓库:https://github.com/intellectronica/agent-skills
仓库路径:skills/copilot-sdk
安装命令:
npx skills add https://github.com/intellectronica/agent-skills --skill copilot-sdk
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/intellectronica/agent-skills --skill copilot-sdk

简介

用于查找、检索和筛选相关信息。适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

  • 适合根据关键词、任务场景或来源线索快速定位候选结果。
  • 可结合来源仓库和原始 README 核验具体用法。
  • 安装前建议确认权限范围、维护状态及是否会触发联网或文件读写。
  • copilot-sdk 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

GitHub Copilot SDK

Overview

The GitHub Copilot SDK exposes the same Copilot CLI agent runtime over JSON-RPC, so apps can drive Copilot programmatically instead of building their own orchestration layer.

Status: Public preview SDKs: Node.js/TypeScript, Python, Go,.NET, Java Architecture: Application -> SDK client -> JSON-RPC -> Copilot CLI

How to use this skill

When helping with the Copilot SDK:

  1. Prefer the official docs index and the language-specific README over memory.
  2. Treat the top-level SDK README plus docs/ as the source of truth for shared behavior.
  3. Call out preview status when stability or breaking changes matter.
  4. Avoid hardcoding model lists when runtime discovery via listModels() is available.
  5. Watch for stale guidance around permissions, lifecycle methods, and event names.

Current source of truth

Core SDK docs

Language-specific docs

Copilot CLI and GitHub Docs

Recipes and examples


High-value facts

Authentication and prerequisites

  • A GitHub Copilot subscription is required for normal SDK use.
  • BYOK is supported and does not require GitHub Copilot authentication.
  • Node.js, Python, and.NET bundle the Copilot CLI automatically.
  • Go can use an installed CLI or embed/bundle one with the go tool bundler workflow.
  • Java currently lives in github/copilot-sdk-java and expects the CLI to be installed separately.
  • Azure Managed Identity / Entra auth is supported as a documented BYOK pattern by passing short-lived bearer tokens from DefaultAzureCredential.

Permissions

  • The SDK uses a deny-by-default permission model.
  • In practice, create/resume flows should provide an explicit permission handler such as:

- TypeScript: approveAll - Python: PermissionHandler.approve_all - Go: copilot.PermissionHandler.ApproveAll - .NET: PermissionHandler.ApproveAll - Java: PermissionHandler.APPROVE_ALL

Session lifecycle

  • Preferred cleanup method: disconnect()
  • Deprecated cleanup method: destroy()
  • To resume sessions reliably, provide your own sessionId when creating them.
  • BYOK provider configuration must be provided again when resuming because keys are not persisted.

Transport and deployment

  • Default transport is stdio with an SDK-managed CLI process.
  • You can connect to an external headless CLI server via cliUrl.
  • Current external server docs use:
copilot --headless --port 4321

Models

  • Do not hardcode model support unless the user specifically needs a fixed list.
  • Prefer client.listModels() and the official supported-models page.
  • reasoningEffort exists for models that support it.

Installation

SDKInstall
Node.js / TypeScriptnpm install @github/copilot-sdk
Pythonpip install github-copilot-sdk
Gogo get github.com/github/copilot-sdk/go
.NETdotnet add package GitHub.Copilot.SDK
JavaMaven/Gradle package com.github:copilot-sdk-java

Setup and deployment choices

Pick the setup that matches the application shape:

  • Local CLI - simplest path for personal tools and development.
  • Bundled CLI - ship a CLI binary with your app for desktop/distributable tooling.
  • Backend services - run the CLI in headless mode and connect with cliUrl.
  • Scaling and multi-tenancy - shared CLI vs CLI-per-user, shared storage, and session locking.
  • Azure Managed Identity - use BYOK with short-lived bearer tokens instead of static API keys when Azure auth is the real requirement.

Quick start pattern

Use the same mental model in every language:

  1. Create/start the client.
  2. Create a session with a permission handler.
  3. Register event handlers before send() if you need streaming or progress.
  4. Send with send() or sendAndWait().
  5. Wait for session.idle or the returned final message.
  6. disconnect() the session and stop/dispose the client.

TypeScript example

import { CopilotClient, approveAll } from "@github/copilot-sdk";

const client = new CopilotClient();
await client.start();

const session = await client.createSession({
  model: "gpt-5",
  streaming: true,
  onPermissionRequest: approveAll,
});

session.on("assistant.message_delta", (event) => {
  process.stdout.write(event.data.deltaContent ?? "");
});

await session.sendAndWait({ prompt: "What is 2+2?" });

await session.disconnect();
await client.stop();

Core capabilities to remember

Client and session APIs

Common operations across SDKs:

  • Client lifecycle: start(), stop(), forceStop()
  • Session lifecycle: createSession(), resumeSession(), disconnect()
  • Messaging: send(), sendAndWait(), abort(), getMessages()
  • Discovery: listModels(), listSessions(), getStatus() / ping()

Events and streaming

  • Final assistant output arrives in assistant.message.
  • Streaming text arrives in assistant.message_delta.
  • session.idle is the reliable "turn complete" signal.
  • The event system now includes reasoning, tool progress, permission, elicitation, sub-agent, and skill events.

See references/event-system.md.

Custom tools

  • Node uses defineTool(...) with Zod or raw JSON Schema.
  • Python uses @define_tool with Pydantic models.
  • Go prefers DefineTool(...).
  • .NET uses AIFunctionFactory.Create(...).
  • Overriding built-ins always requires explicit opt-in:

- TypeScript: overridesBuiltInTool: true - Python: overrides_built_in_tool=True - Go: OverridesBuiltInTool = true - .NET: AdditionalProperties["is_override"] = true

  • Custom tools can also opt into skipPermission.

Custom agents, MCP, hooks, and skills

  • customAgents lets you define sub-agents per session.
  • mcpServers attaches local or remote MCP servers.
  • Hooks provide control points such as onPreToolUse, onPostToolUse, onUserPromptSubmitted, and lifecycle/error hooks.
  • Skills are loaded with skillDirectories; disable selectively with disabledSkills.

See references/cli-agents-mcp.md.

Attachments, commands, and interaction

  • Sessions can send file, directory, and image attachments.
  • Image input supports both file and blob attachments, and vision should be checked through model capabilities.
  • In-flight messaging supports mode: "immediate" for steering and mode: "enqueue" for queueing.
  • The SDK can register custom slash commands.
  • Apps can answer user questions with onUserInputRequest.
  • Rich UI prompts are available through elicitation handlers and session.ui when the connected client supports them.

Telemetry and observability

  • The SDK supports OpenTelemetry configuration through TelemetryConfig.
  • Trace context propagation is built in, with Node using an explicit onGetTraceContext callback for outbound propagation.

Persistence and long-running work

  • Use a stable sessionId for resumable sessions.
  • Use infiniteSessions for long-running workflows that may need compaction.
  • Session state is stored under ~/.copilot/session-state/ unless configuration overrides it.

SDK vs. CLI-only features

  • The SDK exposes programmatic surfaces for sessions, models, plans, mode switching, workspace files, custom agents, hooks, MCP, skills, and telemetry.
  • Many terminal UX features remain CLI-only, such as most slash-command workflows, interactive pickers, and export/share commands.
  • When translating a CLI workflow into app code, check the compatibility guide before assuming a slash command has an SDK equivalent.

Language conventions

ConceptTypeScriptPythonGo.NETJava
Create sessioncreateSession()create_session()CreateSession()CreateSessionAsync()createSession()
Resume sessionresumeSession()resume_session()ResumeSession()ResumeSessionAsync()resumeSession()
Final contentevent.data.contentevent.data.content*event.Data.Contentevt.Data.Contentevent.getData().content()
Delta contentevent.data.deltaContentevent.data.delta_content*event.Data.DeltaContentevt.Data.DeltaContentevent.getData().deltaContent()
Skills fieldskillDirectoriesskill_directoriesSkillDirectoriesSkillDirectoriessetSkillDirectories(...)

Common gotchas

  • The SDK is public preview, so older examples drift quickly.
  • Hardcoded model tables get stale; prefer runtime discovery.
  • destroy() still appears in older examples but disconnect() is the current method.
  • A missing permission handler causes confusion fast; treat it as required for real sessions.
  • assistant.message and assistant.message_delta use event.data.*, not top-level event.content.
  • Streaming/event subscriptions should be attached before send().
  • Session resumption without a caller-provided sessionId is awkward to operationalize.

Local reference files in this skill

  • references/working-examples.md - current starter examples, including tools and resume patterns
  • references/event-system.md - event names, lifecycle, and language access patterns
  • references/cli-agents-mcp.md - custom agents, skills, MCP, headless CLI, and config locations
  • references/troubleshooting.md - common failures, debug logging, auth, permissions, and transport issues

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

25.59%
按下载量换算652

github-copilot

24.82%
按下载量换算632

Codex

16.99%
按下载量换算433

OpenCode

12.76%
按下载量换算325

Gemini CLI

8.28%
按下载量换算211

Antigravity

3.24%
按下载量换算82

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

执行命令

安装流程涉及命令执行,可能通过 npx skills add https://github.com/intellectronica/agent-skills --skill copilot-sdk;npx skills add intellectronica/agent-skills --skill "copilot-sdk" 联网下载 Skill 或依赖。用户安装前应确认命令来源、仓库内容和执行环境。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。

来源信息

继续浏览同类 Skills