@bastani/atomic 0.8.31-alpha.5 → 0.9.0-alpha.2
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/CHANGELOG.md +28 -1
- package/dist/builtin/cursor/CHANGELOG.md +10 -1
- package/dist/builtin/cursor/package.json +2 -2
- package/dist/builtin/cursor/src/proto/protobuf-codec-json.ts +44 -0
- package/dist/builtin/cursor/src/proto/protobuf-codec-request.ts +271 -0
- package/dist/builtin/cursor/src/proto/protobuf-codec-wire.ts +231 -0
- package/dist/builtin/cursor/src/proto/protobuf-codec.ts +5 -523
- package/dist/builtin/cursor/src/stream.ts +6 -70
- package/dist/builtin/cursor/src/transport-errors.ts +74 -0
- package/dist/builtin/cursor/src/transport-frame.ts +56 -0
- package/dist/builtin/cursor/src/transport-http2.ts +122 -0
- package/dist/builtin/cursor/src/transport-native-client.ts +161 -0
- package/dist/builtin/cursor/src/transport-run-stream.ts +188 -0
- package/dist/builtin/cursor/src/transport-timeouts.ts +87 -0
- package/dist/builtin/cursor/src/transport-types.ts +140 -0
- package/dist/builtin/cursor/src/transport.ts +24 -790
- package/dist/builtin/intercom/CHANGELOG.md +9 -0
- package/dist/builtin/intercom/broker/client.ts +0 -35
- package/dist/builtin/intercom/contact-supervisor-tool.ts +289 -0
- package/dist/builtin/intercom/index-heavy.ts +77 -1336
- package/dist/builtin/intercom/intercom-tool.ts +409 -0
- package/dist/builtin/intercom/intercom-utils.ts +401 -0
- package/dist/builtin/intercom/lifecycle.ts +133 -0
- package/dist/builtin/intercom/overlay.ts +96 -0
- package/dist/builtin/intercom/package.json +2 -2
- package/dist/builtin/intercom/subagent-relay.ts +137 -0
- package/dist/builtin/mcp/CHANGELOG.md +9 -0
- package/dist/builtin/mcp/config-write-utils.ts +104 -0
- package/dist/builtin/mcp/config.ts +4 -180
- package/dist/builtin/mcp/mcp-panel-renderer.ts +243 -0
- package/dist/builtin/mcp/mcp-panel-state.ts +227 -0
- package/dist/builtin/mcp/mcp-panel-types.ts +86 -0
- package/dist/builtin/mcp/mcp-panel.ts +145 -579
- package/dist/builtin/mcp/mcp-setup-panel.ts +4 -81
- package/dist/builtin/mcp/package.json +3 -3
- package/dist/builtin/mcp/proxy-auth.ts +61 -0
- package/dist/builtin/mcp/proxy-call.ts +373 -0
- package/dist/builtin/mcp/proxy-connect.ts +58 -0
- package/dist/builtin/mcp/proxy-info-modes.ts +326 -0
- package/dist/builtin/mcp/proxy-modes.ts +3 -805
- package/dist/builtin/mcp/proxy-types.ts +3 -0
- package/dist/builtin/mcp/ui-server-http.ts +81 -0
- package/dist/builtin/mcp/ui-server.ts +2 -127
- package/dist/builtin/subagents/CHANGELOG.md +9 -0
- package/dist/builtin/subagents/package.json +4 -4
- package/dist/builtin/subagents/src/agents/agent-discovery.ts +127 -0
- package/dist/builtin/subagents/src/agents/agent-loaders.ts +175 -0
- package/dist/builtin/subagents/src/agents/agent-management-helpers.ts +310 -0
- package/dist/builtin/subagents/src/agents/agent-management.ts +3 -309
- package/dist/builtin/subagents/src/agents/agent-overrides.ts +397 -0
- package/dist/builtin/subagents/src/agents/agent-paths.ts +88 -0
- package/dist/builtin/subagents/src/agents/agent-types.ts +136 -0
- package/dist/builtin/subagents/src/agents/agents.ts +22 -895
- package/dist/builtin/subagents/src/agents/skills-paths.ts +333 -0
- package/dist/builtin/subagents/src/agents/skills.ts +3 -326
- package/dist/builtin/subagents/src/extension/index.ts +4 -118
- package/dist/builtin/subagents/src/extension/prompt-guidance.ts +13 -0
- package/dist/builtin/subagents/src/runs/background/async-execution-chain.ts +401 -0
- package/dist/builtin/subagents/src/runs/background/async-execution-common.ts +131 -0
- package/dist/builtin/subagents/src/runs/background/async-execution-single.ts +213 -0
- package/dist/builtin/subagents/src/runs/background/async-execution-types.ts +84 -0
- package/dist/builtin/subagents/src/runs/background/async-execution.ts +13 -795
- package/dist/builtin/subagents/src/runs/background/subagent-runner-dynamic.ts +215 -0
- package/dist/builtin/subagents/src/runs/background/subagent-runner-finalize.ts +136 -0
- package/dist/builtin/subagents/src/runs/background/subagent-runner-output.ts +105 -0
- package/dist/builtin/subagents/src/runs/background/subagent-runner-parallel-helpers.ts +112 -0
- package/dist/builtin/subagents/src/runs/background/subagent-runner-parallel.ts +159 -0
- package/dist/builtin/subagents/src/runs/background/subagent-runner-sequential.ts +127 -0
- package/dist/builtin/subagents/src/runs/background/subagent-runner-state.ts +427 -0
- package/dist/builtin/subagents/src/runs/background/subagent-runner-step.ts +273 -0
- package/dist/builtin/subagents/src/runs/background/subagent-runner-streaming.ts +269 -0
- package/dist/builtin/subagents/src/runs/background/subagent-runner-types.ts +196 -0
- package/dist/builtin/subagents/src/runs/background/subagent-runner-utils.ts +70 -0
- package/dist/builtin/subagents/src/runs/background/subagent-runner.ts +44 -2233
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-behavior.ts +75 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-component.ts +202 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-edit.ts +97 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-editor.ts +160 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-frame.ts +72 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-render-modes.ts +161 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-render-selectors.ts +203 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-selectors.ts +234 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-state.ts +103 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-types.ts +29 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify.ts +4 -1328
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-clarify.ts +117 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-details.ts +35 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-dynamic-step.ts +194 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-runner.ts +183 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-step.ts +185 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-sequential-step.ts +229 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-types.ts +194 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution.ts +94 -1043
- package/dist/builtin/subagents/src/runs/foreground/execution-attempt-control.ts +135 -0
- package/dist/builtin/subagents/src/runs/foreground/execution-attempt-finalize.ts +107 -0
- package/dist/builtin/subagents/src/runs/foreground/execution-attempt-types.ts +17 -0
- package/dist/builtin/subagents/src/runs/foreground/execution-attempt.ts +454 -0
- package/dist/builtin/subagents/src/runs/foreground/execution-run-sync.ts +219 -0
- package/dist/builtin/subagents/src/runs/foreground/execution-structured-retries.ts +77 -0
- package/dist/builtin/subagents/src/runs/foreground/execution-updates.ts +34 -0
- package/dist/builtin/subagents/src/runs/foreground/execution-utils.ts +56 -0
- package/dist/builtin/subagents/src/runs/foreground/execution.ts +6 -1082
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-async.ts +207 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-chain.ts +140 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-context.ts +266 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-input.ts +270 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel-task.ts +157 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel.ts +375 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-resume.ts +463 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-runtime.ts +17 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-single.ts +320 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-status.ts +207 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-types.ts +121 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-worktree.ts +113 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor.ts +150 -2522
- package/dist/builtin/subagents/src/runs/shared/model-fallback.ts +0 -16
- package/dist/builtin/subagents/src/runs/shared/nested-events-control.ts +167 -0
- package/dist/builtin/subagents/src/runs/shared/nested-events-core.ts +219 -0
- package/dist/builtin/subagents/src/runs/shared/nested-events-projection.ts +121 -0
- package/dist/builtin/subagents/src/runs/shared/nested-events-registry.ts +289 -0
- package/dist/builtin/subagents/src/runs/shared/nested-events-sanitize.ts +201 -0
- package/dist/builtin/subagents/src/runs/shared/nested-events.ts +50 -935
- package/dist/builtin/subagents/src/runs/shared/worktree.ts +0 -78
- package/dist/builtin/subagents/src/shared/types-async.ts +265 -0
- package/dist/builtin/subagents/src/shared/types-config.ts +125 -0
- package/dist/builtin/subagents/src/shared/types-depth.ts +121 -0
- package/dist/builtin/subagents/src/shared/types-output.ts +63 -0
- package/dist/builtin/subagents/src/shared/types-results.ts +318 -0
- package/dist/builtin/subagents/src/shared/types-runtime.ts +136 -0
- package/dist/builtin/subagents/src/shared/types.ts +10 -975
- package/dist/builtin/subagents/src/slash/slash-commands.ts +0 -12
- package/dist/builtin/subagents/src/tui/render-chain-graph.ts +247 -0
- package/dist/builtin/subagents/src/tui/render-event-formatting.ts +259 -0
- package/dist/builtin/subagents/src/tui/render-layout.ts +120 -0
- package/dist/builtin/subagents/src/tui/render-result-animation.ts +56 -0
- package/dist/builtin/subagents/src/tui/render-result-compact.ts +154 -0
- package/dist/builtin/subagents/src/tui/render-result.ts +390 -0
- package/dist/builtin/subagents/src/tui/render-stable-output.ts +83 -0
- package/dist/builtin/subagents/src/tui/render-status-progress.ts +133 -0
- package/dist/builtin/subagents/src/tui/render-widget-graph.ts +166 -0
- package/dist/builtin/subagents/src/tui/render-widget.ts +273 -0
- package/dist/builtin/subagents/src/tui/render.ts +14 -1801
- package/dist/builtin/web-access/CHANGELOG.md +9 -0
- package/dist/builtin/web-access/content-tools.ts +348 -0
- package/dist/builtin/web-access/curator-page-assets/script-1.ts +400 -0
- package/dist/builtin/web-access/curator-page-assets/script-2.ts +400 -0
- package/dist/builtin/web-access/curator-page-assets/script-3.ts +400 -0
- package/dist/builtin/web-access/curator-page-assets/script-4.ts +400 -0
- package/dist/builtin/web-access/curator-page-assets/script-5.ts +398 -0
- package/dist/builtin/web-access/curator-page-assets/styles-1.ts +394 -0
- package/dist/builtin/web-access/curator-page-assets/styles-2.ts +394 -0
- package/dist/builtin/web-access/curator-page-assets/styles-3.ts +393 -0
- package/dist/builtin/web-access/curator-page.ts +17 -3180
- package/dist/builtin/web-access/curator-server-helpers.ts +115 -0
- package/dist/builtin/web-access/curator-server.ts +2 -113
- package/dist/builtin/web-access/exa-mcp.ts +218 -0
- package/dist/builtin/web-access/exa.ts +2 -207
- package/dist/builtin/web-access/extract-frames.ts +228 -0
- package/dist/builtin/web-access/extract.ts +13 -214
- package/dist/builtin/web-access/github-config.ts +156 -0
- package/dist/builtin/web-access/github-extract.ts +3 -154
- package/dist/builtin/web-access/index-heavy.ts +8 -1904
- package/dist/builtin/web-access/package.json +3 -2
- package/dist/builtin/web-access/web-search-activity.ts +102 -0
- package/dist/builtin/web-access/web-search-browser.ts +116 -0
- package/dist/builtin/web-access/web-search-command.ts +242 -0
- package/dist/builtin/web-access/web-search-config.ts +163 -0
- package/dist/builtin/web-access/web-search-curator.ts +214 -0
- package/dist/builtin/web-access/web-search-features.ts +165 -0
- package/dist/builtin/web-access/web-search-formatting.ts +117 -0
- package/dist/builtin/web-access/web-search-return.ts +136 -0
- package/dist/builtin/web-access/web-search-summary.ts +170 -0
- package/dist/builtin/web-access/web-search-tool.ts +290 -0
- package/dist/builtin/web-access/web-search-types.ts +50 -0
- package/dist/builtin/workflows/CHANGELOG.md +16 -1
- package/dist/builtin/workflows/README.md +189 -122
- package/dist/builtin/workflows/builtin/deep-research-codebase-runner.ts +492 -0
- package/dist/builtin/workflows/builtin/deep-research-codebase-utils.ts +346 -0
- package/dist/builtin/workflows/builtin/deep-research-codebase.ts +36 -849
- package/dist/builtin/workflows/builtin/goal-artifacts.ts +43 -0
- package/dist/builtin/workflows/builtin/goal-ledger.ts +54 -0
- package/dist/builtin/workflows/builtin/goal-prompts.ts +360 -0
- package/dist/builtin/workflows/builtin/goal-reducer.ts +141 -0
- package/dist/builtin/workflows/builtin/goal-reports.ts +56 -0
- package/dist/builtin/workflows/builtin/goal-review.ts +84 -0
- package/dist/builtin/workflows/builtin/goal-runner.ts +336 -0
- package/dist/builtin/workflows/builtin/goal-schemas.ts +60 -0
- package/dist/builtin/workflows/builtin/goal-types.ts +132 -0
- package/dist/builtin/workflows/builtin/goal.ts +40 -1201
- package/dist/builtin/workflows/builtin/index.d.ts +1 -0
- package/dist/builtin/workflows/builtin/open-claude-design-phases.ts +432 -0
- package/dist/builtin/workflows/builtin/open-claude-design-runner.ts +476 -0
- package/dist/builtin/workflows/builtin/open-claude-design-utils.ts +312 -0
- package/dist/builtin/workflows/builtin/open-claude-design.d.ts +1 -0
- package/dist/builtin/workflows/builtin/open-claude-design.ts +47 -1131
- package/dist/builtin/workflows/builtin/ralph-core.ts +408 -0
- package/dist/builtin/workflows/builtin/ralph-models.ts +123 -0
- package/dist/builtin/workflows/builtin/ralph-runner.ts +499 -0
- package/dist/builtin/workflows/builtin/ralph.ts +50 -1019
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/detect-antipatterns-browser.js +2 -2
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs +2 -2
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/rules/checks.mjs +2 -2
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/page.mjs +8 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/live-accept.mjs +13 -15
- package/dist/builtin/workflows/skills/impeccable/scripts/live-manual-edit-evidence.mjs +2 -2
- package/dist/builtin/workflows/skills/impeccable/scripts/live-server.mjs +9 -0
- package/dist/builtin/workflows/src/authoring/typebox-defaults.d.ts +41 -0
- package/dist/builtin/workflows/src/authoring/typebox-defaults.ts +217 -0
- package/dist/builtin/workflows/src/authoring/workflow.ts +184 -0
- package/dist/builtin/workflows/src/authoring.d.ts +14 -66
- package/dist/builtin/workflows/src/engine/graph-inference.ts +100 -0
- package/dist/builtin/workflows/src/engine/options.ts +40 -0
- package/dist/builtin/workflows/src/engine/primitives/chain.ts +29 -0
- package/dist/builtin/workflows/src/engine/primitives/exit.ts +2 -0
- package/dist/builtin/workflows/src/engine/primitives/parallel.ts +47 -0
- package/dist/builtin/workflows/src/engine/primitives/task.ts +108 -0
- package/dist/builtin/workflows/src/engine/primitives/ui.ts +41 -0
- package/dist/builtin/workflows/src/engine/primitives/workflow.ts +159 -0
- package/dist/builtin/workflows/src/engine/replay.ts +8 -0
- package/dist/builtin/workflows/src/engine/run.ts +356 -0
- package/dist/builtin/workflows/src/engine/runtime.ts +160 -0
- package/dist/builtin/workflows/src/extension/atomic-stage-session.ts +186 -0
- package/dist/builtin/workflows/src/extension/config-file-loader.ts +152 -0
- package/dist/builtin/workflows/src/extension/config-loader.ts +2 -167
- package/dist/builtin/workflows/src/extension/discovery-loaders.ts +115 -0
- package/dist/builtin/workflows/src/extension/discovery.ts +3 -117
- package/dist/builtin/workflows/src/extension/extension-factory.ts +120 -0
- package/dist/builtin/workflows/src/extension/extension-lifecycle.ts +109 -0
- package/dist/builtin/workflows/src/extension/extension-runtime-state.ts +270 -0
- package/dist/builtin/workflows/src/extension/index.ts +42 -4166
- package/dist/builtin/workflows/src/extension/public-types.ts +295 -0
- package/dist/builtin/workflows/src/extension/render-component.ts +14 -0
- package/dist/builtin/workflows/src/extension/runtime-direct.ts +96 -0
- package/dist/builtin/workflows/src/extension/runtime.ts +1 -92
- package/dist/builtin/workflows/src/extension/ui-surface.ts +286 -0
- package/dist/builtin/workflows/src/extension/wiring.ts +6 -475
- package/dist/builtin/workflows/src/extension/workflow-command-completions.ts +111 -0
- package/dist/builtin/workflows/src/extension/workflow-command-registration.ts +213 -0
- package/dist/builtin/workflows/src/extension/workflow-command-surfaces.ts +81 -0
- package/dist/builtin/workflows/src/extension/workflow-command-utils.ts +181 -0
- package/dist/builtin/workflows/src/extension/workflow-module-loader.ts +9 -3
- package/dist/builtin/workflows/src/extension/workflow-policy.ts +15 -0
- package/dist/builtin/workflows/src/extension/workflow-ports.ts +41 -0
- package/dist/builtin/workflows/src/extension/workflow-prompts.ts +23 -0
- package/dist/builtin/workflows/src/extension/workflow-run-control-command.ts +286 -0
- package/dist/builtin/workflows/src/extension/workflow-schema.ts +1 -19
- package/dist/builtin/workflows/src/extension/workflow-stage-results.ts +264 -0
- package/dist/builtin/workflows/src/extension/workflow-targets.ts +181 -0
- package/dist/builtin/workflows/src/extension/workflow-tool-content.ts +175 -0
- package/dist/builtin/workflows/src/extension/workflow-tool-control.ts +205 -0
- package/dist/builtin/workflows/src/extension/workflow-tool-helpers.ts +66 -0
- package/dist/builtin/workflows/src/extension/workflow-tool-inspection.ts +164 -0
- package/dist/builtin/workflows/src/extension/workflow-tool-registration.ts +54 -0
- package/dist/builtin/workflows/src/extension/workflow-tool-send.ts +164 -0
- package/dist/builtin/workflows/src/extension/workflow-tool.ts +102 -0
- package/dist/builtin/workflows/src/index.ts +0 -2
- package/dist/builtin/workflows/src/runs/background/runner.ts +6 -3
- package/dist/builtin/workflows/src/runs/foreground/executor-abort.ts +431 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-child-boundary.ts +232 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-child-helpers.ts +74 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-child-workflow.ts +1 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-continuation.ts +167 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-direct-helpers.ts +450 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-direct.ts +233 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-exit-manager.ts +195 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-hil.ts +368 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-inputs.ts +83 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-lifecycle.ts +441 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-outputs.ts +160 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-prompt-nodes.ts +274 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-run-finalizers.ts +122 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-run.ts +1 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-scheduler.ts +204 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-call.ts +194 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-context.ts +120 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-control.ts +126 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-factory.ts +359 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-replay.ts +135 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-types.ts +61 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-task-context.ts +2 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-task-prompts.ts +293 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-types.ts +109 -0
- package/dist/builtin/workflows/src/runs/foreground/executor.ts +19 -5354
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-context.ts +219 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-controller.ts +500 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-messages.ts +129 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-options.ts +53 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-output.ts +146 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-session.ts +55 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-structured-output.ts +82 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-types.ts +141 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner.ts +13 -1355
- package/dist/builtin/workflows/src/runs/shared/graph-inference.ts +2 -100
- package/dist/builtin/workflows/src/runs/shared/model-fallback-candidates.ts +453 -0
- package/dist/builtin/workflows/src/runs/shared/model-fallback-failures.ts +442 -0
- package/dist/builtin/workflows/src/runs/shared/model-fallback.ts +2 -836
- package/dist/builtin/workflows/src/runs/shared/worktree-diff.ts +165 -0
- package/dist/builtin/workflows/src/runs/shared/worktree-git.ts +220 -0
- package/dist/builtin/workflows/src/runs/shared/worktree-setup.ts +335 -0
- package/dist/builtin/workflows/src/runs/shared/worktree-types.ts +92 -0
- package/dist/builtin/workflows/src/runs/shared/worktree.ts +18 -791
- package/dist/builtin/workflows/src/sdk-surface.ts +6 -9
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +371 -0
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.ts +439 -0
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +206 -0
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.ts +282 -0
- package/dist/builtin/workflows/src/shared/authoring-contract.d.ts +5 -598
- package/dist/builtin/workflows/src/shared/persistence-restore-helpers.ts +428 -0
- package/dist/builtin/workflows/src/shared/persistence-restore.ts +9 -431
- package/dist/builtin/workflows/src/shared/store-factory.ts +16 -0
- package/dist/builtin/workflows/src/shared/store-internal.ts +219 -0
- package/dist/builtin/workflows/src/shared/store-prompt-methods.ts +219 -0
- package/dist/builtin/workflows/src/shared/store-public-types.ts +215 -0
- package/dist/builtin/workflows/src/shared/store-run-methods.ts +223 -0
- package/dist/builtin/workflows/src/shared/store-stage-methods.ts +305 -0
- package/dist/builtin/workflows/src/shared/store.ts +11 -1138
- package/dist/builtin/workflows/src/shared/types.ts +25 -8
- package/dist/builtin/workflows/src/shared/workflow-authoring-types.d.ts +49 -0
- package/dist/builtin/workflows/src/shared/workflow-authoring-types.ts +84 -0
- package/dist/builtin/workflows/src/shared/workflow-failures-classifier.ts +266 -0
- package/dist/builtin/workflows/src/shared/workflow-failures-contract.ts +75 -0
- package/dist/builtin/workflows/src/shared/workflow-failures-decisions.ts +477 -0
- package/dist/builtin/workflows/src/shared/workflow-failures-signals.ts +248 -0
- package/dist/builtin/workflows/src/shared/workflow-failures.ts +13 -1001
- package/dist/builtin/workflows/src/tui/chat-surface.ts +0 -66
- package/dist/builtin/workflows/src/tui/graph-view-constants.ts +45 -0
- package/dist/builtin/workflows/src/tui/graph-view-graph-render.ts +161 -0
- package/dist/builtin/workflows/src/tui/graph-view-input.ts +333 -0
- package/dist/builtin/workflows/src/tui/graph-view-render-helpers.ts +336 -0
- package/dist/builtin/workflows/src/tui/graph-view-render.ts +194 -0
- package/dist/builtin/workflows/src/tui/graph-view-state.ts +306 -0
- package/dist/builtin/workflows/src/tui/graph-view-types.ts +70 -0
- package/dist/builtin/workflows/src/tui/graph-view.ts +4 -1386
- package/dist/builtin/workflows/src/tui/inline-form-editor-text.ts +121 -0
- package/dist/builtin/workflows/src/tui/inline-form-editor.ts +11 -223
- package/dist/builtin/workflows/src/tui/inputs-picker-editing.ts +151 -0
- package/dist/builtin/workflows/src/tui/inputs-picker-input.ts +305 -0
- package/dist/builtin/workflows/src/tui/inputs-picker-render.ts +300 -0
- package/dist/builtin/workflows/src/tui/inputs-picker-types.ts +190 -0
- package/dist/builtin/workflows/src/tui/inputs-picker.ts +19 -997
- package/dist/builtin/workflows/src/tui/prompt-card-input.ts +226 -0
- package/dist/builtin/workflows/src/tui/prompt-card-render.ts +373 -0
- package/dist/builtin/workflows/src/tui/prompt-card-select.ts +116 -0
- package/dist/builtin/workflows/src/tui/prompt-card-state.ts +61 -0
- package/dist/builtin/workflows/src/tui/prompt-card-text.ts +129 -0
- package/dist/builtin/workflows/src/tui/prompt-card.ts +8 -910
- package/dist/builtin/workflows/src/tui/stage-chat-view-archive-history.ts +315 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view-custom-ui.ts +127 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view-footer-status.ts +187 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view-input.ts +222 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view-render-helpers.ts +152 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view-state.ts +464 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view-transcript.ts +242 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view-types.ts +151 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view.ts +141 -1777
- package/dist/builtin/workflows/src/tui/workflow-attach-pane-types.ts +85 -0
- package/dist/builtin/workflows/src/tui/workflow-attach-pane.ts +1 -129
- package/dist/builtin/workflows/src/workflows/registry.ts +7 -3
- package/dist/config-self-update.d.ts +21 -0
- package/dist/config-self-update.d.ts.map +1 -0
- package/dist/config-self-update.js +265 -0
- package/dist/config-self-update.js.map +1 -0
- package/dist/config.d.ts +3 -12
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +15 -252
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-accessors.d.ts +3 -0
- package/dist/core/agent-session-accessors.d.ts.map +1 -0
- package/dist/core/agent-session-accessors.js +36 -0
- package/dist/core/agent-session-accessors.js.map +1 -0
- package/dist/core/agent-session-auto-compaction.d.ts +32 -0
- package/dist/core/agent-session-auto-compaction.d.ts.map +1 -0
- package/dist/core/agent-session-auto-compaction.js +219 -0
- package/dist/core/agent-session-auto-compaction.js.map +1 -0
- package/dist/core/agent-session-bash.d.ts +30 -0
- package/dist/core/agent-session-bash.d.ts.map +1 -0
- package/dist/core/agent-session-bash.js +79 -0
- package/dist/core/agent-session-bash.js.map +1 -0
- package/dist/core/agent-session-compaction.d.ts +44 -0
- package/dist/core/agent-session-compaction.d.ts.map +1 -0
- package/dist/core/agent-session-compaction.js +282 -0
- package/dist/core/agent-session-compaction.js.map +1 -0
- package/dist/core/agent-session-events.d.ts +65 -0
- package/dist/core/agent-session-events.d.ts.map +1 -0
- package/dist/core/agent-session-events.js +373 -0
- package/dist/core/agent-session-events.js.map +1 -0
- package/dist/core/agent-session-export.d.ts +42 -0
- package/dist/core/agent-session-export.d.ts.map +1 -0
- package/dist/core/agent-session-export.js +199 -0
- package/dist/core/agent-session-export.js.map +1 -0
- package/dist/core/agent-session-extension-bindings.d.ts +37 -0
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -0
- package/dist/core/agent-session-extension-bindings.js +231 -0
- package/dist/core/agent-session-extension-bindings.js.map +1 -0
- package/dist/core/agent-session-message-queue.d.ts +85 -0
- package/dist/core/agent-session-message-queue.d.ts.map +1 -0
- package/dist/core/agent-session-message-queue.js +264 -0
- package/dist/core/agent-session-message-queue.js.map +1 -0
- package/dist/core/agent-session-methods.d.ts +300 -0
- package/dist/core/agent-session-methods.d.ts.map +1 -0
- package/dist/core/agent-session-methods.js +2 -0
- package/dist/core/agent-session-methods.js.map +1 -0
- package/dist/core/agent-session-models.d.ts +111 -0
- package/dist/core/agent-session-models.d.ts.map +1 -0
- package/dist/core/agent-session-models.js +368 -0
- package/dist/core/agent-session-models.js.map +1 -0
- package/dist/core/agent-session-prompt.d.ts +61 -0
- package/dist/core/agent-session-prompt.d.ts.map +1 -0
- package/dist/core/agent-session-prompt.js +330 -0
- package/dist/core/agent-session-prompt.js.map +1 -0
- package/dist/core/agent-session-retry.d.ts +62 -0
- package/dist/core/agent-session-retry.d.ts.map +1 -0
- package/dist/core/agent-session-retry.js +202 -0
- package/dist/core/agent-session-retry.js.map +1 -0
- package/dist/core/agent-session-services.d.ts +0 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +0 -1
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session-skill-block.d.ts +13 -0
- package/dist/core/agent-session-skill-block.d.ts.map +1 -0
- package/dist/core/agent-session-skill-block.js +37 -0
- package/dist/core/agent-session-skill-block.js.map +1 -0
- package/dist/core/agent-session-state.d.ts +48 -0
- package/dist/core/agent-session-state.d.ts.map +1 -0
- package/dist/core/agent-session-state.js +129 -0
- package/dist/core/agent-session-state.js.map +1 -0
- package/dist/core/agent-session-tool-hooks.d.ts +7 -0
- package/dist/core/agent-session-tool-hooks.d.ts.map +1 -0
- package/dist/core/agent-session-tool-hooks.js +72 -0
- package/dist/core/agent-session-tool-hooks.js.map +1 -0
- package/dist/core/agent-session-tool-registry.d.ts +15 -0
- package/dist/core/agent-session-tool-registry.d.ts.map +1 -0
- package/dist/core/agent-session-tool-registry.js +149 -0
- package/dist/core/agent-session-tool-registry.js.map +1 -0
- package/dist/core/agent-session-tree.d.ts +46 -0
- package/dist/core/agent-session-tree.d.ts.map +1 -0
- package/dist/core/agent-session-tree.js +217 -0
- package/dist/core/agent-session-tree.js.map +1 -0
- package/dist/core/agent-session-types.d.ts +157 -0
- package/dist/core/agent-session-types.d.ts.map +1 -0
- package/dist/core/agent-session-types.js +41 -0
- package/dist/core/agent-session-types.js.map +1 -0
- package/dist/core/agent-session.d.ts +66 -688
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +26 -3153
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/atomic-guide-command.d.ts.map +1 -1
- package/dist/core/atomic-guide-command.js +1 -1
- package/dist/core/atomic-guide-command.js.map +1 -1
- package/dist/core/auth-storage-backends.d.ts +49 -0
- package/dist/core/auth-storage-backends.d.ts.map +1 -0
- package/dist/core/auth-storage-backends.js +185 -0
- package/dist/core/auth-storage-backends.js.map +1 -0
- package/dist/core/auth-storage.d.ts +2 -49
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +3 -183
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/compaction/context-compaction-metrics.d.ts +16 -0
- package/dist/core/compaction/context-compaction-metrics.d.ts.map +1 -0
- package/dist/core/compaction/context-compaction-metrics.js +58 -0
- package/dist/core/compaction/context-compaction-metrics.js.map +1 -0
- package/dist/core/compaction/context-compaction-prompt.d.ts +9 -0
- package/dist/core/compaction/context-compaction-prompt.d.ts.map +1 -0
- package/dist/core/compaction/context-compaction-prompt.js +161 -0
- package/dist/core/compaction/context-compaction-prompt.js.map +1 -0
- package/dist/core/compaction/context-compaction-runner.d.ts +5 -0
- package/dist/core/compaction/context-compaction-runner.d.ts.map +1 -0
- package/dist/core/compaction/context-compaction-runner.js +181 -0
- package/dist/core/compaction/context-compaction-runner.js.map +1 -0
- package/dist/core/compaction/context-compaction-strategy.d.ts +5 -0
- package/dist/core/compaction/context-compaction-strategy.d.ts.map +1 -0
- package/dist/core/compaction/context-compaction-strategy.js +27 -0
- package/dist/core/compaction/context-compaction-strategy.js.map +1 -0
- package/dist/core/compaction/context-compaction-types.d.ts +73 -0
- package/dist/core/compaction/context-compaction-types.d.ts.map +1 -0
- package/dist/core/compaction/context-compaction-types.js +6 -0
- package/dist/core/compaction/context-compaction-types.js.map +1 -0
- package/dist/core/compaction/context-compaction.d.ts +9 -200
- package/dist/core/compaction/context-compaction.d.ts.map +1 -1
- package/dist/core/compaction/context-compaction.js +7 -1943
- package/dist/core/compaction/context-compaction.js.map +1 -1
- package/dist/core/compaction/context-deletion-application.d.ts +13 -0
- package/dist/core/compaction/context-deletion-application.d.ts.map +1 -0
- package/dist/core/compaction/context-deletion-application.js +259 -0
- package/dist/core/compaction/context-deletion-application.js.map +1 -0
- package/dist/core/compaction/context-deletion-store.d.ts +78 -0
- package/dist/core/compaction/context-deletion-store.d.ts.map +1 -0
- package/dist/core/compaction/context-deletion-store.js +162 -0
- package/dist/core/compaction/context-deletion-store.js.map +1 -0
- package/dist/core/compaction/context-deletion-targets.d.ts +40 -0
- package/dist/core/compaction/context-deletion-targets.d.ts.map +1 -0
- package/dist/core/compaction/context-deletion-targets.js +267 -0
- package/dist/core/compaction/context-deletion-targets.js.map +1 -0
- package/dist/core/compaction/context-deletion-tool-definitions.d.ts +187 -0
- package/dist/core/compaction/context-deletion-tool-definitions.d.ts.map +1 -0
- package/dist/core/compaction/context-deletion-tool-definitions.js +98 -0
- package/dist/core/compaction/context-deletion-tool-definitions.js.map +1 -0
- package/dist/core/compaction/context-deletion-tool-helpers.d.ts +19 -0
- package/dist/core/compaction/context-deletion-tool-helpers.d.ts.map +1 -0
- package/dist/core/compaction/context-deletion-tool-helpers.js +137 -0
- package/dist/core/compaction/context-deletion-tool-helpers.js.map +1 -0
- package/dist/core/compaction/context-deletion-tools.d.ts +4 -0
- package/dist/core/compaction/context-deletion-tools.d.ts.map +1 -0
- package/dist/core/compaction/context-deletion-tools.js +395 -0
- package/dist/core/compaction/context-deletion-tools.js.map +1 -0
- package/dist/core/compaction/context-transcript-analysis.d.ts +9 -0
- package/dist/core/compaction/context-transcript-analysis.d.ts.map +1 -0
- package/dist/core/compaction/context-transcript-analysis.js +234 -0
- package/dist/core/compaction/context-transcript-analysis.js.map +1 -0
- package/dist/core/export-html/index.d.ts.map +1 -1
- package/dist/core/export-html/index.js +2 -1
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/export-html/template-js/data-tree.js +287 -0
- package/dist/core/export-html/template-js/entries-navigation.js +424 -0
- package/dist/core/export-html/template-js/initialization.js +312 -0
- package/dist/core/export-html/template-js/message-tools.js +415 -0
- package/dist/core/export-html/template-js/tree-filter-render.js +421 -0
- package/dist/core/export-html/template-script.d.ts +3 -0
- package/dist/core/export-html/template-script.d.ts.map +1 -0
- package/dist/core/export-html/template-script.js +13 -0
- package/dist/core/export-html/template-script.js.map +1 -0
- package/dist/core/export-html/template.js +3 -1
- package/dist/core/extensions/agent-events.d.ts +159 -0
- package/dist/core/extensions/agent-events.d.ts.map +1 -0
- package/dist/core/extensions/agent-events.js +2 -0
- package/dist/core/extensions/agent-events.js.map +1 -0
- package/dist/core/extensions/api-types.d.ts +189 -0
- package/dist/core/extensions/api-types.d.ts.map +1 -0
- package/dist/core/extensions/api-types.js +2 -0
- package/dist/core/extensions/api-types.js.map +1 -0
- package/dist/core/extensions/command-types.d.ts +14 -0
- package/dist/core/extensions/command-types.d.ts.map +1 -0
- package/dist/core/extensions/command-types.js +2 -0
- package/dist/core/extensions/command-types.js.map +1 -0
- package/dist/core/extensions/context-types.d.ts +130 -0
- package/dist/core/extensions/context-types.d.ts.map +1 -0
- package/dist/core/extensions/context-types.js +2 -0
- package/dist/core/extensions/context-types.js.map +1 -0
- package/dist/core/extensions/event-results.d.ts +61 -0
- package/dist/core/extensions/event-results.d.ts.map +1 -0
- package/dist/core/extensions/event-results.js +2 -0
- package/dist/core/extensions/event-results.js.map +1 -0
- package/dist/core/extensions/event-types.d.ts +6 -0
- package/dist/core/extensions/event-types.d.ts.map +1 -0
- package/dist/core/extensions/event-types.js +2 -0
- package/dist/core/extensions/event-types.js.map +1 -0
- package/dist/core/extensions/loader-api.d.ts +10 -0
- package/dist/core/extensions/loader-api.d.ts.map +1 -0
- package/dist/core/extensions/loader-api.js +143 -0
- package/dist/core/extensions/loader-api.js.map +1 -0
- package/dist/core/extensions/loader-core.d.ts +10 -0
- package/dist/core/extensions/loader-core.d.ts.map +1 -0
- package/dist/core/extensions/loader-core.js +98 -0
- package/dist/core/extensions/loader-core.js.map +1 -0
- package/dist/core/extensions/loader-discovery.d.ts +7 -0
- package/dist/core/extensions/loader-discovery.d.ts.map +1 -0
- package/dist/core/extensions/loader-discovery.js +139 -0
- package/dist/core/extensions/loader-discovery.js.map +1 -0
- package/dist/core/extensions/loader-resources.d.ts +11 -0
- package/dist/core/extensions/loader-resources.d.ts.map +1 -0
- package/dist/core/extensions/loader-resources.js +10 -0
- package/dist/core/extensions/loader-resources.js.map +1 -0
- package/dist/core/extensions/loader-runtime.d.ts +7 -0
- package/dist/core/extensions/loader-runtime.d.ts.map +1 -0
- package/dist/core/extensions/loader-runtime.js +51 -0
- package/dist/core/extensions/loader-runtime.js.map +1 -0
- package/dist/core/extensions/loader-virtual-modules.d.ts +9 -0
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -0
- package/dist/core/extensions/loader-virtual-modules.js +124 -0
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -0
- package/dist/core/extensions/loader.d.ts +5 -28
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +4 -542
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/message-types.d.ts +34 -0
- package/dist/core/extensions/message-types.d.ts.map +1 -0
- package/dist/core/extensions/message-types.js +2 -0
- package/dist/core/extensions/message-types.js.map +1 -0
- package/dist/core/extensions/provider-types.d.ts +71 -0
- package/dist/core/extensions/provider-types.d.ts.map +1 -0
- package/dist/core/extensions/provider-types.js +2 -0
- package/dist/core/extensions/provider-types.js.map +1 -0
- package/dist/core/extensions/runner-context.d.ts +42 -0
- package/dist/core/extensions/runner-context.d.ts.map +1 -0
- package/dist/core/extensions/runner-context.js +112 -0
- package/dist/core/extensions/runner-context.js.map +1 -0
- package/dist/core/extensions/runner-events.d.ts +47 -0
- package/dist/core/extensions/runner-events.d.ts.map +1 -0
- package/dist/core/extensions/runner-events.js +280 -0
- package/dist/core/extensions/runner-events.js.map +1 -0
- package/dist/core/extensions/runner-handlers.d.ts +32 -0
- package/dist/core/extensions/runner-handlers.d.ts.map +1 -0
- package/dist/core/extensions/runner-handlers.js +2 -0
- package/dist/core/extensions/runner-handlers.js.map +1 -0
- package/dist/core/extensions/runner-project-trust.d.ts +6 -0
- package/dist/core/extensions/runner-project-trust.d.ts.map +1 -0
- package/dist/core/extensions/runner-project-trust.js +27 -0
- package/dist/core/extensions/runner-project-trust.js.map +1 -0
- package/dist/core/extensions/runner-registries.d.ts +8 -0
- package/dist/core/extensions/runner-registries.d.ts.map +1 -0
- package/dist/core/extensions/runner-registries.js +76 -0
- package/dist/core/extensions/runner-registries.js.map +1 -0
- package/dist/core/extensions/runner-shortcuts.d.ts +10 -0
- package/dist/core/extensions/runner-shortcuts.d.ts.map +1 -0
- package/dist/core/extensions/runner-shortcuts.js +71 -0
- package/dist/core/extensions/runner-shortcuts.js.map +1 -0
- package/dist/core/extensions/runner-ui.d.ts +3 -0
- package/dist/core/extensions/runner-ui.d.ts.map +1 -0
- package/dist/core/extensions/runner-ui.js +50 -0
- package/dist/core/extensions/runner-ui.js.map +1 -0
- package/dist/core/extensions/runner.d.ts +7 -74
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +67 -673
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/runtime-types.d.ts +179 -0
- package/dist/core/extensions/runtime-types.d.ts.map +1 -0
- package/dist/core/extensions/runtime-types.js +2 -0
- package/dist/core/extensions/runtime-types.js.map +1 -0
- package/dist/core/extensions/session-events.d.ts +89 -0
- package/dist/core/extensions/session-events.d.ts.map +1 -0
- package/dist/core/extensions/session-events.js +2 -0
- package/dist/core/extensions/session-events.js.map +1 -0
- package/dist/core/extensions/tool-events.d.ts +127 -0
- package/dist/core/extensions/tool-events.d.ts.map +1 -0
- package/dist/core/extensions/tool-events.js +26 -0
- package/dist/core/extensions/tool-events.js.map +1 -0
- package/dist/core/extensions/tool-types.d.ts +100 -0
- package/dist/core/extensions/tool-types.d.ts.map +1 -0
- package/dist/core/extensions/tool-types.js +11 -0
- package/dist/core/extensions/tool-types.js.map +1 -0
- package/dist/core/extensions/types.d.ts +20 -1288
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js +4 -34
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/extensions/ui-types.d.ts +200 -0
- package/dist/core/extensions/ui-types.d.ts.map +1 -0
- package/dist/core/extensions/ui-types.js +2 -0
- package/dist/core/extensions/ui-types.js.map +1 -0
- package/dist/core/index.d.ts +0 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +0 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/model-registry-auth.d.ts +7 -0
- package/dist/core/model-registry-auth.d.ts.map +1 -0
- package/dist/core/model-registry-auth.js +64 -0
- package/dist/core/model-registry-auth.js.map +1 -0
- package/dist/core/model-registry-builtins.d.ts +9 -0
- package/dist/core/model-registry-builtins.d.ts.map +1 -0
- package/dist/core/model-registry-builtins.js +126 -0
- package/dist/core/model-registry-builtins.js.map +1 -0
- package/dist/core/model-registry-custom-loader.d.ts +3 -0
- package/dist/core/model-registry-custom-loader.d.ts.map +1 -0
- package/dist/core/model-registry-custom-loader.js +213 -0
- package/dist/core/model-registry-custom-loader.js.map +1 -0
- package/dist/core/model-registry-dynamic.d.ts +6 -0
- package/dist/core/model-registry-dynamic.d.ts.map +1 -0
- package/dist/core/model-registry-dynamic.js +155 -0
- package/dist/core/model-registry-dynamic.js.map +1 -0
- package/dist/core/model-registry-loader.d.ts +4 -0
- package/dist/core/model-registry-loader.d.ts.map +1 -0
- package/dist/core/model-registry-loader.js +20 -0
- package/dist/core/model-registry-loader.js.map +1 -0
- package/dist/core/model-registry-schemas.d.ts +1136 -0
- package/dist/core/model-registry-schemas.d.ts.map +1 -0
- package/dist/core/model-registry-schemas.js +171 -0
- package/dist/core/model-registry-schemas.js.map +1 -0
- package/dist/core/model-registry-types.d.ts +74 -0
- package/dist/core/model-registry-types.d.ts.map +1 -0
- package/dist/core/model-registry-types.js +2 -0
- package/dist/core/model-registry-types.js.map +1 -0
- package/dist/core/model-registry.d.ts +3 -76
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +24 -733
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver-cli.d.ts +19 -0
- package/dist/core/model-resolver-cli.d.ts.map +1 -0
- package/dist/core/model-resolver-cli.js +118 -0
- package/dist/core/model-resolver-cli.js.map +1 -0
- package/dist/core/model-resolver-defaults.d.ts +5 -0
- package/dist/core/model-resolver-defaults.d.ts.map +1 -0
- package/dist/core/model-resolver-defaults.js +47 -0
- package/dist/core/model-resolver-defaults.js.map +1 -0
- package/dist/core/model-resolver-initial.d.ts +31 -0
- package/dist/core/model-resolver-initial.d.ts.map +1 -0
- package/dist/core/model-resolver-initial.js +116 -0
- package/dist/core/model-resolver-initial.js.map +1 -0
- package/dist/core/model-resolver-patterns.d.ts +26 -0
- package/dist/core/model-resolver-patterns.d.ts.map +1 -0
- package/dist/core/model-resolver-patterns.js +139 -0
- package/dist/core/model-resolver-patterns.js.map +1 -0
- package/dist/core/model-resolver-scope.d.ts +15 -0
- package/dist/core/model-resolver-scope.d.ts.map +1 -0
- package/dist/core/model-resolver-scope.js +66 -0
- package/dist/core/model-resolver-scope.js.map +1 -0
- package/dist/core/model-resolver-types.d.ts +29 -0
- package/dist/core/model-resolver-types.d.ts.map +1 -0
- package/dist/core/model-resolver-types.js +2 -0
- package/dist/core/model-resolver-types.js.map +1 -0
- package/dist/core/model-resolver.d.ts +6 -107
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +5 -549
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/package-manager-auto-resources.d.ts +5 -0
- package/dist/core/package-manager-auto-resources.d.ts.map +1 -0
- package/dist/core/package-manager-auto-resources.js +109 -0
- package/dist/core/package-manager-auto-resources.js.map +1 -0
- package/dist/core/package-manager-command.d.ts +11 -0
- package/dist/core/package-manager-command.d.ts.map +1 -0
- package/dist/core/package-manager-command.js +102 -0
- package/dist/core/package-manager-command.js.map +1 -0
- package/dist/core/package-manager-constants.d.ts +4 -0
- package/dist/core/package-manager-constants.d.ts.map +1 -0
- package/dist/core/package-manager-constants.js +4 -0
- package/dist/core/package-manager-constants.js.map +1 -0
- package/dist/core/package-manager-env.d.ts +4 -0
- package/dist/core/package-manager-env.d.ts.map +1 -0
- package/dist/core/package-manager-env.js +40 -0
- package/dist/core/package-manager-env.js.map +1 -0
- package/dist/core/package-manager-git.d.ts +10 -0
- package/dist/core/package-manager-git.d.ts.map +1 -0
- package/dist/core/package-manager-git.js +271 -0
- package/dist/core/package-manager-git.js.map +1 -0
- package/dist/core/package-manager-manifest.d.ts +7 -0
- package/dist/core/package-manager-manifest.d.ts.map +1 -0
- package/dist/core/package-manager-manifest.js +45 -0
- package/dist/core/package-manager-manifest.js.map +1 -0
- package/dist/core/package-manager-npm.d.ts +25 -0
- package/dist/core/package-manager-npm.d.ts.map +1 -0
- package/dist/core/package-manager-npm.js +252 -0
- package/dist/core/package-manager-npm.js.map +1 -0
- package/dist/core/package-manager-operations.d.ts +11 -0
- package/dist/core/package-manager-operations.d.ts.map +1 -0
- package/dist/core/package-manager-operations.js +196 -0
- package/dist/core/package-manager-operations.js.map +1 -0
- package/dist/core/package-manager-paths.d.ts +14 -0
- package/dist/core/package-manager-paths.d.ts.map +1 -0
- package/dist/core/package-manager-paths.js +61 -0
- package/dist/core/package-manager-paths.js.map +1 -0
- package/dist/core/package-manager-progress.d.ts +4 -0
- package/dist/core/package-manager-progress.d.ts.map +1 -0
- package/dist/core/package-manager-progress.js +16 -0
- package/dist/core/package-manager-progress.js.map +1 -0
- package/dist/core/package-manager-resolver.d.ts +5 -0
- package/dist/core/package-manager-resolver.d.ts.map +1 -0
- package/dist/core/package-manager-resolver.js +149 -0
- package/dist/core/package-manager-resolver.js.map +1 -0
- package/dist/core/package-manager-resource-accumulator.d.ts +6 -0
- package/dist/core/package-manager-resource-accumulator.d.ts.map +1 -0
- package/dist/core/package-manager-resource-accumulator.js +67 -0
- package/dist/core/package-manager-resource-accumulator.js.map +1 -0
- package/dist/core/package-manager-resource-collector.d.ts +5 -0
- package/dist/core/package-manager-resource-collector.d.ts.map +1 -0
- package/dist/core/package-manager-resource-collector.js +148 -0
- package/dist/core/package-manager-resource-collector.js.map +1 -0
- package/dist/core/package-manager-resource-files.d.ts +14 -0
- package/dist/core/package-manager-resource-files.d.ts.map +1 -0
- package/dist/core/package-manager-resource-files.js +265 -0
- package/dist/core/package-manager-resource-files.js.map +1 -0
- package/dist/core/package-manager-resource-patterns.d.ts +12 -0
- package/dist/core/package-manager-resource-patterns.d.ts.map +1 -0
- package/dist/core/package-manager-resource-patterns.js +136 -0
- package/dist/core/package-manager-resource-patterns.js.map +1 -0
- package/dist/core/package-manager-settings.d.ts +10 -0
- package/dist/core/package-manager-settings.d.ts.map +1 -0
- package/dist/core/package-manager-settings.js +91 -0
- package/dist/core/package-manager-settings.js.map +1 -0
- package/dist/core/package-manager-source.d.ts +21 -0
- package/dist/core/package-manager-source.d.ts.map +1 -0
- package/dist/core/package-manager-source.js +146 -0
- package/dist/core/package-manager-source.js.map +1 -0
- package/dist/core/package-manager-types.d.ts +169 -0
- package/dist/core/package-manager-types.d.ts.map +1 -0
- package/dist/core/package-manager-types.js +9 -0
- package/dist/core/package-manager-types.js.map +1 -0
- package/dist/core/package-manager.d.ts +9 -174
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +56 -2100
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/resource-loader-assets.d.ts +6 -0
- package/dist/core/resource-loader-assets.d.ts.map +1 -0
- package/dist/core/resource-loader-assets.js +209 -0
- package/dist/core/resource-loader-assets.js.map +1 -0
- package/dist/core/resource-loader-context-files.d.ts +10 -0
- package/dist/core/resource-loader-context-files.d.ts.map +1 -0
- package/dist/core/resource-loader-context-files.js +74 -0
- package/dist/core/resource-loader-context-files.js.map +1 -0
- package/dist/core/resource-loader-core.d.ts +83 -0
- package/dist/core/resource-loader-core.d.ts.map +1 -0
- package/dist/core/resource-loader-core.js +170 -0
- package/dist/core/resource-loader-core.js.map +1 -0
- package/dist/core/resource-loader-discovery.d.ts +4 -0
- package/dist/core/resource-loader-discovery.d.ts.map +1 -0
- package/dist/core/resource-loader-discovery.js +28 -0
- package/dist/core/resource-loader-discovery.js.map +1 -0
- package/dist/core/resource-loader-extensions.d.ts +13 -0
- package/dist/core/resource-loader-extensions.d.ts.map +1 -0
- package/dist/core/resource-loader-extensions.js +110 -0
- package/dist/core/resource-loader-extensions.js.map +1 -0
- package/dist/core/resource-loader-helpers.d.ts +4 -0
- package/dist/core/resource-loader-helpers.d.ts.map +1 -0
- package/dist/core/resource-loader-helpers.js +23 -0
- package/dist/core/resource-loader-helpers.js.map +1 -0
- package/dist/core/resource-loader-internals.d.ts +97 -0
- package/dist/core/resource-loader-internals.d.ts.map +1 -0
- package/dist/core/resource-loader-internals.js +4 -0
- package/dist/core/resource-loader-internals.js.map +1 -0
- package/dist/core/resource-loader-package-resources.d.ts +31 -0
- package/dist/core/resource-loader-package-resources.d.ts.map +1 -0
- package/dist/core/resource-loader-package-resources.js +112 -0
- package/dist/core/resource-loader-package-resources.js.map +1 -0
- package/dist/core/resource-loader-paths.d.ts +4 -0
- package/dist/core/resource-loader-paths.d.ts.map +1 -0
- package/dist/core/resource-loader-paths.js +22 -0
- package/dist/core/resource-loader-paths.js.map +1 -0
- package/dist/core/resource-loader-reload.d.ts +6 -0
- package/dist/core/resource-loader-reload.d.ts.map +1 -0
- package/dist/core/resource-loader-reload.js +230 -0
- package/dist/core/resource-loader-reload.js.map +1 -0
- package/dist/core/resource-loader-source-info.d.ts +9 -0
- package/dist/core/resource-loader-source-info.d.ts.map +1 -0
- package/dist/core/resource-loader-source-info.js +101 -0
- package/dist/core/resource-loader-source-info.js.map +1 -0
- package/dist/core/resource-loader-types.d.ts +130 -0
- package/dist/core/resource-loader-types.d.ts.map +1 -0
- package/dist/core/resource-loader-types.js +2 -0
- package/dist/core/resource-loader-types.js.map +1 -0
- package/dist/core/resource-loader.d.ts +3 -242
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +2 -976
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sdk-exports.d.ts +7 -0
- package/dist/core/sdk-exports.d.ts.map +1 -0
- package/dist/core/sdk-exports.js +5 -0
- package/dist/core/sdk-exports.js.map +1 -0
- package/dist/core/sdk-types.d.ts +83 -0
- package/dist/core/sdk-types.d.ts.map +1 -0
- package/dist/core/sdk-types.js +2 -0
- package/dist/core/sdk-types.js.map +1 -0
- package/dist/core/sdk.d.ts +3 -91
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +2 -7
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager-archive.d.ts +27 -0
- package/dist/core/session-manager-archive.d.ts.map +1 -0
- package/dist/core/session-manager-archive.js +114 -0
- package/dist/core/session-manager-archive.js.map +1 -0
- package/dist/core/session-manager-core.d.ts +104 -0
- package/dist/core/session-manager-core.d.ts.map +1 -0
- package/dist/core/session-manager-core.js +346 -0
- package/dist/core/session-manager-core.js.map +1 -0
- package/dist/core/session-manager-entries.d.ts +38 -0
- package/dist/core/session-manager-entries.d.ts.map +1 -0
- package/dist/core/session-manager-entries.js +124 -0
- package/dist/core/session-manager-entries.js.map +1 -0
- package/dist/core/session-manager-history.d.ts +38 -0
- package/dist/core/session-manager-history.d.ts.map +1 -0
- package/dist/core/session-manager-history.js +379 -0
- package/dist/core/session-manager-history.js.map +1 -0
- package/dist/core/session-manager-list.d.ts +5 -0
- package/dist/core/session-manager-list.d.ts.map +1 -0
- package/dist/core/session-manager-list.js +196 -0
- package/dist/core/session-manager-list.js.map +1 -0
- package/dist/core/session-manager-migrations.d.ts +11 -0
- package/dist/core/session-manager-migrations.d.ts.map +1 -0
- package/dist/core/session-manager-migrations.js +80 -0
- package/dist/core/session-manager-migrations.js.map +1 -0
- package/dist/core/session-manager-paths.d.ts +7 -0
- package/dist/core/session-manager-paths.d.ts.map +1 -0
- package/dist/core/session-manager-paths.js +22 -0
- package/dist/core/session-manager-paths.js.map +1 -0
- package/dist/core/session-manager-storage.d.ts +15 -0
- package/dist/core/session-manager-storage.d.ts.map +1 -0
- package/dist/core/session-manager-storage.js +127 -0
- package/dist/core/session-manager-storage.js.map +1 -0
- package/dist/core/session-manager-types.d.ts +172 -0
- package/dist/core/session-manager-types.d.ts.map +1 -0
- package/dist/core/session-manager-types.js +2 -0
- package/dist/core/session-manager-types.js.map +1 -0
- package/dist/core/session-manager-validation.d.ts +7 -0
- package/dist/core/session-manager-validation.d.ts.map +1 -0
- package/dist/core/session-manager-validation.js +34 -0
- package/dist/core/session-manager-validation.js.map +1 -0
- package/dist/core/session-manager.d.ts +8 -390
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +7 -1418
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager-basic-accessors.d.ts +65 -0
- package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -0
- package/dist/core/settings-manager-basic-accessors.js +253 -0
- package/dist/core/settings-manager-basic-accessors.js.map +1 -0
- package/dist/core/settings-manager-core.d.ts +57 -0
- package/dist/core/settings-manager-core.d.ts.map +1 -0
- package/dist/core/settings-manager-core.js +387 -0
- package/dist/core/settings-manager-core.js.map +1 -0
- package/dist/core/settings-manager-internals.d.ts +13 -0
- package/dist/core/settings-manager-internals.d.ts.map +1 -0
- package/dist/core/settings-manager-internals.js +4 -0
- package/dist/core/settings-manager-internals.js.map +1 -0
- package/dist/core/settings-manager-resource-accessors.d.ts +43 -0
- package/dist/core/settings-manager-resource-accessors.d.ts.map +1 -0
- package/dist/core/settings-manager-resource-accessors.js +172 -0
- package/dist/core/settings-manager-resource-accessors.js.map +1 -0
- package/dist/core/settings-manager-ui-accessors.d.ts +44 -0
- package/dist/core/settings-manager-ui-accessors.d.ts.map +1 -0
- package/dist/core/settings-manager-ui-accessors.js +208 -0
- package/dist/core/settings-manager-ui-accessors.js.map +1 -0
- package/dist/core/settings-manager.d.ts +6 -321
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +5 -1060
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/settings-merge.d.ts +4 -0
- package/dist/core/settings-merge.d.ts.map +1 -0
- package/dist/core/settings-merge.js +26 -0
- package/dist/core/settings-merge.js.map +1 -0
- package/dist/core/settings-storage.d.ts +20 -0
- package/dist/core/settings-storage.d.ts.map +1 -0
- package/dist/core/settings-storage.js +100 -0
- package/dist/core/settings-storage.js.map +1 -0
- package/dist/core/settings-types.d.ts +123 -0
- package/dist/core/settings-types.d.ts.map +1 -0
- package/dist/core/settings-types.js +2 -0
- package/dist/core/settings-types.js.map +1 -0
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +7 -0
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts +0 -5
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +10 -11
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit-diff-preserve.d.ts +18 -0
- package/dist/core/tools/edit-diff-preserve.d.ts.map +1 -0
- package/dist/core/tools/edit-diff-preserve.js +85 -0
- package/dist/core/tools/edit-diff-preserve.js.map +1 -0
- package/dist/core/tools/edit-diff.d.ts +3 -2
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js +15 -18
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/index.d.ts +0 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +0 -1
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/todos-execute.d.ts +5 -0
- package/dist/core/tools/todos-execute.d.ts.map +1 -0
- package/dist/core/tools/todos-execute.js +200 -0
- package/dist/core/tools/todos-execute.js.map +1 -0
- package/dist/core/tools/todos-locks.d.ts +4 -0
- package/dist/core/tools/todos-locks.d.ts.map +1 -0
- package/dist/core/tools/todos-locks.js +80 -0
- package/dist/core/tools/todos-locks.js.map +1 -0
- package/dist/core/tools/todos-model.d.ts +21 -0
- package/dist/core/tools/todos-model.d.ts.map +1 -0
- package/dist/core/tools/todos-model.js +71 -0
- package/dist/core/tools/todos-model.js.map +1 -0
- package/dist/core/tools/todos-mutations.d.ts +6 -0
- package/dist/core/tools/todos-mutations.d.ts.map +1 -0
- package/dist/core/tools/todos-mutations.js +85 -0
- package/dist/core/tools/todos-mutations.js.map +1 -0
- package/dist/core/tools/todos-paths.d.ts +5 -0
- package/dist/core/tools/todos-paths.d.ts.map +1 -0
- package/dist/core/tools/todos-paths.js +25 -0
- package/dist/core/tools/todos-paths.js.map +1 -0
- package/dist/core/tools/todos-render.d.ts +10 -0
- package/dist/core/tools/todos-render.d.ts.map +1 -0
- package/dist/core/tools/todos-render.js +159 -0
- package/dist/core/tools/todos-render.js.map +1 -0
- package/dist/core/tools/todos-storage.d.ts +9 -0
- package/dist/core/tools/todos-storage.d.ts.map +1 -0
- package/dist/core/tools/todos-storage.js +183 -0
- package/dist/core/tools/todos-storage.js.map +1 -0
- package/dist/core/tools/todos-types.d.ts +46 -0
- package/dist/core/tools/todos-types.d.ts.map +1 -0
- package/dist/core/tools/todos-types.js +27 -0
- package/dist/core/tools/todos-types.js.map +1 -0
- package/dist/core/tools/todos.d.ts +12 -32
- package/dist/core/tools/todos.d.ts.map +1 -1
- package/dist/core/tools/todos.js +7 -893
- package/dist/core/tools/todos.js.map +1 -1
- package/dist/index-extensions.d.ts +3 -0
- package/dist/index-extensions.d.ts.map +1 -0
- package/dist/index-extensions.js +2 -0
- package/dist/index-extensions.js.map +1 -0
- package/dist/index.d.ts +3 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/main-app-mode.d.ts +15 -0
- package/dist/main-app-mode.d.ts.map +1 -0
- package/dist/main-app-mode.js +51 -0
- package/dist/main-app-mode.js.map +1 -0
- package/dist/main-session-options.d.ts +12 -0
- package/dist/main-session-options.d.ts.map +1 -0
- package/dist/main-session-options.js +87 -0
- package/dist/main-session-options.js.map +1 -0
- package/dist/main-session.d.ts +9 -0
- package/dist/main-session.d.ts.map +1 -0
- package/dist/main-session.js +188 -0
- package/dist/main-session.js.map +1 -0
- package/dist/main-stdio.d.ts +12 -0
- package/dist/main-stdio.d.ts.map +1 -0
- package/dist/main-stdio.js +68 -0
- package/dist/main-stdio.js.map +1 -0
- package/dist/main.d.ts +2 -3
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +11 -388
- package/dist/main.js.map +1 -1
- package/dist/migrations-config-values.d.ts +9 -0
- package/dist/migrations-config-values.d.ts.map +1 -0
- package/dist/migrations-config-values.js +298 -0
- package/dist/migrations-config-values.js.map +1 -0
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +2 -296
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.js +0 -7
- package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-actions.d.ts +9 -0
- package/dist/modes/interactive/components/chat-session-host-actions.d.ts.map +1 -0
- package/dist/modes/interactive/components/chat-session-host-actions.js +244 -0
- package/dist/modes/interactive/components/chat-session-host-actions.js.map +1 -0
- package/dist/modes/interactive/components/chat-session-host-editor.d.ts +18 -0
- package/dist/modes/interactive/components/chat-session-host-editor.d.ts.map +1 -0
- package/dist/modes/interactive/components/chat-session-host-editor.js +165 -0
- package/dist/modes/interactive/components/chat-session-host-editor.js.map +1 -0
- package/dist/modes/interactive/components/chat-session-host-events.d.ts +5 -0
- package/dist/modes/interactive/components/chat-session-host-events.d.ts.map +1 -0
- package/dist/modes/interactive/components/chat-session-host-events.js +200 -0
- package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -0
- package/dist/modes/interactive/components/chat-session-host-rendering.d.ts +13 -0
- package/dist/modes/interactive/components/chat-session-host-rendering.d.ts.map +1 -0
- package/dist/modes/interactive/components/chat-session-host-rendering.js +185 -0
- package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -0
- package/dist/modes/interactive/components/chat-session-host-runtime.d.ts +13 -0
- package/dist/modes/interactive/components/chat-session-host-runtime.d.ts.map +1 -0
- package/dist/modes/interactive/components/chat-session-host-runtime.js +101 -0
- package/dist/modes/interactive/components/chat-session-host-runtime.js.map +1 -0
- package/dist/modes/interactive/components/chat-session-host-state.d.ts +53 -0
- package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -0
- package/dist/modes/interactive/components/chat-session-host-state.js +42 -0
- package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -0
- package/dist/modes/interactive/components/chat-session-host-types.d.ts +63 -0
- package/dist/modes/interactive/components/chat-session-host-types.d.ts.map +1 -0
- package/dist/modes/interactive/components/chat-session-host-types.js +2 -0
- package/dist/modes/interactive/components/chat-session-host-types.js.map +1 -0
- package/dist/modes/interactive/components/chat-session-host-utils.d.ts +28 -0
- package/dist/modes/interactive/components/chat-session-host-utils.d.ts.map +1 -0
- package/dist/modes/interactive/components/chat-session-host-utils.js +103 -0
- package/dist/modes/interactive/components/chat-session-host-utils.js.map +1 -0
- package/dist/modes/interactive/components/chat-session-host.d.ts +6 -129
- package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.js +50 -1022
- package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
- package/dist/modes/interactive/components/config-selector-list.d.ts +65 -0
- package/dist/modes/interactive/components/config-selector-list.d.ts.map +1 -0
- package/dist/modes/interactive/components/config-selector-list.js +458 -0
- package/dist/modes/interactive/components/config-selector-list.js.map +1 -0
- package/dist/modes/interactive/components/config-selector.d.ts +3 -58
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +2 -457
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +2 -2
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-delete.d.ts +10 -0
- package/dist/modes/interactive/components/session-selector-delete.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector-delete.js +40 -0
- package/dist/modes/interactive/components/session-selector-delete.js.map +1 -0
- package/dist/modes/interactive/components/session-selector-header.d.ts +33 -0
- package/dist/modes/interactive/components/session-selector-header.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector-header.js +117 -0
- package/dist/modes/interactive/components/session-selector-header.js.map +1 -0
- package/dist/modes/interactive/components/session-selector-list.d.ts +49 -0
- package/dist/modes/interactive/components/session-selector-list.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector-list.js +307 -0
- package/dist/modes/interactive/components/session-selector-list.js.map +1 -0
- package/dist/modes/interactive/components/session-selector-tree.d.ts +25 -0
- package/dist/modes/interactive/components/session-selector-tree.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector-tree.js +53 -0
- package/dist/modes/interactive/components/session-selector-tree.js.map +1 -0
- package/dist/modes/interactive/components/session-selector-types.d.ts +4 -0
- package/dist/modes/interactive/components/session-selector-types.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector-types.js +2 -0
- package/dist/modes/interactive/components/session-selector-types.js.map +1 -0
- package/dist/modes/interactive/components/session-selector-utils.d.ts +4 -0
- package/dist/modes/interactive/components/session-selector-utils.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector-utils.js +37 -0
- package/dist/modes/interactive/components/session-selector-utils.js.map +1 -0
- package/dist/modes/interactive/components/session-selector.d.ts +3 -49
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +5 -542
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-handlers.d.ts +3 -0
- package/dist/modes/interactive/components/settings-selector-handlers.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-selector-handlers.js +84 -0
- package/dist/modes/interactive/components/settings-selector-handlers.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector-items.d.ts +4 -0
- package/dist/modes/interactive/components/settings-selector-items.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-selector-items.js +211 -0
- package/dist/modes/interactive/components/settings-selector-items.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector-options.d.ts +6 -0
- package/dist/modes/interactive/components/settings-selector-options.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-selector-options.js +14 -0
- package/dist/modes/interactive/components/settings-selector-options.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector-submenus.d.ts +44 -0
- package/dist/modes/interactive/components/settings-selector-submenus.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-selector-submenus.js +228 -0
- package/dist/modes/interactive/components/settings-selector-submenus.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector-types.d.ts +67 -0
- package/dist/modes/interactive/components/settings-selector-types.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-selector-types.js +2 -0
- package/dist/modes/interactive/components/settings-selector-types.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +2 -63
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +5 -538
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-component.d.ts +21 -0
- package/dist/modes/interactive/components/tree-selector-component.d.ts.map +1 -0
- package/dist/modes/interactive/components/tree-selector-component.js +80 -0
- package/dist/modes/interactive/components/tree-selector-component.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector-content.d.ts +8 -0
- package/dist/modes/interactive/components/tree-selector-content.d.ts.map +1 -0
- package/dist/modes/interactive/components/tree-selector-content.js +263 -0
- package/dist/modes/interactive/components/tree-selector-content.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector-help.d.ts +16 -0
- package/dist/modes/interactive/components/tree-selector-help.d.ts.map +1 -0
- package/dist/modes/interactive/components/tree-selector-help.js +103 -0
- package/dist/modes/interactive/components/tree-selector-help.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector-label-input.d.ts +16 -0
- package/dist/modes/interactive/components/tree-selector-label-input.d.ts.map +1 -0
- package/dist/modes/interactive/components/tree-selector-label-input.js +46 -0
- package/dist/modes/interactive/components/tree-selector-label-input.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector-list.d.ts +33 -0
- package/dist/modes/interactive/components/tree-selector-list.d.ts.map +1 -0
- package/dist/modes/interactive/components/tree-selector-list.js +336 -0
- package/dist/modes/interactive/components/tree-selector-list.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector-model.d.ts +7 -0
- package/dist/modes/interactive/components/tree-selector-model.d.ts.map +1 -0
- package/dist/modes/interactive/components/tree-selector-model.js +358 -0
- package/dist/modes/interactive/components/tree-selector-model.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector-types.d.ts +57 -0
- package/dist/modes/interactive/components/tree-selector-types.d.ts.map +1 -0
- package/dist/modes/interactive/components/tree-selector-types.js +6 -0
- package/dist/modes/interactive/components/tree-selector-types.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector-viewport.d.ts +10 -0
- package/dist/modes/interactive/components/tree-selector-viewport.d.ts.map +1 -0
- package/dist/modes/interactive/components/tree-selector-viewport.js +32 -0
- package/dist/modes/interactive/components/tree-selector-viewport.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector.d.ts +2 -88
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +1 -1200
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.d.ts +2 -0
- package/dist/modes/interactive/interactive-agent-events.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-agent-events.js +370 -0
- package/dist/modes/interactive/interactive-agent-events.js.map +1 -0
- package/dist/modes/interactive/interactive-auth-login.d.ts +2 -0
- package/dist/modes/interactive/interactive-auth-login.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-auth-login.js +214 -0
- package/dist/modes/interactive/interactive-auth-login.js.map +1 -0
- package/dist/modes/interactive/interactive-auth-routing.d.ts +2 -0
- package/dist/modes/interactive/interactive-auth-routing.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-auth-routing.js +128 -0
- package/dist/modes/interactive/interactive-auth-routing.js.map +1 -0
- package/dist/modes/interactive/interactive-autocomplete.d.ts +2 -0
- package/dist/modes/interactive/interactive-autocomplete.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-autocomplete.js +140 -0
- package/dist/modes/interactive/interactive-autocomplete.js.map +1 -0
- package/dist/modes/interactive/interactive-bash-compact.d.ts +2 -0
- package/dist/modes/interactive/interactive-bash-compact.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-bash-compact.js +112 -0
- package/dist/modes/interactive/interactive-bash-compact.js.map +1 -0
- package/dist/modes/interactive/interactive-editor-actions.d.ts +2 -0
- package/dist/modes/interactive/interactive-editor-actions.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-editor-actions.js +131 -0
- package/dist/modes/interactive/interactive-editor-actions.js.map +1 -0
- package/dist/modes/interactive/interactive-extension-context.d.ts +2 -0
- package/dist/modes/interactive/interactive-extension-context.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-extension-context.js +159 -0
- package/dist/modes/interactive/interactive-extension-context.js.map +1 -0
- package/dist/modes/interactive/interactive-extension-custom-ui.d.ts +2 -0
- package/dist/modes/interactive/interactive-extension-custom-ui.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-extension-custom-ui.js +208 -0
- package/dist/modes/interactive/interactive-extension-custom-ui.js.map +1 -0
- package/dist/modes/interactive/interactive-extension-dialogs.d.ts +2 -0
- package/dist/modes/interactive/interactive-extension-dialogs.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-extension-dialogs.js +162 -0
- package/dist/modes/interactive/interactive-extension-dialogs.js.map +1 -0
- package/dist/modes/interactive/interactive-extension-runtime.d.ts +2 -0
- package/dist/modes/interactive/interactive-extension-runtime.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-extension-runtime.js +179 -0
- package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -0
- package/dist/modes/interactive/interactive-extension-widgets.d.ts +2 -0
- package/dist/modes/interactive/interactive-extension-widgets.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-extension-widgets.js +113 -0
- package/dist/modes/interactive/interactive-extension-widgets.js.map +1 -0
- package/dist/modes/interactive/interactive-hotkeys-debug.d.ts +2 -0
- package/dist/modes/interactive/interactive-hotkeys-debug.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-hotkeys-debug.js +186 -0
- package/dist/modes/interactive/interactive-hotkeys-debug.js.map +1 -0
- package/dist/modes/interactive/interactive-input-handling.d.ts +2 -0
- package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-input-handling.js +275 -0
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -0
- package/dist/modes/interactive/interactive-mode-base.d.ts +103 -0
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-mode-base.js +130 -0
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -0
- package/dist/modes/interactive/interactive-mode-deps.d.ts +81 -0
- package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-mode-deps.js +74 -0
- package/dist/modes/interactive/interactive-mode-deps.js.map +1 -0
- package/dist/modes/interactive/interactive-mode-helpers.d.ts +21 -0
- package/dist/modes/interactive/interactive-mode-helpers.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-mode-helpers.js +77 -0
- package/dist/modes/interactive/interactive-mode-helpers.js.map +1 -0
- package/dist/modes/interactive/interactive-mode-surface.d.ts +313 -0
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-mode-surface.js +2 -0
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -0
- package/dist/modes/interactive/interactive-mode-types.d.ts +29 -0
- package/dist/modes/interactive/interactive-mode-types.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-mode-types.js +2 -0
- package/dist/modes/interactive/interactive-mode-types.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +30 -404
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +29 -5260
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.d.ts +2 -0
- package/dist/modes/interactive/interactive-model-routing.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-model-routing.js +269 -0
- package/dist/modes/interactive/interactive-model-routing.js.map +1 -0
- package/dist/modes/interactive/interactive-process-lifecycle.d.ts +2 -0
- package/dist/modes/interactive/interactive-process-lifecycle.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-process-lifecycle.js +189 -0
- package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -0
- package/dist/modes/interactive/interactive-queueing.d.ts +2 -0
- package/dist/modes/interactive/interactive-queueing.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-queueing.js +163 -0
- package/dist/modes/interactive/interactive-queueing.js.map +1 -0
- package/dist/modes/interactive/interactive-render-chat.d.ts +2 -0
- package/dist/modes/interactive/interactive-render-chat.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-render-chat.js +170 -0
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -0
- package/dist/modes/interactive/interactive-resource-disclosure.d.ts +2 -0
- package/dist/modes/interactive/interactive-resource-disclosure.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-resource-disclosure.js +101 -0
- package/dist/modes/interactive/interactive-resource-disclosure.js.map +1 -0
- package/dist/modes/interactive/interactive-resource-paths.d.ts +2 -0
- package/dist/modes/interactive/interactive-resource-paths.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-resource-paths.js +228 -0
- package/dist/modes/interactive/interactive-resource-paths.js.map +1 -0
- package/dist/modes/interactive/interactive-resource-rendering.d.ts +2 -0
- package/dist/modes/interactive/interactive-resource-rendering.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-resource-rendering.js +181 -0
- package/dist/modes/interactive/interactive-resource-rendering.js.map +1 -0
- package/dist/modes/interactive/interactive-selectors.d.ts +2 -0
- package/dist/modes/interactive/interactive-selectors.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-selectors.js +198 -0
- package/dist/modes/interactive/interactive-selectors.js.map +1 -0
- package/dist/modes/interactive/interactive-session-routing.d.ts +2 -0
- package/dist/modes/interactive/interactive-session-routing.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-session-routing.js +232 -0
- package/dist/modes/interactive/interactive-session-routing.js.map +1 -0
- package/dist/modes/interactive/interactive-session-runtime.d.ts +2 -0
- package/dist/modes/interactive/interactive-session-runtime.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-session-runtime.js +131 -0
- package/dist/modes/interactive/interactive-session-runtime.js.map +1 -0
- package/dist/modes/interactive/interactive-slash-commands.d.ts +2 -0
- package/dist/modes/interactive/interactive-slash-commands.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-slash-commands.js +338 -0
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -0
- package/dist/modes/interactive/interactive-startup.d.ts +2 -0
- package/dist/modes/interactive/interactive-startup.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-startup.js +348 -0
- package/dist/modes/interactive/interactive-startup.js.map +1 -0
- package/dist/modes/interactive/model-search.d.ts +5 -0
- package/dist/modes/interactive/model-search.d.ts.map +1 -1
- package/dist/modes/interactive/model-search.js +9 -0
- package/dist/modes/interactive/model-search.js.map +1 -1
- package/dist/modes/interactive/theme/color-utils.d.ts +20 -0
- package/dist/modes/interactive/theme/color-utils.d.ts.map +1 -0
- package/dist/modes/interactive/theme/color-utils.js +204 -0
- package/dist/modes/interactive/theme/color-utils.js.map +1 -0
- package/dist/modes/interactive/theme/export-colors.d.ts +19 -0
- package/dist/modes/interactive/theme/export-colors.d.ts.map +1 -0
- package/dist/modes/interactive/theme/export-colors.js +69 -0
- package/dist/modes/interactive/theme/export-colors.js.map +1 -0
- package/dist/modes/interactive/theme/global-theme.d.ts +12 -0
- package/dist/modes/interactive/theme/global-theme.d.ts.map +1 -0
- package/dist/modes/interactive/theme/global-theme.js +150 -0
- package/dist/modes/interactive/theme/global-theme.js.map +1 -0
- package/dist/modes/interactive/theme/terminal-detection.d.ts +30 -0
- package/dist/modes/interactive/theme/terminal-detection.d.ts.map +1 -0
- package/dist/modes/interactive/theme/terminal-detection.js +89 -0
- package/dist/modes/interactive/theme/terminal-detection.js.map +1 -0
- package/dist/modes/interactive/theme/theme-class.d.ts +30 -0
- package/dist/modes/interactive/theme/theme-class.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme-class.js +83 -0
- package/dist/modes/interactive/theme/theme-class.js.map +1 -0
- package/dist/modes/interactive/theme/theme-loading.d.ts +17 -0
- package/dist/modes/interactive/theme/theme-loading.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme-loading.js +155 -0
- package/dist/modes/interactive/theme/theme-loading.js.map +1 -0
- package/dist/modes/interactive/theme/theme-parse.d.ts +5 -0
- package/dist/modes/interactive/theme/theme-parse.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme-parse.js +52 -0
- package/dist/modes/interactive/theme/theme-parse.js.map +1 -0
- package/dist/modes/interactive/theme/theme-schema.d.ts +255 -0
- package/dist/modes/interactive/theme/theme-schema.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme-schema.js +78 -0
- package/dist/modes/interactive/theme/theme-schema.js.map +1 -0
- package/dist/modes/interactive/theme/theme.d.ts +6 -108
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +6 -1065
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/interactive/theme/tui-theme.d.ts +15 -0
- package/dist/modes/interactive/theme/tui-theme.d.ts.map +1 -0
- package/dist/modes/interactive/theme/tui-theme.js +199 -0
- package/dist/modes/interactive/theme/tui-theme.js.map +1 -0
- package/dist/modes/rpc/rpc-client.d.ts +1 -61
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +1 -72
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts +14 -0
- package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-command-handler.js +226 -0
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -0
- package/dist/modes/rpc/rpc-extension-ui.d.ts +15 -0
- package/dist/modes/rpc/rpc-extension-ui.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-extension-ui.js +196 -0
- package/dist/modes/rpc/rpc-extension-ui.js.map +1 -0
- package/dist/modes/rpc/rpc-input.d.ts +12 -0
- package/dist/modes/rpc/rpc-input.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-input.js +54 -0
- package/dist/modes/rpc/rpc-input.js.map +1 -0
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +43 -607
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-responses.d.ts +8 -0
- package/dist/modes/rpc/rpc-responses.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-responses.js +27 -0
- package/dist/modes/rpc/rpc-responses.js.map +1 -0
- package/dist/modes/rpc/rpc-session-binding.d.ts +25 -0
- package/dist/modes/rpc/rpc-session-binding.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-session-binding.js +70 -0
- package/dist/modes/rpc/rpc-session-binding.js.map +1 -0
- package/dist/package-manager-cli-parser.d.ts +28 -0
- package/dist/package-manager-cli-parser.d.ts.map +1 -0
- package/dist/package-manager-cli-parser.js +269 -0
- package/dist/package-manager-cli-parser.js.map +1 -0
- package/dist/package-manager-cli.d.ts +0 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +2 -267
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/utils/git.d.ts.map +1 -1
- package/dist/utils/git.js +10 -0
- package/dist/utils/git.js.map +1 -1
- package/dist/utils/shell.d.ts +1 -0
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +12 -5
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/version-check.d.ts +1 -0
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js +17 -0
- package/dist/utils/version-check.js.map +1 -1
- package/docs/custom-provider.md +4 -3
- package/docs/development.md +4 -0
- package/docs/models.md +3 -2
- package/docs/packages.md +2 -2
- package/docs/quickstart.md +1 -1
- package/docs/sdk.md +2 -40
- package/docs/security.md +1 -1
- package/docs/workflows.md +246 -179
- package/examples/extensions/custom-provider-anthropic/index.ts +1 -106
- package/examples/extensions/gondolin/index.ts +0 -23
- package/examples/extensions/overlay-qa-animation-components.ts +255 -0
- package/examples/extensions/overlay-qa-focus-components.ts +222 -0
- package/examples/extensions/overlay-qa-position-components.ts +433 -0
- package/examples/extensions/overlay-qa-shared.ts +37 -0
- package/examples/extensions/overlay-qa-streaming-input-components.ts +205 -0
- package/examples/extensions/overlay-qa-tests.ts +17 -1156
- package/examples/extensions/overlay-qa-toggle-passive-components.ts +169 -0
- package/examples/extensions/space-invaders.ts +0 -60
- package/examples/extensions/subagent/display.ts +148 -0
- package/examples/extensions/subagent/index.ts +11 -858
- package/examples/extensions/subagent/render.ts +383 -0
- package/examples/extensions/subagent/runner.ts +252 -0
- package/examples/extensions/subagent/schemas.ts +59 -0
- package/examples/extensions/subagent/types.ts +36 -0
- package/examples/extensions/tic-tac-toe-instructions.ts +65 -0
- package/examples/extensions/tic-tac-toe-rendering.ts +414 -0
- package/examples/extensions/tic-tac-toe-state.ts +158 -0
- package/examples/extensions/tic-tac-toe.ts +92 -754
- package/examples/rpc-extension-ui-components.ts +189 -0
- package/examples/rpc-extension-ui.ts +2 -179
- package/package.json +7 -7
- package/dist/builtin/workflows/src/workflows/define-workflow.ts +0 -277
- package/dist/core/tools/bash-policy.d.ts +0 -62
- package/dist/core/tools/bash-policy.d.ts.map +0 -1
- package/dist/core/tools/bash-policy.js +0 -1069
- package/dist/core/tools/bash-policy.js.map +0 -1
|
@@ -7,1358 +7,16 @@
|
|
|
7
7
|
* prompt abstraction.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
CompleteStageOpts,
|
|
24
|
-
StageContext,
|
|
25
|
-
StageExecutionMeta,
|
|
26
|
-
StageOptions,
|
|
27
|
-
StageOutputOptions,
|
|
28
|
-
StagePromptOptions,
|
|
29
|
-
WorkflowMaxOutput,
|
|
30
|
-
WorkflowModelAttempt,
|
|
31
|
-
WorkflowExecutionMode,
|
|
32
|
-
WorkflowModelCatalogPort,
|
|
33
|
-
} from "../../shared/types.js";
|
|
34
|
-
import type { Static, TSchema } from "typebox";
|
|
35
|
-
import {
|
|
36
|
-
buildModelCandidatesFromCatalog,
|
|
37
|
-
errorMessage,
|
|
38
|
-
isRetryableModelFailure,
|
|
39
|
-
workflowModelId,
|
|
40
|
-
type WorkflowResolvedModelCandidate,
|
|
41
|
-
} from "../shared/model-fallback.js";
|
|
42
|
-
|
|
43
|
-
export interface StageSessionRuntime {
|
|
44
|
-
prompt(text: string, options?: PromptOptions): Promise<string | void>;
|
|
45
|
-
steer(text: string): Promise<void>;
|
|
46
|
-
followUp(text: string): Promise<void>;
|
|
47
|
-
subscribe(listener: (event: Parameters<AgentSession["subscribe"]>[0] extends (event: infer T) => void ? T : never) => void): () => void;
|
|
48
|
-
readonly sessionFile: string | undefined;
|
|
49
|
-
readonly sessionId: string;
|
|
50
|
-
setModel(model: Parameters<AgentSession["setModel"]>[0]): Promise<void>;
|
|
51
|
-
setThinkingLevel(level: Parameters<AgentSession["setThinkingLevel"]>[0]): void;
|
|
52
|
-
cycleModel(): ReturnType<AgentSession["cycleModel"]>;
|
|
53
|
-
cycleThinkingLevel(): ReturnType<AgentSession["cycleThinkingLevel"]>;
|
|
54
|
-
readonly agent: AgentSession["agent"];
|
|
55
|
-
readonly model: AgentSession["model"];
|
|
56
|
-
readonly thinkingLevel: AgentSession["thinkingLevel"];
|
|
57
|
-
readonly messages: AgentSession["messages"];
|
|
58
|
-
readonly isStreaming: AgentSession["isStreaming"];
|
|
59
|
-
/** Number of SDK-level queued steering/follow-up messages, when supported. */
|
|
60
|
-
readonly pendingMessageCount?: number;
|
|
61
|
-
/** Settings manager supplied by the Atomic SDK when the adapter did not pre-create one. */
|
|
62
|
-
readonly settingsManager?: WorkflowFastModeSettingsManager;
|
|
63
|
-
navigateTree: AgentSession["navigateTree"];
|
|
64
|
-
compact: AgentSession["compact"];
|
|
65
|
-
abortCompaction(): void;
|
|
66
|
-
abort(): Promise<void>;
|
|
67
|
-
dispose(): void | Promise<void>;
|
|
68
|
-
getLastAssistantText?: () => string | undefined;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export type StageSessionCreateOptions = CreateAgentSessionOptions & Pick<StageOptions, "mcp" | "fallbackModels" | "fallbackThinkingLevels">;
|
|
72
|
-
|
|
73
|
-
type WorkflowFastModeSettings = {
|
|
74
|
-
readonly chat: boolean;
|
|
75
|
-
readonly workflow: boolean;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
type WorkflowFastModeSettingsManager = {
|
|
79
|
-
getCodexFastModeSettings(): WorkflowFastModeSettings;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
export interface StageSessionCreateResult {
|
|
83
|
-
readonly session: StageSessionRuntime;
|
|
84
|
-
readonly settingsManager?: WorkflowFastModeSettingsManager;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export interface AgentSessionAdapter {
|
|
88
|
-
create(options: StageSessionCreateOptions, meta?: StageExecutionMeta): Promise<StageSessionRuntime | StageSessionCreateResult>;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export interface StageModelFallbackMeta {
|
|
92
|
-
readonly model?: string;
|
|
93
|
-
readonly fastMode?: boolean;
|
|
94
|
-
readonly attemptedModels?: readonly string[];
|
|
95
|
-
readonly modelAttempts?: readonly WorkflowModelAttempt[];
|
|
96
|
-
readonly warnings?: readonly string[];
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export interface PromptAdapter {
|
|
100
|
-
prompt(text: string, meta?: StageExecutionMeta): Promise<string>;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export interface CompleteAdapter {
|
|
104
|
-
complete(text: string, opts?: CompleteStageOpts, meta?: StageExecutionMeta): Promise<string>;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export interface StageAdapters {
|
|
108
|
-
agentSession?: AgentSessionAdapter;
|
|
109
|
-
prompt?: PromptAdapter;
|
|
110
|
-
complete?: CompleteAdapter;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export interface StageRunnerOpts {
|
|
114
|
-
stageId: string;
|
|
115
|
-
stageName: string;
|
|
116
|
-
adapters: StageAdapters;
|
|
117
|
-
/** Options passed to ctx.stage(name, options?). Forwarded to createAgentSession except mcp. */
|
|
118
|
-
stageOptions?: StageOptions;
|
|
119
|
-
/** Run ID of the containing workflow execution — forwarded to session adapter metadata. */
|
|
120
|
-
runId: string;
|
|
121
|
-
/** AbortSignal from the executor's own AbortController — forwarded to session adapter metadata. */
|
|
122
|
-
signal?: AbortSignal;
|
|
123
|
-
/** Optional model catalog used for fallback validation/resolution. */
|
|
124
|
-
models?: WorkflowModelCatalogPort;
|
|
125
|
-
/** Runtime execution mode forwarded to stage session adapters. */
|
|
126
|
-
executionMode?: WorkflowExecutionMode;
|
|
127
|
-
/** Host-resolved non-default session directory inherited by stages without explicit sessionDir. */
|
|
128
|
-
defaultSessionDir?: string;
|
|
129
|
-
/** Internal: notifies the executor when an in-flight fallback changes model/fast metadata. */
|
|
130
|
-
onModelFallbackMetaChange?: (meta: StageModelFallbackMeta) => void;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export interface InternalStageContext extends StageContext {
|
|
134
|
-
/** Internal cleanup hook; intentionally omitted from the public StageContext type. */
|
|
135
|
-
__dispose(): Promise<void>;
|
|
136
|
-
/** Internal result snapshot hook for the workflow store/TUI. */
|
|
137
|
-
__getLastAssistantText(): string | undefined;
|
|
138
|
-
getLastAssistantText(): string | undefined;
|
|
139
|
-
/**
|
|
140
|
-
* Internal: eagerly create the underlying SDK AgentSession without
|
|
141
|
-
* sending a prompt. Used by the live stage-control registry when a
|
|
142
|
-
* user attaches to a stage and types their first message before the
|
|
143
|
-
* workflow body's natural first `prompt()` lands.
|
|
144
|
-
*/
|
|
145
|
-
__ensureSession(): Promise<void>;
|
|
146
|
-
/** Internal: reopen an archived stage transcript before post-terminal follow-up. */
|
|
147
|
-
__ensureSessionFromFile(sessionFile: string): Promise<void>;
|
|
148
|
-
/**
|
|
149
|
-
* Internal: snapshot of currently-known SDK session metadata. Returns
|
|
150
|
-
* `undefined` keys when the session has not yet been created.
|
|
151
|
-
*/
|
|
152
|
-
__sessionMeta(): { sessionId: string | undefined; sessionFile: string | undefined };
|
|
153
|
-
/** Internal: live coding-agent session when the adapter returned one. */
|
|
154
|
-
__agentSession(): AgentSession | undefined;
|
|
155
|
-
/** Internal: SDK queued steering/follow-up message count, when available. */
|
|
156
|
-
__pendingMessageCount(): number;
|
|
157
|
-
/** Internal: selected/effective model and fallback attempt metadata. */
|
|
158
|
-
__modelFallbackMeta(): StageModelFallbackMeta;
|
|
159
|
-
/**
|
|
160
|
-
* Internal: register a controlled-pause request. The executor's
|
|
161
|
-
* tracked stage call uses this to distinguish a user-initiated pause
|
|
162
|
-
* from an unrelated abort and to wait for `__resume()` before
|
|
163
|
-
* resolving the awaiter.
|
|
164
|
-
*/
|
|
165
|
-
__requestPause(): Promise<void>;
|
|
166
|
-
/**
|
|
167
|
-
* Internal: complete a pending controlled pause. If `message` is
|
|
168
|
-
* provided it is sent to the SDK session before the awaiter resolves.
|
|
169
|
-
*/
|
|
170
|
-
__resume(message?: string): Promise<void>;
|
|
171
|
-
/** Internal: true while a controlled pause is in flight. */
|
|
172
|
-
__isPaused(): boolean;
|
|
173
|
-
/** Internal: true once a schema-backed prompt captured its final structured output. */
|
|
174
|
-
__structuredOutputFinalized(): boolean;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
function stripWorkflowOnlyOptions(options: StageOptions | undefined, defaultSessionDir?: string): CreateAgentSessionOptions {
|
|
178
|
-
if (!options) {
|
|
179
|
-
return defaultSessionDir === undefined
|
|
180
|
-
? {}
|
|
181
|
-
: { sessionManager: SessionManager.create(process.cwd(), defaultSessionDir) };
|
|
182
|
-
}
|
|
183
|
-
const {
|
|
184
|
-
schema: _schema,
|
|
185
|
-
mcp: _mcp,
|
|
186
|
-
fallbackModels: _fallbackModels,
|
|
187
|
-
fallbackThinkingLevels: _fallbackThinkingLevels,
|
|
188
|
-
context,
|
|
189
|
-
forkFromSessionFile,
|
|
190
|
-
sessionDir,
|
|
191
|
-
gitWorktreeDir: _gitWorktreeDir,
|
|
192
|
-
baseBranch: _baseBranch,
|
|
193
|
-
...sessionOptions
|
|
194
|
-
} = options;
|
|
195
|
-
if (sessionOptions.sessionManager === undefined) {
|
|
196
|
-
const cwd = sessionOptions.cwd ?? process.cwd();
|
|
197
|
-
const effectiveSessionDir = sessionDir ?? defaultSessionDir;
|
|
198
|
-
if (context === "fork" && forkFromSessionFile !== undefined) {
|
|
199
|
-
sessionOptions.sessionManager = SessionManager.forkFrom(forkFromSessionFile, cwd, effectiveSessionDir);
|
|
200
|
-
} else if (effectiveSessionDir !== undefined) {
|
|
201
|
-
sessionOptions.sessionManager = SessionManager.create(cwd, effectiveSessionDir);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
return sessionOptions as CreateAgentSessionOptions;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
type AgentSessionConsumer = "prompt" | "complete";
|
|
208
|
-
|
|
209
|
-
function missingAdapter(consumer: AgentSessionConsumer): never {
|
|
210
|
-
if (consumer === "complete") {
|
|
211
|
-
throw new Error(
|
|
212
|
-
"atomic-workflows: ctx.complete requires either RunOpts.adapters.complete or RunOpts.adapters.agentSession",
|
|
213
|
-
);
|
|
214
|
-
}
|
|
215
|
-
throw new Error(
|
|
216
|
-
"atomic-workflows: prompt adapter not configured — provide an AgentSessionAdapter via RunOpts.adapters.agentSession",
|
|
217
|
-
);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
function unavailableSync(property: string): never {
|
|
221
|
-
throw new Error(
|
|
222
|
-
`atomic-workflows: stage AgentSession property "${property}" is unavailable until the SDK session has been created`,
|
|
223
|
-
);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
type TextLikeContent = {
|
|
227
|
-
readonly type?: string;
|
|
228
|
-
readonly text?: string;
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
type MessageWithTextContent = {
|
|
232
|
-
readonly content?: string | readonly TextLikeContent[];
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
function extractMessageText(message: AgentSession["messages"][number]): string {
|
|
236
|
-
const { content } = message as MessageWithTextContent;
|
|
237
|
-
if (typeof content === "string") return content;
|
|
238
|
-
if (Array.isArray(content)) {
|
|
239
|
-
return content
|
|
240
|
-
.map((block) => (block.type === "text" && typeof block.text === "string" ? block.text : ""))
|
|
241
|
-
.filter(Boolean)
|
|
242
|
-
.join("");
|
|
243
|
-
}
|
|
244
|
-
return "";
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
function lastAssistantTextFromMessages(messages: AgentSession["messages"]): string | undefined {
|
|
248
|
-
for (let index = messages.length - 1; index >= 0; index -= 1) {
|
|
249
|
-
const message = messages[index];
|
|
250
|
-
// Only assistant prose is a valid non-terminating turn output. A tool
|
|
251
|
-
// result is the turn output ONLY when its tool terminated the turn, which
|
|
252
|
-
// is handled separately by `terminatingToolResultText`.
|
|
253
|
-
if (!message || message.role !== "assistant") continue;
|
|
254
|
-
const text = extractMessageText(message).trim();
|
|
255
|
-
if (text) return text;
|
|
256
|
-
}
|
|
257
|
-
return undefined;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
function messageStopReason(message: AgentSession["messages"][number]): string | undefined {
|
|
261
|
-
const record = message as { readonly stopReason?: unknown };
|
|
262
|
-
return typeof record.stopReason === "string" ? record.stopReason : undefined;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
function normalizedStopReason(stopReason: string | undefined): string | undefined {
|
|
266
|
-
return stopReason?.toLowerCase().replace(/[_-]+/g, "");
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
function isTerminalAssistantFailureStopReason(stopReason: string | undefined): boolean {
|
|
270
|
-
const normalized = normalizedStopReason(stopReason);
|
|
271
|
-
return normalized === "error" || normalized === "aborted";
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
function isCleanAssistantStopReason(stopReason: string | undefined): boolean {
|
|
275
|
-
const normalized = normalizedStopReason(stopReason);
|
|
276
|
-
return normalized === "stop" || normalized === "tooluse" || normalized === "length";
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
function assistantErrorMessage(message: AgentSession["messages"][number]): string | undefined {
|
|
280
|
-
const record = message as { readonly errorMessage?: unknown };
|
|
281
|
-
return typeof record.errorMessage === "string" && record.errorMessage.trim().length > 0
|
|
282
|
-
? record.errorMessage
|
|
283
|
-
: undefined;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
function latestTerminalAssistantFailureSince(
|
|
287
|
-
messages: AgentSession["messages"],
|
|
288
|
-
startIndex: number,
|
|
289
|
-
): AgentSession["messages"][number] | undefined {
|
|
290
|
-
for (let index = messages.length - 1; index >= startIndex; index -= 1) {
|
|
291
|
-
const message = messages[index];
|
|
292
|
-
if (!message || message.role !== "assistant") continue;
|
|
293
|
-
const stopReason = messageStopReason(message);
|
|
294
|
-
if (isTerminalAssistantFailureStopReason(stopReason)) return message;
|
|
295
|
-
if (isCleanAssistantStopReason(stopReason)) return undefined;
|
|
296
|
-
if (assistantErrorMessage(message) === undefined && extractMessageText(message).trim().length > 0) {
|
|
297
|
-
return undefined;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
return undefined;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
class WorkflowPromptModelFailure extends Error {
|
|
304
|
-
override readonly cause: unknown;
|
|
305
|
-
|
|
306
|
-
constructor(cause: unknown) {
|
|
307
|
-
super(errorMessage(cause));
|
|
308
|
-
this.name = "WorkflowPromptModelFailure";
|
|
309
|
-
this.cause = cause;
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
/**
|
|
314
|
-
* When an agent turn ends on a tool that returned `terminate: true`, control
|
|
315
|
-
* returns with the tool result as the final conversational message and no
|
|
316
|
-
* trailing assistant response (see the structured-output contract in the
|
|
317
|
-
* Atomic extension docs). That tool result is the deterministic output of the
|
|
318
|
-
* turn, so it must win over any prose the model emitted *before* the tool call
|
|
319
|
-
* in the same assistant message (which `getLastAssistantText()` would otherwise
|
|
320
|
-
* surface). This keeps terminating structured-output tools such as the `goal`
|
|
321
|
-
* and `ralph` review gates' `review_decision` tool deterministic regardless of
|
|
322
|
-
* surrounding narration.
|
|
323
|
-
*
|
|
324
|
-
* Returns the trailing tool-result text ONLY when the most recent
|
|
325
|
-
* conversational message is a tool result whose tool call actually returned
|
|
326
|
-
* `terminate: true` (tracked at runtime from the session's tool_execution_end
|
|
327
|
-
* events — see `terminatingToolCallIds`). Returns `undefined` for a turn that
|
|
328
|
-
* ended on an assistant response, OR on a tool result from a non-terminating
|
|
329
|
-
* tool (e.g. a turn aborted/errored right after a tool call) — both fall back
|
|
330
|
-
* to the last assistant message.
|
|
331
|
-
*/
|
|
332
|
-
function terminatingToolResultText(
|
|
333
|
-
messages: AgentSession["messages"],
|
|
334
|
-
terminatingToolCallIds: ReadonlySet<string>,
|
|
335
|
-
): string | undefined {
|
|
336
|
-
for (let index = messages.length - 1; index >= 0; index -= 1) {
|
|
337
|
-
const message = messages[index];
|
|
338
|
-
if (!message) continue;
|
|
339
|
-
if (message.role === "toolResult") {
|
|
340
|
-
// The trailing message is a tool result. It is the deterministic turn
|
|
341
|
-
// output only if THIS tool call returned `terminate: true`; otherwise the
|
|
342
|
-
// turn ended on this tool for another reason (abort/error) and the last
|
|
343
|
-
// assistant message is the real output.
|
|
344
|
-
const toolCallId = (message as { toolCallId?: unknown }).toolCallId;
|
|
345
|
-
if (typeof toolCallId !== "string" || !terminatingToolCallIds.has(toolCallId)) {
|
|
346
|
-
return undefined;
|
|
347
|
-
}
|
|
348
|
-
const text = extractMessageText(message).trim();
|
|
349
|
-
return text.length > 0 ? text : undefined;
|
|
350
|
-
}
|
|
351
|
-
if (message.role === "assistant") return undefined;
|
|
352
|
-
// Skip non-conversational roles (system/user) while locating the tail.
|
|
353
|
-
}
|
|
354
|
-
return undefined;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
/**
|
|
358
|
-
* A stage session backed by a real Atomic `AgentSession` exposes its
|
|
359
|
-
* `extensionRunner`. When workflow wiring binds extensions to a stage session it
|
|
360
|
-
* replays the `session_start` lifecycle (see wiring.ts `bindExtensions`), so
|
|
361
|
-
* extensions such as MCP begin per-session initialization. Tearing that session
|
|
362
|
-
* down with `dispose()` alone invalidates the extension runtime WITHOUT emitting
|
|
363
|
-
* `session_shutdown`, so those extensions never receive a graceful teardown
|
|
364
|
-
* signal: MCP, for example, logs a spurious stale-context "initialization
|
|
365
|
-
* failed" error when its deferred init races with disposal, and leaves any child
|
|
366
|
-
* MCP servers running.
|
|
367
|
-
*
|
|
368
|
-
* The test stub session (createTestAgentSession) has no `extensionRunner`, so the
|
|
369
|
-
* capability is optional and feature-detected at runtime.
|
|
370
|
-
*/
|
|
371
|
-
type StageSessionExtensionRunner = {
|
|
372
|
-
hasHandlers(eventType: string): boolean;
|
|
373
|
-
emit(event: { readonly type: "session_shutdown"; readonly reason: "quit" }): Promise<unknown>;
|
|
374
|
-
};
|
|
375
|
-
|
|
376
|
-
function stageSessionExtensionRunner(
|
|
377
|
-
current: StageSessionRuntime,
|
|
378
|
-
): StageSessionExtensionRunner | undefined {
|
|
379
|
-
const runner = (current as StageSessionRuntime & { extensionRunner?: StageSessionExtensionRunner })
|
|
380
|
-
.extensionRunner;
|
|
381
|
-
if (runner && typeof runner.hasHandlers === "function" && typeof runner.emit === "function") {
|
|
382
|
-
return runner;
|
|
383
|
-
}
|
|
384
|
-
return undefined;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
/**
|
|
388
|
-
* Dispose a stage session, mirroring the host `AgentSessionRuntime` teardown:
|
|
389
|
-
* emit `session_shutdown` before `dispose()` whenever the session exposes a
|
|
390
|
-
* compatible extension runner, so extensions tear down per-session resources
|
|
391
|
-
* (and bump their lifecycle generation) instead of being silently invalidated.
|
|
392
|
-
* A throwing shutdown handler must never strand the session, so disposal always
|
|
393
|
-
* runs.
|
|
394
|
-
*/
|
|
395
|
-
async function disposeStageSession(current: StageSessionRuntime | undefined): Promise<void> {
|
|
396
|
-
if (!current) return;
|
|
397
|
-
const runner = stageSessionExtensionRunner(current);
|
|
398
|
-
if (runner?.hasHandlers("session_shutdown")) {
|
|
399
|
-
try {
|
|
400
|
-
await runner.emit({ type: "session_shutdown", reason: "quit" });
|
|
401
|
-
} catch (error) {
|
|
402
|
-
console.error("atomic-workflows: stage session_shutdown handler failed", error);
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
await current.dispose();
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
function asAgentSession(activeSession: StageSessionRuntime | undefined): AgentSession | undefined {
|
|
409
|
-
if (!activeSession) return undefined;
|
|
410
|
-
const candidate = activeSession as StageSessionRuntime & Partial<Pick<AgentSession, "state" | "sessionManager" | "modelRegistry" | "getContextUsage">>;
|
|
411
|
-
if (
|
|
412
|
-
candidate.state !== undefined &&
|
|
413
|
-
candidate.sessionManager !== undefined &&
|
|
414
|
-
candidate.modelRegistry !== undefined &&
|
|
415
|
-
typeof candidate.getContextUsage === "function"
|
|
416
|
-
) {
|
|
417
|
-
return candidate as AgentSession;
|
|
418
|
-
}
|
|
419
|
-
return undefined;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
function lastAssistantTextFromSession(
|
|
423
|
-
activeSession: StageSessionRuntime | undefined,
|
|
424
|
-
fallback: string | undefined,
|
|
425
|
-
terminatingToolCallIds: ReadonlySet<string>,
|
|
426
|
-
): string | undefined {
|
|
427
|
-
if (!activeSession) return fallback;
|
|
428
|
-
// A tool that returned `terminate: true` ends the turn with its tool result
|
|
429
|
-
// as the final message; that result is the deterministic stage output and
|
|
430
|
-
// wins over prose emitted before the terminating tool call. Detection is by
|
|
431
|
-
// the tool call's actual runtime terminate flag — NOT merely "the last
|
|
432
|
-
// message is a tool result".
|
|
433
|
-
const terminatingText = terminatingToolResultText(activeSession.messages, terminatingToolCallIds);
|
|
434
|
-
if (terminatingText !== undefined) return terminatingText;
|
|
435
|
-
// Otherwise the turn output is the last assistant message — never a tool
|
|
436
|
-
// result from a non-terminating tool.
|
|
437
|
-
const direct = activeSession.getLastAssistantText?.();
|
|
438
|
-
if (direct !== undefined && direct.trim()) return direct;
|
|
439
|
-
return lastAssistantTextFromMessages(activeSession.messages) ?? direct ?? fallback;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
const DEFAULT_MAX_OUTPUT_BYTES = 200 * 1024;
|
|
443
|
-
const DEFAULT_MAX_OUTPUT_LINES = 5000;
|
|
444
|
-
|
|
445
|
-
function normalizeMaxOutput(maxOutput: WorkflowMaxOutput | undefined): Required<WorkflowMaxOutput> {
|
|
446
|
-
return {
|
|
447
|
-
bytes: maxOutput?.bytes ?? DEFAULT_MAX_OUTPUT_BYTES,
|
|
448
|
-
lines: maxOutput?.lines ?? DEFAULT_MAX_OUTPUT_LINES,
|
|
449
|
-
};
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
function truncateByLines(text: string, maxLines: number): { text: string; truncated: boolean } {
|
|
453
|
-
if (!Number.isFinite(maxLines) || maxLines <= 0) return { text: "", truncated: text.length > 0 };
|
|
454
|
-
const lines = text.split(/\r?\n/);
|
|
455
|
-
if (lines.length <= maxLines) return { text, truncated: false };
|
|
456
|
-
return { text: lines.slice(0, maxLines).join("\n"), truncated: true };
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
function truncateByBytes(text: string, maxBytes: number): { text: string; truncated: boolean } {
|
|
460
|
-
if (!Number.isFinite(maxBytes) || maxBytes <= 0) return { text: "", truncated: text.length > 0 };
|
|
461
|
-
if (Buffer.byteLength(text, "utf8") <= maxBytes) return { text, truncated: false };
|
|
462
|
-
|
|
463
|
-
let low = 0;
|
|
464
|
-
let high = text.length;
|
|
465
|
-
while (low < high) {
|
|
466
|
-
const mid = Math.ceil((low + high) / 2);
|
|
467
|
-
if (Buffer.byteLength(text.slice(0, mid), "utf8") <= maxBytes) low = mid;
|
|
468
|
-
else high = mid - 1;
|
|
469
|
-
}
|
|
470
|
-
return { text: text.slice(0, low), truncated: true };
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
function truncateOutput(text: string, maxOutput: WorkflowMaxOutput | undefined): string {
|
|
474
|
-
const limits = normalizeMaxOutput(maxOutput);
|
|
475
|
-
const byLines = truncateByLines(text, limits.lines);
|
|
476
|
-
const byBytes = truncateByBytes(byLines.text, limits.bytes);
|
|
477
|
-
if (!byLines.truncated && !byBytes.truncated) return text;
|
|
478
|
-
return `${byBytes.text}\n\n[workflow output truncated; limits: ${limits.bytes} bytes, ${limits.lines} lines]`;
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
function countLines(text: string): number {
|
|
482
|
-
if (!text) return 0;
|
|
483
|
-
const newlineMatches = text.match(/\r\n|\r|\n/g);
|
|
484
|
-
return (newlineMatches?.length ?? 0) + (/[\r\n]$/.test(text) ? 0 : 1);
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
function formatByteSize(bytes: number): string {
|
|
488
|
-
if (bytes < 1024) return `${bytes} B`;
|
|
489
|
-
const units = ["KB", "MB", "GB", "TB"];
|
|
490
|
-
let value = bytes / 1024;
|
|
491
|
-
let unitIndex = 0;
|
|
492
|
-
while (value >= 1024 && unitIndex < units.length - 1) {
|
|
493
|
-
value /= 1024;
|
|
494
|
-
unitIndex += 1;
|
|
495
|
-
}
|
|
496
|
-
return `${value.toFixed(1)} ${units[unitIndex]}`;
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
function savedOutputReference(outputPath: string, fullOutput: string): string {
|
|
500
|
-
const absolutePath = resolve(outputPath);
|
|
501
|
-
const bytes = Buffer.byteLength(fullOutput, "utf8");
|
|
502
|
-
const lines = countLines(fullOutput);
|
|
503
|
-
return `Output saved to: ${absolutePath} (${formatByteSize(bytes)}, ${lines} ${lines === 1 ? "line" : "lines"}). Read this file if needed.`;
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
function resolveOutputPath(
|
|
507
|
-
output: string | false | undefined,
|
|
508
|
-
runtimeCwd: string,
|
|
509
|
-
requestedCwd: string | undefined,
|
|
510
|
-
): string | undefined {
|
|
511
|
-
if (typeof output !== "string" || output.length === 0) return undefined;
|
|
512
|
-
if (isAbsolute(output)) return output;
|
|
513
|
-
const baseCwd = requestedCwd === undefined
|
|
514
|
-
? runtimeCwd
|
|
515
|
-
: isAbsolute(requestedCwd)
|
|
516
|
-
? requestedCwd
|
|
517
|
-
: resolve(runtimeCwd, requestedCwd);
|
|
518
|
-
return resolve(baseCwd, output);
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
function splitPromptOptions(options: StagePromptOptions | undefined): {
|
|
522
|
-
sdkOptions: PromptOptions | undefined;
|
|
523
|
-
outputOptions: StageOutputOptions;
|
|
524
|
-
} {
|
|
525
|
-
if (!options) return { sdkOptions: undefined, outputOptions: {} };
|
|
526
|
-
const sdkOptions: PromptOptions = {};
|
|
527
|
-
if (options.expandPromptTemplates !== undefined) sdkOptions.expandPromptTemplates = options.expandPromptTemplates;
|
|
528
|
-
if (options.images !== undefined) sdkOptions.images = options.images;
|
|
529
|
-
if (options.streamingBehavior !== undefined) sdkOptions.streamingBehavior = options.streamingBehavior;
|
|
530
|
-
if (options.source !== undefined) sdkOptions.source = options.source;
|
|
531
|
-
if (options.preflightResult !== undefined) sdkOptions.preflightResult = options.preflightResult;
|
|
532
|
-
|
|
533
|
-
const outputOptions: StageOutputOptions = {
|
|
534
|
-
...(options.output !== undefined ? { output: options.output } : {}),
|
|
535
|
-
...(options.outputMode !== undefined ? { outputMode: options.outputMode } : {}),
|
|
536
|
-
...(options.context !== undefined ? { context: options.context } : {}),
|
|
537
|
-
...(options.cwd !== undefined ? { cwd: options.cwd } : {}),
|
|
538
|
-
...(options.maxOutput !== undefined ? { maxOutput: options.maxOutput } : {}),
|
|
539
|
-
...(options.artifacts !== undefined ? { artifacts: options.artifacts } : {}),
|
|
540
|
-
...(options.sessionDir !== undefined ? { sessionDir: options.sessionDir } : {}),
|
|
541
|
-
};
|
|
542
|
-
|
|
543
|
-
return {
|
|
544
|
-
sdkOptions: Object.keys(sdkOptions).length === 0 ? undefined : sdkOptions,
|
|
545
|
-
outputOptions,
|
|
546
|
-
};
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
const STRUCTURED_OUTPUT_TOOL_NAME = "structured_output";
|
|
550
|
-
const STRUCTURED_OUTPUT_MAX_CORRECTIVE_PROMPTS = 3;
|
|
551
|
-
const STRUCTURED_OUTPUT_MISSING_ERROR = "atomic-workflows: stage configured with schema must finish by calling structured_output.";
|
|
552
|
-
|
|
553
|
-
type ToolResultContentBlock = {
|
|
554
|
-
readonly type?: unknown;
|
|
555
|
-
readonly text?: unknown;
|
|
556
|
-
};
|
|
557
|
-
|
|
558
|
-
function toolResultText(content: unknown): string | undefined {
|
|
559
|
-
if (!Array.isArray(content)) return undefined;
|
|
560
|
-
const text = content
|
|
561
|
-
.map((block: ToolResultContentBlock) => block.type === "text" && typeof block.text === "string" ? block.text : "")
|
|
562
|
-
.join("\n")
|
|
563
|
-
.trim();
|
|
564
|
-
return text.length > 0 ? text : undefined;
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
function structuredOutputToolErrorFromEvent(event: unknown): string | undefined {
|
|
568
|
-
if (event === null || typeof event !== "object") return undefined;
|
|
569
|
-
const record = event as Record<string, unknown>;
|
|
570
|
-
if (record["type"] !== "tool_execution_end") return undefined;
|
|
571
|
-
if (record["toolName"] !== STRUCTURED_OUTPUT_TOOL_NAME) return undefined;
|
|
572
|
-
const result = record["result"];
|
|
573
|
-
const resultRecord = result !== null && typeof result === "object" ? result as Record<string, unknown> : undefined;
|
|
574
|
-
const isError = record["isError"] === true || resultRecord?.["isError"] === true;
|
|
575
|
-
if (!isError) return undefined;
|
|
576
|
-
return toolResultText(resultRecord?.["content"]) ?? "structured_output tool call failed schema validation.";
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
function formatStructuredOutputCorrectionPrompt(error: string, attempt: number): string {
|
|
580
|
-
return [
|
|
581
|
-
"The previous response failed this stage's structured-output contract.",
|
|
582
|
-
"",
|
|
583
|
-
`Corrective attempt ${attempt}/${STRUCTURED_OUTPUT_MAX_CORRECTIVE_PROMPTS}.`,
|
|
584
|
-
"",
|
|
585
|
-
"Error:",
|
|
586
|
-
error,
|
|
587
|
-
"",
|
|
588
|
-
"You must finish by calling the `structured_output` tool exactly once with arguments matching the registered schema.",
|
|
589
|
-
"Do not answer with plain JSON text, Markdown, or prose. If you attempted `structured_output` and validation failed, correct the tool arguments and call `structured_output` again.",
|
|
590
|
-
].join("\n");
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
function stringifyStructuredOutputValue(value: unknown): string {
|
|
594
|
-
try {
|
|
595
|
-
return JSON.stringify(value, null, 2);
|
|
596
|
-
} catch (error) {
|
|
597
|
-
throw new Error(`atomic-workflows: structured_output returned a non-serializable value: ${error instanceof Error ? error.message : String(error)}`);
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
function stageOptionsWithStructuredOutput(
|
|
602
|
-
options: StageOptions | undefined,
|
|
603
|
-
capture: StructuredOutputCapture<unknown> | undefined,
|
|
604
|
-
): StageOptions | undefined {
|
|
605
|
-
if (!options?.schema || !capture) return options;
|
|
606
|
-
const tools = options.tools === undefined
|
|
607
|
-
? options.noTools === "all" ? [STRUCTURED_OUTPUT_TOOL_NAME] : undefined
|
|
608
|
-
: Array.from(new Set([...options.tools, STRUCTURED_OUTPUT_TOOL_NAME]));
|
|
609
|
-
const excludedTools = options.excludedTools?.filter((toolName) => toolName !== STRUCTURED_OUTPUT_TOOL_NAME);
|
|
610
|
-
return {
|
|
611
|
-
...options,
|
|
612
|
-
...(tools !== undefined ? { tools } : {}),
|
|
613
|
-
...(excludedTools !== undefined ? { excludedTools } : {}),
|
|
614
|
-
customTools: [
|
|
615
|
-
...(options.customTools ?? []),
|
|
616
|
-
createStructuredOutputTool({
|
|
617
|
-
schema: options.schema as TSchema,
|
|
618
|
-
capture: capture as StructuredOutputCapture<Static<TSchema>>,
|
|
619
|
-
}),
|
|
620
|
-
],
|
|
621
|
-
};
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
function validatePromptOutputOptions(outputOptions: StageOutputOptions): void {
|
|
625
|
-
if (outputOptions.outputMode === "file-only" && (typeof outputOptions.output !== "string" || outputOptions.output.length === 0)) {
|
|
626
|
-
throw new Error(
|
|
627
|
-
"atomic-workflows: prompt sets outputMode: \"file-only\" but does not configure an output file. Set output to a path or use outputMode: \"inline\".",
|
|
628
|
-
);
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
async function finalizePromptOutput(
|
|
633
|
-
fullOutput: string,
|
|
634
|
-
outputOptions: StageOutputOptions,
|
|
635
|
-
runtimeCwd: string,
|
|
636
|
-
): Promise<string> {
|
|
637
|
-
const outputPath = resolveOutputPath(outputOptions.output, runtimeCwd, outputOptions.cwd);
|
|
638
|
-
validatePromptOutputOptions(outputOptions);
|
|
639
|
-
|
|
640
|
-
const displayOutput = truncateOutput(fullOutput, outputOptions.maxOutput);
|
|
641
|
-
if (outputPath === undefined) return displayOutput;
|
|
642
|
-
|
|
643
|
-
try {
|
|
644
|
-
await mkdir(dirname(outputPath), { recursive: true });
|
|
645
|
-
await writeFile(outputPath, fullOutput, "utf8");
|
|
646
|
-
} catch (err) {
|
|
647
|
-
return `${displayOutput}\n\nOutput file error: ${outputPath}\n${err instanceof Error ? err.message : String(err)}`;
|
|
648
|
-
}
|
|
649
|
-
|
|
650
|
-
const reference = savedOutputReference(outputPath, fullOutput);
|
|
651
|
-
return outputOptions.outputMode === "file-only"
|
|
652
|
-
? reference
|
|
653
|
-
: `${displayOutput}\n\n${reference}`;
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
export function createStageContext(opts: StageRunnerOpts): InternalStageContext {
|
|
657
|
-
const { stageId, stageName, adapters, runId, signal, stageOptions, executionMode, defaultSessionDir } = opts;
|
|
658
|
-
const structuredOutputCapture = stageOptions?.schema ? createStructuredOutputCapture<unknown>() : undefined;
|
|
659
|
-
const effectiveStageOptions = stageOptionsWithStructuredOutput(stageOptions, structuredOutputCapture);
|
|
660
|
-
const meta: StageExecutionMeta = { runId, stageId, stageName, signal, stageOptions: effectiveStageOptions, executionMode };
|
|
661
|
-
let session: StageSessionRuntime | undefined;
|
|
662
|
-
let sessionPromise: Promise<StageSessionRuntime> | undefined;
|
|
663
|
-
let reattachSessionFile: string | undefined;
|
|
664
|
-
let lastAssistantText: string | undefined;
|
|
665
|
-
// Tool-call ids whose tool returned `terminate: true` at runtime, observed
|
|
666
|
-
// from the session's `tool_execution_end` events. The SDK ends the turn on a
|
|
667
|
-
// terminating tool, so its tool result is the deterministic stage output; a
|
|
668
|
-
// trailing tool result from any other tool is NOT. See
|
|
669
|
-
// `lastAssistantTextFromSession`. The tool result *message* does not carry the
|
|
670
|
-
// terminate flag, so it must be tracked from the live event stream.
|
|
671
|
-
const terminatingToolCallIds = new Set<string>();
|
|
672
|
-
let latestStructuredOutputToolError: string | undefined;
|
|
673
|
-
let unsubscribeTerminateWatcher: (() => void) | undefined;
|
|
674
|
-
const recordTerminatingToolCall = (event: unknown): void => {
|
|
675
|
-
if (event === null || typeof event !== "object") return;
|
|
676
|
-
const record = event as Record<string, unknown>;
|
|
677
|
-
if (record["type"] !== "tool_execution_end") return;
|
|
678
|
-
const result = record["result"];
|
|
679
|
-
if (result === null || typeof result !== "object") return;
|
|
680
|
-
if ((result as Record<string, unknown>)["terminate"] !== true) return;
|
|
681
|
-
const callId = record["toolCallId"];
|
|
682
|
-
if (typeof callId === "string" && callId.length > 0) {
|
|
683
|
-
terminatingToolCallIds.add(callId);
|
|
684
|
-
}
|
|
685
|
-
};
|
|
686
|
-
let adapterMessages: AgentSession["messages"] = [];
|
|
687
|
-
let disposed = false;
|
|
688
|
-
let pendingThinkingLevel: Parameters<StageContext["setThinkingLevel"]>[0] | undefined;
|
|
689
|
-
const pendingListeners = new Set<(event: Parameters<StageContext["subscribe"]>[0] extends (event: infer T) => void ? T : never) => void>();
|
|
690
|
-
const listenerUnsubscribes = new Map<(event: Parameters<StageContext["subscribe"]>[0] extends (event: infer T) => void ? T : never) => void, () => void>();
|
|
691
|
-
|
|
692
|
-
/**
|
|
693
|
-
* Pause/resume coordination. `pauseRequest` is non-null while a
|
|
694
|
-
* controlled pause is pending. The executor's `runTrackedStageCall`
|
|
695
|
-
* inspects this in its catch handler to distinguish a user pause
|
|
696
|
-
* (await `pauseDeferred.promise`, then re-issue the call) from a
|
|
697
|
-
* genuine SDK abort that should fail the stage.
|
|
698
|
-
*
|
|
699
|
-
* `pendingResumeMessage` is the next user message to feed back into
|
|
700
|
-
* the SDK session when `__resume(message)` is called.
|
|
701
|
-
*/
|
|
702
|
-
let pauseRequest: {
|
|
703
|
-
deferred: PromiseWithResolvers<{ message?: string }>;
|
|
704
|
-
} | null = null;
|
|
705
|
-
|
|
706
|
-
// Wire the executor's abort signal to the live SDK session and pause
|
|
707
|
-
// deferred so a kill (or other forced abort) doesn't leave a paused stage
|
|
708
|
-
// hanging on a resume signal that will never arrive. Re-use the abort
|
|
709
|
-
// reason instead of manufacturing a stage-specific error; shutdown/kill is
|
|
710
|
-
// expected cancellation and should not surface as a noisy per-stage failure.
|
|
711
|
-
if (signal) {
|
|
712
|
-
const abortReason = (): Error | DOMException | string => {
|
|
713
|
-
const reason = signal.reason;
|
|
714
|
-
if (reason instanceof Error || reason instanceof DOMException || typeof reason === "string") {
|
|
715
|
-
return reason;
|
|
716
|
-
}
|
|
717
|
-
return new DOMException("workflow killed", "AbortError");
|
|
718
|
-
};
|
|
719
|
-
const onAbort = (): void => {
|
|
720
|
-
void session?.abort().catch(() => {});
|
|
721
|
-
if (!pauseRequest) return;
|
|
722
|
-
const req = pauseRequest;
|
|
723
|
-
pauseRequest = null;
|
|
724
|
-
req.deferred.reject(abortReason());
|
|
725
|
-
};
|
|
726
|
-
if (signal.aborted) onAbort();
|
|
727
|
-
else signal.addEventListener("abort", onAbort, { once: true });
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
const hasExplicitModelFallbackConfig =
|
|
731
|
-
effectiveStageOptions?.model !== undefined || (effectiveStageOptions?.fallbackModels?.length ?? 0) > 0;
|
|
732
|
-
let candidatesPromise: Promise<WorkflowResolvedModelCandidate[]> | undefined;
|
|
733
|
-
let activeCandidateIndex: number | undefined;
|
|
734
|
-
let selectedModel: string | undefined;
|
|
735
|
-
// A single ModelRegistry (carrying its AuthStorage) reused across every model
|
|
736
|
-
// fallback candidate in this stage. Captured from the first created session
|
|
737
|
-
// and threaded into subsequent candidate sessions so fallback does not rebuild
|
|
738
|
-
// auth/model state per candidate — which can misreport configured providers as
|
|
739
|
-
// "No API key found" under auth.json lock contention (issue #1431).
|
|
740
|
-
let sharedModelRegistry: CreateAgentSessionOptions["modelRegistry"];
|
|
741
|
-
// When true, the next promptWithFallback() call first retries the model the
|
|
742
|
-
// session last settled on (a post-completion follow-up, a subsequent turn, or
|
|
743
|
-
// a reattached session) before replaying the chain from the primary. Set on
|
|
744
|
-
// every successful attempt and by ensureSession()'s reattach branch; cleared
|
|
745
|
-
// when the current session is disposed.
|
|
746
|
-
let resumeCurrentSession = false;
|
|
747
|
-
const modelAttempts: WorkflowModelAttempt[] = [];
|
|
748
|
-
const modelWarnings: string[] = [];
|
|
749
|
-
const pendingFallbackWarnings: string[] = [];
|
|
750
|
-
const modelCatalog = opts.models === undefined
|
|
751
|
-
? undefined
|
|
752
|
-
: {
|
|
753
|
-
...opts.models,
|
|
754
|
-
recordWarning: (warning: string): void => {
|
|
755
|
-
modelWarnings.push(warning);
|
|
756
|
-
opts.models?.recordWarning?.(warning);
|
|
757
|
-
},
|
|
758
|
-
} satisfies WorkflowModelCatalogPort;
|
|
759
|
-
|
|
760
|
-
function modelCandidates(): Promise<WorkflowResolvedModelCandidate[]> {
|
|
761
|
-
if (!candidatesPromise) {
|
|
762
|
-
candidatesPromise = buildModelCandidatesFromCatalog({
|
|
763
|
-
primaryModel: effectiveStageOptions?.model,
|
|
764
|
-
fallbackModels: effectiveStageOptions?.fallbackModels,
|
|
765
|
-
fallbackThinkingLevels: effectiveStageOptions?.fallbackThinkingLevels,
|
|
766
|
-
catalog: modelCatalog,
|
|
767
|
-
});
|
|
768
|
-
}
|
|
769
|
-
return candidatesPromise;
|
|
770
|
-
}
|
|
771
|
-
|
|
772
|
-
function stageOptionsForCandidate(
|
|
773
|
-
candidate: WorkflowResolvedModelCandidate | undefined,
|
|
774
|
-
resumeOptions?: { restoreSavedModel?: boolean },
|
|
775
|
-
): StageOptions | undefined {
|
|
776
|
-
const optionsForCandidate: StageOptions = candidate === undefined
|
|
777
|
-
? { ...(effectiveStageOptions ?? {}) }
|
|
778
|
-
: {
|
|
779
|
-
...(effectiveStageOptions ?? {}),
|
|
780
|
-
model: candidate.value,
|
|
781
|
-
...(candidate.reasoningLevel !== undefined ? { thinkingLevel: candidate.reasoningLevel } : {}),
|
|
782
|
-
// A per-candidate context window (parsed from a parenthesized token in
|
|
783
|
-
// the model string) overrides any stage-level contextWindow so only
|
|
784
|
-
// that specific model — e.g. a github-copilot opus fallback — requests
|
|
785
|
-
// its larger window; other candidates keep the stage default.
|
|
786
|
-
...(candidate.contextWindow !== undefined ? { contextWindow: candidate.contextWindow } : {}),
|
|
787
|
-
fallbackModels: undefined,
|
|
788
|
-
fallbackThinkingLevels: undefined,
|
|
789
|
-
};
|
|
790
|
-
// When resuming a reattached session (a post-completion follow-up), drop any
|
|
791
|
-
// model override so the SDK restores the model the session last used — the
|
|
792
|
-
// one that actually worked — instead of forcing the primary/candidate model.
|
|
793
|
-
if (resumeOptions?.restoreSavedModel) {
|
|
794
|
-
delete optionsForCandidate.model;
|
|
795
|
-
}
|
|
796
|
-
if (reattachSessionFile !== undefined && optionsForCandidate.sessionManager === undefined) {
|
|
797
|
-
const cwd = optionsForCandidate.cwd ?? process.cwd();
|
|
798
|
-
optionsForCandidate.sessionManager = SessionManager.open(
|
|
799
|
-
reattachSessionFile,
|
|
800
|
-
optionsForCandidate.sessionDir,
|
|
801
|
-
cwd,
|
|
802
|
-
);
|
|
803
|
-
optionsForCandidate.context = undefined;
|
|
804
|
-
optionsForCandidate.forkFromSessionFile = undefined;
|
|
805
|
-
}
|
|
806
|
-
// Reuse the registry captured from the first session for later fallback
|
|
807
|
-
// candidates. A caller-supplied modelRegistry is preserved (issue #1431).
|
|
808
|
-
if (sharedModelRegistry !== undefined && optionsForCandidate.modelRegistry === undefined) {
|
|
809
|
-
optionsForCandidate.modelRegistry = sharedModelRegistry;
|
|
810
|
-
}
|
|
811
|
-
return Object.keys(optionsForCandidate).length === 0 ? undefined : optionsForCandidate;
|
|
812
|
-
}
|
|
813
|
-
|
|
814
|
-
let sessionSettingsManager: WorkflowFastModeSettingsManager | undefined;
|
|
815
|
-
|
|
816
|
-
function isWorkflowFastModeEnabled(): boolean | undefined {
|
|
817
|
-
const model = session?.model;
|
|
818
|
-
const settingsManager = sessionSettingsManager ?? effectiveStageOptions?.settingsManager;
|
|
819
|
-
if (model === undefined || settingsManager === undefined) return undefined;
|
|
820
|
-
return shouldApplyCodexFastModeForScope(model, settingsManager.getCodexFastModeSettings(), "workflow");
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
function currentModelFallbackMeta(): StageModelFallbackMeta {
|
|
824
|
-
const attemptedModels = modelAttempts.map((attempt) => attempt.model);
|
|
825
|
-
const model = selectedModel ?? workflowModelId(session?.model);
|
|
826
|
-
const fastMode = isWorkflowFastModeEnabled();
|
|
827
|
-
return {
|
|
828
|
-
...(model !== undefined ? { model } : {}),
|
|
829
|
-
...(fastMode !== undefined ? { fastMode } : {}),
|
|
830
|
-
...(attemptedModels.length > 0 ? { attemptedModels } : {}),
|
|
831
|
-
...(modelAttempts.length > 0 ? { modelAttempts: [...modelAttempts] } : {}),
|
|
832
|
-
...(modelWarnings.length > 0 ? { warnings: [...modelWarnings] } : {}),
|
|
833
|
-
};
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
function notifyModelFallbackMetaChange(): void {
|
|
837
|
-
opts.onModelFallbackMetaChange?.(currentModelFallbackMeta());
|
|
838
|
-
}
|
|
839
|
-
|
|
840
|
-
function normalizeSessionCreateResult(created: StageSessionRuntime | StageSessionCreateResult): StageSessionCreateResult {
|
|
841
|
-
if ("session" in created) return created;
|
|
842
|
-
return { session: created };
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
function effectiveCandidateReasoning(candidate: WorkflowResolvedModelCandidate): StageOptions["thinkingLevel"] | undefined {
|
|
846
|
-
return candidate.reasoningLevel ?? effectiveStageOptions?.thinkingLevel;
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
function modelAttemptReasoning(candidate: WorkflowResolvedModelCandidate): Pick<WorkflowModelAttempt, "reasoningLevel"> {
|
|
850
|
-
const reasoningLevel = effectiveCandidateReasoning(candidate);
|
|
851
|
-
return reasoningLevel !== undefined ? { reasoningLevel } : {};
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
function applyCandidateThinking(candidate: WorkflowResolvedModelCandidate | undefined): void {
|
|
855
|
-
pendingThinkingLevel = candidate === undefined
|
|
856
|
-
? effectiveStageOptions?.thinkingLevel
|
|
857
|
-
: effectiveCandidateReasoning(candidate);
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
function candidateLabel(candidate: WorkflowResolvedModelCandidate): string {
|
|
861
|
-
return candidate.reasoningLevel !== undefined ? `${candidate.id}:${candidate.reasoningLevel}` : candidate.id;
|
|
862
|
-
}
|
|
863
|
-
|
|
864
|
-
function attachSession(created: StageSessionRuntime | StageSessionCreateResult): StageSessionRuntime {
|
|
865
|
-
const result = normalizeSessionCreateResult(created);
|
|
866
|
-
session = result.session;
|
|
867
|
-
// Capture the SDK ModelRegistry from the first real session so subsequent
|
|
868
|
-
// fallback candidates reuse the same already-loaded auth/model state instead
|
|
869
|
-
// of re-creating it per candidate (issue #1431). The test stub session has
|
|
870
|
-
// no modelRegistry, so capture is simply skipped there.
|
|
871
|
-
if (sharedModelRegistry === undefined) {
|
|
872
|
-
const withRegistry = result.session as Partial<Pick<AgentSession, "modelRegistry">>;
|
|
873
|
-
if (withRegistry.modelRegistry !== undefined) {
|
|
874
|
-
sharedModelRegistry = withRegistry.modelRegistry;
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
|
-
sessionSettingsManager = result.settingsManager ?? result.session.settingsManager;
|
|
878
|
-
if (pendingThinkingLevel !== undefined) {
|
|
879
|
-
result.session.setThinkingLevel(pendingThinkingLevel);
|
|
880
|
-
}
|
|
881
|
-
for (const listener of pendingListeners) {
|
|
882
|
-
listenerUnsubscribes.set(listener, result.session.subscribe(listener));
|
|
883
|
-
}
|
|
884
|
-
// Track terminating tool calls for this session so the stage result text is
|
|
885
|
-
// derived deterministically from a tool that actually ended the turn. Also
|
|
886
|
-
// remember schema-validation errors from structured_output so corrective
|
|
887
|
-
// retry prompts can echo the concrete failure instead of a generic miss.
|
|
888
|
-
unsubscribeTerminateWatcher?.();
|
|
889
|
-
unsubscribeTerminateWatcher = result.session.subscribe((event) => {
|
|
890
|
-
recordTerminatingToolCall(event);
|
|
891
|
-
latestStructuredOutputToolError = structuredOutputToolErrorFromEvent(event) ?? latestStructuredOutputToolError;
|
|
892
|
-
});
|
|
893
|
-
return result.session;
|
|
894
|
-
}
|
|
895
|
-
|
|
896
|
-
async function createSession(
|
|
897
|
-
candidate: WorkflowResolvedModelCandidate | undefined,
|
|
898
|
-
consumer: AgentSessionConsumer,
|
|
899
|
-
resumeOptions?: { restoreSavedModel?: boolean },
|
|
900
|
-
): Promise<StageSessionRuntime> {
|
|
901
|
-
applyCandidateThinking(candidate);
|
|
902
|
-
const created = adapters.agentSession
|
|
903
|
-
? await adapters.agentSession.create(stripWorkflowOnlyOptions(stageOptionsForCandidate(candidate, resumeOptions), defaultSessionDir) as StageSessionCreateOptions, {
|
|
904
|
-
...meta,
|
|
905
|
-
stageOptions: stageOptionsForCandidate(candidate, resumeOptions),
|
|
906
|
-
})
|
|
907
|
-
: missingAdapter(consumer);
|
|
908
|
-
return attachSession(created);
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
async function ensureSession(consumer: AgentSessionConsumer = "prompt"): Promise<StageSessionRuntime> {
|
|
912
|
-
if (disposed) throw new Error(`atomic-workflows: stage "${stageName}" session has been disposed`);
|
|
913
|
-
// Reuse an already-attached session. After model fallback settles, `session`
|
|
914
|
-
// is set but `sessionPromise` is left undefined; without this guard a
|
|
915
|
-
// follow-up's ensureSession() (via ctx.followUp / ctx.steer / __ensureSession)
|
|
916
|
-
// would create a brand-new session from the primary candidate and discard the
|
|
917
|
-
// working fallback session (issue #1431 follow-up).
|
|
918
|
-
if (session !== undefined) return session;
|
|
919
|
-
if (!sessionPromise) {
|
|
920
|
-
sessionPromise = (async () => {
|
|
921
|
-
if (!hasExplicitModelFallbackConfig) return createSession(undefined, consumer);
|
|
922
|
-
const candidates = await modelCandidates();
|
|
923
|
-
const first = candidates[0];
|
|
924
|
-
if (first === undefined) return createSession(undefined, consumer);
|
|
925
|
-
|
|
926
|
-
// Reattaching a previously-run session (e.g. a post-completion
|
|
927
|
-
// follow-up after the session was disposed): resume on the model the
|
|
928
|
-
// session last settled on — the one that actually worked — instead of
|
|
929
|
-
// replaying the fallback chain from an unavailable primary.
|
|
930
|
-
// promptWithFallback retries that model first; if it fails again it
|
|
931
|
-
// restarts the full chain from the primary.
|
|
932
|
-
if (reattachSessionFile !== undefined) {
|
|
933
|
-
const resumed = await createSession(undefined, consumer, { restoreSavedModel: true });
|
|
934
|
-
const restoredId = workflowModelId(resumed.model);
|
|
935
|
-
const restoredIndex = restoredId === undefined
|
|
936
|
-
? -1
|
|
937
|
-
: candidates.findIndex((entry) => entry.id === restoredId);
|
|
938
|
-
activeCandidateIndex = restoredIndex >= 0 ? restoredIndex : undefined;
|
|
939
|
-
selectedModel = restoredId ?? first.id;
|
|
940
|
-
resumeCurrentSession = true;
|
|
941
|
-
return resumed;
|
|
942
|
-
}
|
|
943
|
-
|
|
944
|
-
activeCandidateIndex = 0;
|
|
945
|
-
selectedModel = first.id;
|
|
946
|
-
return createSession(first, consumer);
|
|
947
|
-
})();
|
|
948
|
-
}
|
|
949
|
-
return sessionPromise;
|
|
950
|
-
}
|
|
951
|
-
|
|
952
|
-
async function ensureSessionFromFile(sessionFile: string, consumer: AgentSessionConsumer = "prompt"): Promise<StageSessionRuntime> {
|
|
953
|
-
if (sessionPromise || session) return ensureSession(consumer);
|
|
954
|
-
reattachSessionFile = sessionFile;
|
|
955
|
-
return ensureSession(consumer);
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
async function disposeCurrentSession(): Promise<void> {
|
|
959
|
-
const current = session;
|
|
960
|
-
session = undefined;
|
|
961
|
-
sessionPromise = undefined;
|
|
962
|
-
sessionSettingsManager = undefined;
|
|
963
|
-
resumeCurrentSession = false;
|
|
964
|
-
for (const unsubscribe of listenerUnsubscribes.values()) unsubscribe();
|
|
965
|
-
listenerUnsubscribes.clear();
|
|
966
|
-
unsubscribeTerminateWatcher?.();
|
|
967
|
-
unsubscribeTerminateWatcher = undefined;
|
|
968
|
-
terminatingToolCallIds.clear();
|
|
969
|
-
await disposeStageSession(current);
|
|
970
|
-
}
|
|
971
|
-
|
|
972
|
-
async function promptWithPauseResume(
|
|
973
|
-
activeSession: StageSessionRuntime,
|
|
974
|
-
initialText: string,
|
|
975
|
-
sdkOptions: PromptOptions | undefined,
|
|
976
|
-
): Promise<{ readonly terminalScanStartIndex: number }> {
|
|
977
|
-
// Pause/resume loop: when a controlled pause aborts the SDK call,
|
|
978
|
-
// swallow the resulting abort, suspend on `pauseRequest.deferred`,
|
|
979
|
-
// and either re-issue with the user's resume message or return the
|
|
980
|
-
// accumulated assistant text when resume carries no message.
|
|
981
|
-
let nextText: string | undefined = initialText;
|
|
982
|
-
while (nextText !== undefined) {
|
|
983
|
-
const pendingPauseBeforePrompt = pauseRequest;
|
|
984
|
-
if (pendingPauseBeforePrompt) {
|
|
985
|
-
const { message } = await pendingPauseBeforePrompt.deferred.promise;
|
|
986
|
-
nextText = message;
|
|
987
|
-
if (nextText === undefined) return { terminalScanStartIndex: activeSession.messages.length };
|
|
988
|
-
continue;
|
|
989
|
-
}
|
|
990
|
-
const promptStartIndex = activeSession.messages.length;
|
|
991
|
-
try {
|
|
992
|
-
await activeSession.prompt(nextText, sdkOptions);
|
|
993
|
-
const pendingPauseAfterPrompt = pauseRequest;
|
|
994
|
-
if (pendingPauseAfterPrompt) {
|
|
995
|
-
const { message } = await pendingPauseAfterPrompt.deferred.promise;
|
|
996
|
-
nextText = message;
|
|
997
|
-
if (nextText === undefined) return { terminalScanStartIndex: activeSession.messages.length };
|
|
998
|
-
continue;
|
|
999
|
-
}
|
|
1000
|
-
return { terminalScanStartIndex: promptStartIndex };
|
|
1001
|
-
} catch (err) {
|
|
1002
|
-
const pendingPauseAfterThrow = pauseRequest;
|
|
1003
|
-
if (pendingPauseAfterThrow) {
|
|
1004
|
-
const { message } = await pendingPauseAfterThrow.deferred.promise;
|
|
1005
|
-
nextText = message;
|
|
1006
|
-
if (nextText === undefined) return { terminalScanStartIndex: activeSession.messages.length };
|
|
1007
|
-
continue;
|
|
1008
|
-
}
|
|
1009
|
-
throw err;
|
|
1010
|
-
}
|
|
1011
|
-
}
|
|
1012
|
-
return { terminalScanStartIndex: activeSession.messages.length };
|
|
1013
|
-
}
|
|
1014
|
-
|
|
1015
|
-
async function promptWithFallback(
|
|
1016
|
-
text: string,
|
|
1017
|
-
sdkOptions: PromptOptions | undefined,
|
|
1018
|
-
consumer: AgentSessionConsumer = "prompt",
|
|
1019
|
-
): Promise<void> {
|
|
1020
|
-
if (!hasExplicitModelFallbackConfig) {
|
|
1021
|
-
await promptWithPauseResume(await ensureSession(consumer), text, sdkOptions);
|
|
1022
|
-
return;
|
|
1023
|
-
}
|
|
1024
|
-
|
|
1025
|
-
const candidates = await modelCandidates();
|
|
1026
|
-
if (candidates.length === 0) {
|
|
1027
|
-
await promptWithPauseResume(await ensureSession(consumer), text, sdkOptions);
|
|
1028
|
-
return;
|
|
1029
|
-
}
|
|
1030
|
-
|
|
1031
|
-
const capturedStructuredOutputForAttempt = (): boolean =>
|
|
1032
|
-
structuredOutputCapture?.called === true && signal?.aborted !== true;
|
|
1033
|
-
const recordSuccessfulAttempt = (candidate: WorkflowResolvedModelCandidate): void => {
|
|
1034
|
-
modelAttempts.push({ model: candidate.id, success: true, ...modelAttemptReasoning(candidate) });
|
|
1035
|
-
pendingFallbackWarnings.length = 0;
|
|
1036
|
-
// The session settled on a working model; a later follow-up/turn should
|
|
1037
|
-
// resume on it rather than replaying the chain from the primary.
|
|
1038
|
-
resumeCurrentSession = true;
|
|
1039
|
-
};
|
|
1040
|
-
|
|
1041
|
-
// Resume preamble: when the stage already settled on a working model (a
|
|
1042
|
-
// post-completion follow-up, a subsequent turn, or a reattached session),
|
|
1043
|
-
// retry that model first instead of replaying the chain from an unavailable
|
|
1044
|
-
// primary. If that model now fails retryably, restart the full chain from
|
|
1045
|
-
// the primary.
|
|
1046
|
-
if (resumeCurrentSession && session !== undefined) {
|
|
1047
|
-
resumeCurrentSession = false;
|
|
1048
|
-
const resumedSession = session;
|
|
1049
|
-
const resumedLabel = selectedModel ?? workflowModelId(resumedSession.model) ?? candidates[0]!.id;
|
|
1050
|
-
notifyModelFallbackMetaChange();
|
|
1051
|
-
try {
|
|
1052
|
-
const { terminalScanStartIndex } = await promptWithPauseResume(resumedSession, text, sdkOptions);
|
|
1053
|
-
const terminalFailure = latestTerminalAssistantFailureSince(resumedSession.messages, terminalScanStartIndex);
|
|
1054
|
-
if (terminalFailure === undefined || capturedStructuredOutputForAttempt()) {
|
|
1055
|
-
modelAttempts.push({ model: resumedLabel, success: true });
|
|
1056
|
-
pendingFallbackWarnings.length = 0;
|
|
1057
|
-
resumeCurrentSession = true;
|
|
1058
|
-
return;
|
|
1059
|
-
}
|
|
1060
|
-
throw new WorkflowPromptModelFailure(terminalFailure);
|
|
1061
|
-
} catch (err) {
|
|
1062
|
-
if (capturedStructuredOutputForAttempt() && isRetryableModelFailure(err)) {
|
|
1063
|
-
modelAttempts.push({ model: resumedLabel, success: true });
|
|
1064
|
-
pendingFallbackWarnings.length = 0;
|
|
1065
|
-
resumeCurrentSession = true;
|
|
1066
|
-
return;
|
|
1067
|
-
}
|
|
1068
|
-
const message = errorMessage(err);
|
|
1069
|
-
modelAttempts.push({ model: resumedLabel, success: false, error: message });
|
|
1070
|
-
if (signal?.aborted || !isRetryableModelFailure(err)) {
|
|
1071
|
-
modelWarnings.push(...pendingFallbackWarnings);
|
|
1072
|
-
pendingFallbackWarnings.length = 0;
|
|
1073
|
-
notifyModelFallbackMetaChange();
|
|
1074
|
-
throw err;
|
|
1075
|
-
}
|
|
1076
|
-
// The resumed model failed retryably: restart the whole fallback chain
|
|
1077
|
-
// from the primary. disposeCurrentSession clears resumeCurrentSession.
|
|
1078
|
-
pendingFallbackWarnings.push(`[fallback] resume on ${resumedLabel} failed: ${message}. Restarting fallback from ${candidateLabel(candidates[0]!)}.`);
|
|
1079
|
-
await disposeCurrentSession();
|
|
1080
|
-
activeCandidateIndex = undefined;
|
|
1081
|
-
}
|
|
1082
|
-
}
|
|
1083
|
-
|
|
1084
|
-
let index = activeCandidateIndex ?? 0;
|
|
1085
|
-
|
|
1086
|
-
while (index < candidates.length) {
|
|
1087
|
-
const candidate = candidates[index]!;
|
|
1088
|
-
const activeSession = session && activeCandidateIndex === index
|
|
1089
|
-
? session
|
|
1090
|
-
: await createSession(candidate, consumer);
|
|
1091
|
-
activeCandidateIndex = index;
|
|
1092
|
-
selectedModel = candidate.id;
|
|
1093
|
-
notifyModelFallbackMetaChange();
|
|
1094
|
-
try {
|
|
1095
|
-
const { terminalScanStartIndex } = await promptWithPauseResume(activeSession, text, sdkOptions);
|
|
1096
|
-
const terminalFailure = latestTerminalAssistantFailureSince(activeSession.messages, terminalScanStartIndex);
|
|
1097
|
-
if (terminalFailure !== undefined) {
|
|
1098
|
-
if (capturedStructuredOutputForAttempt()) {
|
|
1099
|
-
recordSuccessfulAttempt(candidate);
|
|
1100
|
-
return;
|
|
1101
|
-
}
|
|
1102
|
-
throw new WorkflowPromptModelFailure(terminalFailure);
|
|
1103
|
-
}
|
|
1104
|
-
recordSuccessfulAttempt(candidate);
|
|
1105
|
-
return;
|
|
1106
|
-
} catch (err) {
|
|
1107
|
-
const message = errorMessage(err);
|
|
1108
|
-
if (capturedStructuredOutputForAttempt() && isRetryableModelFailure(err)) {
|
|
1109
|
-
recordSuccessfulAttempt(candidate);
|
|
1110
|
-
return;
|
|
1111
|
-
}
|
|
1112
|
-
modelAttempts.push({ model: candidate.id, success: false, ...modelAttemptReasoning(candidate), error: message });
|
|
1113
|
-
if (signal?.aborted || !isRetryableModelFailure(err) || index === candidates.length - 1) {
|
|
1114
|
-
modelWarnings.push(...pendingFallbackWarnings);
|
|
1115
|
-
pendingFallbackWarnings.length = 0;
|
|
1116
|
-
notifyModelFallbackMetaChange();
|
|
1117
|
-
throw err;
|
|
1118
|
-
}
|
|
1119
|
-
const nextCandidate = candidates[index + 1]!;
|
|
1120
|
-
pendingFallbackWarnings.push(`[fallback] ${candidateLabel(candidate)} failed: ${message}. Retrying with ${candidateLabel(nextCandidate)}.`);
|
|
1121
|
-
await disposeCurrentSession();
|
|
1122
|
-
index += 1;
|
|
1123
|
-
}
|
|
1124
|
-
}
|
|
1125
|
-
}
|
|
1126
|
-
|
|
1127
|
-
function requireSession(property: string): StageSessionRuntime {
|
|
1128
|
-
if (!session) unavailableSync(property);
|
|
1129
|
-
return session;
|
|
1130
|
-
}
|
|
1131
|
-
|
|
1132
|
-
return {
|
|
1133
|
-
name: stageName,
|
|
1134
|
-
|
|
1135
|
-
async prompt(text, options) {
|
|
1136
|
-
const { sdkOptions, outputOptions } = splitPromptOptions(options);
|
|
1137
|
-
const runtimeCwd = typeof effectiveStageOptions?.cwd === "string" ? effectiveStageOptions.cwd : process.cwd();
|
|
1138
|
-
validatePromptOutputOptions(outputOptions);
|
|
1139
|
-
if (structuredOutputCapture?.called) {
|
|
1140
|
-
throw new Error("atomic-workflows: stage schema supports one prompt() call per stage context because structured_output may be called exactly once. Create a new ctx.stage(...) for each additional schema-backed prompt.");
|
|
1141
|
-
}
|
|
1142
|
-
if (adapters.prompt) {
|
|
1143
|
-
if (structuredOutputCapture) {
|
|
1144
|
-
throw new Error("atomic-workflows: stage schema requires an AgentSessionAdapter so the structured_output tool can be registered.");
|
|
1145
|
-
}
|
|
1146
|
-
const rawText = await adapters.prompt.prompt(text, meta);
|
|
1147
|
-
lastAssistantText = await finalizePromptOutput(rawText, outputOptions, runtimeCwd);
|
|
1148
|
-
adapterMessages = assistantMessage(lastAssistantText);
|
|
1149
|
-
return lastAssistantText;
|
|
1150
|
-
}
|
|
1151
|
-
if (structuredOutputCapture) {
|
|
1152
|
-
let nextPrompt = text;
|
|
1153
|
-
let correctiveAttempts = 0;
|
|
1154
|
-
let structuredOutputError = STRUCTURED_OUTPUT_MISSING_ERROR;
|
|
1155
|
-
while (!structuredOutputCapture.called) {
|
|
1156
|
-
latestStructuredOutputToolError = undefined;
|
|
1157
|
-
await promptWithFallback(nextPrompt, sdkOptions);
|
|
1158
|
-
if (structuredOutputCapture.called) break;
|
|
1159
|
-
structuredOutputError = latestStructuredOutputToolError ?? STRUCTURED_OUTPUT_MISSING_ERROR;
|
|
1160
|
-
if (correctiveAttempts >= STRUCTURED_OUTPUT_MAX_CORRECTIVE_PROMPTS) {
|
|
1161
|
-
throw new Error(structuredOutputError);
|
|
1162
|
-
}
|
|
1163
|
-
correctiveAttempts += 1;
|
|
1164
|
-
nextPrompt = formatStructuredOutputCorrectionPrompt(structuredOutputError, correctiveAttempts);
|
|
1165
|
-
}
|
|
1166
|
-
const rawStructuredText = stringifyStructuredOutputValue(structuredOutputCapture.value);
|
|
1167
|
-
lastAssistantText = await finalizePromptOutput(rawStructuredText, outputOptions, runtimeCwd);
|
|
1168
|
-
return structuredOutputCapture.value as never;
|
|
1169
|
-
}
|
|
1170
|
-
await promptWithFallback(text, sdkOptions);
|
|
1171
|
-
const rawText = lastAssistantTextFromSession(session, lastAssistantText, terminatingToolCallIds) ?? "";
|
|
1172
|
-
lastAssistantText = await finalizePromptOutput(rawText, outputOptions, runtimeCwd);
|
|
1173
|
-
return lastAssistantText;
|
|
1174
|
-
},
|
|
1175
|
-
|
|
1176
|
-
async complete(text, completeOpts) {
|
|
1177
|
-
if (adapters.complete) {
|
|
1178
|
-
lastAssistantText = await adapters.complete.complete(text, completeOpts, meta);
|
|
1179
|
-
adapterMessages = assistantMessage(lastAssistantText);
|
|
1180
|
-
return lastAssistantText;
|
|
1181
|
-
}
|
|
1182
|
-
if (
|
|
1183
|
-
completeOpts?.model !== undefined ||
|
|
1184
|
-
completeOpts?.maxTokens !== undefined ||
|
|
1185
|
-
completeOpts?.fallbackModels !== undefined
|
|
1186
|
-
) {
|
|
1187
|
-
throw new Error(
|
|
1188
|
-
"atomic-workflows: complete options require a CompleteAdapter via RunOpts.adapters.complete",
|
|
1189
|
-
);
|
|
1190
|
-
}
|
|
1191
|
-
// Intentional fallback: when a CompleteAdapter is not configured,
|
|
1192
|
-
// `ctx.complete()` can still use the stage AgentSession for simple text
|
|
1193
|
-
// completions. Completion-specific options require the dedicated adapter.
|
|
1194
|
-
await promptWithFallback(text, undefined, "complete");
|
|
1195
|
-
lastAssistantText = lastAssistantTextFromSession(session, lastAssistantText, terminatingToolCallIds) ?? "";
|
|
1196
|
-
return lastAssistantText;
|
|
1197
|
-
},
|
|
1198
|
-
|
|
1199
|
-
async steer(text) {
|
|
1200
|
-
await (await ensureSession()).steer(text);
|
|
1201
|
-
},
|
|
1202
|
-
|
|
1203
|
-
async followUp(text) {
|
|
1204
|
-
await (await ensureSession()).followUp(text);
|
|
1205
|
-
},
|
|
1206
|
-
|
|
1207
|
-
subscribe(listener) {
|
|
1208
|
-
pendingListeners.add(listener);
|
|
1209
|
-
if (session) listenerUnsubscribes.set(listener, session.subscribe(listener));
|
|
1210
|
-
return () => {
|
|
1211
|
-
pendingListeners.delete(listener);
|
|
1212
|
-
const unsubscribe = listenerUnsubscribes.get(listener);
|
|
1213
|
-
listenerUnsubscribes.delete(listener);
|
|
1214
|
-
unsubscribe?.();
|
|
1215
|
-
};
|
|
1216
|
-
},
|
|
1217
|
-
|
|
1218
|
-
get sessionFile() {
|
|
1219
|
-
return session?.sessionFile;
|
|
1220
|
-
},
|
|
1221
|
-
|
|
1222
|
-
get sessionId() {
|
|
1223
|
-
return requireSession("sessionId").sessionId;
|
|
1224
|
-
},
|
|
1225
|
-
|
|
1226
|
-
async setModel(model) {
|
|
1227
|
-
await (await ensureSession()).setModel(model);
|
|
1228
|
-
},
|
|
1229
|
-
|
|
1230
|
-
setThinkingLevel(level) {
|
|
1231
|
-
pendingThinkingLevel = level;
|
|
1232
|
-
session?.setThinkingLevel(level);
|
|
1233
|
-
},
|
|
1234
|
-
|
|
1235
|
-
async cycleModel() {
|
|
1236
|
-
return (await ensureSession()).cycleModel();
|
|
1237
|
-
},
|
|
1238
|
-
|
|
1239
|
-
cycleThinkingLevel() {
|
|
1240
|
-
return requireSession("cycleThinkingLevel").cycleThinkingLevel();
|
|
1241
|
-
},
|
|
1242
|
-
|
|
1243
|
-
get agent() {
|
|
1244
|
-
return requireSession("agent").agent;
|
|
1245
|
-
},
|
|
1246
|
-
|
|
1247
|
-
get model() {
|
|
1248
|
-
return session?.model;
|
|
1249
|
-
},
|
|
1250
|
-
|
|
1251
|
-
get thinkingLevel() {
|
|
1252
|
-
return requireSession("thinkingLevel").thinkingLevel;
|
|
1253
|
-
},
|
|
1254
|
-
|
|
1255
|
-
get messages() {
|
|
1256
|
-
return session?.messages ?? adapterMessages;
|
|
1257
|
-
},
|
|
1258
|
-
|
|
1259
|
-
get isStreaming() {
|
|
1260
|
-
return session?.isStreaming ?? false;
|
|
1261
|
-
},
|
|
1262
|
-
|
|
1263
|
-
async navigateTree(targetId, options) {
|
|
1264
|
-
return (await ensureSession()).navigateTree(targetId, options);
|
|
1265
|
-
},
|
|
1266
|
-
|
|
1267
|
-
async compact() {
|
|
1268
|
-
return (await ensureSession()).compact();
|
|
1269
|
-
},
|
|
1270
|
-
|
|
1271
|
-
abortCompaction() {
|
|
1272
|
-
session?.abortCompaction();
|
|
1273
|
-
},
|
|
1274
|
-
|
|
1275
|
-
async abort() {
|
|
1276
|
-
await session?.abort();
|
|
1277
|
-
},
|
|
1278
|
-
|
|
1279
|
-
async __dispose() {
|
|
1280
|
-
disposed = true;
|
|
1281
|
-
for (const unsubscribe of listenerUnsubscribes.values()) unsubscribe();
|
|
1282
|
-
listenerUnsubscribes.clear();
|
|
1283
|
-
pendingListeners.clear();
|
|
1284
|
-
unsubscribeTerminateWatcher?.();
|
|
1285
|
-
unsubscribeTerminateWatcher = undefined;
|
|
1286
|
-
terminatingToolCallIds.clear();
|
|
1287
|
-
await disposeStageSession(session);
|
|
1288
|
-
},
|
|
1289
|
-
|
|
1290
|
-
__getLastAssistantText() {
|
|
1291
|
-
return lastAssistantTextFromSession(session, lastAssistantText, terminatingToolCallIds);
|
|
1292
|
-
},
|
|
1293
|
-
|
|
1294
|
-
getLastAssistantText() {
|
|
1295
|
-
return lastAssistantTextFromSession(session, lastAssistantText, terminatingToolCallIds);
|
|
1296
|
-
},
|
|
1297
|
-
|
|
1298
|
-
async __ensureSession() {
|
|
1299
|
-
await ensureSession();
|
|
1300
|
-
},
|
|
1301
|
-
|
|
1302
|
-
async __ensureSessionFromFile(sessionFile) {
|
|
1303
|
-
await ensureSessionFromFile(sessionFile);
|
|
1304
|
-
},
|
|
1305
|
-
|
|
1306
|
-
__sessionMeta() {
|
|
1307
|
-
return {
|
|
1308
|
-
sessionId: session?.sessionId,
|
|
1309
|
-
sessionFile: session?.sessionFile,
|
|
1310
|
-
};
|
|
1311
|
-
},
|
|
1312
|
-
|
|
1313
|
-
__agentSession() {
|
|
1314
|
-
return asAgentSession(session);
|
|
1315
|
-
},
|
|
1316
|
-
|
|
1317
|
-
__pendingMessageCount() {
|
|
1318
|
-
return typeof session?.pendingMessageCount === "number" ? session.pendingMessageCount : 0;
|
|
1319
|
-
},
|
|
1320
|
-
|
|
1321
|
-
__modelFallbackMeta() {
|
|
1322
|
-
return currentModelFallbackMeta();
|
|
1323
|
-
},
|
|
1324
|
-
|
|
1325
|
-
async __requestPause() {
|
|
1326
|
-
if (pauseRequest) return;
|
|
1327
|
-
const deferred = Promise.withResolvers<{ message?: string }>();
|
|
1328
|
-
// A shutdown may reject this deferred when no prompt awaiter is actively
|
|
1329
|
-
// observing it (for example a paused pending live stream). Keep the
|
|
1330
|
-
// original promise for real waiters, but mark expected cancellation as
|
|
1331
|
-
// observed so app-exit cleanup stays quiet.
|
|
1332
|
-
void deferred.promise.catch(() => {});
|
|
1333
|
-
pauseRequest = { deferred };
|
|
1334
|
-
// Best-effort: stop the current Pi op so the awaiter races abort.
|
|
1335
|
-
// The executor's `runTrackedStageCall` re-issues the call once
|
|
1336
|
-
// `__resume()` settles `pauseRequest.deferred`.
|
|
1337
|
-
await session?.abort();
|
|
1338
|
-
},
|
|
1339
|
-
|
|
1340
|
-
async __resume(message?: string) {
|
|
1341
|
-
const req = pauseRequest;
|
|
1342
|
-
if (!req) return;
|
|
1343
|
-
pauseRequest = null;
|
|
1344
|
-
req.deferred.resolve({ message });
|
|
1345
|
-
},
|
|
1346
|
-
|
|
1347
|
-
__isPaused() {
|
|
1348
|
-
return pauseRequest !== null;
|
|
1349
|
-
},
|
|
1350
|
-
|
|
1351
|
-
__structuredOutputFinalized() {
|
|
1352
|
-
return structuredOutputCapture?.called === true;
|
|
1353
|
-
},
|
|
1354
|
-
};
|
|
1355
|
-
}
|
|
1356
|
-
|
|
1357
|
-
function assistantMessage(text: string): AgentSession["messages"] {
|
|
1358
|
-
return [
|
|
1359
|
-
{
|
|
1360
|
-
role: "assistant",
|
|
1361
|
-
content: [{ type: "text", text }],
|
|
1362
|
-
},
|
|
1363
|
-
] as AgentSession["messages"];
|
|
1364
|
-
}
|
|
10
|
+
export { createStageContext } from "./stage-runner-context.js";
|
|
11
|
+
export type {
|
|
12
|
+
AgentSessionAdapter,
|
|
13
|
+
CompleteAdapter,
|
|
14
|
+
InternalStageContext,
|
|
15
|
+
PromptAdapter,
|
|
16
|
+
StageAdapters,
|
|
17
|
+
StageModelFallbackMeta,
|
|
18
|
+
StageRunnerOpts,
|
|
19
|
+
StageSessionCreateOptions,
|
|
20
|
+
StageSessionCreateResult,
|
|
21
|
+
StageSessionRuntime,
|
|
22
|
+
} from "./stage-runner-types.js";
|