@github/copilot-sdk 1.0.29-preview.8 → 1.0.29-preview.9

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/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 Per-client options lowered to environment variables (`env`,
42
- * `telemetry`, `gitHubToken`, `baseDirectory`) are **not** honored in-process;
43
- * the worker inherits the host process's ambient environment. Set the
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 };
@@ -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?: string }`.
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,12 +116,15 @@ 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
  }
@@ -143,6 +146,20 @@ All handlers may return `void`/`undefined` (no-op) or an output object.
143
146
  | `decision` | `"block"` | Refuses the prompt: no model turn runs and no user message is recorded |
144
147
  | `reason` | `string` | Why the prompt was blocked, carried by the ephemeral `session.warning` (`warningType: "policy_blocked"`) |
145
148
 
149
+ ### onUserPromptTransformed
150
+
151
+ Fires after the runtime adds generated context to the submitted prompt, before
152
+ the result is stored in session history or sent to the model. `prompt` is the
153
+ prompt after `onUserPromptSubmitted`; `transformedPrompt` also carries the
154
+ runtime-generated context.
155
+
156
+ **Input:** `{ prompt: string, transformedPrompt: string, timestamp, workingDirectory }`
157
+
158
+ **Output (all fields optional):**
159
+ | Field | Type | Effect |
160
+ |-------|------|--------|
161
+ | `modifiedTransformedPrompt` | `string` | Replaces the content stored in session history and sent to the model |
162
+
146
163
  ### onPreToolUse
147
164
 
148
165
  **Input:** `{ toolName: string, toolArgs: unknown, timestamp, workingDirectory }`
@@ -155,6 +172,19 @@ All handlers may return `void`/`undefined` (no-op) or an output object.
155
172
  | `modifiedArgs` | `unknown` | Replaces the tool arguments |
156
173
  | `additionalContext` | `string` | Injected into the conversation |
157
174
 
175
+ ### onPreMcpToolCall
176
+
177
+ Fires before a tool call is sent to an MCP server. It controls only the `_meta`
178
+ object sent with the request; to allow, deny or change the call itself, use
179
+ `onPreToolUse`.
180
+
181
+ **Input:** `{ toolCallId?: string, serverName: string, toolName: string, arguments: unknown, _meta?: Record<string, unknown>, timestamp, workingDirectory }`
182
+
183
+ **Output (all fields optional):**
184
+ | Field | Type | Effect |
185
+ |-------|------|--------|
186
+ | `metaToUse` | `Record<string, unknown> \| null` | An object becomes the request's `_meta`; `null` omits it; leaving it out keeps the current `_meta` |
187
+
158
188
  ### onPostToolUse
159
189
 
160
190
  **Input:** `{ toolName: string, toolArgs: unknown, toolResult: ToolResultObject, timestamp, workingDirectory }`
@@ -218,6 +248,23 @@ fire it.
218
248
  | `retryCount` | `number` | Max retries (when errorHandling is "retry") |
219
249
  | `userNotification` | `string` | Message shown to the user |
220
250
 
251
+ ### onAgentStop
252
+
253
+ Fires when the top-level agent reaches a natural terminal stop: it went idle
254
+ without pending work and was not aborted. Sub-agents fire `onSubagentStop`
255
+ instead.
256
+
257
+ **Input:** `{ stopReason?: string, transcriptPath?: string, stopHookActive?: boolean, timestamp, workingDirectory }`
258
+
259
+ `stopHookActive` is `true` when this stop follows an earlier `"block"` from this
260
+ hook; check it to avoid blocking indefinitely. The runtime also caps
261
+ consecutive blocks.
262
+
263
+ **Output (optional):**
264
+ | Field | Type | Effect |
265
+ |-------|------|--------|
266
+ | `decision` and `reason` | `"block"` and `string` | Keep the agent running; `reason` is enqueued as its next user message |
267
+
221
268
  ### onSubagentStart
222
269
 
223
270
  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 | Fires When | Can Modify |
156
- | ----------------------- | ---------------------------------------- | ------------------------------------------- |
157
- | `onUserPromptSubmitted` | User sends a message | The prompt text, add context |
158
- | `onPreToolUse` | Before a tool executes | Tool args, permission decision, add context |
159
- | `onPostToolUse` | After a tool executes successfully | Tool result, add context |
160
- | `onPostToolUseFailure` | After a tool execution returns a failure | Add hidden guidance to the model |
161
- | `onSessionStart` | Session starts or resumes | Add context |
162
- | `onSessionEnd` | Session ends | Cleanup actions, summary |
163
- | `onErrorOccurred` | An error occurs | Error handling strategy (retry/skip/abort) |
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-preview.8",
9
- "copilotCliVersion": "1.0.106-9",
8
+ "version": "1.0.29-preview.9",
9
+ "copilotCliVersion": "1.0.106-10",
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.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": "748c6af611e01288d99b688f61267884cb35ef25",
121
- "version": "1.0.106-9",
120
+ "sourceSha": "b3da66080b3d00711a816a990fdaf6308ff17a1f",
121
+ "version": "1.0.106-10",
122
122
  "visibility": "public"
123
123
  },
124
124
  "optionalDependencies": {
125
- "@github/copilot-sdk-darwin-arm64": "1.0.29-preview.8",
126
- "@github/copilot-sdk-darwin-x64": "1.0.29-preview.8",
127
- "@github/copilot-sdk-linux-arm64": "1.0.29-preview.8",
128
- "@github/copilot-sdk-linux-x64": "1.0.29-preview.8",
129
- "@github/copilot-sdk-linuxmusl-arm64": "1.0.29-preview.8",
130
- "@github/copilot-sdk-linuxmusl-x64": "1.0.29-preview.8",
131
- "@github/copilot-sdk-win32-arm64": "1.0.29-preview.8",
132
- "@github/copilot-sdk-win32-x64": "1.0.29-preview.8"
125
+ "@github/copilot-sdk-darwin-arm64": "1.0.29-preview.9",
126
+ "@github/copilot-sdk-darwin-x64": "1.0.29-preview.9",
127
+ "@github/copilot-sdk-linux-arm64": "1.0.29-preview.9",
128
+ "@github/copilot-sdk-linux-x64": "1.0.29-preview.9",
129
+ "@github/copilot-sdk-linuxmusl-arm64": "1.0.29-preview.9",
130
+ "@github/copilot-sdk-linuxmusl-x64": "1.0.29-preview.9",
131
+ "@github/copilot-sdk-win32-arm64": "1.0.29-preview.9",
132
+ "@github/copilot-sdk-win32-x64": "1.0.29-preview.9"
133
133
  }
134
134
  }