Skip to main content

SDK and CLI compatibility

Compare which Copilot CLI features are available through 코필로트 SDK, identify CLI-only features, and find programmatic workarounds.

누가 이 기능을 사용할 수 있나요?

GitHub Copilot SDK 는 모든 Copilot 계획에서 사용할 수 있습니다.

참고

코필로트 SDK가 현재 기술 미리 보기에 있습니다. 기능 및 가용성은 변경될 수 있습니다.

GitHub Copilot SDK communicates with GitHub Copilot 명령 줄 인터페이스 (CLI) via JSON-RPC protocol. Features must be explicitly exposed through this protocol to be available in the SDK. Many interactive CLI features are terminal-specific and not available programmatically.

Feature comparison

Available in SDK

FeatureSDK methodNotes
Session Management
Create sessioncreateSession()Full config support
Resume sessionresumeSession()With infinite session workspaces
Disconnect sessiondisconnect()Release in-memory resources
Destroy sessiondestroy()Use disconnect() instead
Delete sessiondeleteSession()Remove from storage
List sessionslistSessions()All stored sessions
Get last sessiongetLastSessionId()For quick resume
Get foreground sessiongetForegroundSessionId()Multi-session coordination
Set foreground sessionsetForegroundSessionId()Multi-session coordination
Messaging
Send messagesend()With attachments
Send and waitsendAndWait()Blocks until complete
Steering (immediate mode)send({ mode: "immediate" })Inject mid-turn without aborting
Queueing (enqueue mode)send({ mode: "enqueue" })Buffer for sequential processing (default)
File attachmentssend({ attachments: [{ type: "file", path }] })Images auto-encoded and resized
Directory attachmentssend({ attachments: [{ type: "directory", path }] })Attach directory context
Get historygetMessages()All session events
Abortabort()Cancel in-flight request
Tools
Register custom toolsregisterTools()Full JSON Schema support
Tool permission controlonPreToolUse hookAllow/deny/ask
Tool result modificationonPostToolUse hookTransform results
Available/excluded toolsavailableTools, excludedTools configFilter tools
Models
List modelslistModels()With capabilities, billing, policy
Set model (at creation)model in session configPer-session
Switch model (mid-session)session.setModel()Also via session.rpc.model.switchTo()
Get current modelsession.rpc.model.getCurrent()Query active model
Reasoning effortreasoningEffort configFor supported models
Agent Mode
Get current modesession.rpc.mode.get()Returns current mode
Set modesession.rpc.mode.set()Switch between modes
Plan Management
Read plansession.rpc.plan.read()Get plan.md content and path
Update plansession.rpc.plan.update()Write plan.md content
Delete plansession.rpc.plan.delete()Remove plan.md
Workspace Files
List workspace filessession.rpc.workspace.listFiles()Files in session workspace
Read workspace filesession.rpc.workspace.readFile()Read file content
Create workspace filesession.rpc.workspace.createFile()Create file in workspace
Authentication
Get auth statusgetAuthStatus()Check login state
Use tokengithubToken optionProgrammatic auth
Connectivity
Pingclient.ping()Health check with server timestamp
Get server statusclient.getStatus()Protocol version and server info
MCP Servers
Local/stdio serversmcpServers configSpawn processes
Remote HTTP/SSEmcpServers configConnect to services
Hooks
Pre-tool useonPreToolUsePermission, modify args
Post-tool useonPostToolUseModify results
User promptonUserPromptSubmittedModify prompts
Session start/endonSessionStart, onSessionEndLifecycle with source/reason
Error handlingonErrorOccurredCustom handling
Events
All session eventson(), once()40+ event types
Streamingstreaming: trueDelta events
Session Config
Custom agentscustomAgents configDefine specialized agents
System messagesystemMessage configAppend or replace
Custom providerprovider configBYOK support
Infinite sessionsinfiniteSessions configAuto-compaction
Permission handleronPermissionRequestApprove/deny requests
User input handleronUserInputRequestHandle ask_user
SkillsskillDirectories configCustom skills
Disabled skillsdisabledSkills configDisable specific skills
Config directoryconfigDir configOverride default config location
Client nameclientName configIdentify app in User-Agent
Working directoryworkingDirectory configSet session cwd
Experimental
Agent managementsession.rpc.agent.*List, select, deselect, get current agent
Fleet modesession.rpc.fleet.start()Parallel sub-agent execution
Manual compactionsession.rpc.compaction.compact()Trigger compaction on demand

Not available in SDK (CLI-only)

