@github/copilot-sdk 1.0.13 → 1.0.14-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/dist/index.d.ts CHANGED
@@ -11,5 +11,5 @@ export { defineFactory, FactoryResumeError, isFactoryRunTerminal } from "./facto
11
11
  export { Canvas, CanvasError, createCanvas, type CanvasAction, type CanvasDeclaration, type CanvasHostContext, type CanvasHostContextCapabilities, type CanvasJsonSchema, type CanvasOptions, } from "./canvas.js";
12
12
  export { defineTool, approveAll, createAttributedPermissionResult, convertMcpCallToolResult, createSessionFsAdapter, CopilotRequestHandler, CopilotWebSocketHandler, CopilotWebSocketCloseStatus, CopilotWebSocketForwarder, SessionFsSqliteTransactionFailure, SYSTEM_MESSAGE_SECTIONS, } from "./types.js";
13
13
  export type * from "./generated/session-events.js";
14
- export type { AskUserVariant, CommandContext, CommandDefinition, CommandHandler, CanvasProviderIdentity, CloudSessionOptions, CloudSessionRepository, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, AgentStopHandler, AgentStopHookInput, AgentStopHookOutput, UserPromptTransformedHandler, UserPromptTransformedHookInput, UserPromptTransformedHookOutput, CopilotClientInfo, CopilotClientMode, CopilotClientOptions, CopilotExpAssignmentResponse, StdioRuntimeConnection, InProcessRuntimeConnection, TcpRuntimeConnection, UriRuntimeConnection, ChildProcessRuntimeConnection, CustomAgentConfig, ElicitationFieldValue, ElicitationHandler, ElicitationParams, ElicitationContext, ElicitationResult, ElicitationSchema, ElicitationSchemaField, ExpConfigEntry, ExpFlagValue, ExitPlanModeHandler, ExitPlanModeRequest, ExitPlanModeResult, ExtensionInfo, ForegroundSessionInfo, GetAuthStatusResponse, GetStatusResponse, GitHubMcpToolConfig, GitHubTelemetryNotification, GitHubTelemetryEvent, GitHubTelemetryClientInfo, GitHubTokenAcquireReason, GitHubTokenAcquireResult, GitHubTokenProvider, GitHubTokenProviderArgs, GitHubTokenProviderResult, InfiniteSessionConfig, LargeToolOutputConfig, MemoryConfiguration, UiInputOptions, FactoryLimits, FactoryMeta, MCPStdioServerConfig, MCPHTTPServerConfig, MCPServerConfig, DefaultAgentConfig, BearerTokenProvider, MessageOptions, ManagedSettings, ManagedSettingsPermissions, ModelBilling, ModelBillingTokenPrices, ModelBillingTokenPricesLongContext, AutoTier, CapiSessionOptions, CurrentModel, ModelSwitchAutoTierResult, ModelSwitchAutoTierStatus, ModelCapabilities, ModelCapabilitiesOverride, ModelInfo, ModelPolicy, NamedProviderConfig, PermissionHandler, PermissionRequest, PermissionRequestedData, PermissionRequestedEvent, PermissionRequestResult, AttributedPermissionResult, PermissionDecisionContext, PermissionDecisionOutcome, PermissionDecisionSource, PermissionDecisionSurface, PermissionResponseCapability, ProviderConfig, ProviderModelConfig, ProviderTokenArgs, RemoteSessionMode, ResumeSessionConfig, SectionOverride, SectionOverrideAction, SectionTransformFn, SessionCapabilities, SessionConfig, SessionConfigBase, SessionEvent, SessionEventHandler, SessionEventPayload, SessionEventType, SessionLifecycleEvent, SessionLifecycleEventMetadata, SessionLifecycleEventType, SessionLifecycleHandler, SessionHooks, SessionCreatedEvent, SessionDeletedEvent, SessionUpdatedEvent, SessionForegroundEvent, SessionBackgroundEvent, SessionContext, SessionListFilter, SessionMetadata, SessionUiApi, SessionFsConfig, SessionFsProvider, SessionFsFileInfo, SessionFsSqliteQueryResult, SessionFsSqliteQueryType, SessionFsSqliteProvider, SessionFsSqliteStatement, SessionFsSqliteTransactionErrorClass, CopilotRequestContext, SystemMessageAppendConfig, SystemMessageConfig, SystemMessageCustomizeConfig, SystemMessageReplaceConfig, SystemMessageSection, TelemetryConfig, TraceContext, TraceContextProvider, Tool, ToolHandler, ToolInvocation, CurrentToolMetadata, ToolTelemetry, ToolResultObject, ToolSearchConfig, TypedSessionEventHandler, TypedSessionLifecycleHandler, ZodSchema, } from "./types.js";
15
- export type { RunOptions, ResumeOptions, FactoryResumeErrorCode, SessionFactoryApi, FactoryAgentOptions, FactoryContext, FactoryDefinition, FactoryHandle, FactoryJsonSchema, JsonValue, FactoryPipelineStage, FactoryStepOptions, FactoryRunResult, FactoryRunStatus, FactoryRunSummary, FactoryListRunsOptions, FactoryRunsPage, FactoryRunDetail, FactoryProgressPage, FactoryProgressLine, FactoryPhaseObservation, FactoryPhaseStatus, FactoryAgentSummary, } from "./factory.js";
14
+ export type { AskUserVariant, CommandContext, CommandDefinition, CommandHandler, CanvasProviderIdentity, CloudSessionOptions, CloudSessionRepository, AutoModeSwitchHandler, AutoModeSwitchRequest, AutoModeSwitchResponse, AgentStopHandler, AgentStopHookInput, AgentStopHookOutput, UserPromptTransformedHandler, UserPromptTransformedHookInput, UserPromptTransformedHookOutput, CopilotClientInfo, CopilotClientMode, CopilotClientOptions, CopilotExpAssignmentResponse, StdioRuntimeConnection, InProcessRuntimeConnection, TcpRuntimeConnection, UriRuntimeConnection, ChildProcessRuntimeConnection, CustomAgentConfig, ElicitationFieldValue, ElicitationHandler, ElicitationParams, ElicitationContext, ElicitationResult, ElicitationSchema, ElicitationSchemaField, ExpConfigEntry, ExpFlagValue, ExitPlanModeHandler, ExitPlanModeRequest, ExitPlanModeResult, ExtensionInfo, ForegroundSessionInfo, GetAuthStatusResponse, GetStatusResponse, GitHubMcpToolConfig, GitHubTelemetryNotification, GitHubTelemetryEvent, GitHubTelemetryClientInfo, GitHubTokenAcquireReason, GitHubTokenAcquireResult, GitHubTokenProvider, GitHubTokenProviderArgs, GitHubTokenProviderResult, InfiniteSessionConfig, LargeToolOutputConfig, MemoryConfiguration, UiInputOptions, FactoryLimits, FactoryMeta, MCPStdioServerConfig, MCPHTTPServerConfig, MCPServerConfig, DefaultAgentConfig, BearerTokenProvider, MessageOptions, MessageSource, ManagedSettings, ManagedSettingsPermissions, ModelBilling, ModelBillingTokenPrices, ModelBillingTokenPricesLongContext, AutoTier, CapiSessionOptions, CurrentModel, ModelSwitchAutoTierResult, ModelSwitchAutoTierStatus, ModelCapabilities, ModelCapabilitiesOverride, ModelInfo, ModelPolicy, NamedProviderConfig, PermissionHandler, PermissionRequest, PermissionRequestedData, PermissionRequestedEvent, PermissionRequestResult, AttributedPermissionResult, PermissionDecisionContext, PermissionDecisionOutcome, PermissionDecisionSource, PermissionDecisionSurface, PermissionResponseCapability, ProviderConfig, ProviderModelConfig, ProviderTokenArgs, RemoteSessionMode, ResumeSessionConfig, SectionOverride, SectionOverrideAction, SectionTransformFn, SessionCapabilities, SessionConfig, SessionConfigBase, SessionEvent, SessionEventHandler, SessionEventPayload, SessionEventType, SessionLifecycleEvent, SessionLifecycleEventMetadata, SessionLifecycleEventType, SessionLifecycleHandler, SessionHooks, SessionCreatedEvent, SessionDeletedEvent, SessionUpdatedEvent, SessionForegroundEvent, SessionBackgroundEvent, SessionContext, SessionListFilter, SessionMetadata, SessionUiApi, SessionFsConfig, SessionFsProvider, SessionFsFileInfo, SessionFsSqliteQueryResult, SessionFsSqliteQueryType, SessionFsSqliteProvider, SessionFsSqliteStatement, SessionFsSqliteTransactionErrorClass, CopilotRequestContext, SystemMessageAppendConfig, SystemMessageConfig, SystemMessageCustomizeConfig, SystemMessageReplaceConfig, SystemMessageSection, TelemetryConfig, TraceContext, TraceContextProvider, Tool, ToolHandler, ToolInvocation, CurrentToolMetadata, ToolTelemetry, ToolResultObject, ToolSearchConfig, TypedSessionEventHandler, TypedSessionLifecycleHandler, ZodSchema, } from "./types.js";
15
+ export type { RunOptions, ResumeOptions, FactoryLimitOverrides, FactoryResumeErrorCode, SessionFactoryApi, FactoryAgentOptions, FactoryContext, FactoryDefinition, FactoryHandle, FactoryJsonSchema, JsonValue, FactoryPipelineStage, FactoryStepOptions, FactoryRunResult, FactoryRunStatus, FactoryRunSummary, FactoryListRunsOptions, FactoryRunsPage, FactoryRunDetail, FactoryProgressPage, FactoryProgressLine, FactoryPhaseObservation, FactoryPhaseStatus, FactoryAgentSummary, } from "./factory.js";
package/dist/session.d.ts CHANGED
@@ -59,6 +59,7 @@ export declare class CopilotSession {
59
59
  private hooks?;
60
60
  private transformCallbacks?;
61
61
  private _rpc;
62
+ private _internalRpc;
62
63
  private traceContextProvider?;
63
64
  private readonly managedSettingsEnabled;
64
65
  private _capabilities;
package/dist/session.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AsyncLocalStorage } from "node:async_hooks";
2
2
  import { ConnectionError, ErrorCodes, ResponseError } from "vscode-jsonrpc/node.js";
