@bastani/atomic 0.8.28-alpha.2 → 0.8.28-alpha.3

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 (113) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/builtin/intercom/package.json +1 -1
  3. package/dist/builtin/mcp/package.json +1 -1
  4. package/dist/builtin/subagents/package.json +1 -1
  5. package/dist/builtin/web-access/package.json +1 -1
  6. package/dist/builtin/workflows/CHANGELOG.md +18 -0
  7. package/dist/builtin/workflows/README.md +1 -1
  8. package/dist/builtin/workflows/package.json +1 -1
  9. package/dist/builtin/workflows/src/authoring.d.ts +5 -2
  10. package/dist/builtin/workflows/src/extension/dispatcher.ts +2 -0
  11. package/dist/builtin/workflows/src/extension/index.ts +8 -0
  12. package/dist/builtin/workflows/src/extension/render-result.ts +5 -2
  13. package/dist/builtin/workflows/src/extension/workflow-schema.ts +18 -0
  14. package/dist/builtin/workflows/src/runs/background/status.ts +4 -0
  15. package/dist/builtin/workflows/src/runs/foreground/executor.ts +1251 -110
  16. package/dist/builtin/workflows/src/shared/authoring-contract.d.ts +34 -10
  17. package/dist/builtin/workflows/src/shared/expanded-workflow-graph.ts +10 -2
  18. package/dist/builtin/workflows/src/shared/persistence-restore.ts +28 -9
  19. package/dist/builtin/workflows/src/shared/persistence-session-entries.ts +9 -3
  20. package/dist/builtin/workflows/src/shared/store-types.ts +10 -3
  21. package/dist/builtin/workflows/src/shared/store.ts +29 -7
  22. package/dist/builtin/workflows/src/shared/types.ts +12 -10
  23. package/dist/builtin/workflows/src/tui/run-detail.ts +12 -0
  24. package/dist/builtin/workflows/src/tui/status-helpers.ts +4 -0
  25. package/dist/builtin/workflows/src/tui/status-list.ts +15 -1
  26. package/dist/builtin/workflows/src/tui/store-widget-installer.ts +1 -1
  27. package/dist/builtin/workflows/src/tui/widget.ts +12 -3
  28. package/dist/builtin/workflows/src/workflows/define-workflow.ts +3 -3
  29. package/dist/core/agent-session-services.d.ts +1 -0
  30. package/dist/core/agent-session-services.d.ts.map +1 -1
  31. package/dist/core/agent-session-services.js +1 -0
  32. package/dist/core/agent-session-services.js.map +1 -1
  33. package/dist/core/agent-session.d.ts +4 -0
  34. package/dist/core/agent-session.d.ts.map +1 -1
  35. package/dist/core/agent-session.js +12 -1
  36. package/dist/core/agent-session.js.map +1 -1
  37. package/dist/core/index.d.ts +1 -0
  38. package/dist/core/index.d.ts.map +1 -1
  39. package/dist/core/index.js +1 -0
  40. package/dist/core/index.js.map +1 -1
  41. package/dist/core/sdk.d.ts +4 -2
  42. package/dist/core/sdk.d.ts.map +1 -1
  43. package/dist/core/sdk.js +1 -0
  44. package/dist/core/sdk.js.map +1 -1
  45. package/dist/core/tools/ask-user-question/state/inline-input.d.ts +28 -0
  46. package/dist/core/tools/ask-user-question/state/inline-input.d.ts.map +1 -0
  47. package/dist/core/tools/ask-user-question/state/inline-input.js +56 -0
  48. package/dist/core/tools/ask-user-question/state/inline-input.js.map +1 -0
  49. package/dist/core/tools/ask-user-question/state/key-router.d.ts.map +1 -1
  50. package/dist/core/tools/ask-user-question/state/key-router.js +30 -4
  51. package/dist/core/tools/ask-user-question/state/key-router.js.map +1 -1
  52. package/dist/core/tools/ask-user-question/state/questionnaire-session.d.ts.map +1 -1
  53. package/dist/core/tools/ask-user-question/state/questionnaire-session.js +9 -8
  54. package/dist/core/tools/ask-user-question/state/questionnaire-session.js.map +1 -1
  55. package/dist/core/tools/ask-user-question/state/row-intent.d.ts +3 -2
  56. package/dist/core/tools/ask-user-question/state/row-intent.d.ts.map +1 -1
  57. package/dist/core/tools/ask-user-question/state/row-intent.js +1 -1
  58. package/dist/core/tools/ask-user-question/state/row-intent.js.map +1 -1
  59. package/dist/core/tools/ask-user-question/state/selectors/contract.d.ts +2 -0
  60. package/dist/core/tools/ask-user-question/state/selectors/contract.d.ts.map +1 -1
  61. package/dist/core/tools/ask-user-question/state/selectors/contract.js.map +1 -1
  62. package/dist/core/tools/ask-user-question/state/selectors/projections.d.ts.map +1 -1
  63. package/dist/core/tools/ask-user-question/state/selectors/projections.js +2 -0
  64. package/dist/core/tools/ask-user-question/state/selectors/projections.js.map +1 -1
  65. package/dist/core/tools/ask-user-question/state/state-reducer.d.ts.map +1 -1
  66. package/dist/core/tools/ask-user-question/state/state-reducer.js +36 -24
  67. package/dist/core/tools/ask-user-question/state/state-reducer.js.map +1 -1
  68. package/dist/core/tools/ask-user-question/state/state.d.ts +8 -0
  69. package/dist/core/tools/ask-user-question/state/state.d.ts.map +1 -1
  70. package/dist/core/tools/ask-user-question/state/state.js.map +1 -1
  71. package/dist/core/tools/ask-user-question/tool/format-answer.d.ts +6 -0
  72. package/dist/core/tools/ask-user-question/tool/format-answer.d.ts.map +1 -1
  73. package/dist/core/tools/ask-user-question/tool/format-answer.js +19 -1
  74. package/dist/core/tools/ask-user-question/tool/format-answer.js.map +1 -1
  75. package/dist/core/tools/ask-user-question/tool/response-envelope.d.ts +3 -2
  76. package/dist/core/tools/ask-user-question/tool/response-envelope.d.ts.map +1 -1
  77. package/dist/core/tools/ask-user-question/tool/response-envelope.js +15 -3
  78. package/dist/core/tools/ask-user-question/tool/response-envelope.js.map +1 -1
  79. package/dist/core/tools/ask-user-question/tool/types.d.ts +2 -1
  80. package/dist/core/tools/ask-user-question/tool/types.d.ts.map +1 -1
  81. package/dist/core/tools/ask-user-question/tool/types.js.map +1 -1
  82. package/dist/core/tools/ask-user-question/view/components/chat-row-view.d.ts +5 -2
  83. package/dist/core/tools/ask-user-question/view/components/chat-row-view.d.ts.map +1 -1
  84. package/dist/core/tools/ask-user-question/view/components/chat-row-view.js +2 -0
  85. package/dist/core/tools/ask-user-question/view/components/chat-row-view.js.map +1 -1
  86. package/dist/core/tools/ask-user-question/view/components/wrapping-select.d.ts +1 -0
  87. package/dist/core/tools/ask-user-question/view/components/wrapping-select.d.ts.map +1 -1
  88. package/dist/core/tools/ask-user-question/view/components/wrapping-select.js +2 -1
  89. package/dist/core/tools/ask-user-question/view/components/wrapping-select.js.map +1 -1
  90. package/dist/core/tools/ask-user-question/view/props-adapter.d.ts +3 -3
  91. package/dist/core/tools/ask-user-question/view/props-adapter.d.ts.map +1 -1
  92. package/dist/core/tools/ask-user-question/view/props-adapter.js +11 -4
  93. package/dist/core/tools/ask-user-question/view/props-adapter.js.map +1 -1
  94. package/dist/core/tools/bash-policy.d.ts +62 -0
  95. package/dist/core/tools/bash-policy.d.ts.map +1 -0
  96. package/dist/core/tools/bash-policy.js +1069 -0
  97. package/dist/core/tools/bash-policy.js.map +1 -0
  98. package/dist/core/tools/bash.d.ts +5 -0
  99. package/dist/core/tools/bash.d.ts.map +1 -1
  100. package/dist/core/tools/bash.js +7 -0
  101. package/dist/core/tools/bash.js.map +1 -1
  102. package/dist/core/tools/index.d.ts +1 -0
  103. package/dist/core/tools/index.d.ts.map +1 -1
  104. package/dist/core/tools/index.js +1 -0
  105. package/dist/core/tools/index.js.map +1 -1
  106. package/dist/index.d.ts +2 -2
  107. package/dist/index.d.ts.map +1 -1
  108. package/dist/index.js +1 -1
  109. package/dist/index.js.map +1 -1
  110. package/docs/sdk.md +42 -0
  111. package/docs/security.md +2 -0
  112. package/docs/workflows.md +127 -15
  113. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.8.28-alpha.3] - 2026-06-11
