@github/copilot-sdk 0.1.29 → 0.1.30

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/README.md CHANGED
@@ -402,6 +402,19 @@ const session = await client.createSession({
402
402
 
403
403
  When Copilot invokes `lookup_issue`, the client automatically runs your handler and responds to the CLI. Handlers can return any JSON-serializable value (automatically wrapped), a simple string, or a `ToolResultObject` for full control over result metadata. Raw JSON schemas are also supported if Zod isn't desired.
404
404
 
405
+ #### Overriding Built-in Tools
406
+
407
+ If you register a tool with the same name as a built-in CLI tool (e.g. `edit_file`, `read_file`), the SDK will throw an error unless you explicitly opt in by setting `overridesBuiltInTool: true`. This flag signals that you intend to replace the built-in tool with your custom implementation.
408
+
409
+ ```ts
410
+ defineTool("edit_file", {
411
+ description: "Custom file editor with project-specific validation",
412
+ parameters: z.object({ path: z.string(), content: z.string() }),
413
+ overridesBuiltInTool: true,
414
+ handler: async ({ path, content }) => { /* your logic */ },
415
+ })
416
+ ```
417
+
405
418
  ### System Message Customization
406
419
 
407
420
  Control the system prompt using `systemMessage` in session config:
package/dist/client.js CHANGED
@@ -371,7 +371,8 @@ class CopilotClient {
371
371
  tools: config.tools?.map((tool) => ({
372
372
  name: tool.name,
373
373
  description: tool.description,
374
- parameters: toJsonSchema(tool.parameters)
374
+ parameters: toJsonSchema(tool.parameters),
375
+ overridesBuiltInTool: tool.overridesBuiltInTool
375
376
  })),
376
377
  systemMessage: config.systemMessage,
377
378
  availableTools: config.availableTools,
@@ -451,7 +452,8 @@ class CopilotClient {
451
452
  tools: config.tools?.map((tool) => ({
452
453
  name: tool.name,
453
454
  description: tool.description,
454
- parameters: toJsonSchema(tool.parameters)
455
+ parameters: toJsonSchema(tool.parameters),
456
+ overridesBuiltInTool: tool.overridesBuiltInTool
455
457
  })),
456
458
  provider: config.provider,
457
459
  requestPermission: true,
package/dist/session.d.ts CHANGED
@@ -291,4 +291,16 @@ export declare class CopilotSession {
291
291
  * ```
292
292
  */
293
293
  abort(): Promise<void>;
294
+ /**
295
+ * Change the model for this session.
296
+ * The new model takes effect for the next message. Conversation history is preserved.
297
+ *
298
+ * @param model - Model ID to switch to
299
+ *
300
+ * @example
301
+ * ```typescript
302
+ * await session.setModel("gpt-4.1");
303
+ * ```
304
+ */
305
+ setModel(model: string): Promise<void>;
294
306
  }
package/dist/session.js CHANGED
@@ -383,6 +383,20 @@ class CopilotSession {
383
383
  sessionId: this.sessionId
384
384
  });
385
385
  }
386
+ /**
387
+ * Change the model for this session.
388
+ * The new model takes effect for the next message. Conversation history is preserved.
389
+ *
390
+ * @param model - Model ID to switch to
391
+ *
392
+ * @example
393
+ * ```typescript
394
+ * await session.setModel("gpt-4.1");
395
+ * ```
396
+ */
397
+ async setModel(model) {
398
+ await this.rpc.model.switchTo({ modelId: model });
399
+ }
386
400
  }
387
401
  export {
388
402
  CopilotSession
package/dist/types.d.ts CHANGED
@@ -117,6 +117,12 @@ export interface Tool<TArgs = unknown> {
117
117
  description?: string;
118
118
  parameters?: ZodSchema<TArgs> | Record<string, unknown>;
119
119
  handler: ToolHandler<TArgs>;
120
+ /**
121
+ * When true, explicitly indicates this tool is intended to override a built-in tool
122
+ * of the same name. If not set and the name clashes with a built-in tool, the runtime
123
+ * will return an error.
124
+ */
125
+ overridesBuiltInTool?: boolean;
120
126
  }
121
127
  /**
122
128
  * Helper to define a tool with Zod schema and get type inference for the handler.
@@ -126,6 +132,7 @@ export declare function defineTool<T = unknown>(name: string, config: {
126
132
  description?: string;
127
133
  parameters?: ZodSchema<T> | Record<string, unknown>;
128
134
  handler: ToolHandler<T>;
135
+ overridesBuiltInTool?: boolean;
129
136
  }): Tool<T>;
130
137
  export interface ToolCallRequestPayload {
131
138
  sessionId: string;
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.29",
7
+ "version": "0.1.30",
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",