@bastani/atomic 0.8.23 → 0.8.24-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/builtin/intercom/CHANGELOG.md +7 -0
  3. package/dist/builtin/intercom/package.json +1 -1
  4. package/dist/builtin/mcp/CHANGELOG.md +7 -0
  5. package/dist/builtin/mcp/package.json +1 -1
  6. package/dist/builtin/subagents/CHANGELOG.md +22 -0
  7. package/dist/builtin/subagents/README.md +16 -0
  8. package/dist/builtin/subagents/agents/code-simplifier.md +2 -3
  9. package/dist/builtin/subagents/agents/codebase-analyzer.md +2 -3
  10. package/dist/builtin/subagents/agents/codebase-locator.md +2 -3
  11. package/dist/builtin/subagents/agents/codebase-online-researcher.md +2 -3
  12. package/dist/builtin/subagents/agents/codebase-pattern-finder.md +2 -3
  13. package/dist/builtin/subagents/agents/codebase-research-analyzer.md +2 -3
  14. package/dist/builtin/subagents/agents/codebase-research-locator.md +2 -3
  15. package/dist/builtin/subagents/agents/debugger.md +2 -3
  16. package/dist/builtin/subagents/package.json +1 -1
  17. package/dist/builtin/subagents/skills/subagent/SKILL.md +6 -0
  18. package/dist/builtin/subagents/src/agents/agent-serializer.ts +3 -0
  19. package/dist/builtin/subagents/src/agents/agents.ts +20 -1
  20. package/dist/builtin/subagents/src/runs/background/async-execution.ts +1 -1
  21. package/dist/builtin/subagents/src/runs/background/subagent-runner.ts +3 -1
  22. package/dist/builtin/subagents/src/runs/foreground/chain-clarify.ts +7 -7
  23. package/dist/builtin/subagents/src/runs/foreground/execution.ts +5 -1
  24. package/dist/builtin/subagents/src/runs/shared/model-fallback.ts +9 -10
  25. package/dist/builtin/subagents/src/shared/types.ts +1 -0
  26. package/dist/builtin/web-access/CHANGELOG.md +7 -0
  27. package/dist/builtin/web-access/package.json +1 -1
  28. package/dist/builtin/workflows/CHANGELOG.md +25 -0
  29. package/dist/builtin/workflows/README.md +38 -41
  30. package/dist/builtin/workflows/builtin/deep-research-codebase.d.ts +35 -0
  31. package/dist/builtin/workflows/builtin/deep-research-codebase.ts +11 -14
  32. package/dist/builtin/workflows/builtin/goal.d.ts +46 -0
  33. package/dist/builtin/workflows/builtin/goal.ts +10 -12
  34. package/dist/builtin/workflows/builtin/index.d.ts +136 -0
  35. package/dist/builtin/workflows/builtin/open-claude-design.d.ts +44 -0
  36. package/dist/builtin/workflows/builtin/open-claude-design.ts +19 -20
  37. package/dist/builtin/workflows/builtin/ralph.d.ts +36 -0
  38. package/dist/builtin/workflows/builtin/ralph.ts +20 -24
  39. package/dist/builtin/workflows/package.json +15 -5
  40. package/dist/builtin/workflows/src/authoring.ts +410 -0
  41. package/dist/builtin/workflows/src/extension/workflow-module-loader.ts +6 -12
  42. package/dist/builtin/workflows/src/extension/workflow-schema.ts +3 -2
  43. package/dist/builtin/workflows/src/index.ts +0 -5
  44. package/dist/builtin/workflows/src/runs/foreground/executor.ts +23 -9
  45. package/dist/builtin/workflows/src/runs/foreground/stage-runner.ts +33 -5
  46. package/dist/builtin/workflows/src/runs/shared/model-fallback.ts +61 -10
  47. package/dist/builtin/workflows/src/sdk-surface.ts +12 -2
  48. package/dist/builtin/workflows/src/shared/authoring-contract.ts +660 -0
  49. package/dist/builtin/workflows/src/shared/render-inputs-schema.ts +1 -1
  50. package/dist/builtin/workflows/src/shared/types.ts +65 -350
  51. package/dist/builtin/workflows/src/workflows/define-workflow.ts +59 -44
  52. package/dist/core/atomic-guide-command.d.ts.map +1 -1
  53. package/dist/core/atomic-guide-command.js +1 -1
  54. package/dist/core/atomic-guide-command.js.map +1 -1
  55. package/dist/modes/interactive/components/chat-message-renderer.d.ts +1 -0
  56. package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
  57. package/dist/modes/interactive/components/chat-message-renderer.js +13 -1
  58. package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
  59. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  60. package/dist/modes/interactive/interactive-mode.js +1 -1
  61. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  62. package/dist/utils/changelog.d.ts.map +1 -1
  63. package/dist/utils/changelog.js +23 -16
  64. package/dist/utils/changelog.js.map +1 -1
  65. package/docs/extensions.md +2 -2
  66. package/docs/packages.md +8 -4
  67. package/docs/subagents.md +30 -0
  68. package/docs/workflows.md +39 -21
  69. package/package.json +1 -1
  70. package/dist/builtin/workflows/src/runs/shared/workflow-runner.ts +0 -335
