@github/copilot-sdk 1.0.15-unstable.35663726336.gcb2a8cc → 1.0.15

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.d.ts CHANGED
@@ -4,14 +4,16 @@
4
4
  import type { Canvas } from "./canvas.js";
5
5
  import type { SessionFsProvider } from "./sessionFsProvider.js";
6
6
  import type { CopilotRequestHandler } from "./copilotRequestHandler.js";
7
+ import type { InstallationConfirmationHandler } from "./installationConfirmation.js";
8
+ export type { InstallationConfirmationHandler } from "./installationConfirmation.js";
7
9
  import type { AttachmentExtensionContext as GeneratedExtensionContextAttachment, AutoTier, PermissionRequest as GeneratedPermissionRequest, PermissionRequestedData as GeneratedPermissionRequestedData, PermissionRequestedEvent as GeneratedPermissionRequestedEvent, ReasoningSummary, SessionLimitsConfig, SessionEvent as GeneratedSessionEvent } from "./generated/session-events.js";
8
10
  import type { CopilotSession } from "./session.js";
9
- import type { FactoryJsonSchema, JsonValue } from "./factory.js";
10
- import type { ExtensionLaunchProviderHandler as GeneratedExtensionLaunchProvider, GitHubTokenAcquireRequest, GitHubTokenAcquireResult, GitHubTelemetryNotification, ModelBillingTokenPrices, OpenCanvasInstance, RemoteSessionMode, CurrentToolMetadata } from "./generated/rpc.js";
11
+ import type { JsonValue } from "./workflow.js";
12
+ import type { ExtensionLaunchProviderHandler as GeneratedExtensionLaunchProvider, GitHubTokenAcquireRequest, GitHubTokenAcquireResult, GitHubTelemetryNotification, ModelBillingTokenPrices, DiagnosticsConfiguration, OpenCanvasInstance, RemoteSessionMode, CurrentToolMetadata } from "./generated/rpc.js";
11
13
  import type { ToolSet } from "./toolSet.js";
12
14
  export type { RemoteSessionMode } from "./generated/rpc.js";
13
15
  export type { CurrentToolMetadata } from "./generated/rpc.js";
14
- export type { ExtensionLaunchProfile, ExtensionLaunchProviderResolveRequest, ExtensionLaunchProviderResolveResult, GitHubTokenAcquireReason, GitHubTokenAcquireResult, GitHubTelemetryNotification, GitHubTelemetryEvent, GitHubTelemetryClientInfo, } from "./generated/rpc.js";
16
+ export type { ConnectorAccountRequest, ConnectorAvailability, ConnectorCapabilities, ConnectorCatalogEntry, ConnectorCatalogResult, ConnectorCatalogStatus, ConnectorConnectRequest, ConnectorConnectResult, ConnectorContinueRequest, ConnectorDisconnectResult, ConnectorMcpStatus, ConnectorReconcileRequest, ConnectorRuntimeStatus, ConnectorStatus, ExtensionLaunchProfile, ExtensionLaunchProviderResolveRequest, ExtensionLaunchProviderResolveResult, GitHubTokenAcquireReason, GitHubTokenAcquireResult, GitHubTelemetryNotification, GitHubTelemetryEvent, GitHubTelemetryClientInfo, InstallationConfirmationRequest, InstallationConfirmationResponse, InstallationDecision, InstallationReview, McpInstallationReview, } from "./generated/rpc.js";
15
17
  /**
16
18
  * Arguments passed to a session's {@link GitHubTokenProvider}.
17
19
  *
@@ -290,6 +292,12 @@ export interface CopilotClientOptions {
290
292
  * @experimental
291
293
  */
292
294
  extensionLaunchProvider?: ExtensionLaunchProvider;
295
+ /**
296
+ * Connection-global human review for experimental installation operations.
297
+ * Does not register or enable installation capabilities on the runtime.
298
+ * @experimental
299
+ */
300
+ installationConfirmationHandler?: InstallationConfirmationHandler;
293
301
  /**
294
302
  * Log level for the Copilot runtime. When omitted, the runtime uses its
295
303
  * own default (currently `"info"`).
@@ -1622,6 +1630,8 @@ export interface McpAuthStaticClientConfig {
1622
1630
  grantType?: "client_credentials";
1623
1631
  /** Whether this is a public OAuth client. */
1624
1632
  publicClient?: boolean;
1633
+ /** Configured OAuth scope string used when the server challenge omits scope. */
1634
+ scope?: string;
1625
1635
  }
