@trailstep/core 0.1.0 → 0.2.0

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
@@ -14,6 +14,94 @@ interface AgentModelTarget {
14
14
  readonly model: string;
15
15
  }
16
16
 
17
+ interface TrailStepProviderRegistration {
18
+ readonly source: TrailStepProviderSource;
19
+ readonly manifest: TrailStepProviderManifest;
20
+ }
21
+ type TrailStepProviderSource = {
22
+ readonly type: "local-manifest";
23
+ readonly path: string;
24
+ } | {
25
+ readonly type: "legacy-custom-provider";
26
+ } | {
27
+ readonly type: "npm" | "github" | "local-package";
28
+ readonly packageName: string;
29
+ readonly spec: string;
30
+ readonly resolvedVersion?: string;
31
+ };
32
+ /**
33
+ * ESM package contract for provider packages: export `trailstepProvider` from
34
+ * the package root. Keep hook functions outside `manifest` so the manifest is
35
+ * serializable and safe to persist.
36
+ */
37
+ interface TrailStepProviderPackageDefinition {
38
+ readonly manifest: TrailStepProviderManifest;
39
+ readonly hooks?: Record<string, unknown>;
40
+ }
41
+ interface TrailStepProviderManifest {
42
+ readonly schemaVersion: 1;
43
+ readonly id: string;
44
+ readonly displayName: string;
45
+ readonly working: TrailStepProviderWorkingManifest;
46
+ readonly interactive: TrailStepProviderInteractiveManifest;
47
+ readonly model: TrailStepProviderModelManifest;
48
+ readonly thinking: TrailStepProviderThinkingManifest;
49
+ readonly env?: TrailStepProviderEnvironmentManifest;
50
+ readonly hooks?: Record<string, unknown>;
51
+ }
52
+ type TrailStepProviderPromptFileReferenceStyle = "at-prefixed-argument";
53
+ interface TrailStepProviderPromptManifest {
54
+ readonly kind: "prompt-file";
55
+ readonly reference?: TrailStepProviderPromptFileReferenceStyle;
56
+ }
57
+ type TrailStepProviderOutputStyle = "provider-output-file" | "stdout-json-envelope" | "stdout-jsonl-transcript";
58
+ interface TrailStepProviderOutputParsingManifest {
59
+ readonly resultField?: string;
60
+ }
61
+ interface TrailStepProviderOutputManifest {
62
+ readonly style: TrailStepProviderOutputStyle;
63
+ readonly parsing?: TrailStepProviderOutputParsingManifest;
64
+ }
65
+ interface TrailStepProviderWorkingManifest {
66
+ readonly supported: boolean;
67
+ readonly command?: string;
68
+ readonly args?: readonly string[];
69
+ readonly prompt?: TrailStepProviderPromptManifest;
70
+ readonly output?: TrailStepProviderOutputManifest;
71
+ }
72
+ interface TrailStepProviderInteractiveManifest {
73
+ readonly supported: boolean;
74
+ readonly reason?: string;
75
+ readonly command?: string;
76
+ readonly args?: readonly string[];
77
+ readonly requiresSystemPromptFile?: boolean;
78
+ readonly systemPromptFileFlag?: string;
79
+ readonly modelFlag?: string;
80
+ readonly permissionBypassFlag?: string;
81
+ }
82
+ interface TrailStepProviderEnvironmentManifest {
83
+ readonly required?: readonly string[];
84
+ readonly optional?: readonly string[];
85
+ }
86
+ interface TrailStepProviderModelDiscoveryManifest {
87
+ readonly command: string;
88
+ readonly args: readonly string[];
89
+ readonly outputParser: string;
90
+ }
91
+ interface TrailStepProviderModelManifest {
92
+ readonly supported: boolean;
93
+ readonly reason?: string;
94
+ readonly flag?: string;
95
+ readonly discovery?: TrailStepProviderModelDiscoveryManifest;
96
+ }
97
+ interface TrailStepProviderThinkingManifest {
98
+ readonly supported: boolean;
99
+ readonly reason?: string;
100
+ readonly flag?: string;
101
+ readonly levels?: readonly WorkflowAgentThinking[];
102
+ }
103
+ declare function parseTrailStepProviderManifest(path: string, value: unknown, diagnostics: string[]): TrailStepProviderManifest | undefined;
104
+
17
105
  interface RetryPolicy {
18
106
  readonly maxAttempts: number;
19
107
  }