FeatureCLI command/optionReason
Session Export
Export to file--share, /shareNot in protocol
Export to gist--share-gist, /share gistNot in protocol
Interactive UI
Slash commands/help, /clear, /exit, etc.Terminal UI (TUI)-only
Agent picker dialog/agentInteractive UI
Diff mode dialog/diffInteractive UI
Feedback dialog/feedbackInteractive UI
Theme picker/themeTerminal UI
Model picker/modelInteractive UI (use SDK setModel() instead)
Copy to clipboard/copyTerminal-specific
Context management/contextInteractive UI
Research & History
Deep research/researchTUI workflow with web search
Session history tools/chronicleStandup, tips, improve, reindex
Terminal Features
Color output--no-colorTerminal-specific
Screen reader mode--screen-readerAccessibility
Rich diff rendering--plain-diffTerminal rendering
Startup banner--bannerVisual element
Streamer mode/streamer-modeTUI display mode
Alternate screen buffer--alt-screen, --no-alt-screenTerminal rendering
Mouse support--mouse, --no-mouseTerminal input
Path/Permission Shortcuts
Allow all paths--allow-all-pathsUse permission handler
Allow all URLs--allow-all-urlsUse permission handler
Allow all permissions--yolo, --allow-all, /allow-allUse permission handler
Granular tool permissions--allow-tool, --deny-toolUse onPreToolUse hook
URL access control--allow-url, --deny-urlUse permission handler
Reset allowed tools/reset-allowed-toolsTUI command
Directory Management
Add directory/add-dir, --add-dirConfigure in session
List directories/list-dirsTUI command
Change directory/cwdTUI command
Plugin/MCP Management
Plugin commands/pluginInteractive management
MCP server management/mcpInteractive UI
Account Management
Login flow/login, copilot auth loginOAuth device flow
Logout/logout, copilot auth logoutDirect CLI
User info/userTUI command
Session Operations
Clear conversation/clearTUI-only
Plan view/planTUI-only (use SDK session.rpc.plan.* instead)
Session management/session, /resume, /renameTUI workflow
Fleet mode (interactive)/fleetTUI-only (use SDK session.rpc.fleet.start() instead)
Skills Management
Manage skills/skillsInteractive UI
Task Management
View background tasks/tasksTUI command
Usage & Stats
Token usage/usageSubscribe to usage events
Code Review
Review changes/reviewTUI command
Delegation
Delegate to PR/delegateTUI workflow
Terminal Setup
Shell integration/terminal-setupShell-specific
Development
Toggle experimental/experimental, --experimentalRuntime flag
Custom instructions control--no-custom-instructionsCLI flag
Diagnose session/diagnoseTUI command
View/manage instructions/instructionsTUI command
Collect debug logs/collect-debug-logsDiagnostic tool
Reindex workspace/reindexTUI command
IDE integration/ideIDE-specific workflow
Non-interactive Mode
Prompt mode-p, --promptSingle-shot execution
Interactive prompt-i, --interactiveAuto-execute then interactive
Silent output-s, --silentScript-friendly
Continue session--continueResume most recent
Agent selection--agent <agent>CLI flag

Workarounds

Session export

The --share option is not available via SDK. To work around this:

  • Collect events manually: Subscribe to session events and build your own export:

    TypeScript
    const events: SessionEvent[] = [];
    session.on((event) => events.push(event));
    // ... after conversation ...
    const messages = await session.getMessages();
    // Format as markdown yourself
    
  • Use the CLI directly for one-off exports.

Permission control

The SDK uses a deny-by-default permission model. All permission requests (file writes, shell commands, URL fetches, and others) are denied unless your app provides an onPermissionRequest handler.

Instead of --allow-all-paths or --yolo, use the permission handler:

TypeScript
const session = await client.createSession({
  onPermissionRequest: approveAll,
});

Token usage tracking

Instead of /usage, subscribe to usage events:

TypeScript
session.on("assistant.usage", (event) => {
  console.log("Tokens used:", {
    input: event.data.inputTokens,
    output: event.data.outputTokens,
  });
});

Context compaction

Instead of /compact, configure automatic compaction or trigger it manually:

TypeScript
// Automatic compaction via config
const session = await client.createSession({
  infiniteSessions: {
    enabled: true,
    backgroundCompactionThreshold: 0.80,  // Start background compaction at 80% context utilization
    bufferExhaustionThreshold: 0.95,      // Block and compact at 95% context utilization
  },
});

// Manual compaction (experimental)
const result = await session.rpc.compaction.compact();
console.log(`Removed ${result.tokensRemoved} tokens, ${result.messagesRemoved} messages`);

참고

Thresholds are context utilization ratios (0.0-1.0), not absolute token counts.

Plan management

Read and write session plans programmatically:

TypeScript
// Read the current plan
const plan = await session.rpc.plan.read();
if (plan.exists) {
  console.log(plan.content);
}

// Update the plan
await session.rpc.plan.update({ content: "# My Plan\n- Step 1\n- Step 2" });

// Delete the plan
await session.rpc.plan.delete();

Message steering

Inject a message into the current LLM turn without aborting:

TypeScript
// Steer the agent mid-turn
await session.send({ prompt: "Focus on error handling first", mode: "immediate" });

// Default: enqueue for next turn
await session.send({ prompt: "Next, add tests" });

Protocol limitations

The SDK can only access features exposed through the CLI's JSON-RPC protocol. If you need a CLI feature that's not available:

  • Check for alternatives: Many features have SDK equivalents (see Workarounds above).
  • Use the CLI directly: For one-off operations, invoke the CLI.
  • Request the feature: Open an issue in the github/copilot-sdk repository to request protocol support.

Version compatibility

SDK protocol rangeCLI protocol versionCompatibility
v2-v3v3Full support
v2-v3v2Supported with automatic v2 adapters

The SDK negotiates protocol versions with the CLI at startup. The SDK supports protocol versions 2 through 3. When connecting to a v2 CLI server, the SDK automatically adapts tool.call and permission.request messages to the v3 event model—no code changes required.

You can check versions at runtime:

TypeScript
const status = await client.getStatus();
console.log("Protocol version:", status.protocolVersion);