1626
1636
  /** MCP OAuth request that the SDK host can satisfy with a host-acquired token. */
1627
1637
  export interface McpAuthRequest {
@@ -1690,69 +1700,6 @@ export interface CanvasProviderIdentity {
1690
1700
  /** Optional display name surfaced as the canvas extension name. */
1691
1701
  name?: string;
1692
1702
  }
1693
- /**
1694
- * Static resource ceilings declared by a factory before it runs.
1695
- *
1696
- * @experimental Part of the experimental Agent Factories surface and may
1697
- * change or be removed in future SDK or CLI releases.
1698
- */
1699
- export interface FactoryLimits {
1700
- /** Maximum number of factory subagents that may run concurrently. Must be positive when present. */
1701
- maxConcurrentSubagents?: number;
1702
- /** Maximum total number of factory subagents that may be spawned. Must be positive when present. */
1703
- maxTotalSubagents?: number;
1704
- /** Maximum AI credits consumed by factory subagents and descendants. This post-paid ceiling is soft. */
1705
- maxAiCredits?: number;
1706
- /**
1707
- * Maximum accumulated active-execution time, in seconds. Active execution includes the entire extension body,
1708
- * subprocess waits, queued-agent waits, and sleeps. The limit is armed from the remaining headroom when a run
1709
- * resumes; time between attempts is not counted. Must be finite and positive when present.
1710
- */
1711
- timeoutSeconds?: number;
1712
- }
1713
- /**
1714
- * Registration metadata for an extension-authored factory.
1715
- *
1716
- * @experimental Part of the experimental Agent Factories surface and may
1717
- * change or be removed in future SDK or CLI releases.
1718
- */
1719
- export interface FactoryMeta {
1720
- /** Stable factory name used for invocation. */
1721
- name: string;
1722
- /** Human-readable factory description. */
1723
- description: string;
1724
- /** Display metadata for the progress phases the factory may report. */
1725
- phases: Array<{
1726
- title: string;
1727
- detail?: string;
1728
- }>;
1729
- /**
1730
- * Optional declared shape of the arguments this factory expects as `ctx.args`.
1731
- *
1732
- * Declaring one is strongly recommended for any factory that reads `ctx.args`.
1733
- * When the model invokes the factory through the `run_factory` tool, the CLI
1734
- * validates `args` against this declaration **before** the run starts, so a
1735
- * malformed call is rejected with a correction hint and retried without ever
1736
- * creating a run row, prompting the user for permission, or spending credits. A
1737
- * factory that declares nothing is never validated: a malformed call starts,
1738
- * takes an approval, spends credits, and then fails inside the factory body.
1739
- * `factories_manage` with `operation: "inspect"` reports the declared shape so an
1740
- * agent can read it before invoking.
1741
- *
1742
- * This covers the model's `run_factory` path only. `session.factory.run(...)` is
1743
- * not validated against the declaration, so a factory should still check
1744
- * `ctx.args` rather than assume the declared shape held.
1745
- *
1746
- * Enforcement covers structure — types, required properties, and enum/const
1747
- * values. Finer constraints such as `minLength`, `pattern`, and
1748
- * `additionalProperties` are recorded in the declaration but not enforced. See
1749
- * {@link FactoryJsonSchema} for the accepted subset. A declaration outside that
1750
- * subset is rejected at registration.
1751
- */
1752
- argsSchema?: FactoryJsonSchema;
1753
- /** Optional resource ceilings presented to the user before execution. */
1754
- limits?: FactoryLimits;
1755
- }
1756
1703
  /**
1757
1704
  * Provider-scoped options for the Copilot API (CAPI).
1758
1705
  *
@@ -1922,6 +1869,16 @@ export interface SessionConfigBase {
1922
1869
  * the session to the long-context tier; omit or use "default" otherwise.
1923
1870
  */
1924
1871
  contextTier?: ContextTier;
1872
+ /**
1873
+ * Enables session-scoped MCP diagnostic capture at the requested level.
1874
+ *
1875
+ * Diagnostics are off by default. At `"debug"` and `"trace"` levels, entries
1876
+ * can contain MCP payloads, tool arguments, paths, and server stderr. Do not
1877
+ * upload entries as telemetry or export them without deliberate host action.
1878
+ * Omit this option when resuming a resident session to preserve its current
1879
+ * diagnostic level.
1880
+ */
1881
+ diagnostics?: DiagnosticsConfiguration;
1925
1882
  /** Per-property overrides for model capabilities, deep-merged over runtime defaults. */
1926
1883
  modelCapabilities?: ModelCapabilitiesOverride;
1927
1884
  /**
@@ -2465,6 +2422,14 @@ export interface SessionConfig extends SessionConfigBase {
2465
2422
  * Optional custom session ID. If not provided, the server generates one.
2466
2423
  */
2467
2424
  sessionId?: string;
2425
+ /**
2426
+ * Invalidates the process-wide custom-instruction discovery cache before
2427
+ * creating this session. Use when instruction files changed in the same runtime.
2428
+ * Other sessions in this runtime may observe updated instructions on later turns
2429
+ * or discovery. This does not watch files or enable disabled instruction loading.
2430
+ * @default false
2431
+ */
2432
+ refreshCustomInstructions?: boolean;
2468
2433
  /**
2469
2434
  * Creates a remote session in the cloud instead of a local session.
2470
2435
  * The optional repository is associated with the cloud session.
@@ -0,0 +1,367 @@
1
+ import type { WorkflowGetRunProgressRequest, WorkflowListRunsRequest, WorkflowListRunsResult, WorkflowProgressPage, WorkflowRunDetail, WorkflowRunResult, WorkflowRunStatus, WorkflowRunSummary } from "./generated/rpc.js";
2
+ import type { ContextTier } from "./generated/session-events.js";
3
+ import type { CopilotSession } from "./session.js";
4
+ export type { WorkflowRunResult };
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
+ };
9
+ export type { WorkflowAgentSummary, WorkflowPhaseStatus, WorkflowPhaseObservation, WorkflowProgressLine, WorkflowProgressPage, WorkflowRunDetail, WorkflowRunStatus, WorkflowRunSummary, } from "./generated/rpc.js";
10
+ /**
11
+ * Options for paging durable workflow runs.
12
+ *
13
+ * @experimental Part of the experimental Dynamic Workflows surface and may
14
+ * change or be removed in future SDK or CLI releases.
15
+ */
16
+ export type WorkflowListRunsOptions = WorkflowListRunsRequest;
17
+ /**
18
+ * A page of durable workflow runs and its paging metadata.
19
+ *
20
+ * @experimental Part of the experimental Dynamic Workflows surface and may
21
+ * change or be removed in future SDK or CLI releases.
22
+ */
23
+ export type WorkflowRunsPage = WorkflowListRunsResult;
24
+ /**
25
+ * Whether a workflow run status is terminal.
26
+ *
27
+ * @experimental Part of the experimental Dynamic Workflows surface and may
28
+ * change or be removed in future SDK or CLI releases.
29
+ */
30
+ export declare function isWorkflowRunTerminal(status: WorkflowRunStatus): boolean;
31
+ declare const workflowHandleBrand: unique symbol;
32
+ /**
33
+ * Conservative JSON shape language accepted by the Dynamic Workflows surface, for
34
+ * both structured workflow agent output and a workflow's declared `argsSchema`.
35
+ *
36
+ * This is a best-effort structural guard — used to decide whether a subagent's
37
+ * structured output should be accepted or retried, and whether a caller's
38
+ * workflow `args` match the declared shape — **not** a full JSON Schema
39
+ * validator. Only these keywords are honored: `type`, `required`, `enum`,
40
+ * `const`, recursive `properties`/`items`, and `anyOf`/`oneOf`/`allOf`. A `type`
41
+ * is one of `null`, `boolean`, `integer`, `number`, `string`, `array`, or
42
+ * `object`, or a non-empty array of those (for example `["object", "null"]`).
43
+ *
44
+ * Everything else is **ignored, not enforced**. In particular, string
45
+ * constraints (`pattern`, `minLength`, `maxLength`, `format`), numeric ranges
46
+ * (`minimum`, `maximum`), and `additionalProperties` do not reject
47
+ * non-conforming output. Boolean schemas are outside this accepted shape.
48
+ * `oneOf` is treated like `anyOf` (at least one branch must match) rather than
49
+ * strict exactly-one. Author schemas within this subset; do not rely on
50
+ * unsupported constraints for correctness.
51
+ *
52
+ * @experimental Part of the experimental Dynamic Workflows surface and may
53
+ * change or be removed in future SDK or CLI releases.
54
+ */
55
+ export type WorkflowJsonSchema = {
56
+ [key: string]: JsonValue;
57
+ };
58
+ /**
59
+ * Static resource ceilings declared by a workflow before it runs.
60
+ *
61
+ * @experimental Part of the experimental Dynamic Workflows surface and may
62
+ * change or be removed in future SDK or CLI releases.
63
+ */
64
+ export interface WorkflowLimits {
65
+ /** Maximum number of workflow subagents that may run concurrently. Must be positive when present. */
66
+ maxConcurrentSubagents?: number;
67
+ /** Maximum total number of workflow subagents that may be spawned. Must be positive when present. */
68
+ maxTotalSubagents?: number;
69
+ /** Maximum AI credits consumed by workflow subagents and descendants. This post-paid ceiling is soft. */
70
+ maxAiCredits?: number;
71
+ /**
72
+ * Maximum accumulated active-execution time, in seconds. Active execution includes the entire extension body,
73
+ * subprocess waits, queued-agent waits, and sleeps. The limit is armed from the remaining headroom when a run
74
+ * resumes; time between attempts is not counted. Must be finite and positive when present.
75
+ */
76
+ timeoutSeconds?: number;
77
+ }
78
+ /**
79
+ * Registration metadata for an extension-authored workflow.
80
+ *
81
+ * @experimental Part of the experimental Dynamic Workflows surface and may
82
+ * change or be removed in future SDK or CLI releases.
83
+ */
84
+ export interface WorkflowMeta {
85
+ /** Stable workflow name used for invocation. */
86
+ name: string;
87
+ /** Human-readable workflow description. */
88
+ description: string;
89
+ /** Display metadata for the progress phases the workflow may report. */
90
+ phases: Array<{
91
+ title: string;
92
+ detail?: string;
93
+ }>;
94
+ /**
95
+ * Optional declared shape of the arguments this workflow expects as `ctx.args`.
96
+ *
97
+ * The runtime records and validates this schema when the workflow contribution
98
+ * is registered. Workflow bodies should still validate any semantic constraints
99
+ * they depend on because the public `session.workflow.run(...)` API forwards
100
+ * arguments directly.
101
+ */
102
+ argsSchema?: WorkflowJsonSchema;
103
+ /** Optional resource ceilings presented before execution. */
104
+ limits?: WorkflowLimits;
105
+ }
106
+ /**
107
+ * Options for one workflow-scoped subagent call.
108
+ *
109
+ * @experimental Part of the experimental Dynamic Workflows surface and may
110
+ * change or be removed in future SDK or CLI releases.
111
+ */
112
+ export interface WorkflowAgentOptions {
113
+ label?: string;
114
+ schema?: WorkflowJsonSchema;
115
+ model?: string;
116
+ reasoningEffort?: string;
117
+ contextTier?: ContextTier;
118
+ agent?: string;
119
+ }
120
+ export declare const WORKFLOW_AGENT_OPTION_KEYS: readonly ["label", "schema", "model", "reasoningEffort", "contextTier", "agent"];
121
+ /**
122
+ * Options for a durable workflow step.
123
+ *
124
+ * @experimental Part of the experimental Dynamic Workflows surface and may
125
+ * change or be removed in future SDK or CLI releases.
126
+ */
127
+ export interface WorkflowStepOptions {
128
+ /** Skip the journal and always invoke the producer. */
129
+ volatile?: boolean;
130
+ }
131
+ /**
132
+ * Per-invocation workflow resource ceiling overrides.
133
+ *
134
+ * An omitted field preserves the existing/default ceiling, a number replaces
135
+ * it, and `null` explicitly makes that dimension unlimited.
136
+ *
137
+ * @experimental Part of the experimental Dynamic Workflows surface and may
138
+ * change or be removed in future SDK or CLI releases.
139
+ */
140
+ export interface WorkflowLimitOverrides {
141
+ maxConcurrentSubagents?: number | null;
142
+ maxTotalSubagents?: number | null;
143
+ maxAiCredits?: number | null;
144
+ timeoutSeconds?: number | null;
145
+ }
146
+ /**
147
+ * One stage in a per-item workflow pipeline.
148
+ *
149
+ * @experimental Part of the experimental Dynamic Workflows surface and may
150
+ * change or be removed in future SDK or CLI releases.
151
+ */
152
+ export type WorkflowPipelineStage<TInput = unknown, TResult = unknown> = (previous: TInput, item: unknown, index: number) => Promise<TResult> | TResult;
153
+ /**
154
+ * Context passed to an extension-authored workflow body.
155
+ *
156
+ * @experimental Part of the experimental Dynamic Workflows surface and may
157
+ * change or be removed in future SDK or CLI releases.
158
+ */
159
+ export interface WorkflowContext<TArgs extends JsonValue = JsonValue> {
160
+ /** Stable identifier for the current workflow run. */
161
+ readonly runId: string;
162
+ /** Spawn and await one workflow-scoped subagent. */
163
+ agent(prompt: string, options?: WorkflowAgentOptions): Promise<unknown>;
164
+ /** Memoize an arbitrary producer under a stable author-supplied key. */
165
+ step(key: string, producer: () => Promise<JsonValue> | JsonValue, options?: WorkflowStepOptions): Promise<JsonValue>;
166
+ /**
167
+ * Pause this run at a durable, one-shot checkpoint.
168
+ *
169
+ * The first attempt to reach a key pauses and aborts cooperatively. A
170
+ * resumed attempt returns from the same key and continues.
171
+ */
172
+ pause(key: string): Promise<void>;
173
+ /**
174
+ * Run thunks concurrently and await all of them.
175
+ *
176
+ * A thunk that throws becomes `null` in the result array, so one failed
177
+ * item does not lose the rest. Cancellation and hard runtime failures
178
+ * (`ResponseError`, `ConnectionError`) are the exception: those propagate
179
+ * and reject the whole call, because they mean the run itself is in
180
+ * trouble rather than one item having failed.
181
+ */
182
+ parallel<TResult>(thunks: Array<() => Promise<TResult> | TResult>): Promise<Array<TResult | null>>;
183
+ /**
184
+ * Run each item through every stage without barriers between stages.
185
+ *
186
+ * A stage that throws drops that item to `null` and skips its remaining
187
+ * stages. As with {@link WorkflowContext.parallel}, cancellation and hard
188
+ * runtime failures propagate instead of being recorded per item.
189
+ */
190
+ pipeline(items: unknown[], ...stages: WorkflowPipelineStage[]): Promise<unknown[]>;
191
+ /** Start a named workflow progress phase. */
192
+ phase(title: string): void;
193
+ /** Emit a workflow progress line. */
194
+ log(message: string): void;
195
+ /** Reject because nested workflows are not supported. */
196
+ workflow(name: string, args?: JsonValue): Promise<JsonValue | void>;
197
+ /** Caller-supplied input, forwarded verbatim. */
198
+ args: TArgs;
199
+ /**
200
+ * The session instance returned by `joinSession`. It refuses calls that
201
+ * start, resume, or pause a workflow run.
202
+ */
203
+ session: CopilotSession;
204
+ /** Cooperative cancellation signal for the current workflow run. */
205
+ signal: AbortSignal;
206
+ }
207
+ /**
208
+ * Definition accepted by {@link defineWorkflow}.
209
+ *
210
+ * @experimental Part of the experimental Dynamic Workflows surface and may
211
+ * change or be removed in future SDK or CLI releases.
212
+ */
213
+ export interface WorkflowDefinition<TArgs extends JsonValue = JsonValue, TResult extends JsonValue | void = JsonValue | void> {
214
+ meta: WorkflowMeta;
215
+ run(context: WorkflowContext<TArgs>): Promise<TResult>;
216
+ }
217
+ /**
218
+ * A deeply immutable view of a value.
219
+ *
220
+ * `defineWorkflow` deep-freezes the metadata it stores, so the handle's view of
221
+ * it has to be readonly all the way down or `handle.meta.name = "..."` and
222
+ * `handle.meta.phases.push(...)` would compile and then throw at runtime.
223
+ */
224
+ type DeepReadonly<T> = T extends (infer U)[] ? readonly DeepReadonly<U>[] : T extends object ? {
225
+ readonly [K in keyof T]: DeepReadonly<T[K]>;
226
+ } : T;
227
+ /**
228
+ * Opaque reusable reference to a defined workflow.
229
+ *
230
+ * @experimental Part of the experimental Dynamic Workflows surface and may
231
+ * change or be removed in future SDK or CLI releases.
232
+ */
233
+ export interface WorkflowHandle<TArgs extends JsonValue = JsonValue, TResult extends JsonValue | void = JsonValue | void> {
234
+ readonly meta: DeepReadonly<WorkflowMeta>;
235
+ readonly [workflowHandleBrand]: {
236
+ readonly args: TArgs;
237
+ readonly result: TResult;
238
+ };
239
+ }
240
+ /**
241
+ * Options for invoking a workflow.
242
+ *
243
+ * @experimental Part of the experimental Dynamic Workflows surface and may
244
+ * change or be removed in future SDK or CLI releases.
245
+ */
246
+ export interface WorkflowRunOptions<TArgs extends JsonValue = JsonValue> {
247
+ /** Input surfaced as `context.args`. */
248
+ args?: TArgs;
249
+ /** Optional per-invocation resource ceiling overrides. */
250
+ limits?: WorkflowLimitOverrides;
251
+ /** Whether to notify the originating session when the workflow completes. */
252
+ notifyOnComplete?: boolean;
253
+ /** Whether to emit workflow phase names to the session transcript. */
254
+ logPhaseNames?: boolean;
255
+ }
256
+ /**
257
+ * Options for resuming a workflow run by ID.
258
+ *
259
+ * @experimental Part of the experimental Dynamic Workflows surface and may
260
+ * change or be removed in future SDK or CLI releases.
261
+ */
262
+ export interface WorkflowResumeOptions {
263
+ /** Optional per-invocation resource ceiling overrides. */
264
+ limits?: WorkflowLimitOverrides;
265
+ /** Whether to notify the originating session when the workflow completes. */
266
+ notifyOnComplete?: boolean;
267
+ /** Whether to emit workflow phase names to the session transcript. */
268
+ logPhaseNames?: boolean;
269
+ }
270
+ /**
271
+ * Machine-readable pre-execution workflow resume failure.
272
+ *
273
+ * @experimental Part of the experimental Dynamic Workflows surface and may
274
+ * change or be removed in future SDK or CLI releases.
275
+ */
276
+ export type WorkflowResumeErrorCode = "not_found" | "non_resumable" | "workflow_run_not_resumable" | "already_active" | "workflow_already_running" | "workflow_limits_invalid" | "workflow_session_disposed" | "workflow_storage_unavailable" | "workflow_storage_corrupt";
277
+ /**
278
+ * Friendly workflow API exposed on a session.
279
+ *
280
+ * @experimental Part of the experimental Dynamic Workflows surface and may
281
+ * change or be removed in future SDK or CLI releases.
282
+ */
283
+ export interface SessionWorkflowApi {
284
+ /**
285
+ * Run a registered workflow and resolve with its run envelope.
286
+ *
287
+ * The envelope is returned for every outcome, including `error`, `halted`,
288
+ * `paused`, and `cancelled` — inspect `status` and read `result` only when
289
+ * the run completed. `paused` settles the current attempt, but the same
290
+ * durable run can later resume under its existing run ID. SDK-initiated
291
+ * runs do not request permission, so they have no declined outcome.
292
+ * Failures that occur before a run exists (such as an unknown workflow or
293
+ * attempting to start a run while the session is at its active top-level
294
+ * run limit) still reject.
295
+ */
296
+ run(name: string, options?: WorkflowRunOptions): Promise<WorkflowRunResult>;
297
+ run<TArgs extends JsonValue>(workflow: WorkflowHandle<TArgs, JsonValue | void>, options?: WorkflowRunOptions<TArgs>): Promise<WorkflowRunResult>;
298
+ /**
299
+ * Resume a run from its persisted workflow name, arguments, journal, and accounting.
300
+ *
301
+ * Resolves with the run envelope like {@link SessionWorkflowApi.run}.
302
+ * SDK-initiated resumes do not request permission. A pre-execution failure
303
+ * with a documented resume code rejects with {@link WorkflowResumeError}.
304
+ */
305
+ resume(runId: string, options?: WorkflowResumeOptions): Promise<WorkflowRunResult>;
306
+ /** Read the latest durable envelope for a workflow run. */
307
+ getRun(runId: string): Promise<WorkflowRunResult>;
308
+ /**
309
+ * Wait for the current attempt to settle and resolve with its envelope.
310
+ *
311
+ * Resolves as soon as the run reaches `completed`, `error`, `halted`,
312
+ * `paused`, or `cancelled`, and resolves immediately when the current
313
+ * attempt has already settled. A `paused` envelope is an attempt-level
314
+ * snapshot: resuming the same durable run can later change the envelope
315
+ * returned by {@link SessionWorkflowApi.getRun}.
316
+ *
317
+ * This watches the runtime's `workflow.run_updated` event and
318
+ * periodically re-reads the durable envelope so a missed event cannot
319
+ * leave the wait hanging. Pass a `signal` to stop waiting; aborting rejects
320
+ * and has no effect on the run itself, which keeps executing. Use
321
+ * {@link SessionWorkflowApi.cancel} to actually stop it.
322
+ */
323
+ waitForRun(runId: string, options?: {
324
+ signal?: AbortSignal;
325
+ }): Promise<WorkflowRunResult>;
326
+ /**
327
+ * List the newest default page of this session's durable workflow runs.
328
+ *
329
+ * This backwards-compatible overload returns only the runs array. Pass
330
+ * paging options to receive the full page, including its cursors and
331
+ * truncation metadata.
332
+ */
333
+ listRuns(): Promise<WorkflowRunSummary[]>;
334
+ /**
335
+ * Page this session's durable workflow runs.
336
+ *
337
+ * `afterSeq` and `beforeSeq` are exclusive cursors. The result includes
338
+ * `oldestSeq`, `newestSeq`, `hasMoreNewer`, and `omittedOlder` so callers
339
+ * can continue paging without using the raw RPC client.
340
+ */
341
+ listRuns(options: WorkflowListRunsOptions): Promise<WorkflowRunsPage>;
342
+ /** Read durable phases, direct agents, and the latest progress tail for a run. */
343
+ getRunDetail(runId: string): Promise<WorkflowRunDetail>;
344
+ /** Page durable progress forward, backward, or from the latest tail. */
345
+ getRunProgress(runId: string, options?: Omit<WorkflowGetRunProgressRequest, "runId">): Promise<WorkflowProgressPage>;
346
+ /** Pause a running workflow attempt and return its `paused` envelope. */
347
+ pause(runId: string): Promise<WorkflowRunResult>;
348
+ /** Cancel a workflow run and return its terminal envelope. */
349
+ cancel(runId: string): Promise<WorkflowRunResult>;
350
+ }
351
+ /**
352
+ * Error thrown when a workflow cannot be resumed before execution begins.
353
+ *
354
+ * @experimental Part of the experimental Dynamic Workflows surface and may
355
+ * change or be removed in future SDK or CLI releases.
356
+ */
357
+ export declare class WorkflowResumeError extends Error {
358
+ readonly code: WorkflowResumeErrorCode;
359
+ constructor(code: WorkflowResumeErrorCode, message: string);
360
+ }
361
+ /**
362
+ * Defines an extension-authored workflow and returns an opaque registration handle.
363
+ *
364
+ * @experimental Part of the experimental Dynamic Workflows surface and may
365
+ * change or be removed in future SDK or CLI releases.
366
+ */
367
+ export declare function defineWorkflow<TArgs extends JsonValue = JsonValue, TResult extends JsonValue | void = JsonValue | void>(definition: WorkflowDefinition<TArgs, TResult>): WorkflowHandle<TArgs, TResult>;
@@ -1,14 +1,14 @@
1
- const FACTORY_TERMINAL_STATUSES = /* @__PURE__ */ new Set([
1
+ const WORKFLOW_TERMINAL_STATUSES = /* @__PURE__ */ new Set([
2
2
  "completed",
3
3
  "halted",
4
4
  "paused",
5
5
  "cancelled",
6
6
  "error"
7
7
  ]);
8
- function isFactoryRunTerminal(status) {
9
- return FACTORY_TERMINAL_STATUSES.has(status);
8
+ function isWorkflowRunTerminal(status) {
9
+ return WORKFLOW_TERMINAL_STATUSES.has(status);
10
10
  }
11
- const FACTORY_AGENT_OPTION_KEYS = [
11
+ const WORKFLOW_AGENT_OPTION_KEYS = [
12
12
  "label",
13
13
  "schema",
14
14
  "model",
@@ -16,16 +16,16 @@ const FACTORY_AGENT_OPTION_KEYS = [
16
16
  "contextTier",
17
17
  "agent"
18
18
  ];
19
- class FactoryResumeError extends Error {
19
+ class WorkflowResumeError extends Error {
20
20
  constructor(code, message) {
21
21
  super(message);
22
22
  this.code = code;
23
- this.name = "FactoryResumeError";
23
+ this.name = "WorkflowResumeError";
24
24
  }
25
25
  code;
26
26
  }
27
- const factoryHandles = /* @__PURE__ */ new WeakMap();
28
- const MAX_FACTORY_TIMEOUT_SECONDS = 2147483647e-3;
27
+ const workflowHandles = /* @__PURE__ */ new WeakMap();
28
+ const MAX_WORKFLOW_TIMEOUT_SECONDS = 2147483647e-3;
29
29
  const NANO_AIU_PER_AIU = 1e9;
30
30
  function deepFreeze(value) {
31
31
  if (value !== null && typeof value === "object" && !Object.isFrozen(value)) {
@@ -44,24 +44,24 @@ function validateLimits(meta) {
44
44
  for (const field of ["maxConcurrentSubagents", "maxTotalSubagents"]) {
45
45
  const value = limits[field];
46
46
  if (value !== void 0 && (!Number.isInteger(value) || value <= 0)) {
47
- throw new Error(`Factory limit "${field}" must be a positive integer`);
47
+ throw new Error(`Workflow limit "${field}" must be a positive integer`);
48
48
  }
49
49
  }
50
50
  if (limits.timeoutSeconds !== void 0 && (!Number.isFinite(limits.timeoutSeconds) || limits.timeoutSeconds <= 0)) {
51
51
  throw new Error(
52
- 'Factory limit "timeoutSeconds" must be a positive, finite number of seconds'
52
+ 'Workflow limit "timeoutSeconds" must be a positive, finite number of seconds'
53
53
  );
54
54
  }
55
- if (limits.timeoutSeconds !== void 0 && limits.timeoutSeconds > MAX_FACTORY_TIMEOUT_SECONDS) {
55
+ if (limits.timeoutSeconds !== void 0 && limits.timeoutSeconds > MAX_WORKFLOW_TIMEOUT_SECONDS) {
56
56
  throw new Error(
57
- `Factory limit "timeoutSeconds" must not exceed ${MAX_FACTORY_TIMEOUT_SECONDS} seconds`
57
+ `Workflow limit "timeoutSeconds" must not exceed ${MAX_WORKFLOW_TIMEOUT_SECONDS} seconds`
58
58
  );
59
59
  }
60
60
  if (limits.maxAiCredits !== void 0) {
61
61
  const maxNanoAiu = Math.round(limits.maxAiCredits * NANO_AIU_PER_AIU);
62
62
  if (!Number.isFinite(limits.maxAiCredits) || limits.maxAiCredits <= 0 || !Number.isSafeInteger(maxNanoAiu) || maxNanoAiu < 1) {
63
63
  throw new Error(
64
- 'Factory limit "maxAiCredits" must be a positive, finite number that rounds to a safe positive integer nano-AIU ceiling'
64
+ 'Workflow limit "maxAiCredits" must be a positive, finite number that rounds to a safe positive integer nano-AIU ceiling'
65
65
  );
66
66
  }
67
67
  }
@@ -70,15 +70,15 @@ function validatePhases(meta) {
70
70
  const titles = /* @__PURE__ */ new Set();
71
71
  for (const phase of meta.phases) {
72
72
  if (phase.title.trim().length === 0) {
73
- throw new Error("Factory phase titles must not be empty");
73
+ throw new Error("Workflow phase titles must not be empty");
74
74
  }
75
75
  if (titles.has(phase.title)) {
76
- throw new Error(`Factory phase title "${phase.title}" is declared more than once`);
76
+ throw new Error(`Workflow phase title "${phase.title}" is declared more than once`);
77
77
  }
78
78
  titles.add(phase.title);
79
79
  }
80
80
  }
81
- function defineFactory(definition) {
81
+ function defineWorkflow(definition) {
82
82
  const meta = deepFreeze(structuredClone(definition.meta));
83
83
  validateLimits(meta);
84
84
  validatePhases(meta);
@@ -87,20 +87,20 @@ function defineFactory(definition) {
87
87
  run: definition.run
88
88
  };
89
89
  const handle = Object.freeze({ meta });
90
- factoryHandles.set(handle, stored);
90
+ workflowHandles.set(handle, stored);
91
91
  return handle;
92
92
  }
93
- function getFactoryDefinition(handle) {
94
- const definition = factoryHandles.get(handle);
93
+ function getWorkflowDefinition(handle) {
94
+ const definition = workflowHandles.get(handle);
95
95
  if (!definition) {
96
- throw new Error("Invalid factory handle");
96
+ throw new Error("Invalid workflow handle");
97
97
  }
98
98
  return definition;
99
99
  }
100
100
  export {
101
- FACTORY_AGENT_OPTION_KEYS,
102
- FactoryResumeError,
103
- defineFactory,
104
- getFactoryDefinition,
105
- isFactoryRunTerminal
101
+ WORKFLOW_AGENT_OPTION_KEYS,
102
+ WorkflowResumeError,
103
+ defineWorkflow,
104
+ getWorkflowDefinition,
105
+ isWorkflowRunTerminal
106
106
  };
@@ -77,5 +77,5 @@ An approved extension can pass a granted value to anything it starts, so ask onl
77
77
  ## Further Reading
78
78
 
79
79
  - `examples.md` — Practical code examples for tools, hooks, events, and complete extensions
80
- - `factories.md`: Authoring, running, resuming, and observing Agent Factories
80
+ - `workflows.md` — Authoring, running, resuming, and observing Dynamic Workflows
81
81
  - `agent-author.md` — Step-by-step workflow for agents authoring extensions programmatically