@@ -40,19 +128,31 @@ interface ResolveTimeoutPolicyOptions {
40
128
  declare function resolveTimeoutPolicy(options: ResolveTimeoutPolicyOptions): TimeoutPolicy;
41
129
  declare function validateTimeoutPolicy(input: unknown): TimeoutPolicy;
42
130
 
131
+ type TrailStepCustomProviderModelOverrideSupport = {
132
+ readonly supported: true;
133
+ readonly flag?: string;
134
+ } | {
135
+ readonly supported: false;
136
+ };
137
+ type TrailStepCustomProviderThinkingOverrideSupport = {
138
+ readonly supported: true;
139
+ readonly flag?: string;
140
+ readonly levels: readonly WorkflowAgentThinking[];
141
+ } | {
142
+ readonly supported: false;
143
+ readonly levels?: readonly [];
144
+ };
43
145
  interface TrailStepCustomProviderConfig {
44
146
  readonly binary: string;
45
147
  readonly args?: readonly string[];
46
148
  readonly interactiveArgs?: readonly string[];
149
+ readonly model?: TrailStepCustomProviderModelOverrideSupport;
150
+ readonly thinking?: TrailStepCustomProviderThinkingOverrideSupport;
47
151
  readonly cwd?: string;
48
152
  readonly env?: Readonly<Record<string, string>>;
49
153
  }
50
154
  interface TrailStepAgentTarget {
51
- /**
52
- * Either a key declared in the top-level `customProviders` object, or a
53
- * built-in provider registry id (e.g. `"claude"`). The registry is checked
54
- * first; `customProviders` is the fallback/escape hatch.
55
- */
155
+ /** Either a key declared in top-level `providers` or `customProviders`. */
56
156
  readonly provider: string;
57
157
  readonly model?: string;
58
158
  readonly thinking?: WorkflowAgentThinking;
@@ -70,11 +170,28 @@ interface TrailStepWorkflowConfig {
70
170
  readonly agents?: TrailStepAgentMappings;
71
171
  readonly settings?: TrailStepSettings;
72
172
  }
173
+ interface TrailStepStorageLifecycleRetentionConfig {
174
+ /** Duration string such as "7d"; false disables compression for the matching scope. */
175
+ readonly compressAfter?: string | false;
176
+ /** Duration string such as "30d"; false disables deletion for the matching scope. */
177
+ readonly deleteAfter?: string | false;
178
+ }
179
+ interface TrailStepStorageLifecycleConfig extends TrailStepStorageLifecycleRetentionConfig {
180
+ readonly enabled?: boolean;
181
+ readonly runOn?: readonly ("run" | "open" | "runs")[];
182
+ readonly throttle?: string | false;
183
+ readonly workflows?: Readonly<Record<string, TrailStepStorageLifecycleRetentionConfig>>;
184
+ }
185
+ interface TrailStepStorageConfig {
186
+ readonly lifecycle?: TrailStepStorageLifecycleConfig;
187
+ }
73
188
  interface TrailStepConfig {
74
189
  readonly version: 1;
75
190
  readonly customProviders: Readonly<Record<string, TrailStepCustomProviderConfig>>;
191
+ readonly providers?: Readonly<Record<string, TrailStepProviderRegistration>>;
76
192
  readonly agents: TrailStepAgentMappings;
77
193
  readonly settings?: TrailStepSettings;
194
+ readonly storage?: TrailStepStorageConfig;
78
195
  readonly workflows?: Readonly<Record<string, TrailStepWorkflowConfig>>;
79
196
  }
80
197
  interface ResolveAgentTargetsOptions {
@@ -84,10 +201,6 @@ interface ResolveAgentTargetsOptions {
84
201
  readonly roleSize: string;
85
202
  }
86
203
 
87
- declare function parseTrailStepConfig(value: unknown): TrailStepConfig;
88
-
89
- declare function resolveAgentTargets(options: ResolveAgentTargetsOptions): readonly TrailStepAgentTarget[];
90
-
91
204
  type PlainObject = Record<string, unknown>;
92
205
  interface ValidationDiagnostic {
93
206
  readonly path: string;
@@ -104,67 +217,6 @@ type ShapePrimitive = "string" | "number" | "boolean";
104
217
  type ShapeObject = Readonly<Record<string, ShapePrimitive>>;
105
218
  type ShapeInput<T extends PlainObject = PlainObject> = Schema<T> | ShapeObject;
106
219
 
107
- /**
108
- * A captured document artifact. `Document` doubles as its own
109
- * `Schema<Document>`: `validate`/`diagnostics`/`assert`/`jsonSchema`/
110
- * `captureMode` are static members, so passing the class itself as
111
- * `.prompt(source, { output: Document })` gives both the TypeScript output
112
- * type and the runtime validator from one symbol -- no separate schema
113
- * constant to import or keep in sync.
114
- */
115
- declare class Document {
116
- readonly content: string;
117
- readonly path: string;
118
- [key: string]: unknown;
119
- static readonly captureMode: "raw-text";
120
- static readonly jsonSchema: Record<string, unknown>;
121
- static validate(value: unknown): value is Document;
122
- static diagnostics(value: unknown): readonly ValidationDiagnostic[];
123
- /**
124
- * Deliberately duck-types instead of checking `instanceof Document`: on
125
- * resume, a completed step's recorded output is replayed from
126
- * `events.jsonl` via `JSON.parse`, producing a plain deserialized object —
127
- * never a live `Document` instance — before `assert` is called on it. An
128
- * `instanceof` check would fail every such replay. `assert` reconstructs a
129
- * genuine `Document` from any content/path-shaped value, so every
130
- * consumer downstream — a live capture or a replayed value alike — always
131
- * receives a real `Document` instance with working prototype methods.
132
- */
133
- static assert(value: unknown, label?: string): Document;
134
- constructor(content: string, path: string);
135
- }
136
- /**
137
- * Captures `content` as a durable document artifact for the currently
138
- * executing step. Must be called from within a step's `.do()` callback —
139
- * it reads the step-scoped ambient context (`RunContext.currentStep`, set
140
- * by `withStepContext` for the duration of the step) to determine both the
141
- * directory to write into and this call's 1-based index within the step, so
142
- * that a step calling `document(...)` more than once gets
143
- * `document-1.md`, `document-2.md`, etc.
144
- */
145
- declare function document(content: string): Promise<Document>;
146
-
147
- /**
148
- * Synchronously reads each named file relative to `dir` and returns its
149
- * trimmed content keyed the same way, so a step's `prompt.ts` can load all
150
- * of its shared markdown fragments in one call:
151
- * `loadFragments(import.meta.dirname, { methodology: "../shared/methodology.md" })`.
152
- */
153
- declare function loadFragments<TKey extends string>(dir: string, files: Record<TKey, string>): Record<TKey, string>;
154
- /**
155
- * Renders `body` as a `## title` markdown section, or `undefined` when
156
- * `body` is falsy -- so a conditional section can be inlined directly as a
157
- * `promptSections(...)` argument instead of built up separately.
158
- */
159
- declare function section(title: string, body: string | false | null | undefined): string | undefined;
160
- /**
161
- * Joins prompt fragments and `section(...)` results with a blank line
162
- * between each, dropping any falsy (conditionally-omitted) part.
163
- */
164
- declare function promptSections(...parts: ReadonlyArray<string | false | null | undefined>): string;
165
- /** Renders `items` as a markdown bullet list, one `- item` per line. */
166
- declare function list(items: readonly string[]): string;
167
-
168
220
  interface AgentStepRequestConfig<TInput extends PlainObject = PlainObject, TOutput extends PlainObject = PlainObject> {
169
221
  readonly kind?: "agent";
170
222
  readonly id: string;
@@ -217,14 +269,37 @@ declare class TrailStepFailureError extends Error {
217
269
  constructor(failure: Failure);
218
270
  }
219
271
 
220
- /** A local text file to load a prompt's content from, resolved relative to the workflow's `cwd` at dispatch time. */
272
+ interface RunContextState {
273
+ get<T = unknown>(key: string): Promise<T | undefined>;
274
+ getPersisted<T = unknown>(key: string): Promise<T | undefined>;
275
+ hydratePersisted(): Promise<void>;
276
+ set(key: string, value: unknown, options?: {
277
+ readonly persist?: boolean;
278
+ }): Promise<void>;
279
+ }
280
+
281
+ /** A local text file to load a prompt's content from, resolved relative to the workflow/project `cwd` at dispatch time. */
221
282
  interface PromptTemplateSource {
222
283
  readonly kind: "promptTemplate";
223
284
  readonly path: string;
224
285
  }
286
+ interface StepCwdContext<TInput extends PlainObject = PlainObject> {
287
+ readonly input: TInput;
288
+ readonly state: RunContextState;
289
+ readonly workflow: {
290
+ readonly id: string;
291
+ };
292
+ }
293
+ type StepCwdCallback<TInput extends PlainObject = PlainObject> = {
294
+ bivarianceHack(context: StepCwdContext<TInput>): unknown | Promise<unknown>;
295
+ }["bivarianceHack"];
296
+ type StepCwdInput<TInput extends PlainObject = PlainObject> = string | StepCwdCallback<TInput>;
225
297
  /** The object passed to `step(...)`. Always relevant, regardless of whether `.prompt(...)` is called. */
226
298
  interface StepConfig {
227
299
  readonly id: string;
300
+ readonly title?: string;
301
+ readonly description?: string;
302
+ readonly cwd?: StepCwdInput;
228
303
  readonly retry?: RetryPolicyInput;
229
304
  readonly timeout?: TimeoutPolicyInput;
230
305
  }
@@ -247,31 +322,130 @@ interface SubPromptOptions<TOutput extends PlainObject = PlainObject> {
247
322
  readonly adapter?: AgentAdapterSelection<PlainObject, TOutput>;
248
323
  readonly maxSubPrompts?: number;
249
324
  }
250
- /** The runtime shape stored in `StepNode.config` -- `StepConfig` plus `PromptOptions` (when a prompt was given) plus the resolved `input` and `prompt` source. */
325
+ type StepDisplayLevel = "info" | "warning" | "error" | "debug";
326
+ interface StepDisplayObject {
327
+ readonly message: string;
328
+ readonly level?: StepDisplayLevel;
329
+ readonly data?: unknown;
330
+ }
331
+ type StepDisplayValue = string | StepDisplayObject;
332
+ interface StepDisplayContext<TInput extends PlainObject = PlainObject, TOutput extends PlainObject = PlainObject> {
333
+ readonly input: TInput;
334
+ readonly output: TOutput;
335
+ }
336
+ type StepDisplayCallback<TInput extends PlainObject = PlainObject, TOutput extends PlainObject = PlainObject> = {
337
+ bivarianceHack(context: StepDisplayContext<TInput, TOutput>): StepDisplayValue | Promise<StepDisplayValue>;
338
+ }["bivarianceHack"];
339
+ type StepDisplayContent<TInput extends PlainObject = PlainObject, TOutput extends PlainObject = PlainObject> = StepDisplayValue | StepDisplayCallback<TInput, TOutput>;
340
+ /** Ordered phase for durable progress display events. */
341
+ interface DisplayPhase<TInput extends PlainObject = PlainObject, TOutput extends PlainObject = PlainObject> {
342
+ readonly kind: "display";
343
+ readonly content?: StepDisplayContent<TInput, TOutput>;
344
+ readonly options?: PlainObject;
345
+ }
346
+ interface WaitDefinition<TWaitOutput extends PlainObject = PlainObject> {
347
+ readonly id: string;
348
+ readonly kind: "input";
349
+ readonly message: string;
350
+ readonly output: ShapeInput<TWaitOutput>;
351
+ }
352
+ interface WaitOptions<TWaitOutput extends PlainObject = PlainObject> {
353
+ readonly output: ShapeInput<TWaitOutput>;
354
+ }
355
+ interface WaitPendingInput {
356
+ readonly id: string;
357
+ readonly message: string;
358
+ readonly retryAfterSeconds?: number;
359
+ }
360
+ interface WaitPendingResult {
361
+ readonly status: "pending";
362
+ readonly id: string;
363
+ readonly message: string;
364
+ readonly retryAfterSeconds?: number;
365
+ }
366
+ interface WaitDoneResult<TWaitOutput extends PlainObject = PlainObject> {
367
+ readonly status: "done";
368
+ readonly output: TWaitOutput;
369
+ }
370
+ type WaitCheckResult<TWaitOutput extends PlainObject = PlainObject> = WaitDoneResult<TWaitOutput> | WaitPendingResult;
371
+ interface CheckWaitHelpers<TWaitOutput extends PlainObject = PlainObject> {
372
+ done(output: TWaitOutput): WaitDoneResult<TWaitOutput>;
373
+ pending(input: WaitPendingInput): WaitPendingResult;
374
+ }
375
+ interface StepWaitContext<TInput extends PlainObject = PlainObject, TOutput extends PlainObject = PlainObject> {
376
+ readonly input: TInput;
377
+ readonly output: TOutput;
378
+ readonly waits: Readonly<Record<string, PlainObject>>;
379
+ }
380
+ interface CheckWaitContext<TInput extends PlainObject = PlainObject, TOutput extends PlainObject = PlainObject, TWaitOutput extends PlainObject = PlainObject> extends StepWaitContext<TInput, TOutput> {
381
+ readonly wait: CheckWaitHelpers<TWaitOutput>;
382
+ }
383
+ type WaitCallback<TInput extends PlainObject = PlainObject, TOutput extends PlainObject = PlainObject, TWaitOutput extends PlainObject = PlainObject> = {
384
+ bivarianceHack(context: StepWaitContext<TInput, TOutput>): WaitDefinition<TWaitOutput> | Promise<WaitDefinition<TWaitOutput>>;
385
+ }["bivarianceHack"];
386
+ type CheckWaitCallback<TInput extends PlainObject = PlainObject, TOutput extends PlainObject = PlainObject, TWaitOutput extends PlainObject = PlainObject> = {
387
+ bivarianceHack(context: CheckWaitContext<TInput, TOutput, TWaitOutput>): WaitCheckResult<TWaitOutput> | Promise<WaitCheckResult<TWaitOutput>>;
388
+ }["bivarianceHack"];
389
+ type WaitInput<TInput extends PlainObject = PlainObject, TOutput extends PlainObject = PlainObject, TWaitOutput extends PlainObject = PlainObject> = WaitDefinition<TWaitOutput> | WaitCallback<TInput, TOutput, TWaitOutput>;
390
+ /** Ordered durable pause phase for human/external input/check waits. */
391
+ interface WaitPhase<TInput extends PlainObject = PlainObject, TOutput extends PlainObject = PlainObject> {
392
+ readonly kind: "wait";
393
+ readonly wait: WaitInput<TInput, TOutput> | CheckWaitCallback<TInput, TOutput>;
394
+ readonly options?: WaitOptions;
395
+ }
396
+ interface PromptPhase<TInput extends PlainObject = PlainObject, TOutput extends PlainObject = PlainObject> extends PromptOptions<TOutput> {
397
+ readonly kind: "prompt";
398
+ readonly prompt: AgentPrompt<TInput> | PromptTemplateSource;
399
+ }
400
+ type StepContinuationOutput<TOutput extends PlainObject = PlainObject> = TOutput & {
401
+ readonly output: TOutput;
402
+ readonly waits: Readonly<Record<string, PlainObject>>;
403
+ };
404
+ type StepContinuation<TInput extends PlainObject = PlainObject, TOutput extends PlainObject = PlainObject> = {
405
+ bivarianceHack(output: TOutput, input: TInput): ContinuationResult | Promise<ContinuationResult>;
406
+ }["bivarianceHack"];
407
+ type StepContextContinuation<TInput extends PlainObject = PlainObject, TOutput extends PlainObject = PlainObject> = {
408
+ bivarianceHack(output: StepContinuationOutput<TOutput>, input: TInput): ContinuationResult | Promise<ContinuationResult>;
409
+ }["bivarianceHack"];
410
+ interface DoPhase<TInput extends PlainObject = PlainObject, TOutput extends PlainObject = PlainObject> {
411
+ readonly kind: "do";
412
+ readonly onOutput: StepContinuation<TInput, TOutput>;
413
+ }
414
+ type StepPhase<TInput extends PlainObject = PlainObject, TOutput extends PlainObject = PlainObject> = DisplayPhase<TInput, TOutput> | WaitPhase<TInput, TOutput> | PromptPhase<TInput, TOutput> | DoPhase<TInput, TOutput>;
415
+ /** The runtime shape stored in `StepNode.config` -- `StepConfig` plus the resolved `input`. Legacy prompt fields are retained for compatibility; ordered `StepNode.phases` is the canonical execution model. */
251
416
  interface ContinuationStepConfig<TInput extends PlainObject = PlainObject, TOutput extends PlainObject = PlainObject> {
252
417
  readonly id: string;
418
+ readonly title?: string;
419
+ readonly description?: string;
253
420
  readonly input: TInput;
421
+ /** @deprecated Prefer the ordered prompt phase in `StepNode.phases`. */
254
422
  readonly output?: ShapeInput<TOutput>;
423
+ /** @deprecated Prefer the ordered prompt phase in `StepNode.phases`. */
255
424
  readonly prompt?: AgentPrompt<TInput> | PromptTemplateSource;
425
+ /** @deprecated Prefer the ordered prompt phase in `StepNode.phases`. */
256
426
  readonly agent?: string;
427
+ /** @deprecated Prefer the ordered prompt phase in `StepNode.phases`. */
257
428
  readonly mode?: "working" | "interactive";
429
+ /** @deprecated Prefer the ordered prompt phase in `StepNode.phases`. */
258
430
  readonly adapter?: AgentAdapterSelection<TInput, TOutput>;
431
+ /** @deprecated Prefer the ordered prompt phase in `StepNode.phases`. */
259
432
  readonly maxSubPrompts?: number;
433
+ readonly cwd?: StepCwdInput<TInput>;
260
434
  readonly retry?: RetryPolicyInput;
261
435
  readonly timeout?: TimeoutPolicyInput;
262
436
  }
263
- type StepContinuation<TInput extends PlainObject = PlainObject, TOutput extends PlainObject = PlainObject> = {
264
- bivarianceHack(output: TOutput, input: TInput): ContinuationResult | Promise<ContinuationResult>;
265
- }["bivarianceHack"];
266
437
  type StepErrorContinuation = {
267
438
  bivarianceHack(error: Failure): ContinuationResult;
268
439
  }["bivarianceHack"];
269
440
  interface StepNode<TInput extends PlainObject = PlainObject, TOutput extends PlainObject = PlainObject> {
270
441
  readonly kind: "step";
271
442
  readonly config: ContinuationStepConfig<TInput, TOutput>;
272
- /** Receives the step's own input as the second argument, alongside its output as the first. */
443
+ /** Ordered phase pipeline. This is the canonical runtime representation for authored nodes. Optional only so legacy StepNode-shaped objects can still be translated at runtime. */
444
+ readonly phases?: readonly StepPhase<TInput, TOutput>[];
445
+ /** @deprecated Prefer the `do` phase in `StepNode.phases`. Retained for compatibility with existing callers. */
273
446
  readonly onOutput: StepContinuation<TInput, TOutput>;
274
447
  readonly onError?: StepErrorContinuation;
448
+ readonly options?: StepInvocationOptions;
275
449
  }
276
450
  /**
277
451
  * Returned by `step(...).prompt(...)?.do(...)`: a reusable step definition,
@@ -280,69 +454,83 @@ interface StepNode<TInput extends PlainObject = PlainObject, TOutput extends Pla
280
454
  * calling it. When `TInput` has no required keys (e.g. a step that ignores
281
455
  * its input), the call is `stepA()` -- the input argument is optional.
282
456
  */
283
- type StepFactory<TInput extends PlainObject = PlainObject, TOutput extends PlainObject = PlainObject> = ({} extends TInput ? (input?: TInput) => StepNode<TInput, TOutput> : (input: TInput) => StepNode<TInput, TOutput>) & {
457
+ interface StepInvocationOptions extends Partial<Omit<StepConfig, "id">> {
458
+ readonly branchId?: string;
459
+ }
460
+ type StepFactory<TInput extends PlainObject = PlainObject, TOutput extends PlainObject = PlainObject> = ({} extends TInput ? (input?: TInput, options?: StepInvocationOptions) => StepNode<TInput, TOutput> : (input: TInput, options?: StepInvocationOptions) => StepNode<TInput, TOutput>) & {
284
461
  catch(onError: StepErrorContinuation): StepFactory<TInput, TOutput>;
285
462
  };
286
463
  type SubPromptFactory<TInput extends PlainObject = PlainObject, TOutput extends PlainObject = PlainObject> = {} extends TInput ? (input?: TInput) => Promise<TOutput> : (input: TInput) => Promise<TOutput>;
464
+ interface TerminalMessageOptions {
465
+ readonly message?: string;
466
+ }
287
467
  interface DoneNode<TOutput extends PlainObject = PlainObject> {
288
468
  readonly kind: "done";
289
469
  readonly output: TOutput;
470
+ readonly message?: string;
290
471
  }
291
472
  /** Terminates the workflow as a failure without dispatching a step -- no step.* events, just workflow.failed. */
292
473
  interface FailNode {
293
474
  readonly kind: "fail";
294
475
  readonly failure: Failure;
476
+ readonly message?: string;
295
477
  }
296
- type ContinuationResult<TOutput extends PlainObject = PlainObject> = StepNode<PlainObject, PlainObject> | DoneNode<TOutput> | FailNode;
297
-
298
- /** Loads a step's prompt from a local text file, resolved relative to the workflow's `cwd` at dispatch time. */
299
- declare function promptTemplate(path: string): PromptTemplateSource;
300
-
301
- type JsonSchemaObject = JSONSchemaType<PlainObject> | Record<string, unknown>;
302
- declare function normalizeShape<T extends PlainObject>(shapeInput: ShapeInput<T>): Schema<T>;
303
- declare function shape<T extends PlainObject>(shapeObject: ShapeObject): Schema<T>;
304
- declare function jsonSchema<T extends PlainObject>(schema: JsonSchemaObject): Schema<T>;
305
-
306
- /**
307
- * Ambient handle onto the active run's identity and durable key-value store.
308
- * Backed by AsyncLocalStorage, set once per run by `runWorkflow`; step
309
- * continuations import this directly rather than receiving it as an argument.
310
- */
311
- declare const state: {
312
- get<T = unknown>(key: string): Promise<T | undefined>;
313
- set(key: string, value: unknown): Promise<void>;
314
- readonly id: string;
315
- readonly name: string;
316
- readonly path: string;
317
- readonly cwd: string | undefined;
318
- };
319
-
320
- /**
321
- * The only step-authoring primitive. `.prompt(...)` is optional; when present,
322
- * the step dispatches to an agent and `.do(...)` receives its structured
323
- * output. When absent, nothing is dispatched -- `.do(...)` receives the
324
- * step's input directly and is responsible for the work and the continuation
325
- * in one function. Either way, `.do(...)` produces a reusable `StepFactory`
326
- * -- call it with a live input value (`stepA(input)`) to get a `StepNode`.
327
- * When the inferred input type has no required keys, the argument is
328
- * optional (`stepA()`) and defaults to `{}`.
329
- */
330
- declare function step(config: StepConfig): {
331
- prompt<TInput extends PlainObject = PlainObject, TOutput extends PlainObject = PlainObject>(source: AgentPrompt<TInput> | PromptTemplateSource, options?: PromptOptions<TOutput>): {
332
- do(onOutput: StepContinuation<TInput, TOutput>): StepFactory<TInput, TOutput>;
333
- };
334
- do<TInput extends PlainObject = PlainObject>(onOutput: StepContinuation<TInput, TInput>): StepFactory<TInput, TInput>;
335
- };
336
- declare function done<TOutput extends PlainObject = PlainObject>(output?: TOutput): DoneNode<TOutput>;
337
- declare function fail(failure: Failure): FailNode;
338
- declare function isStepNode(value: unknown): value is StepNode;
339
- declare function isDoneNode(value: unknown): value is DoneNode;
340
- declare function isFailNode(value: unknown): value is FailNode;
341
-
342
- declare function subPrompt<TInput extends PlainObject = PlainObject, TOutput extends PlainObject = PlainObject>(source: AgentPrompt<TInput> | PromptTemplateSource, options: SubPromptOptions<TOutput>): SubPromptFactory<TInput, TOutput>;
478
+ interface WorkflowInvocationOptions {
479
+ readonly branchId?: string;
480
+ }
481
+ type PostContinuation<TOutput extends PlainObject = PlainObject> = {
482
+ bivarianceHack(output: TOutput): ContinuationResult | Promise<ContinuationResult>;
483
+ }["bivarianceHack"];
484
+ interface WorkflowInvocationNode<TInput extends PlainObject = PlainObject, TOutput extends PlainObject = PlainObject> {
485
+ readonly kind: "workflowInvocation";
486
+ readonly workflow: Workflow<TInput, TOutput>;
487
+ readonly input: TInput;
488
+ readonly options?: WorkflowInvocationOptions;
489
+ post(continuation: PostContinuation<TOutput>): WorkflowInvocationNode<TInput, TOutput>;
490
+ readonly postContinuation?: PostContinuation<TOutput>;
491
+ }
492
+ interface AbsoluteDoneNode<TOutput extends PlainObject = PlainObject> {
493
+ readonly kind: "absoluteDone";
494
+ readonly output: TOutput;
495
+ readonly message?: string;
496
+ }
497
+ interface AbsoluteFailNode {
498
+ readonly kind: "absoluteFail";
499
+ readonly failure: Failure;
500
+ readonly message?: string;
501
+ }
502
+ interface RunnableWorkflowInvocationNode {
503
+ readonly kind: "workflowInvocation";
504
+ readonly workflow: unknown;
505
+ readonly input: PlainObject;
506
+ readonly options?: unknown;
507
+ readonly postContinuation?: PostContinuation;
508
+ }
509
+ type RunnableContinuationNode = StepNode<PlainObject, PlainObject> | RunnableWorkflowInvocationNode;
510
+ type ContinuationArray = readonly RunnableContinuationNode[];
511
+ type ParallelFailurePolicy = "fail-fast" | "all-settled";
512
+ interface ParallelOptions {
513
+ readonly concurrency?: number;
514
+ readonly failurePolicy?: ParallelFailurePolicy;
515
+ }
516
+ interface ParallelNode<TOutput extends PlainObject = PlainObject> {
517
+ readonly kind: "parallel";
518
+ readonly nodes: ContinuationArray;
519
+ readonly options?: ParallelOptions;
520
+ post(continuation: PostContinuation<TOutput>): ParallelNode<TOutput>;
521
+ readonly postContinuation?: PostContinuation<TOutput>;
522
+ }
523
+ type ContinuationResult<TOutput extends PlainObject = PlainObject> = StepNode<PlainObject, PlainObject> | DoneNode<TOutput> | FailNode | RunnableWorkflowInvocationNode | AbsoluteDoneNode<TOutput> | AbsoluteFailNode | ContinuationArray | ParallelNode<TOutput>;
343
524
 
525
+ interface WorkflowSkillOptions {
526
+ readonly description?: string;
527
+ readonly instructions?: string;
528
+ readonly markdown?: string;
529
+ }
344
530
  interface Workflow<TInput extends PlainObject = PlainObject, TOutput extends PlainObject = PlainObject> {
345
531
  readonly id: string;
532
+ readonly description?: string;
533
+ readonly skill?: string | WorkflowSkillOptions;
346
534
  readonly input?: Schema<TInput>;
347
535
  readonly output?: Schema<TOutput>;
348
536
  readonly inputShape?: ShapeInput<TInput>;
@@ -352,43 +540,26 @@ interface Workflow<TInput extends PlainObject = PlainObject, TOutput extends Pla
352
540
  readonly timeout?: TimeoutPolicyInput;
353
541
  readonly start: (input: TInput) => ContinuationResult<TOutput>;
354
542
  }
543
+ type WorkflowBuilderOptions<TInput extends PlainObject = PlainObject, TOutput extends PlainObject = PlainObject> = Workflow<TInput, TOutput>;
544
+ type DefinedWorkflow<TInput extends PlainObject = PlainObject, TOutput extends PlainObject = PlainObject> = Workflow<TInput, TOutput> & ((input: TInput, options?: WorkflowInvocationOptions) => WorkflowInvocationNode<TInput, TOutput>);
355
545
 
356
- type DeprecationTargetPackage = "@trailstep/core" | "@trailstep/authoring";
357
- interface DeprecationEntry {
358
- /** Which published package exports this symbol. A symbol re-exported by both (like `step`,
359
- * which authoring re-exports from core) needs one entry per package it's importable from, since a
360
- * workflow author might import it from either. */
361
- readonly package: DeprecationTargetPackage;
362
- /** The exact named export identifier, e.g. "step". Matched literally against import statement
363
- * text by the scanner. */
364
- readonly symbol: string;
365
- /** Semver version at/after which this symbol is considered deprecated (still works, warns). */
366
- readonly deprecatedSince: string;
367
- /** Semver version at/after which this symbol is actually removed (no longer works). Omit if the
368
- * symbol is deprecated but has no planned removal. */
369
- readonly removedIn?: string;
370
- /** Human-readable explanation, shown verbatim in doctor/update output. */
371
- readonly message: string;
372
- /** Optional suggested replacement API, shown as "Suggested replacement: <this>." */
373
- readonly replacement?: string;
374
- }
375
- type DeprecationManifest = readonly DeprecationEntry[];
376
- interface DeprecationStatus extends DeprecationEntry {
377
- readonly severity: "warning" | "blocking";
378
- }
379
-
380
- declare const deprecationManifest: DeprecationManifest;
381
- interface FindDeprecationsAsOfQuery {
382
- readonly package: DeprecationTargetPackage;
383
- readonly version: string;
546
+ declare const CANCELLATION_MARKER_FILE = "cancel.json";
547
+ interface CancellationMarker {
548
+ readonly requestedAt?: string;
549
+ readonly reason?: string;
550
+ readonly source?: string;
384
551
  }
385
- /**
386
- * Returns every manifest entry for query.package whose deprecatedSince is at or before
387
- * query.version, tagged with a severity. Calling this once with version set to a target
388
- * version naturally captures every entry between the installed version and the target, no matter
389
- * how many majors are being skipped in one update.
390
- */
391
- declare function findDeprecationsAsOf(manifest: DeprecationManifest, query: FindDeprecationsAsOfQuery): readonly DeprecationStatus[];
552
+ declare function cancellationMarkerPath(runDir: string): string;
553
+ declare function readCancellationMarker(runDir: string): Promise<CancellationMarker | undefined>;
554
+ declare function writeCancellationMarker(options: {
555
+ readonly runDir: string;
556
+ readonly reason?: string;
557
+ readonly source?: string;
558
+ readonly requestedAt?: Date;
559
+ }): Promise<{
560
+ readonly marker: CancellationMarker;
561
+ readonly alreadyExisted: boolean;
562
+ }>;
392
563
 
393
564
  type TrailStepConfigInput = TrailStepConfig | Readonly<Record<string, unknown>>;
394
565
  interface InteractiveProcessRequest {
@@ -409,7 +580,7 @@ interface WorkingAgentProcessRequest {
409
580
  readonly args: readonly string[];
410
581
  readonly cwd: string;
411
582
  readonly shell: false;
412
- readonly stdio: "inherit";
583
+ readonly stdio: "inherit" | "pipe";
413
584
  readonly promptFile: string;
414
585
  readonly outputFile: string;
415
586
  readonly model?: string;
@@ -417,6 +588,7 @@ interface WorkingAgentProcessRequest {
417
588
  }
418
589
  interface WorkingAgentProcessResult {
419
590
  readonly exitCode: number;
591
+ readonly stdout?: string;
420
592
  }
421
593
  type WorkingAgentProcessRunner = (request: WorkingAgentProcessRequest) => WorkingAgentProcessResult | Promise<WorkingAgentProcessResult>;
422
594
  interface Event<TPayload extends PlainObject = PlainObject> {
@@ -424,11 +596,22 @@ interface Event<TPayload extends PlainObject = PlainObject> {
424
596
  readonly runId: string;
425
597
  readonly workflowId: string;
426
598
  readonly stepId?: string;
427
- readonly type: "workflow.started" | "workflow.resumed" | "workflow.retryStarted" | "workflow.failed" | "step.started" | "step.completed" | "step.failed" | "subPrompt.started" | "subPrompt.completed" | "subPrompt.failed" | "interactive.sessionStarted" | "interactive.sessionCompleted" | "agent.toolCall" | "workflow.completed";
599
+ readonly type: "workflow.started" | "workflow.resumed" | "workflow.retryStarted" | "workflow.cancelRequested" | "workflow.failed" | "workflow.cancelled" | "step.started" | "step.completed" | "step.failed" | "step.cancelled" | "step.display" | "step.progress" | "step.warning" | "step.artifact" | "wait.started" | "wait.satisfied" | "wait.failed" | "subPrompt.started" | "subPrompt.completed" | "subPrompt.failed" | "interactive.sessionStarted" | "interactive.sessionCompleted" | "agent.toolCall" | "workflow.completed";
428
600
  readonly timestamp: string;
429
601
  readonly schemaVersion: "v0";
430
602
  readonly payload: TPayload;
431
603
  }
604
+ interface WaitResultDetails {
605
+ readonly stepId: string;
606
+ readonly waitId: string;
607
+ readonly kind?: "input" | "check";
608
+ readonly message: string;
609
+ readonly retryAfterSeconds?: number;
610
+ readonly artifactPaths: {
611
+ readonly requestFile: string;
612
+ readonly answerFile: string;
613
+ };
614
+ }
432
615
  type Result<TOutput extends PlainObject = PlainObject> = {
433
616
  readonly status: "success";
434
617
  readonly runId: string;
@@ -441,9 +624,30 @@ type Result<TOutput extends PlainObject = PlainObject> = {
441
624
  readonly runDir: string;
442
625
  readonly failure: Failure;
443
626
  readonly events: readonly Event[];
444
- };
627
+ } | ({
628
+ readonly status: "waiting";
629
+ readonly runId: string;
630
+ readonly runDir: string;
631
+ readonly wait: WaitResultDetails;
632
+ readonly events: readonly Event[];
633
+ } & {
634
+ /** Type-only compatibility for existing non-success branches; waiting results do not carry a runtime failure. */
635
+ readonly failure: never;
636
+ }) | ({
637
+ readonly status: "cancelled";
638
+ readonly runId: string;
639
+ readonly runDir: string;
640
+ readonly cancellation: CancellationMarker;
641
+ readonly events: readonly Event[];
642
+ } & {
643
+ /** Type-only compatibility for existing non-success branches; cancelled results do not carry a runtime failure. */
644
+ readonly failure: never;
645
+ });
445
646
  interface RunWorkflowBaseOptions<TInput extends PlainObject, TOutput extends PlainObject> {
446
647
  readonly workflow: Workflow<TInput, TOutput>;
648
+ /** Root used for workflow/config-relative resolution and default artifact storage. Defaults to `cwd` for backward compatibility, then `process.cwd()`. */
649
+ readonly projectCwd?: string;
650
+ /** Default execution cwd for steps and agent processes. Defaults to `projectCwd`. */
447
651
  readonly cwd?: string;
448
652
  readonly runsRoot?: string;
449
653
  readonly eventSink?: (event: Event) => void | Promise<void>;
@@ -453,12 +657,27 @@ interface RunWorkflowBaseOptions<TInput extends PlainObject, TOutput extends Pla
453
657
  /** Injectable stdout-capturing runner for built-in registry provider adapters (e.g. Claude). Test-only seam. */
454
658
  readonly providerWorkingRunner?: ProviderWorkingRunner;
455
659
  readonly maxSteps?: number;
660
+ readonly scheduler?: {
661
+ readonly workers?: number;
662
+ };
456
663
  }
664
+ type RunWorkflowTrackRetryOptions = {
665
+ readonly mode: "failed-only";
666
+ } | {
667
+ readonly mode: "branch";
668
+ readonly branchId: string;
669
+ };
670
+ type RunWorkflowRetryOptions = {
671
+ readonly runDir: string;
672
+ readonly kind: "manual" | "automatic";
673
+ readonly track?: RunWorkflowTrackRetryOptions;
674
+ };
457
675
  type RunWorkflowOptions<TInput extends PlainObject = PlainObject, TOutput extends PlainObject = PlainObject> = RunWorkflowBaseOptions<TInput, TOutput> & ({
458
676
  readonly input: TInput;
459
677
  readonly runName: string;
460
678
  readonly resume?: undefined;
461
679
  readonly retry?: undefined;
680
+ readonly continue?: undefined;
462
681
  } | {
463
682
  readonly resume: {
464
683
  readonly runDir: string;
@@ -466,14 +685,21 @@ type RunWorkflowOptions<TInput extends PlainObject = PlainObject, TOutput extend
466
685
  readonly input?: undefined;
467
686
  readonly runName?: undefined;
468
687
  readonly retry?: undefined;
688
+ readonly continue?: undefined;
469
689
  } | {
470
- readonly retry: {
690
+ readonly retry: RunWorkflowRetryOptions;
691
+ readonly input?: undefined;
692
+ readonly runName?: undefined;
693
+ readonly resume?: undefined;
694
+ readonly continue?: undefined;
695
+ } | {
696
+ readonly continue: {
471
697
  readonly runDir: string;
472
- readonly kind: "manual" | "automatic";
473
698
  };
474
699
  readonly input?: undefined;
475
700
  readonly runName?: undefined;
476
701
  readonly resume?: undefined;
702
+ readonly retry?: undefined;
477
703
  });
478
704
 
479
705
  /**
@@ -517,6 +743,87 @@ interface ProviderWorkingProcessResult {
517
743
  * `stdin` is set. Injectable for tests.
518
744
  */
519
745
  type ProviderWorkingRunner = (request: ProviderWorkingProcessRequest) => ProviderWorkingProcessResult | Promise<ProviderWorkingProcessResult>;
746
+ type ProviderPromptFileReferenceStyle = "at-prefixed-argument";
747
+ type ProviderPromptInputSpec = {
748
+ readonly kind: "prompt-file";
749
+ readonly reference: ProviderPromptFileReferenceStyle;
750
+ } | {
751
+ readonly kind: "inline-prompt";
752
+ };
753
+ type ProviderOutputStyle = "stdout-json-envelope" | "stdout-jsonl-transcript" | "provider-output-file";
754
+ interface ProviderOutputParsingMetadata {
755
+ readonly resultField?: string;
756
+ }
757
+ interface ProviderOutputSpec {
758
+ readonly style: ProviderOutputStyle;
759
+ readonly parsing?: ProviderOutputParsingMetadata;
760
+ }
761
+ type ProviderModelDiscoveryOutputParser = "pi-list-models-table";
762
+ interface ProviderModelDiscoverySpec {
763
+ readonly command: string;
764
+ readonly args: readonly string[];
765
+ readonly outputParser: ProviderModelDiscoveryOutputParser;
766
+ }
767
+ type ProviderModelOverrideSupport = {
768
+ readonly supported: true;
769
+ readonly flag: string;
770
+ readonly discovery?: ProviderModelDiscoverySpec;
771
+ } | {
772
+ readonly supported: false;
773
+ };
774
+ type ProviderThinkingOverrideSupport = {
775
+ readonly supported: true;
776
+ readonly flag: string;
777
+ readonly levels: readonly WorkflowAgentThinking[];
778
+ } | {
779
+ readonly supported: false;
780
+ readonly levels?: readonly [];
781
+ };
782
+ interface ProviderWorkingRepairInvocationSpec {
783
+ readonly supported: boolean;
784
+ readonly resumeFlag?: string;
785
+ readonly promptDelivery?: "stdin" | "prompt-file";
786
+ }
787
+ interface ProviderWorkingInvocationSpec {
788
+ readonly command: string;
789
+ readonly prompt: ProviderPromptInputSpec;
790
+ readonly baseArgs: readonly string[];
791
+ readonly output: ProviderOutputSpec;
792
+ readonly repair?: ProviderWorkingRepairInvocationSpec;
793
+ }
794
+ type ManagedSessionPromptInjectionMode = "hidden-system-prompt-file" | "visible-prompt-file" | "visible-inline-prompt";
795
+ type ProviderManagedSessionPromptDelivery = {
796
+ readonly delivery: "hidden-system-prompt-file";
797
+ } | {
798
+ readonly delivery: "visible-prompt";
799
+ readonly mode: "visible-prompt-file" | "visible-inline-prompt";
800
+ };
801
+ type ProviderInteractiveInvocationSpec = {
802
+ readonly supported: true;
803
+ readonly command: string;
804
+ readonly requiresSystemPromptFile?: boolean;
805
+ readonly systemPromptFileFlag?: string;
806
+ readonly modelFlag?: string;
807
+ readonly permissionBypassFlag?: string;
808
+ /**
809
+ * Declares how TrailStep-managed standalone sessions should deliver their
810
+ * managed-session prompt. Hidden/system delivery is only claimed when the
811
+ * provider adapter has a dedicated system-prompt mechanism; otherwise the
812
+ * managed prompt is intentionally passed as visible user input.
813
+ */
814
+ readonly managedSessionPrompt: ProviderManagedSessionPromptDelivery;
815
+ } | {
816
+ readonly supported: false;
817
+ readonly reason?: string;
818
+ };
819
+ interface ProviderSpec {
820
+ readonly id: string;
821
+ readonly displayName: string;
822
+ readonly model: ProviderModelOverrideSupport;
823
+ readonly thinking: ProviderThinkingOverrideSupport;
824
+ readonly working: ProviderWorkingInvocationSpec;
825
+ readonly interactive: ProviderInteractiveInvocationSpec;
826
+ }
520
827
  /** Request shape for a built-in provider's interactive (human-in-the-loop) invocation. */
521
828
  interface ProviderInteractiveRequest {
522
829
  readonly prompt: string;
@@ -527,6 +834,7 @@ interface ProviderInteractiveRequest {
527
834
  readonly systemPromptFile?: string;
528
835
  readonly cwd: string;
529
836
  readonly model?: string;
837
+ readonly thinking?: WorkflowAgentThinking;
530
838
  /** Undefined means bypass (per-tool confirmation is skipped by default). */
531
839
  readonly permissionMode?: "bypass" | "prompt";
532
840
  readonly env?: Readonly<Record<string, string>>;
@@ -558,6 +866,7 @@ interface ProviderWorkingRepairRequest {
558
866
  */
559
867
  interface ProviderAdapter {
560
868
  readonly id: string;
869
+ readonly spec: ProviderSpec;
561
870
  /** Non-interactive invocation: writes `request.outputFile` itself before resolving. */
562
871
  runWorking(request: ProviderWorkingRequest, runner?: ProviderWorkingRunner): Promise<void>;
563
872
  /**
@@ -575,25 +884,238 @@ interface ProviderAdapter {
575
884
  runInteractive(request: ProviderInteractiveRequest, runner?: InteractiveProcessRunner): Promise<InteractiveProcessResult>;
576
885
  }
577
886
 
887
+ interface LaunchInteractiveAgentTargetOptions {
888
+ readonly config: TrailStepConfig;
889
+ readonly target: TrailStepAgentTarget;
890
+ readonly prompt: string;
891
+ readonly promptFile: string;
892
+ readonly cwd: string;
893
+ readonly runner?: InteractiveProcessRunner;
894
+ readonly signal?: AbortSignal;
895
+ }
896
+ type LaunchInteractiveAgentTargetResult = InteractiveProcessResult & {
897
+ readonly promptInjectionMode: ManagedSessionPromptInjectionMode;
898
+ };
899
+ declare function launchInteractiveAgentTarget(options: LaunchInteractiveAgentTargetOptions): Promise<LaunchInteractiveAgentTargetResult>;
900
+
901
+ type ParsedTrailStepConfig = TrailStepConfig & {
902
+ readonly providers: NonNullable<TrailStepConfig["providers"]>;
903
+ };
904
+ declare function parseTrailStepConfig(value: unknown): ParsedTrailStepConfig;
905
+
906
+ declare function resolveAgentTargets(options: ResolveAgentTargetsOptions): readonly TrailStepAgentTarget[];
907
+
908
+ /**
909
+ * A captured document artifact. `Document` doubles as its own
910
+ * `Schema<Document>`: `validate`/`diagnostics`/`assert`/`jsonSchema`/
911
+ * `captureMode` are static members, so passing the class itself as
912
+ * `.prompt(source, { output: Document })` gives both the TypeScript output
913
+ * type and the runtime validator from one symbol -- no separate schema
914
+ * constant to import or keep in sync.
915
+ */
916
+ declare class Document {
917
+ readonly content: string;
918
+ readonly path: string;
919
+ [key: string]: unknown;
920
+ static readonly captureMode: "raw-text";
921
+ static readonly jsonSchema: Record<string, unknown>;
922
+ static validate(value: unknown): value is Document;
923
+ static diagnostics(value: unknown): readonly ValidationDiagnostic[];
924
+ /**
925
+ * Deliberately duck-types instead of checking `instanceof Document`: on
926
+ * resume, a completed step's recorded output is replayed from
927
+ * `events.jsonl` via `JSON.parse`, producing a plain deserialized object —
928
+ * never a live `Document` instance — before `assert` is called on it. An
929
+ * `instanceof` check would fail every such replay. `assert` reconstructs a
930
+ * genuine `Document` from any content/path-shaped value, so every
931
+ * consumer downstream — a live capture or a replayed value alike — always
932
+ * receives a real `Document` instance with working prototype methods.
933
+ */
934
+ static assert(value: unknown, label?: string): Document;
935
+ constructor(content: string, path: string);
936
+ }
578
937
  /**
579
- * Core's built-in known-CLI provider registry. Each entry maps a provider id
580
- * (matched against a `.trailstep/config.json` target's `provider` field) to a
581
- * core-owned CLI print-mode invocation for a single named vendor.
582
- *
583
- * This is the full four-provider set. Unlike Claude/Codex/Pi, `gemini`'s
584
- * adapter is structurally verified only (an injected fake stdout-capturing
585
- * runner in `agent.test.ts`/`gemini.test.ts`) — the real `gemini` CLI is not
586
- * installed in this environment, so its argv/envelope shape has not been
587
- * confirmed against a live process.
938
+ * Captures `content` as a durable document artifact for the currently
939
+ * executing step. Must be called from within a step's `.do()` callback —
940
+ * it reads the step-scoped ambient context (`RunContext.currentStep`, set
941
+ * by `withStepContext` for the duration of the step) to determine both the
942
+ * directory to write into and this call's 1-based index within the step, so
943
+ * that a step calling `document(...)` more than once gets
944
+ * `document-1.md`, `document-2.md`, etc.
588
945
  */
589
- declare const providerRegistry: Record<"claude" | "codex" | "pi" | "gemini", ProviderAdapter>;
590
- type ProviderRegistryKey = keyof typeof providerRegistry;
946
+ declare function document(content: string): Promise<Document>;
947
+
948
+ /** Ambient handle onto the active run's track-scoped durable key-value store. */
949
+ declare const globalState: {
950
+ get<T = unknown>(key: string): Promise<T | undefined>;
951
+ set(key: string, value: unknown): Promise<void>;
952
+ update<T = unknown>(key: string, updater: (current: T | undefined) => T | Promise<T>): Promise<T>;
953
+ };
954
+
955
+ interface NotifyArtifact {
956
+ readonly path: string;
957
+ readonly mediaType?: string;
958
+ readonly data?: PlainObject;
959
+ }
960
+ interface NotifyApi {
961
+ progress(message: string, data?: PlainObject): Promise<void>;
962
+ warning(message: string, data?: PlainObject): Promise<void>;
963
+ artifact(name: string, artifact: NotifyArtifact): Promise<void>;
964
+ }
965
+ declare const notify: NotifyApi;
966
+
967
+ /**
968
+ * Synchronously reads each named file relative to `dir` and returns its
969
+ * trimmed content keyed the same way, so a step's `prompt.ts` can load all
970
+ * of its shared markdown fragments in one call:
971
+ * `loadFragments(import.meta.dirname, { methodology: "../shared/methodology.md" })`.
972
+ */
973
+ declare function loadFragments<TKey extends string>(dir: string, files: Record<TKey, string>): Record<TKey, string>;
974
+ /**
975
+ * Renders `body` as a `## title` markdown section, or `undefined` when
976
+ * `body` is falsy -- so a conditional section can be inlined directly as a
977
+ * `promptSections(...)` argument instead of built up separately.
978
+ */
979
+ declare function section(title: string, body: string | false | null | undefined): string | undefined;
980
+ /**
981
+ * Joins prompt fragments and `section(...)` results with a blank line
982
+ * between each, dropping any falsy (conditionally-omitted) part.
983
+ */
984
+ declare function promptSections(...parts: ReadonlyArray<string | false | null | undefined>): string;
985
+ /** Renders `items` as a markdown bullet list, one `- item` per line. */
986
+ declare function list(items: readonly string[]): string;
987
+
988
+ /** Loads a step's prompt from a local text file, resolved relative to the workflow/project `cwd` at dispatch time. */
989
+ declare function promptTemplate(path: string): PromptTemplateSource;
990
+
991
+ type JsonSchemaObject = JSONSchemaType<PlainObject> | Record<string, unknown>;
992
+ declare function normalizeShape<T extends PlainObject>(shapeInput: ShapeInput<T>): Schema<T>;
993
+ declare function shape<T extends PlainObject>(shapeObject: ShapeObject): Schema<T>;
994
+ declare function jsonSchema<T extends PlainObject>(schema: JsonSchemaObject): Schema<T>;
995
+
996
+ /**
997
+ * Ambient handle onto the active run's identity and durable key-value store.
998
+ * Backed by AsyncLocalStorage, set once per run by `runWorkflow`; step
999
+ * continuations import this directly rather than receiving it as an argument.
1000
+ */
1001
+ declare const state: {
1002
+ get<T = unknown>(key: string): Promise<T | undefined>;
1003
+ getPersisted<T = unknown>(key: string): Promise<T | undefined>;
1004
+ set(key: string, value: unknown): Promise<void>;
1005
+ readonly id: string;
1006
+ readonly name: string;
1007
+ readonly path: string;
1008
+ readonly cwd: string | undefined;
1009
+ readonly executionCwd: string | undefined;
1010
+ readonly isReplayingCompletedStep: boolean;
1011
+ readonly projectCwd: string | undefined;
1012
+ };
1013
+
1014
+ /**
1015
+ * The only step-authoring primitive. `.prompt(...)` is optional; when present,
1016
+ * the step dispatches to an agent and `.do(...)` receives its structured
1017
+ * output. When absent, nothing is dispatched -- `.do(...)` receives the
1018
+ * step's input directly and is responsible for the work and the continuation
1019
+ * in one function. Either way, `.do(...)` produces a reusable `StepFactory`
1020
+ * -- call it with a live input value (`stepA(input)`) to get a `StepNode`.
1021
+ * When the inferred input type has no required keys, the argument is
1022
+ * optional (`stepA()`) and defaults to `{}`.
1023
+ */
1024
+ interface StepBuilder {
1025
+ display(content?: StepDisplayContent<PlainObject, PlainObject>, options?: PlainObject): StepBuilder;
1026
+ wait(wait: WaitInput<PlainObject, PlainObject>): StepBuilder;
1027
+ wait<TWaitOutput extends PlainObject = PlainObject>(wait: CheckWaitCallback<PlainObject, PlainObject, TWaitOutput>, options: WaitOptions<TWaitOutput>): StepBuilder;
1028
+ prompt<TInput extends PlainObject = PlainObject, TOutput extends PlainObject = PlainObject>(source: AgentPrompt<TInput> | PromptTemplateSource, options?: PromptOptions<TOutput>): PromptedStepBuilder<TInput, TOutput>;
1029
+ do<TInput extends PlainObject = PlainObject>(onOutput: StepContextContinuation<TInput, TInput>): FluentStepFactory<TInput, TInput>;
1030
+ do<TInput extends PlainObject = PlainObject>(onOutput: StepContinuation<TInput, TInput>): FluentStepFactory<TInput, TInput>;
1031
+ }
1032
+ interface PromptedStepBuilder<TInput extends PlainObject = PlainObject, TOutput extends PlainObject = PlainObject> {
1033
+ display(content?: StepDisplayContent<TInput, TOutput>, options?: PlainObject): PromptedStepBuilder<TInput, TOutput>;
1034
+ wait(wait: WaitInput<TInput, TOutput>): PromptedStepBuilder<TInput, TOutput>;
1035
+ wait<TWaitOutput extends PlainObject = PlainObject>(wait: CheckWaitCallback<TInput, TOutput, TWaitOutput>, options: WaitOptions<TWaitOutput>): PromptedStepBuilder<TInput, TOutput>;
1036
+ do(onOutput: StepContextContinuation<TInput, TOutput>): FluentStepFactory<TInput, TOutput>;
1037
+ do(onOutput: StepContinuation<TInput, TOutput>): FluentStepFactory<TInput, TOutput>;
1038
+ }
1039
+ type FluentStepFactory<TInput extends PlainObject = PlainObject, TOutput extends PlainObject = PlainObject> = StepFactory<TInput, TOutput> & {
1040
+ catch(onError: StepErrorContinuation): FluentStepFactory<TInput, TOutput>;
1041
+ display(content?: StepDisplayContent<TInput, TOutput>, options?: PlainObject): FluentStepFactory<TInput, TOutput>;
1042
+ wait(wait: WaitInput<TInput, TOutput>): FluentStepFactory<TInput, TOutput>;
1043
+ wait<TWaitOutput extends PlainObject = PlainObject>(wait: CheckWaitCallback<TInput, TOutput, TWaitOutput>, options: WaitOptions<TWaitOutput>): FluentStepFactory<TInput, TOutput>;
1044
+ };
1045
+ declare function step(config: StepConfig): StepBuilder;
1046
+ declare function done<TOutput extends PlainObject = PlainObject>(output?: TOutput, options?: TerminalMessageOptions): DoneNode<TOutput>;
1047
+ declare function fail(failure: Failure, options?: TerminalMessageOptions): FailNode;
1048
+ declare function absoluteDone<TOutput extends PlainObject = PlainObject>(output?: TOutput, options?: TerminalMessageOptions): AbsoluteDoneNode<TOutput>;
1049
+ declare function absoluteFail(failure: Failure, options?: TerminalMessageOptions): AbsoluteFailNode;
1050
+ declare function parallel<TOutput extends PlainObject = PlainObject>(nodes: ContinuationArray, options?: ParallelOptions): ParallelNode<TOutput>;
1051
+ declare function isStepNode(value: unknown): value is StepNode;
1052
+ declare function isDoneNode(value: unknown): value is DoneNode;
1053
+ declare function isFailNode(value: unknown): value is FailNode;
1054
+ declare function isWorkflowInvocationNode(value: unknown): value is WorkflowInvocationNode;
1055
+ declare function isParallelNode(value: unknown): value is ParallelNode;
1056
+ declare function isAbsoluteDoneNode(value: unknown): value is AbsoluteDoneNode;
1057
+ declare function isAbsoluteFailNode(value: unknown): value is AbsoluteFailNode;
1058
+
1059
+ declare function subPrompt<TInput extends PlainObject = PlainObject, TOutput extends PlainObject = PlainObject>(source: AgentPrompt<TInput> | PromptTemplateSource, options: SubPromptOptions<TOutput>): SubPromptFactory<TInput, TOutput>;
1060
+
1061
+ declare function defineWorkflow<TInput extends PlainObject = PlainObject, TOutput extends PlainObject = PlainObject>(options: WorkflowBuilderOptions<TInput, TOutput>): DefinedWorkflow<TInput, TOutput>;
1062
+
1063
+ type DeepReadonly<T> = T extends (...args: never[]) => unknown ? T : T extends readonly (infer U)[] ? readonly DeepReadonly<U>[] : T extends object ? {
1064
+ readonly [K in keyof T]: DeepReadonly<T[K]>;
1065
+ } : T;
1066
+ interface WorkflowInputApi<TInput extends PlainObject = PlainObject> {
1067
+ input(): Promise<DeepReadonly<TInput>>;
1068
+ input<TOverrideInput extends PlainObject>(): Promise<DeepReadonly<TOverrideInput>>;
1069
+ inputValue<TKey extends keyof TInput & string>(key: TKey): Promise<DeepReadonly<TInput[TKey]>>;
1070
+ inputValue<TOverrideInput extends PlainObject, TKey extends keyof TOverrideInput & string>(key: TKey): Promise<DeepReadonly<TOverrideInput[TKey]>>;
1071
+ withInput<TTypedInput extends PlainObject>(): WorkflowInputApi<TTypedInput>;
1072
+ }
1073
+ declare const workflow: WorkflowInputApi;
1074
+
1075
+ type DeprecationTargetPackage = "@trailstep/core" | "@trailstep/authoring";
1076
+ interface DeprecationEntry {
1077
+ /** Which published package exports this symbol. A symbol re-exported by both (like `step`,
1078
+ * which authoring re-exports from core) needs one entry per package it's importable from, since a
1079
+ * workflow author might import it from either. */
1080
+ readonly package: DeprecationTargetPackage;
1081
+ /** The exact named export identifier, e.g. "step". Matched literally against import statement
1082
+ * text by the scanner. */
1083
+ readonly symbol: string;
1084
+ /** Semver version at/after which this symbol is considered deprecated (still works, warns). */
1085
+ readonly deprecatedSince: string;
1086
+ /** Semver version at/after which this symbol is actually removed (no longer works). Omit if the
1087
+ * symbol is deprecated but has no planned removal. */
1088
+ readonly removedIn?: string;
1089
+ /** Human-readable explanation, shown verbatim in doctor/update output. */
1090
+ readonly message: string;
1091
+ /** Optional suggested replacement API, shown as "Suggested replacement: <this>." */
1092
+ readonly replacement?: string;
1093
+ }
1094
+ type DeprecationManifest = readonly DeprecationEntry[];
1095
+ interface DeprecationStatus extends DeprecationEntry {
1096
+ readonly severity: "warning" | "blocking";
1097
+ }
1098
+
1099
+ declare const deprecationManifest: DeprecationManifest;
1100
+ interface FindDeprecationsAsOfQuery {
1101
+ readonly package: DeprecationTargetPackage;
1102
+ readonly version: string;
1103
+ }
1104
+ /**
1105
+ * Returns every manifest entry for query.package whose deprecatedSince is at or before
1106
+ * query.version, tagged with a severity. Calling this once with version set to a target
1107
+ * version naturally captures every entry between the installed version and the target, no matter
1108
+ * how many majors are being skipped in one update.
1109
+ */
1110
+ declare function findDeprecationsAsOf(manifest: DeprecationManifest, query: FindDeprecationsAsOfQuery): readonly DeprecationStatus[];
591
1111
 
592
1112
  type RunState = Record<string, unknown>;
593
1113
  declare function defaultRunsRoot(cwd: string): string;
594
1114
  declare function readRunEvents(runDir: string): Promise<Event[]>;
595
1115
  declare function readRunState(runDir: string): Promise<RunState>;
596
1116
  declare function writeRunState(runDir: string, state: RunState): Promise<void>;
1117
+ declare function readGlobalState(runDir: string): Promise<RunState>;
1118
+ declare function writeGlobalState(runDir: string, state: RunState): Promise<void>;
597
1119
 
598
1120
  interface LatestUnresolvedFailure {
599
1121
  readonly event: Event;
@@ -607,7 +1129,34 @@ declare function selectLatestUnresolvedFailure(events: readonly Event[]): Latest
607
1129
 
608
1130
  declare function runWorkflow<TInput extends PlainObject, TOutput extends PlainObject>(options: RunWorkflowOptions<TInput, TOutput>): Promise<Result<TOutput>>;
609
1131
 
610
- type RunSummaryStatus = "active" | "completed" | "failed" | "unknown";
1132
+ interface TrackSummary {
1133
+ readonly runId: string;
1134
+ readonly status: string;
1135
+ readonly workers?: number;
1136
+ readonly failurePolicy?: string;
1137
+ readonly rootBranchId?: string;
1138
+ readonly terminalBranchId?: string;
1139
+ readonly terminalKind?: string;
1140
+ readonly terminalOutput?: unknown;
1141
+ readonly failure?: unknown;
1142
+ readonly splitOccurred?: boolean;
1143
+ readonly branches: readonly BranchSummary[];
1144
+ }
1145
+ interface BranchSummary {
1146
+ readonly branchId: string;
1147
+ readonly requestedBranchId?: string;
1148
+ readonly parentBranchId?: string;
1149
+ readonly status?: string;
1150
+ readonly workflowId?: string;
1151
+ readonly latestStepIndex?: number;
1152
+ readonly latestStepId?: string;
1153
+ readonly latestMessage?: string;
1154
+ readonly wait?: unknown;
1155
+ readonly failure?: unknown;
1156
+ readonly output?: unknown;
1157
+ }
1158
+
1159
+ type RunSummaryStatus = "active" | "completed" | "failed" | "cancelled" | "archived" | "unknown";
611
1160
  interface RunSummary {
612
1161
  readonly runId: string;
613
1162
  readonly runDir: string;
@@ -615,6 +1164,8 @@ interface RunSummary {
615
1164
  readonly workflowId?: string;
616
1165
  readonly lastTimestamp?: string;
617
1166
  readonly latestFailure?: LatestUnresolvedFailure;
1167
+ readonly track?: TrackSummary;
1168
+ readonly trackWarning?: string;
618
1169
  readonly warning?: string;
619
1170
  }
620
1171
  declare function listRunSummaries(options: {
@@ -626,4 +1177,73 @@ declare function selectRecentFailedRunSummaries(summaries: readonly RunSummary[]
626
1177
  }): RunSummary[];
627
1178
  declare function newestFirst(left: RunSummary, right: RunSummary): number;
628
1179
 
629
- export { type AgentAdapter, type AgentAdapterObject, type AgentAdapterRequest, type AgentAdapterSelection, type AgentMessage, type AgentModelTarget, type AgentPrompt, type AgentTool, type ContinuationResult, type ContinuationStepConfig, type DeprecationEntry, type DeprecationManifest, type DeprecationStatus, type DeprecationTargetPackage, Document, type DoneNode, type Event, type FailNode, type Failure, type FindDeprecationsAsOfQuery, type InteractiveProcessRequest, type InteractiveProcessResult, type InteractiveProcessRunner, type JsonSchemaObject, type LatestUnresolvedFailure, type PlainObject, type PromptOptions, type PromptTemplateSource, type ProviderAdapter, type ProviderInteractiveRequest, type ProviderRegistryKey, type ProviderWorkingProcessRequest, type ProviderWorkingProcessResult, type ProviderWorkingRequest, type ProviderWorkingRunner, type ResolveAgentTargetsOptions, type ResolveRetryPolicyOptions, type ResolveTimeoutPolicyOptions, type Result, type RetryPolicy, type RetryPolicyInput, type RunSummary, type RunSummaryStatus, type RunWorkflowOptions, type Schema, type ShapeInput, type ShapeObject, type ShapePrimitive, type StepConfig, type StepContinuation, type StepErrorContinuation, type StepFactory, type StepNode, type SubPromptFactory, type SubPromptOptions, type TimeoutPolicy, type TimeoutPolicyInput, type TrailStepAgentMappings, type TrailStepAgentTarget, type TrailStepConfig, type TrailStepCustomProviderConfig, TrailStepFailureError, type TrailStepSettings, type TrailStepWorkflowConfig, type Workflow, type WorkflowAgentRole, type WorkflowAgentSize, type WorkflowAgentThinking, type WorkingAgentProcessRequest, type WorkingAgentProcessResult, type WorkingAgentProcessRunner, defaultRunsRoot, deprecationManifest, document, done, fail, findDeprecationsAsOf, isDoneNode, isFailNode, isStepNode, jsonSchema, list, listRunSummaries, loadFragments, newestFirst, normalizeShape, parseTrailStepConfig, promptSections, promptTemplate, providerRegistry, readRunEvents, readRunState, resolveAgentTargets, resolveRetryPolicy, resolveTimeoutPolicy, runWorkflow, section, selectLatestUnresolvedFailure, selectRecentFailedRunSummaries, shape, state, step, subPrompt, validateRetryPolicy, validateTimeoutPolicy, writeRunState };
1180
+ interface StorageLifecyclePolicy {
1181
+ readonly enabled?: boolean;
1182
+ readonly archiveAfterDays?: number | false;
1183
+ readonly deleteAfterDays?: number | false;
1184
+ readonly workflows?: Readonly<Record<string, {
1185
+ readonly archiveAfterDays?: number | false;
1186
+ readonly deleteAfterDays?: number | false;
1187
+ }>>;
1188
+ }
1189
+ interface StorageLifecycleAction {
1190
+ readonly action: "archive" | "delete-hot" | "delete-archive";
1191
+ readonly runId: string;
1192
+ readonly reason: string;
1193
+ readonly path: string;
1194
+ }
1195
+ interface StorageLifecycleStatus {
1196
+ readonly runsRoot: string;
1197
+ readonly enabled: boolean;
1198
+ readonly hotRuns: number;
1199
+ readonly archivedRuns: number;
1200
+ readonly pinnedRuns: readonly string[];
1201
+ }
1202
+ declare function storageArchiveDir(runsRoot: string): string;
1203
+ declare function storagePinPath(runDir: string): string;
1204
+ declare function readStorageLifecycleStatus(options: {
1205
+ readonly cwd: string;
1206
+ readonly runsRoot?: string;
1207
+ readonly policy?: StorageLifecyclePolicy;
1208
+ }): Promise<StorageLifecycleStatus>;
1209
+ declare function planStorageLifecycle(options: {
1210
+ readonly cwd: string;
1211
+ readonly runsRoot?: string;
1212
+ readonly policy?: StorageLifecyclePolicy;
1213
+ readonly now?: Date;
1214
+ }): Promise<StorageLifecycleAction[]>;
1215
+ declare function applyStorageLifecycle(options: {
1216
+ readonly cwd: string;
1217
+ readonly runsRoot?: string;
1218
+ readonly policy?: StorageLifecyclePolicy;
1219
+ readonly now?: Date;
1220
+ readonly dryRun?: boolean;
1221
+ }): Promise<StorageLifecycleAction[]>;
1222
+ declare function archiveRun(options: {
1223
+ readonly runsRoot: string;
1224
+ readonly runId: string;
1225
+ readonly now?: Date;
1226
+ }): Promise<void>;
1227
+ declare function restoreArchivedRun(options: {
1228
+ readonly runsRoot: string;
1229
+ readonly runId: string;
1230
+ }): Promise<void>;
1231
+ declare function pinRun(options: {
1232
+ readonly runsRoot: string;
1233
+ readonly runId: string;
1234
+ }): Promise<void>;
1235
+ declare function unpinRun(options: {
1236
+ readonly runsRoot: string;
1237
+ readonly runId: string;
1238
+ }): Promise<void>;
1239
+ declare function deleteRun(options: {
1240
+ readonly runsRoot: string;
1241
+ readonly runId: string;
1242
+ }): Promise<void>;
1243
+ declare function deleteArchivedRun(options: {
1244
+ readonly runsRoot: string;
1245
+ readonly runId: string;
1246
+ }): Promise<void>;
1247
+ declare function parseStorageLifecycleDurationDays(value: string): number | undefined;
1248
+
1249
+ export { type AbsoluteDoneNode, type AbsoluteFailNode, type AgentAdapter, type AgentAdapterObject, type AgentAdapterRequest, type AgentAdapterSelection, type AgentMessage, type AgentModelTarget, type AgentPrompt, type AgentTool, type BranchSummary, CANCELLATION_MARKER_FILE, type CancellationMarker, type CheckWaitCallback, type CheckWaitContext, type CheckWaitHelpers, type ContinuationArray, type ContinuationResult, type ContinuationStepConfig, type DeepReadonly, type DefinedWorkflow, type DeprecationEntry, type DeprecationManifest, type DeprecationStatus, type DeprecationTargetPackage, type DisplayPhase, type DoPhase, Document, type DoneNode, type Event, type FailNode, type Failure, type FindDeprecationsAsOfQuery, type InteractiveProcessRequest, type InteractiveProcessResult, type InteractiveProcessRunner, type JsonSchemaObject, type LatestUnresolvedFailure, type LaunchInteractiveAgentTargetOptions, type LaunchInteractiveAgentTargetResult, type ManagedSessionPromptInjectionMode, type NotifyApi, type NotifyArtifact, type ParallelNode, type PlainObject, type PostContinuation, type PromptOptions, type PromptPhase, type PromptTemplateSource, type ProviderAdapter, type ProviderInteractiveInvocationSpec, type ProviderInteractiveRequest, type ProviderManagedSessionPromptDelivery, type ProviderModelDiscoveryOutputParser, type ProviderModelDiscoverySpec, type ProviderModelOverrideSupport, type ProviderOutputParsingMetadata, type ProviderOutputSpec, type ProviderOutputStyle, type ProviderPromptFileReferenceStyle, type ProviderPromptInputSpec, type ProviderSpec, type ProviderThinkingOverrideSupport, type ProviderWorkingInvocationSpec, type ProviderWorkingProcessRequest, type ProviderWorkingProcessResult, type ProviderWorkingRepairInvocationSpec, type ProviderWorkingRequest, type ProviderWorkingRunner, type ResolveAgentTargetsOptions, type ResolveRetryPolicyOptions, type ResolveTimeoutPolicyOptions, type Result, type RetryPolicy, type RetryPolicyInput, type RunSummary, type RunSummaryStatus, type RunWorkflowOptions, type RunWorkflowRetryOptions, type RunWorkflowTrackRetryOptions, type RunnableContinuationNode, type Schema, type ShapeInput, type ShapeObject, type ShapePrimitive, type StepConfig, type StepContextContinuation, type StepContinuation, type StepContinuationOutput, type StepCwdCallback, type StepCwdContext, type StepCwdInput, type StepDisplayCallback, type StepDisplayContent, type StepDisplayContext, type StepDisplayLevel, type StepDisplayObject, type StepDisplayValue, type StepErrorContinuation, type StepFactory, type StepInvocationOptions, type StepNode, type StepPhase, type StepWaitContext, type StorageLifecycleAction, type StorageLifecyclePolicy, type StorageLifecycleStatus, type SubPromptFactory, type SubPromptOptions, type TerminalMessageOptions, type TimeoutPolicy, type TimeoutPolicyInput, type TrackSummary, type TrailStepAgentMappings, type TrailStepAgentTarget, type TrailStepConfig, type TrailStepCustomProviderConfig, type TrailStepCustomProviderModelOverrideSupport, type TrailStepCustomProviderThinkingOverrideSupport, TrailStepFailureError, type TrailStepProviderEnvironmentManifest, type TrailStepProviderInteractiveManifest, type TrailStepProviderManifest, type TrailStepProviderModelDiscoveryManifest, type TrailStepProviderModelManifest, type TrailStepProviderOutputManifest, type TrailStepProviderOutputParsingManifest, type TrailStepProviderOutputStyle, type TrailStepProviderPackageDefinition, type TrailStepProviderPromptFileReferenceStyle, type TrailStepProviderPromptManifest, type TrailStepProviderRegistration, type TrailStepProviderSource, type TrailStepProviderThinkingManifest, type TrailStepProviderWorkingManifest, type TrailStepSettings, type TrailStepWorkflowConfig, type WaitCallback, type WaitCheckResult, type WaitDefinition, type WaitDoneResult, type WaitInput, type WaitOptions, type WaitPendingInput, type WaitPendingResult, type WaitPhase, type WaitResultDetails, type Workflow, type WorkflowAgentRole, type WorkflowAgentSize, type WorkflowAgentThinking, type WorkflowBuilderOptions, type WorkflowInputApi, type WorkflowInvocationNode, type WorkflowInvocationOptions, type WorkflowSkillOptions, type WorkingAgentProcessRequest, type WorkingAgentProcessResult, type WorkingAgentProcessRunner, absoluteDone, absoluteFail, applyStorageLifecycle, archiveRun, cancellationMarkerPath, defaultRunsRoot, defineWorkflow, deleteArchivedRun, deleteRun, deprecationManifest, document, done, fail, findDeprecationsAsOf, globalState, isAbsoluteDoneNode, isAbsoluteFailNode, isDoneNode, isFailNode, isParallelNode, isStepNode, isWorkflowInvocationNode, jsonSchema, launchInteractiveAgentTarget, list, listRunSummaries, loadFragments, newestFirst, normalizeShape, notify, parallel, parseStorageLifecycleDurationDays, parseTrailStepConfig, parseTrailStepProviderManifest, pinRun, planStorageLifecycle, promptSections, promptTemplate, readCancellationMarker, readGlobalState, readRunEvents, readRunState, readStorageLifecycleStatus, resolveAgentTargets, resolveRetryPolicy, resolveTimeoutPolicy, restoreArchivedRun, runWorkflow, section, selectLatestUnresolvedFailure, selectRecentFailedRunSummaries, shape, state, step, storageArchiveDir, storagePinPath, subPrompt, unpinRun, validateRetryPolicy, validateTimeoutPolicy, workflow, writeCancellationMarker, writeGlobalState, writeRunState };