@github/copilot-sdk 1.0.10-preview.0 → 1.0.11-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.
@@ -2,6 +2,10 @@
2
2
  * AUTO-GENERATED FILE - DO NOT EDIT
3
3
  * Generated from: session-events.schema.json
4
4
  */
5
+ /** A value that can be represented losslessly on the SDK JSON wire. */
6
+ export type JsonValue = null | boolean | number | string | JsonValue[] | {
7
+ [key: string]: JsonValue;
8
+ };
5
9
  /**
6
10
  * Union of all session event variants emitted by the Copilot CLI runtime.
7
11
  */
@@ -484,6 +488,10 @@ export type ElicitationCompletedAction =
484
488
  | "decline"
485
489
  /** The user dismissed the request. */
486
490
  | "cancel";
491
+ /**
492
+ * Opaque JSON value submitted for one field in accepted `elicitation.completed` form content.
493
+ */
494
+ export type ElicitationCompletedContent = JsonValue | undefined;
487
495
  /**
488
496
  * Reason the runtime is requesting host-provided MCP OAuth credentials
489
497
  */
@@ -524,6 +532,10 @@ export type McpHeadersRefreshCompletedOutcome =
524
532
  | "none"
525
533
  /** No response arrived within the bounded window. */
526
534
  | "timeout";
535
+ /**
536
+ * Source-defined JSON payload for the custom notification
537
+ */
538
+ export type CustomNotificationPayload = JsonValue;
527
539
  /**
528
540
  * The user's auto-mode-switch choice
529
541
  */
