@bastani/atomic 0.9.12 → 0.9.13-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 +150 -0
- package/README.md +35 -17
- package/dist/builtin/i-have-adhd/CHANGELOG.md +17 -0
- package/dist/builtin/i-have-adhd/LICENSE +21 -0
- package/dist/builtin/i-have-adhd/README.md +18 -0
- package/dist/builtin/i-have-adhd/index.ts +238 -0
- package/dist/builtin/i-have-adhd/package.json +56 -0
- package/dist/builtin/i-have-adhd/skills/i-have-adhd/SKILL.md +140 -0
- package/dist/builtin/intercom/CHANGELOG.md +25 -0
- package/dist/builtin/intercom/README.md +30 -16
- package/dist/builtin/intercom/broker/bounded-stderr-install.ts +18 -0
- package/dist/builtin/intercom/broker/bounded-stderr.ts +132 -0
- package/dist/builtin/intercom/broker/broker.ts +12 -23
- package/dist/builtin/intercom/broker/client.ts +81 -5
- package/dist/builtin/intercom/broker/paths.ts +9 -0
- package/dist/builtin/intercom/broker/presence-handler.ts +103 -0
- package/dist/builtin/intercom/broker/spawn.ts +128 -29
- package/dist/builtin/intercom/contact-supervisor-tool.ts +13 -3
- package/dist/builtin/intercom/foreground-detach-handoff.ts +30 -14
- package/dist/builtin/intercom/group.ts +64 -25
- package/dist/builtin/intercom/index-heavy.ts +51 -8
- package/dist/builtin/intercom/index.ts +50 -22
- package/dist/builtin/intercom/intercom-tool.ts +82 -5
- package/dist/builtin/intercom/intercom-utils.ts +15 -29
- package/dist/builtin/intercom/lazy-subagent-ack.ts +11 -6
- package/dist/builtin/intercom/package.json +2 -3
- package/dist/builtin/intercom/runtime-group.ts +13 -0
- package/dist/builtin/intercom/skills/intercom/SKILL.md +30 -2
- package/dist/builtin/intercom/source-ownership.ts +9 -12
- package/dist/builtin/intercom/subagent-relay.ts +32 -16
- package/dist/builtin/intercom/terminal-ordering-barrier.ts +21 -4
- package/dist/builtin/intercom/types.ts +3 -1
- package/dist/builtin/intercom/ui/compose.ts +8 -6
- package/dist/builtin/intercom/ui/session-list.ts +7 -5
- package/dist/builtin/mcp/CHANGELOG.md +19 -0
- package/dist/builtin/mcp/README.md +3 -1
- package/dist/builtin/mcp/glimpse-ui.ts +2 -1
- package/dist/builtin/mcp/index.ts +10 -26
- package/dist/builtin/mcp/mcp-panel.ts +35 -34
- package/dist/builtin/mcp/mcp-setup-panel.ts +35 -33
- package/dist/builtin/mcp/npx-resolver.ts +3 -2
- package/dist/builtin/mcp/package.json +3 -3
- package/dist/builtin/mcp/sampling-handler.ts +5 -1
- package/dist/builtin/mcp/server-manager.ts +4 -7
- package/dist/builtin/mcp/startup-warmup.ts +20 -8
- package/dist/builtin/subagents/CHANGELOG.md +63 -0
- package/dist/builtin/subagents/README.md +144 -351
- package/dist/builtin/subagents/agents/worker.md +1 -1
- package/dist/builtin/subagents/package.json +5 -5
- package/dist/builtin/subagents/prompts/parallel-context-build.md +2 -2
- package/dist/builtin/subagents/prompts/parallel-handoff-plan.md +4 -4
- package/dist/builtin/subagents/prompts/review-loop.md +1 -1
- package/dist/builtin/subagents/skills/subagent/SKILL.md +39 -102
- package/dist/builtin/subagents/src/agents/agent-discovery.ts +1 -29
- package/dist/builtin/subagents/src/agents/agent-loaders.ts +1 -40
- package/dist/builtin/subagents/src/agents/agent-management-helpers.ts +6 -135
- package/dist/builtin/subagents/src/agents/agent-management.ts +52 -282
- package/dist/builtin/subagents/src/agents/agent-paths.ts +0 -22
- package/dist/builtin/subagents/src/agents/agent-types.ts +0 -40
- package/dist/builtin/subagents/src/agents/agents.ts +0 -3
- package/dist/builtin/subagents/src/agents/identity.ts +2 -4
- package/dist/builtin/subagents/src/agents/skills-paths.ts +8 -1
- package/dist/builtin/subagents/src/extension/doctor.ts +4 -24
- package/dist/builtin/subagents/src/extension/fanout-child.ts +76 -56
- package/dist/builtin/subagents/src/extension/index.ts +32 -39
- package/dist/builtin/subagents/src/extension/prompt-guidance.ts +2 -2
- package/dist/builtin/subagents/src/extension/schemas.ts +1 -157
- package/dist/builtin/subagents/src/extension/startup-maintenance.ts +25 -46
- package/dist/builtin/subagents/src/extension/tool-description.ts +4 -13
- package/dist/builtin/subagents/src/intercom/intercom-bridge.ts +6 -2
- package/dist/builtin/subagents/src/intercom/result-intercom.ts +27 -29
- package/dist/builtin/subagents/src/intercom/supervisor-authorization.ts +9 -2
- package/dist/builtin/subagents/src/runs/background/async-job-tracker.ts +248 -435
- package/dist/builtin/subagents/src/runs/background/completion-notification.ts +8 -3
- package/dist/builtin/subagents/src/runs/background/notify.ts +83 -26
- package/dist/builtin/subagents/src/runs/foreground/execution-run-sync.ts +1 -281
- package/dist/builtin/subagents/src/runs/foreground/execution-updates.ts +0 -5
- package/dist/builtin/subagents/src/runs/foreground/execution.ts +1 -4
- package/dist/builtin/subagents/src/runs/foreground/inprocess-run-sync.ts +559 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-async.ts +103 -259
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-context.ts +29 -31
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-input.ts +10 -173
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel-task.ts +7 -5
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel.ts +13 -6
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-resume.ts +1 -646
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-runtime.ts +2 -7
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-single.ts +14 -7
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-status.ts +39 -20
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-types.ts +16 -11
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-worktree.ts +1 -14
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor.ts +194 -104
- package/dist/builtin/subagents/src/runs/inprocess/background-single.ts +195 -0
- package/dist/builtin/subagents/src/runs/inprocess/background.ts +90 -0
- package/dist/builtin/subagents/src/runs/inprocess/child-policy.ts +27 -0
- package/dist/builtin/subagents/src/runs/inprocess/control-registry.ts +55 -0
- package/dist/builtin/subagents/src/runs/inprocess/control-status.ts +106 -0
- package/dist/builtin/subagents/src/runs/inprocess/index.ts +50 -0
- package/dist/builtin/subagents/src/runs/inprocess/nested-routing.ts +218 -0
- package/dist/builtin/subagents/src/runs/{shared/subagent-prompt-runtime.ts → inprocess/prompt-behavior.ts} +37 -75
- package/dist/builtin/subagents/src/runs/inprocess/runner.ts +1392 -0
- package/dist/builtin/subagents/src/runs/{shared/nested-events.ts → inprocess/runtime-support/nested-api.ts} +13 -7
- package/dist/builtin/subagents/src/runs/{shared/nested-events-control.ts → inprocess/runtime-support/nested-control.ts} +18 -17
- package/dist/builtin/subagents/src/runs/{shared/nested-events-core.ts → inprocess/runtime-support/nested-core.ts} +14 -61
- package/dist/builtin/subagents/src/runs/{shared/nested-events-projection.ts → inprocess/runtime-support/nested-projection.ts} +4 -12
- package/dist/builtin/subagents/src/runs/{shared/nested-events-registry.ts → inprocess/runtime-support/nested-registry.ts} +19 -4
- package/dist/builtin/subagents/src/runs/{shared/nested-render.ts → inprocess/runtime-support/nested-rendering.ts} +3 -3
- package/dist/builtin/subagents/src/runs/{shared/nested-events-sanitize.ts → inprocess/runtime-support/nested-sanitize.ts} +4 -6
- package/dist/builtin/subagents/src/runs/inprocess.ts +1 -0
- package/dist/builtin/subagents/src/runs/shared/intercom-group.ts +23 -7
- package/dist/builtin/subagents/src/runs/shared/model-candidate-filter.ts +0 -1
- package/dist/builtin/subagents/src/runs/shared/model-fallback.ts +15 -492
- package/dist/builtin/subagents/src/runs/shared/parallel-utils.ts +13 -97
- package/dist/builtin/subagents/src/runs/shared/run-history.ts +3 -5
- package/dist/builtin/subagents/src/runs/shared/single-output.ts +4 -4
- package/dist/builtin/subagents/src/runs/shared/worktree.ts +7 -2
- package/dist/builtin/subagents/src/shared/formatters.ts +2 -56
- package/dist/builtin/subagents/src/shared/settings.ts +14 -350
- package/dist/builtin/subagents/src/shared/types-async.ts +8 -32
- package/dist/builtin/subagents/src/shared/types-config.ts +29 -13
- package/dist/builtin/subagents/src/shared/types-depth.ts +30 -56
- package/dist/builtin/subagents/src/shared/types-results.ts +18 -60
- package/dist/builtin/subagents/src/shared/types-runtime.ts +0 -1
- package/dist/builtin/subagents/src/shared/utils.ts +5 -0
- package/dist/builtin/subagents/src/slash/bridge-settlement.ts +87 -0
- package/dist/builtin/subagents/src/slash/prompt-template-bridge.ts +49 -10
- package/dist/builtin/subagents/src/slash/slash-bridge.ts +27 -7
- package/dist/builtin/subagents/src/slash/slash-commands.ts +37 -82
- package/dist/builtin/subagents/src/slash/slash-live-state.ts +3 -94
- package/dist/builtin/subagents/src/tui/render-event-formatting.ts +3 -35
- package/dist/builtin/subagents/src/tui/render-progress.ts +89 -0
- package/dist/builtin/subagents/src/tui/render-result-compact.ts +77 -68
- package/dist/builtin/subagents/src/tui/render-result.ts +79 -99
- package/dist/builtin/subagents/src/tui/render-stable-output.ts +1 -6
- package/dist/builtin/subagents/src/tui/render-status-progress.ts +8 -5
- package/dist/builtin/subagents/src/tui/render-widget-graph.ts +6 -63
- package/dist/builtin/subagents/src/tui/render-widget.ts +0 -24
- package/dist/builtin/web-access/CHANGELOG.md +14 -0
- package/dist/builtin/web-access/chrome-cookies.ts +3 -2
- package/dist/builtin/web-access/github-api.ts +7 -6
- package/dist/builtin/web-access/github-extract.ts +2 -1
- package/dist/builtin/web-access/package.json +3 -3
- package/dist/builtin/web-access/subprocess.ts +3 -1
- package/dist/builtin/web-access/summary-review.ts +2 -2
- package/dist/builtin/web-access/web-search-features.ts +38 -22
- package/dist/builtin/web-access/web-search-summary.ts +2 -2
- package/dist/builtin/workflows/CHANGELOG.md +70 -0
- package/dist/builtin/workflows/README.md +54 -4
- package/dist/builtin/workflows/builtin/open-claude-design-utils.ts +3 -0
- package/dist/builtin/workflows/builtin/ralph-models.ts +25 -20
- package/dist/builtin/workflows/builtin/shared-prompts.ts +5 -2
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/src/durable/backend.ts +25 -1
- package/dist/builtin/workflows/src/durable/completed-catalog-stage-groups.ts +60 -3
- package/dist/builtin/workflows/src/durable/completed-catalog.ts +67 -1
- package/dist/builtin/workflows/src/durable/completed-subtree.ts +22 -7
- package/dist/builtin/workflows/src/durable/dbos-metadata.ts +15 -1
- package/dist/builtin/workflows/src/durable/local-command.ts +2 -1
- package/dist/builtin/workflows/src/durable/resume-runtime.ts +1 -0
- package/dist/builtin/workflows/src/durable/tool-primitive.ts +4 -28
- package/dist/builtin/workflows/src/durable/types.ts +22 -1
- package/dist/builtin/workflows/src/durable/workflow-child-result.ts +3 -1
- package/dist/builtin/workflows/src/engine/primitives/workflow.ts +1 -1
- package/dist/builtin/workflows/src/engine/run-durable-finalize.ts +10 -2
- package/dist/builtin/workflows/src/engine/run-durable-topology.ts +9 -2
- package/dist/builtin/workflows/src/engine/run.ts +17 -1
- package/dist/builtin/workflows/src/extension/atomic-stage-session.ts +18 -39
- package/dist/builtin/workflows/src/extension/companions.ts +1 -1
- package/dist/builtin/workflows/src/extension/config-file-loader.ts +10 -1
- package/dist/builtin/workflows/src/extension/config-loader.ts +1 -1
- package/dist/builtin/workflows/src/extension/dispatcher.ts +4 -0
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +2095 -1181
- package/dist/builtin/workflows/src/extension/lifecycle-notifications.ts +332 -39
- package/dist/builtin/workflows/src/extension/mcp.ts +13 -2
- package/dist/builtin/workflows/src/extension/render-result.ts +5 -0
- package/dist/builtin/workflows/src/extension/runtime-durable-resume.ts +6 -3
- package/dist/builtin/workflows/src/extension/runtime.ts +7 -1
- package/dist/builtin/workflows/src/extension/ui-surface.ts +7 -20
- package/dist/builtin/workflows/src/extension/wiring.ts +86 -17
- package/dist/builtin/workflows/src/extension/workflow-command-registration.ts +12 -3
- package/dist/builtin/workflows/src/extension/workflow-durable-resume-command.ts +5 -2
- package/dist/builtin/workflows/src/extension/workflow-ports.ts +14 -6
- package/dist/builtin/workflows/src/extension/workflow-prompts.ts +11 -6
- package/dist/builtin/workflows/src/extension/workflow-run-control-command.ts +17 -7
- package/dist/builtin/workflows/src/extension/workflow-status-summary.ts +11 -0
- package/dist/builtin/workflows/src/extension/workflow-tool-content.ts +18 -1
- package/dist/builtin/workflows/src/extension/workflow-tool-control.ts +12 -8
- package/dist/builtin/workflows/src/extension/workflow-tool.ts +9 -4
- package/dist/builtin/workflows/src/intercom/intercom-routing.ts +12 -6
- package/dist/builtin/workflows/src/intercom/result-intercom.ts +35 -4
- package/dist/builtin/workflows/src/runs/background/quit.ts +28 -4
- package/dist/builtin/workflows/src/runs/background/resume-acknowledgements.ts +2 -1
- package/dist/builtin/workflows/src/runs/background/status.ts +70 -8
- package/dist/builtin/workflows/src/runs/foreground/executor-abort.ts +11 -3
- package/dist/builtin/workflows/src/runs/foreground/executor-child-boundary.ts +2 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-direct-helpers.ts +4 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-exit-manager.ts +26 -2
- package/dist/builtin/workflows/src/runs/foreground/executor-prompt-nodes.ts +3 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-run-finalizers.ts +3 -2
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-control.ts +1 -1
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-context.ts +1 -1
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-controller.ts +688 -38
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-types.ts +3 -1
- package/dist/builtin/workflows/src/runs/shared/model-fallback-failures.ts +19 -514
- package/dist/builtin/workflows/src/runs/shared/retry.ts +44 -0
- package/dist/builtin/workflows/src/runs/shared/worktree-git-runner.ts +5 -2
- package/dist/builtin/workflows/src/runs/shared/worktree-setup.ts +2 -0
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +10 -3
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.ts +11 -3
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +5 -1
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.ts +5 -0
- package/dist/builtin/workflows/src/shared/graph-store-snapshot.ts +34 -2
- package/dist/builtin/workflows/src/shared/persistence-restore-helpers.ts +28 -6
- package/dist/builtin/workflows/src/shared/persistence-restore.ts +3 -0
- package/dist/builtin/workflows/src/shared/persistence-session-entries.ts +4 -0
- package/dist/builtin/workflows/src/shared/run-indicator-status.ts +75 -0
- package/dist/builtin/workflows/src/shared/stage-ui-broker.ts +10 -4
- package/dist/builtin/workflows/src/shared/store-public-types.ts +47 -9
- package/dist/builtin/workflows/src/shared/store-run-methods.ts +42 -8
- package/dist/builtin/workflows/src/shared/store-stage-methods.ts +31 -8
- package/dist/builtin/workflows/src/shared/store-types.ts +35 -1
- package/dist/builtin/workflows/src/shared/timing.ts +10 -0
- package/dist/builtin/workflows/src/shared/workflow-artifact-env.ts +21 -0
- package/dist/builtin/workflows/src/shared/workflow-artifacts.ts +2 -5
- package/dist/builtin/workflows/src/tui/chat-surface-message.ts +22 -2
- package/dist/builtin/workflows/src/tui/dispatch-confirm.ts +37 -2
- package/dist/builtin/workflows/src/tui/graph-view-constants.ts +0 -15
- package/dist/builtin/workflows/src/tui/graph-view-graph-render.ts +38 -47
- package/dist/builtin/workflows/src/tui/graph-view-input.ts +48 -45
- package/dist/builtin/workflows/src/tui/graph-view-layout.ts +266 -0
- package/dist/builtin/workflows/src/tui/graph-view-render-helpers.ts +1 -86
- package/dist/builtin/workflows/src/tui/graph-view-render.ts +209 -91
- package/dist/builtin/workflows/src/tui/graph-view-state.ts +5 -7
- package/dist/builtin/workflows/src/tui/graph-view-types.ts +13 -7
- package/dist/builtin/workflows/src/tui/inline-form-editor.ts +8 -6
- package/dist/builtin/workflows/src/tui/inline-form-overlay.ts +2 -1
- package/dist/builtin/workflows/src/tui/inputs-overlay.ts +7 -4
- package/dist/builtin/workflows/src/tui/inputs-picker-input.ts +66 -0
- package/dist/builtin/workflows/src/tui/keybindings-adapter.ts +1 -0
- package/dist/builtin/workflows/src/tui/node-card.ts +1 -1
- package/dist/builtin/workflows/src/tui/overlay-adapter.ts +18 -46
- package/dist/builtin/workflows/src/tui/overlay-terminal-modes.ts +15 -26
- package/dist/builtin/workflows/src/tui/session-list.ts +1 -1
- package/dist/builtin/workflows/src/tui/session-overlays.ts +19 -12
- package/dist/builtin/workflows/src/tui/session-picker.ts +47 -4
- package/dist/builtin/workflows/src/tui/stage-chat-view-footer-status.ts +5 -14
- package/dist/builtin/workflows/src/tui/stage-chat-view-input.ts +8 -7
- package/dist/builtin/workflows/src/tui/stage-chat-view-state.ts +12 -3
- package/dist/builtin/workflows/src/tui/stage-chat-view-types.ts +1 -11
- package/dist/builtin/workflows/src/tui/stage-chat-view.ts +0 -8
- package/dist/builtin/workflows/src/tui/status-list.ts +32 -47
- package/dist/builtin/workflows/src/tui/store-widget-installer.ts +9 -5
- package/dist/builtin/workflows/src/tui/widget.ts +16 -46
- package/dist/builtin/workflows/src/tui/workflow-attach-pane-types.ts +0 -15
- package/dist/builtin/workflows/src/tui/workflow-attach-pane.ts +2 -26
- package/dist/builtin/workflows/src/tui/workflow-status.ts +3 -3
- package/dist/bun/split-loader.js +2 -0
- package/dist/bun/split-loader.js.map +1 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +6 -2
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/auth-check.d.ts +35 -0
- package/dist/cli/auth-check.d.ts.map +1 -0
- package/dist/cli/auth-check.js +100 -0
- package/dist/cli/auth-check.js.map +1 -0
- package/dist/cli/auth-command.d.ts +27 -0
- package/dist/cli/auth-command.d.ts.map +1 -0
- package/dist/cli/auth-command.js +150 -0
- package/dist/cli/auth-command.js.map +1 -0
- package/dist/cli/config-selector.js +2 -2
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/credential-print.d.ts +18 -23
- package/dist/cli/credential-print.d.ts.map +1 -1
- package/dist/cli/credential-print.js +42 -88
- package/dist/cli/credential-print.js.map +1 -1
- package/dist/cli/experimental/auth.d.ts +16 -0
- package/dist/cli/experimental/auth.d.ts.map +1 -0
- package/dist/cli/experimental/auth.js +13 -0
- package/dist/cli/experimental/auth.js.map +1 -0
- package/dist/cli/experimental/cli.d.ts +6 -0
- package/dist/cli/experimental/cli.d.ts.map +1 -0
- package/dist/cli/experimental/cli.js +5 -0
- package/dist/cli/experimental/cli.js.map +1 -0
- package/dist/cli/experimental/command-options.d.ts +17 -0
- package/dist/cli/experimental/command-options.d.ts.map +1 -0
- package/dist/cli/experimental/command-options.js +35 -0
- package/dist/cli/experimental/command-options.js.map +1 -0
- package/dist/cli/experimental/command.d.ts +63 -0
- package/dist/cli/experimental/command.d.ts.map +1 -0
- package/dist/cli/experimental/command.js +127 -0
- package/dist/cli/experimental/command.js.map +1 -0
- package/dist/cli/experimental/commands/client.d.ts +13 -0
- package/dist/cli/experimental/commands/client.d.ts.map +1 -0
- package/dist/cli/experimental/commands/client.js +25 -0
- package/dist/cli/experimental/commands/client.js.map +1 -0
- package/dist/cli/experimental/commands/pi.d.ts +15 -0
- package/dist/cli/experimental/commands/pi.d.ts.map +1 -0
- package/dist/cli/experimental/commands/pi.js +28 -0
- package/dist/cli/experimental/commands/pi.js.map +1 -0
- package/dist/cli/experimental/commands/server.d.ts +13 -0
- package/dist/cli/experimental/commands/server.d.ts.map +1 -0
- package/dist/cli/experimental/commands/server.js +25 -0
- package/dist/cli/experimental/commands/server.js.map +1 -0
- package/dist/cli/experimental/transport-address.d.ts +10 -0
- package/dist/cli/experimental/transport-address.d.ts.map +1 -0
- package/dist/cli/experimental/transport-address.js +38 -0
- package/dist/cli/experimental/transport-address.js.map +1 -0
- package/dist/cli/session-picker.js +2 -2
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/cli/startup-ui.d.ts.map +1 -1
- package/dist/cli/startup-ui.js +4 -10
- package/dist/cli/startup-ui.js.map +1 -1
- package/dist/cli.js +2 -0
- package/dist/cli.js.map +1 -1
- package/dist/client/index.d.ts +3 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +3 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/remote-session.d.ts +64 -0
- package/dist/client/remote-session.d.ts.map +1 -0
- package/dist/client/remote-session.js +351 -0
- package/dist/client/remote-session.js.map +1 -0
- package/dist/client/transcript.d.ts +12 -0
- package/dist/client/transcript.d.ts.map +1 -0
- package/dist/client/transcript.js +98 -0
- package/dist/client/transcript.js.map +1 -0
- package/dist/core/agent-session-auto-compaction.d.ts +17 -13
- package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-auto-compaction.js +192 -67
- package/dist/core/agent-session-auto-compaction.js.map +1 -1
- package/dist/core/agent-session-bash.d.ts.map +1 -1
- package/dist/core/agent-session-bash.js +2 -0
- package/dist/core/agent-session-bash.js.map +1 -1
- package/dist/core/agent-session-compaction.d.ts +3 -6
- package/dist/core/agent-session-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-compaction.js +64 -28
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-events.d.ts +1 -11
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +64 -37
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
- package/dist/core/agent-session-extension-bindings.js +4 -2
- package/dist/core/agent-session-extension-bindings.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +19 -2
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-models.d.ts +1 -0
- package/dist/core/agent-session-models.d.ts.map +1 -1
- package/dist/core/agent-session-models.js +23 -5
- package/dist/core/agent-session-models.js.map +1 -1
- package/dist/core/agent-session-post-tool-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-post-tool-compaction.js +22 -6
- package/dist/core/agent-session-post-tool-compaction.js.map +1 -1
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +4 -0
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-retry.d.ts +21 -4
- package/dist/core/agent-session-retry.d.ts.map +1 -1
- package/dist/core/agent-session-retry.js +232 -106
- package/dist/core/agent-session-retry.js.map +1 -1
- package/dist/core/agent-session-runtime-auth.d.ts.map +1 -1
- package/dist/core/agent-session-runtime-auth.js +3 -0
- package/dist/core/agent-session-runtime-auth.js.map +1 -1
- package/dist/core/agent-session-state.d.ts.map +1 -1
- package/dist/core/agent-session-state.js +2 -1
- package/dist/core/agent-session-state.js.map +1 -1
- package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
- package/dist/core/agent-session-tool-hooks.js +37 -14
- package/dist/core/agent-session-tool-hooks.js.map +1 -1
- package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
- package/dist/core/agent-session-tool-registry.js +5 -1
- package/dist/core/agent-session-tool-registry.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +5 -1
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts +18 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +37 -0
- 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 +2 -3
- package/dist/core/atomic-guide-command.js.map +1 -1
- package/dist/core/auth-storage.d.ts +18 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +83 -0
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/bash-executor.d.ts +5 -0
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +43 -19
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/builtin-packages.d.ts.map +1 -1
- package/dist/core/builtin-packages.js +6 -0
- package/dist/core/builtin-packages.js.map +1 -1
- package/dist/core/codex-fast-mode.d.ts.map +1 -1
- package/dist/core/codex-fast-mode.js +8 -3
- package/dist/core/codex-fast-mode.js.map +1 -1
- package/dist/core/exec.d.ts.map +1 -1
- package/dist/core/exec.js +4 -3
- package/dist/core/exec.js.map +1 -1
- package/dist/core/extensions/agent-events.d.ts +0 -1
- package/dist/core/extensions/agent-events.d.ts.map +1 -1
- package/dist/core/extensions/agent-events.js.map +1 -1
- package/dist/core/extensions/api-types.d.ts +5 -3
- package/dist/core/extensions/api-types.d.ts.map +1 -1
- package/dist/core/extensions/api-types.js.map +1 -1
- package/dist/core/extensions/context-types.d.ts +40 -0
- package/dist/core/extensions/context-types.d.ts.map +1 -1
- package/dist/core/extensions/context-types.js.map +1 -1
- package/dist/core/extensions/event-results.d.ts +5 -0
- package/dist/core/extensions/event-results.d.ts.map +1 -1
- package/dist/core/extensions/event-results.js.map +1 -1
- package/dist/core/extensions/index.d.ts +2 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js +1 -0
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader-api.d.ts.map +1 -1
- package/dist/core/extensions/loader-api.js +14 -1
- package/dist/core/extensions/loader-api.js.map +1 -1
- package/dist/core/extensions/loader-discovery.d.ts.map +1 -1
- package/dist/core/extensions/loader-discovery.js +3 -23
- package/dist/core/extensions/loader-discovery.js.map +1 -1
- package/dist/core/extensions/loader-runtime.d.ts.map +1 -1
- package/dist/core/extensions/loader-runtime.js +20 -3
- package/dist/core/extensions/loader-runtime.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +7 -1
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/extensions/message-types.d.ts +6 -0
- package/dist/core/extensions/message-types.d.ts.map +1 -1
- package/dist/core/extensions/message-types.js.map +1 -1
- package/dist/core/extensions/provider-types.d.ts +9 -3
- package/dist/core/extensions/provider-types.d.ts.map +1 -1
- package/dist/core/extensions/provider-types.js.map +1 -1
- package/dist/core/extensions/runner-context.d.ts +2 -1
- package/dist/core/extensions/runner-context.d.ts.map +1 -1
- package/dist/core/extensions/runner-context.js +4 -0
- package/dist/core/extensions/runner-context.js.map +1 -1
- package/dist/core/extensions/runner-registries.d.ts +2 -1
- package/dist/core/extensions/runner-registries.d.ts.map +1 -1
- package/dist/core/extensions/runner-registries.js +3 -0
- package/dist/core/extensions/runner-registries.js.map +1 -1
- package/dist/core/extensions/runner-ui.d.ts.map +1 -1
- package/dist/core/extensions/runner-ui.js +1 -0
- package/dist/core/extensions/runner-ui.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +4 -2
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +9 -3
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/runtime-types.d.ts +4 -1
- package/dist/core/extensions/runtime-types.d.ts.map +1 -1
- package/dist/core/extensions/runtime-types.js.map +1 -1
- package/dist/core/extensions/stale-context.d.ts +5 -0
- package/dist/core/extensions/stale-context.d.ts.map +1 -0
- package/dist/core/extensions/stale-context.js +11 -0
- package/dist/core/extensions/stale-context.js.map +1 -0
- package/dist/core/extensions/ui-types.d.ts +14 -11
- package/dist/core/extensions/ui-types.d.ts.map +1 -1
- package/dist/core/extensions/ui-types.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +3 -2
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/intercom-runtime-group.d.ts +13 -0
- package/dist/core/intercom-runtime-group.d.ts.map +1 -0
- package/dist/core/intercom-runtime-group.js +23 -0
- package/dist/core/intercom-runtime-group.js.map +1 -0
- package/dist/core/keybindings.d.ts +44 -4
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/model-config.d.ts +39 -5
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +6 -0
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-fallback-failures.d.ts +30 -0
- package/dist/core/model-fallback-failures.d.ts.map +1 -0
- package/dist/core/model-fallback-failures.js +610 -0
- package/dist/core/model-fallback-failures.js.map +1 -0
- package/dist/core/model-registry.d.ts +12 -5
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +20 -12
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver-cli.d.ts.map +1 -1
- package/dist/core/model-resolver-cli.js +46 -14
- package/dist/core/model-resolver-cli.js.map +1 -1
- package/dist/core/model-resolver-defaults.d.ts.map +1 -1
- package/dist/core/model-resolver-defaults.js +2 -0
- package/dist/core/model-resolver-defaults.js.map +1 -1
- package/dist/core/model-resolver-scope.d.ts +2 -0
- package/dist/core/model-resolver-scope.d.ts.map +1 -1
- package/dist/core/model-resolver-scope.js +12 -9
- package/dist/core/model-resolver-scope.js.map +1 -1
- package/dist/core/model-resolver.d.ts +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +1 -1
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime-snapshot.d.ts +10 -0
- package/dist/core/model-runtime-snapshot.d.ts.map +1 -1
- package/dist/core/model-runtime-snapshot.js +14 -1
- package/dist/core/model-runtime-snapshot.js.map +1 -1
- package/dist/core/model-runtime-streaming.d.ts +3 -1
- package/dist/core/model-runtime-streaming.d.ts.map +1 -1
- package/dist/core/model-runtime-streaming.js +16 -0
- package/dist/core/model-runtime-streaming.js.map +1 -1
- package/dist/core/model-runtime-types.d.ts +2 -0
- package/dist/core/model-runtime-types.d.ts.map +1 -1
- package/dist/core/model-runtime-types.js.map +1 -1
- package/dist/core/model-runtime.d.ts +37 -10
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +312 -113
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/oauth-login.d.ts.map +1 -1
- package/dist/core/oauth-login.js +2 -1
- package/dist/core/oauth-login.js.map +1 -1
- package/dist/core/openai-responses-payload-sanitizer.d.ts.map +1 -1
- package/dist/core/openai-responses-payload-sanitizer.js +18 -2
- package/dist/core/openai-responses-payload-sanitizer.js.map +1 -1
- package/dist/core/package-manager-git.d.ts.map +1 -1
- package/dist/core/package-manager-git.js +56 -10
- package/dist/core/package-manager-git.js.map +1 -1
- package/dist/core/package-manager-manifest.d.ts +1 -1
- package/dist/core/package-manager-manifest.d.ts.map +1 -1
- package/dist/core/package-manager-manifest.js +19 -9
- package/dist/core/package-manager-manifest.js.map +1 -1
- package/dist/core/package-manager-resource-collector.js.map +1 -1
- package/dist/core/package-manager-resource-files.d.ts.map +1 -1
- package/dist/core/package-manager-resource-files.js +1 -2
- package/dist/core/package-manager-resource-files.js.map +1 -1
- package/dist/core/provider-composer-internal.d.ts +10 -2
- package/dist/core/provider-composer-internal.d.ts.map +1 -1
- package/dist/core/provider-composer-internal.js +7 -3
- package/dist/core/provider-composer-internal.js.map +1 -1
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +19 -12
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/provider-display-names.d.ts.map +1 -1
- package/dist/core/provider-display-names.js +2 -0
- package/dist/core/provider-display-names.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +77 -67
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resolve-config-value.d.ts.map +1 -1
- package/dist/core/resolve-config-value.js +3 -0
- package/dist/core/resolve-config-value.js.map +1 -1
- package/dist/core/resource-loader-context-files.d.ts.map +1 -1
- package/dist/core/resource-loader-context-files.js +13 -5
- package/dist/core/resource-loader-context-files.js.map +1 -1
- package/dist/core/retry-policy.d.ts +30 -0
- package/dist/core/retry-policy.d.ts.map +1 -0
- package/dist/core/retry-policy.js +25 -0
- package/dist/core/retry-policy.js.map +1 -0
- package/dist/core/runtime-credentials.d.ts +5 -5
- package/dist/core/runtime-credentials.d.ts.map +1 -1
- package/dist/core/runtime-credentials.js +8 -8
- package/dist/core/runtime-credentials.js.map +1 -1
- package/dist/core/sdk-types.d.ts +8 -2
- package/dist/core/sdk-types.d.ts.map +1 -1
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +6 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager-core.d.ts +2 -0
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +7 -0
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-list.d.ts.map +1 -1
- package/dist/core/session-manager-list.js +3 -1
- package/dist/core/session-manager-list.js.map +1 -1
- package/dist/core/settings-manager-ui-accessors.d.ts +8 -1
- package/dist/core/settings-manager-ui-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-ui-accessors.js +31 -0
- package/dist/core/settings-manager-ui-accessors.js.map +1 -1
- package/dist/core/settings-manager.d.ts +2 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/settings-merge.d.ts.map +1 -1
- package/dist/core/settings-merge.js +13 -16
- package/dist/core/settings-merge.js.map +1 -1
- package/dist/core/settings-types.d.ts +5 -0
- package/dist/core/settings-types.d.ts.map +1 -1
- package/dist/core/settings-types.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +0 -2
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/questionnaire-session.d.ts +2 -2
- package/dist/core/tools/ask-user-question/state/questionnaire-session.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/state/questionnaire-session.js +39 -2
- package/dist/core/tools/ask-user-question/state/questionnaire-session.js.map +1 -1
- package/dist/core/tools/bash-async-execution.d.ts +2 -0
- package/dist/core/tools/bash-async-execution.d.ts.map +1 -1
- package/dist/core/tools/bash-async-execution.js +4 -1
- package/dist/core/tools/bash-async-execution.js.map +1 -1
- package/dist/core/tools/bash-async-output.d.ts +1 -0
- package/dist/core/tools/bash-async-output.d.ts.map +1 -1
- package/dist/core/tools/bash-async-output.js +62 -27
- package/dist/core/tools/bash-async-output.js.map +1 -1
- package/dist/core/tools/bash-pty-native.d.ts.map +1 -1
- package/dist/core/tools/bash-pty-native.js +2 -1
- package/dist/core/tools/bash-pty-native.js.map +1 -1
- package/dist/core/tools/bash.d.ts +9 -0
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +34 -16
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/directory-tree.d.ts +11 -0
- package/dist/core/tools/directory-tree.d.ts.map +1 -1
- package/dist/core/tools/directory-tree.js +26 -0
- package/dist/core/tools/directory-tree.js.map +1 -1
- package/dist/core/tools/edit.d.ts +4 -0
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +12 -8
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/errno.d.ts +25 -0
- package/dist/core/tools/errno.d.ts.map +1 -0
- package/dist/core/tools/errno.js +29 -0
- package/dist/core/tools/errno.js.map +1 -0
- package/dist/core/tools/find.d.ts +8 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +20 -15
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +5 -1
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/index.d.ts +7 -7
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +7 -7
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/ls.d.ts +4 -0
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +5 -1
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts +8 -1
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +50 -28
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/oversized-tool-result.d.ts.map +1 -1
- package/dist/core/tools/oversized-tool-result.js +129 -22
- package/dist/core/tools/oversized-tool-result.js.map +1 -1
- package/dist/core/tools/persisted-output-file.d.ts +80 -0
- package/dist/core/tools/persisted-output-file.d.ts.map +1 -0
- package/dist/core/tools/persisted-output-file.js +284 -0
- package/dist/core/tools/persisted-output-file.js.map +1 -0
- package/dist/core/tools/read.d.ts +10 -0
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +20 -8
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/search.d.ts +4 -0
- package/dist/core/tools/search.d.ts.map +1 -1
- package/dist/core/tools/search.js +5 -1
- package/dist/core/tools/search.js.map +1 -1
- package/dist/core/tools/session-temp-cleanup.d.ts +133 -0
- package/dist/core/tools/session-temp-cleanup.d.ts.map +1 -0
- package/dist/core/tools/session-temp-cleanup.js +669 -0
- package/dist/core/tools/session-temp-cleanup.js.map +1 -0
- package/dist/core/tools/session-temp-dir.d.ts +116 -0
- package/dist/core/tools/session-temp-dir.d.ts.map +1 -0
- package/dist/core/tools/session-temp-dir.js +409 -0
- package/dist/core/tools/session-temp-dir.js.map +1 -0
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js +2 -0
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/core/tools/tool-limits.d.ts +11 -0
- package/dist/core/tools/tool-limits.d.ts.map +1 -1
- package/dist/core/tools/tool-limits.js +11 -0
- package/dist/core/tools/tool-limits.js.map +1 -1
- package/dist/core/tools/windows-directory-security.d.ts +82 -0
- package/dist/core/tools/windows-directory-security.d.ts.map +1 -0
- package/dist/core/tools/windows-directory-security.js +238 -0
- package/dist/core/tools/windows-directory-security.js.map +1 -0
- package/dist/core/tools/write.d.ts +4 -0
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +8 -4
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/trust-manager.js +1 -1
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/extensions/llama/huggingface-ui.d.ts +1 -1
- package/dist/extensions/llama/huggingface-ui.d.ts.map +1 -1
- package/dist/extensions/llama/huggingface-ui.js +6 -5
- package/dist/extensions/llama/huggingface-ui.js.map +1 -1
- package/dist/extensions/llama/index.d.ts.map +1 -1
- package/dist/extensions/llama/index.js +11 -2
- package/dist/extensions/llama/index.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +24 -8
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/extensions/llama/ui.d.ts.map +1 -1
- package/dist/extensions/llama/ui.js +5 -2
- package/dist/extensions/llama/ui.js.map +1 -1
- package/dist/index-extensions.d.ts +2 -2
- package/dist/index-extensions.d.ts.map +1 -1
- package/dist/index-extensions.js +1 -1
- package/dist/index-extensions.js.map +1 -1
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/dist/main-runtime-api-key.d.ts +2 -2
- package/dist/main-runtime-api-key.d.ts.map +1 -1
- package/dist/main-runtime-api-key.js +7 -2
- package/dist/main-runtime-api-key.js.map +1 -1
- package/dist/main-session.js +2 -2
- package/dist/main-session.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +130 -26
- package/dist/main.js.map +1 -1
- package/dist/modes/index.d.ts +1 -0
- package/dist/modes/index.d.ts.map +1 -1
- package/dist/modes/index.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +6 -2
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +18 -5
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.d.ts +1 -1
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.js +5 -4
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts +2 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +3 -2
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.d.ts +17 -7
- package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.js +35 -69
- package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-actions.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-actions.js +11 -3
- package/dist/modes/interactive/components/chat-session-host-actions.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-events.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-events.js +25 -15
- package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-rendering.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-rendering.js +9 -4
- package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-state.d.ts +2 -0
- package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-state.js +2 -0
- package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.d.ts +9 -0
- package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.js +14 -0
- package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
- package/dist/modes/interactive/components/chat-transcript.d.ts +32 -0
- package/dist/modes/interactive/components/chat-transcript.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-transcript.js +173 -5
- package/dist/modes/interactive/components/chat-transcript.js.map +1 -1
- package/dist/modes/interactive/components/config-selector-list.d.ts +1 -1
- package/dist/modes/interactive/components/config-selector-list.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector-list.js +9 -8
- package/dist/modes/interactive/components/config-selector-list.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +32 -10
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts +2 -1
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +3 -2
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +3 -2
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-input.js +1 -0
- package/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/dist/modes/interactive/components/extension-selector.d.ts +1 -1
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-selector.js +4 -0
- package/dist/modes/interactive/components/extension-selector.js.map +1 -1
- package/dist/modes/interactive/components/fast-mode-selector.d.ts +1 -1
- package/dist/modes/interactive/components/fast-mode-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/fast-mode-selector.js +7 -5
- package/dist/modes/interactive/components/fast-mode-selector.js.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.d.ts +1 -1
- package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.js +3 -0
- package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
- package/dist/modes/interactive/components/footer.js +1 -1
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/host-input-form.d.ts +1 -1
- package/dist/modes/interactive/components/host-input-form.d.ts.map +1 -1
- package/dist/modes/interactive/components/host-input-form.js +6 -5
- package/dist/modes/interactive/components/host-input-form.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +1 -1
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +2 -1
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/markdown-transform.d.ts +3 -0
- package/dist/modes/interactive/components/markdown-transform.d.ts.map +1 -0
- package/dist/modes/interactive/components/markdown-transform.js +19 -0
- package/dist/modes/interactive/components/markdown-transform.js.map +1 -0
- package/dist/modes/interactive/components/mermaid.d.ts +11 -0
- package/dist/modes/interactive/components/mermaid.d.ts.map +1 -0
- package/dist/modes/interactive/components/mermaid.js +81 -0
- package/dist/modes/interactive/components/mermaid.js.map +1 -0
- package/dist/modes/interactive/components/model-selector.d.ts +2 -2
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +9 -6
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +3 -2
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +6 -2
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +39 -13
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-delete.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-delete.js +2 -1
- package/dist/modes/interactive/components/session-selector-delete.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-list.d.ts +1 -1
- package/dist/modes/interactive/components/session-selector-list.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-list.js +12 -11
- package/dist/modes/interactive/components/session-selector-list.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +3 -3
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-handlers.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-handlers.js +9 -0
- package/dist/modes/interactive/components/settings-selector-handlers.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-items.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-items.js +21 -0
- package/dist/modes/interactive/components/settings-selector-items.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-submenus.d.ts +3 -3
- package/dist/modes/interactive/components/settings-selector-submenus.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-submenus.js +6 -1
- package/dist/modes/interactive/components/settings-selector-submenus.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-types.d.ts +8 -1
- package/dist/modes/interactive/components/settings-selector-types.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +2 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +3 -2
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +2 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +50 -27
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-component.d.ts +1 -1
- package/dist/modes/interactive/components/tree-selector-component.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-component.js +2 -3
- package/dist/modes/interactive/components/tree-selector-component.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-help.d.ts +1 -1
- package/dist/modes/interactive/components/tree-selector-help.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-help.js +3 -1
- package/dist/modes/interactive/components/tree-selector-help.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-label-input.d.ts +1 -1
- package/dist/modes/interactive/components/tree-selector-label-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-label-input.js +1 -0
- package/dist/modes/interactive/components/tree-selector-label-input.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-list.d.ts +1 -1
- package/dist/modes/interactive/components/tree-selector-list.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-list.js +3 -0
- package/dist/modes/interactive/components/tree-selector-list.js.map +1 -1
- package/dist/modes/interactive/components/trust-selector.d.ts +1 -1
- package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/trust-selector.js +4 -0
- package/dist/modes/interactive/components/trust-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.d.ts +1 -1
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.js +4 -0
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts +4 -1
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +10 -2
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/external-editor.d.ts.map +1 -1
- package/dist/modes/interactive/external-editor.js +2 -1
- package/dist/modes/interactive/external-editor.js.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.js +36 -18
- package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
- package/dist/modes/interactive/interactive-auth-login.js +9 -2
- package/dist/modes/interactive/interactive-auth-login.js.map +1 -1
- package/dist/modes/interactive/interactive-auth-routing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-auth-routing.js +5 -1
- package/dist/modes/interactive/interactive-auth-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-bash-compact.js +16 -4
- package/dist/modes/interactive/interactive-bash-compact.js.map +1 -1
- package/dist/modes/interactive/interactive-deferred-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-deferred-startup.js +3 -0
- package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-editor-actions.js +2 -0
- package/dist/modes/interactive/interactive-editor-actions.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-context.js +12 -7
- package/dist/modes/interactive/interactive-extension-context.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-custom-ui.js +1 -0
- package/dist/modes/interactive/interactive-extension-custom-ui.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-dialogs.js +7 -0
- package/dist/modes/interactive/interactive-extension-dialogs.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-widgets.js +7 -24
- package/dist/modes/interactive/interactive-extension-widgets.js.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +9 -8
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +52 -3
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +143 -5
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts +2 -2
- package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.js +2 -2
- package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +9 -3
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +1 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.js +107 -41
- package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-process-lifecycle.js +1 -1
- package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.js +24 -6
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-selectors.js +44 -5
- package/dist/modes/interactive/interactive-selectors.js.map +1 -1
- package/dist/modes/interactive/interactive-session-runtime.js +1 -0
- package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +9 -4
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +37 -18
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-tui.d.ts +21 -0
- package/dist/modes/interactive/interactive-tui.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-tui.js +279 -0
- package/dist/modes/interactive/interactive-tui.js.map +1 -0
- package/dist/modes/interactive/streaming-assistant-message.d.ts +34 -0
- package/dist/modes/interactive/streaming-assistant-message.d.ts.map +1 -0
- package/dist/modes/interactive/streaming-assistant-message.js +76 -0
- package/dist/modes/interactive/streaming-assistant-message.js.map +1 -0
- package/dist/modes/interactive/theme/catppuccin-frappe.json +1 -0
- package/dist/modes/interactive/theme/catppuccin-latte.json +1 -0
- package/dist/modes/interactive/theme/catppuccin-macchiato.json +1 -0
- package/dist/modes/interactive/theme/catppuccin-mocha.json +1 -0
- package/dist/modes/interactive/theme/dark.json +1 -0
- package/dist/modes/interactive/theme/light.json +1 -0
- package/dist/modes/interactive/theme/terminal-detection.d.ts +10 -0
- package/dist/modes/interactive/theme/terminal-detection.d.ts.map +1 -1
- package/dist/modes/interactive/theme/terminal-detection.js +19 -0
- package/dist/modes/interactive/theme/terminal-detection.js.map +1 -1
- package/dist/modes/interactive/theme/theme-class.d.ts +2 -2
- package/dist/modes/interactive/theme/theme-class.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-class.js +5 -1
- package/dist/modes/interactive/theme/theme-class.js.map +1 -1
- package/dist/modes/interactive/theme/theme-controller.d.ts +3 -1
- package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-controller.js +10 -13
- package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
- package/dist/modes/interactive/theme/theme-loading.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-loading.js +1 -0
- package/dist/modes/interactive/theme/theme-loading.js.map +1 -1
- package/dist/modes/interactive/theme/theme-schema.d.ts +4 -0
- package/dist/modes/interactive/theme/theme-schema.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-schema.js +2 -1
- package/dist/modes/interactive/theme/theme-schema.js.map +1 -1
- package/dist/modes/interactive/theme/theme-schema.json +5 -1
- package/dist/modes/interactive/theme/theme.d.ts +1 -1
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +1 -1
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/interactive-engine/engine-custom-ui.d.ts +1 -1
- package/dist/modes/interactive-engine/engine-custom-ui.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-custom-ui.js +28 -11
- package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -1
- package/dist/modes/interactive-engine/engine-render-service.js +3 -3
- package/dist/modes/interactive-engine/engine-render-service.js.map +1 -1
- package/dist/modes/interactive-engine/extension-ui-bridge.d.ts +2 -1
- package/dist/modes/interactive-engine/extension-ui-bridge.d.ts.map +1 -1
- package/dist/modes/interactive-engine/extension-ui-bridge.js +2 -2
- package/dist/modes/interactive-engine/extension-ui-bridge.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +7 -0
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +7 -0
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/interactive-engine/protocol.d.ts +12 -10
- package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
- package/dist/modes/interactive-engine/protocol.js +14 -11
- package/dist/modes/interactive-engine/protocol.js.map +1 -1
- package/dist/modes/interactive-engine/remote-component.d.ts +11 -1
- package/dist/modes/interactive-engine/remote-component.d.ts.map +1 -1
- package/dist/modes/interactive-engine/remote-component.js +48 -8
- package/dist/modes/interactive-engine/remote-component.js.map +1 -1
- package/dist/modes/interactive-engine/terminal-mode-controller.d.ts +19 -12
- package/dist/modes/interactive-engine/terminal-mode-controller.d.ts.map +1 -1
- package/dist/modes/interactive-engine/terminal-mode-controller.js +54 -35
- package/dist/modes/interactive-engine/terminal-mode-controller.js.map +1 -1
- package/dist/modes/json-event.d.ts +28 -0
- package/dist/modes/json-event.d.ts.map +1 -0
- package/dist/modes/json-event.js +12 -0
- package/dist/modes/json-event.js.map +1 -0
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +2 -1
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client-process.d.ts +1 -0
- package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-process.js +5 -1
- package/dist/modes/rpc/rpc-client-process.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +7 -2
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +1 -1
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-event-buffer.d.ts +9 -0
- package/dist/modes/rpc/rpc-event-buffer.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-event-buffer.js +10 -5
- package/dist/modes/rpc/rpc-event-buffer.js.map +1 -1
- package/dist/modes/rpc/rpc-extension-ui.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-extension-ui.js +3 -0
- package/dist/modes/rpc/rpc-extension-ui.js.map +1 -1
- package/dist/modes/rpc/rpc-input.js +1 -1
- package/dist/modes/rpc/rpc-input.js.map +1 -1
- package/dist/modes/rpc/rpc-output-buffer.d.ts +9 -0
- package/dist/modes/rpc/rpc-output-buffer.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-output-buffer.js +10 -5
- package/dist/modes/rpc/rpc-output-buffer.js.map +1 -1
- package/dist/modes/rpc/rpc-provider-auth.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-provider-auth.js +3 -0
- package/dist/modes/rpc/rpc-provider-auth.js.map +1 -1
- package/dist/modes/rpc/rpc-responses.d.ts +1 -1
- package/dist/modes/rpc/rpc-responses.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-responses.js +13 -1
- package/dist/modes/rpc/rpc-responses.js.map +1 -1
- package/dist/modes/rpc/rpc-session-binding.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-session-binding.js +2 -1
- package/dist/modes/rpc/rpc-session-binding.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +9 -2
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/rpc-entry.js +2 -0
- package/dist/rpc-entry.js.map +1 -1
- package/dist/self-update-plan.d.ts.map +1 -1
- package/dist/self-update-plan.js +5 -4
- package/dist/self-update-plan.js.map +1 -1
- package/dist/server/create-harness.d.ts +53 -0
- package/dist/server/create-harness.d.ts.map +1 -0
- package/dist/server/create-harness.js +349 -0
- package/dist/server/create-harness.js.map +1 -0
- package/dist/utils/agent-attribution.d.ts +2 -0
- package/dist/utils/agent-attribution.d.ts.map +1 -0
- package/dist/utils/agent-attribution.js +2 -0
- package/dist/utils/agent-attribution.js.map +1 -0
- package/dist/utils/child-process.d.ts +3 -1
- package/dist/utils/child-process.d.ts.map +1 -1
- package/dist/utils/child-process.js +24 -4
- package/dist/utils/child-process.js.map +1 -1
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +2 -1
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +12 -3
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/management-http.d.ts +23 -0
- package/dist/utils/management-http.d.ts.map +1 -0
- package/dist/utils/management-http.js +50 -0
- package/dist/utils/management-http.js.map +1 -0
- package/dist/utils/open-browser.d.ts.map +1 -1
- package/dist/utils/open-browser.js +2 -1
- package/dist/utils/open-browser.js.map +1 -1
- package/dist/utils/paths.d.ts +2 -0
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +13 -0
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +17 -4
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/tool-result-images.d.ts +17 -0
- package/dist/utils/tool-result-images.d.ts.map +1 -0
- package/dist/utils/tool-result-images.js +41 -0
- package/dist/utils/tool-result-images.js.map +1 -0
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +7 -8
- package/dist/utils/tools-manager.js.map +1 -1
- package/dist/utils/version-check.d.ts +4 -0
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js +20 -2
- package/dist/utils/version-check.js.map +1 -1
- package/docs/compaction.md +2 -1
- package/docs/custom-provider.md +15 -7
- package/docs/development.md +1 -0
- package/docs/docs.json +1 -0
- package/docs/environment-variables.md +4 -0
- package/docs/extensions.md +102 -18
- package/docs/i-have-adhd.md +36 -0
- package/docs/intercom.md +31 -16
- package/docs/json.md +2 -2
- package/docs/keybindings.md +55 -12
- package/docs/models/model-selection.md +34 -8
- package/docs/models.md +28 -3
- package/docs/providers.md +20 -2
- package/docs/quickstart.md +5 -5
- package/docs/rpc.md +18 -12
- package/docs/sdk.md +43 -7
- package/docs/security.md +10 -10
- package/docs/sessions.md +2 -0
- package/docs/settings.md +32 -6
- package/docs/subagents.md +30 -45
- package/docs/themes.md +5 -3
- package/docs/tools.md +21 -1
- package/docs/tui.md +41 -24
- package/docs/usage.md +40 -14
- package/docs/windows.md +2 -0
- package/docs/workflows.md +237 -25
- package/examples/extensions/custom-provider-anthropic/index.ts +9 -2
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +9 -2
- package/examples/extensions/gondolin/package-lock.json +3 -3
- package/examples/extensions/modal-editor.ts +8 -10
- package/examples/extensions/rainbow-editor.ts +3 -2
- package/examples/extensions/subagent/README.md +16 -45
- package/examples/extensions/subagent/index.ts +6 -96
- package/examples/extensions/subagent/render.ts +0 -78
- package/examples/extensions/subagent/runner.ts +0 -3
- package/examples/extensions/subagent/schemas.ts +0 -13
- package/examples/extensions/subagent/types.ts +1 -2
- package/examples/sdk/09-api-keys-and-oauth.ts +6 -2
- package/examples/sdk/12-full-control.ts +8 -2
- package/examples/sdk/README.md +4 -1
- package/npm-shrinkwrap.json +191 -634
- package/package.json +14 -7
- package/dist/builtin/subagents/src/agents/chain-serializer.ts +0 -257
- package/dist/builtin/subagents/src/runs/background/async-event-journal.ts +0 -112
- package/dist/builtin/subagents/src/runs/background/async-execution-chain.ts +0 -543
- package/dist/builtin/subagents/src/runs/background/async-execution-common.ts +0 -140
- package/dist/builtin/subagents/src/runs/background/async-execution-single.ts +0 -279
- package/dist/builtin/subagents/src/runs/background/async-execution-types.ts +0 -99
- package/dist/builtin/subagents/src/runs/background/async-execution.ts +0 -17
- package/dist/builtin/subagents/src/runs/background/async-resume.ts +0 -402
- package/dist/builtin/subagents/src/runs/background/async-status.ts +0 -411
- package/dist/builtin/subagents/src/runs/background/completion-claims.ts +0 -196
- package/dist/builtin/subagents/src/runs/background/completion-dedupe.ts +0 -102
- package/dist/builtin/subagents/src/runs/background/parallel-groups.ts +0 -59
- package/dist/builtin/subagents/src/runs/background/result-delivery-processor.ts +0 -300
- package/dist/builtin/subagents/src/runs/background/result-file-claims.ts +0 -166
- package/dist/builtin/subagents/src/runs/background/result-quarantine.ts +0 -77
- package/dist/builtin/subagents/src/runs/background/result-retry-scheduler.ts +0 -48
- package/dist/builtin/subagents/src/runs/background/result-status.ts +0 -87
- package/dist/builtin/subagents/src/runs/background/result-watcher-data.ts +0 -72
- package/dist/builtin/subagents/src/runs/background/result-watcher.ts +0 -320
- package/dist/builtin/subagents/src/runs/background/run-id-resolver.ts +0 -105
- package/dist/builtin/subagents/src/runs/background/run-status.ts +0 -358
- package/dist/builtin/subagents/src/runs/background/stale-run-reconciler.ts +0 -457
- package/dist/builtin/subagents/src/runs/background/subagent-runner-dynamic.ts +0 -376
- package/dist/builtin/subagents/src/runs/background/subagent-runner-finalize.ts +0 -150
- package/dist/builtin/subagents/src/runs/background/subagent-runner-output.ts +0 -109
- package/dist/builtin/subagents/src/runs/background/subagent-runner-parallel-helpers.ts +0 -128
- package/dist/builtin/subagents/src/runs/background/subagent-runner-parallel.ts +0 -309
- package/dist/builtin/subagents/src/runs/background/subagent-runner-sequential.ts +0 -173
- package/dist/builtin/subagents/src/runs/background/subagent-runner-state.ts +0 -578
- package/dist/builtin/subagents/src/runs/background/subagent-runner-step.ts +0 -330
- package/dist/builtin/subagents/src/runs/background/subagent-runner-streaming.ts +0 -330
- package/dist/builtin/subagents/src/runs/background/subagent-runner-types.ts +0 -210
- package/dist/builtin/subagents/src/runs/background/subagent-runner-utils.ts +0 -69
- package/dist/builtin/subagents/src/runs/background/subagent-runner.ts +0 -90
- package/dist/builtin/subagents/src/runs/background/top-level-async.ts +0 -12
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-details.ts +0 -38
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-dynamic-step.ts +0 -280
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-runner.ts +0 -217
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-step.ts +0 -271
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-sequential-step.ts +0 -271
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-types.ts +0 -200
- package/dist/builtin/subagents/src/runs/foreground/chain-execution.ts +0 -184
- package/dist/builtin/subagents/src/runs/foreground/execution-attempt-control.ts +0 -140
- package/dist/builtin/subagents/src/runs/foreground/execution-attempt-finalize.ts +0 -108
- package/dist/builtin/subagents/src/runs/foreground/execution-attempt-types.ts +0 -17
- package/dist/builtin/subagents/src/runs/foreground/execution-attempt.ts +0 -558
- package/dist/builtin/subagents/src/runs/foreground/execution-structured-retries.ts +0 -83
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-chain.ts +0 -109
- package/dist/builtin/subagents/src/runs/shared/attempt-watchdog.ts +0 -126
- package/dist/builtin/subagents/src/runs/shared/chain-outputs.ts +0 -126
- package/dist/builtin/subagents/src/runs/shared/dynamic-fanout.ts +0 -387
- package/dist/builtin/subagents/src/runs/shared/final-drain.ts +0 -39
- package/dist/builtin/subagents/src/runs/shared/pi-args.ts +0 -339
- package/dist/builtin/subagents/src/runs/shared/pi-spawn.ts +0 -165
- package/dist/builtin/subagents/src/runs/shared/spawn-env.ts +0 -21
- package/dist/builtin/subagents/src/runs/shared/structured-output.ts +0 -150
- package/dist/builtin/subagents/src/runs/shared/workflow-graph.ts +0 -232
- package/dist/builtin/subagents/src/shared/post-exit-stdio-guard.ts +0 -86
- package/dist/builtin/subagents/src/slash/saved-chain-mapping.ts +0 -60
- package/dist/builtin/subagents/src/tui/render-chain-graph.ts +0 -335
- package/examples/extensions/subagent/prompts/implement-and-review.md +0 -10
- package/examples/extensions/subagent/prompts/implement.md +0 -10
- package/examples/extensions/subagent/prompts/scout-and-plan.md +0 -9
- /package/dist/builtin/subagents/src/runs/{shared/nested-path.ts → inprocess/runtime-support/nested-paths.ts} +0 -0
|
@@ -0,0 +1,1392 @@
|
|
|
1
|
+
import { appendFileSync, existsSync, mkdirSync, readdirSync, statSync } from "node:fs";
|
|
2
|
+
import { basename, dirname, join, relative, resolve } from "node:path";
|
|
3
|
+
import {
|
|
4
|
+
type AgentSession,
|
|
5
|
+
type AgentSessionEvent,
|
|
6
|
+
type AgentSessionEventListener,
|
|
7
|
+
type CreateAgentSessionOptions,
|
|
8
|
+
createAgentSession,
|
|
9
|
+
DefaultResourceLoader,
|
|
10
|
+
getAgentDir,
|
|
11
|
+
getBuiltinPackagePaths,
|
|
12
|
+
type PackageSource,
|
|
13
|
+
SessionManager,
|
|
14
|
+
type SessionStats,
|
|
15
|
+
SettingsManager,
|
|
16
|
+
type SubagentIntercomIdentity,
|
|
17
|
+
} from "@bastani/atomic";
|
|
18
|
+
import {
|
|
19
|
+
type ChildIdentity,
|
|
20
|
+
type NativeAdmissionResult,
|
|
21
|
+
type AgentStatus as NativeAgentStatus,
|
|
22
|
+
type NativeExecutionGuardResult,
|
|
23
|
+
type TerminationCause as NativeTerminationCause,
|
|
24
|
+
SubagentControl,
|
|
25
|
+
} from "@bastani/atomic-natives";
|
|
26
|
+
import type { Api, Model } from "@earendil-works/pi-ai/compat";
|
|
27
|
+
import type { AgentConfig } from "../../agents/agent-types.ts";
|
|
28
|
+
import { ensureArtifactsDir, writeArtifact, writeMetadata } from "../../shared/artifacts.ts";
|
|
29
|
+
import {
|
|
30
|
+
getSubagentCodexFastModeSettings,
|
|
31
|
+
resolveSubagentCodexFastModeScope,
|
|
32
|
+
resolveSubagentModelFastMode,
|
|
33
|
+
} from "../../shared/fast-mode.ts";
|
|
34
|
+
import { resolveEffectiveThinking } from "../../shared/model-info.ts";
|
|
35
|
+
import {
|
|
36
|
+
type AgentProgress,
|
|
37
|
+
type ArtifactPaths,
|
|
38
|
+
DEFAULT_MAX_OUTPUT,
|
|
39
|
+
type MaxOutputConfig,
|
|
40
|
+
normalizeMaxSubagentDepth,
|
|
41
|
+
truncateOutput,
|
|
42
|
+
} from "../../shared/types.ts";
|
|
43
|
+
import { type ChildModePolicy, resolveChildModePolicy } from "./child-policy.ts";
|
|
44
|
+
import { type InProcessNestedResumeOutcome, registerInProcessNestedAttempt } from "./nested-routing.ts";
|
|
45
|
+
import { createInProcessChildPromptBehavior } from "./prompt-behavior.ts";
|
|
46
|
+
|
|
47
|
+
export type ChildStatus = NativeAgentStatus;
|
|
48
|
+
export type ContinuationReason = "async-requested" | "intercom-coordination";
|
|
49
|
+
export type TerminationCauseName = NativeTerminationCause;
|
|
50
|
+
export type TerminalStatus = "ok" | "error" | "skipped" | "interrupted" | "continued";
|
|
51
|
+
|
|
52
|
+
export interface ParentContext {
|
|
53
|
+
readonly path: string;
|
|
54
|
+
readonly depth: number;
|
|
55
|
+
readonly sessionId?: string;
|
|
56
|
+
readonly intercomGroup?: string;
|
|
57
|
+
readonly workflowStageSubagentGuard?: boolean;
|
|
58
|
+
readonly orchestrationContext?: CreateAgentSessionOptions["orchestrationContext"];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface TestSessionOptions {
|
|
62
|
+
readonly output?: string;
|
|
63
|
+
readonly promptLogPath?: string;
|
|
64
|
+
/** Hold a test prompt open until the caller releases the supplied promise. */
|
|
65
|
+
readonly promptGate?: Promise<void>;
|
|
66
|
+
/** Match AgentSession.abort() settling an active prompt without throwing. */
|
|
67
|
+
readonly abortResolvesPrompt?: boolean;
|
|
68
|
+
/** Emit a fallback event for tests that exercise live model metadata. */
|
|
69
|
+
readonly fallbackModel?: string;
|
|
70
|
+
/** Emit the effective thinking level applied to the fallback candidate. */
|
|
71
|
+
readonly fallbackThinkingLevel?: string;
|
|
72
|
+
/** Test-only session model exposed through the AgentSession accessors. */
|
|
73
|
+
readonly sessionModel?: string;
|
|
74
|
+
/** Test-only effective thinking level exposed through the AgentSession accessors. */
|
|
75
|
+
readonly sessionThinkingLevel?: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface ChildSpec {
|
|
79
|
+
readonly taskName: string;
|
|
80
|
+
readonly task: string;
|
|
81
|
+
readonly agent: AgentConfig;
|
|
82
|
+
readonly cwd: string;
|
|
83
|
+
readonly tools?: string[];
|
|
84
|
+
readonly excludedTools?: string[];
|
|
85
|
+
readonly mcpDirectTools?: string[];
|
|
86
|
+
readonly skills?: string[];
|
|
87
|
+
readonly customTools?: CreateAgentSessionOptions["customTools"];
|
|
88
|
+
readonly model?: Model<Api>;
|
|
89
|
+
readonly thinkingLevel?: CreateAgentSessionOptions["thinkingLevel"];
|
|
90
|
+
readonly parent?: ParentContext;
|
|
91
|
+
/** Typed identity/capability resolved by the parent before admission. */
|
|
92
|
+
readonly intercom?: SubagentIntercomIdentity;
|
|
93
|
+
readonly sessionFile?: string;
|
|
94
|
+
/**
|
|
95
|
+
* Effective delegation limit for this child, already narrowed by the parent's
|
|
96
|
+
* limit and the child agent's own `maxSubagentDepth`. Retained on the spec so
|
|
97
|
+
* a cold reload reissues the same limit.
|
|
98
|
+
*/
|
|
99
|
+
readonly maxSubagentDepth?: number;
|
|
100
|
+
readonly testSession?: boolean | TestSessionOptions;
|
|
101
|
+
readonly artifactJsonlPath?: string;
|
|
102
|
+
/**
|
|
103
|
+
* Fallback model candidates (full ids, optional `:thinking` suffix) handed to
|
|
104
|
+
* the SDK session so child fallback uses the exact classification and
|
|
105
|
+
* candidate-advancement behavior main chat and workflow stages share.
|
|
106
|
+
*/
|
|
107
|
+
readonly fallbackModels?: readonly string[];
|
|
108
|
+
/** Live progress callback for the parent's tool-result rendering. */
|
|
109
|
+
readonly onProgress?: (progress: AgentProgress) => void;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface ChildPolicy extends ChildModePolicy {
|
|
113
|
+
readonly cwd: string;
|
|
114
|
+
readonly tools?: readonly string[];
|
|
115
|
+
readonly excludedTools?: readonly string[];
|
|
116
|
+
readonly mcpDirectTools?: readonly string[];
|
|
117
|
+
readonly skills: readonly string[];
|
|
118
|
+
readonly customTools?: CreateAgentSessionOptions["customTools"];
|
|
119
|
+
readonly model?: Model<Api>;
|
|
120
|
+
readonly thinkingLevel?: CreateAgentSessionOptions["thinkingLevel"];
|
|
121
|
+
readonly intercomGroup?: string;
|
|
122
|
+
readonly depth: number;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export interface ModelCandidate {
|
|
126
|
+
readonly model?: Model<Api>;
|
|
127
|
+
readonly modelId?: string;
|
|
128
|
+
readonly thinkingLevel?: CreateAgentSessionOptions["thinkingLevel"];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function modelIdForCandidate(candidate: ModelCandidate, fallbackModel?: Model<Api>): string | undefined {
|
|
132
|
+
return (
|
|
133
|
+
candidate.modelId ??
|
|
134
|
+
(candidate.model ? `${candidate.model.provider}/${candidate.model.id}` : undefined) ??
|
|
135
|
+
(fallbackModel ? `${fallbackModel.provider}/${fallbackModel.id}` : undefined)
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function modelIdForSession(session: AgentSession | undefined): string | undefined {
|
|
140
|
+
const model = session?.model;
|
|
141
|
+
return model ? `${model.provider}/${model.id}` : undefined;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function thinkingLevelForSession(session: AgentSession | undefined): string | undefined {
|
|
145
|
+
const thinking = session?.thinkingLevel;
|
|
146
|
+
return typeof thinking === "string" ? thinking : undefined;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function initialThinkingForAttempt(
|
|
150
|
+
model: string | undefined,
|
|
151
|
+
configuredThinking: string | undefined,
|
|
152
|
+
): string | undefined {
|
|
153
|
+
return resolveEffectiveThinking(model, configuredThinking) ?? configuredThinking;
|
|
154
|
+
}
|
|
155
|
+
function defaultFastModeForChild(
|
|
156
|
+
cwd: string,
|
|
157
|
+
context: ParentContext["orchestrationContext"],
|
|
158
|
+
workflowStageSubagentGuard?: boolean,
|
|
159
|
+
): (model?: string) => boolean {
|
|
160
|
+
const settings = getSubagentCodexFastModeSettings(cwd);
|
|
161
|
+
const scope = resolveSubagentCodexFastModeScope(workflowStageSubagentGuard ?? context?.kind === "workflow-stage");
|
|
162
|
+
return (model) => resolveSubagentModelFastMode({ model, cwd, settings, scope });
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export interface AttemptSignals {
|
|
166
|
+
readonly abort: AbortSignal;
|
|
167
|
+
readonly interrupt: AbortSignal;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export type AttemptStats = SessionStats;
|
|
171
|
+
|
|
172
|
+
export type AttemptOutcome =
|
|
173
|
+
| {
|
|
174
|
+
readonly status: "ok";
|
|
175
|
+
readonly output: string;
|
|
176
|
+
readonly stats: AttemptStats;
|
|
177
|
+
readonly path: string;
|
|
178
|
+
readonly envelope: string;
|
|
179
|
+
readonly sessionFile?: string;
|
|
180
|
+
readonly model?: string;
|
|
181
|
+
readonly thinking?: string;
|
|
182
|
+
readonly attemptedModels?: readonly string[];
|
|
183
|
+
}
|
|
184
|
+
| {
|
|
185
|
+
readonly status: "error";
|
|
186
|
+
readonly cause: string;
|
|
187
|
+
readonly stats: AttemptStats;
|
|
188
|
+
readonly path: string;
|
|
189
|
+
readonly envelope: string;
|
|
190
|
+
readonly sessionFile?: string;
|
|
191
|
+
readonly fallbackSignal?: string;
|
|
192
|
+
readonly model?: string;
|
|
193
|
+
readonly thinking?: string;
|
|
194
|
+
readonly attemptedModels?: readonly string[];
|
|
195
|
+
}
|
|
196
|
+
| {
|
|
197
|
+
readonly status: "interrupted";
|
|
198
|
+
readonly stats: AttemptStats;
|
|
199
|
+
readonly path: string;
|
|
200
|
+
readonly envelope: string;
|
|
201
|
+
readonly sessionFile?: string;
|
|
202
|
+
readonly model?: string;
|
|
203
|
+
readonly thinking?: string;
|
|
204
|
+
}
|
|
205
|
+
| {
|
|
206
|
+
readonly status: "continued";
|
|
207
|
+
readonly childPath: string;
|
|
208
|
+
readonly stats: AttemptStats;
|
|
209
|
+
readonly path: string;
|
|
210
|
+
readonly envelope: string;
|
|
211
|
+
readonly sessionFile?: string;
|
|
212
|
+
readonly model?: string;
|
|
213
|
+
readonly thinking?: string;
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
export interface ResultEnvelope {
|
|
217
|
+
readonly path: string;
|
|
218
|
+
readonly status: TerminalStatus;
|
|
219
|
+
readonly cause?: string;
|
|
220
|
+
readonly stats: AttemptStats;
|
|
221
|
+
readonly envelope: string;
|
|
222
|
+
readonly model?: string;
|
|
223
|
+
readonly thinking?: string;
|
|
224
|
+
readonly fastMode?: boolean;
|
|
225
|
+
readonly modelAttempts?: readonly {
|
|
226
|
+
readonly model: string;
|
|
227
|
+
readonly status: TerminalStatus;
|
|
228
|
+
readonly cause?: string;
|
|
229
|
+
}[];
|
|
230
|
+
readonly sessionFile?: string;
|
|
231
|
+
readonly artifactsDir?: string;
|
|
232
|
+
readonly durationMs?: number;
|
|
233
|
+
readonly timestamp: number;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export interface DeliverChildResultOptions {
|
|
237
|
+
readonly artifactsDir?: string;
|
|
238
|
+
readonly artifactPaths?: ArtifactPaths;
|
|
239
|
+
readonly artifactsDisabled?: boolean;
|
|
240
|
+
readonly maxOutput?: MaxOutputConfig;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export interface AdmittedResult {
|
|
244
|
+
readonly admitted?: AdmittedChild;
|
|
245
|
+
readonly refusal?: AdmissionRefusal;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export interface AdmissionRefusal {
|
|
249
|
+
readonly kind: NativeAdmissionResult["refusal"] extends infer R ? (R extends { kind: infer K } ? K : never) : never;
|
|
250
|
+
readonly reason: string;
|
|
251
|
+
readonly maxDepth?: number;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const EMPTY_STATS: AttemptStats = {
|
|
255
|
+
sessionFile: undefined,
|
|
256
|
+
sessionId: "",
|
|
257
|
+
userMessages: 0,
|
|
258
|
+
assistantMessages: 0,
|
|
259
|
+
toolCalls: 0,
|
|
260
|
+
toolResults: 0,
|
|
261
|
+
totalMessages: 0,
|
|
262
|
+
tokens: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
263
|
+
cost: 0,
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
const CAPACITY_RETRY_INITIAL_DELAY_MS = 5;
|
|
267
|
+
const INTERRUPTED_ENVELOPE = "Interrupted";
|
|
268
|
+
const CAPACITY_RETRY_MAX_DELAY_MS = 100;
|
|
269
|
+
|
|
270
|
+
type CapacityWaitResult = "retry" | "abort" | "interrupt";
|
|
271
|
+
|
|
272
|
+
function waitForExecutionCapacity(delayMs: number, signals: AttemptSignals): Promise<CapacityWaitResult> {
|
|
273
|
+
if (signals.interrupt.aborted) return Promise.resolve("interrupt");
|
|
274
|
+
if (signals.abort.aborted) return Promise.resolve("abort");
|
|
275
|
+
return new Promise((resolveWait) => {
|
|
276
|
+
let settled = false;
|
|
277
|
+
let timer: ReturnType<typeof setTimeout>;
|
|
278
|
+
const settle = (result: CapacityWaitResult) => {
|
|
279
|
+
if (settled) return;
|
|
280
|
+
settled = true;
|
|
281
|
+
clearTimeout(timer);
|
|
282
|
+
signals.abort.removeEventListener("abort", onAbort);
|
|
283
|
+
signals.interrupt.removeEventListener("abort", onInterrupt);
|
|
284
|
+
resolveWait(result);
|
|
285
|
+
};
|
|
286
|
+
const onAbort = () => settle("abort");
|
|
287
|
+
const onInterrupt = () => settle("interrupt");
|
|
288
|
+
signals.abort.addEventListener("abort", onAbort, { once: true });
|
|
289
|
+
signals.interrupt.addEventListener("abort", onInterrupt, { once: true });
|
|
290
|
+
timer = setTimeout(() => settle("retry"), delayMs);
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function workflowMetadataFromContext(
|
|
295
|
+
context: CreateAgentSessionOptions["orchestrationContext"] | undefined,
|
|
296
|
+
): { runId: string; stageId: string; stageName: string } | undefined {
|
|
297
|
+
if (context?.kind !== "workflow-stage") return undefined;
|
|
298
|
+
return {
|
|
299
|
+
runId: context.workflowRunId,
|
|
300
|
+
stageId: context.workflowStageId,
|
|
301
|
+
stageName: context.workflowStageName,
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Effective delegation limit for an admitted child. A caller that already
|
|
307
|
+
* narrowed the parent's limit against the agent definition puts the result on
|
|
308
|
+
* the spec; a caller admitting a child directly still gets the agent's own
|
|
309
|
+
* declared limit rather than an unbounded policy.
|
|
310
|
+
*/
|
|
311
|
+
export function effectiveChildMaxSubagentDepth(spec: ChildSpec): number | undefined {
|
|
312
|
+
return spec.maxSubagentDepth ?? normalizeMaxSubagentDepth(spec.agent.maxSubagentDepth);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* In-process children must load the same bundled extensions as the host.
|
|
317
|
+
* Workflow extensions are disabled inside workflow-owned sessions because their
|
|
318
|
+
* startup lifecycle belongs to the parent workflow store.
|
|
319
|
+
*/
|
|
320
|
+
export function inProcessChildBuiltinPackagePaths(
|
|
321
|
+
context: CreateAgentSessionOptions["orchestrationContext"] | undefined,
|
|
322
|
+
): PackageSource[] {
|
|
323
|
+
return getBuiltinPackagePaths().map((source) => {
|
|
324
|
+
if (context?.kind !== "workflow-stage" || basename(source) !== "workflows") return source;
|
|
325
|
+
return { source, extensions: [] };
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Resource-loading options for a real (non-test) in-process child session.
|
|
331
|
+
* Omitting `builtinPackagePaths` leaves a child with no bundled extension at
|
|
332
|
+
* all — no `subagent`, `web_search`, `fetch_content`, or `intercom` — so the
|
|
333
|
+
* bundled roots belong in every child loader.
|
|
334
|
+
*/
|
|
335
|
+
export function inProcessChildResourceLoaderOptions(input: {
|
|
336
|
+
readonly cwd: string;
|
|
337
|
+
readonly agentDir: string;
|
|
338
|
+
readonly settingsManager: SettingsManager;
|
|
339
|
+
readonly agent: Pick<AgentConfig, "systemPrompt" | "systemPromptMode">;
|
|
340
|
+
readonly orchestrationContext: CreateAgentSessionOptions["orchestrationContext"] | undefined;
|
|
341
|
+
}): ConstructorParameters<typeof DefaultResourceLoader>[0] {
|
|
342
|
+
const agentPrompt = input.agent.systemPrompt?.trim();
|
|
343
|
+
return {
|
|
344
|
+
cwd: input.cwd,
|
|
345
|
+
agentDir: input.agentDir,
|
|
346
|
+
settingsManager: input.settingsManager,
|
|
347
|
+
builtinPackagePaths: inProcessChildBuiltinPackagePaths(input.orchestrationContext),
|
|
348
|
+
...(agentPrompt && input.agent.systemPromptMode === "append"
|
|
349
|
+
? { appendSystemPrompt: [agentPrompt] }
|
|
350
|
+
: agentPrompt
|
|
351
|
+
? { systemPrompt: agentPrompt }
|
|
352
|
+
: {}),
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function createTestSession(sessionManager: SessionManager, spec: ChildSpec): AgentSession {
|
|
357
|
+
const listeners = new Set<AgentSessionEventListener>();
|
|
358
|
+
const testOptions = typeof spec.testSession === "object" ? spec.testSession : {};
|
|
359
|
+
const sessionModel = (() => {
|
|
360
|
+
const fullId = testOptions.sessionModel;
|
|
361
|
+
if (!fullId) return undefined;
|
|
362
|
+
const slash = fullId.indexOf("/");
|
|
363
|
+
return {
|
|
364
|
+
provider: slash === -1 ? "" : fullId.slice(0, slash),
|
|
365
|
+
id: slash === -1 ? fullId : fullId.slice(slash + 1),
|
|
366
|
+
};
|
|
367
|
+
})();
|
|
368
|
+
let lastAssistantText = "";
|
|
369
|
+
let aborted = false;
|
|
370
|
+
let settlePromptAbort: (() => void) | undefined;
|
|
371
|
+
const promptAbort = new Promise<"aborted">((resolve, reject) => {
|
|
372
|
+
settlePromptAbort = () => {
|
|
373
|
+
if (testOptions.abortResolvesPrompt) resolve("aborted");
|
|
374
|
+
else reject(new Error("aborted"));
|
|
375
|
+
};
|
|
376
|
+
});
|
|
377
|
+
let userMessages = 0;
|
|
378
|
+
let assistantMessages = 0;
|
|
379
|
+
const zeroTokens = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 };
|
|
380
|
+
const zeroCost = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 };
|
|
381
|
+
return {
|
|
382
|
+
sessionFile: sessionManager.getSessionFile(),
|
|
383
|
+
model: sessionModel,
|
|
384
|
+
thinkingLevel: testOptions.sessionThinkingLevel,
|
|
385
|
+
abort: async () => {
|
|
386
|
+
aborted = true;
|
|
387
|
+
settlePromptAbort?.();
|
|
388
|
+
},
|
|
389
|
+
subscribe(listener: AgentSessionEventListener) {
|
|
390
|
+
listeners.add(listener);
|
|
391
|
+
return () => listeners.delete(listener);
|
|
392
|
+
},
|
|
393
|
+
prompt: async (text: string) => {
|
|
394
|
+
for (const listener of listeners) listener({ type: "agent_start" } as AgentSessionEvent);
|
|
395
|
+
if (aborted) throw new Error("aborted");
|
|
396
|
+
if (testOptions.promptLogPath) appendFileSync(testOptions.promptLogPath, `${text}\n---PROMPT---\n`, "utf8");
|
|
397
|
+
sessionManager.appendMessage({ role: "user", content: text, timestamp: Date.now() });
|
|
398
|
+
userMessages += 1;
|
|
399
|
+
if (testOptions.promptGate) {
|
|
400
|
+
const gateResult = await Promise.race([
|
|
401
|
+
testOptions.promptGate.then(() => "released" as const),
|
|
402
|
+
promptAbort,
|
|
403
|
+
]);
|
|
404
|
+
if (gateResult === "aborted") return "";
|
|
405
|
+
}
|
|
406
|
+
if (testOptions.fallbackModel) {
|
|
407
|
+
for (const listener of listeners) {
|
|
408
|
+
listener({
|
|
409
|
+
type: "model_fallback_start",
|
|
410
|
+
from: "openai/gpt-5.1-codex",
|
|
411
|
+
to: testOptions.fallbackModel,
|
|
412
|
+
reason: "test fallback",
|
|
413
|
+
attempt: 1,
|
|
414
|
+
} as AgentSessionEvent);
|
|
415
|
+
if (testOptions.fallbackThinkingLevel) {
|
|
416
|
+
listener({
|
|
417
|
+
type: "thinking_level_changed",
|
|
418
|
+
level: testOptions.fallbackThinkingLevel,
|
|
419
|
+
} as AgentSessionEvent);
|
|
420
|
+
}
|
|
421
|
+
listener({
|
|
422
|
+
type: "tool_execution_start",
|
|
423
|
+
toolCallId: "test-fallback-tool",
|
|
424
|
+
toolName: "test-fallback-tool",
|
|
425
|
+
args: {},
|
|
426
|
+
} as AgentSessionEvent);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
lastAssistantText = testOptions.output ?? "done";
|
|
430
|
+
sessionManager.appendMessage({
|
|
431
|
+
role: "assistant",
|
|
432
|
+
content: [{ type: "text", text: lastAssistantText }],
|
|
433
|
+
api: "openai-responses",
|
|
434
|
+
provider: "openai",
|
|
435
|
+
model: "gpt-5.4",
|
|
436
|
+
usage: {
|
|
437
|
+
input: 0,
|
|
438
|
+
output: 0,
|
|
439
|
+
cacheRead: 0,
|
|
440
|
+
cacheWrite: 0,
|
|
441
|
+
totalTokens: 0,
|
|
442
|
+
cost: zeroCost,
|
|
443
|
+
},
|
|
444
|
+
stopReason: "stop",
|
|
445
|
+
timestamp: Date.now(),
|
|
446
|
+
});
|
|
447
|
+
assistantMessages += 1;
|
|
448
|
+
return lastAssistantText;
|
|
449
|
+
},
|
|
450
|
+
getLastAssistantText: () => lastAssistantText,
|
|
451
|
+
getSessionStats: () => ({
|
|
452
|
+
sessionFile: sessionManager.getSessionFile(),
|
|
453
|
+
sessionId: sessionManager.getSessionId(),
|
|
454
|
+
userMessages,
|
|
455
|
+
assistantMessages,
|
|
456
|
+
toolCalls: 0,
|
|
457
|
+
toolResults: 0,
|
|
458
|
+
totalMessages: userMessages + assistantMessages,
|
|
459
|
+
tokens: zeroTokens,
|
|
460
|
+
cost: 0,
|
|
461
|
+
}),
|
|
462
|
+
dispose: () => {},
|
|
463
|
+
} as unknown as AgentSession;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
function nativeStatus(value: ChildStatus): NativeAgentStatus {
|
|
467
|
+
return value;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
function nativeCause(value: TerminationCauseName): NativeTerminationCause {
|
|
471
|
+
return value;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
function refusal(result: NativeAdmissionResult): AdmittedResult {
|
|
475
|
+
if (!result.refusal) return {};
|
|
476
|
+
return {
|
|
477
|
+
refusal: {
|
|
478
|
+
kind: result.refusal.kind,
|
|
479
|
+
reason: result.refusal.reason,
|
|
480
|
+
...(result.refusal.maxDepth === undefined ? {} : { maxDepth: result.refusal.maxDepth }),
|
|
481
|
+
},
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
function statsFor(session: AgentSession | undefined, fallbackSessionId: string): AttemptStats {
|
|
486
|
+
if (!session) return { ...EMPTY_STATS, sessionId: fallbackSessionId };
|
|
487
|
+
try {
|
|
488
|
+
return session.getSessionStats();
|
|
489
|
+
} catch {
|
|
490
|
+
return {
|
|
491
|
+
...EMPTY_STATS,
|
|
492
|
+
sessionId: fallbackSessionId,
|
|
493
|
+
sessionFile: session.sessionFile,
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
function outputFor(session: AgentSession | undefined): string {
|
|
499
|
+
return session?.getLastAssistantText() ?? "";
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
function boundedEnvelope(output: string, artifactPath?: string, maxOutput?: MaxOutputConfig): string {
|
|
503
|
+
const config = { ...DEFAULT_MAX_OUTPUT, ...maxOutput };
|
|
504
|
+
const result = truncateOutput(output, config, artifactPath);
|
|
505
|
+
return result.truncated && artifactPath ? `${result.text}\n\nFull output: ${artifactPath}` : result.text;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
function canonicalArtifactPaths(artifactsDir: string, childPath: string): ArtifactPaths {
|
|
509
|
+
const prefix = childPath.replaceAll("/", "_");
|
|
510
|
+
return {
|
|
511
|
+
inputPath: join(artifactsDir, `${prefix}_input.md`),
|
|
512
|
+
outputPath: join(artifactsDir, `${prefix}_output.md`),
|
|
513
|
+
jsonlPath: join(artifactsDir, `${prefix}.jsonl`),
|
|
514
|
+
metadataPath: join(artifactsDir, `${prefix}_meta.json`),
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
function validatePath(pathValue: string): void {
|
|
519
|
+
if (
|
|
520
|
+
!pathValue ||
|
|
521
|
+
pathValue.startsWith("/") ||
|
|
522
|
+
pathValue.includes("\\") ||
|
|
523
|
+
pathValue.split("/").some((part) => !part || part === "." || part === "..")
|
|
524
|
+
) {
|
|
525
|
+
throw new Error("child path is outside the trusted session root");
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
function trustedSessionRoot(parent: ParentContext, requestedRoot?: string): string {
|
|
530
|
+
validatePath(parent.path);
|
|
531
|
+
const root = resolve(requestedRoot ?? join(process.cwd(), ".atomic", "subagents"));
|
|
532
|
+
const child = resolve(root, ...parent.path.split("/"));
|
|
533
|
+
if (relative(root, child).startsWith("..")) throw new Error("subagent session root escapes trusted root");
|
|
534
|
+
return root;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
function sessionDirectory(root: string, pathValue: string): string {
|
|
538
|
+
validatePath(pathValue);
|
|
539
|
+
const directory = resolve(root, ...pathValue.split("/"));
|
|
540
|
+
if (relative(root, directory).startsWith("..")) throw new Error("child session path escapes trusted root");
|
|
541
|
+
return directory;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
function safeArgsPreview(args: unknown): string {
|
|
545
|
+
if (args === undefined) return "";
|
|
546
|
+
try {
|
|
547
|
+
const text = typeof args === "string" ? args : JSON.stringify(args);
|
|
548
|
+
return text.length > 200 ? `${text.slice(0, 200)}…` : text;
|
|
549
|
+
} catch {
|
|
550
|
+
return "";
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
/**
|
|
555
|
+
* How a child session event should publish {@link AgentProgress} to the host UI.
|
|
556
|
+
*
|
|
557
|
+
* - `force` — the event changed progress the live widget shows; bypass the throttle.
|
|
558
|
+
* - `throttled` — worth publishing, but subject to the 400 ms throttle.
|
|
559
|
+
* - `none` — carries nothing the widget shows; do not publish.
|
|
560
|
+
*
|
|
561
|
+
* `none` is the important case. Foreground subagent results render into chat
|
|
562
|
+
* scrollback, which can sit above pi-tui's viewport fold. Every publish rewrites
|
|
563
|
+
* `durationMs`/`lastActivityAt` and repaints the widget, and a repaint of a row
|
|
564
|
+
* above the fold makes `TUI.doRender()` take its `firstChanged < viewportTop`
|
|
565
|
+
* branch, which issues a full redraw that writes `\x1b[2J\x1b[H\x1b[3J` — clearing
|
|
566
|
+
* the user's scrollback and snapping the terminal to the bottom. A catch-all
|
|
567
|
+
* publish therefore destroyed the scrollback ~2.5x/s for the whole run, because
|
|
568
|
+
* `AgentSessionEvent` includes high-frequency traffic (`message_update` streaming
|
|
569
|
+
* deltas, `tool_execution_update`, `entry_appended`) that the widget never shows.
|
|
570
|
+
* Keep this table narrow: add an event only when the widget renders something the
|
|
571
|
+
* event changed.
|
|
572
|
+
*/
|
|
573
|
+
export type ProgressEmission = "force" | "throttled" | "none";
|
|
574
|
+
|
|
575
|
+
export function progressEmissionFor(eventType: AgentSessionEvent["type"]): ProgressEmission {
|
|
576
|
+
switch (eventType) {
|
|
577
|
+
case "agent_start":
|
|
578
|
+
case "tool_execution_start":
|
|
579
|
+
case "tool_execution_end":
|
|
580
|
+
return "force";
|
|
581
|
+
case "message_end":
|
|
582
|
+
return "throttled";
|
|
583
|
+
default:
|
|
584
|
+
return "none";
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
function writeEvent(pathValue: string | undefined, event: AgentSessionEvent): void {
|
|
589
|
+
if (!pathValue) return;
|
|
590
|
+
mkdirSync(dirname(pathValue), { recursive: true });
|
|
591
|
+
appendFileSync(pathValue, `${JSON.stringify(event)}\n`, "utf8");
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
/**
|
|
595
|
+
* A child identity whose constructor is private. Depth and path validation happen
|
|
596
|
+
* at the Rust admission door, so callers cannot manufacture an admitted depth-6
|
|
597
|
+
* child or bypass canonical identity allocation.
|
|
598
|
+
*/
|
|
599
|
+
interface AdmittedChildInput {
|
|
600
|
+
readonly identity: ChildIdentity;
|
|
601
|
+
readonly spec: ChildSpec;
|
|
602
|
+
readonly policy: ChildPolicy;
|
|
603
|
+
readonly sessionDir: string;
|
|
604
|
+
readonly sessionFile?: string;
|
|
605
|
+
readonly control: SubagentControlRuntime;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
export class AdmittedChild {
|
|
609
|
+
readonly identity: ChildIdentity;
|
|
610
|
+
readonly spec: ChildSpec;
|
|
611
|
+
readonly policy: ChildPolicy;
|
|
612
|
+
readonly sessionDir: string;
|
|
613
|
+
readonly sessionFile?: string;
|
|
614
|
+
readonly control: SubagentControlRuntime;
|
|
615
|
+
|
|
616
|
+
private constructor(input: {
|
|
617
|
+
identity: ChildIdentity;
|
|
618
|
+
spec: ChildSpec;
|
|
619
|
+
policy: ChildPolicy;
|
|
620
|
+
sessionDir: string;
|
|
621
|
+
sessionFile?: string;
|
|
622
|
+
control: SubagentControlRuntime;
|
|
623
|
+
}) {
|
|
624
|
+
this.identity = input.identity;
|
|
625
|
+
this.spec = input.spec;
|
|
626
|
+
this.policy = input.policy;
|
|
627
|
+
this.sessionDir = input.sessionDir;
|
|
628
|
+
this.sessionFile = input.sessionFile;
|
|
629
|
+
this.control = input.control;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
static create(input: AdmittedChildInput): AdmittedChild {
|
|
633
|
+
if (input.identity.depth > 5) throw new Error("child depth exceeds maximum 5");
|
|
634
|
+
validatePath(input.identity.path);
|
|
635
|
+
return new AdmittedChild(input);
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
export interface ChildRuntimeMetadata {
|
|
640
|
+
model?: string;
|
|
641
|
+
thinking?: string;
|
|
642
|
+
fastMode?: boolean;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
export interface RunningAttempt {
|
|
646
|
+
readonly id: number;
|
|
647
|
+
readonly child: AdmittedChild;
|
|
648
|
+
readonly candidate: ModelCandidate;
|
|
649
|
+
readonly startedAt: number;
|
|
650
|
+
currentModel?: string;
|
|
651
|
+
currentThinking?: string;
|
|
652
|
+
currentFastMode?: boolean;
|
|
653
|
+
status: "running" | ChildStatus;
|
|
654
|
+
promise: Promise<AttemptOutcome>;
|
|
655
|
+
terminate?: (cause: TerminationCauseName) => Promise<void>;
|
|
656
|
+
attemptToken?: number;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
export interface StartAttemptOptions {
|
|
660
|
+
readonly fastModeForModel?: (model: string | undefined) => boolean;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
export class SubagentControlRuntime {
|
|
664
|
+
readonly native: SubagentControl;
|
|
665
|
+
readonly parent: ParentContext;
|
|
666
|
+
readonly sessionRoot: string;
|
|
667
|
+
private readonly sessions = new Map<string, AgentSession>();
|
|
668
|
+
private readonly specs = new Map<string, ChildSpec>();
|
|
669
|
+
private readonly sessionFiles = new Map<string, string>();
|
|
670
|
+
private readonly runningAttempts = new Map<number, RunningAttempt>();
|
|
671
|
+
private readonly attemptTokens = new Map<string, number>();
|
|
672
|
+
private readonly attemptTerminators = new Map<string, (cause: TerminationCauseName) => Promise<void>>();
|
|
673
|
+
private readonly delivered = new Set<string>();
|
|
674
|
+
private readonly deliveredEnvelopes = new Map<string, ResultEnvelope>();
|
|
675
|
+
private nextAttemptId = 1;
|
|
676
|
+
|
|
677
|
+
constructor(parent: ParentContext, sessionRoot?: string) {
|
|
678
|
+
this.parent = { ...parent };
|
|
679
|
+
this.sessionRoot = trustedSessionRoot(this.parent, sessionRoot);
|
|
680
|
+
this.native = new SubagentControl(this.parent.path);
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
registerAgents(agents: readonly AgentConfig[]): void {
|
|
684
|
+
for (const agent of agents) this.native.registerAgent(agent.name);
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
admitChildSession(spec: ChildSpec, parent: ParentContext = this.parent): AdmittedResult {
|
|
688
|
+
if (!existsSync(spec.cwd) || !statSync(spec.cwd).isDirectory()) {
|
|
689
|
+
return {
|
|
690
|
+
refusal: {
|
|
691
|
+
kind: "invalidCwd",
|
|
692
|
+
reason: `cwd is not a directory: ${spec.cwd}`,
|
|
693
|
+
},
|
|
694
|
+
};
|
|
695
|
+
}
|
|
696
|
+
const native = this.native.admitChildSession(
|
|
697
|
+
{ taskName: spec.taskName, agentName: spec.agent.name, cwd: spec.cwd },
|
|
698
|
+
{ path: parent.path, depth: parent.depth },
|
|
699
|
+
);
|
|
700
|
+
if (!native.child) return refusal(native);
|
|
701
|
+
const identity = native.child;
|
|
702
|
+
const childModePolicy = resolveChildModePolicy(spec);
|
|
703
|
+
const sessionDir = spec.sessionFile
|
|
704
|
+
? dirname(spec.sessionFile)
|
|
705
|
+
: sessionDirectory(this.sessionRoot, identity.path);
|
|
706
|
+
mkdirSync(sessionDir, { recursive: true });
|
|
707
|
+
this.specs.set(identity.path, spec);
|
|
708
|
+
return {
|
|
709
|
+
admitted: AdmittedChild.create({
|
|
710
|
+
identity,
|
|
711
|
+
spec,
|
|
712
|
+
policy: {
|
|
713
|
+
...childModePolicy,
|
|
714
|
+
cwd: spec.cwd,
|
|
715
|
+
tools: spec.tools ?? spec.agent.tools,
|
|
716
|
+
excludedTools: spec.excludedTools,
|
|
717
|
+
mcpDirectTools: spec.mcpDirectTools ?? spec.agent.mcpDirectTools,
|
|
718
|
+
skills: [...(spec.skills ?? spec.agent.skills ?? [])],
|
|
719
|
+
customTools: spec.customTools,
|
|
720
|
+
model: spec.model,
|
|
721
|
+
thinkingLevel: spec.thinkingLevel ?? (spec.agent.thinking as ChildPolicy["thinkingLevel"]),
|
|
722
|
+
intercomGroup: parent.intercomGroup,
|
|
723
|
+
intercom: spec.intercom,
|
|
724
|
+
depth: identity.depth,
|
|
725
|
+
...(effectiveChildMaxSubagentDepth(spec) === undefined
|
|
726
|
+
? {}
|
|
727
|
+
: { maxSubagentDepth: effectiveChildMaxSubagentDepth(spec) }),
|
|
728
|
+
},
|
|
729
|
+
sessionDir,
|
|
730
|
+
sessionFile: spec.sessionFile,
|
|
731
|
+
control: this,
|
|
732
|
+
}),
|
|
733
|
+
};
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
async runChildAttempt(
|
|
737
|
+
admitted: AdmittedChild,
|
|
738
|
+
candidate: ModelCandidate,
|
|
739
|
+
signals: AttemptSignals,
|
|
740
|
+
onModelChange: ((model: string | undefined, thinking?: string, fastMode?: boolean) => void) | undefined,
|
|
741
|
+
fastModeForModel: (model: string | undefined) => boolean,
|
|
742
|
+
): Promise<AttemptOutcome> {
|
|
743
|
+
const candidateModelId = modelIdForCandidate(candidate, admitted.policy.model);
|
|
744
|
+
const configuredThinking = candidate.thinkingLevel ?? admitted.policy.thinkingLevel;
|
|
745
|
+
let effectiveModelId = candidateModelId;
|
|
746
|
+
let effectiveThinking = initialThinkingForAttempt(candidateModelId, configuredThinking);
|
|
747
|
+
let attemptedModels: string[] = candidateModelId ? [candidateModelId] : [];
|
|
748
|
+
let guard: NativeExecutionGuardResult;
|
|
749
|
+
let retryDelayMs = CAPACITY_RETRY_INITIAL_DELAY_MS;
|
|
750
|
+
for (;;) {
|
|
751
|
+
guard = this.native.beginChildAttempt(admitted.identity.path);
|
|
752
|
+
if (guard.token || guard.refusal?.kind !== "capacityExhausted") break;
|
|
753
|
+
const waitResult = await waitForExecutionCapacity(retryDelayMs, signals);
|
|
754
|
+
if (waitResult !== "retry") {
|
|
755
|
+
const stats = { ...EMPTY_STATS, sessionId: admitted.identity.path };
|
|
756
|
+
const status = waitResult === "interrupt" ? "interrupted" : "error";
|
|
757
|
+
this.native.publishChildStatus(admitted.identity.path, nativeStatus(status));
|
|
758
|
+
return status === "interrupted"
|
|
759
|
+
? {
|
|
760
|
+
status,
|
|
761
|
+
stats,
|
|
762
|
+
path: admitted.identity.path,
|
|
763
|
+
envelope: INTERRUPTED_ENVELOPE,
|
|
764
|
+
...(effectiveModelId === undefined ? {} : { model: effectiveModelId }),
|
|
765
|
+
...(effectiveThinking === undefined ? {} : { thinking: effectiveThinking }),
|
|
766
|
+
}
|
|
767
|
+
: {
|
|
768
|
+
status,
|
|
769
|
+
cause: waitResult,
|
|
770
|
+
stats,
|
|
771
|
+
path: admitted.identity.path,
|
|
772
|
+
envelope: boundedEnvelope(waitResult),
|
|
773
|
+
...(effectiveModelId === undefined ? {} : { model: effectiveModelId }),
|
|
774
|
+
...(effectiveThinking === undefined ? {} : { thinking: effectiveThinking }),
|
|
775
|
+
};
|
|
776
|
+
}
|
|
777
|
+
retryDelayMs = Math.min(retryDelayMs * 2, CAPACITY_RETRY_MAX_DELAY_MS);
|
|
778
|
+
}
|
|
779
|
+
if (!guard.token) {
|
|
780
|
+
const reason = guard.refusal?.reason ?? "child execution was refused";
|
|
781
|
+
const stats = { ...EMPTY_STATS, sessionId: admitted.identity.path };
|
|
782
|
+
this.native.publishChildStatus(admitted.identity.path, nativeStatus("error"));
|
|
783
|
+
return {
|
|
784
|
+
status: "error",
|
|
785
|
+
cause: reason,
|
|
786
|
+
stats,
|
|
787
|
+
path: admitted.identity.path,
|
|
788
|
+
envelope: boundedEnvelope(reason),
|
|
789
|
+
...(effectiveModelId === undefined ? {} : { model: effectiveModelId }),
|
|
790
|
+
...(effectiveThinking === undefined ? {} : { thinking: effectiveThinking }),
|
|
791
|
+
};
|
|
792
|
+
}
|
|
793
|
+
const token = guard.token;
|
|
794
|
+
this.attemptTokens.set(admitted.identity.path, token);
|
|
795
|
+
let session: AgentSession | undefined;
|
|
796
|
+
let activeSessionManager: SessionManager | undefined;
|
|
797
|
+
let termination: TerminationCauseName | undefined;
|
|
798
|
+
let terminating: Promise<void> | undefined;
|
|
799
|
+
let unsubscribe: (() => void) | undefined;
|
|
800
|
+
const terminate = async (cause: TerminationCauseName): Promise<void> => {
|
|
801
|
+
if (terminating) return terminating;
|
|
802
|
+
termination = cause;
|
|
803
|
+
terminating = (async () => {
|
|
804
|
+
try {
|
|
805
|
+
activeSessionManager?.flush();
|
|
806
|
+
await session?.abort();
|
|
807
|
+
} finally {
|
|
808
|
+
try {
|
|
809
|
+
await this.native.terminateChildAttempt(token, nativeCause(cause));
|
|
810
|
+
} catch {
|
|
811
|
+
// The attempt may have completed between signal delivery and termination.
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
})();
|
|
815
|
+
return terminating;
|
|
816
|
+
};
|
|
817
|
+
this.attemptTerminators.set(admitted.identity.path, terminate);
|
|
818
|
+
const abortListener = () => void terminate("abort");
|
|
819
|
+
const interruptListener = () => void terminate("interrupt");
|
|
820
|
+
signals.abort.addEventListener("abort", abortListener, { once: true });
|
|
821
|
+
signals.interrupt.addEventListener("abort", interruptListener, {
|
|
822
|
+
once: true,
|
|
823
|
+
});
|
|
824
|
+
try {
|
|
825
|
+
const workflow = workflowMetadataFromContext(admitted.spec.parent?.orchestrationContext);
|
|
826
|
+
if (admitted.sessionFile) mkdirSync(dirname(admitted.sessionFile), { recursive: true });
|
|
827
|
+
const sessionManager = admitted.sessionFile
|
|
828
|
+
? SessionManager.open(admitted.sessionFile, admitted.sessionDir, admitted.policy.cwd)
|
|
829
|
+
: SessionManager.create(
|
|
830
|
+
admitted.policy.cwd,
|
|
831
|
+
admitted.sessionDir,
|
|
832
|
+
workflow ? { internal: true, workflow } : { internal: true },
|
|
833
|
+
);
|
|
834
|
+
activeSessionManager = sessionManager;
|
|
835
|
+
if (workflow) sessionManager.markSessionInternal(workflow);
|
|
836
|
+
let created: { session: AgentSession };
|
|
837
|
+
if (admitted.spec.testSession) {
|
|
838
|
+
created = { session: createTestSession(sessionManager, admitted.spec) };
|
|
839
|
+
} else {
|
|
840
|
+
const settingsManager = SettingsManager.create(admitted.policy.cwd, getAgentDir());
|
|
841
|
+
const resourceLoader = new DefaultResourceLoader(
|
|
842
|
+
inProcessChildResourceLoaderOptions({
|
|
843
|
+
cwd: admitted.policy.cwd,
|
|
844
|
+
agentDir: getAgentDir(),
|
|
845
|
+
settingsManager,
|
|
846
|
+
agent: admitted.spec.agent,
|
|
847
|
+
orchestrationContext: admitted.spec.parent?.orchestrationContext,
|
|
848
|
+
}),
|
|
849
|
+
);
|
|
850
|
+
await resourceLoader.reload();
|
|
851
|
+
const promptBehavior = createInProcessChildPromptBehavior(admitted.policy);
|
|
852
|
+
created = {
|
|
853
|
+
session: (
|
|
854
|
+
await createAgentSession({
|
|
855
|
+
cwd: admitted.policy.cwd,
|
|
856
|
+
model: candidate.model ?? admitted.policy.model,
|
|
857
|
+
thinkingLevel: candidate.thinkingLevel ?? admitted.policy.thinkingLevel,
|
|
858
|
+
...(admitted.spec.fallbackModels?.length
|
|
859
|
+
? { fallbackModels: [...admitted.spec.fallbackModels] }
|
|
860
|
+
: {}),
|
|
861
|
+
tools: admitted.policy.tools ? [...admitted.policy.tools] : undefined,
|
|
862
|
+
excludedTools: admitted.policy.excludedTools ? [...admitted.policy.excludedTools] : undefined,
|
|
863
|
+
customTools: admitted.policy.customTools,
|
|
864
|
+
resourceLoader,
|
|
865
|
+
sessionManager,
|
|
866
|
+
settingsManager,
|
|
867
|
+
orchestrationContext: admitted.spec.parent?.orchestrationContext,
|
|
868
|
+
subagentPolicy: admitted.policy,
|
|
869
|
+
systemPromptTransform: promptBehavior.systemPromptTransform,
|
|
870
|
+
initialContextTransform: promptBehavior.initialContextTransform,
|
|
871
|
+
})
|
|
872
|
+
).session,
|
|
873
|
+
};
|
|
874
|
+
}
|
|
875
|
+
session = created.session;
|
|
876
|
+
if (session.sessionFile) this.sessionFiles.set(admitted.identity.path, session.sessionFile);
|
|
877
|
+
this.sessions.set(admitted.identity.path, session);
|
|
878
|
+
const initialModelId = modelIdForSession(session) ?? candidateModelId;
|
|
879
|
+
effectiveModelId = initialModelId;
|
|
880
|
+
effectiveThinking =
|
|
881
|
+
thinkingLevelForSession(session) ?? initialThinkingForAttempt(candidateModelId, configuredThinking);
|
|
882
|
+
attemptedModels = initialModelId ? [initialModelId] : [];
|
|
883
|
+
onModelChange?.(effectiveModelId, effectiveThinking, fastModeForModel(effectiveModelId));
|
|
884
|
+
const progressState: AgentProgress = {
|
|
885
|
+
index: 0,
|
|
886
|
+
agent: admitted.spec.agent.name,
|
|
887
|
+
status: "running",
|
|
888
|
+
...(initialModelId === undefined ? {} : { model: initialModelId }),
|
|
889
|
+
...(effectiveThinking === undefined ? {} : { thinking: effectiveThinking }),
|
|
890
|
+
fastMode: fastModeForModel(initialModelId),
|
|
891
|
+
task: admitted.spec.task,
|
|
892
|
+
recentTools: [],
|
|
893
|
+
recentOutput: [],
|
|
894
|
+
toolCount: 0,
|
|
895
|
+
tokens: 0,
|
|
896
|
+
durationMs: 0,
|
|
897
|
+
lastActivityAt: Date.now(),
|
|
898
|
+
};
|
|
899
|
+
const attemptStartedAt = Date.now();
|
|
900
|
+
let lastProgressEmit = 0;
|
|
901
|
+
const emitProgress = (force: boolean) => {
|
|
902
|
+
const onProgress = admitted.spec.onProgress;
|
|
903
|
+
if (!onProgress) return;
|
|
904
|
+
const now = Date.now();
|
|
905
|
+
if (!force && now - lastProgressEmit < 400) return;
|
|
906
|
+
lastProgressEmit = now;
|
|
907
|
+
progressState.durationMs = now - attemptStartedAt;
|
|
908
|
+
progressState.lastActivityAt = now;
|
|
909
|
+
onProgress({ ...progressState, recentTools: [...progressState.recentTools] });
|
|
910
|
+
};
|
|
911
|
+
unsubscribe = session.subscribe((event) => {
|
|
912
|
+
writeEvent(admitted.spec.artifactJsonlPath, event);
|
|
913
|
+
const emission = progressEmissionFor(event.type);
|
|
914
|
+
if (event.type === "agent_start") {
|
|
915
|
+
this.native.publishChildStatus(admitted.identity.path, nativeStatus("running"));
|
|
916
|
+
} else if (event.type === "tool_execution_start") {
|
|
917
|
+
progressState.toolCount += 1;
|
|
918
|
+
progressState.currentTool = event.toolName;
|
|
919
|
+
progressState.currentToolArgs = safeArgsPreview(event.args);
|
|
920
|
+
progressState.currentToolStartedAt = Date.now();
|
|
921
|
+
} else if (event.type === "tool_execution_end") {
|
|
922
|
+
if (progressState.currentTool !== undefined) {
|
|
923
|
+
progressState.recentTools.push({
|
|
924
|
+
tool: progressState.currentTool,
|
|
925
|
+
args: progressState.currentToolArgs ?? "",
|
|
926
|
+
endMs: Date.now(),
|
|
927
|
+
});
|
|
928
|
+
if (progressState.recentTools.length > 5) progressState.recentTools.shift();
|
|
929
|
+
}
|
|
930
|
+
progressState.currentTool = undefined;
|
|
931
|
+
progressState.currentToolArgs = undefined;
|
|
932
|
+
progressState.currentToolStartedAt = undefined;
|
|
933
|
+
} else if (event.type === "message_end") {
|
|
934
|
+
const message = (event as { message?: { role?: string; usage?: { input?: number; output?: number } } })
|
|
935
|
+
.message;
|
|
936
|
+
if (message?.role === "assistant") {
|
|
937
|
+
progressState.turnCount = (progressState.turnCount ?? 0) + 1;
|
|
938
|
+
const usage = message.usage;
|
|
939
|
+
if (usage) progressState.tokens += (usage.input ?? 0) + (usage.output ?? 0);
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
if (emission !== "none") emitProgress(emission === "force");
|
|
943
|
+
if (event.type === "model_fallback_start") {
|
|
944
|
+
if (!attemptedModels.includes(event.to)) attemptedModels.push(event.to);
|
|
945
|
+
effectiveModelId = event.to;
|
|
946
|
+
progressState.model = event.to;
|
|
947
|
+
progressState.fastMode = fastModeForModel(event.to);
|
|
948
|
+
onModelChange?.(effectiveModelId, effectiveThinking, progressState.fastMode);
|
|
949
|
+
} else if (event.type === "thinking_level_changed") {
|
|
950
|
+
effectiveThinking = event.level;
|
|
951
|
+
progressState.thinking = effectiveThinking;
|
|
952
|
+
const fastMode = fastModeForModel(effectiveModelId);
|
|
953
|
+
onModelChange?.(effectiveModelId, effectiveThinking, fastMode);
|
|
954
|
+
emitProgress(true);
|
|
955
|
+
}
|
|
956
|
+
});
|
|
957
|
+
if (signals.abort.aborted) await terminate("abort");
|
|
958
|
+
if (signals.interrupt.aborted) await terminate("interrupt");
|
|
959
|
+
await session.prompt(admitted.spec.task);
|
|
960
|
+
await terminating;
|
|
961
|
+
const stats = statsFor(session, admitted.identity.path);
|
|
962
|
+
const sessionFile = session.sessionFile;
|
|
963
|
+
const output = outputFor(session);
|
|
964
|
+
const status: "ok" | "error" | "interrupted" =
|
|
965
|
+
termination === "interrupt" ? "interrupted" : termination ? "error" : "ok";
|
|
966
|
+
this.native.publishChildStatus(admitted.identity.path, nativeStatus(status));
|
|
967
|
+
this.native.finishChildAttempt(token, nativeStatus(status));
|
|
968
|
+
const envelope =
|
|
969
|
+
status === "interrupted"
|
|
970
|
+
? INTERRUPTED_ENVELOPE
|
|
971
|
+
: boundedEnvelope(output || termination || "(no output)", undefined);
|
|
972
|
+
if (status === "ok")
|
|
973
|
+
return {
|
|
974
|
+
status,
|
|
975
|
+
output,
|
|
976
|
+
stats,
|
|
977
|
+
path: admitted.identity.path,
|
|
978
|
+
envelope,
|
|
979
|
+
sessionFile,
|
|
980
|
+
...(effectiveModelId === undefined ? {} : { model: effectiveModelId }),
|
|
981
|
+
...(effectiveThinking === undefined ? {} : { thinking: effectiveThinking }),
|
|
982
|
+
...(attemptedModels.length > 1 ? { attemptedModels: [...attemptedModels] } : {}),
|
|
983
|
+
};
|
|
984
|
+
return {
|
|
985
|
+
status,
|
|
986
|
+
cause: termination ?? "agent session ended without a successful completion",
|
|
987
|
+
stats,
|
|
988
|
+
path: admitted.identity.path,
|
|
989
|
+
envelope,
|
|
990
|
+
sessionFile,
|
|
991
|
+
...(effectiveModelId === undefined ? {} : { model: effectiveModelId }),
|
|
992
|
+
...(effectiveThinking === undefined ? {} : { thinking: effectiveThinking }),
|
|
993
|
+
...(status === "error" && attemptedModels.length > 1 ? { attemptedModels: [...attemptedModels] } : {}),
|
|
994
|
+
};
|
|
995
|
+
} catch (error) {
|
|
996
|
+
const stats = statsFor(session, admitted.identity.path);
|
|
997
|
+
const cause = error instanceof Error ? error.message : String(error);
|
|
998
|
+
const status: "interrupted" | "error" = termination === "interrupt" ? "interrupted" : "error";
|
|
999
|
+
this.native.publishChildStatus(admitted.identity.path, nativeStatus(status));
|
|
1000
|
+
try {
|
|
1001
|
+
this.native.finishChildAttempt(token, nativeStatus(status));
|
|
1002
|
+
} catch {
|
|
1003
|
+
// Preserve the original failure when Rust already stamped termination.
|
|
1004
|
+
}
|
|
1005
|
+
return status === "interrupted"
|
|
1006
|
+
? {
|
|
1007
|
+
status,
|
|
1008
|
+
stats,
|
|
1009
|
+
path: admitted.identity.path,
|
|
1010
|
+
envelope: INTERRUPTED_ENVELOPE,
|
|
1011
|
+
sessionFile: session?.sessionFile,
|
|
1012
|
+
...(effectiveModelId === undefined ? {} : { model: effectiveModelId }),
|
|
1013
|
+
...(effectiveThinking === undefined ? {} : { thinking: effectiveThinking }),
|
|
1014
|
+
}
|
|
1015
|
+
: {
|
|
1016
|
+
status,
|
|
1017
|
+
cause,
|
|
1018
|
+
stats,
|
|
1019
|
+
path: admitted.identity.path,
|
|
1020
|
+
envelope: boundedEnvelope(cause),
|
|
1021
|
+
sessionFile: session?.sessionFile,
|
|
1022
|
+
...(effectiveModelId === undefined ? {} : { model: effectiveModelId }),
|
|
1023
|
+
...(effectiveThinking === undefined ? {} : { thinking: effectiveThinking }),
|
|
1024
|
+
...(attemptedModels.length > 1 ? { attemptedModels: [...attemptedModels] } : {}),
|
|
1025
|
+
};
|
|
1026
|
+
} finally {
|
|
1027
|
+
signals.abort.removeEventListener("abort", abortListener);
|
|
1028
|
+
signals.interrupt.removeEventListener("abort", interruptListener);
|
|
1029
|
+
try {
|
|
1030
|
+
unsubscribe?.();
|
|
1031
|
+
} catch {
|
|
1032
|
+
// Listener teardown must not replace the attempt result.
|
|
1033
|
+
}
|
|
1034
|
+
try {
|
|
1035
|
+
activeSessionManager?.flush();
|
|
1036
|
+
} catch {
|
|
1037
|
+
// Persistence teardown must not replace the attempt result.
|
|
1038
|
+
}
|
|
1039
|
+
try {
|
|
1040
|
+
session?.dispose();
|
|
1041
|
+
} catch {
|
|
1042
|
+
// Session teardown must not replace the attempt result.
|
|
1043
|
+
}
|
|
1044
|
+
this.sessions.delete(admitted.identity.path);
|
|
1045
|
+
if (this.attemptTokens.get(admitted.identity.path) === token)
|
|
1046
|
+
this.attemptTokens.delete(admitted.identity.path);
|
|
1047
|
+
if (this.attemptTerminators.get(admitted.identity.path) === terminate)
|
|
1048
|
+
this.attemptTerminators.delete(admitted.identity.path);
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
startAttempt(
|
|
1053
|
+
admitted: AdmittedChild,
|
|
1054
|
+
candidate: ModelCandidate,
|
|
1055
|
+
signals: AttemptSignals,
|
|
1056
|
+
options: StartAttemptOptions = {},
|
|
1057
|
+
): RunningAttempt {
|
|
1058
|
+
const initialModel = modelIdForCandidate(candidate, admitted.policy.model);
|
|
1059
|
+
const initialThinking = initialThinkingForAttempt(
|
|
1060
|
+
initialModel,
|
|
1061
|
+
candidate.thinkingLevel ?? admitted.policy.thinkingLevel,
|
|
1062
|
+
);
|
|
1063
|
+
const fastModeForModel =
|
|
1064
|
+
options.fastModeForModel ??
|
|
1065
|
+
defaultFastModeForChild(
|
|
1066
|
+
admitted.policy.cwd,
|
|
1067
|
+
admitted.spec.parent?.orchestrationContext,
|
|
1068
|
+
admitted.spec.parent?.workflowStageSubagentGuard,
|
|
1069
|
+
);
|
|
1070
|
+
const running: RunningAttempt = {
|
|
1071
|
+
id: this.nextAttemptId++,
|
|
1072
|
+
child: admitted,
|
|
1073
|
+
candidate,
|
|
1074
|
+
status: "running",
|
|
1075
|
+
startedAt: Date.now(),
|
|
1076
|
+
...(initialModel === undefined ? {} : { currentModel: initialModel }),
|
|
1077
|
+
currentThinking: initialThinking,
|
|
1078
|
+
currentFastMode: fastModeForModel(initialModel),
|
|
1079
|
+
promise: Promise.resolve({
|
|
1080
|
+
status: "error",
|
|
1081
|
+
cause: "uninitialized",
|
|
1082
|
+
stats: { ...EMPTY_STATS, sessionId: admitted.identity.path },
|
|
1083
|
+
path: admitted.identity.path,
|
|
1084
|
+
envelope: "uninitialized",
|
|
1085
|
+
}),
|
|
1086
|
+
};
|
|
1087
|
+
running.promise = this.runChildAttempt(
|
|
1088
|
+
admitted,
|
|
1089
|
+
candidate,
|
|
1090
|
+
signals,
|
|
1091
|
+
(model, thinking, fastMode) => {
|
|
1092
|
+
running.currentModel = model;
|
|
1093
|
+
running.currentThinking = thinking;
|
|
1094
|
+
running.currentFastMode = fastMode;
|
|
1095
|
+
},
|
|
1096
|
+
fastModeForModel,
|
|
1097
|
+
).then((result) => {
|
|
1098
|
+
running.status = result.status;
|
|
1099
|
+
this.runningAttempts.delete(running.id);
|
|
1100
|
+
return result;
|
|
1101
|
+
});
|
|
1102
|
+
running.terminate = (cause) => this.terminateRunningAttempt(running, cause);
|
|
1103
|
+
running.promise.catch(() => undefined);
|
|
1104
|
+
this.runningAttempts.set(running.id, running);
|
|
1105
|
+
return running;
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
continueInBackground(running: RunningAttempt, _reason: ContinuationReason): string {
|
|
1109
|
+
if (running.status !== "running") throw new Error("continue_in_background requires a running attempt");
|
|
1110
|
+
this.native.publishChildStatus(running.child.identity.path, nativeStatus("continued"));
|
|
1111
|
+
running.status = "continued";
|
|
1112
|
+
running.promise.catch(() => undefined);
|
|
1113
|
+
return running.child.identity.path;
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
reloadColdChild(pathValue: string, message: string): AdmittedResult {
|
|
1117
|
+
let sessionDir: string;
|
|
1118
|
+
try {
|
|
1119
|
+
sessionDir = sessionDirectory(this.sessionRoot, pathValue);
|
|
1120
|
+
} catch (error) {
|
|
1121
|
+
return {
|
|
1122
|
+
refusal: {
|
|
1123
|
+
kind: "invalidCwd",
|
|
1124
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
1125
|
+
},
|
|
1126
|
+
};
|
|
1127
|
+
}
|
|
1128
|
+
const identity = this.native.listChildren().find((child) => child.path === pathValue);
|
|
1129
|
+
if (!identity)
|
|
1130
|
+
return {
|
|
1131
|
+
refusal: { kind: "unknownAgent", reason: "unknown child identity" },
|
|
1132
|
+
};
|
|
1133
|
+
const sessionFile = this.sessionFiles.get(pathValue) ?? this.findSessionFile(sessionDir);
|
|
1134
|
+
if (!sessionFile)
|
|
1135
|
+
return {
|
|
1136
|
+
refusal: {
|
|
1137
|
+
kind: "invalidCwd",
|
|
1138
|
+
reason: "child session file is missing",
|
|
1139
|
+
},
|
|
1140
|
+
};
|
|
1141
|
+
sessionDir = dirname(sessionFile);
|
|
1142
|
+
const native = this.native.reloadColdChild(pathValue, message);
|
|
1143
|
+
if (!native.child) return refusal(native);
|
|
1144
|
+
const previous = this.specs.get(pathValue);
|
|
1145
|
+
if (!previous)
|
|
1146
|
+
return {
|
|
1147
|
+
refusal: {
|
|
1148
|
+
kind: "unknownAgent",
|
|
1149
|
+
reason: "child policy is not resident",
|
|
1150
|
+
},
|
|
1151
|
+
};
|
|
1152
|
+
const spec: ChildSpec = { ...previous, task: message };
|
|
1153
|
+
this.specs.set(pathValue, spec);
|
|
1154
|
+
return {
|
|
1155
|
+
admitted: AdmittedChild.create({
|
|
1156
|
+
identity: native.child,
|
|
1157
|
+
spec,
|
|
1158
|
+
policy: { ...this.policyFor(spec, native.child.depth) },
|
|
1159
|
+
sessionDir,
|
|
1160
|
+
sessionFile,
|
|
1161
|
+
control: this,
|
|
1162
|
+
}),
|
|
1163
|
+
};
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
getChildMetadata(pathValue: string): ChildRuntimeMetadata | undefined {
|
|
1167
|
+
const running = [...this.runningAttempts.values()].find(
|
|
1168
|
+
(attempt) =>
|
|
1169
|
+
attempt.child.identity.path === pathValue &&
|
|
1170
|
+
(attempt.status === "running" || attempt.status === "continued"),
|
|
1171
|
+
);
|
|
1172
|
+
if (!running) return undefined;
|
|
1173
|
+
const model = running.currentModel;
|
|
1174
|
+
const thinking = running.currentThinking;
|
|
1175
|
+
if (model === undefined && thinking === undefined && running.currentFastMode === undefined) return undefined;
|
|
1176
|
+
return {
|
|
1177
|
+
...(model === undefined ? {} : { model }),
|
|
1178
|
+
...(thinking === undefined ? {} : { thinking }),
|
|
1179
|
+
...(running.currentFastMode === undefined ? {} : { fastMode: running.currentFastMode }),
|
|
1180
|
+
};
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
registerNestedAttempt(runId: string, running: RunningAttempt, candidate: ModelCandidate): void {
|
|
1184
|
+
registerInProcessNestedAttempt({
|
|
1185
|
+
runId,
|
|
1186
|
+
path: running.child.identity.path,
|
|
1187
|
+
status: () => running.status,
|
|
1188
|
+
interrupt: () => this.terminateChildAttempt(running, "interrupt"),
|
|
1189
|
+
resume: async (message): Promise<InProcessNestedResumeOutcome> => {
|
|
1190
|
+
const admission = this.reloadColdChild(running.child.identity.path, message);
|
|
1191
|
+
if (!admission.admitted) {
|
|
1192
|
+
throw new Error(admission.refusal?.reason ?? "nested child cold reload was refused");
|
|
1193
|
+
}
|
|
1194
|
+
const neverAbort = new AbortController().signal;
|
|
1195
|
+
const resumed = this.startAttempt(admission.admitted, candidate, {
|
|
1196
|
+
abort: neverAbort,
|
|
1197
|
+
interrupt: neverAbort,
|
|
1198
|
+
});
|
|
1199
|
+
const outcome = await resumed.promise;
|
|
1200
|
+
return {
|
|
1201
|
+
status: outcome.status,
|
|
1202
|
+
path: outcome.path,
|
|
1203
|
+
sessionFile: outcome.sessionFile,
|
|
1204
|
+
envelope: outcome.envelope,
|
|
1205
|
+
};
|
|
1206
|
+
},
|
|
1207
|
+
});
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
async terminateChildAttempt(running: RunningAttempt, cause: TerminationCauseName): Promise<void> {
|
|
1211
|
+
if (running.status !== "running" && running.status !== "continued") return;
|
|
1212
|
+
await running.terminate?.(cause);
|
|
1213
|
+
await running.promise;
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
async deliverChildResult(envelope: ResultEnvelope, options?: DeliverChildResultOptions): Promise<void> {
|
|
1217
|
+
if (this.delivered.has(envelope.path)) return;
|
|
1218
|
+
this.delivered.add(envelope.path);
|
|
1219
|
+
const artifactDir = options?.artifactsDir ?? envelope.artifactsDir;
|
|
1220
|
+
const paths =
|
|
1221
|
+
options?.artifactPaths ?? (artifactDir ? canonicalArtifactPaths(artifactDir, envelope.path) : undefined);
|
|
1222
|
+
const bounded = boundedEnvelope(envelope.envelope, paths?.outputPath, options?.maxOutput);
|
|
1223
|
+
const deliveredEnvelope = { ...envelope, envelope: bounded };
|
|
1224
|
+
this.deliveredEnvelopes.set(envelope.path, deliveredEnvelope);
|
|
1225
|
+
if (options?.artifactsDisabled) return;
|
|
1226
|
+
if (!artifactDir || !paths)
|
|
1227
|
+
throw new Error(`Artifact persistence paths are unresolved for child ${envelope.path}`);
|
|
1228
|
+
ensureArtifactsDir(artifactDir);
|
|
1229
|
+
writeArtifact(paths.outputPath, envelope.envelope);
|
|
1230
|
+
writeMetadata(paths.metadataPath, {
|
|
1231
|
+
...deliveredEnvelope,
|
|
1232
|
+
outputPath: paths.outputPath,
|
|
1233
|
+
});
|
|
1234
|
+
appendFileSync(join(artifactDir, "run-history.jsonl"), `${JSON.stringify(deliveredEnvelope)}\n`, "utf8");
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
getDeliveredResult(pathValue: string): ResultEnvelope | undefined {
|
|
1238
|
+
return this.deliveredEnvelopes.get(pathValue);
|
|
1239
|
+
}
|
|
1240
|
+
findChild(pathValue: string): ChildIdentity | undefined {
|
|
1241
|
+
return this.native.listChildren().find((child) => child.path === pathValue);
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
listChildren(): readonly ChildIdentity[] {
|
|
1245
|
+
return this.native.listChildren();
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
async interruptChild(pathValue: string): Promise<boolean> {
|
|
1249
|
+
const running = [...this.runningAttempts.values()].find(
|
|
1250
|
+
(attempt) =>
|
|
1251
|
+
attempt.child.identity.path === pathValue &&
|
|
1252
|
+
(attempt.status === "running" || attempt.status === "continued"),
|
|
1253
|
+
);
|
|
1254
|
+
if (!running) return false;
|
|
1255
|
+
await this.terminateChildAttempt(running, "interrupt");
|
|
1256
|
+
return true;
|
|
1257
|
+
}
|
|
1258
|
+
async resumeChild(
|
|
1259
|
+
pathValue: string,
|
|
1260
|
+
message: string,
|
|
1261
|
+
candidate: ModelCandidate,
|
|
1262
|
+
signals: AttemptSignals = {
|
|
1263
|
+
abort: new AbortController().signal,
|
|
1264
|
+
interrupt: new AbortController().signal,
|
|
1265
|
+
},
|
|
1266
|
+
): Promise<AttemptOutcome> {
|
|
1267
|
+
const admission = this.reloadColdChild(pathValue, message);
|
|
1268
|
+
if (!admission.admitted) {
|
|
1269
|
+
const reason = admission.refusal?.reason ?? "cold child reload was refused";
|
|
1270
|
+
return {
|
|
1271
|
+
status: "error",
|
|
1272
|
+
cause: reason,
|
|
1273
|
+
stats: { ...EMPTY_STATS, sessionId: pathValue },
|
|
1274
|
+
path: pathValue,
|
|
1275
|
+
envelope: boundedEnvelope(reason),
|
|
1276
|
+
};
|
|
1277
|
+
}
|
|
1278
|
+
const running = this.startAttempt(admission.admitted, candidate, signals);
|
|
1279
|
+
return running.promise;
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
subscribe(pathValue: string, callback: (status: ChildStatus) => void): void {
|
|
1283
|
+
this.native.subscribeChildStatus(pathValue, callback);
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
private policyFor(spec: ChildSpec, depth: number): ChildPolicy {
|
|
1287
|
+
return {
|
|
1288
|
+
...resolveChildModePolicy(spec),
|
|
1289
|
+
cwd: spec.cwd,
|
|
1290
|
+
tools: spec.tools ?? spec.agent.tools,
|
|
1291
|
+
excludedTools: spec.excludedTools,
|
|
1292
|
+
mcpDirectTools: spec.mcpDirectTools ?? spec.agent.mcpDirectTools,
|
|
1293
|
+
skills: [...(spec.skills ?? spec.agent.skills ?? [])],
|
|
1294
|
+
customTools: spec.customTools,
|
|
1295
|
+
model: spec.model,
|
|
1296
|
+
thinkingLevel: spec.thinkingLevel ?? (spec.agent.thinking as ChildPolicy["thinkingLevel"]),
|
|
1297
|
+
intercomGroup: spec.parent?.intercomGroup,
|
|
1298
|
+
depth,
|
|
1299
|
+
...(effectiveChildMaxSubagentDepth(spec) === undefined
|
|
1300
|
+
? {}
|
|
1301
|
+
: { maxSubagentDepth: effectiveChildMaxSubagentDepth(spec) }),
|
|
1302
|
+
};
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
private async terminateRunningAttempt(running: RunningAttempt, cause: TerminationCauseName): Promise<void> {
|
|
1306
|
+
const terminate = this.attemptTerminators.get(running.child.identity.path);
|
|
1307
|
+
if (terminate) {
|
|
1308
|
+
await terminate(cause);
|
|
1309
|
+
return;
|
|
1310
|
+
}
|
|
1311
|
+
const token = running.attemptToken ?? this.attemptTokens.get(running.child.identity.path);
|
|
1312
|
+
if (token === undefined) {
|
|
1313
|
+
await running.promise;
|
|
1314
|
+
return;
|
|
1315
|
+
}
|
|
1316
|
+
try {
|
|
1317
|
+
await this.native.terminateChildAttempt(token, nativeCause(cause));
|
|
1318
|
+
} catch {
|
|
1319
|
+
// The runner's signal path owns the race with terminal completion.
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
private findSessionFile(sessionDir: string): string | undefined {
|
|
1324
|
+
try {
|
|
1325
|
+
const entry = readdirSync(sessionDir, { withFileTypes: true }).find(
|
|
1326
|
+
(candidate) => candidate.isFile() && candidate.name.endsWith(".jsonl"),
|
|
1327
|
+
);
|
|
1328
|
+
return entry ? join(sessionDir, entry.name) : undefined;
|
|
1329
|
+
} catch {
|
|
1330
|
+
return undefined;
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
export function createSubagentControl(parent: ParentContext, sessionRoot?: string): SubagentControlRuntime {
|
|
1336
|
+
return new SubagentControlRuntime(parent, sessionRoot);
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
export function admit_child_session(
|
|
1340
|
+
control: SubagentControlRuntime,
|
|
1341
|
+
spec: ChildSpec,
|
|
1342
|
+
parent: ParentContext,
|
|
1343
|
+
): AdmittedResult {
|
|
1344
|
+
return control.admitChildSession(spec, parent);
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
export function run_child_attempt(
|
|
1348
|
+
control: SubagentControlRuntime,
|
|
1349
|
+
admitted: AdmittedChild,
|
|
1350
|
+
candidate: ModelCandidate,
|
|
1351
|
+
signals: AttemptSignals,
|
|
1352
|
+
): Promise<AttemptOutcome> {
|
|
1353
|
+
return control.runChildAttempt(
|
|
1354
|
+
admitted,
|
|
1355
|
+
candidate,
|
|
1356
|
+
signals,
|
|
1357
|
+
undefined,
|
|
1358
|
+
defaultFastModeForChild(
|
|
1359
|
+
admitted.policy.cwd,
|
|
1360
|
+
admitted.spec.parent?.orchestrationContext,
|
|
1361
|
+
admitted.spec.parent?.workflowStageSubagentGuard,
|
|
1362
|
+
),
|
|
1363
|
+
);
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
export function continue_in_background(
|
|
1367
|
+
control: SubagentControlRuntime,
|
|
1368
|
+
running: RunningAttempt,
|
|
1369
|
+
reason: ContinuationReason,
|
|
1370
|
+
): string {
|
|
1371
|
+
return control.continueInBackground(running, reason);
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
export function reload_cold_child(control: SubagentControlRuntime, pathValue: string, message: string): AdmittedResult {
|
|
1375
|
+
return control.reloadColdChild(pathValue, message);
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
export function terminate_child_attempt(
|
|
1379
|
+
control: SubagentControlRuntime,
|
|
1380
|
+
running: RunningAttempt,
|
|
1381
|
+
cause: TerminationCauseName,
|
|
1382
|
+
): Promise<void> {
|
|
1383
|
+
return control.terminateChildAttempt(running, cause);
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
export function deliver_child_result(
|
|
1387
|
+
control: SubagentControlRuntime,
|
|
1388
|
+
envelope: ResultEnvelope,
|
|
1389
|
+
options?: DeliverChildResultOptions,
|
|
1390
|
+
): Promise<void> {
|
|
1391
|
+
return control.deliverChildResult(envelope, options);
|
|
1392
|
+
}
|