@github/copilot-sdk
Advanced tools
@@ -38,4 +38,6 @@ "use strict"; | ||
| const client = new import_client.CopilotClient({ _internalConnection: { kind: "parent-process" } }); | ||
| const { extensionSdkPath: _stripped, ...rest } = config; | ||
| void _stripped; | ||
| return client.resumeSession(sessionId, { | ||
| ...config, | ||
| ...rest, | ||
| onPermissionRequest: config.onPermissionRequest ?? import_types.defaultJoinSessionPermissionHandler, | ||
@@ -42,0 +44,0 @@ suppressResumeEvent: config.suppressResumeEvent ?? true |
+5
-1
@@ -771,2 +771,3 @@ import { spawn } from "node:child_process"; | ||
| reasoningSummary: config.reasoningSummary, | ||
| contextTier: config.contextTier, | ||
| tools: config.tools?.map((tool) => ({ | ||
@@ -782,2 +783,3 @@ name: tool.name, | ||
| requestExtensions: config.requestExtensions, | ||
| extensionSdkPath: config.extensionSdkPath, | ||
| extensionInfo: config.extensionInfo, | ||
@@ -934,2 +936,3 @@ commands: config.commands?.map((cmd) => ({ | ||
| reasoningSummary: config.reasoningSummary, | ||
| contextTier: config.contextTier, | ||
| systemMessage: wireSystemMessage, | ||
@@ -950,2 +953,3 @@ availableTools: toolFilterOptions.availableTools, | ||
| requestExtensions: config.requestExtensions, | ||
| extensionSdkPath: config.extensionSdkPath, | ||
| extensionInfo: config.extensionInfo, | ||
@@ -990,3 +994,3 @@ commands: config.commands?.map((cmd) => ({ | ||
| infiniteSessions: config.infiniteSessions, | ||
| suppressResumeEvent: config.suppressResumeEvent, | ||
| disableResume: config.suppressResumeEvent, | ||
| continuePendingWork: config.continuePendingWork, | ||
@@ -993,0 +997,0 @@ gitHubToken: config.gitHubToken, |
| import type { CopilotSession } from "./session.js"; | ||
| import { type ExtensionInfo, type PermissionHandler, type ResumeSessionConfig } from "./types.js"; | ||
| export { Canvas, CanvasError, createCanvas, type CanvasAction, type CanvasDeclaration, type CanvasHostContext, type CanvasJsonSchema, type CanvasOptions, } from "./canvas.js"; | ||
| export type JoinSessionConfig = Omit<ResumeSessionConfig, "onPermissionRequest"> & { | ||
| export type JoinSessionConfig = Omit<ResumeSessionConfig, "onPermissionRequest" | "extensionSdkPath"> & { | ||
| onPermissionRequest?: PermissionHandler; | ||
@@ -6,0 +6,0 @@ }; |
@@ -18,4 +18,6 @@ import { CopilotClient } from "./client.js"; | ||
| const client = new CopilotClient({ _internalConnection: { kind: "parent-process" } }); | ||
| const { extensionSdkPath: _stripped, ...rest } = config; | ||
| void _stripped; | ||
| return client.resumeSession(sessionId, { | ||
| ...config, | ||
| ...rest, | ||
| onPermissionRequest: config.onPermissionRequest ?? defaultJoinSessionPermissionHandler, | ||
@@ -22,0 +24,0 @@ suppressResumeEvent: config.suppressResumeEvent ?? true |
| import { createSessionRpc } from "./generated/rpc.js"; | ||
| import type { OpenCanvasInstance } from "./generated/rpc.js"; | ||
| import type { MessageOptions, ReasoningEffort, ReasoningSummary, ModelCapabilitiesOverride, SessionCapabilities, SessionEvent, SessionEventHandler, SessionEventType, SessionUiApi, TypedSessionEventHandler } from "./types.js"; | ||
| import type { MessageOptions, ContextTier, ReasoningEffort, ReasoningSummary, ModelCapabilitiesOverride, SessionCapabilities, SessionEvent, SessionEventHandler, SessionEventType, SessionUiApi, TypedSessionEventHandler } from "./types.js"; | ||
| /** Assistant message event - the final response from the assistant. */ | ||
@@ -267,2 +267,3 @@ export type AssistantMessageEvent = Extract<SessionEvent, { | ||
| reasoningSummary?: ReasoningSummary; | ||
| contextTier?: ContextTier; | ||
| modelCapabilities?: ModelCapabilitiesOverride; | ||
@@ -269,0 +270,0 @@ }): Promise<void>; |
+7
-4
@@ -161,3 +161,3 @@ # Copilot CLI Extension Examples | ||
| | `onPostToolUseFailure` | After a tool execution returns a failure | Add hidden guidance to the model | | ||
| | `onSessionStart` | Session starts or resumes | Add context, modify config | | ||
| | `onSessionStart` | Session starts or resumes | Add context | | ||
| | `onSessionEnd` | Session ends | Cleanup actions, summary | | ||
@@ -419,3 +419,3 @@ | `onErrorOccurred` | An error occurs | Error handling strategy (retry/skip/abort) | | ||
| | `assistant.message` | Agent's final response | `content`, `messageId`, `toolRequests` | | ||
| | `assistant.streaming_delta` | Token-by-token streaming (ephemeral) | `totalResponseSizeBytes` | | ||
| | `assistant.message_delta` | Message content chunks (ephemeral) | `deltaContent` | | ||
| | `tool.execution_start` | A tool is about to run | `toolCallId`, `toolName`, `arguments` | | ||
@@ -634,4 +634,7 @@ | `tool.execution_complete` | A tool finished running | `toolCallId`, `toolName`, `success`, `result`, `error` | | ||
| const cmd = String(input.toolArgs?.command || ""); | ||
| if (/rm\\s+-rf\\s+\\/ / i.test(cmd) || /Remove-Item\\s+.*-Recurse/i.test(cmd)) { | ||
| return { permissionDecision: "deny" }; | ||
| if (/rm\\s+-rf\\s+\//i.test(cmd) || /Remove-Item\\s+.*-Recurse/i.test(cmd)) { | ||
| return { | ||
| permissionDecision: "deny", | ||
| permissionDecisionReason: "Destructive commands are not allowed.", | ||
| }; | ||
| } | ||
@@ -638,0 +641,0 @@ } |
+3
-3
@@ -7,3 +7,3 @@ { | ||
| }, | ||
| "version": "1.0.0-beta.10", | ||
| "version": "1.0.0-beta.11", | ||
| "description": "TypeScript SDK for programmatic control of GitHub Copilot CLI via JSON-RPC", | ||
@@ -48,3 +48,3 @@ "main": "./dist/cjs/index.js", | ||
| "prepublishOnly": "npm run build", | ||
| "package": "npm run clean && npm run build && node scripts/set-version.js && npm pack && npm version 0.1.0 --no-git-tag-version --allow-same-version" | ||
| "package": "npm run clean && npm run build && node scripts/set-version.js && npm pack && npm version 0.0.0-dev --no-git-tag-version --allow-same-version" | ||
| }, | ||
@@ -61,3 +61,3 @@ "keywords": [ | ||
| "dependencies": { | ||
| "@github/copilot": "^1.0.56-1", | ||
| "@github/copilot": "^1.0.57", | ||
| "vscode-jsonrpc": "^8.2.1", | ||
@@ -64,0 +64,0 @@ "zod": "^4.3.6" |
+12
-8
@@ -5,4 +5,2 @@ # Copilot SDK for Node.js/TypeScript | ||
| > **Note:** This SDK is in public preview and may change in breaking ways. | ||
| ## Installation | ||
@@ -61,3 +59,3 @@ | ||
| Sessions also support `Symbol.asyncDispose` for use with [`await using`](https://github.com/tc39/proposal-explicit-resource-management) (TypeScript 5.2+/Node.js 18.0+): | ||
| Sessions also support `Symbol.asyncDispose` for use with [`await using`](https://github.com/tc39/proposal-explicit-resource-management) (TypeScript 5.2+ / Node.js 20+): | ||
@@ -87,10 +85,16 @@ ```typescript | ||
| - `RuntimeConnection.forTcp({ port?, connectionToken?, path?, args? })` — spawn the runtime as a TCP server. | ||
| - `RuntimeConnection.forUri(url, { connectionToken? })` — connect to an already-running runtime (mutually exclusive with `gitHubToken`/`useLoggedInUser`). | ||
| - `cwd?: string` - Working directory for the runtime process (default: current process cwd). | ||
| - `RuntimeConnection.forUri(url, { connectionToken? })` — connect to an already-running runtime (mutually exclusive with `gitHubToken`/`useLoggedInUser`). There is no top-level `cliUrl` shortcut; use this factory for URL-based connections. | ||
| - `mode?: "empty" | "copilot-cli"` - Defaulting strategy. Use `"empty"` for multi-user server mode; defaults to `"copilot-cli"`. | ||
| - `workingDirectory?: string` - Working directory for the runtime process (default: current process cwd). | ||
| - `baseDirectory?: string` - Base directory for Copilot data (session state, config, etc.). Sets `COPILOT_HOME` on the spawned runtime. When not set, the runtime defaults to `~/.copilot`. Ignored when connecting via `RuntimeConnection.forUri`. | ||
| - `logLevel?: string` - Log level. When omitted, the runtime uses its own default (currently `"info"`). | ||
| - `logLevel?: "none" | "error" | "warning" | "info" | "debug" | "all"` - Log level. When omitted, the runtime uses its own default (currently `"info"`). | ||
| - `env?: Record<string, string | undefined>` - Environment variables for the runtime process. When omitted, inherits `process.env`. | ||
| - `gitHubToken?: string` - GitHub token for authentication. When provided, takes priority over other auth methods. | ||
| - `useLoggedInUser?: boolean` - Whether to use logged-in user for authentication (default: true, but false when `gitHubToken` is provided). Cannot be used with `RuntimeConnection.forUri`. | ||
| - `onListModels?: () => Promise<ModelInfo[]> | ModelInfo[]` - Optional model-list provider, useful when using a custom provider. | ||
| - `telemetry?: TelemetryConfig` - OpenTelemetry configuration for the runtime process. Providing this object enables telemetry — no separate flag needed. See [Telemetry](#telemetry) below. | ||
| - `onGetTraceContext?: TraceContextProvider` - Advanced: callback for linking your application's own OpenTelemetry spans into the same distributed trace as the runtime's spans. Not needed for normal telemetry collection. See [Telemetry](#telemetry) below. | ||
| - `sessionFs?: SessionFsConfig` - Custom session filesystem provider. | ||
| - `sessionIdleTimeoutSeconds?: number` - Server-wide idle timeout for sessions in seconds. Ignored when connecting via `RuntimeConnection.forUri`. | ||
| - `enableRemoteSessions?: boolean` - Enable Mission Control remote session support. Ignored when connecting via `RuntimeConnection.forUri`. | ||
@@ -169,3 +173,3 @@ #### Methods | ||
| ##### `on(eventType: SessionLifecycleEventType, handler): () => void` | ||
| ##### `onLifecycle(eventType: SessionLifecycleEventType, handler): () => void` | ||
@@ -180,3 +184,3 @@ Subscribe to a specific session lifecycle event type. Returns an unsubscribe function. | ||
| ##### `on(handler: SessionLifecycleHandler): () => void` | ||
| ##### `onLifecycle(handler: SessionLifecycleHandler): () => void` | ||
@@ -183,0 +187,0 @@ Subscribe to all session lifecycle events. Returns an unsubscribe function. |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
1153203
0.81%31263
0.62%1044
0.38%Updated