3
- import { createSessionRpc } from "./generated/rpc.js";
3
+ import { createInternalSessionRpc, createSessionRpc } from "./generated/rpc.js";
4
4
  import { CanvasError } from "./canvas.js";
5
5
  import { getTraceContext } from "./telemetry.js";
6
6
  import { isAttributedPermissionResult } from "./types.js";
@@ -23,10 +23,14 @@ const factoryExecutionStore = new AsyncLocalStorage();
23
23
  function throwIfFactoryExecutionIsActive() {
24
24
  if (factoryExecutionStore.getStore()?.active) {
25
25
  throw new Error(
26
- "factory.run and factory.resume are not allowed while a factory body is running on this call path."
26
+ "factory.run, factory.resume, and factory.pause are not allowed while a factory body is running on this call path."
27
27
  );
28
28
  }
29
29
  }
30
+ function runInFactoryHelperScope(helperScope, callback) {
31
+ const current = factoryExecutionStore.getStore();
32
+ return factoryExecutionStore.run({ active: current?.active ?? false, helperScope }, callback);
33
+ }
30
34
  function deserializeHookInput(raw) {
31
35
  if (!raw || typeof raw !== "object" || typeof raw.timestamp !== "number") {
32
36
  return raw;
@@ -70,7 +74,7 @@ async function runFactoryParallel(thunks) {
70
74
  }
71
75
  return Promise.all(
72
76
  thunks.map(
73
- (thunk) => Promise.resolve().then(() => thunk()).catch((error) => {
77
+ (thunk) => Promise.resolve().then(() => runInFactoryHelperScope("parallel", thunk)).catch((error) => {
74
78
  if (isFactoryFatalError(error)) {
75
79
  throw error;
76
80
  }
@@ -89,7 +93,10 @@ async function runFactoryPipeline(items, ...stages) {
89
93
  let previous = item;
90
94
  for (const stage of stages) {
91
95
  try {
92
- previous = await stage(previous, item, index);
96
+ previous = await runInFactoryHelperScope(
97
+ "pipeline",
98
+ () => stage(previous, item, index)
99
+ );
93
100
  } catch (error) {
94
101
  if (isFactoryFatalError(error)) {
95
102
  throw error;
@@ -246,6 +253,7 @@ class CopilotSession {
246
253
  hooks;
247
254
  transformCallbacks;
248
255
  _rpc = null;
256
+ _internalRpc = null;
249
257
  traceContextProvider;
250
258
  managedSettingsEnabled;
251
259
  _capabilities = {};
@@ -312,6 +320,10 @@ class CopilotSession {
312
320
  }),
313
321
  getRunDetail: (runId) => this.rpc.factory.getRunDetail({ runId }),
314
322
  getRunProgress: (runId, options = {}) => this.rpc.factory.getRunProgress({ runId, ...options }),
323
+ pause: async (runId) => {
324
+ throwIfFactoryExecutionIsActive();
325
+ return this.rpc.factory.pause({ runId });
326
+ },
315
327
  cancel: async (runId) => this.rpc.factory.cancel({ runId })
316
328
  };
317
329
  /**
@@ -410,6 +422,13 @@ class CopilotSession {
410
422
  }
411
423
  return this._rpc;
412
424
  }
425
+ /** @internal */
426
+ get internalRpc() {
427
+ if (!this._internalRpc) {
428
+ this._internalRpc = createInternalSessionRpc(this.connection, this.sessionId);
429
+ }
430
+ return this._internalRpc;
431
+ }
413
432
  /**
414
433
  * Path to the session workspace directory when infinite sessions are enabled.
415
434
  * Contains checkpoints/, plan.md, and files/ subdirectories.
@@ -451,6 +470,7 @@ class CopilotSession {
451
470
  ...await getTraceContext(this.traceContextProvider),
452
471
  sessionId: this.sessionId,
453
472
  prompt: options.prompt,
473
+ source: options.source,
454
474
  displayPrompt: options.displayPrompt,
455
475
  attachments: options.attachments,
456
476
  mode: options.mode,
@@ -1091,6 +1111,36 @@ class CopilotSession {
1091
1111
  );
1092
1112
  return result2;
1093
1113
  },
1114
+ pause: async (key) => {
1115
+ if (typeof key !== "string" || key.length === 0) {
1116
+ throw new Error("Factory pause checkpoint key must not be empty");
1117
+ }
1118
+ const helperScope = factoryExecutionStore.getStore()?.helperScope;
1119
+ if (helperScope !== void 0) {
1120
+ throw new Error(
1121
+ `Factory pause checkpoints are not allowed inside ${helperScope}() branches`
1122
+ );
1123
+ }
1124
+ await progress.flush();
1125
+ const response = await awaitFactoryOperation(
1126
+ () => self.internalRpc.factory.pauseAtCheckpoint({
1127
+ runId: params.runId,
1128
+ executionToken: params.executionToken,
1129
+ key
1130
+ }),
1131
+ controller.signal
1132
+ );
1133
+ switch (response.action) {
1134
+ case "continue":
1135
+ return;
1136
+ case "pause":
1137
+ await awaitFactoryOperation(
1138
+ () => new Promise(() => {
1139
+ }),
1140
+ controller.signal
1141
+ );
1142
+ }
1143
+ },
1094
1144
  parallel: runFactoryParallel,
1095
1145
  pipeline: runFactoryPipeline,
1096
1146
  factory: async () => {
@@ -1126,11 +1176,9 @@ class CopilotSession {
1126
1176
  },
1127
1177
  async abort(params) {
1128
1178
  const controllersForRun = self.factoryAbortControllers.get(params.runId);
1129
- if (controllersForRun !== void 0) {
1130
- const reason = new DOMException("Factory run was aborted", "AbortError");
1131
- for (const controller of controllersForRun.values()) {
1132
- controller.abort(reason);
1133
- }
1179
+ const controller = controllersForRun?.get(params.executionToken);
1180
+ if (controller !== void 0) {
1181
+ controller.abort(new DOMException("Factory run was aborted", "AbortError"));
1134
1182
  }
1135
1183
  return {};
1136
1184
  }
package/dist/types.d.ts CHANGED
@@ -46,7 +46,8 @@ export type { SessionFsSqliteStatement } from "./sessionFsProvider.js";
46
46
  export type { SessionFsSqliteTransactionErrorClass } from "./sessionFsProvider.js";
47
47
  export { SessionFsSqliteTransactionFailure } from "./sessionFsProvider.js";
48
48
  export type { LlmInferenceHeaders } from "./generated/rpc.js";
49
- export type { PermissionDecisionContext, PermissionDecisionOutcome, PermissionDecisionSource, PermissionDecisionSurface, PermissionResponseCapability, } from "./generated/rpc.js";
49
+ export type { PermissionDecisionContext, PermissionDecisionOutcome, PermissionDecisionSurface, PermissionResponseCapability, } from "./generated/rpc.js";
50
+ export type { PermissionDecisionSource } from "./generated/session-events.js";
50
51
  export type { CopilotRequestContext } from "./copilotRequestHandler.js";
51
52
  export { CopilotRequestHandler, CopilotWebSocketHandler, CopilotWebSocketCloseStatus, CopilotWebSocketForwarder, } from "./copilotRequestHandler.js";
52
53
  /**
@@ -2244,6 +2245,11 @@ export interface SessionConfigBase {
2244
2245
  * @default "in-memory"
2245
2246
  */
2246
2247
  mcpOAuthTokenStorage?: "persistent" | "in-memory";
2248
+ /**
2249
+ * OAuth Client ID Metadata Document URL identifying the host for MCP authorization.
2250
+ * When unset, no host identity is supplied.
2251
+ */
2252
+ authClientIdMetadataUrl?: string;
2247
2253
  /**
2248
2254
  * MCP server configurations for the session.
2249
2255
  * Keys are server names, values are server configurations.
@@ -2730,11 +2736,21 @@ export interface ProviderModelConfig {
2730
2736
  */
2731
2737
  capabilities?: ModelCapabilitiesOverride;
2732
2738
  }
2739
+ /**
2740
+ * Message provenance, independent of delivery mode.
2741
+ */
2742
+ export type MessageSource = "user" | "system" | `agent-${string}`;
2733
2743
  export interface MessageOptions {
2734
2744
  /**
2735
2745
  * The prompt/message to send
2736
2746
  */
2737
2747
  prompt: string;
2748
+ /**
2749
+ * Optional message provenance. Omitted by default to preserve the runtime's
2750
+ * default for user messages. Use "system" for application-generated context
2751
+ * or `agent-${id}` for messages originating from an identified agent.
2752
+ */
2753
+ source?: MessageSource;
2738
2754
  /**
2739
2755
  * File, directory, selection, or blob attachments
2740
2756
  */
@@ -2909,6 +2925,7 @@ export interface ModelCapabilities {
2909
2925
  };
2910
2926
  limits: {
2911
2927
  max_prompt_tokens?: number;
2928
+ max_output_tokens?: number;
2912
2929
  max_context_window_tokens: number;
2913
2930
  vision?: {
2914
2931
  supported_media_types: string[];
package/docs/factories.md CHANGED
@@ -62,19 +62,20 @@ Validation covers the model's `run_factory` path only. An extension calling `ses
62
62
 
63
63
  The `run()` context provides:
64
64
 
65
- - `ctx.runId`: Stable ID reused across resumed attempts.
66
- - `ctx.args`: Invocation arguments, forwarded verbatim. When the caller omits `args`, this is `{}` rather than `undefined`.
67
- - `ctx.agent(prompt, options?)`: Runs one factory-owned subagent. Options are exactly `label`, `schema`, `model`, `agent`, `reasoningEffort`, and `contextTier`. See [Subagent calls](#subagent-calls).
68
- - `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.
69
- - `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.
70
- - `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.
71
- - `ctx.log(message)`: Appends a progress line. When a factory bounds its own coverage (top-N, sampling), log what was dropped.
72
- - `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.
65
+ * `ctx.runId`: Stable ID reused across resumed attempts.
66
+ * `ctx.args`: Invocation arguments, forwarded verbatim. When the caller omits `args`, this is `{}` rather than `undefined`.
67
+ * `ctx.agent(prompt, options?)`: Runs one factory-owned subagent. Options are exactly `label`, `schema`, `model`, `agent`, `reasoningEffort`, and `contextTier`. See [Subagent calls](#subagent-calls).
68
+ * `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.
69
+ * `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.
70
+ * `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.
71
+ * `ctx.log(message)`: Appends a progress line. When a factory bounds its own coverage (top-N, sampling), log what was dropped.
72
+ * `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.
73
73
 
74
74
  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.
75
- - `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.
76
- - `ctx.signal`: Cooperative cancellation signal for extension work and subprocesses.
77
- - `ctx.factory(...)`: Always rejects because nested factories are not supported.
75
+ * `ctx.pause(key)`: Pauses at a durable, one-shot checkpoint. The first attempt records the checkpoint, pauses, and throws `AbortError` after cooperative cancellation. When the run resumes, the factory starts again and the same checkpoint returns so execution can continue. Call it only from the main factory flow, not inside `ctx.parallel()` or `ctx.pipeline()`.
76
+ * `ctx.session`: The session returned by `joinSession`. It refuses calls that start, resume, or pause a factory run. Call `extensions_manage` with `operation: "guide"` to read more about the session APIs.
77
+ * `ctx.signal`: Cooperative cancellation signal for extension work and subprocesses.
78
+ * `ctx.factory(...)`: Always rejects because nested factories are not supported.
78
79
 
79
80
  Factory-owned subagents are intentionally hidden from `read_agent` and `write_agent`. Use the factory observability APIs instead.
80
81
 
@@ -157,7 +158,7 @@ session.factory.run(
157
158
  name: string,
158
159
  options?: {
159
160
  args?: JsonValue;
160
- limits?: FactoryLimits;
161
+ limits?: FactoryLimitOverrides;
161
162
  notifyOnComplete?: boolean;
162
163
  logPhaseNames?: boolean;
163
164
  },
@@ -180,7 +181,7 @@ The signature is:
180
181
  session.factory.resume(
181
182
  runId: string,
182
183
  options?: {
183
- limits?: FactoryLimits;
184
+ limits?: FactoryLimitOverrides;
184
185
  notifyOnComplete?: boolean;
185
186
  logPhaseNames?: boolean;
186
187
  },
@@ -189,15 +190,31 @@ session.factory.resume(
189
190
 
190
191
  Set `notifyOnComplete` to `true` for factories that are likely to be invoked by an agent, so the originating session is notified when the factory completes. Set it to `false` for factories intended to be invoked programmatically, where the caller awaits the result directly. Set `logPhaseNames` to emit factory phase names to the session transcript. Both options apply to new and resumed runs.
191
192
 
192
- 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`.
193
+ Both resolve with the run envelope (`FactoryRunResult`) for **every** outcome—`completed`, `error`, `halted`, `paused`, and `cancelled` alike. Inspect `status` and read `result` only when the run completed; a limit breach carries a typed `failure`. A `paused` envelope means that the current attempt settled, not that the durable run is permanently finished. Resume the same run ID to start another attempt with its journal and accounting intact. 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`.
193
194
 
194
195
  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.
195
196
 
197
+ Pause a running attempt from outside its factory body:
198
+
199
+ ```ts
200
+ const paused = await session.factory.pause(runId);
201
+ ```
202
+
203
+ Inside a factory body, use a durable checkpoint instead:
204
+
205
+ ```ts
206
+ await ctx.step("prepare", prepareInput);
207
+ await ctx.pause("review-ready");
208
+ await ctx.agent("Review the prepared input");
209
+ ```
210
+
211
+ The first attempt pauses at `"review-ready"` and ends through cooperative cancellation. On resume, the factory starts from the beginning, reuses the journaled step, returns from the checkpoint, and continues.
212
+
196
213
  The agent-facing `run_factory` tool has exactly two input branches:
197
214
 
198
215
  ```ts
199
- { name: string; args?: JsonValue; limits?: FactoryLimits }
200
- { resumeFromRunId: string; limits?: FactoryLimits }
216
+ { name: string; args?: JsonValue; limits?: FactoryLimitOverrides }
217
+ { resumeFromRunId: string; limits?: FactoryLimitOverrides }
201
218
  ```
202
219
 
203
220
  ## Authoring a factory from inside a session
@@ -253,9 +270,9 @@ const progressPage = await session.factory.getRunProgress(runId, {
253
270
  - `getRunDetail(runId)` returns phases, prompt-safe agent summaries, and the latest progress page.
254
271
  - `getRunProgress(runId, options?)` pages progress forward, backward, by phase, or from the latest tail.
255
272
 
256
- `getRun(runId)` reads the latest run envelope, and `cancel(runId)` cancels a run and returns its terminal envelope.
273
+ `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.
257
274
 
258
- `waitForRun(runId, options?)` resolves with the terminal envelope once the run settles into `completed`, `error`, `halted`, or `cancelled`, and resolves immediately when it has already settled:
275
+ `waitForRun(runId, options?)` resolves with the current attempt's envelope once it settles into `completed`, `error`, `halted`, `paused`, or `cancelled`. It resolves immediately when the current attempt has already settled:
259
276
 
260
277
  ```ts
261
278
  const settled = await session.factory.waitForRun(runId);
@@ -272,7 +289,7 @@ setTimeout(() => controller.abort(), 30_000);
272
289
  const settled = await session.factory.waitForRun(runId, { signal: controller.signal });
273
290
  ```
274
291
 
275
- Aborting rejects the wait and has no effect on the run, which keeps executing — use `cancel(runId)` to actually stop it. Because a terminal envelope is final, the resolved value never changes afterwards. `isFactoryRunTerminal(status)` exposes the same terminal-status test for callers driving their own loop.
292
+ Aborting rejects the wait and has no effect on the run, which keeps executing—use `pause(runId)` or `cancel(runId)` to stop it. The resolved object is a snapshot of that settled attempt. If its status is `paused`, a later resume updates the durable envelope under the same run ID. Call `getRun(runId)` to read the latest envelope. `isFactoryRunTerminal(status)` exposes the same current-attempt settlement test for callers driving their own loop.
276
293
 
277
294
  Listen for the ephemeral `factory.run_updated` event. Its `{ runId, revision }` payload is an invalidation signal. Re-read the desired API when a newer monotonic revision arrives.
278
295
 
package/package.json CHANGED
@@ -4,8 +4,8 @@
4
4
  "type": "git",
5
5
  "url": "https://github.com/github/copilot-sdk.git"
6
6
  },
7
- "version": "1.0.13",
8
- "copilotCliVersion": "1.0.83",
7
+ "version": "1.0.14-preview.1",
8
+ "copilotCliVersion": "1.0.84-5",
9
9
  "description": "TypeScript SDK for programmatic control of GitHub Copilot CLI via JSON-RPC",
10
10
  "main": "./dist/cjs/index.js",
11
11
  "types": "./dist/index.d.ts",
@@ -33,6 +33,7 @@
33
33
  },
34
34
  "type": "module",
35
35
  "scripts": {
36
+ "auth:refresh": "node ../scripts/npm-auth-refresh.mjs --run",
36
37
  "clean": "rimraf --glob dist *.tgz",
37
38
  "build": "tsx esbuild-copilotsdk-nodejs.ts",
38
39
  "pack:release": "tsx scripts/package-sdk.ts",
@@ -61,7 +62,7 @@
61
62
  "author": "GitHub",
62
63
  "license": "MIT",
63
64
  "dependencies": {
64
- "koffi": "^3.1.0",
65
+ "koffi": "^3.2.1",
65
66
  "vscode-jsonrpc": "^8.2.1",
66
67
  "zod": "^4.3.6"
67
68
  },
@@ -95,13 +96,13 @@
95
96
  "README.md"
96
97
  ],
97
98
  "optionalDependencies": {
98
- "@github/copilot-sdk-darwin-arm64": "1.0.13",
99
- "@github/copilot-sdk-darwin-x64": "1.0.13",
100
- "@github/copilot-sdk-linux-arm64": "1.0.13",
101
- "@github/copilot-sdk-linux-x64": "1.0.13",
102
- "@github/copilot-sdk-linuxmusl-arm64": "1.0.13",
103
- "@github/copilot-sdk-linuxmusl-x64": "1.0.13",
104
- "@github/copilot-sdk-win32-arm64": "1.0.13",
105
- "@github/copilot-sdk-win32-x64": "1.0.13"
99
+ "@github/copilot-sdk-darwin-arm64": "1.0.14-preview.1",
100
+ "@github/copilot-sdk-darwin-x64": "1.0.14-preview.1",
101
+ "@github/copilot-sdk-linux-arm64": "1.0.14-preview.1",
102
+ "@github/copilot-sdk-linux-x64": "1.0.14-preview.1",
103
+ "@github/copilot-sdk-linuxmusl-arm64": "1.0.14-preview.1",
104
+ "@github/copilot-sdk-linuxmusl-x64": "1.0.14-preview.1",
105
+ "@github/copilot-sdk-win32-arm64": "1.0.14-preview.1",
106
+ "@github/copilot-sdk-win32-x64": "1.0.14-preview.1"
106
107
  }
107
108
  }