copilot-sdk-nodejs
БесплатноБез исполняемых скриптовНе проверенThis file provides guidance on building Node.js/TypeScript applications using GitHub Copilot SDK. Triggers on: **.ts, **.js, package.json
от diegosouzapw★ 68 звёзд на GitHubОб этом скилле
Core Principles
- The SDK is in technical preview and may have breaking changes
- Requires Node.js 18.0 or later
- Requires GitHub Copilot CLI installed and in PATH
- Built with TypeScript for type safety
- Uses async/await patterns throughout
- Provides full TypeScript type definitions
Installation
Always install via npm/pnpm/yarn:
npm install @github/copilot-sdk
# or
pnpm add @github/copilot-sdk
# or
yarn add @github/copilot-sdk
Client Initialization
Basic Client Setup
import { CopilotClient } from "@github/copilot-sdk";
const client = new CopilotClient();
await client.start();
// Use client...
await client.stop();
Client Configuration Options
When creating a CopilotClient, use CopilotClientOptions:
cliPath- Path to CLI executable (default: "copilot" from PATH)cliArgs- Extra arguments prepended before SDK-managed flags (string[])cliUrl- URL of existing CLI server (e.g., "localhost:8080"). When provided, client won't spawn a processport- Server port (default: 0 for random)useStdio- Use stdio transport instead of TCP (default: true)logLevel- Log level (default: "debug")autoStart- Auto-start server (default: true)autoRestart- Auto-restart on crash (default: true)cwd- Working directory for the CLI process (default: process.cwd())env- Environment variables for the CLI process (default: process.env)
Manual Server Control
For explicit control:
const client = new CopilotClient({ autoStart: false });
await client.start();
// Use client...
await client.stop();
Use forceStop() when stop() takes too long.
Session Management
Creating Sessions
Use SessionConfig for configuration:
const session = await client.createSession({
model: "gpt-5",
streaming: true,
tools: [...],
systemMessage: { ... },
availableTools: ["tool1", "tool2"],
excludedTools: ["tool3"],
provider: { ... }
});
Session Config Options
sessionId- Custom session ID (string)model- Model name ("gpt-5", "claude-sonnet-4.5", etc.)tools- Custom tools exposed to the CLI (Tool[])systemMessage- System message customization (SystemMessageConfig)availableTools- Allowlist of tool names (string[])excludedTools- Blocklist of tool names (string[])provider- Custom API provider configuration (BYOK) (ProviderConfig)streaming- Enable streaming response chunks (boolean)mcpServers- MCP server configurations (MCPServerConfig[])customAgents- Custom agent configurations (CustomAgentConfig[])configDir- Config directory override (string)skillDirectories- Skill directories (string[])disabledSkills- Disabled skills (string[])onPermissionRequest- Permission request handler (PermissionHandler)
Resuming Sessions
const session = await client.resumeSession("session-id", {
tools: [myNewTool],
});
Session Operations
session.sessionId- Get session identifier (string)await session.send({ prompt: "...", attachments: [...] })- Send message, returns Promiseawait session.sendAndWait({ prompt: "..." }, timeout)- Send and wait for idle, returns Promise<AssistantMessageEvent | null>await session.abort()- Abort current processingawait session.getMessages()- Get all events/messages, returns Promise<SessionEvent[]>await session.destroy()- Clean up session
Event Handling
Event Subscription Pattern
ALWAYS use async/await or Promises for waiting on session events:
await new Promise<void>((resolve) => {
session.on((event) => {
if (event.type === "assistant.message") {
console.log(event.data.content);
} else if (event.type === "session.idle") {
resolve();
}
});
session.send({ prompt: "..." });
});
Unsubscribing from Events
The on() method returns a function that unsubscribes:
const unsubscribe = session.on((event) => {
// handler
});
// Later...
unsubscribe();
Event Types
Use discriminated unions with type guards for event handling:
session.on((event) => {
switch (event.type) {
case "user.message":
// Handle user message
break;
case "assistant.message":
console.log(event.data.content);
break;
case "tool.executionStart":
// Tool execution started
break;
case "tool.executionComplete":
// Tool execution completed
break;
case "session.start":
// Session started
break;
case "session.idle":
// Session is idle (processing complete)
break;
case "session.error":
console.error(`Error: ${event.data.message}`);
break;
}
});
Streaming Responses
Enabling Streaming
Set streaming: true in SessionConfig:
const session = await client.createSession({
model: "gpt-5",
streaming: true,
});
Handling
Установить copilot-sdk-nodejs в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл copilot-sdk-nodejs?
This file provides guidance on building Node.js/TypeScript applications using GitHub Copilot SDK. Triggers on: **.ts, **.js, package.json
Как установить скилл copilot-sdk-nodejs?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл copilot-sdk-nodejs запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic