@github/copilot-sdk 1.0.14-preview.0 → 1.0.14-unstable.35049111350.g7f86a90

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 CHANGED
@@ -21,6 +21,10 @@ release's `SHA256SUMS.txt`.
21
21
 
22
22
  `npm run pack:release` builds the main package and all platform packages. Set
23
23
  `COPILOT_CLI_DOWNLOAD_BASE_URL` to use a release mirror while packaging.
24
+ Release workflows instead set `COPILOT_SDK_RUNTIME_PACKAGE_DIR` to a directory
25
+ containing validated runtime npm package roots named for all eight platforms.
26
+ This keeps `COPILOT_CLI_USE_NPM_PACKAGE` false and embeds those runtime files in
27
+ the self-contained SDK platform packages.
24
28
 
25
29
  ## Installation
26
30
 
@@ -22,7 +22,7 @@ __export(cliVersion_exports, {
22
22
  COPILOT_CLI_VERSION: () => COPILOT_CLI_VERSION
23
23
  });
24
24
  module.exports = __toCommonJS(cliVersion_exports);
25
- const COPILOT_CLI_VERSION = "1.0.84-5";
25
+ const COPILOT_CLI_VERSION = "1.0.84-9.unstable.r35045926061.g4848e94";
26
26
  const COPILOT_CLI_USE_NPM_PACKAGE = false;
27
27
  // Annotate the CommonJS export names for ESM import in node:
