@github/copilot-sdk 0.1.33-preview.0 → 0.1.33-preview.1
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 +13 -1
- package/dist/client.d.ts +0 -4
- package/dist/client.js +7 -19
- package/dist/types.d.ts +6 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -82,7 +82,6 @@ new CopilotClient(options?: CopilotClientOptions)
|
|
|
82
82
|
- `useStdio?: boolean` - Use stdio transport instead of TCP (default: true)
|
|
83
83
|
- `logLevel?: string` - Log level (default: "info")
|
|
84
84
|
- `autoStart?: boolean` - Auto-start server (default: true)
|
|
85
|
-
- `autoRestart?: boolean` - Auto-restart on crash (default: true)
|
|
86
85
|
- `githubToken?: string` - GitHub token for authentication. When provided, takes priority over other auth methods.
|
|
87
86
|
- `useLoggedInUser?: boolean` - Whether to use logged-in user for authentication (default: true, but false when `githubToken` is provided). Cannot be used with `cliUrl`.
|
|
88
87
|
|
|
@@ -426,6 +425,19 @@ defineTool("edit_file", {
|
|
|
426
425
|
})
|
|
427
426
|
```
|
|
428
427
|
|
|
428
|
+
#### Skipping Permission Prompts
|
|
429
|
+
|
|
430
|
+
Set `skipPermission: true` on a tool definition to allow it to execute without triggering a permission prompt:
|
|
431
|
+
|
|
432
|
+
```ts
|
|
433
|
+
defineTool("safe_lookup", {
|
|
434
|
+
description: "A read-only lookup that needs no confirmation",
|
|
435
|
+
parameters: z.object({ id: z.string() }),
|
|
436
|
+
skipPermission: true,
|
|
437
|
+
handler: async ({ id }) => { /* your logic */ },
|
|
438
|
+
})
|
|
439
|
+
```
|
|
440
|
+
|
|
429
441
|
### System Message Customization
|
|
430
442
|
|
|
431
443
|
Control the system prompt using `systemMessage` in session config:
|
package/dist/client.d.ts
CHANGED
package/dist/client.js
CHANGED
|
@@ -125,7 +125,7 @@ class CopilotClient {
|
|
|
125
125
|
cliUrl: options.cliUrl,
|
|
126
126
|
logLevel: options.logLevel || "debug",
|
|
127
127
|
autoStart: options.autoStart ?? true,
|
|
128
|
-
autoRestart:
|
|
128
|
+
autoRestart: false,
|
|
129
129
|
env: options.env ?? process.env,
|
|
130
130
|
githubToken: options.githubToken,
|
|
131
131
|
// Default useLoggedInUser to false when githubToken is provided, otherwise true
|
|
@@ -405,7 +405,8 @@ class CopilotClient {
|
|
|
405
405
|
name: tool.name,
|
|
406
406
|
description: tool.description,
|
|
407
407
|
parameters: toJsonSchema(tool.parameters),
|
|
408
|
-
overridesBuiltInTool: tool.overridesBuiltInTool
|
|
408
|
+
overridesBuiltInTool: tool.overridesBuiltInTool,
|
|
409
|
+
skipPermission: tool.skipPermission
|
|
409
410
|
})),
|
|
410
411
|
systemMessage: config.systemMessage,
|
|
411
412
|
availableTools: config.availableTools,
|
|
@@ -496,7 +497,8 @@ class CopilotClient {
|
|
|
496
497
|
name: tool.name,
|
|
497
498
|
description: tool.description,
|
|
498
499
|
parameters: toJsonSchema(tool.parameters),
|
|
499
|
-
overridesBuiltInTool: tool.overridesBuiltInTool
|
|
500
|
+
overridesBuiltInTool: tool.overridesBuiltInTool,
|
|
501
|
+
skipPermission: tool.skipPermission
|
|
500
502
|
})),
|
|
501
503
|
provider: config.provider,
|
|
502
504
|
requestPermission: true,
|
|
@@ -926,8 +928,6 @@ stderr: ${stderrOutput}`
|
|
|
926
928
|
} else {
|
|
927
929
|
reject(new Error(`CLI server exited with code ${code}`));
|
|
928
930
|
}
|
|
929
|
-
} else if (this.options.autoRestart && this.state === "connected") {
|
|
930
|
-
void this.reconnect();
|
|
931
931
|
}
|
|
932
932
|
});
|
|
933
933
|
setTimeout(() => {
|
|
@@ -1033,11 +1033,10 @@ stderr: ${stderrOutput}`
|
|
|
1033
1033
|
async (params) => await this.handleHooksInvoke(params)
|
|
1034
1034
|
);
|
|
1035
1035
|
this.connection.onClose(() => {
|
|
1036
|
-
|
|
1037
|
-
void this.reconnect();
|
|
1038
|
-
}
|
|
1036
|
+
this.state = "disconnected";
|
|
1039
1037
|
});
|
|
1040
1038
|
this.connection.onError((_error) => {
|
|
1039
|
+
this.state = "disconnected";
|
|
1041
1040
|
});
|
|
1042
1041
|
}
|
|
1043
1042
|
handleSessionEventNotification(notification) {
|
|
@@ -1191,17 +1190,6 @@ stderr: ${stderrOutput}`
|
|
|
1191
1190
|
isToolResultObject(value) {
|
|
1192
1191
|
return typeof value === "object" && value !== null && "textResultForLlm" in value && typeof value.textResultForLlm === "string" && "resultType" in value;
|
|
1193
1192
|
}
|
|
1194
|
-
/**
|
|
1195
|
-
* Attempt to reconnect to the server
|
|
1196
|
-
*/
|
|
1197
|
-
async reconnect() {
|
|
1198
|
-
this.state = "disconnected";
|
|
1199
|
-
try {
|
|
1200
|
-
await this.stop();
|
|
1201
|
-
await this.start();
|
|
1202
|
-
} catch (_error) {
|
|
1203
|
-
}
|
|
1204
|
-
}
|
|
1205
1193
|
}
|
|
1206
1194
|
export {
|
|
1207
1195
|
CopilotClient
|
package/dist/types.d.ts
CHANGED
|
@@ -56,8 +56,7 @@ export interface CopilotClientOptions {
|
|
|
56
56
|
*/
|
|
57
57
|
autoStart?: boolean;
|
|
58
58
|
/**
|
|
59
|
-
*
|
|
60
|
-
* @default true
|
|
59
|
+
* @deprecated This option has no effect and will be removed in a future release.
|
|
61
60
|
*/
|
|
62
61
|
autoRestart?: boolean;
|
|
63
62
|
/**
|
|
@@ -136,6 +135,10 @@ export interface Tool<TArgs = unknown> {
|
|
|
136
135
|
* will return an error.
|
|
137
136
|
*/
|
|
138
137
|
overridesBuiltInTool?: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* When true, the tool can execute without a permission prompt.
|
|
140
|
+
*/
|
|
141
|
+
skipPermission?: boolean;
|
|
139
142
|
}
|
|
140
143
|
/**
|
|
141
144
|
* Helper to define a tool with Zod schema and get type inference for the handler.
|
|
@@ -146,6 +149,7 @@ export declare function defineTool<T = unknown>(name: string, config: {
|
|
|
146
149
|
parameters?: ZodSchema<T> | Record<string, unknown>;
|
|
147
150
|
handler: ToolHandler<T>;
|
|
148
151
|
overridesBuiltInTool?: boolean;
|
|
152
|
+
skipPermission?: boolean;
|
|
149
153
|
}): Tool<T>;
|
|
150
154
|
export interface ToolCallRequestPayload {
|
|
151
155
|
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.33-preview.
|
|
7
|
+
"version": "0.1.33-preview.1",
|
|
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",
|