@github/copilot-sdk 0.1.26-preview.0 → 0.1.27

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 CHANGED
@@ -130,10 +130,11 @@ export declare class CopilotClient {
130
130
  * @example
131
131
  * ```typescript
132
132
  * // Basic session
133
- * const session = await client.createSession();
133
+ * const session = await client.createSession({ onPermissionRequest: approveAll });
134
134
  *
135
135
  * // Session with model and tools
136
136
  * const session = await client.createSession({
137
+ * onPermissionRequest: approveAll,
137
138
  * model: "gpt-4",
138
139
  * tools: [{
139
140
  * name: "get_weather",
@@ -144,7 +145,7 @@ export declare class CopilotClient {
144
145
  * });
145
146
  * ```
146
147
  */
147
- createSession(config?: SessionConfig): Promise<CopilotSession>;
148
+ createSession(config: SessionConfig): Promise<CopilotSession>;
148
149
  /**
149
150
  * Resumes an existing conversation session by its ID.
150
151
  *
@@ -160,15 +161,16 @@ export declare class CopilotClient {
160
161
  * @example
161
162
  * ```typescript
162
163
  * // Resume a previous session
163
- * const session = await client.resumeSession("session-123");
164
+ * const session = await client.resumeSession("session-123", { onPermissionRequest: approveAll });
164
165
  *
165
166
  * // Resume with new tools
166
167
  * const session = await client.resumeSession("session-123", {
168
+ * onPermissionRequest: approveAll,
167
169
  * tools: [myNewTool]
168
170
  * });
169
171
  * ```
170
172
  */
171
- resumeSession(sessionId: string, config?: ResumeSessionConfig): Promise<CopilotSession>;
173
+ resumeSession(sessionId: string, config: ResumeSessionConfig): Promise<CopilotSession>;
172
174
  /**
173
175
  * Gets the current connection state of the client.
174
176
  *
@@ -177,7 +179,7 @@ export declare class CopilotClient {
177
179
  * @example
178
180
  * ```typescript
179
181
  * if (client.getState() === "connected") {
180
- * const session = await client.createSession();
182
+ * const session = await client.createSession({ onPermissionRequest: approveAll });
181
183
  * }
182
184
  * ```
183
185
  */
@@ -234,7 +236,7 @@ export declare class CopilotClient {
234
236
  * ```typescript
235
237
  * const lastId = await client.getLastSessionId();
236
238
  * if (lastId) {
237
- * const session = await client.resumeSession(lastId);
239
+ * const session = await client.resumeSession(lastId, { onPermissionRequest: approveAll });
238
240
  * }
239
241
  * ```
240
242
  */
package/dist/client.js CHANGED
@@ -335,10 +335,11 @@ class CopilotClient {
335
335
  * @example
336
336
  * ```typescript
337
337
  * // Basic session
338
- * const session = await client.createSession();
338
+ * const session = await client.createSession({ onPermissionRequest: approveAll });
339
339
  *
340
340
  * // Session with model and tools
341
341
  * const session = await client.createSession({
342
+ * onPermissionRequest: approveAll,
342
343
  * model: "gpt-4",
343
344
  * tools: [{
344
345
  * name: "get_weather",
@@ -349,7 +350,12 @@ class CopilotClient {
349
350
  * });
350
351
  * ```
351
352
  */
352
- async createSession(config = {}) {
353
+ async createSession(config) {
354
+ if (!config?.onPermissionRequest) {
355
+ throw new Error(
356
+ "An onPermissionRequest handler is required when creating a session. For example, to allow all permissions, use { onPermissionRequest: approveAll }."
357
+ );
358
+ }
353
359
  if (!this.connection) {
354
360
  if (this.options.autoStart) {
355
361
  await this.start();
@@ -387,9 +393,7 @@ class CopilotClient {
387
393
  const { sessionId, workspacePath } = response;
388
394
  const session = new CopilotSession(sessionId, this.connection, workspacePath);
389
395
  session.registerTools(config.tools);
390
- if (config.onPermissionRequest) {
391
- session.registerPermissionHandler(config.onPermissionRequest);
392
- }
396
+ session.registerPermissionHandler(config.onPermissionRequest);
393
397
  if (config.onUserInputRequest) {
394
398
  session.registerUserInputHandler(config.onUserInputRequest);
395
399
  }
@@ -414,15 +418,21 @@ class CopilotClient {
414
418
  * @example
415
419
  * ```typescript
416
420
  * // Resume a previous session
417
- * const session = await client.resumeSession("session-123");
421
+ * const session = await client.resumeSession("session-123", { onPermissionRequest: approveAll });
418
422
  *
419
423
  * // Resume with new tools
420
424
  * const session = await client.resumeSession("session-123", {
425
+ * onPermissionRequest: approveAll,
421
426
  * tools: [myNewTool]
422
427
  * });
423
428
  * ```
424
429
  */
425
- async resumeSession(sessionId, config = {}) {
430
+ async resumeSession(sessionId, config) {
431
+ if (!config?.onPermissionRequest) {
432
+ throw new Error(
433
+ "An onPermissionRequest handler is required when resuming a session. For example, to allow all permissions, use { onPermissionRequest: approveAll }."
434
+ );
435
+ }
426
436
  if (!this.connection) {
427
437
  if (this.options.autoStart) {
428
438
  await this.start();
@@ -461,9 +471,7 @@ class CopilotClient {
461
471
  const { sessionId: resumedSessionId, workspacePath } = response;
462
472
  const session = new CopilotSession(resumedSessionId, this.connection, workspacePath);
463
473
  session.registerTools(config.tools);
464
- if (config.onPermissionRequest) {
465
- session.registerPermissionHandler(config.onPermissionRequest);
466
- }
474
+ session.registerPermissionHandler(config.onPermissionRequest);
467
475
  if (config.onUserInputRequest) {
468
476
  session.registerUserInputHandler(config.onUserInputRequest);
469
477
  }
@@ -481,7 +489,7 @@ class CopilotClient {
481
489
  * @example
482
490
  * ```typescript
483
491
  * if (client.getState() === "connected") {
484
- * const session = await client.createSession();
492
+ * const session = await client.createSession({ onPermissionRequest: approveAll });
485
493
  * }
486
494
  * ```
487
495
  */
@@ -594,7 +602,7 @@ class CopilotClient {
594
602
  * ```typescript
595
603
  * const lastId = await client.getLastSessionId();
596
604
  * if (lastId) {
597
- * const session = await client.resumeSession(lastId);
605
+ * const session = await client.resumeSession(lastId, { onPermissionRequest: approveAll });
598
606
  * }
599
607
  * ```
600
608
  */
@@ -287,6 +287,113 @@ export interface SessionFleetStartParams {
287
287
  */
288
288
  prompt?: string;
289
289
  }
290
+ export interface SessionAgentListResult {
291
+ /**
292
+ * Available custom agents
293
+ */
294
+ agents: {
295
+ /**
296
+ * Unique identifier of the custom agent
297
+ */
298
+ name: string;
299
+ /**
300
+ * Human-readable display name
301
+ */
302
+ displayName: string;
303
+ /**
304
+ * Description of the agent's purpose
305
+ */
306
+ description: string;
307
+ }[];
308
+ }
309
+ export interface SessionAgentListParams {
310
+ /**
311
+ * Target session identifier
312
+ */
313
+ sessionId: string;
314
+ }
315
+ export interface SessionAgentGetCurrentResult {
316
+ /**
317
+ * Currently selected custom agent, or null if using the default agent
318
+ */
319
+ agent: {
320
+ /**
321
+ * Unique identifier of the custom agent
322
+ */
323
+ name: string;
324
+ /**
325
+ * Human-readable display name
326
+ */
327
+ displayName: string;
328
+ /**
329
+ * Description of the agent's purpose
330
+ */
331
+ description: string;
332
+ } | null;
333
+ }
334
+ export interface SessionAgentGetCurrentParams {
335
+ /**
336
+ * Target session identifier
337
+ */
338
+ sessionId: string;
339
+ }
340
+ export interface SessionAgentSelectResult {
341
+ /**
342
+ * The newly selected custom agent
343
+ */
344
+ agent: {
345
+ /**
346
+ * Unique identifier of the custom agent
347
+ */
348
+ name: string;
349
+ /**
350
+ * Human-readable display name
351
+ */
352
+ displayName: string;
353
+ /**
354
+ * Description of the agent's purpose
355
+ */
356
+ description: string;
357
+ };
358
+ }
359
+ export interface SessionAgentSelectParams {
360
+ /**
361
+ * Target session identifier
362
+ */
363
+ sessionId: string;
364
+ /**
365
+ * Name of the custom agent to select
366
+ */
367
+ name: string;
368
+ }
369
+ export interface SessionAgentDeselectResult {
370
+ }
371
+ export interface SessionAgentDeselectParams {
372
+ /**
373
+ * Target session identifier
374
+ */
375
+ sessionId: string;
376
+ }
377
+ export interface SessionCompactionCompactResult {
378
+ /**
379
+ * Whether compaction completed successfully
380
+ */
381
+ success: boolean;
382
+ /**
383
+ * Number of tokens freed by compaction
384
+ */
385
+ tokensRemoved: number;
386
+ /**
387
+ * Number of messages removed during compaction
388
+ */
389
+ messagesRemoved: number;
390
+ }
391
+ export interface SessionCompactionCompactParams {
392
+ /**
393
+ * Target session identifier
394
+ */
395
+ sessionId: string;
396
+ }
290
397
  /** Create typed server-scoped RPC methods (no session required). */
291
398
  export declare function createServerRpc(connection: MessageConnection): {
292
399
  ping: (params: PingParams) => Promise<PingResult>;
@@ -323,4 +430,13 @@ export declare function createSessionRpc(connection: MessageConnection, sessionI
323
430
  fleet: {
324
431
  start: (params: Omit<SessionFleetStartParams, "sessionId">) => Promise<SessionFleetStartResult>;
325
432
  };
433
+ agent: {
434
+ list: () => Promise<SessionAgentListResult>;
435
+ getCurrent: () => Promise<SessionAgentGetCurrentResult>;
436
+ select: (params: Omit<SessionAgentSelectParams, "sessionId">) => Promise<SessionAgentSelectResult>;
437
+ deselect: () => Promise<SessionAgentDeselectResult>;
438
+ };
439
+ compaction: {
440
+ compact: () => Promise<SessionCompactionCompactResult>;
441
+ };
326
442
  };
@@ -34,6 +34,15 @@ function createSessionRpc(connection, sessionId) {
34
34
  },
35
35
  fleet: {
36
36
  start: async (params) => connection.sendRequest("session.fleet.start", { sessionId, ...params })
37
+ },
38
+ agent: {
39
+ list: async () => connection.sendRequest("session.agent.list", { sessionId }),
40
+ getCurrent: async () => connection.sendRequest("session.agent.getCurrent", { sessionId }),
41
+ select: async (params) => connection.sendRequest("session.agent.select", { sessionId, ...params }),
42
+ deselect: async () => connection.sendRequest("session.agent.deselect", { sessionId })
43
+ },
44
+ compaction: {
45
+ compact: async () => connection.sendRequest("session.compaction.compact", { sessionId })
37
46
  }
38
47
  };
39
48
  }
@@ -260,6 +260,15 @@ export type SessionEvent = {
260
260
  };
261
261
  requestId?: string;
262
262
  };
263
+ } | {
264
+ id: string;
265
+ timestamp: string;
266
+ parentId: string | null;
267
+ ephemeral?: boolean;
268
+ type: "session.task_complete";
269
+ data: {
270
+ summary?: string;
271
+ };
263
272
  } | {
264
273
  id: string;
265
274
  timestamp: string;
@@ -349,6 +358,15 @@ export type SessionEvent = {
349
358
  reasoningId: string;
350
359
  deltaContent: string;
351
360
  };
361
+ } | {
362
+ id: string;
363
+ timestamp: string;
364
+ parentId: string | null;
365
+ ephemeral: true;
366
+ type: "assistant.streaming_delta";
367
+ data: {
368
+ totalResponseSizeBytes: number;
369
+ };
352
370
  } | {
353
371
  id: string;
354
372
  timestamp: string;
@@ -379,7 +397,6 @@ export type SessionEvent = {
379
397
  data: {
380
398
  messageId: string;
381
399
  deltaContent: string;
382
- totalResponseSizeBytes?: number;
383
400
  parentToolCallId?: string;
384
401
  };
385
402
  } | {
package/dist/types.d.ts CHANGED
@@ -168,7 +168,7 @@ export type SystemMessageConfig = SystemMessageAppendConfig | SystemMessageRepla
168
168
  * Permission request types from the server
169
169
  */
170
170
  export interface PermissionRequest {
171
- kind: "shell" | "write" | "mcp" | "read" | "url";
171
+ kind: "shell" | "write" | "mcp" | "read" | "url" | "custom-tool";
172
172
  toolCallId?: string;
173
173
  [key: string]: unknown;
174
174
  }
@@ -549,7 +549,7 @@ export interface SessionConfig {
549
549
  * Handler for permission requests from the server.
550
550
  * When provided, the server will call this handler to request permission for operations.
551
551
  */
552
- onPermissionRequest?: PermissionHandler;
552
+ onPermissionRequest: PermissionHandler;
553
553
  /**
554
554
  * Handler for user input requests from the agent.
555
555
  * When provided, enables the ask_user tool allowing the agent to ask questions.
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.26-preview.0",
7
+ "version": "0.1.27",
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.411",
43
+ "@github/copilot": "^0.0.416",
44
44
  "vscode-jsonrpc": "^8.2.1",
45
45
  "zod": "^4.3.6"
46
46
  },