@github/copilot-sdk
Advanced tools
@@ -6,3 +6,3 @@ /** | ||
| * Generated by: scripts/generate-session-types.ts | ||
| * Generated at: 2026-01-13T00:08:20.716Z | ||
| * Generated at: 2026-01-16T00:52:51.450Z | ||
| * | ||
@@ -113,3 +113,42 @@ * To update these types: | ||
| parentId: string | null; | ||
| ephemeral: true; | ||
| type: "session.usage_info"; | ||
| data: { | ||
| tokenLimit: number; | ||
| currentTokens: number; | ||
| messagesLength: number; | ||
| }; | ||
| } | { | ||
| id: string; | ||
| timestamp: string; | ||
| parentId: string | null; | ||
| ephemeral?: boolean; | ||
| type: "session.compaction_start"; | ||
| data: {}; | ||
| } | { | ||
| id: string; | ||
| timestamp: string; | ||
| parentId: string | null; | ||
| ephemeral?: boolean; | ||
| type: "session.compaction_complete"; | ||
| data: { | ||
| success: boolean; | ||
| error?: string; | ||
| preCompactionTokens?: number; | ||
| postCompactionTokens?: number; | ||
| preCompactionMessagesLength?: number; | ||
| messagesRemoved?: number; | ||
| tokensRemoved?: number; | ||
| summaryContent?: string; | ||
| compactionTokensUsed?: { | ||
| input: number; | ||
| output: number; | ||
| cachedInput: number; | ||
| }; | ||
| }; | ||
| } | { | ||
| id: string; | ||
| timestamp: string; | ||
| parentId: string | null; | ||
| ephemeral?: boolean; | ||
| type: "user.message"; | ||
@@ -160,3 +199,2 @@ data: { | ||
| content: string; | ||
| chunkContent?: string; | ||
| }; | ||
@@ -167,3 +205,3 @@ } | { | ||
| parentId: string | null; | ||
| ephemeral?: true; | ||
| ephemeral: true; | ||
| type: "assistant.reasoning_delta"; | ||
@@ -183,4 +221,2 @@ data: { | ||
| content: string; | ||
| chunkContent?: string; | ||
| totalResponseSizeBytes?: number; | ||
| toolRequests?: { | ||
@@ -197,3 +233,3 @@ toolCallId: string; | ||
| parentId: string | null; | ||
| ephemeral?: true; | ||
| ephemeral: true; | ||
| type: "assistant.message_delta"; | ||
@@ -314,3 +350,3 @@ data: { | ||
| ephemeral?: boolean; | ||
| type: "custom_agent.started"; | ||
| type: "subagent.started"; | ||
| data: { | ||
@@ -327,3 +363,3 @@ toolCallId: string; | ||
| ephemeral?: boolean; | ||
| type: "custom_agent.completed"; | ||
| type: "subagent.completed"; | ||
| data: { | ||
@@ -338,3 +374,3 @@ toolCallId: string; | ||
| ephemeral?: boolean; | ||
| type: "custom_agent.failed"; | ||
| type: "subagent.failed"; | ||
| data: { | ||
@@ -350,3 +386,3 @@ toolCallId: string; | ||
| ephemeral?: boolean; | ||
| type: "custom_agent.selected"; | ||
| type: "subagent.selected"; | ||
| data: { | ||
@@ -353,0 +389,0 @@ agentName: string; |
+1
-1
@@ -7,4 +7,4 @@ /** | ||
| export { CopilotClient } from "./client.js"; | ||
| export { CopilotSession } from "./session.js"; | ||
| export { CopilotSession, type AssistantMessageEvent } from "./session.js"; | ||
| export { defineTool } from "./types.js"; | ||
| export type { ConnectionState, CopilotClientOptions, CustomAgentConfig, MCPLocalServerConfig, MCPRemoteServerConfig, MCPServerConfig, MessageOptions, PermissionHandler, PermissionRequest, PermissionRequestResult, ResumeSessionConfig, SessionConfig, SessionEvent, SessionEventHandler, SessionMetadata, SystemMessageAppendConfig, SystemMessageConfig, SystemMessageReplaceConfig, Tool, ToolHandler, ToolInvocation, ToolResultObject, ZodSchema, } from "./types.js"; |
+31
-4
@@ -7,2 +7,6 @@ /** | ||
| import type { MessageOptions, PermissionHandler, PermissionRequestResult, SessionEvent, SessionEventHandler, Tool, ToolHandler } from "./types.js"; | ||
| /** Assistant message event - the final response from the assistant. */ | ||
| export type AssistantMessageEvent = Extract<SessionEvent, { | ||
| type: "assistant.message"; | ||
| }>; | ||
| /** | ||
@@ -20,3 +24,3 @@ * Represents a single conversation session with the Copilot CLI. | ||
| * // Subscribe to events | ||
| * const unsubscribe = session.on((event) => { | ||
| * session.on((event) => { | ||
| * if (event.type === "assistant.message") { | ||
@@ -27,7 +31,6 @@ * console.log(event.data.content); | ||
| * | ||
| * // Send a message | ||
| * await session.send({ prompt: "Hello, world!" }); | ||
| * // Send a message and wait for completion | ||
| * await session.sendAndWait({ prompt: "Hello, world!" }); | ||
| * | ||
| * // Clean up | ||
| * unsubscribe(); | ||
| * await session.destroy(); | ||
@@ -70,2 +73,26 @@ * ``` | ||
| /** | ||
| * Sends a message to this session and waits until the session becomes idle. | ||
| * | ||
| * This is a convenience method that combines {@link send} with waiting for | ||
| * the `session.idle` event. Use this when you want to block until the | ||
| * assistant has finished processing the message. | ||
| * | ||
| * Events are still delivered to handlers registered via {@link on} while waiting. | ||
| * | ||
| * @param options - The message options including the prompt and optional attachments | ||
| * @param timeout - Timeout in milliseconds (default: 60000). Controls how long to wait; does not abort in-flight agent work. | ||
| * @returns A promise that resolves with the final assistant message when the session becomes idle, | ||
| * or undefined if no assistant message was received | ||
| * @throws Error if the timeout is reached before the session becomes idle | ||
| * @throws Error if the session has been destroyed or the connection fails | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * // Send and wait for completion with default 60s timeout | ||
| * const response = await session.sendAndWait({ prompt: "What is 2+2?" }); | ||
| * console.log(response?.data.content); // "4" | ||
| * ``` | ||
| */ | ||
| sendAndWait(options: MessageOptions, timeout?: number): Promise<AssistantMessageEvent | undefined>; | ||
| /** | ||
| * Subscribes to events from this session. | ||
@@ -72,0 +99,0 @@ * |
+61
-0
@@ -44,2 +44,63 @@ class CopilotSession { | ||
| /** | ||
| * Sends a message to this session and waits until the session becomes idle. | ||
| * | ||
| * This is a convenience method that combines {@link send} with waiting for | ||
| * the `session.idle` event. Use this when you want to block until the | ||
| * assistant has finished processing the message. | ||
| * | ||
| * Events are still delivered to handlers registered via {@link on} while waiting. | ||
| * | ||
| * @param options - The message options including the prompt and optional attachments | ||
| * @param timeout - Timeout in milliseconds (default: 60000). Controls how long to wait; does not abort in-flight agent work. | ||
| * @returns A promise that resolves with the final assistant message when the session becomes idle, | ||
| * or undefined if no assistant message was received | ||
| * @throws Error if the timeout is reached before the session becomes idle | ||
| * @throws Error if the session has been destroyed or the connection fails | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * // Send and wait for completion with default 60s timeout | ||
| * const response = await session.sendAndWait({ prompt: "What is 2+2?" }); | ||
| * console.log(response?.data.content); // "4" | ||
| * ``` | ||
| */ | ||
| async sendAndWait(options, timeout) { | ||
| const effectiveTimeout = timeout ?? 6e4; | ||
| let resolveIdle; | ||
| let rejectWithError; | ||
| const idlePromise = new Promise((resolve, reject) => { | ||
| resolveIdle = resolve; | ||
| rejectWithError = reject; | ||
| }); | ||
| let lastAssistantMessage; | ||
| const unsubscribe = this.on((event) => { | ||
| if (event.type === "assistant.message") { | ||
| lastAssistantMessage = event; | ||
| } else if (event.type === "session.idle") { | ||
| resolveIdle(); | ||
| } else if (event.type === "session.error") { | ||
| const error = new Error(event.data.message); | ||
| error.stack = event.data.stack; | ||
| rejectWithError(error); | ||
| } | ||
| }); | ||
| try { | ||
| await this.send(options); | ||
| const timeoutPromise = new Promise((_, reject) => { | ||
| setTimeout( | ||
| () => reject( | ||
| new Error( | ||
| `Timeout after ${effectiveTimeout}ms waiting for session.idle` | ||
| ) | ||
| ), | ||
| effectiveTimeout | ||
| ); | ||
| }); | ||
| await Promise.race([idlePromise, timeoutPromise]); | ||
| return lastAssistantMessage; | ||
| } finally { | ||
| unsubscribe(); | ||
| } | ||
| } | ||
| /** | ||
| * Subscribes to events from this session. | ||
@@ -46,0 +107,0 @@ * |
+2
-2
@@ -7,3 +7,3 @@ { | ||
| }, | ||
| "version": "0.1.13-preview.0", | ||
| "version": "0.1.13", | ||
| "description": "TypeScript SDK for programmatic control of GitHub Copilot CLI via JSON-RPC", | ||
@@ -44,3 +44,3 @@ "main": "./dist/index.js", | ||
| "dependencies": { | ||
| "@github/copilot": "^0.0.382-0", | ||
| "@github/copilot": "^0.0.384", | ||
| "vscode-jsonrpc": "^8.2.1", | ||
@@ -47,0 +47,0 @@ "zod": "^4.3.5" |
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
77271
6.37%2456
5.32%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated