@github/copilot-sdk 1.0.29-preview.8 → 1.0.29
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 +174 -5
- package/dist/cjs/cliVersion.js +1 -1
- package/dist/cjs/client.js +65 -22
- package/dist/cjs/generated/rpc.js +17 -2
- package/dist/cjs/session.js +11 -1
- package/dist/cjs/types.js +3 -5
- package/dist/cliVersion.d.ts +1 -1
- package/dist/cliVersion.js +1 -1
- package/dist/client.d.ts +2 -5
- package/dist/client.js +67 -24
- package/dist/generated/rpc.d.ts +146 -9
- package/dist/generated/rpc.js +17 -2
- package/dist/generated/session-events.d.ts +13 -1
- package/dist/session.d.ts +1 -1
- package/dist/session.js +11 -1
- package/dist/types.d.ts +9 -13
- package/dist/types.js +3 -5
- package/docs/agent-author.md +53 -5
- package/docs/examples.md +14 -9
- package/docs/workflows.md +2 -3
- package/package.json +13 -13
package/dist/types.d.ts
CHANGED
|
@@ -142,14 +142,10 @@ export interface StdioRuntimeConnection extends ChildProcessRuntimeConnection {
|
|
|
142
142
|
* {@link RuntimeConnection.forInProcess}.
|
|
143
143
|
*
|
|
144
144
|
* @experimental The in-process (FFI) transport is experimental and its behavior may
|
|
145
|
-
* change.
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
* transport, because the native runtime loads into the shared host process and its
|
|
150
|
-
* worker inherits that process's ambient environment. To configure the in-process
|
|
151
|
-
* runtime, set the corresponding environment variables on the host process before
|
|
152
|
-
* constructing the client. See https://github.com/github/copilot-sdk/issues/1934.
|
|
145
|
+
* change. Typed authentication and {@link CopilotClientOptions.baseDirectory}
|
|
146
|
+
* are scoped to this host. Client-level `env`, `workingDirectory` and
|
|
147
|
+
* `telemetry` are unsupported; set working directories
|
|
148
|
+
* on individual sessions.
|
|
153
149
|
*/
|
|
154
150
|
export interface InProcessRuntimeConnection {
|
|
155
151
|
readonly kind: "inprocess";
|
|
@@ -228,11 +224,9 @@ export declare const RuntimeConnection: {
|
|
|
228
224
|
/**
|
|
229
225
|
* Host the runtime in-process over the native runtime library's C ABI (FFI).
|
|
230
226
|
*
|
|
231
|
-
* @experimental
|
|
232
|
-
* `
|
|
233
|
-
*
|
|
234
|
-
* corresponding environment variables on the host process instead. See
|
|
235
|
-
* https://github.com/github/copilot-sdk/issues/1934.
|
|
227
|
+
* @experimental Runtime configuration from `gitHubToken` and
|
|
228
|
+
* `baseDirectory` is scoped to this host, not the process environment.
|
|
229
|
+
* Client-level `env`, `telemetry` and `workingDirectory` are unsupported.
|
|
236
230
|
*/
|
|
237
231
|
readonly forInProcess: (options?: Pick<InProcessRuntimeConnection, "runOnUiThread">) => InProcessRuntimeConnection;
|
|
238
232
|
};
|
|
@@ -327,6 +321,7 @@ export interface CopilotClientOptions {
|
|
|
327
321
|
/**
|
|
328
322
|
* Base directory for Copilot data (session state, config, etc.).
|
|
329
323
|
* Sets the COPILOT_HOME environment variable on the spawned runtime.
|
|
324
|
+
* In-process hosts also keep their runtime cache in this directory's `cache` subdirectory.
|
|
330
325
|
* When not set, the runtime defaults to ~/.copilot.
|
|
331
326
|
* Ignored when connecting to an existing runtime via {@link RuntimeConnection.forUri}.
|
|
332
327
|
*/
|
|
@@ -362,6 +357,7 @@ export interface CopilotClientOptions {
|
|
|
362
357
|
logLevel?: "none" | "error" | "warning" | "info" | "debug" | "all";
|
|
363
358
|
/**
|
|
364
359
|
* Environment variables to pass to the runtime process. If not set, inherits process.env.
|
|
360
|
+
* Unsupported with {@link RuntimeConnection.forInProcess}; use typed client/session options.
|
|
365
361
|
*/
|
|
366
362
|
env?: Record<string, string | undefined>;
|
|
367
363
|
/**
|
package/dist/types.js
CHANGED
|
@@ -38,11 +38,9 @@ const RuntimeConnection = {
|
|
|
38
38
|
/**
|
|
39
39
|
* Host the runtime in-process over the native runtime library's C ABI (FFI).
|
|
40
40
|
*
|
|
41
|
-
* @experimental
|
|
42
|
-
* `
|
|
43
|
-
*
|
|
44
|
-
* corresponding environment variables on the host process instead. See
|
|
45
|
-
* https://github.com/github/copilot-sdk/issues/1934.
|
|
41
|
+
* @experimental Runtime configuration from `gitHubToken` and
|
|
42
|
+
* `baseDirectory` is scoped to this host, not the process environment.
|
|
43
|
+
* Client-level `env`, `telemetry` and `workingDirectory` are unsupported.
|
|
46
44
|
*/
|
|
47
45
|
forInProcess(options = {}) {
|
|
48
46
|
return { kind: "inprocess", ...options };
|
package/docs/agent-author.md
CHANGED
|
@@ -95,7 +95,7 @@ tools: [
|
|
|
95
95
|
// Return value: string or ToolResultObject
|
|
96
96
|
// string → treated as success
|
|
97
97
|
// { textResultForLlm, resultType } → structured result
|
|
98
|
-
// resultType: "success" | "failure" | "rejected" | "denied"
|
|
98
|
+
// resultType: "success" | "failure" | "rejected" | "denied" | "timeout"
|
|
99
99
|
return `Result: ${args.arg1}`;
|
|
100
100
|
},
|
|
101
101
|
},
|
|
@@ -105,7 +105,7 @@ tools: [
|
|
|
105
105
|
**Constraints:**
|
|
106
106
|
|
|
107
107
|
- Tool names must be unique across ALL loaded extensions. Collisions cause the second extension to fail to load.
|
|
108
|
-
- Handler must return a string or `{ textResultForLlm: string, resultType
|
|
108
|
+
- Handler must return a string or `{ textResultForLlm: string, resultType: "success" | "failure" | "rejected" | "denied" | "timeout" }`. `resultType` is required: an object without a recognized `resultType` is not a structured result, and the model receives it serialized as JSON text.
|
|
109
109
|
- Handler receives `(args, invocation)` — the second argument has `sessionId`, `toolCallId`, `toolName`.
|
|
110
110
|
- Use `session.log()` to surface messages to the user. Don't use `console.log()` (stdout is reserved for JSON-RPC).
|
|
111
111
|
|
|
@@ -116,18 +116,22 @@ tools: [
|
|
|
116
116
|
```js
|
|
117
117
|
hooks: {
|
|
118
118
|
onUserPromptSubmitted: async (input, invocation) => { ... },
|
|
119
|
+
onUserPromptTransformed: async (input, invocation) => { ... },
|
|
119
120
|
onPreToolUse: async (input, invocation) => { ... },
|
|
121
|
+
onPreMcpToolCall: async (input, invocation) => { ... },
|
|
120
122
|
onPostToolUse: async (input, invocation) => { ... },
|
|
121
123
|
onPostToolUseFailure: async (input, invocation) => { ... },
|
|
122
124
|
onSessionStart: async (input, invocation) => { ... },
|
|
123
125
|
onSessionEnd: async (input, invocation) => { ... },
|
|
124
126
|
onErrorOccurred: async (input, invocation) => { ... },
|
|
127
|
+
onAgentStop: async (input, invocation) => { ... },
|
|
125
128
|
onSubagentStart: async (input, invocation) => { ... },
|
|
126
129
|
onSubagentStop: async (input, invocation) => { ... },
|
|
127
130
|
}
|
|
128
131
|
```
|
|
129
132
|
|
|
130
133
|
All hook inputs include `sessionId`, `timestamp` (`Date`) and `workingDirectory`.
|
|
134
|
+
Tool hooks also receive `toolCallId` when the runtime supplies one; correlate a call's hooks with `(input.sessionId, input.toolCallId)`.
|
|
131
135
|
All handlers receive `invocation: { sessionId: string }` as the second argument.
|
|
132
136
|
All handlers may return `void`/`undefined` (no-op) or an output object.
|
|
133
137
|
|
|
@@ -143,9 +147,23 @@ All handlers may return `void`/`undefined` (no-op) or an output object.
|
|
|
143
147
|
| `decision` | `"block"` | Refuses the prompt: no model turn runs and no user message is recorded |
|
|
144
148
|
| `reason` | `string` | Why the prompt was blocked, carried by the ephemeral `session.warning` (`warningType: "policy_blocked"`) |
|
|
145
149
|
|
|
150
|
+
### onUserPromptTransformed
|
|
151
|
+
|
|
152
|
+
Fires after the runtime adds generated context to the submitted prompt, before
|
|
153
|
+
the result is stored in session history or sent to the model. `prompt` is the
|
|
154
|
+
prompt after `onUserPromptSubmitted`; `transformedPrompt` also carries the
|
|
155
|
+
runtime-generated context.
|
|
156
|
+
|
|
157
|
+
**Input:** `{ prompt: string, transformedPrompt: string, timestamp, workingDirectory }`
|
|
158
|
+
|
|
159
|
+
**Output (all fields optional):**
|
|
160
|
+
| Field | Type | Effect |
|
|
161
|
+
|-------|------|--------|
|
|
162
|
+
| `modifiedTransformedPrompt` | `string` | Replaces the content stored in session history and sent to the model |
|
|
163
|
+
|
|
146
164
|
### onPreToolUse
|
|
147
165
|
|
|
148
|
-
**Input:** `{ toolName: string, toolArgs: unknown, timestamp, workingDirectory }`
|
|
166
|
+
**Input:** `{ toolCallId?: string, toolName: string, toolArgs: unknown, timestamp, workingDirectory }`
|
|
149
167
|
|
|
150
168
|
**Output (all fields optional):**
|
|
151
169
|
| Field | Type | Effect |
|
|
@@ -155,9 +173,22 @@ All handlers may return `void`/`undefined` (no-op) or an output object.
|
|
|
155
173
|
| `modifiedArgs` | `unknown` | Replaces the tool arguments |
|
|
156
174
|
| `additionalContext` | `string` | Injected into the conversation |
|
|
157
175
|
|
|
176
|
+
### onPreMcpToolCall
|
|
177
|
+
|
|
178
|
+
Fires before a tool call is sent to an MCP server. It controls only the `_meta`
|
|
179
|
+
object sent with the request; to allow, deny or change the call itself, use
|
|
180
|
+
`onPreToolUse`.
|
|
181
|
+
|
|
182
|
+
**Input:** `{ toolCallId?: string, serverName: string, toolName: string, arguments: unknown, _meta?: Record<string, unknown>, timestamp, workingDirectory }`
|
|
183
|
+
|
|
184
|
+
**Output (all fields optional):**
|
|
185
|
+
| Field | Type | Effect |
|
|
186
|
+
|-------|------|--------|
|
|
187
|
+
| `metaToUse` | `Record<string, unknown> \| null` | An object becomes the request's `_meta`; `null` omits it; leaving it out keeps the current `_meta` |
|
|
188
|
+
|
|
158
189
|
### onPostToolUse
|
|
159
190
|
|
|
160
|
-
**Input:** `{ toolName: string, toolArgs: unknown, toolResult: ToolResultObject, timestamp, workingDirectory }`
|
|
191
|
+
**Input:** `{ toolCallId?: string, toolName: string, toolArgs: unknown, toolResult: ToolResultObject, timestamp, workingDirectory }`
|
|
161
192
|
|
|
162
193
|
Fires only when the tool returned a successful result. To observe non-success
|
|
163
194
|
outcomes, register `onPostToolUseFailure` as well.
|
|
@@ -170,7 +201,7 @@ outcomes, register `onPostToolUseFailure` as well.
|
|
|
170
201
|
|
|
171
202
|
### onPostToolUseFailure
|
|
172
203
|
|
|
173
|
-
**Input:** `{ toolName: string, toolArgs: unknown, error: string, timestamp, workingDirectory }`
|
|
204
|
+
**Input:** `{ toolCallId?: string, toolName: string, toolArgs: unknown, error: string, timestamp, workingDirectory }`
|
|
174
205
|
|
|
175
206
|
Fires after a tool execution whose result was `"failure"`. `onPostToolUse`
|
|
176
207
|
does **not** fire for these outcomes, so register this handler to observe or
|
|
@@ -218,6 +249,23 @@ fire it.
|
|
|
218
249
|
| `retryCount` | `number` | Max retries (when errorHandling is "retry") |
|
|
219
250
|
| `userNotification` | `string` | Message shown to the user |
|
|
220
251
|
|
|
252
|
+
### onAgentStop
|
|
253
|
+
|
|
254
|
+
Fires when the top-level agent reaches a natural terminal stop: it went idle
|
|
255
|
+
without pending work and was not aborted. Sub-agents fire `onSubagentStop`
|
|
256
|
+
instead.
|
|
257
|
+
|
|
258
|
+
**Input:** `{ stopReason?: string, transcriptPath?: string, stopHookActive?: boolean, timestamp, workingDirectory }`
|
|
259
|
+
|
|
260
|
+
`stopHookActive` is `true` when this stop follows an earlier `"block"` from this
|
|
261
|
+
hook; check it to avoid blocking indefinitely. The runtime also caps
|
|
262
|
+
consecutive blocks.
|
|
263
|
+
|
|
264
|
+
**Output (optional):**
|
|
265
|
+
| Field | Type | Effect |
|
|
266
|
+
|-------|------|--------|
|
|
267
|
+
| `decision` and `reason` | `"block"` and `string` | Keep the agent running; `reason` is enqueued as its next user message |
|
|
268
|
+
|
|
221
269
|
### onSubagentStart
|
|
222
270
|
|
|
223
271
|
Fires before a sub-agent's first turn. The input's `sessionId` and the
|
package/docs/examples.md
CHANGED
|
@@ -152,15 +152,20 @@ Hooks intercept and modify behavior at key lifecycle points. Register them in th
|
|
|
152
152
|
|
|
153
153
|
### Available Hooks
|
|
154
154
|
|
|
155
|
-
| Hook
|
|
156
|
-
|
|
|
157
|
-
| `onUserPromptSubmitted`
|
|
158
|
-
| `
|
|
159
|
-
| `
|
|
160
|
-
| `
|
|
161
|
-
| `
|
|
162
|
-
| `
|
|
163
|
-
| `
|
|
155
|
+
| Hook | Fires When | Can Modify |
|
|
156
|
+
| ------------------------- | -------------------------------------------- | ------------------------------------------- |
|
|
157
|
+
| `onUserPromptSubmitted` | User sends a message | The prompt text, add context |
|
|
158
|
+
| `onUserPromptTransformed` | Runtime has transformed the submitted prompt | The transformed prompt |
|
|
159
|
+
| `onPreToolUse` | Before a tool executes | Tool args, permission decision, add context |
|
|
160
|
+
| `onPreMcpToolCall` | Before an MCP tool call is sent | The request's `_meta` |
|
|
161
|
+
| `onPostToolUse` | After a tool executes successfully | Tool result, add context |
|
|
162
|
+
| `onPostToolUseFailure` | After a tool execution returns a failure | Add hidden guidance to the model |
|
|
163
|
+
| `onSessionStart` | Session starts or resumes | Add context |
|
|
164
|
+
| `onSessionEnd` | Session ends | Cleanup actions, summary |
|
|
165
|
+
| `onErrorOccurred` | An error occurs | Error handling strategy (retry/skip/abort) |
|
|
166
|
+
| `onAgentStop` | Top-level agent naturally stops | Block the stop and request another turn |
|
|
167
|
+
| `onSubagentStart` | Before a sub-agent's first turn | Add context to its prompt |
|
|
168
|
+
| `onSubagentStop` | After a sub-agent completes a turn | Request another turn, replace its response |
|
|
164
169
|
|
|
165
170
|
All hook inputs include `timestamp` (`Date`) and `workingDirectory`.
|
|
166
171
|
|
package/docs/workflows.md
CHANGED
|
@@ -225,7 +225,6 @@ Observation does not restore execution eligibility. Starting, resuming, pausing,
|
|
|
225
225
|
```ts
|
|
226
226
|
const runs = await session.workflow.listRuns();
|
|
227
227
|
const runsPage = await session.workflow.listRuns({
|
|
228
|
-
afterSeq,
|
|
229
228
|
beforeSeq,
|
|
230
229
|
limit,
|
|
231
230
|
});
|
|
@@ -233,15 +232,15 @@ const detail = await session.workflow.getRunDetail(runId);
|
|
|
233
232
|
const progressPage = await session.workflow.getRunProgress(runId, {
|
|
234
233
|
phaseId,
|
|
235
234
|
afterSeq,
|
|
236
|
-
beforeSeq,
|
|
237
235
|
limit,
|
|
238
236
|
});
|
|
239
237
|
```
|
|
240
238
|
|
|
241
239
|
- `listRuns()` returns only the runs array from the newest default page of this session's durable workflow runs. This overload preserves the original convenience API.
|
|
242
|
-
- `listRuns({ afterSeq, beforeSeq, limit })` returns the full page. Its `oldestSeq`, `newestSeq`, `hasMoreNewer`, and `omittedOlder` fields let callers continue paging without raw RPC calls.
|
|
240
|
+
- `listRuns({ afterSeq, limit })` or `listRuns({ beforeSeq, limit })` returns the full page. Its `oldestSeq`, `newestSeq`, `hasMoreNewer`, and `omittedOlder` fields let callers continue paging without raw RPC calls.
|
|
243
241
|
- `getRunDetail(runId)` returns phases, prompt-safe agent summaries, and the latest progress page. Each current-runtime agent summary includes `consumedNanoAiu`, the known spend from that direct agent and its descendants. Older runtimes omit the field, and historical agents without attributable charge rows also omit it when the run contains unattributed spend.
|
|
244
242
|
- `getRunProgress(runId, options?)` pages progress forward, backward, by phase, or from the latest tail.
|
|
243
|
+
- Both paging calls take at most one cursor: `afterSeq` pages forward and `beforeSeq` pages backward, each exclusive of the given sequence number. A request with both fails with JSON-RPC `-32602` and `data.code: "workflow_runs_invalid_cursor"` from `listRuns`, or `"workflow_progress_invalid_cursor"` from `getRunProgress`.
|
|
245
244
|
|
|
246
245
|
`getRun(runId)` reads the latest run envelope. `pause(runId)` pauses a running attempt and returns its `paused` envelope. `cancel(runId)` cancels a run and returns its terminal envelope.
|
|
247
246
|
|
package/package.json
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
"url": "https://github.com/github/copilot-agent-runtime.git",
|
|
6
6
|
"directory": "src/sdk/nodejs"
|
|
7
7
|
},
|
|
8
|
-
"version": "1.0.29
|
|
9
|
-
"copilotCliVersion": "1.0.
|
|
8
|
+
"version": "1.0.29",
|
|
9
|
+
"copilotCliVersion": "1.0.107",
|
|
10
10
|
"description": "TypeScript SDK for programmatic control of GitHub Copilot CLI via JSON-RPC",
|
|
11
11
|
"main": "./dist/cjs/index.js",
|
|
12
12
|
"types": "./dist/index.d.ts",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"author": "GitHub",
|
|
69
69
|
"license": "MIT",
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"koffi": "3.3.
|
|
71
|
+
"koffi": "3.3.4",
|
|
72
72
|
"vscode-jsonrpc": "10.0.0",
|
|
73
73
|
"zod": "4.6.7"
|
|
74
74
|
},
|
|
@@ -117,18 +117,18 @@
|
|
|
117
117
|
"README.md"
|
|
118
118
|
],
|
|
119
119
|
"copilotRuntime": {
|
|
120
|
-
"sourceSha": "
|
|
121
|
-
"version": "1.0.
|
|
120
|
+
"sourceSha": "2bfb456b9e0878c4cb3dd05cb9877ac9c97cbd68",
|
|
121
|
+
"version": "1.0.107",
|
|
122
122
|
"visibility": "public"
|
|
123
123
|
},
|
|
124
124
|
"optionalDependencies": {
|
|
125
|
-
"@github/copilot-sdk-darwin-arm64": "1.0.29
|
|
126
|
-
"@github/copilot-sdk-darwin-x64": "1.0.29
|
|
127
|
-
"@github/copilot-sdk-linux-arm64": "1.0.29
|
|
128
|
-
"@github/copilot-sdk-linux-x64": "1.0.29
|
|
129
|
-
"@github/copilot-sdk-linuxmusl-arm64": "1.0.29
|
|
130
|
-
"@github/copilot-sdk-linuxmusl-x64": "1.0.29
|
|
131
|
-
"@github/copilot-sdk-win32-arm64": "1.0.29
|
|
132
|
-
"@github/copilot-sdk-win32-x64": "1.0.29
|
|
125
|
+
"@github/copilot-sdk-darwin-arm64": "1.0.29",
|
|
126
|
+
"@github/copilot-sdk-darwin-x64": "1.0.29",
|
|
127
|
+
"@github/copilot-sdk-linux-arm64": "1.0.29",
|
|
128
|
+
"@github/copilot-sdk-linux-x64": "1.0.29",
|
|
129
|
+
"@github/copilot-sdk-linuxmusl-arm64": "1.0.29",
|
|
130
|
+
"@github/copilot-sdk-linuxmusl-x64": "1.0.29",
|
|
131
|
+
"@github/copilot-sdk-win32-arm64": "1.0.29",
|
|
132
|
+
"@github/copilot-sdk-win32-x64": "1.0.29"
|
|
133
133
|
}
|
|
134
134
|
}
|