28
28
  0 && (module.exports = {
@@ -28,6 +28,7 @@ module.exports = __toCommonJS(factory_exports);
28
28
  const FACTORY_TERMINAL_STATUSES = /* @__PURE__ */ new Set([
29
29
  "completed",
30
30
  "halted",
31
+ "paused",
31
32
  "cancelled",
32
33
  "error"
33
34
  ]);
@@ -760,15 +760,7 @@ function createInternalServerRpc(connection) {
760
760
  */
761
761
  getBoardEntryCount: async (params) => connection.sendRequest("sessions.getBoardEntryCount", params),
762
762
  /**
763
- * Registers extension-provided tools on the given session, gated by an optional `enabled` callback. Returns an opaque unsubscribe function the caller must invoke to deregister the tools when the extension is torn down. Marked internal because `loader`, `enabled`, and the returned `unsubscribe` are in-process handles that cannot cross the JSON-RPC boundary. Disappears once extension discovery / launch / tool registration are owned by the runtime: SDK consumers will pass pure config (search paths, disabled ids) via `SessionOptions` and the runtime will resolve, launch, register, and tear down extensions itself.
764
- *
765
- * @param params Params to attach an extension loader's tools to a session.
766
- *
767
- * @returns Handle for releasing the extension tool registration.
768
- */
769
- registerExtensionToolsOnSession: async (params) => connection.sendRequest("sessions.registerExtensionToolsOnSession", params),
770
- /**
771
- * Attaches (or detaches) an in-process ExtensionController delegate for the given session, used by shared-API surfaces that need to query or modify the session's extension state. Pass `controller: undefined` to detach. Marked internal because the controller is an in-process object that cannot cross the JSON-RPC boundary. Disappears alongside `registerExtensionToolsOnSession`: once the runtime owns extension management, the public surface exposes list/enable/disable/reload as dedicated RPCs served by the runtime.
763
+ * Attaches (or detaches) an in-process ExtensionController delegate for the given session in a local host adapter. Pass `controller: undefined` to detach. Internal because the controller cannot cross the JSON-RPC boundary; the runtime manages its own session extension service.
772
764
  *
773
765
  * @param params Params to attach or detach an in-process ExtensionController delegate.
774
766
  */
@@ -877,11 +869,11 @@ function createSessionRpc(connection, sessionId) {
877
869
  /** @experimental */
878
870
  debug: {
879
871
  /**
880
- * Collects a redacted session debug log bundle into a local archive or staging directory. The runtime includes session-owned logs by default and accepts caller-provided diagnostic entries so host applications can add their own files without changing this API shape.
872
+ * Collects a session debug log bundle into a local archive or staging directory. Logs are redacted by default; redaction can be configured per caller-provided diagnostic entry. The runtime includes session-owned logs by default and accepts caller-provided diagnostic entries so host applications can add their own files without changing this API shape.
881
873
  *
882
- * @param params Options for collecting a redacted session debug bundle.
874
+ * @param params Options for collecting a session debug bundle with configurable redaction.
883
875
  *
884
- * @returns Result of collecting a redacted debug bundle.
876
+ * @returns Result of collecting a session debug bundle.
885
877
  */
886
878
  collectLogs: async (params) => connection.sendRequest("session.debug.collectLogs", { sessionId, ...params })
887
879
  },
@@ -1191,6 +1183,32 @@ function createSessionRpc(connection, sessionId) {
1191
1183
  * @param params Relative path and UTF-8 content for the workspace file to create or overwrite.
1192
1184
  */
1193
1185
  createFile: async (params) => connection.sendRequest("session.workspaces.createFile", { sessionId, ...params }),
1186
+ /**
1187
+ * Returns metadata for a file or directory in the session workspace files directory.
1188
+ *
1189
+ * @param params Relative path of the workspace file or directory to inspect.
1190
+ *
1191
+ * @returns Filesystem metadata for a path in the session workspace files directory.
1192
+ */
1193
+ statFile: async (params) => connection.sendRequest("session.workspaces.statFile", { sessionId, ...params }),
1194
+ /**
1195
+ * Creates a directory in the session workspace files directory.
1196
+ *
1197
+ * @param params Directory to create within the session workspace files directory.
1198
+ */
1199
+ createDirectory: async (params) => connection.sendRequest("session.workspaces.createDirectory", { sessionId, ...params }),
1200
+ /**
1201
+ * Removes a file or directory from the session workspace files directory.
1202
+ *
1203
+ * @param params File or directory to remove from the session workspace files directory.
1204
+ */
1205
+ removePath: async (params) => connection.sendRequest("session.workspaces.removePath", { sessionId, ...params }),
1206
+ /**
1207
+ * Renames a file or directory within the session workspace files directory.
1208
+ *
1209
+ * @param params Source and destination paths for a rename within the session workspace files directory.
1210
+ */
1211
+ renamePath: async (params) => connection.sendRequest("session.workspaces.renamePath", { sessionId, ...params }),
1194
1212
  /**
1195
1213
  * Lists workspace checkpoints in chronological order.
1196
1214
  *
@@ -41,10 +41,14 @@ const factoryExecutionStore = new import_node_async_hooks.AsyncLocalStorage();
41
41
  function throwIfFactoryExecutionIsActive() {
42
42
  if (factoryExecutionStore.getStore()?.active) {
43
43
  throw new Error(
44
- "factory.run and factory.resume are not allowed while a factory body is running on this call path."
44
+ "factory.run, factory.resume, and factory.pause are not allowed while a factory body is running on this call path."
45
45
  );
46
46
  }
47
47
  }
48
+ function runInFactoryHelperScope(helperScope, callback) {
49
+ const current = factoryExecutionStore.getStore();
50
+ return factoryExecutionStore.run({ active: current?.active ?? false, helperScope }, callback);
51
+ }
48
52
  function deserializeHookInput(raw) {
49
53
  if (!raw || typeof raw !== "object" || typeof raw.timestamp !== "number") {
50
54
  return raw;
@@ -88,7 +92,7 @@ async function runFactoryParallel(thunks) {
88
92
  }
89
93
  return Promise.all(
90
94
  thunks.map(
91
- (thunk) => Promise.resolve().then(() => thunk()).catch((error) => {
95
+ (thunk) => Promise.resolve().then(() => runInFactoryHelperScope("parallel", thunk)).catch((error) => {
92
96
  if (isFactoryFatalError(error)) {
93
97
  throw error;
94
98
  }
@@ -107,7 +111,10 @@ async function runFactoryPipeline(items, ...stages) {
107
111
  let previous = item;
108
112
  for (const stage of stages) {
109
113
  try {
110
- previous = await stage(previous, item, index);
114
+ previous = await runInFactoryHelperScope(
115
+ "pipeline",
116
+ () => stage(previous, item, index)
117
+ );
111
118
  } catch (error) {
112
119
  if (isFactoryFatalError(error)) {
113
120
  throw error;
@@ -264,6 +271,7 @@ class CopilotSession {
264
271
  hooks;
265
272
  transformCallbacks;
266
273
  _rpc = null;
274
+ _internalRpc = null;
267
275
  traceContextProvider;
268
276
  managedSettingsEnabled;
269
277
  _capabilities = {};
@@ -330,6 +338,10 @@ class CopilotSession {
330
338
  }),
331
339
  getRunDetail: (runId) => this.rpc.factory.getRunDetail({ runId }),
332
340
  getRunProgress: (runId, options = {}) => this.rpc.factory.getRunProgress({ runId, ...options }),
341
+ pause: async (runId) => {
342
+ throwIfFactoryExecutionIsActive();
343
+ return this.rpc.factory.pause({ runId });
344
+ },
333
345
  cancel: async (runId) => this.rpc.factory.cancel({ runId })
334
346
  };
335
347
  /**
@@ -428,6 +440,13 @@ class CopilotSession {
428
440
  }
429
441
  return this._rpc;
430
442
  }
443
+ /** @internal */
444
+ get internalRpc() {
445
+ if (!this._internalRpc) {
446
+ this._internalRpc = (0, import_rpc.createInternalSessionRpc)(this.connection, this.sessionId);
447
+ }
448
+ return this._internalRpc;
449
+ }
431
450
  /**
432
451
  * Path to the session workspace directory when infinite sessions are enabled.
433
452
  * Contains checkpoints/, plan.md, and files/ subdirectories.
@@ -1110,6 +1129,36 @@ class CopilotSession {
1110
1129
  );
1111
1130
  return result2;
1112
1131
  },
1132
+ pause: async (key) => {
1133
+ if (typeof key !== "string" || key.length === 0) {
1134
+ throw new Error("Factory pause checkpoint key must not be empty");
1135
+ }
1136
+ const helperScope = factoryExecutionStore.getStore()?.helperScope;
1137
+ if (helperScope !== void 0) {
1138
+ throw new Error(
1139
+ `Factory pause checkpoints are not allowed inside ${helperScope}() branches`
1140
+ );
1141
+ }
1142
+ await progress.flush();
1143
+ const response = await awaitFactoryOperation(
1144
+ () => self.internalRpc.factory.pauseAtCheckpoint({
1145
+ runId: params.runId,
1146
+ executionToken: params.executionToken,
1147
+ key
1148
+ }),
1149
+ controller.signal
1150
+ );
1151
+ switch (response.action) {
1152
+ case "continue":
1153
+ return;
1154
+ case "pause":
1155
+ await awaitFactoryOperation(
1156
+ () => new Promise(() => {
1157
+ }),
1158
+ controller.signal
1159
+ );
1160
+ }
1161
+ },
1113
1162
  parallel: runFactoryParallel,
1114
1163
  pipeline: runFactoryPipeline,
1115
1164
  factory: async () => {
@@ -1145,11 +1194,9 @@ class CopilotSession {
1145
1194
  },
1146
1195
  async abort(params) {
1147
1196
  const controllersForRun = self.factoryAbortControllers.get(params.runId);
1148
- if (controllersForRun !== void 0) {
1149
- const reason = new DOMException("Factory run was aborted", "AbortError");
1150
- for (const controller of controllersForRun.values()) {
1151
- controller.abort(reason);
1152
- }
1197
+ const controller = controllersForRun?.get(params.executionToken);
1198
+ if (controller !== void 0) {
1199
+ controller.abort(new DOMException("Factory run was aborted", "AbortError"));
1153
1200
  }
1154
1201
  return {};
1155
1202
  }
@@ -1,2 +1,2 @@
1
- export declare const COPILOT_CLI_VERSION = "1.0.84-5";
1
+ export declare const COPILOT_CLI_VERSION = "1.0.84-9.unstable.r35045926061.g4848e94";
2
2
  export declare const COPILOT_CLI_USE_NPM_PACKAGE = false;
@@ -1,4 +1,4 @@
1
- const COPILOT_CLI_VERSION = "1.0.84-5";
1
+ const COPILOT_CLI_VERSION = "1.0.84-9.unstable.r35045926061.g4848e94";
2
2
  const COPILOT_CLI_USE_NPM_PACKAGE = false;
3
3
  export {
4
4
  COPILOT_CLI_USE_NPM_PACKAGE,
package/dist/factory.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { FactoryGetRunProgressRequest, FactoryListRunsRequest, FactoryListRunsResult, FactoryProgressPage, FactoryRunDetail, FactoryRunResult, FactoryRunStatus, FactoryRunSummary } from "./generated/rpc.js";
2
2
  import type { ContextTier } from "./generated/session-events.js";
3
3
  import type { CopilotSession } from "./session.js";
4
- import type { FactoryLimits, FactoryMeta } from "./types.js";
4
+ import type { FactoryMeta } from "./types.js";
5
5
  export type { FactoryRunResult };
6
6
  export type { FactoryAgentSummary, FactoryPhaseStatus, FactoryPhaseObservation, FactoryProgressLine, FactoryProgressPage, FactoryRunDetail, FactoryRunStatus, FactoryRunSummary, } from "./generated/rpc.js";
7
7
  /**
@@ -81,6 +81,21 @@ export interface FactoryStepOptions {
81
81
  /** Skip the journal and always invoke the producer. */
82
82
  volatile?: boolean;
83
83
  }
84
+ /**
85
+ * Per-invocation factory resource ceiling overrides.
86
+ *
87
+ * An omitted field preserves the existing/default ceiling, a number replaces
88
+ * it, and `null` explicitly makes that dimension unlimited.
89
+ *
90
+ * @experimental Part of the experimental Agent Factories surface and may
91
+ * change or be removed in future SDK or CLI releases.
92
+ */
93
+ export interface FactoryLimitOverrides {
94
+ maxConcurrentSubagents?: number | null;
95
+ maxTotalSubagents?: number | null;
96
+ maxAiCredits?: number | null;
97
+ timeoutSeconds?: number | null;
98
+ }
84
99
  /**
85
100
  * One stage in a per-item factory pipeline.
86
101
  *
@@ -101,6 +116,13 @@ export interface FactoryContext<TArgs extends JsonValue = JsonValue> {
101
116
  agent(prompt: string, options?: FactoryAgentOptions): Promise<unknown>;
102
117
  /** Memoize an arbitrary producer under a stable author-supplied key. */
103
118
  step(key: string, producer: () => Promise<JsonValue> | JsonValue, options?: FactoryStepOptions): Promise<JsonValue>;
119
+ /**
120
+ * Pause this run at a durable, one-shot checkpoint.
121
+ *
122
+ * The first attempt to reach a key pauses and aborts cooperatively. A
123
+ * resumed attempt returns from the same key and continues.
124
+ */
125
+ pause(key: string): Promise<void>;
104
126
  /**
105
127
  * Run thunks concurrently and await all of them.
106
128
  *
@@ -129,7 +151,7 @@ export interface FactoryContext<TArgs extends JsonValue = JsonValue> {
129
151
  args: TArgs;
130
152
  /**
131
153
  * The session instance returned by `joinSession`. It refuses calls that
132
- * start or resume a factory run.
154
+ * start, resume, or pause a factory run.
133
155
  */
134
156
  session: CopilotSession;
135
157
  /** Cooperative cancellation signal for the current factory run. */
@@ -178,7 +200,7 @@ export interface RunOptions<TArgs extends JsonValue = JsonValue> {
178
200
  /** Input surfaced as `context.args`. */
179
201
  args?: TArgs;
180
202
  /** Optional per-invocation resource ceiling overrides. */
181
- limits?: FactoryLimits;
203
+ limits?: FactoryLimitOverrides;
182
204
  /** Whether to notify the originating session when the factory completes. */
183
205
  notifyOnComplete?: boolean;
184
206
  /** Whether to emit factory phase names to the session transcript. */
@@ -198,7 +220,7 @@ export interface RunOptions<TArgs extends JsonValue = JsonValue> {
198
220
  */
199
221
  export interface ResumeOptions {
200
222
  /** Optional per-invocation resource ceiling overrides. */
201
- limits?: FactoryLimits;
223
+ limits?: FactoryLimitOverrides;
202
224
  /** Whether to notify the originating session when the factory completes. */
203
225
  notifyOnComplete?: boolean;
204
226
  /** Whether to emit factory phase names to the session transcript. */
@@ -222,13 +244,14 @@ export interface SessionFactoryApi {
222
244
  * Run a registered factory and resolve with its run envelope.
223
245
  *
224
246
  * The envelope is returned for every outcome, including `error`, `halted`,
225
- * and `cancelled` — inspect `status` and read `result` only when the run
226
- * completed. SDK-initiated runs do not request permission, so they have no
227
- * declined outcome. The model's `run_factory` tool requests permission
228
- * before a durable row exists; declining it creates no run row. Failures
229
- * that occur before a run exists (such as an unknown factory or attempting
230
- * to start a run while the session is at its active top-level run limit)
231
- * still reject.
247
+ * `paused`, and `cancelled` — inspect `status` and read `result` only when
248
+ * the run completed. `paused` settles the current attempt, but the same
249
+ * durable run can later resume under its existing run ID. SDK-initiated
250
+ * runs do not request permission, so they have no declined outcome. The
251
+ * model's `run_factory` tool requests permission before a durable row
252
+ * exists; declining it creates no run row. Failures that occur before a run
253
+ * exists (such as an unknown factory or attempting to start a run while the
254
+ * session is at its active top-level run limit) still reject.
232
255
  */
233
256
  run(name: string, options?: RunOptions): Promise<FactoryRunResult>;
234
257
  run<TArgs extends JsonValue>(factory: FactoryHandle<TArgs, JsonValue | void>, options?: RunOptions<TArgs>): Promise<FactoryRunResult>;
@@ -243,12 +266,13 @@ export interface SessionFactoryApi {
243
266
  /** Read the latest durable envelope for a factory run. */
244
267
  getRun(runId: string): Promise<FactoryRunResult>;
245
268
  /**
246
- * Wait for a run to settle and resolve with its terminal envelope.
269
+ * Wait for the current attempt to settle and resolve with its envelope.
247
270
  *
248
- * Resolves as soon as the run reaches `completed`, `error`, `halted`, or
249
- * `cancelled`, and resolves immediately when it has already settled. A
250
- * terminal envelope is final, so the resolved value never changes
251
- * afterwards.
271
+ * Resolves as soon as the run reaches `completed`, `error`, `halted`,
272
+ * `paused`, or `cancelled`, and resolves immediately when the current
273
+ * attempt has already settled. A `paused` envelope is an attempt-level
274
+ * snapshot: resuming the same durable run can later change the envelope
275
+ * returned by {@link SessionFactoryApi.getRun}.
252
276
  *
253
277
  * This watches the run's `factory.run_updated` invalidation events and
254
278
  * periodically re-reads the durable envelope so a missed event cannot
@@ -279,6 +303,8 @@ export interface SessionFactoryApi {
279
303
  getRunDetail(runId: string): Promise<FactoryRunDetail>;
280
304
  /** Page durable progress forward, backward, or from the latest tail. */
281
305
  getRunProgress(runId: string, options?: Omit<FactoryGetRunProgressRequest, "runId">): Promise<FactoryProgressPage>;
306
+ /** Pause a running factory attempt and return its `paused` envelope. */
307
+ pause(runId: string): Promise<FactoryRunResult>;
282
308
  /** Cancel a factory run and return its terminal envelope. */
283
309
  cancel(runId: string): Promise<FactoryRunResult>;
284
310
  }
package/dist/factory.js CHANGED
@@ -1,6 +1,7 @@
1
1
  const FACTORY_TERMINAL_STATUSES = /* @__PURE__ */ new Set([
2
2
  "completed",
3
3
  "halted",
4
+ "paused",
4
5
  "cancelled",
5
6
  "error"
6
7
  ]);