@@ -3024,9 +3036,7 @@ export interface AttachmentExtensionContext {
3024
3036
  /**
3025
3037
  * Caller-supplied JSON payload
3026
3038
  */
3027
- payload?: {
3028
- [k: string]: unknown | undefined;
3029
- };
3039
+ payload?: JsonValue;
3030
3040
  /**
3031
3041
  * Human-readable composer pill label
3032
3042
  */
@@ -3566,9 +3576,7 @@ export interface CitationReference {
3566
3576
  /**
3567
3577
  * Provider-native citation correlation data (e.g. Anthropic search_result_index / document_index), passed through opaquely for debugging and forward compatibility.
3568
3578
  */
3569
- providerMetadata?: {
3570
- [k: string]: unknown | undefined;
3571
- };
3579
+ providerMetadata?: JsonValue;
3572
3580
  /**
3573
3581
  * Identifier of the CitationSource this reference points to (CitationSource.id).
3574
3582
  */
@@ -3637,9 +3645,9 @@ export interface AssistantMessageServerTools {
3637
3645
  functionCallNamespaces?: {
3638
3646
  [k: string]: string | undefined;
3639
3647
  };
3640
- items?: unknown[];
3648
+ items?: JsonValue[];
3641
3649
  provider: string;
3642
- rawContentBlocks?: unknown[];
3650
+ rawContentBlocks?: JsonValue[];
3643
3651
  }
3644
3652
  /**
3645
3653
  * A tool invocation request from the assistant
@@ -3648,9 +3656,7 @@ export interface AssistantMessageToolRequest {
3648
3656
  /**
3649
3657
  * Arguments to pass to the tool, format depends on the tool
3650
3658
  */
3651
- arguments?: {
3652
- [k: string]: unknown | undefined;
3653
- };
3659
+ arguments?: JsonValue;
3654
3660
  /**
3655
3661
  * Resolved intention summary describing what this specific call does
3656
3662
  */
@@ -4209,9 +4215,7 @@ export interface ToolUserRequestedData {
4209
4215
  /**
4210
4216
  * Arguments for the tool invocation
4211
4217
  */
4212
- arguments?: {
4213
- [k: string]: unknown | undefined;
4214
- };
4218
+ arguments?: JsonValue;
4215
4219
  /**
4216
4220
  * Unique identifier for this tool call
4217
4221
  */
@@ -4258,9 +4262,7 @@ export interface ToolExecutionStartData {
4258
4262
  /**
4259
4263
  * Arguments passed to the tool
4260
4264
  */
4261
- arguments?: {
4262
- [k: string]: unknown | undefined;
4263
- };
4265
+ arguments?: JsonValue;
4264
4266
  /**
4265
4267
  * When true, the tool output should be displayed expanded (verbatim) in the CLI timeline
4266
4268
  */
@@ -4484,9 +4486,7 @@ export interface ToolExecutionCompleteData {
4484
4486
  *
4485
4487
  * @experimental
4486
4488
  */
4487
- mcpMeta?: {
4488
- [k: string]: unknown | undefined;
4489
- };
4489
+ mcpMeta?: JsonValue;
4490
4490
  /**
4491
4491
  * Model identifier that generated this tool call
4492
4492
  */
@@ -4515,7 +4515,7 @@ export interface ToolExecutionCompleteData {
4515
4515
  * Tool-specific telemetry data (e.g., CodeQL check counts, grep match counts)
4516
4516
  */
4517
4517
  toolTelemetry?: {
4518
- [k: string]: unknown | undefined;
4518
+ [k: string]: JsonValue | undefined;
4519
4519
  };
4520
4520
  /**
4521
4521
  * Identifier for the agent loop turn this tool was invoked in, matching the corresponding assistant.turn_start event
@@ -4568,15 +4568,11 @@ export interface ToolExecutionCompleteResult {
4568
4568
  *
4569
4569
  * @experimental
4570
4570
  */
4571
- mcpMeta?: {
4572
- [k: string]: unknown | undefined;
4573
- };
4571
+ mcpMeta?: JsonValue;
4574
4572
  /**
4575
4573
  * Structured content (arbitrary JSON) returned verbatim by the MCP tool
4576
4574
  */
4577
- structuredContent?: {
4578
- [k: string]: unknown | undefined;
4579
- };
4575
+ structuredContent?: JsonValue;
4580
4576
  uiResource?: ToolExecutionCompleteUIResource;
4581
4577
  }
4582
4578
  /**
@@ -4595,7 +4591,7 @@ export interface PersistedBinaryImage {
4595
4591
  * Optional metadata from the producing tool.
4596
4592
  */
4597
4593
  metadata?: {
4598
- [k: string]: unknown | undefined;
4594
+ [k: string]: JsonValue | undefined;
4599
4595
  };
4600
4596
  /**
4601
4597
  * MIME type of the binary data
@@ -4620,7 +4616,7 @@ export interface OmittedBinaryResult {
4620
4616
  * Optional metadata from the producing tool.
4621
4617
  */
4622
4618
  metadata?: {
4623
- [k: string]: unknown | undefined;
4619
+ [k: string]: JsonValue | undefined;
4624
4620
  };
4625
4621
  /**
4626
4622
  * MIME type of the omitted binary data
@@ -4650,7 +4646,7 @@ export interface BinaryAssetReference {
4650
4646
  * Optional metadata from the producing tool.
4651
4647
  */
4652
4648
  metadata?: {
4653
- [k: string]: unknown | undefined;
4649
+ [k: string]: JsonValue | undefined;
4654
4650
  };
4655
4651
  /**
4656
4652
  * MIME type of the referenced binary data
@@ -5201,6 +5197,10 @@ export interface SubagentCompletedData {
5201
5197
  * Internal name of the sub-agent
5202
5198
  */
5203
5199
  agentName: string;
5200
+ /**
5201
+ * Whether the sub-agent was torn down by cancellation - its own abort, or an ancestor being killed - instead of finishing its work. Cancellation is not a failure, so the run still reports completion; this distinguishes a torn-down sub-agent from one that ran to the end.
5202
+ */
5203
+ cancelled?: boolean;
5204
5204
  /**
5205
5205
  * Wall-clock duration of the sub-agent execution in milliseconds
5206
5206
  */
@@ -5416,9 +5416,7 @@ export interface HookStartData {
5416
5416
  /**
5417
5417
  * Input data passed to the hook
5418
5418
  */
5419
- input?: {
5420
- [k: string]: unknown | undefined;
5421
- };
5419
+ input?: JsonValue;
5422
5420
  }
5423
5421
  /**
5424
5422
  * Session event "hook.end". Hook invocation completion details including output, success status, and error information
@@ -5466,9 +5464,7 @@ export interface HookEndData {
5466
5464
  /**
5467
5465
  * Output data produced by the hook
5468
5466
  */
5469
- output?: {
5470
- [k: string]: unknown | undefined;
5471
- };
5467
+ output?: JsonValue;
5472
5468
  /**
5473
5469
  * Whether the hook completed successfully
5474
5470
  */
@@ -5589,7 +5585,7 @@ export interface BinaryAssetData {
5589
5585
  * Optional metadata from the producing tool.
5590
5586
  */
5591
5587
  metadata?: {
5592
- [k: string]: unknown | undefined;
5588
+ [k: string]: JsonValue | undefined;
5593
5589
  };
5594
5590
  /**
5595
5591
  * MIME type of the binary asset
@@ -5658,7 +5654,7 @@ export interface SystemMessageMetadata {
5658
5654
  * Template variables used when constructing the prompt
5659
5655
  */
5660
5656
  variables?: {
5661
- [k: string]: unknown | undefined;
5657
+ [k: string]: JsonValue | undefined;
5662
5658
  };
5663
5659
  }
5664
5660
  /**
@@ -5863,9 +5859,7 @@ export interface SystemNotificationFactoryCompleted {
5863
5859
  /**
5864
5860
  * Machine-readable terminal failure details, when present.
5865
5861
  */
5866
- failure?: {
5867
- [k: string]: unknown | undefined;
5868
- };
5862
+ failure?: JsonValue;
5869
5863
  /**
5870
5864
  * Bounded prompt-safe preview of the completed result.
5871
5865
  */
@@ -5891,9 +5885,7 @@ export interface SystemNotificationUnclassified {
5891
5885
  /**
5892
5886
  * Opaque metadata supplied by the external host, when present.
5893
5887
  */
5894
- metadata?: {
5895
- [k: string]: unknown | undefined;
5896
- };
5888
+ metadata?: JsonValue;
5897
5889
  /**
5898
5890
  * Type discriminator. Always "unclassified".
5899
5891
  */
@@ -5946,9 +5938,7 @@ export interface PermissionRequestedData {
5946
5938
  /**
5947
5939
  * Neutral risk metadata supplied by the tool host. Consumers may display this value but must not use it to bypass the permission decision.
5948
5940
  */
5949
- riskAssessment?: {
5950
- [k: string]: unknown | undefined;
5951
- };
5941
+ riskAssessment?: JsonValue;
5952
5942
  }
5953
5943
  /**
5954
5944
  * Shell command permission request
@@ -6131,9 +6121,7 @@ export interface PermissionRequestMcp {
6131
6121
  /**
6132
6122
  * Arguments to pass to the MCP tool
6133
6123
  */
6134
- args?: {
6135
- [k: string]: unknown | undefined;
6136
- };
6124
+ args?: JsonValue;
6137
6125
  /**
6138
6126
  * Permission kind discriminator
6139
6127
  */
@@ -6234,9 +6222,7 @@ export interface PermissionRequestCustomTool {
6234
6222
  /**
6235
6223
  * Arguments to pass to the custom tool
6236
6224
  */
6237
- args?: {
6238
- [k: string]: unknown | undefined;
6239
- };
6225
+ args?: JsonValue;
6240
6226
  /**
6241
6227
  * Permission kind discriminator
6242
6228
  */
@@ -6269,9 +6255,7 @@ export interface PermissionRequestHook {
6269
6255
  /**
6270
6256
  * Arguments of the tool call being gated
6271
6257
  */
6272
- toolArgs?: {
6273
- [k: string]: unknown | undefined;
6274
- };
6258
+ toolArgs?: JsonValue;
6275
6259
  /**
6276
6260
  * Tool call ID that triggered this permission request
6277
6261
  */
@@ -6530,9 +6514,7 @@ export interface PermissionPromptRequestMcp {
6530
6514
  /**
6531
6515
  * Arguments to pass to the MCP tool
6532
6516
  */
6533
- args?: {
6534
- [k: string]: unknown | undefined;
6535
- };
6517
+ args?: JsonValue;
6536
6518
  /**
6537
6519
  * Auto-approval judge information for this request; present only when auto mode is enabled.
6538
6520
  *
@@ -6647,9 +6629,7 @@ export interface PermissionPromptRequestCustomTool {
6647
6629
  /**
6648
6630
  * Arguments to pass to the custom tool
6649
6631
  */
6650
- args?: {
6651
- [k: string]: unknown | undefined;
6652
- };
6632
+ args?: JsonValue;
6653
6633
  /**
6654
6634
  * Auto-approval judge information for this request; present only when auto mode is enabled.
6655
6635
  *
@@ -6718,9 +6698,7 @@ export interface PermissionPromptRequestHook {
6718
6698
  /**
6719
6699
  * Arguments of the tool call being gated
6720
6700
  */
6721
- toolArgs?: {
6722
- [k: string]: unknown | undefined;
6723
- };
6701
+ toolArgs?: JsonValue;
6724
6702
  /**
6725
6703
  * Tool call ID that triggered this permission request
6726
6704
  */
@@ -7300,7 +7278,7 @@ export interface ElicitationRequestedSchema {
7300
7278
  * Form field definitions, keyed by field name
7301
7279
  */
7302
7280
  properties: {
7303
- [k: string]: unknown | undefined;
7281
+ [k: string]: JsonValue | undefined;
7304
7282
  };
7305
7283
  /**
7306
7284
  * List of required field names
@@ -7357,12 +7335,6 @@ export interface ElicitationCompletedData {
7357
7335
  */
7358
7336
  requestId: string;
7359
7337
  }
7360
- /**
7361
- * Opaque JSON value submitted for one field in accepted `elicitation.completed` form content.
7362
- */
7363
- export interface ElicitationCompletedContent {
7364
- [k: string]: unknown | undefined;
7365
- }
7366
7338
  /**
7367
7339
  * Session event "sampling.requested". Sampling request from an MCP server; contains the server name and a requestId for correlation
7368
7340
  */
@@ -7400,9 +7372,7 @@ export interface SamplingRequestedData {
7400
7372
  /**
7401
7373
  * The JSON-RPC request ID from the MCP protocol
7402
7374
  */
7403
- mcpRequestId: {
7404
- [k: string]: unknown | undefined;
7405
- };
7375
+ mcpRequestId: JsonValue;
7406
7376
  /**
7407
7377
  * Unique identifier for this sampling request; used to respond via session.respondToSampling()
7408
7378
  */
@@ -7751,12 +7721,6 @@ export interface CustomNotificationData {
7751
7721
  */
7752
7722
  version?: number;
7753
7723
  }
7754
- /**
7755
- * Source-defined JSON payload for the custom notification
7756
- */
7757
- export interface CustomNotificationPayload {
7758
- [k: string]: unknown | undefined;
7759
- }
7760
7724
  /**
7761
7725
  * Optional source-defined string identifiers describing the payload subject
7762
7726
  */
@@ -7800,9 +7764,7 @@ export interface ExternalToolRequestedData {
7800
7764
  /**
7801
7765
  * Arguments to pass to the external tool
7802
7766
  */
7803
- arguments?: {
7804
- [k: string]: unknown | undefined;
7805
- };
7767
+ arguments?: JsonValue;
7806
7768
  /**
7807
7769
  * Unique identifier for this request; used to respond via session.respondToExternalTool()
7808
7770
  */
@@ -8355,9 +8317,7 @@ export interface ManagedSettingsResolvedData {
8355
8317
  /**
8356
8318
  * The effective (resolved) managed settings values, so clients can render exactly what is enforced. Absent when no managed policy is in force.
8357
8319
  */
8358
- settings?: {
8359
- [k: string]: unknown | undefined;
8360
- };
8320
+ settings?: JsonValue;
8361
8321
  source: ManagedSettingsResolvedSource;
8362
8322
  }
8363
8323
  /**
@@ -9208,9 +9168,7 @@ export interface CanvasOpenedData {
9208
9168
  /**
9209
9169
  * Input supplied when the instance was opened
9210
9170
  */
9211
- input?: {
9212
- [k: string]: unknown | undefined;
9213
- };
9171
+ input?: JsonValue;
9214
9172
  /**
9215
9173
  * Stable caller-supplied canvas instance identifier
9216
9174
  */
@@ -9305,9 +9263,7 @@ export interface CanvasRegistryChangedCanvas {
9305
9263
  /**
9306
9264
  * JSON Schema for canvas open input
9307
9265
  */
9308
- inputSchema?: {
9309
- [k: string]: unknown | undefined;
9310
- };
9266
+ inputSchema?: JsonValue;
9311
9267
  }
9312
9268
  /**
9313
9269
  * A single action within a canvas declaration, with its name, optional description, and optional input schema.
@@ -9321,9 +9277,7 @@ export interface CanvasRegistryChangedCanvasAction {
9321
9277
  /**
9322
9278
  * JSON Schema for action input
9323
9279
  */
9324
- inputSchema?: {
9325
- [k: string]: unknown | undefined;
9326
- };
9280
+ inputSchema?: JsonValue;
9327
9281
  /**
9328
9282
  * Action name
9329
9283
  */
@@ -9474,9 +9428,7 @@ export interface CanvasRecordedData {
9474
9428
  /**
9475
9429
  * Input supplied when the instance was opened
9476
9430
  */
9477
- input?: {
9478
- [k: string]: unknown | undefined;
9479
- };
9431
+ input?: JsonValue;
9480
9432
  /**
9481
9433
  * Stable caller-supplied canvas instance identifier
9482
9434
  */
@@ -9612,7 +9564,7 @@ export interface McpAppToolCallCompleteData {
9612
9564
  * Arguments passed to the tool by the app view, if any
9613
9565
  */
9614
9566
  arguments?: {
9615
- [k: string]: unknown | undefined;
9567
+ [k: string]: JsonValue | undefined;
9616
9568
  };
9617
9569
  /**
9618
9570
  * Wall-clock duration of the underlying tools/call in milliseconds
@@ -9623,7 +9575,7 @@ export interface McpAppToolCallCompleteData {
9623
9575
  * Standard MCP CallToolResult returned by the server. Present whether or not the call set isError.
9624
9576
  */
9625
9577
  result?: {
9626
- [k: string]: unknown | undefined;
9578
+ [k: string]: JsonValue | undefined;
9627
9579
  };
9628
9580
  /**
9629
9581
  * Name of the MCP server hosting the tool
package/dist/session.js CHANGED
@@ -1,14 +1,30 @@
1
+ import { AsyncLocalStorage } from "node:async_hooks";
1
2
  import { ConnectionError, ErrorCodes, ResponseError } from "vscode-jsonrpc/node.js";
2
3
  import { createSessionRpc } from "./generated/rpc.js";
3
4
  import { CanvasError } from "./canvas.js";
4
5
  import { getTraceContext } from "./telemetry.js";
5
6
  import {
7
+ FACTORY_AGENT_OPTION_KEYS,
6
8
  getFactoryDefinition,
7
9
  FactoryResumeError,
8
10
  isFactoryRunTerminal
9
11
  } from "./factory.js";
10
12
  function isFactoryResumeErrorCode(value) {
11
- return value === "not_found" || value === "non_resumable" || value === "already_active" || value === "reapproval_declined" || value === "no_approval_provider";
13
+ return value === "not_found" || value === "non_resumable" || value === "already_active" || value === "factory_already_running" || value === "factory_limits_invalid" || value === "factory_session_disposed" || value === "factory_storage_unavailable" || value === "factory_storage_corrupt";
14
+ }
15
+ function copyDefinedFactoryAgentOption(source, target, key) {
16
+ const value = source[key];
17
+ if (value !== void 0) {
18
+ target[key] = value;
19
+ }
20
+ }
21
+ const factoryExecutionStore = new AsyncLocalStorage();
22
+ function throwIfFactoryExecutionIsActive() {
23
+ if (factoryExecutionStore.getStore()?.active) {
24
+ throw new Error(
25
+ "factory.run and factory.resume are not allowed while a factory body is running on this call path."
26
+ );
27
+ }
12
28
  }
13
29
  function deserializeHookInput(raw) {
14
30
  if (!raw || typeof raw !== "object" || typeof raw.timestamp !== "number") {
@@ -129,7 +145,10 @@ class FactoryProgressBuffer {
129
145
  const lines = this.pending.splice(0);
130
146
  await this.flushTail;
131
147
  if (this.flushFailed) {
132
- throw this.flushError;
148
+ console.warn(
149
+ "Ignoring a background factory progress flush failure after the factory body settled",
150
+ this.flushError
151
+ );
133
152
  }
134
153
  if (lines.length > 0) {
135
154
  try {
@@ -160,9 +179,6 @@ class FactoryProgressBuffer {
160
179
  }
161
180
  }
162
181
  }
163
- function toPublicFactoryRunResult(envelope) {
164
- return envelope;
165
- }
166
182
  async function awaitFactoryOperation(operation, signal) {
167
183
  let rejectAbort;
168
184
  const abortPromise = new Promise((_resolve, reject) => {
@@ -242,6 +258,7 @@ class CopilotSession {
242
258
  */
243
259
  factory = {
244
260
  run: (async (nameOrHandle, options) => {
261
+ throwIfFactoryExecutionIsActive();
245
262
  const name = typeof nameOrHandle === "string" ? nameOrHandle : getFactoryDefinition(nameOrHandle).meta.name;
246
263
  if (options?.resumeFromRunId !== void 0) {
247
264
  return this.factory.resume(options.resumeFromRunId, {
@@ -258,6 +275,7 @@ class CopilotSession {
258
275
  return this.settleFactoryRun(envelope);
259
276
  }),
260
277
  resume: (async (runId, options) => {
278
+ throwIfFactoryExecutionIsActive();
261
279
  let response;
262
280
  try {
263
281
  response = await this.rpc.factory.resume({
@@ -275,12 +293,12 @@ class CopilotSession {
275
293
  }
276
294
  return this.settleFactoryRun(response.run);
277
295
  }),
278
- getRun: async (runId) => toPublicFactoryRunResult(await this.rpc.factory.getRun({ runId })),
296
+ getRun: async (runId) => this.rpc.factory.getRun({ runId }),
279
297
  waitForRun: (runId, options) => this.waitForFactoryRun(runId, options?.signal),
280
- listRuns: async () => (await this.rpc.factory.listRuns()).runs,
298
+ listRuns: async () => (await this.rpc.factory.listRuns({})).runs,
281
299
  getRunDetail: (runId) => this.rpc.factory.getRunDetail({ runId }),
282
300
  getRunProgress: (runId, options = {}) => this.rpc.factory.getRunProgress({ runId, ...options }),
283
- cancel: async (runId) => toPublicFactoryRunResult(await this.rpc.factory.cancel({ runId }))
301
+ cancel: async (runId) => this.rpc.factory.cancel({ runId })
284
302
  };
285
303
  /**
286
304
  * Resolve a start/resume envelope into the terminal envelope callers expect.
@@ -291,7 +309,7 @@ class CopilotSession {
291
309
  */
292
310
  settleFactoryRun(envelope) {
293
311
  if (isFactoryRunTerminal(envelope.status)) {
294
- return Promise.resolve(toPublicFactoryRunResult(envelope));
312
+ return Promise.resolve(envelope);
295
313
  }
296
314
  return this.waitForFactoryRun(envelope.runId);
297
315
  }
@@ -345,7 +363,7 @@ class CopilotSession {
345
363
  rereadRequested = false;
346
364
  const envelope = await this.rpc.factory.getRun({ runId });
347
365
  if (isFactoryRunTerminal(envelope.status)) {
348
- finish(() => resolve(toPublicFactoryRunResult(envelope)));
366
+ finish(() => resolve(envelope));
349
367
  return;
350
368
  }
351
369
  } while (rereadRequested && !settled);
@@ -945,16 +963,16 @@ class CopilotSession {
945
963
  },
946
964
  agent: async (prompt, options = {}) => {
947
965
  await progress.flush();
966
+ const opts = {};
967
+ for (const key of FACTORY_AGENT_OPTION_KEYS) {
968
+ copyDefinedFactoryAgentOption(options, opts, key);
969
+ }
948
970
  const response = await awaitFactoryOperation(
949
971
  () => self.rpc.factory.agent({
950
972
  factoryRunId: params.runId,
951
973
  executionToken: params.executionToken,
952
974
  prompt,
953
- opts: {
954
- label: options.label,
955
- schema: options.schema,
956
- model: options.model
957
- }
975
+ opts
958
976
  }),
959
977
  controller.signal
960
978
  );
@@ -1002,7 +1020,14 @@ class CopilotSession {
1002
1020
  throw new Error("nested factories are not supported");
1003
1021
  }
1004
1022
  };
1005
- const result = await definition.run(context);
1023
+ const execution = { active: true };
1024
+ const result = await factoryExecutionStore.run(execution, async () => {
1025
+ try {
1026
+ return await definition.run(context);
1027
+ } finally {
1028
+ execution.active = false;
1029
+ }
1030
+ });
1006
1031
  if (result === void 0) {
1007
1032
  return {};
1008
1033
  }
package/dist/types.d.ts CHANGED
@@ -6,6 +6,7 @@ import type { SessionFsProvider } from "./sessionFsProvider.js";
6
6
  import type { CopilotRequestHandler } from "./copilotRequestHandler.js";
7
7
  import type { PermissionRequest as GeneratedPermissionRequest, PermissionRequestedData as GeneratedPermissionRequestedData, PermissionRequestedEvent as GeneratedPermissionRequestedEvent, ReasoningSummary, SessionLimitsConfig, SessionEvent as GeneratedSessionEvent } from "./generated/session-events.js";
8
8
  import type { CopilotSession } from "./session.js";
9
+ import type { JsonValue } from "./factory.js";
9
10
  import type { GitHubTelemetryNotification, ModelBillingTokenPrices, OpenCanvasInstance, RemoteSessionMode, CurrentToolMetadata } from "./generated/rpc.js";
10
11
  import type { ToolSet } from "./toolSet.js";
11
12
  export type { RemoteSessionMode } from "./generated/rpc.js";
@@ -355,7 +356,7 @@ export type ToolBinaryResult = {
355
356
  type: "image" | "resource";
356
357
  description?: string;
357
358
  };
358
- export type ToolTelemetry = Record<string, Record<string, unknown> | undefined>;
359
+ export type ToolTelemetry = Record<string, Record<string, JsonValue> | undefined>;
359
360
  export type ToolResultObject = {
360
361
  textResultForLlm: string;
361
362
  binaryResultsForLlm?: ToolBinaryResult[];
@@ -1937,6 +1938,13 @@ export interface SessionConfigBase {
1937
1938
  * @experimental
1938
1939
  */
1939
1940
  enableCitations?: boolean;
1941
+ /**
1942
+ * Opt in to capturing file changes for session rewind and cumulative session
1943
+ * diff. On create, capture starts with the first turn. On resume, this can
1944
+ * enable tracking only when the session still has a valid baseline; it cannot
1945
+ * reconstruct changes from earlier untracked turns.
1946
+ */
1947
+ enableFileChangeTracking?: boolean;
1940
1948
  /**
1941
1949
  * Limits applied to this session's current accounting window.
1942
1950
  *
package/docs/factories.md CHANGED
@@ -53,7 +53,7 @@ The `run()` context provides:
53
53
 
54
54
  - `ctx.runId`: Stable ID reused across resumed attempts.
55
55
  - `ctx.args`: Invocation arguments, forwarded verbatim. When the caller omits `args`, this is `{}` rather than `undefined`.
56
- - `ctx.agent(prompt, options?)`: Runs one factory-owned subagent. Options are exactly `label`, `schema`, and `model`. See [Subagent calls](#subagent-calls).
56
+ - `ctx.agent(prompt, options?)`: Runs one factory-owned subagent. Options are exactly `label`, `schema`, `model`, `agent`, `reasoningEffort`, and `contextTier`. See [Subagent calls](#subagent-calls).
57
57
  - `ctx.parallel(thunks)`: Runs thunks concurrently and awaits all of them (a barrier). A thunk that throws becomes `null` in the result array, so one failed item does not lose the rest. Cancellation and hard runtime failures (`ResponseError`, `ConnectionError`) are the exception — those propagate and reject the whole call, because they mean the run itself is in trouble rather than one item having failed. Handle them at run level; do not assume every failure arrives as a `null`. Rejects above 4096 items.
58
58
  - `ctx.pipeline(items, ...stages)`: Flows each item through every stage without a barrier between stages, so one item can be in a later stage while another is still in an earlier one. Each stage is called as `(previous, item, index)`, where `previous` is the prior stage's result and `item` is the original input. A stage that throws drops that item to `null` and skips its remaining stages, with the same exception for cancellation and hard runtime failures. Rejects above 4096 items.
59
59
  - `ctx.phase(title)`: Starts a named progress phase. This sets a single run-global value, so calling it from inside concurrent `parallel`/`pipeline` stages races. Call it at run-level transitions and distinguish concurrent work by `label` instead.
@@ -61,7 +61,7 @@ The `run()` context provides:
61
61
  - `ctx.step(key, producer, options?)`: Journals the producer's JSON result under a stable key so a resume replays it without re-running the producer. A journaled (default) producer must return a JSON-serializable value; `undefined` or a non-JSON value is rejected. Pass `{ volatile: true }` to bypass the journal and run the producer every time.
62
62
 
63
63
  The key is the *sole* identity: neither the producer body nor its inputs contribute to it. A resume replays the cached value for a matching key even if the producer has since changed, so version the key (`"scan-v2"`) whenever its inputs or meaning change. Journaled producers are best-effort at-least-once and may run again across crashes or concurrent same-key callers, so keep side effects idempotent.
64
- - `ctx.session`: The full session returned by `joinSession`.
64
+ - `ctx.session`: The session returned by `joinSession`. It refuses calls that start or resume a factory run. Call `extensions_manage` with `operation: "guide"` to read more about the session APIs.
65
65
  - `ctx.signal`: Cooperative cancellation signal for extension work and subprocesses.
66
66
  - `ctx.factory(...)`: Always rejects because nested factories are not supported.
67
67
 
@@ -156,7 +156,7 @@ session.factory.resume(
156
156
  ): Promise<FactoryRunResult>;
157
157
  ```
158
158
 
159
- Both resolve with the run envelope (`FactoryRunResult`) for **every** outcome — `completed`, `error`, `halted`, and `cancelled` alike. Inspect `status` and read `result` only when the run completed; a limit breach carries a typed `failure`. A declined fresh run is not a pre-execution failure: the run row already exists by the time the prompt is answered, so it resolves with a terminal `cancelled` envelope carrying the run ID. Only failures that occur *before* a run exists reject: an unknown factory name or an already-active session. Pre-execution resume failures, including a declined reapproval, throw `FactoryResumeError`, whose `code` is one of `not_found`, `non_resumable`, `already_active`, `reapproval_declined`, or `no_approval_provider`.
159
+ Both resolve with the run envelope (`FactoryRunResult`) for **every** outcome — `completed`, `error`, `halted`, and `cancelled` alike. Inspect `status` and read `result` only when the run completed; a limit breach carries a typed `failure`. SDK-initiated `run` and `resume` do not request permission, so they have no declined outcome. The model's `run_factory` tool requests permission before the durable row exists; declining it creates no run row. An SDK-initiated run is refused only when the session already has its maximum number of active top-level runs. Pre-execution resume failures throw `FactoryResumeError`, whose `code` is one of `not_found`, `non_resumable`, `already_active`, `factory_already_running`, `factory_limits_invalid`, `factory_session_disposed`, `factory_storage_unavailable`, or `factory_storage_corrupt`.
160
160
 
161
161
  An agent that no longer has a prior run's ID in context can recover it with `factories_manage` and `operation: "runs"`, which lists the session's factory runs with their IDs and statuses. This matters for resume: a run that reached a limit keeps its journal, so resuming it replays completed work for free, while restarting it from scratch pays for that work twice.
162
162
 
@@ -210,7 +210,7 @@ const page = await session.factory.getRunProgress(runId, {
210
210
  });
211
211
  ```
212
212
 
213
- - `listRuns()` returns summaries in durable creation order.
213
+ - `listRuns()` returns the newest default page of this session's durable factory runs.
214
214
  - `getRunDetail(runId)` returns phases, prompt-safe agent summaries, and the latest progress page.
215
215
  - `getRunProgress(runId, options?)` pages progress forward, backward, by phase, or from the latest tail.
216
216
 
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": "1.0.10-preview.0",
7
+ "version": "1.0.11-preview.1",
8
8
  "description": "TypeScript SDK for programmatic control of GitHub Copilot CLI via JSON-RPC",
9
9
  "main": "./dist/cjs/index.js",
10
10
  "types": "./dist/index.d.ts",
@@ -56,7 +56,7 @@
56
56
  "author": "GitHub",
57
57
  "license": "MIT",
58
58
  "dependencies": {
59
- "@github/copilot": "^1.0.79-6",
59
+ "@github/copilot": "^1.0.79",
60
60
  "koffi": "^3.1.0",
61
61
  "vscode-jsonrpc": "^8.2.1",
62
62
  "zod": "^4.3.6"