@github/copilot-sdk 0.1.14 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.d.ts +14 -1
- package/dist/client.js +42 -5
- package/dist/generated/session-events.d.ts +24 -1
- package/dist/index.d.ts +1 -1
- package/dist/sdkProtocolVersion.d.ts +1 -1
- package/dist/sdkProtocolVersion.js +1 -1
- package/dist/types.d.ts +83 -1
- package/package.json +2 -2
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CopilotSession } from "./session.js";
|
|
2
|
-
import type { ConnectionState, CopilotClientOptions, ResumeSessionConfig, SessionConfig, SessionMetadata } from "./types.js";
|
|
2
|
+
import type { ConnectionState, CopilotClientOptions, GetAuthStatusResponse, GetStatusResponse, ModelInfo, ResumeSessionConfig, SessionConfig, SessionMetadata } from "./types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Main client for interacting with the Copilot CLI.
|
|
5
5
|
*
|
|
@@ -220,6 +220,19 @@ export declare class CopilotClient {
|
|
|
220
220
|
timestamp: number;
|
|
221
221
|
protocolVersion?: number;
|
|
222
222
|
}>;
|
|
223
|
+
/**
|
|
224
|
+
* Get CLI status including version and protocol information
|
|
225
|
+
*/
|
|
226
|
+
getStatus(): Promise<GetStatusResponse>;
|
|
227
|
+
/**
|
|
228
|
+
* Get current authentication status
|
|
229
|
+
*/
|
|
230
|
+
getAuthStatus(): Promise<GetAuthStatusResponse>;
|
|
231
|
+
/**
|
|
232
|
+
* List available models with their metadata
|
|
233
|
+
* @throws Error if not authenticated
|
|
234
|
+
*/
|
|
235
|
+
listModels(): Promise<ModelInfo[]>;
|
|
223
236
|
/**
|
|
224
237
|
* Verify that the server's protocol version matches the SDK's expected version
|
|
225
238
|
*/
|
package/dist/client.js
CHANGED
|
@@ -5,8 +5,8 @@ import {
|
|
|
5
5
|
StreamMessageReader,
|
|
6
6
|
StreamMessageWriter
|
|
7
7
|
} from "vscode-jsonrpc/node.js";
|
|
8
|
-
import { CopilotSession } from "./session.js";
|
|
9
8
|
import { getSdkProtocolVersion } from "./sdkProtocolVersion.js";
|
|
9
|
+
import { CopilotSession } from "./session.js";
|
|
10
10
|
function isZodSchema(value) {
|
|
11
11
|
return value != null && typeof value === "object" && "toJSONSchema" in value && typeof value.toJSONSchema === "function";
|
|
12
12
|
}
|
|
@@ -67,7 +67,7 @@ class CopilotClient {
|
|
|
67
67
|
useStdio: options.cliUrl ? false : options.useStdio ?? true,
|
|
68
68
|
// Default to stdio unless cliUrl is provided
|
|
69
69
|
cliUrl: options.cliUrl,
|
|
70
|
-
logLevel: options.logLevel || "
|
|
70
|
+
logLevel: options.logLevel || "debug",
|
|
71
71
|
autoStart: options.autoStart ?? true,
|
|
72
72
|
autoRestart: options.autoRestart ?? true,
|
|
73
73
|
env: options.env ?? process.env
|
|
@@ -319,7 +319,10 @@ class CopilotClient {
|
|
|
319
319
|
requestPermission: !!config.onPermissionRequest,
|
|
320
320
|
streaming: config.streaming,
|
|
321
321
|
mcpServers: config.mcpServers,
|
|
322
|
-
customAgents: config.customAgents
|
|
322
|
+
customAgents: config.customAgents,
|
|
323
|
+
configDir: config.configDir,
|
|
324
|
+
skillDirectories: config.skillDirectories,
|
|
325
|
+
disabledSkills: config.disabledSkills
|
|
323
326
|
});
|
|
324
327
|
const sessionId = response.sessionId;
|
|
325
328
|
const session = new CopilotSession(sessionId, this.connection);
|
|
@@ -372,7 +375,9 @@ class CopilotClient {
|
|
|
372
375
|
requestPermission: !!config.onPermissionRequest,
|
|
373
376
|
streaming: config.streaming,
|
|
374
377
|
mcpServers: config.mcpServers,
|
|
375
|
-
customAgents: config.customAgents
|
|
378
|
+
customAgents: config.customAgents,
|
|
379
|
+
skillDirectories: config.skillDirectories,
|
|
380
|
+
disabledSkills: config.disabledSkills
|
|
376
381
|
});
|
|
377
382
|
const resumedSessionId = response.sessionId;
|
|
378
383
|
const session = new CopilotSession(resumedSessionId, this.connection);
|
|
@@ -418,6 +423,38 @@ class CopilotClient {
|
|
|
418
423
|
const result = await this.connection.sendRequest("ping", { message });
|
|
419
424
|
return result;
|
|
420
425
|
}
|
|
426
|
+
/**
|
|
427
|
+
* Get CLI status including version and protocol information
|
|
428
|
+
*/
|
|
429
|
+
async getStatus() {
|
|
430
|
+
if (!this.connection) {
|
|
431
|
+
throw new Error("Client not connected");
|
|
432
|
+
}
|
|
433
|
+
const result = await this.connection.sendRequest("status.get", {});
|
|
434
|
+
return result;
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Get current authentication status
|
|
438
|
+
*/
|
|
439
|
+
async getAuthStatus() {
|
|
440
|
+
if (!this.connection) {
|
|
441
|
+
throw new Error("Client not connected");
|
|
442
|
+
}
|
|
443
|
+
const result = await this.connection.sendRequest("auth.getStatus", {});
|
|
444
|
+
return result;
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* List available models with their metadata
|
|
448
|
+
* @throws Error if not authenticated
|
|
449
|
+
*/
|
|
450
|
+
async listModels() {
|
|
451
|
+
if (!this.connection) {
|
|
452
|
+
throw new Error("Client not connected");
|
|
453
|
+
}
|
|
454
|
+
const result = await this.connection.sendRequest("models.list", {});
|
|
455
|
+
const response = result;
|
|
456
|
+
return response.models;
|
|
457
|
+
}
|
|
421
458
|
/**
|
|
422
459
|
* Verify that the server's protocol version matches the SDK's expected version
|
|
423
460
|
*/
|
|
@@ -545,7 +582,7 @@ class CopilotClient {
|
|
|
545
582
|
spawnArgs = [this.options.cliPath, ...args];
|
|
546
583
|
} else if (process.platform === "win32" && !isAbsolutePath) {
|
|
547
584
|
command = "cmd";
|
|
548
|
-
spawnArgs = ["/c",
|
|
585
|
+
spawnArgs = ["/c", `${this.options.cliPath}`, ...args];
|
|
549
586
|
} else {
|
|
550
587
|
command = this.options.cliPath;
|
|
551
588
|
spawnArgs = args;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Generated from: @github/copilot/session-events.schema.json
|
|
5
5
|
* Generated by: scripts/generate-session-types.ts
|
|
6
|
-
* Generated at: 2026-01-
|
|
6
|
+
* Generated at: 2026-01-22T04:11:04.988Z
|
|
7
7
|
*
|
|
8
8
|
* To update these types:
|
|
9
9
|
* 1. Update the schema in copilot-agent-runtime
|
|
@@ -22,6 +22,12 @@ export type SessionEvent = {
|
|
|
22
22
|
copilotVersion: string;
|
|
23
23
|
startTime: string;
|
|
24
24
|
selectedModel?: string;
|
|
25
|
+
context?: {
|
|
26
|
+
cwd: string;
|
|
27
|
+
gitRoot?: string;
|
|
28
|
+
repository?: string;
|
|
29
|
+
branch?: string;
|
|
30
|
+
};
|
|
25
31
|
};
|
|
26
32
|
} | {
|
|
27
33
|
id: string;
|
|
@@ -32,6 +38,12 @@ export type SessionEvent = {
|
|
|
32
38
|
data: {
|
|
33
39
|
resumeTime: string;
|
|
34
40
|
eventCount: number;
|
|
41
|
+
context?: {
|
|
42
|
+
cwd: string;
|
|
43
|
+
gitRoot?: string;
|
|
44
|
+
repository?: string;
|
|
45
|
+
branch?: string;
|
|
46
|
+
};
|
|
35
47
|
};
|
|
36
48
|
} | {
|
|
37
49
|
id: string;
|
|
@@ -218,6 +230,7 @@ export type SessionEvent = {
|
|
|
218
230
|
toolCallId: string;
|
|
219
231
|
name: string;
|
|
220
232
|
arguments?: unknown;
|
|
233
|
+
type?: "function" | "custom";
|
|
221
234
|
}[];
|
|
222
235
|
parentToolCallId?: string;
|
|
223
236
|
};
|
|
@@ -314,6 +327,16 @@ export type SessionEvent = {
|
|
|
314
327
|
toolCallId: string;
|
|
315
328
|
partialOutput: string;
|
|
316
329
|
};
|
|
330
|
+
} | {
|
|
331
|
+
id: string;
|
|
332
|
+
timestamp: string;
|
|
333
|
+
parentId: string | null;
|
|
334
|
+
ephemeral: true;
|
|
335
|
+
type: "tool.execution_progress";
|
|
336
|
+
data: {
|
|
337
|
+
toolCallId: string;
|
|
338
|
+
progressMessage: string;
|
|
339
|
+
};
|
|
317
340
|
} | {
|
|
318
341
|
id: string;
|
|
319
342
|
timestamp: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
export { CopilotClient } from "./client.js";
|
|
7
7
|
export { CopilotSession, type AssistantMessageEvent } from "./session.js";
|
|
8
8
|
export { defineTool } from "./types.js";
|
|
9
|
-
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";
|
|
9
|
+
export type { ConnectionState, CopilotClientOptions, CustomAgentConfig, GetAuthStatusResponse, GetStatusResponse, MCPLocalServerConfig, MCPRemoteServerConfig, MCPServerConfig, MessageOptions, ModelBilling, ModelCapabilities, ModelInfo, ModelPolicy, PermissionHandler, PermissionRequest, PermissionRequestResult, ResumeSessionConfig, SessionConfig, SessionEvent, SessionEventHandler, SessionMetadata, SystemMessageAppendConfig, SystemMessageConfig, SystemMessageReplaceConfig, Tool, ToolHandler, ToolInvocation, ToolResultObject, ZodSchema, } from "./types.js";
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* The SDK protocol version.
|
|
3
3
|
* This must match the version expected by the copilot-agent-runtime server.
|
|
4
4
|
*/
|
|
5
|
-
export declare const SDK_PROTOCOL_VERSION =
|
|
5
|
+
export declare const SDK_PROTOCOL_VERSION = 2;
|
|
6
6
|
/**
|
|
7
7
|
* Gets the SDK protocol version.
|
|
8
8
|
* @returns The protocol version number
|
package/dist/types.d.ts
CHANGED
|
@@ -260,6 +260,11 @@ export interface SessionConfig {
|
|
|
260
260
|
* Model to use for this session
|
|
261
261
|
*/
|
|
262
262
|
model?: string;
|
|
263
|
+
/**
|
|
264
|
+
* Override the default configuration directory location.
|
|
265
|
+
* When specified, the session will use this directory for storing config and state.
|
|
266
|
+
*/
|
|
267
|
+
configDir?: string;
|
|
263
268
|
/**
|
|
264
269
|
* Tools exposed to the CLI server
|
|
265
270
|
*/
|
|
@@ -299,11 +304,19 @@ export interface SessionConfig {
|
|
|
299
304
|
* Custom agent configurations for the session.
|
|
300
305
|
*/
|
|
301
306
|
customAgents?: CustomAgentConfig[];
|
|
307
|
+
/**
|
|
308
|
+
* Directories to load skills from.
|
|
309
|
+
*/
|
|
310
|
+
skillDirectories?: string[];
|
|
311
|
+
/**
|
|
312
|
+
* List of skill names to disable.
|
|
313
|
+
*/
|
|
314
|
+
disabledSkills?: string[];
|
|
302
315
|
}
|
|
303
316
|
/**
|
|
304
317
|
* Configuration for resuming a session
|
|
305
318
|
*/
|
|
306
|
-
export type ResumeSessionConfig = Pick<SessionConfig, "tools" | "provider" | "streaming" | "onPermissionRequest" | "mcpServers" | "customAgents">;
|
|
319
|
+
export type ResumeSessionConfig = Pick<SessionConfig, "tools" | "provider" | "streaming" | "onPermissionRequest" | "mcpServers" | "customAgents" | "skillDirectories" | "disabledSkills">;
|
|
307
320
|
/**
|
|
308
321
|
* Configuration for a custom API provider.
|
|
309
322
|
*/
|
|
@@ -381,4 +394,73 @@ export interface SessionMetadata {
|
|
|
381
394
|
summary?: string;
|
|
382
395
|
isRemote: boolean;
|
|
383
396
|
}
|
|
397
|
+
/**
|
|
398
|
+
* Response from status.get
|
|
399
|
+
*/
|
|
400
|
+
export interface GetStatusResponse {
|
|
401
|
+
/** Package version (e.g., "1.0.0") */
|
|
402
|
+
version: string;
|
|
403
|
+
/** Protocol version for SDK compatibility */
|
|
404
|
+
protocolVersion: number;
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Response from auth.getStatus
|
|
408
|
+
*/
|
|
409
|
+
export interface GetAuthStatusResponse {
|
|
410
|
+
/** Whether the user is authenticated */
|
|
411
|
+
isAuthenticated: boolean;
|
|
412
|
+
/** Authentication type */
|
|
413
|
+
authType?: "user" | "env" | "gh-cli" | "hmac" | "api-key" | "token";
|
|
414
|
+
/** GitHub host URL */
|
|
415
|
+
host?: string;
|
|
416
|
+
/** User login name */
|
|
417
|
+
login?: string;
|
|
418
|
+
/** Human-readable status message */
|
|
419
|
+
statusMessage?: string;
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Model capabilities and limits
|
|
423
|
+
*/
|
|
424
|
+
export interface ModelCapabilities {
|
|
425
|
+
supports: {
|
|
426
|
+
vision: boolean;
|
|
427
|
+
};
|
|
428
|
+
limits: {
|
|
429
|
+
max_prompt_tokens?: number;
|
|
430
|
+
max_context_window_tokens: number;
|
|
431
|
+
vision?: {
|
|
432
|
+
supported_media_types: string[];
|
|
433
|
+
max_prompt_images: number;
|
|
434
|
+
max_prompt_image_size: number;
|
|
435
|
+
};
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Model policy state
|
|
440
|
+
*/
|
|
441
|
+
export interface ModelPolicy {
|
|
442
|
+
state: "enabled" | "disabled" | "unconfigured";
|
|
443
|
+
terms: string;
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Model billing information
|
|
447
|
+
*/
|
|
448
|
+
export interface ModelBilling {
|
|
449
|
+
multiplier: number;
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Information about an available model
|
|
453
|
+
*/
|
|
454
|
+
export interface ModelInfo {
|
|
455
|
+
/** Model identifier (e.g., "claude-sonnet-4.5") */
|
|
456
|
+
id: string;
|
|
457
|
+
/** Display name */
|
|
458
|
+
name: string;
|
|
459
|
+
/** Model capabilities and limits */
|
|
460
|
+
capabilities: ModelCapabilities;
|
|
461
|
+
/** Policy state */
|
|
462
|
+
policy?: ModelPolicy;
|
|
463
|
+
/** Billing information */
|
|
464
|
+
billing?: ModelBilling;
|
|
465
|
+
}
|
|
384
466
|
export {};
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"type": "git",
|
|
5
5
|
"url": "https://github.com/github/copilot-sdk.git"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.1.
|
|
7
|
+
"version": "0.1.15",
|
|
8
8
|
"description": "TypeScript SDK for programmatic control of GitHub Copilot CLI via JSON-RPC",
|
|
9
9
|
"main": "./dist/index.js",
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"author": "GitHub",
|
|
41
41
|
"license": "MIT",
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@github/copilot": "^0.0.
|
|
43
|
+
"@github/copilot": "^0.0.389",
|
|
44
44
|
"vscode-jsonrpc": "^8.2.1",
|
|
45
45
|
"zod": "^4.3.5"
|
|
46
46
|
},
|