6
+
7
+ ### Added
8
+
9
+ - Added optional inline free-form text entry to the `ask_user_question` TUI's **Chat about this** footer row. Non-empty typed chat text now returns as a `kind: "chat"` answer and is surfaced to the agent without the legacy stop/wait termination envelope, while empty submissions keep the existing sentinel behavior.
10
+ - Added session-scoped `bashPolicy` support for the built-in `bash` tool, with exact/prefix/command-string-glob/regex rules, deny-over-allow precedence, segment-aware parsing by default, newline command separators, conservative reserved/compound-head, leading-redirection, attached command-head redirection, assignment, and non-literal command-head rejection, escaped glob bracket-class literal preservation, invalid glob range handling through `invalid-policy`, non-leading `>|` noclobber redirection handling, unknown top-level policy key rejection, runtime invalid-policy fail-closed validation, default-allow no-rule compatibility, and enforcement before shell execution.
11
+
5
12
  ## [0.8.28-alpha.2] - 2026-06-10
6
13
 
7
14
  ### Security
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/intercom",
3
- "version": "0.8.28-alpha.2",
3
+ "version": "0.8.28-alpha.3",
4
4
  "private": true,
5
5
  "description": "Atomic extension providing a private coordination channel between parent and child agent sessions. Fork of: https://github.com/nicobailon/pi-intercom",