@@ -10,75 +10,43 @@ import type {
10
10
  CreateAgentSessionOptions,
11
11
  ModelCycleResult,
12
12
  PromptOptions,
13
+ SessionManager,
14
+ SettingsManager,
15
+ ToolDefinition,
13
16
  } from "@bastani/atomic";
14
17
  import type { TSchema } from "typebox";
18
+ import type * as AuthoringContract from "./authoring-contract.js";
15
19
 
16
20
  export type { TSchema };
17
21
 
18
22
  export type { AgentSessionEvent, CompactionResult, ModelCycleResult, PromptOptions };
19
23
 
20
24
  export type WorkflowModelValue = NonNullable<CreateAgentSessionOptions["model"]> | string;
25
+ export type WorkflowModelUsage = AuthoringContract.WorkflowModelUsage;
26
+ export type WorkflowModelAttempt = AuthoringContract.WorkflowModelAttempt;
27
+ export type WorkflowModelFallbackFields = AuthoringContract.WorkflowModelFallbackFields;
28
+ export type WorkflowThinkingLevel = AuthoringContract.WorkflowThinkingLevel;
21
29
 
22
- export interface WorkflowModelUsage extends WorkflowSerializableObject {
23
- readonly input?: number;
24
- readonly output?: number;
25
- readonly cacheRead?: number;
26
- readonly cacheWrite?: number;
27
- readonly cost?: number;
28
- readonly turns?: number;
29
- }
30
-
31
- export interface WorkflowModelAttempt extends WorkflowSerializableObject {
32
- readonly model: string;
33
- readonly success: boolean;
34
- readonly error?: string;
35
- readonly usage?: WorkflowModelUsage;
36
- }
37
-
38
- export interface WorkflowModelFallbackFields {
39
- /** Ordered model IDs to try after `model` fails for a retryable provider/model reason. */
40
- readonly fallbackModels?: readonly string[];
41
- }
42
-
43
- export interface WorkflowModelInfo {
44
- readonly provider: string;
45
- readonly id: string;
46
- readonly fullId: string;
30
+ export interface WorkflowModelInfo extends Omit<AuthoringContract.WorkflowModelInfo, "model"> {
47
31
  readonly model?: NonNullable<CreateAgentSessionOptions["model"]>;
48
32
  }
49
33
 
50
- export interface WorkflowModelCatalogPort {
34
+ export interface WorkflowModelCatalogPort extends Omit<AuthoringContract.WorkflowModelCatalogPort, "listModels" | "currentModel"> {
51
35
  listModels(): Promise<readonly WorkflowModelInfo[]>;
52
36
  /** Current user-selected model used as the implicit final fallback. */
53
37
  readonly currentModel?: WorkflowModelValue;
54
- readonly preferredProvider?: string;
55
- /** Optional warning sink for degraded catalog validation/fallback behavior. */
56
- recordWarning?: (warning: string) => void;
57
38
  }
58
39
 
59
40
  // ---------------------------------------------------------------------------
60
41
  // Workflow serializable values
61
42
  // ---------------------------------------------------------------------------
62
43
 
63
- export type WorkflowSerializablePrimitive = string | number | boolean | null;
64
-
65
- export interface WorkflowSerializableObject {
66
- /**
67
- * Optional properties use `undefined` at the type level for ergonomic
68
- * intellisense, but workflow runtime validation rejects actual `undefined`
69
- * values in returned/input objects. Omit optional keys instead.
70
- */
71
- readonly [key: string]: WorkflowSerializableValue | undefined;
72
- }
73
-
74
- export type WorkflowSerializableValue =
75
- | WorkflowSerializablePrimitive
76
- | readonly WorkflowSerializableValue[]
77
- | WorkflowSerializableObject;
78
-
79
- export type WorkflowInputValues = WorkflowSerializableObject;
80
- export type WorkflowOutputValues = WorkflowSerializableObject;
81
- export type WorkflowRunOutput = WorkflowOutputValues;
44
+ export type WorkflowSerializablePrimitive = AuthoringContract.WorkflowSerializablePrimitive;
45
+ export type WorkflowSerializableObject = AuthoringContract.WorkflowSerializableObject;
46
+ export type WorkflowSerializableValue = AuthoringContract.WorkflowSerializableValue;
47
+ export type WorkflowInputValues = AuthoringContract.WorkflowInputValues;
48
+ export type WorkflowOutputValues = AuthoringContract.WorkflowOutputValues;
49
+ export type WorkflowRunOutput = AuthoringContract.WorkflowRunOutput;
82
50
 
83
51
  // ---------------------------------------------------------------------------
84
52
  // Workflow input / output schemas
@@ -90,26 +58,20 @@ export type WorkflowRunOutput = WorkflowOutputValues;
90
58
  * the builder threads the precise `Static<>` types and the runtime validates
91
59
  * via TypeBox `Value`.
92
60
  */
93
- export type WorkflowInputSchemaMap = Readonly<Record<string, TSchema>>;
94
- export type WorkflowOutputSchemaMap = Readonly<Record<string, TSchema>>;
61
+ export type WorkflowInputSchemaMap = AuthoringContract.WorkflowInputSchemaMap;
62
+ export type WorkflowOutputSchemaMap = AuthoringContract.WorkflowOutputSchemaMap;
95
63
 
96
64
  /** A single declared input schema is just a TypeBox schema. */
97
- export type WorkflowInputSchema = TSchema;
65
+ export type WorkflowInputSchema = AuthoringContract.WorkflowInputSchema;
98
66
  /** A single declared output schema is just a TypeBox schema. */
99
- export type WorkflowOutputSchema = TSchema;
67
+ export type WorkflowOutputSchema = AuthoringContract.WorkflowOutputSchema;
100
68
 
101
69
  // ---------------------------------------------------------------------------
102
70
  // Workflow execution policy
103
71
  // ---------------------------------------------------------------------------
104
72
 
105
- export type WorkflowExecutionMode = "interactive" | "non_interactive";
106
-
107
- export interface WorkflowExecutionPolicy {
108
- readonly mode: WorkflowExecutionMode;
109
- readonly allowHumanInput: boolean;
110
- readonly awaitTerminalRun: boolean;
111
- readonly allowInputPicker: boolean;
112
- }
73
+ export type WorkflowExecutionMode = AuthoringContract.WorkflowExecutionMode;
74
+ export type WorkflowExecutionPolicy = AuthoringContract.WorkflowExecutionPolicy;
113
75
 
114
76
  export const INTERACTIVE_WORKFLOW_POLICY: WorkflowExecutionPolicy = Object.freeze({
115
77
  mode: "interactive",
@@ -154,23 +116,14 @@ export interface WorkflowChildResult<TOutputs extends WorkflowOutputValues = Wor
154
116
  * Each primitive suspends the current stage until the user responds.
155
117
  * Mirrors pi ctx.ui.input / confirm / select / editor methods.
156
118
  */
157
- export interface WorkflowUIContext {
158
- /** Ask the user for a free-text value. */
159
- input(prompt: string): Promise<string>;
160
- /** Ask the user a yes/no question. */
161
- confirm(message: string): Promise<boolean>;
162
- /** Ask the user to pick from a fixed list of options. */
163
- select<T extends string>(message: string, options: readonly T[]): Promise<T>;
164
- /** Open a text editor; resolves with the user's final content. */
165
- editor(initial?: string): Promise<string>;
166
- }
119
+ export type WorkflowUIContext = AuthoringContract.WorkflowUIContext;
167
120
 
168
121
  /**
169
122
  * Adapter supplied by the pi runtime (or test harness) to back the HIL
170
123
  * primitives. Must implement the same surface as WorkflowUIContext so that
171
124
  * the executor can delegate directly.
172
125
  */
173
- export type WorkflowUIAdapter = WorkflowUIContext;
126
+ export type WorkflowUIAdapter = AuthoringContract.WorkflowUIAdapter;
174
127
 
175
128
  // ---------------------------------------------------------------------------
176
129
  // StageOptions — per-stage configuration + pi SDK session options
@@ -181,10 +134,10 @@ export type WorkflowUIAdapter = WorkflowUIContext;
181
134
  * When provided, the executor forwards these to the WorkflowMcpPort
182
135
  * before the stage starts and clears them after it settles.
183
136
  */
184
- export interface StageMcpOptions {
185
- /** Allow only these server IDs during this stage (all others implicitly denied). */
137
+ type Mutable<T> = { -readonly [K in keyof T]: T[K] };
138
+
139
+ export interface StageMcpOptions extends AuthoringContract.StageMcpOptions {
186
140
  allow?: string[];
187
- /** Deny these server IDs during this stage (applied after allow when both set). */
188
141
  deny?: string[];
189
142
  }
190
143
 
@@ -193,29 +146,17 @@ export interface StageMcpOptions {
193
146
  * All pi SDK createAgentSession options are forwarded to the stage session;
194
147
  * workflow-owned options such as `mcp` and `gitWorktreeDir` are stripped before SDK session creation.
195
148
  */
196
- export interface StageOptions extends Omit<CreateAgentSessionOptions, "model">, WorkflowModelFallbackFields {
149
+ export interface StageOptions
150
+ extends Omit<CreateAgentSessionOptions, "model" | keyof AuthoringContract.StageOptions>,
151
+ Omit<Mutable<AuthoringContract.StageOptions>, "sessionManager" | "settingsManager"> {
197
152
  /** Model id or pi SDK model object used as the primary stage model. */
198
153
  model?: WorkflowModelValue;
199
154
  /** Per-stage MCP server gating. No-op when no WorkflowMcpPort is configured. */
200
155
  mcp?: StageMcpOptions;
201
- /** Reusable Git worktree root. Defaults this stage cwd to the corresponding worktree cwd unless cwd is explicitly provided. */
202
- gitWorktreeDir?: string;
203
- /** Git ref used when creating gitWorktreeDir. Defaults to HEAD. */
204
- baseBranch?: string;
205
- /**
206
- * Override the session log directory for this stage.
207
- * Converted to a pi SessionManager before createAgentSession() is called.
208
- */
209
- sessionDir?: string;
210
- /**
211
- * Requested context mode for direct/task orchestration.
212
- * "fork" is recorded as workflow intent; the current pi SDK session is
213
- * created from forkFromSessionFile when the host supplies one, or fresh
214
- * unless a caller supplies a forked sessionManager.
215
- */
216
- context?: "fresh" | "fork";
217
- /** Parent session file used to materialize context:"fork". */
218
- forkFromSessionFile?: string;
156
+ customTools?: ToolDefinition[];
157
+ scopedModels?: CreateAgentSessionOptions["scopedModels"];
158
+ sessionManager?: SessionManager;
159
+ settingsManager?: SettingsManager;
219
160
  }
220
161
 
221
162
  // ---------------------------------------------------------------------------
@@ -280,27 +221,9 @@ export interface WorkflowPersistencePort {
280
221
  * `{previous}` handoffs as a typed SDK primitive instead of requiring authors
281
222
  * to manually concatenate prior output into every prompt.
282
223
  */
283
- export interface WorkflowTaskContext extends WorkflowSerializableObject {
284
- /** Optional display label used when rendering the context block. */
285
- readonly name?: string;
286
- /** Textual context made available to the next task. */
287
- readonly text: string;
288
- }
289
-
290
- export type WorkflowTaskContextInput = string | WorkflowTaskContext | WorkflowTaskResult;
291
-
292
- export interface WorkflowTaskResult extends WorkflowTaskContext {
293
- /** Stage/session metadata for UI and explicit downstream handoffs. */
294
- readonly stageName: string;
295
- readonly sessionId?: string;
296
- readonly sessionFile?: string;
297
- readonly artifacts?: WorkflowArtifact[];
298
- readonly model?: string;
299
- readonly fastMode?: boolean;
300
- readonly attemptedModels?: readonly string[];
301
- readonly modelAttempts?: readonly WorkflowModelAttempt[];
302
- readonly warnings?: readonly string[];
303
- }
224
+ export type WorkflowTaskContext = AuthoringContract.WorkflowTaskContext;
225
+ export type WorkflowTaskContextInput = AuthoringContract.WorkflowTaskContextInput;
226
+ export type WorkflowTaskResult = AuthoringContract.WorkflowTaskResult;
304
227
 
305
228
  /**
306
229
  * Higher-level task API: create a tracked stage, optionally inject prior task
@@ -308,209 +231,33 @@ export interface WorkflowTaskResult extends WorkflowTaskContext {
308
231
  *
309
232
  * `{previous}` means prior step output.
310
233
  */
311
- export interface WorkflowTaskOptions extends StageOptions, WorkflowTaskSessionFields {
312
- /** Prompt/task text. Supports `{previous}` placeholders. */
313
- prompt?: string;
314
- /** Alias for `prompt`, used by direct workflow orchestration helpers. */
315
- task?: string;
316
- /** Prior task output/context. If placeholders are absent, it is appended. */
317
- previous?: WorkflowTaskContextInput | readonly WorkflowTaskContextInput[];
318
- }
319
-
320
- export interface WorkflowTaskStep extends WorkflowTaskOptions {
321
- /** Stage/task name. */
322
- name: string;
323
- }
324
-
325
- export interface WorkflowSharedTaskDefaults extends StageOptions {
326
- /** Optional default output artifact path for steps that do not set one. */
327
- output?: string | false;
328
- /** Default output mode for steps that do not set one. */
329
- outputMode?: WorkflowOutputMode;
330
- /** Files the task should read before responding; relative paths resolve via chainDir for chains, otherwise cwd. */
331
- reads?: readonly string[] | false;
332
- /** Workflow-owned temporary isolation flag; not forwarded to createAgentSession(). */
333
- worktree?: boolean;
334
- /** Reusable Git worktree root. Defaults cwd to the corresponding worktree cwd unless cwd is explicitly provided. */
335
- gitWorktreeDir?: string;
336
- /** Git ref used when creating gitWorktreeDir. Defaults to HEAD. */
337
- baseBranch?: string;
338
- /** Default output truncation limits for steps that do not set one. */
339
- maxOutput?: WorkflowMaxOutput;
340
- /** Whether to include debug artifacts such as sessions and worktree diffs. */
341
- artifacts?: boolean;
342
- }
343
-
344
- export interface WorkflowChainOptions extends WorkflowSharedTaskDefaults {
345
- /** Shared/root task used for `{task}` in chain steps. */
346
- task?: string;
347
- /** Shared artifact directory for relative reads, outputs, and worktree diffs. */
348
- chainDir?: string;
349
- }
350
-
351
- export interface WorkflowParallelOptions extends WorkflowSharedTaskDefaults {
352
- /** Shared fallback task for parallel steps without their own task. */
353
- task?: string;
354
- /** Maximum number of parallel steps to schedule concurrently. */
355
- concurrency?: number;
356
- /** Stop scheduling additional steps after the first failure. Default: true. */
357
- failFast?: boolean;
358
- }
359
-
360
- export type WorkflowOutputMode = "inline" | "file-only";
361
-
362
- export interface WorkflowMaxOutput {
363
- /** Maximum UTF-8 bytes returned inline. Default: 204800. */
364
- readonly bytes?: number;
365
- /** Maximum lines returned inline. Default: 5000. */
366
- readonly lines?: number;
367
- }
368
-
369
- export interface StageOutputOptions {
370
- /** Optional output artifact path, or false to disable file output. */
371
- output?: string | false;
372
- /** Return saved output inline or as a concise saved-file reference. */
373
- outputMode?: WorkflowOutputMode;
374
- /** Accepted for parity with direct task options; stage creation options remain authoritative. */
375
- context?: "fresh" | "fork";
376
- /** Override working directory for output path resolution. */
377
- cwd?: string;
378
- /** Final output truncation limits. */
379
- maxOutput?: WorkflowMaxOutput;
380
- /** Whether to include debug artifacts. */
381
- artifacts?: boolean;
382
- /** Override session log directory. */
383
- sessionDir?: string;
384
- }
385
-
234
+ export interface WorkflowTaskOptions extends StageOptions, Omit<Mutable<AuthoringContract.WorkflowTaskOptions>, keyof AuthoringContract.StageOptions> {}
235
+ export interface WorkflowTaskStep extends WorkflowTaskOptions, Omit<Mutable<AuthoringContract.WorkflowTaskStep>, keyof AuthoringContract.WorkflowTaskOptions> {}
236
+ export interface WorkflowSharedTaskDefaults extends StageOptions, Omit<Mutable<AuthoringContract.WorkflowSharedTaskDefaults>, keyof AuthoringContract.StageOptions> {}
237
+ export interface WorkflowChainOptions extends WorkflowSharedTaskDefaults, Omit<Mutable<AuthoringContract.WorkflowChainOptions>, keyof AuthoringContract.WorkflowSharedTaskDefaults> {}
238
+ export interface WorkflowParallelOptions extends WorkflowSharedTaskDefaults, Omit<Mutable<AuthoringContract.WorkflowParallelOptions>, keyof AuthoringContract.WorkflowSharedTaskDefaults> {}
239
+
240
+ export type WorkflowOutputMode = AuthoringContract.WorkflowOutputMode;
241
+ export type WorkflowMaxOutput = AuthoringContract.WorkflowMaxOutput;
242
+ export type StageOutputOptions = Mutable<AuthoringContract.StageOutputOptions>;
386
243
  export type StagePromptOptions = PromptOptions & StageOutputOptions;
387
244
 
388
- export interface WorkflowArtifact extends WorkflowSerializableObject {
389
- readonly kind: "output" | "session" | "diff" | "patch";
390
- readonly path: string;
391
- readonly taskName?: string;
392
- readonly branch?: string;
393
- readonly diffStat?: string;
394
- readonly filesChanged?: number;
395
- readonly insertions?: number;
396
- readonly deletions?: number;
397
- }
398
-
399
- export interface WorkflowProgressSummary {
400
- readonly completed: number;
401
- readonly total: number;
402
- }
403
-
404
- export interface WorkflowControlEvent {
405
- readonly type: "notify" | "needs_attention" | "interrupted" | "resumed";
406
- readonly message: string;
407
- }
408
-
409
- export interface WorkflowIntercomSummary {
410
- readonly enabled: boolean;
411
- readonly delivery?: "off" | "notify" | "result" | "control-and-result";
412
- readonly parentSession?: string;
413
- }
414
-
415
- export type WorkflowDetailsMode =
416
- | "named"
417
- | "single"
418
- | "parallel"
419
- | "chain"
420
- | "inspection"
421
- | "control";
422
-
423
- export type WorkflowDetailsStatus =
424
- | "accepted"
425
- | "running"
426
- | "completed"
427
- | "failed"
428
- | "killed"
429
- | "noop";
430
-
431
- export type WorkflowAction =
432
- | "list"
433
- | "get"
434
- | "inputs"
435
- | "run"
436
- | "status"
437
- | "interrupt"
438
- | "resume";
439
-
440
- export interface WorkflowDetails {
441
- readonly mode: WorkflowDetailsMode;
442
- readonly action?: WorkflowAction;
443
- readonly runId?: string;
444
- readonly status: WorkflowDetailsStatus;
445
- readonly context?: "fresh" | "fork";
446
- readonly results?: WorkflowTaskResult[];
447
- readonly output?: WorkflowOutputValues;
448
- readonly progress?: WorkflowProgressSummary;
449
- readonly artifacts?: WorkflowArtifact[];
450
- readonly controlEvents?: WorkflowControlEvent[];
451
- readonly intercom?: WorkflowIntercomSummary;
452
- readonly warnings?: string[];
453
- readonly error?: string;
454
- }
455
-
456
- export interface WorkflowTaskSessionFields {
457
- /** Prompt text for direct single-task calls. */
458
- prompt?: string;
459
- /** Task text for parallel/chain calls. */
460
- task?: string;
461
- /** Optional output artifact path, or false to disable file output. */
462
- output?: string | false;
463
- outputMode?: WorkflowOutputMode;
464
- reads?: readonly string[] | false;
465
- /** Workflow-owned temporary isolation flag; not forwarded to createAgentSession(). */
466
- worktree?: boolean;
467
- /** Reusable Git worktree root. Defaults cwd to the corresponding worktree cwd unless cwd is explicitly provided. */
468
- gitWorktreeDir?: string;
469
- /** Git ref used when creating gitWorktreeDir. Defaults to HEAD. */
470
- baseBranch?: string;
471
- maxOutput?: WorkflowMaxOutput;
472
- /** Whether to include debug artifacts such as sessions and worktree diffs. */
473
- artifacts?: boolean;
474
- }
475
-
245
+ export type WorkflowArtifact = AuthoringContract.WorkflowArtifact;
246
+ export type WorkflowProgressSummary = AuthoringContract.WorkflowProgressSummary;
247
+ export type WorkflowControlEvent = AuthoringContract.WorkflowControlEvent;
248
+ export type WorkflowIntercomSummary = AuthoringContract.WorkflowIntercomSummary;
249
+ export type WorkflowDetailsMode = AuthoringContract.WorkflowDetailsMode;
250
+ export type WorkflowDetailsStatus = AuthoringContract.WorkflowDetailsStatus;
251
+ export type WorkflowAction = AuthoringContract.WorkflowAction;
252
+ export type WorkflowDetails = Mutable<AuthoringContract.WorkflowDetails>;
253
+ export type WorkflowTaskSessionFields = Mutable<AuthoringContract.WorkflowTaskSessionFields>;
476
254
  export type WorkflowTaskSessionOptions = StageOptions & WorkflowTaskSessionFields;
477
-
478
- export interface WorkflowDirectTaskItem extends WorkflowTaskOptions {
479
- /** Task/stage label passed to ctx.task(name, ...). */
480
- name: string;
481
- /** Repeat count for direct parallel expansion. */
482
- count?: number;
483
- }
484
-
485
- export interface WorkflowParallelChainStep {
255
+ export interface WorkflowDirectTaskItem extends WorkflowTaskOptions, Omit<Mutable<AuthoringContract.WorkflowDirectTaskItem>, keyof AuthoringContract.WorkflowTaskOptions> {}
256
+ export interface WorkflowParallelChainStep extends Omit<AuthoringContract.WorkflowParallelChainStep, "parallel"> {
486
257
  readonly parallel: readonly WorkflowDirectTaskItem[];
487
- readonly concurrency?: number;
488
- readonly failFast?: boolean;
489
- readonly worktree?: boolean;
490
- readonly gitWorktreeDir?: string;
491
- readonly baseBranch?: string;
492
258
  }
493
-
494
259
  export type WorkflowChainStep = WorkflowDirectTaskItem | WorkflowParallelChainStep;
495
-
496
- export interface WorkflowDirectOptions extends StageOptions {
497
- /** Shared/root task used for `{task}` in direct parallel or chain steps. */
498
- task?: string;
499
- /** Optional named chain identifier for status/artifact grouping. */
500
- chainName?: string;
501
- concurrency?: number;
502
- failFast?: boolean;
503
- /** Chain-only shared artifact directory for relative reads, outputs, and worktree diffs. */
504
- chainDir?: string;
505
- reads?: readonly string[] | false;
506
- output?: string | false;
507
- outputMode?: WorkflowOutputMode;
508
- worktree?: boolean;
509
- gitWorktreeDir?: string;
510
- baseBranch?: string;
511
- maxOutput?: WorkflowMaxOutput;
512
- artifacts?: boolean;
513
- }
260
+ export interface WorkflowDirectOptions extends StageOptions, Omit<Mutable<AuthoringContract.WorkflowDirectOptions>, keyof AuthoringContract.StageOptions> {}
514
261
 
515
262
  // ---------------------------------------------------------------------------
516
263
  // Stage context (provided to ctx.stage() calls)
@@ -617,24 +364,7 @@ export interface WorkflowRunContext<TInputs extends WorkflowInputValues = Workfl
617
364
  * statusFile writer. This type is the port — values flow through but are not
618
365
  * acted on until those tasks land.
619
366
  */
620
- export interface WorkflowRuntimeConfig {
621
- /** Maximum workflow recursion/nesting depth. Default: 4. */
622
- readonly maxDepth: number;
623
- /** Default stage concurrency limit. Default: 4. */
624
- readonly defaultConcurrency: number;
625
- /** Persist runs via pi.appendEntry. Default: true. */
626
- readonly persistRuns: boolean;
627
- /** Emit derived status file for CI polling. Default: false. */
628
- readonly statusFile: boolean;
629
- /**
630
- * Filesystem path for the emitted status file.
631
- * Only meaningful when statusFile is true.
632
- * Absence means the writer should choose a default path.
633
- */
634
- readonly statusFilePath?: string;
635
- /** Behaviour on session_start for in-flight runs. Default: "ask". */
636
- readonly resumeInFlight: "ask" | "auto" | "never";
637
- }
367
+ export type WorkflowRuntimeConfig = AuthoringContract.WorkflowRuntimeConfig;
638
368
 
639
369
  // ---------------------------------------------------------------------------
640
370
  // Workflow run function
@@ -643,35 +373,20 @@ export interface WorkflowRuntimeConfig {
643
373
  export type WorkflowRunFn<
644
374
  TInputs extends WorkflowInputValues = WorkflowInputValues,
645
375
  TOutputs extends WorkflowOutputValues = WorkflowOutputValues,
646
- > = (ctx: WorkflowRunContext<TInputs>) => Promise<TOutputs>;
376
+ > = (ctx: WorkflowRunContext<TInputs>) => ReturnType<AuthoringContract.WorkflowRunFn<TInputs, TOutputs>>;
647
377
 
648
378
  // ---------------------------------------------------------------------------
649
379
  // Compiled workflow definition
650
380
  // ---------------------------------------------------------------------------
651
381
 
652
- export interface WorkflowWorktreeInputBinding {
653
- readonly gitWorktreeDir: string;
654
- readonly baseBranch?: string;
655
- }
656
-
657
- export interface WorkflowInputBindings {
658
- readonly worktree?: WorkflowWorktreeInputBinding;
659
- }
382
+ export type WorkflowWorktreeInputBinding = AuthoringContract.WorkflowWorktreeInputBinding;
383
+ export type WorkflowInputBindings = AuthoringContract.WorkflowInputBindings;
384
+ declare const workflowDefinitionBrand: unique symbol;
385
+ export type WorkflowDefinitionBrand = { readonly [workflowDefinitionBrand]: true };
660
386
 
661
387
  export interface WorkflowDefinition<
662
388
  TInputs extends WorkflowInputValues = WorkflowInputValues,
663
389
  TOutputs extends WorkflowOutputValues = WorkflowOutputValues,
664
- > {
665
- /** Sentinel consumed by the registry loader to validate the export. */
666
- readonly __piWorkflow: true;
667
- readonly name: string;
668
- /** Normalised name (lowercase, hyphens) used as the registry key. */
669
- readonly normalizedName: string;
670
- readonly description: string;
671
- readonly inputs: WorkflowInputSchemaMap;
672
- /** Optional output contract used by parent workflows when selecting child outputs. */
673
- readonly outputs?: WorkflowOutputSchemaMap;
674
- /** Optional input-to-runtime defaults declared by the workflow builder. */
675
- readonly inputBindings?: WorkflowInputBindings;
390
+ > extends Omit<AuthoringContract.WorkflowDefinition<TInputs, TOutputs, TInputs, WorkflowDefinitionBrand>, "run" | "__runInputs">, WorkflowDefinitionBrand {
676
391
  readonly run: WorkflowRunFn<TInputs, TOutputs>;
677
392
  }