6
6
  "contributors": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/mcp",
3
- "version": "0.8.28-alpha.2",
3
+ "version": "0.8.28-alpha.3",
4
4
  "private": true,
5
5
  "description": "Atomic extension that adapts MCP (Model Context Protocol) servers into the coding agent. Fork of: https://github.com/nicobailon/pi-mcp-adapter",
6
6
  "contributors": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/subagents",
3
- "version": "0.8.28-alpha.2",
3
+ "version": "0.8.28-alpha.3",
4
4
  "private": true,
5
5
  "description": "Atomic extension for delegating tasks to subagents with chains, parallel execution, and TUI clarification. Fork of: https://github.com/nicobailon/pi-subagents",
6
6
  "contributors": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/web-access",
3
- "version": "0.8.28-alpha.2",
3
+ "version": "0.8.28-alpha.3",
4
4
  "private": true,
5
5
  "description": "Atomic extension for web search, URL fetching, GitHub repo cloning, PDF/video extraction. Fork of: https://github.com/nicobailon/pi-web-access",
6
6
  "contributors": [
@@ -6,6 +6,24 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.8.28-alpha.3] - 2026-06-11
10
+
11
+ ### Added
12
+
13
+ - Added workflow stage/task `bashPolicy` wiring so individual workflow stages can constrain the built-in `bash` tool with command-level allow/deny rules, command-string glob matching, escaped glob bracket-class literal preservation, reserved/compound-head rejection, leading-redirection and attached command-head redirection rejection, non-leading `>|` noclobber redirection handling, assignment-head rejection, invalid glob range handling through `invalid-policy`, unknown top-level policy key rejection, runtime invalid-policy validation, and default-allow no-rule compatibility.
14
+ - Added workflow authoring `ctx.exit(options?)` for intentional early terminal runs from any call depth. `ctx.exit` supports `completed`, `skipped`, `cancelled`, and `blocked` terminal statuses, optional persisted/displayed reasons (including in the default status list), and partial declared outputs while preserving strict validation for provided output keys. This widens public run/detail/child status unions with `skipped`, `cancelled`, and `blocked`; downstream exhaustive switches should add cases for those statuses, while `failed` remains for thrown errors and `killed` remains external run-control. Child workflow results are now discriminated by `exited`: `exited: false` has full declared outputs, while `exited: true` has partial outputs plus the child exit status/reason.
15
+
16
+ ### Fixed
17
+
18
+ - Fixed `ctx.exit(...)` cleanup races so the selected exit is a level-triggered gate: delayed `ctx.stage`/`ctx.task`/`ctx.chain`/`ctx.parallel`/`ctx.workflow`/graph-backed `ctx.ui.*` calls and retained `StageContext` session-control methods no longer create graph, control, or `AgentSession` artifacts after exit; queued `ctx.parallel` work stops after exit even with `failFast: false`; parent exits cancel already-linked hidden child workflows with a typed parent-exit abort reason while the child executor owns skipped child stage/prompt cleanup, live handle/session disposal, and non-resumable `cancelled` child run finalization; parent finalization waits for that child cleanup so child `workflow.stage.end` entries are written exactly once before child and parent `workflow.run.end`; and prompt-node abort handling preserves `workflow-exit` skipped reasons instead of overwriting them with `run-aborted`.
19
+ - Fixed terminal run-end reconciliation after `ctx.exit(...)` cleanup races. If an external kill or another terminal writer wins `Store.recordRunEnd(...)` while exit cleanup or exit-output validation is pending, the returned `RunResult` and `onRunEnd` callback now report the canonical store status/result/error/reason (for example `killed`) and only the winning run-end write is persisted.
20
+ - Fixed workflow-boundary child-edge metadata cleanup for `ctx.exit(...)` and continuation replay. Boundaries that finalize as `skipped` or `failed` now clear `workflowChild`/`workflowChildRun`, stage-end persistence only emits child replay metadata for completed boundary stages, restore ignores stale child metadata on skipped/failed stage-end entries, and expanded graph views no longer flatten stale child stages from non-completed boundaries.
21
+ - Fixed `ctx.exit({ outputs })` payload capture to snapshot outputs by value at the first selected exit call. Later `finally` mutations can no longer remove undeclared keys or change valid/invalid values before post-cleanup validation, and option/output getter or enumeration failures now run workflow-exit cleanup before finalizing as non-resumable authoring failures when that terminal write wins.
22
+ - Fixed `ctx.exit(...)` exposing mutable finalization state to author code. The thrown exit signal and its captured output snapshot are now deep-frozen, so a workflow that catches the exit signal in a broad `try`/`catch` and mutates it before rethrowing can no longer rewrite the terminal status, reason, or outputs (finalization recovers the same frozen object via the run abort reason or the rethrow).
23
+ - Fixed continuation replay races where replayed stage `prompt`/`complete` or prompt-node finalizers could complete after a concurrent `ctx.exit(...)`. Pending replay finalizers now register with workflow-exit cleanup and re-check the exit gate after their replay microtask, so resumed runs skip/suppress those stages instead of writing misleading completed stage-end entries.
24
+ - Fixed control-signal probing for arbitrary workflow-thrown values and abort reasons. `ctx.exit(...)`/parent-exit detection now uses non-throwing reads for private markers, `scope`, aggregate `errors`, `cause`, and `reason`; throwing or inaccessible author accessors are ignored for that probe branch so runs finalize as ordinary failures or kills instead of leaking accessor errors from the executor catch path.
25
+ - Fixed interactive `ctx.ui.*` handling so workflow runs degrade gracefully instead of crashing or emitting a confusing error. Partial/method-less UI adapters could previously surface a raw `TypeError: <method> is not a function` for `input`/`confirm`/`select`/`editor` (only `custom` was already guarded); every primitive is now guarded and rejects with a clear, actionable per-method error. Separately, headless/background (non-interactive) runs without a UI adapter now reject with an explicit "interactive ctx.ui.<primitive> is unavailable in headless (non-interactive) mode…" error that points to running interactively or removing the prompt, replacing the generic "Atomic runtime did not provide a UI adapter" wording for that path. Earlier completed stages remain completed, and interactive background runs keep brokering `ctx.ui.custom` through awaiting-input prompt nodes ([#1339](https://github.com/bastani-inc/atomic/issues/1339)).
26
+
9
27
  ## [0.8.28-alpha.2] - 2026-06-10
10
28
 
11
29
  ### Fixed
@@ -522,7 +522,7 @@ Press **F2** while a workflow is running to open the DAG overlay for the active
522
522
 
523
523
  For interactive use, run workflows through `/workflow <name> [key=value ...]` or let the LLM call the `workflow` tool. In non-interactive (`-p` / `--print` / `--mode json`) sessions, `/workflow <name> key=value` and LLM calls to the `workflow` tool remain available for deterministic workflows. The input picker and graph picker are disabled, top-level `ctx.ui.*` is unavailable, and stage child sessions exclude `ask_user_question`. Named workflow dispatch waits for the terminal run snapshot before returning.
524
524
 
525
- Because human input is runtime-only and workflows no longer carry a declaration-time HIL marker, headless dispatch does not reject a workflow just because its source contains `ctx.ui.*`. If you copy the HIL example above into a non-interactive session, it can pass dispatch and then fail when execution reaches the prompt with an error such as `atomic-workflows: HIL ctx.ui.confirm is unavailable because Atomic runtime did not provide a UI adapter` (the primitive name varies, including `ctx.ui.custom`). Run those workflows interactively, or guard/remove runtime `ctx.ui.*` calls before using headless mode.
525
+ Because human input is runtime-only and workflows no longer carry a declaration-time HIL marker, headless dispatch does not reject a workflow just because its source contains `ctx.ui.*`. If you copy the HIL example above into a non-interactive session, it can pass dispatch and then fail when execution reaches the prompt with an error such as `atomic-workflows: interactive ctx.ui.confirm is unavailable in headless (non-interactive) mode; run the workflow in interactive mode or remove the interactive prompt from this stage` (the primitive name varies, including `ctx.ui.custom`). Run those workflows interactively, or guard/remove runtime `ctx.ui.*` calls before using headless mode.
526
526
 
527
527
  For library or package authoring, define reusable workflows with the builder and export the compiled definition. Hand-written objects with `__piWorkflow: true` are rejected by discovery and composition; `defineWorkflow(...).compile()` is the public authoring surface. Standalone TypeScript workflow packages can import `defineWorkflow` and `Type` from `@bastani/workflows` directly with no local `.d.ts` file or `declare module` shim. The former imperative `runWorkflow` object-form API is removed; use compiled workflow definitions with the exported `run()` / registry helpers for programmatic execution.
528
528
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/workflows",
3
- "version": "0.8.28-alpha.2",
3
+ "version": "0.8.28-alpha.3",
4
4
  "private": true,
5
5
  "description": "Atomic extension for multi-stage workflow authoring and execution.",
6
6
  "contributors": [
@@ -57,7 +57,7 @@ export declare const Type: Omit<typeof TypeboxType, "Any" | "Array" | "BigInt" |
57
57
  Void(): TVoid;
58
58
  };
59
59
  export type { Static, TSchema } from "typebox";
60
- export type { AgentSessionAdapter, CompleteAdapter, CompleteStageOpts, GitWorktreeSetupOptions, GitWorktreeSetupResult, PromptAdapter, PromptOptions, ResolvedInputs, RunResult, RunStatus, StageAdapters, StageStatus, StageOptions, StageContext, StageSnapshot, StageExecutionMeta, StageMcpOptions, StageOutputOptions, StagePromptOptions, StageSessionCreateOptions, StageSessionCreateResult, StageSessionRuntime, WorkflowAction, WorkflowArtifact, WorkflowChainOptions, WorkflowChainStep, WorkflowChildResult, WorkflowContextMode, WorkflowControlEvent, WorkflowCustomToolDefinition, WorkflowCustomUiComponent, WorkflowCustomUiFactory, WorkflowCustomUiKeybindings, WorkflowCustomUiOptions, WorkflowCustomUiOverlayHandle, WorkflowCustomUiOverlayOptions, WorkflowCustomUiTheme, WorkflowCustomUiTui, WorkflowDetails, WorkflowDetailsMode, WorkflowDetailsStatus, WorkflowDirectOptions, WorkflowDirectTaskItem, WorkflowExecutionMode, WorkflowExecutionPolicy, WorkflowInputBindings, WorkflowInputSchema, WorkflowInputSchemaMap, WorkflowInputValues, WorkflowIntercomSummary, WorkflowMaxOutput, WorkflowMcpPort, WorkflowModelAttempt, WorkflowModelCatalogPort, WorkflowModelFallbackFields, WorkflowModelInfo, WorkflowModelUsage, WorkflowModelValue, WorkflowOutputMode, WorkflowOutputSchema, WorkflowOutputSchemaMap, WorkflowOutputValues, WorkflowParallelChainStep, WorkflowParallelOptions, WorkflowPersistencePort, WorkflowProgressSummary, WorkflowRunChildOptions, WorkflowRunOutput, WorkflowRuntimeConfig, WorkflowSerializableObject, WorkflowSerializablePrimitive, WorkflowSerializableValue, WorkflowSharedTaskDefaults, WorkflowTaskContext, WorkflowTaskContextInput, WorkflowTaskOptions, WorkflowTaskResult, WorkflowTaskSessionFields, WorkflowTaskSessionOptions, WorkflowTaskStep, WorkflowThinkingLevel, WorkflowUIAdapter, WorkflowUIContext, WorkflowWorktreeInputBinding, } from "./shared/authoring-contract.js";
60
+ export type { AgentSessionAdapter, CompleteAdapter, CompleteStageOpts, GitWorktreeSetupOptions, GitWorktreeSetupResult, PromptAdapter, PromptOptions, ResolvedInputs, RunResult, RunStatus, StageAdapters, StageStatus, StageOptions, StageContext, StageSnapshot, StageExecutionMeta, StageMcpOptions, StageOutputOptions, StagePromptOptions, StageSessionCreateOptions, StageSessionCreateResult, StageSessionRuntime, WorkflowAction, WorkflowArtifact, WorkflowChainOptions, WorkflowChainStep, WorkflowChildResult, WorkflowContextMode, WorkflowControlEvent, WorkflowCustomToolDefinition, WorkflowCustomUiComponent, WorkflowCustomUiFactory, WorkflowCustomUiKeybindings, WorkflowCustomUiOptions, WorkflowCustomUiOverlayHandle, WorkflowCustomUiOverlayOptions, WorkflowCustomUiTheme, WorkflowCustomUiTui, WorkflowDetails, WorkflowDetailsMode, WorkflowDetailsStatus, WorkflowDirectOptions, WorkflowDirectTaskItem, WorkflowExecutionMode, WorkflowExecutionPolicy, WorkflowExitOptions, WorkflowExitStatus, WorkflowInputBindings, WorkflowInputSchema, WorkflowInputSchemaMap, WorkflowInputValues, WorkflowIntercomSummary, WorkflowMaxOutput, WorkflowMcpPort, WorkflowModelAttempt, WorkflowModelCatalogPort, WorkflowModelFallbackFields, WorkflowModelInfo, WorkflowModelUsage, WorkflowModelValue, WorkflowOutputMode, WorkflowOutputSchema, WorkflowOutputSchemaMap, WorkflowOutputValues, WorkflowParallelChainStep, WorkflowParallelOptions, WorkflowPersistencePort, WorkflowProgressSummary, WorkflowRunChildOptions, WorkflowRunOutput, WorkflowRuntimeConfig, WorkflowSerializableObject, WorkflowSerializablePrimitive, WorkflowSerializableValue, WorkflowSharedTaskDefaults, WorkflowTaskContext, WorkflowTaskContextInput, WorkflowTaskOptions, WorkflowTaskResult, WorkflowTaskSessionFields, WorkflowTaskSessionOptions, WorkflowTaskStep, WorkflowThinkingLevel, WorkflowUIAdapter, WorkflowUIContext, WorkflowWorktreeInputBinding, } from "./shared/authoring-contract.js";
61
61
  import type * as AuthoringContract from "./shared/authoring-contract.js";
62
62
  import type { GitWorktreeSetupOptions, GitWorktreeSetupResult, ResolvedInputs, RunResult, RunStatus, StageSnapshot, WorkflowDefinition as WorkflowContractDefinition, WorkflowDetails, WorkflowDirectOptions, WorkflowDirectTaskItem, WorkflowExecutionPolicy, WorkflowInputValues, WorkflowOutputValues, WorkflowSerializableObject, WorkflowChainStep } from "./shared/authoring-contract.js";
63
63
  declare const workflowDefinitionBrand: unique symbol;
@@ -66,7 +66,7 @@ type WorkflowDefinitionBrand = {
66
66
  };
67
67
  export interface WorkflowDefinition<TInputs extends WorkflowInputValues = WorkflowInputValues, TOutputs extends WorkflowOutputValues = WorkflowOutputValues, TRunInputs extends WorkflowInputValues = TInputs, TDefinitionBrand extends object = WorkflowDefinitionBrand> extends WorkflowContractDefinition<TInputs, TOutputs, TRunInputs, TDefinitionBrand>, WorkflowDefinitionBrand {
68
68
  }
69
- export type WorkflowRunContext<TInputs extends WorkflowInputValues = WorkflowInputValues> = AuthoringContract.WorkflowRunContext<TInputs, WorkflowDefinitionBrand>;
69
+ export type WorkflowRunContext<TInputs extends WorkflowInputValues = WorkflowInputValues, TOutputs extends WorkflowOutputValues = WorkflowOutputValues> = AuthoringContract.WorkflowRunContext<TInputs, WorkflowDefinitionBrand, TOutputs>;
70
70
  export type WorkflowRunFn<TInputs extends WorkflowInputValues = WorkflowInputValues, TOutputs extends WorkflowOutputValues = WorkflowOutputValues> = AuthoringContract.WorkflowRunFn<TInputs, TOutputs, WorkflowDefinitionBrand>;
71
71
  export type AnyWorkflowDefinition = WorkflowDefinition<WorkflowInputValues, WorkflowOutputValues, WorkflowInputValues>;
72
72
  export type WorkflowBuilder<TInputs extends WorkflowInputValues = {}, TOutputs extends WorkflowOutputValues = {}, TRunInputs extends WorkflowInputValues = TInputs> = AuthoringContract.WorkflowBuilder<TInputs, TOutputs, TRunInputs, WorkflowDefinitionBrand, WorkflowDefinition<TInputs, TOutputs, TRunInputs>>;
@@ -161,6 +161,9 @@ export interface RunSnapshot {
161
161
  readonly durationMs?: number;
162
162
  readonly result?: WorkflowOutputValues;
163
163
  readonly error?: string;
164
+ /** True when the run reached its terminal status through ctx.exit(). */
165
+ readonly exited?: boolean;
166
+ readonly exitReason?: string;
164
167
  readonly pendingPrompt?: PendingPrompt;
165
168
  }
166
169
  export interface StoreSnapshot {
@@ -201,6 +201,8 @@ export async function dispatch(
201
201
  status: snapshot.status,
202
202
  result: snapshot.result,
203
203
  error: snapshot.error,
204
+ exited: snapshot.exited,
205
+ exitReason: snapshot.exitReason,
204
206
  stages: snapshot.stages.map((stage) => structuredClone(stage)),
205
207
  };
206
208
  }
@@ -693,6 +693,7 @@ function renderStagesToolContent(
693
693
  if (stage.transcriptPath) lines.push(`transcriptPath: ${stage.transcriptPath}`);
694
694
  if (stage.transcriptPath) lines.push(`transcriptPathJson: ${JSON.stringify(stage.transcriptPath)}`);
695
695
  if (stage.error) lines.push(`error: ${stage.error}`);
696
+ if (stage.skippedReason) lines.push(`skippedReason: ${stage.skippedReason}`);
696
697
  if (stage.awaitingInputSince !== undefined) {
697
698
  lines.push(`awaitingInputSince: ${stage.awaitingInputSince}`);
698
699
  }
@@ -803,6 +804,7 @@ type WorkflowStageSummary = {
803
804
  sessionFile?: string;
804
805
  transcriptPath?: string;
805
806
  error?: string;
807
+ skippedReason?: string;
806
808
  awaitingInputSince?: number;
807
809
  pendingPrompt?: StageSnapshot["pendingPrompt"];
808
810
  inputRequest?: StageSnapshot["inputRequest"];
@@ -842,6 +844,7 @@ function summarizeStage(stage: StageSnapshot): WorkflowStageSummary {
842
844
  sessionFile: stage.sessionFile,
843
845
  transcriptPath: stage.sessionFile,
844
846
  error: stage.error,
847
+ skippedReason: stage.skippedReason,
845
848
  awaitingInputSince: stage.awaitingInputSince,
846
849
  pendingPrompt: stage.pendingPrompt === undefined
847
850
  ? undefined
@@ -1201,6 +1204,9 @@ function isRunStatus(value: string): value is RunStatus {
1201
1204
  case "running":
1202
1205
  case "paused":
1203
1206
  case "completed":
1207
+ case "skipped":
1208
+ case "cancelled":
1209
+ case "blocked":
1204
1210
  case "failed":
1205
1211
  case "killed":
1206
1212
  return true;
@@ -1232,6 +1238,8 @@ function fallbackRunDetailFromResult(
1232
1238
  stages,
1233
1239
  result: result.result,
1234
1240
  error: result.error,
1241
+ exited: result.exited,
1242
+ exitReason: result.exitReason,
1235
1243
  };
1236
1244
  }
1237
1245
 
@@ -91,6 +91,8 @@ type RunResult = {
91
91
  result?: WorkflowOutputValues;
92
92
  details?: WorkflowDetails;
93
93
  error?: string;
94
+ exited?: boolean;
95
+ exitReason?: string;
94
96
  stages?: StageSnapshot[];
95
97
  /**
96
98
  * Free-form message carried by the result. Carries the "started in
@@ -107,6 +109,7 @@ type StageListItem = {
107
109
  sessionFile?: string;
108
110
  transcriptPath?: string;
109
111
  error?: string;
112
+ skippedReason?: string;
110
113
  awaitingInputSince?: number;
111
114
  pendingPrompt?: PendingPrompt;
112
115
  inputRequest?: StageInputRequest;
@@ -330,7 +333,7 @@ export function renderResult(result: WorkflowToolResult, opts?: RenderResultOpts
330
333
  const label = r.name ? ` (${r.name})` : "";
331
334
  return renderNotice("WORKFLOW RUN", `${r.runId}${label}: ${r.details.mode} ${r.details.status}`, opts, themed);
332
335
  }
333
- if (r.status === "completed" || r.status === "killed") {
336
+ if (r.status === "completed" || r.status === "skipped" || r.status === "cancelled" || r.status === "blocked" || r.status === "killed") {
334
337
  const label = r.name ? ` (${r.name})` : "";
335
338
  return renderNotice("WORKFLOW RUN", `${r.runId}${label}: ${r.status}`, opts, themed);
336
339
  }
@@ -357,7 +360,7 @@ export function renderResult(result: WorkflowToolResult, opts?: RenderResultOpts
357
360
  case "stages": {
358
361
  const r = result as StageListResult;
359
362
  if (r.error) return renderNotice("WORKFLOW STAGES", `${r.runId || "(none)"}: ${r.error}`, opts, themed);
360
- const counts = r.stages.map((s) => `${s.name} (${s.id.slice(0, 12)}): ${s.status}`).join("; ");
363
+ const counts = r.stages.map((s) => `${s.name} (${s.id.slice(0, 12)}): ${s.status}${s.skippedReason ? ` — ${s.skippedReason}` : ""}`).join("; ");
361
364
  return renderNotice("WORKFLOW STAGES", `${r.runId}: ${r.filter} — ${counts || "no stages"}`, opts, themed);
362
365
  }
363
366
 
@@ -37,6 +37,23 @@ const McpOptionsSchema = Type.Object({
37
37
  deny: Type.Optional(Type.Array(Type.String())),
38
38
  });
39
39
 
40
+ const BashCommandRuleSchema = Type.Union([
41
+ Type.String(),
42
+ Type.Object({ prefix: Type.String() }, { additionalProperties: false }),
43
+ Type.Object({ glob: Type.String() }, { additionalProperties: false }),
44
+ Type.Object({
45
+ regex: Type.String(),
46
+ flags: Type.Optional(Type.String()),
47
+ }, { additionalProperties: false }),
48
+ ]);
49
+
50
+ const BashCommandPolicySchema = Type.Object({
51
+ default: Type.Optional(Type.Union([Type.Literal("allow"), Type.Literal("deny")])),
52
+ allow: Type.Optional(Type.Array(BashCommandRuleSchema)),
53
+ deny: Type.Optional(Type.Array(BashCommandRuleSchema)),
54
+ match: Type.Optional(Type.Union([Type.Literal("whole"), Type.Literal("segments")])),
55
+ }, { additionalProperties: false });
56
+
40
57
  const StageSessionOptionProperties = {
41
58
  cwd: Type.Optional(Type.String()),
42
59
  agentDir: Type.Optional(Type.String()),
@@ -50,6 +67,7 @@ const StageSessionOptionProperties = {
50
67
  })),
51
68
  tools: Type.Optional(Type.Array(Type.String())),
52
69
  customTools: Type.Optional(Type.Array(SdkSessionOptionArrayElementSchema("customTools"))),
70
+ bashPolicy: Type.Optional(BashCommandPolicySchema),
53
71
  resourceLoader: Type.Optional(SdkSessionOptionSchema("resourceLoader")),
54
72
  sessionManager: Type.Optional(SdkSessionOptionSchema("sessionManager")),
55
73
  settingsManager: Type.Optional(SdkSessionOptionSchema("settingsManager")),
@@ -82,6 +82,8 @@ export interface RunDetail {
82
82
  readonly stages: readonly RunSnapshot["stages"][number][];
83
83
  readonly result?: WorkflowOutputValues;
84
84
  readonly error?: string;
85
+ readonly exited?: boolean;
86
+ readonly exitReason?: string;
85
87
  readonly failureKind?: RunSnapshot["failureKind"];
86
88
  readonly failureCode?: RunSnapshot["failureCode"];
87
89
  readonly failureRecoverability?: RunSnapshot["failureRecoverability"];
@@ -479,6 +481,8 @@ export function inspectRun(
479
481
  stages: expandedStages.map((stage) => structuredClone(stage)),
480
482
  result: copy.result,
481
483
  error: copy.error,
484
+ exited: copy.exited,
485
+ exitReason: copy.exitReason,
482
486
  failureKind: copy.failureKind,
483
487
  failureCode: copy.failureCode,
484
488
  failureRecoverability: copy.failureRecoverability,