@jawcode-dev/coding-agent 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +376 -0
- package/README.md +37 -0
- package/dist/types/async/index.d.ts +2 -0
- package/dist/types/async/job-manager.d.ts +294 -0
- package/dist/types/async/support.d.ts +2 -0
- package/dist/types/autoresearch/dashboard.d.ts +4 -0
- package/dist/types/autoresearch/git.d.ts +36 -0
- package/dist/types/autoresearch/helpers.d.ts +24 -0
- package/dist/types/autoresearch/index.d.ts +2 -0
- package/dist/types/autoresearch/state.d.ts +17 -0
- package/dist/types/autoresearch/storage.d.ts +142 -0
- package/dist/types/autoresearch/tools/init-experiment.d.ts +31 -0
- package/dist/types/autoresearch/tools/log-experiment.d.ts +23 -0
- package/dist/types/autoresearch/tools/run-experiment.d.ts +8 -0
- package/dist/types/autoresearch/tools/update-notes.d.ts +12 -0
- package/dist/types/autoresearch/types.d.ts +154 -0
- package/dist/types/capability/context-file.d.ts +17 -0
- package/dist/types/capability/extension-module.d.ts +15 -0
- package/dist/types/capability/extension.d.ts +28 -0
- package/dist/types/capability/fs.d.ts +20 -0
- package/dist/types/capability/hook.d.ts +19 -0
- package/dist/types/capability/index.d.ts +80 -0
- package/dist/types/capability/instruction.d.ts +17 -0
- package/dist/types/capability/mcp.d.ts +45 -0
- package/dist/types/capability/prompt.d.ts +15 -0
- package/dist/types/capability/rule.d.ts +61 -0
- package/dist/types/capability/settings.d.ts +15 -0
- package/dist/types/capability/skill.d.ts +36 -0
- package/dist/types/capability/slash-command.d.ts +17 -0
- package/dist/types/capability/ssh.d.ts +23 -0
- package/dist/types/capability/system-prompt.d.ts +15 -0
- package/dist/types/capability/tool.d.ts +19 -0
- package/dist/types/capability/types.d.ts +154 -0
- package/dist/types/cli/agents-cli.d.ts +12 -0
- package/dist/types/cli/args.d.ts +56 -0
- package/dist/types/cli/auth-broker-cli.d.ts +25 -0
- package/dist/types/cli/auth-gateway-cli.d.ts +18 -0
- package/dist/types/cli/classify-install-target.d.ts +18 -0
- package/dist/types/cli/commands/init-xdg.d.ts +1 -0
- package/dist/types/cli/config-cli.d.ts +22 -0
- package/dist/types/cli/fast-help.d.ts +1 -0
- package/dist/types/cli/file-processor.d.ts +11 -0
- package/dist/types/cli/grep-cli.d.ts +17 -0
- package/dist/types/cli/initial-message.d.ts +17 -0
- package/dist/types/cli/list-models.d.ts +30 -0
- package/dist/types/cli/notify-cli.d.ts +29 -0
- package/dist/types/cli/plugin-cli.d.ts +32 -0
- package/dist/types/cli/read-cli.d.ts +4 -0
- package/dist/types/cli/session-picker.d.ts +3 -0
- package/dist/types/cli/setup-cli.d.ts +45 -0
- package/dist/types/cli/shell-cli.d.ts +8 -0
- package/dist/types/cli/skills-cli.d.ts +9 -0
- package/dist/types/cli/ssh-cli.d.ts +21 -0
- package/dist/types/cli/stats-cli.d.ts +17 -0
- package/dist/types/cli/update-cli.d.ts +41 -0
- package/dist/types/cli/web-search-cli.d.ts +20 -0
- package/dist/types/cli/worktree-cli.d.ts +26 -0
- package/dist/types/cli.d.ts +4 -0
- package/dist/types/commands/acp.d.ts +12 -0
- package/dist/types/commands/agents.d.ts +34 -0
- package/dist/types/commands/auth-broker.d.ts +54 -0
- package/dist/types/commands/auth-gateway.d.ts +32 -0
- package/dist/types/commands/chat.d.ts +18 -0
- package/dist/types/commands/codex-native-hook.d.ts +6 -0
- package/dist/types/commands/commit.d.ts +27 -0
- package/dist/types/commands/config.d.ts +30 -0
- package/dist/types/commands/contribution-prep.d.ts +18 -0
- package/dist/types/commands/coordinator.d.ts +19 -0
- package/dist/types/commands/goal.d.ts +31 -0
- package/dist/types/commands/grep.d.ts +42 -0
- package/dist/types/commands/harness.d.ts +50 -0
- package/dist/types/commands/interview.d.ts +51 -0
- package/dist/types/commands/launch.d.ts +127 -0
- package/dist/types/commands/mcp-serve.d.ts +24 -0
- package/dist/types/commands/memory.d.ts +19 -0
- package/dist/types/commands/notify.d.ts +30 -0
- package/dist/types/commands/orchestrate.d.ts +48 -0
- package/dist/types/commands/planphase.d.ts +7 -0
- package/dist/types/commands/plugin.d.ts +52 -0
- package/dist/types/commands/ralplan.d.ts +7 -0
- package/dist/types/commands/read.d.ts +15 -0
- package/dist/types/commands/session.d.ts +24 -0
- package/dist/types/commands/setup.d.ts +95 -0
- package/dist/types/commands/shell.d.ts +21 -0
- package/dist/types/commands/skills.d.ts +26 -0
- package/dist/types/commands/ssh.d.ts +48 -0
- package/dist/types/commands/state.d.ts +7 -0
- package/dist/types/commands/stats.d.ts +25 -0
- package/dist/types/commands/team.d.ts +24 -0
- package/dist/types/commands/ultragoal.d.ts +8 -0
- package/dist/types/commands/update.d.ts +20 -0
- package/dist/types/commands/web-search.d.ts +33 -0
- package/dist/types/commands/worktree.d.ts +31 -0
- package/dist/types/commit/agentic/agent.d.ts +31 -0
- package/dist/types/commit/agentic/fallback.d.ts +5 -0
- package/dist/types/commit/agentic/index.d.ts +2 -0
- package/dist/types/commit/agentic/state.d.ts +58 -0
- package/dist/types/commit/agentic/tools/analyze-file.d.ts +19 -0
- package/dist/types/commit/agentic/tools/git-file-diff.d.ts +10 -0
- package/dist/types/commit/agentic/tools/git-hunk.d.ts +9 -0
- package/dist/types/commit/agentic/tools/git-overview.d.ts +9 -0
- package/dist/types/commit/agentic/tools/index.d.ts +16 -0
- package/dist/types/commit/agentic/tools/propose-changelog.d.ts +28 -0
- package/dist/types/commit/agentic/tools/propose-commit.d.ts +36 -0
- package/dist/types/commit/agentic/tools/recent-commits.d.ts +7 -0
- package/dist/types/commit/agentic/tools/schemas.d.ts +27 -0
- package/dist/types/commit/agentic/tools/split-commit.d.ts +53 -0
- package/dist/types/commit/agentic/topo-sort.d.ts +4 -0
- package/dist/types/commit/agentic/trivial.d.ts +7 -0
- package/dist/types/commit/agentic/validation.d.ts +20 -0
- package/dist/types/commit/analysis/conventional.d.ts +22 -0
- package/dist/types/commit/analysis/index.d.ts +4 -0
- package/dist/types/commit/analysis/scope.d.ts +6 -0
- package/dist/types/commit/analysis/summary.d.ts +19 -0
- package/dist/types/commit/analysis/validation.d.ts +8 -0
- package/dist/types/commit/changelog/detect.d.ts +2 -0
- package/dist/types/commit/changelog/generate.d.ts +30 -0
- package/dist/types/commit/changelog/index.d.ts +30 -0
- package/dist/types/commit/changelog/parse.d.ts +2 -0
- package/dist/types/commit/cli.d.ts +3 -0
- package/dist/types/commit/git/diff.d.ts +5 -0
- package/dist/types/commit/index.d.ts +4 -0
- package/dist/types/commit/map-reduce/index.d.ts +28 -0
- package/dist/types/commit/map-reduce/map-phase.d.ts +17 -0
- package/dist/types/commit/map-reduce/reduce-phase.d.ts +13 -0
- package/dist/types/commit/map-reduce/utils.d.ts +2 -0
- package/dist/types/commit/message.d.ts +2 -0
- package/dist/types/commit/model-selection.d.ts +15 -0
- package/dist/types/commit/pipeline.d.ts +5 -0
- package/dist/types/commit/shared-llm.d.ts +54 -0
- package/dist/types/commit/types.d.ts +78 -0
- package/dist/types/commit/utils/exclusions.d.ts +4 -0
- package/dist/types/commit/utils.d.ts +20 -0
- package/dist/types/config/config-file.d.ts +58 -0
- package/dist/types/config/file-lock.d.ts +6 -0
- package/dist/types/config/keybindings.d.ts +359 -0
- package/dist/types/config/model-equivalence.d.ts +24 -0
- package/dist/types/config/model-profile-activation.d.ts +36 -0
- package/dist/types/config/model-profiles.d.ts +19 -0
- package/dist/types/config/model-registry.d.ts +445 -0
- package/dist/types/config/model-resolver.d.ts +217 -0
- package/dist/types/config/models-config-schema.d.ts +652 -0
- package/dist/types/config/oauth-provider-aliases.d.ts +1 -0
- package/dist/types/config/prompt-templates.d.ts +32 -0
- package/dist/types/config/resolve-config-value.d.ts +17 -0
- package/dist/types/config/settings-schema.d.ts +3683 -0
- package/dist/types/config/settings.d.ts +134 -0
- package/dist/types/config/skill-settings-defaults.d.ts +21 -0
- package/dist/types/config.d.ts +66 -0
- package/dist/types/coordinator/contract.d.ts +4 -0
- package/dist/types/coordinator-mcp/policy.d.ts +24 -0
- package/dist/types/coordinator-mcp/safety.d.ts +26 -0
- package/dist/types/coordinator-mcp/server.d.ts +52 -0
- package/dist/types/cursor.d.ts +24 -0
- package/dist/types/dap/client.d.ts +38 -0
- package/dist/types/dap/config.d.ts +6 -0
- package/dist/types/dap/index.d.ts +4 -0
- package/dist/types/dap/session.d.ts +108 -0
- package/dist/types/dap/types.d.ts +524 -0
- package/dist/types/debug/crash-diagnostics.d.ts +45 -0
- package/dist/types/debug/index.d.ts +15 -0
- package/dist/types/debug/log-formatting.d.ts +4 -0
- package/dist/types/debug/log-viewer.d.ts +68 -0
- package/dist/types/debug/profiler.d.ts +24 -0
- package/dist/types/debug/raw-sse-buffer.d.ts +44 -0
- package/dist/types/debug/raw-sse.d.ts +16 -0
- package/dist/types/debug/report-bundle.d.ts +55 -0
- package/dist/types/debug/runtime-gauges.d.ts +6 -0
- package/dist/types/debug/system-info.d.ts +26 -0
- package/dist/types/defaults/jwc-defaults.d.ts +69 -0
- package/dist/types/discovery/agents-md.d.ts +1 -0
- package/dist/types/discovery/agents.d.ts +12 -0
- package/dist/types/discovery/builtin.d.ts +1 -0
- package/dist/types/discovery/claude-plugins.d.ts +1 -0
- package/dist/types/discovery/claude.d.ts +1 -0
- package/dist/types/discovery/cli-jaw.d.ts +1 -0
- package/dist/types/discovery/cline.d.ts +1 -0
- package/dist/types/discovery/codex.d.ts +1 -0
- package/dist/types/discovery/cursor.d.ts +16 -0
- package/dist/types/discovery/gemini.d.ts +1 -0
- package/dist/types/discovery/github.d.ts +1 -0
- package/dist/types/discovery/helpers.d.ts +278 -0
- package/dist/types/discovery/index.d.ts +49 -0
- package/dist/types/discovery/mcp-json.d.ts +1 -0
- package/dist/types/discovery/opencode.d.ts +1 -0
- package/dist/types/discovery/plugin-dir-roots.d.ts +15 -0
- package/dist/types/discovery/ssh.d.ts +1 -0
- package/dist/types/discovery/substitute-plugin-root.d.ts +5 -0
- package/dist/types/discovery/vscode.d.ts +1 -0
- package/dist/types/discovery/windsurf.d.ts +13 -0
- package/dist/types/edit/apply-patch/index.d.ts +35 -0
- package/dist/types/edit/apply-patch/parser.d.ts +34 -0
- package/dist/types/edit/diff.d.ts +75 -0
- package/dist/types/edit/file-read-cache.d.ts +25 -0
- package/dist/types/edit/index.d.ts +58 -0
- package/dist/types/edit/modes/apply-patch.d.ts +24 -0
- package/dist/types/edit/modes/patch.d.ts +99 -0
- package/dist/types/edit/modes/replace.d.ts +149 -0
- package/dist/types/edit/normalize.d.ts +43 -0
- package/dist/types/edit/notebook.d.ts +23 -0
- package/dist/types/edit/read-file.d.ts +2 -0
- package/dist/types/edit/renderer.d.ts +110 -0
- package/dist/types/edit/streaming.d.ts +66 -0
- package/dist/types/eval/backend.d.ts +40 -0
- package/dist/types/eval/index.d.ts +4 -0
- package/dist/types/eval/js/context-manager.d.ts +24 -0
- package/dist/types/eval/js/executor.d.ts +28 -0
- package/dist/types/eval/js/index.d.ts +10 -0
- package/dist/types/eval/js/shared/helpers.d.ts +38 -0
- package/dist/types/eval/js/shared/indirect-eval.d.ts +14 -0
- package/dist/types/eval/js/shared/prelude.d.ts +1 -0
- package/dist/types/eval/js/shared/rewrite-imports.d.ts +6 -0
- package/dist/types/eval/js/shared/runtime.d.ts +47 -0
- package/dist/types/eval/js/shared/types.d.ts +24 -0
- package/dist/types/eval/js/tool-bridge.d.ts +18 -0
- package/dist/types/eval/js/worker-core.d.ts +5 -0
- package/dist/types/eval/js/worker-entry.d.ts +1 -0
- package/dist/types/eval/js/worker-protocol.d.ts +77 -0
- package/dist/types/eval/py/display.d.ts +25 -0
- package/dist/types/eval/py/executor.d.ts +85 -0
- package/dist/types/eval/py/index.d.ts +10 -0
- package/dist/types/eval/py/kernel.d.ts +63 -0
- package/dist/types/eval/py/prelude.d.ts +1 -0
- package/dist/types/eval/py/runtime.d.ts +21 -0
- package/dist/types/eval/py/tool-bridge.d.ts +20 -0
- package/dist/types/eval/types.d.ts +52 -0
- package/dist/types/exa/factory.d.ts +13 -0
- package/dist/types/exa/index.d.ts +20 -0
- package/dist/types/exa/mcp-client.d.ts +45 -0
- package/dist/types/exa/render.d.ts +19 -0
- package/dist/types/exa/researcher.d.ts +9 -0
- package/dist/types/exa/search.d.ts +9 -0
- package/dist/types/exa/types.d.ts +155 -0
- package/dist/types/exa/websets.d.ts +9 -0
- package/dist/types/exec/bash-executor.d.ts +58 -0
- package/dist/types/exec/exec.d.ts +25 -0
- package/dist/types/exec/idle-timeout-watchdog.d.ts +18 -0
- package/dist/types/exec/non-interactive-env.d.ts +4 -0
- package/dist/types/export/custom-share.d.ts +20 -0
- package/dist/types/export/html/index.d.ts +10 -0
- package/dist/types/export/html/template.generated.d.ts +1 -0
- package/dist/types/export/html/template.macro.d.ts +5 -0
- package/dist/types/export/ttsr.d.ts +44 -0
- package/dist/types/extensibility/custom-commands/bundled/ci-green/index.d.ts +9 -0
- package/dist/types/extensibility/custom-commands/bundled/review/index.d.ts +10 -0
- package/dist/types/extensibility/custom-commands/index.d.ts +2 -0
- package/dist/types/extensibility/custom-commands/loader.d.ts +29 -0
- package/dist/types/extensibility/custom-commands/types.d.ts +106 -0
- package/dist/types/extensibility/custom-tools/index.d.ts +6 -0
- package/dist/types/extensibility/custom-tools/loader.d.ts +69 -0
- package/dist/types/extensibility/custom-tools/types.d.ts +227 -0
- package/dist/types/extensibility/custom-tools/wrapper.d.ts +23 -0
- package/dist/types/extensibility/extensions/compact-handler.d.ts +26 -0
- package/dist/types/extensibility/extensions/get-commands-handler.d.ts +29 -0
- package/dist/types/extensibility/extensions/index.d.ts +8 -0
- package/dist/types/extensibility/extensions/loader.d.ts +43 -0
- package/dist/types/extensibility/extensions/runner.d.ts +134 -0
- package/dist/types/extensibility/extensions/types.d.ts +916 -0
- package/dist/types/extensibility/extensions/wrapper.d.ts +54 -0
- package/dist/types/extensibility/hooks/index.d.ts +5 -0
- package/dist/types/extensibility/hooks/loader.d.ts +89 -0
- package/dist/types/extensibility/hooks/runner.d.ts +126 -0
- package/dist/types/extensibility/hooks/tool-wrapper.d.ts +25 -0
- package/dist/types/extensibility/hooks/types.d.ts +431 -0
- package/dist/types/extensibility/jwc-plugins/activation.d.ts +14 -0
- package/dist/types/extensibility/jwc-plugins/index.d.ts +9 -0
- package/dist/types/extensibility/jwc-plugins/injection.d.ts +31 -0
- package/dist/types/extensibility/jwc-plugins/loader.d.ts +3 -0
- package/dist/types/extensibility/jwc-plugins/paths.d.ts +8 -0
- package/dist/types/extensibility/jwc-plugins/schema.d.ts +3 -0
- package/dist/types/extensibility/jwc-plugins/state.d.ts +9 -0
- package/dist/types/extensibility/jwc-plugins/tools.d.ts +8 -0
- package/dist/types/extensibility/jwc-plugins/types.d.ts +64 -0
- package/dist/types/extensibility/jwc-plugins/validation.d.ts +4 -0
- package/dist/types/extensibility/plugins/doctor.d.ts +3 -0
- package/dist/types/extensibility/plugins/git-url.d.ts +34 -0
- package/dist/types/extensibility/plugins/index.d.ts +7 -0
- package/dist/types/extensibility/plugins/installer.d.ts +5 -0
- package/dist/types/extensibility/plugins/legacy-pi-compat.d.ts +2 -0
- package/dist/types/extensibility/plugins/loader.d.ts +31 -0
- package/dist/types/extensibility/plugins/manager.d.ts +65 -0
- package/dist/types/extensibility/plugins/marketplace/cache.d.ts +41 -0
- package/dist/types/extensibility/plugins/marketplace/fetcher.d.ts +48 -0
- package/dist/types/extensibility/plugins/marketplace/index.d.ts +6 -0
- package/dist/types/extensibility/plugins/marketplace/manager.d.ts +57 -0
- package/dist/types/extensibility/plugins/marketplace/registry.d.ts +34 -0
- package/dist/types/extensibility/plugins/marketplace/source-resolver.d.ts +28 -0
- package/dist/types/extensibility/plugins/marketplace/types.d.ts +130 -0
- package/dist/types/extensibility/plugins/parser.d.ts +52 -0
- package/dist/types/extensibility/plugins/types.d.ts +149 -0
- package/dist/types/extensibility/shared-events.d.ts +280 -0
- package/dist/types/extensibility/skills.d.ts +82 -0
- package/dist/types/extensibility/slash-commands.d.ts +49 -0
- package/dist/types/extensibility/tool-proxy.d.ts +4 -0
- package/dist/types/extensibility/typebox.d.ts +155 -0
- package/dist/types/extensibility/utils.d.ts +12 -0
- package/dist/types/goals/goal-planning-start.d.ts +7 -0
- package/dist/types/goals/index.d.ts +3 -0
- package/dist/types/goals/runtime.d.ts +62 -0
- package/dist/types/goals/state.d.ts +40 -0
- package/dist/types/goals/tools/goal-tool.d.ts +62 -0
- package/dist/types/harness-control-plane/classifier.d.ts +13 -0
- package/dist/types/harness-control-plane/control-endpoint.d.ts +31 -0
- package/dist/types/harness-control-plane/finalize.d.ts +55 -0
- package/dist/types/harness-control-plane/operate.d.ts +35 -0
- package/dist/types/harness-control-plane/owner.d.ts +46 -0
- package/dist/types/harness-control-plane/phase-rollup.d.ts +23 -0
- package/dist/types/harness-control-plane/preserve.d.ts +19 -0
- package/dist/types/harness-control-plane/receipt-ingest.d.ts +19 -0
- package/dist/types/harness-control-plane/receipt-spool.d.ts +26 -0
- package/dist/types/harness-control-plane/receipts.d.ts +132 -0
- package/dist/types/harness-control-plane/rpc-adapter.d.ts +66 -0
- package/dist/types/harness-control-plane/seams.d.ts +21 -0
- package/dist/types/harness-control-plane/session-lease.d.ts +65 -0
- package/dist/types/harness-control-plane/state-machine.d.ts +24 -0
- package/dist/types/harness-control-plane/storage.d.ts +60 -0
- package/dist/types/harness-control-plane/types.d.ts +179 -0
- package/dist/types/hashline/anchors.d.ts +20 -0
- package/dist/types/hashline/apply.d.ts +14 -0
- package/dist/types/hashline/constants.d.ts +19 -0
- package/dist/types/hashline/diff-preview.d.ts +2 -0
- package/dist/types/hashline/diff.d.ts +17 -0
- package/dist/types/hashline/execute.d.ts +4 -0
- package/dist/types/hashline/hash.d.ts +123 -0
- package/dist/types/hashline/index.d.ts +13 -0
- package/dist/types/hashline/input.d.ts +11 -0
- package/dist/types/hashline/parser.d.ts +7 -0
- package/dist/types/hashline/prefixes.d.ts +7 -0
- package/dist/types/hashline/recovery.d.ts +27 -0
- package/dist/types/hashline/stream.d.ts +2 -0
- package/dist/types/hashline/types.d.ts +77 -0
- package/dist/types/hindsight/backend.d.ts +13 -0
- package/dist/types/hindsight/bank.d.ts +54 -0
- package/dist/types/hindsight/client.d.ts +224 -0
- package/dist/types/hindsight/config.d.ts +51 -0
- package/dist/types/hindsight/content.d.ts +71 -0
- package/dist/types/hindsight/index.d.ts +8 -0
- package/dist/types/hindsight/mental-models.d.ts +125 -0
- package/dist/types/hindsight/state.d.ts +99 -0
- package/dist/types/hindsight/transcript.d.ts +28 -0
- package/dist/types/hooks/codex-native-hooks-config.d.ts +29 -0
- package/dist/types/hooks/native-skill-hook.d.ts +16 -0
- package/dist/types/hooks/skill-keywords.d.ts +18 -0
- package/dist/types/hooks/skill-state.d.ts +88 -0
- package/dist/types/index.d.ts +33 -0
- package/dist/types/internal-urls/agent-protocol.d.ts +12 -0
- package/dist/types/internal-urls/artifact-protocol.d.ts +6 -0
- package/dist/types/internal-urls/docs-index.generated.d.ts +2 -0
- package/dist/types/internal-urls/index.d.ts +20 -0
- package/dist/types/internal-urls/issue-pr-protocol.d.ts +17 -0
- package/dist/types/internal-urls/json-query.d.ts +30 -0
- package/dist/types/internal-urls/jwc-protocol.d.ts +19 -0
- package/dist/types/internal-urls/local-protocol.d.ts +39 -0
- package/dist/types/internal-urls/mcp-protocol.d.ts +12 -0
- package/dist/types/internal-urls/memory-protocol.d.ts +23 -0
- package/dist/types/internal-urls/parse.d.ts +19 -0
- package/dist/types/internal-urls/registry-helpers.d.ts +11 -0
- package/dist/types/internal-urls/router.d.ts +14 -0
- package/dist/types/internal-urls/rule-protocol.d.ts +6 -0
- package/dist/types/internal-urls/skill-protocol.d.ts +13 -0
- package/dist/types/internal-urls/types.d.ts +109 -0
- package/dist/types/jaw-interview/structured-renderer.d.ts +20 -0
- package/dist/types/jwc-runtime/actor-registry.d.ts +76 -0
- package/dist/types/jwc-runtime/agent-identity.d.ts +6 -0
- package/dist/types/jwc-runtime/cli-jaw-home.d.ts +1 -0
- package/dist/types/jwc-runtime/cli-jaw-vocab.d.ts +15 -0
- package/dist/types/jwc-runtime/cli-write-receipt.d.ts +24 -0
- package/dist/types/jwc-runtime/goal-cli.d.ts +7 -0
- package/dist/types/jwc-runtime/goal-engine.d.ts +193 -0
- package/dist/types/jwc-runtime/goal-guard.d.ts +26 -0
- package/dist/types/jwc-runtime/goal-mode-request.d.ts +78 -0
- package/dist/types/jwc-runtime/jaw-interview-runtime.d.ts +41 -0
- package/dist/types/jwc-runtime/launch-tmux.d.ts +70 -0
- package/dist/types/jwc-runtime/launch-worktree.d.ts +46 -0
- package/dist/types/jwc-runtime/legacy-storage.d.ts +19 -0
- package/dist/types/jwc-runtime/memory-runtime.d.ts +16 -0
- package/dist/types/jwc-runtime/orchestrate-runtime.d.ts +12 -0
- package/dist/types/jwc-runtime/orchestrate-state.d.ts +246 -0
- package/dist/types/jwc-runtime/plan-writer.d.ts +26 -0
- package/dist/types/jwc-runtime/restricted-role-agent-bash.d.ts +2 -0
- package/dist/types/jwc-runtime/session-state-sidecar.d.ts +17 -0
- package/dist/types/jwc-runtime/stage-skill-map.d.ts +7 -0
- package/dist/types/jwc-runtime/state-graph.d.ts +4 -0
- package/dist/types/jwc-runtime/state-migrations.d.ts +34 -0
- package/dist/types/jwc-runtime/state-renderer.d.ts +65 -0
- package/dist/types/jwc-runtime/state-runtime.d.ts +37 -0
- package/dist/types/jwc-runtime/state-schema.d.ts +324 -0
- package/dist/types/jwc-runtime/state-validation.d.ts +6 -0
- package/dist/types/jwc-runtime/state-writer.d.ts +147 -0
- package/dist/types/jwc-runtime/team-runtime.d.ts +349 -0
- package/dist/types/jwc-runtime/tmux-common.d.ts +49 -0
- package/dist/types/jwc-runtime/tmux-sessions.d.ts +17 -0
- package/dist/types/jwc-runtime/workflow-command-ref.d.ts +43 -0
- package/dist/types/jwc-runtime/workflow-manifest.d.ts +54 -0
- package/dist/types/lsp/client.d.ts +66 -0
- package/dist/types/lsp/clients/biome-client.d.ts +16 -0
- package/dist/types/lsp/clients/index.d.ts +19 -0
- package/dist/types/lsp/clients/lsp-linter-client.d.ts +16 -0
- package/dist/types/lsp/clients/swiftlint-client.d.ts +20 -0
- package/dist/types/lsp/config.d.ts +65 -0
- package/dist/types/lsp/edits.d.ts +23 -0
- package/dist/types/lsp/index.d.ts +130 -0
- package/dist/types/lsp/lspmux.d.ts +58 -0
- package/dist/types/lsp/render.d.ts +32 -0
- package/dist/types/lsp/startup-events.d.ts +11 -0
- package/dist/types/lsp/types.d.ts +302 -0
- package/dist/types/lsp/utils.d.ts +108 -0
- package/dist/types/main.d.ts +72 -0
- package/dist/types/mem0/backend.d.ts +2 -0
- package/dist/types/mem0/client.d.ts +49 -0
- package/dist/types/mem0/config.d.ts +24 -0
- package/dist/types/mem0/index.d.ts +5 -0
- package/dist/types/mem0/scope.d.ts +12 -0
- package/dist/types/mem0/state.d.ts +36 -0
- package/dist/types/memories/index.d.ts +28 -0
- package/dist/types/memories/local-query.d.ts +112 -0
- package/dist/types/memories/memory-config.d.ts +46 -0
- package/dist/types/memories/memory-fts.d.ts +51 -0
- package/dist/types/memories/memory-model-resolution.d.ts +20 -0
- package/dist/types/memories/memory-quality.d.ts +27 -0
- package/dist/types/memories/storage.d.ts +110 -0
- package/dist/types/memory-backend/index.d.ts +4 -0
- package/dist/types/memory-backend/local-backend.d.ts +9 -0
- package/dist/types/memory-backend/off-backend.d.ts +7 -0
- package/dist/types/memory-backend/resolve.d.ts +16 -0
- package/dist/types/memory-backend/types.d.ts +64 -0
- package/dist/types/migrate-config-dir-startup.d.ts +1 -0
- package/dist/types/migrate-config-dir.d.ts +22 -0
- package/dist/types/modes/acp/acp-agent.d.ts +61 -0
- package/dist/types/modes/acp/acp-client-bridge.d.ts +9 -0
- package/dist/types/modes/acp/acp-event-mapper.d.ts +34 -0
- package/dist/types/modes/acp/acp-mode.d.ts +5 -0
- package/dist/types/modes/acp/index.d.ts +2 -0
- package/dist/types/modes/acp/terminal-auth.d.ts +6 -0
- package/dist/types/modes/background-row-model.d.ts +3 -0
- package/dist/types/modes/bridge/auth.d.ts +12 -0
- package/dist/types/modes/bridge/bridge-client-bridge.d.ts +9 -0
- package/dist/types/modes/bridge/bridge-mode.d.ts +46 -0
- package/dist/types/modes/bridge/bridge-ui-context.d.ts +88 -0
- package/dist/types/modes/bridge/event-stream.d.ts +8 -0
- package/dist/types/modes/components/_cli-jaw-entry.d.ts +31 -0
- package/dist/types/modes/components/agent-dashboard.d.ts +21 -0
- package/dist/types/modes/components/assistant-message.d.ts +33 -0
- package/dist/types/modes/components/background-footer-detail.d.ts +6 -0
- package/dist/types/modes/components/background-footer-panel-model.d.ts +18 -0
- package/dist/types/modes/components/background-footer-panel.d.ts +19 -0
- package/dist/types/modes/components/bash-execution.d.ts +37 -0
- package/dist/types/modes/components/bordered-loader.d.ts +11 -0
- package/dist/types/modes/components/branch-summary-message.d.ts +15 -0
- package/dist/types/modes/components/btw-panel.d.ts +16 -0
- package/dist/types/modes/components/compaction-summary-message.d.ts +15 -0
- package/dist/types/modes/components/composer-chrome.d.ts +7 -0
- package/dist/types/modes/components/composer-footer.d.ts +43 -0
- package/dist/types/modes/components/countdown-timer.d.ts +14 -0
- package/dist/types/modes/components/custom-editor.d.ts +80 -0
- package/dist/types/modes/components/custom-message.d.ts +17 -0
- package/dist/types/modes/components/custom-provider-wizard.d.ts +10 -0
- package/dist/types/modes/components/diff.d.ts +11 -0
- package/dist/types/modes/components/dynamic-border.d.ts +14 -0
- package/dist/types/modes/components/eval-execution.d.ts +31 -0
- package/dist/types/modes/components/execution-shared.d.ts +46 -0
- package/dist/types/modes/components/extensions/extension-dashboard.d.ts +26 -0
- package/dist/types/modes/components/extensions/extension-list.d.ts +39 -0
- package/dist/types/modes/components/extensions/index.d.ts +8 -0
- package/dist/types/modes/components/extensions/inspector-panel.d.ts +8 -0
- package/dist/types/modes/components/extensions/state-manager.d.ts +50 -0
- package/dist/types/modes/components/extensions/types.d.ts +151 -0
- package/dist/types/modes/components/footer.d.ts +30 -0
- package/dist/types/modes/components/full-transcript-overlay.d.ts +21 -0
- package/dist/types/modes/components/help-selector.d.ts +38 -0
- package/dist/types/modes/components/history-search.d.ts +7 -0
- package/dist/types/modes/components/hook-editor.d.ts +18 -0
- package/dist/types/modes/components/hook-input.d.ts +15 -0
- package/dist/types/modes/components/hook-message.d.ts +15 -0
- package/dist/types/modes/components/hook-selector.d.ts +64 -0
- package/dist/types/modes/components/index.d.ts +35 -0
- package/dist/types/modes/components/jobs-overlay-model.d.ts +31 -0
- package/dist/types/modes/components/jobs-overlay.d.ts +30 -0
- package/dist/types/modes/components/keybinding-hints.d.ts +40 -0
- package/dist/types/modes/components/login-dialog.d.ts +32 -0
- package/dist/types/modes/components/message-frame.d.ts +42 -0
- package/dist/types/modes/components/model-selector.d.ts +53 -0
- package/dist/types/modes/components/oauth-selector.d.ts +14 -0
- package/dist/types/modes/components/pabcd-border.d.ts +8 -0
- package/dist/types/modes/components/plugin-selector.d.ts +26 -0
- package/dist/types/modes/components/plugin-settings.d.ts +66 -0
- package/dist/types/modes/components/provider-onboarding-selector.d.ts +7 -0
- package/dist/types/modes/components/queue-mode-selector.d.ts +9 -0
- package/dist/types/modes/components/quota-panel.d.ts +21 -0
- package/dist/types/modes/components/read-tool-group.d.ts +34 -0
- package/dist/types/modes/components/runtime-mcp-add-wizard.d.ts +25 -0
- package/dist/types/modes/components/session-observer-overlay.d.ts +11 -0
- package/dist/types/modes/components/session-selector.d.ts +30 -0
- package/dist/types/modes/components/settings-defs.d.ts +50 -0
- package/dist/types/modes/components/settings-selector.d.ts +56 -0
- package/dist/types/modes/components/show-images-selector.d.ts +9 -0
- package/dist/types/modes/components/skill-hud/render.d.ts +2 -0
- package/dist/types/modes/components/skill-message.d.ts +11 -0
- package/dist/types/modes/components/status-line/context-thresholds.d.ts +4 -0
- package/dist/types/modes/components/status-line/git-utils.d.ts +22 -0
- package/dist/types/modes/components/status-line/index.d.ts +4 -0
- package/dist/types/modes/components/status-line/presets.d.ts +3 -0
- package/dist/types/modes/components/status-line/segments.d.ts +5 -0
- package/dist/types/modes/components/status-line/separators.d.ts +3 -0
- package/dist/types/modes/components/status-line/token-rate.d.ts +10 -0
- package/dist/types/modes/components/status-line/types.d.ts +92 -0
- package/dist/types/modes/components/status-line/workflow-readers.d.ts +21 -0
- package/dist/types/modes/components/status-line.d.ts +82 -0
- package/dist/types/modes/components/theme-selector.d.ts +10 -0
- package/dist/types/modes/components/thinking-selector.d.ts +10 -0
- package/dist/types/modes/components/todo-reminder.d.ts +13 -0
- package/dist/types/modes/components/tool-execution.d.ts +69 -0
- package/dist/types/modes/components/tool-transcript-overlay.d.ts +18 -0
- package/dist/types/modes/components/tree-selector.d.ts +31 -0
- package/dist/types/modes/components/ttsr-notification.d.ts +15 -0
- package/dist/types/modes/components/user-message-selector.d.ts +28 -0
- package/dist/types/modes/components/user-message.d.ts +8 -0
- package/dist/types/modes/components/visual-truncate.d.ts +19 -0
- package/dist/types/modes/components/welcome.d.ts +42 -0
- package/dist/types/modes/controllers/btw-controller.d.ts +10 -0
- package/dist/types/modes/controllers/command-controller-shared.d.ts +47 -0
- package/dist/types/modes/controllers/command-controller.d.ts +39 -0
- package/dist/types/modes/controllers/event-controller.d.ts +12 -0
- package/dist/types/modes/controllers/extension-ui-controller.d.ts +80 -0
- package/dist/types/modes/controllers/input-controller.d.ts +49 -0
- package/dist/types/modes/controllers/runtime-mcp-command-controller.d.ts +10 -0
- package/dist/types/modes/controllers/selector-controller.d.ts +78 -0
- package/dist/types/modes/controllers/ssh-command-controller.d.ts +10 -0
- package/dist/types/modes/controllers/todo-command-controller.d.ts +7 -0
- package/dist/types/modes/emoji-autocomplete.d.ts +16 -0
- package/dist/types/modes/index.d.ts +10 -0
- package/dist/types/modes/interactive-mode.d.ts +295 -0
- package/dist/types/modes/jobs-observer.d.ts +67 -0
- package/dist/types/modes/oauth-manual-input.d.ts +8 -0
- package/dist/types/modes/print-mode.d.ts +27 -0
- package/dist/types/modes/prompt-action-autocomplete.d.ts +46 -0
- package/dist/types/modes/rpc/host-tools.d.ts +1 -0
- package/dist/types/modes/rpc/host-uris.d.ts +1 -0
- package/dist/types/modes/rpc/rpc-client.d.ts +267 -0
- package/dist/types/modes/rpc/rpc-mode.d.ts +67 -0
- package/dist/types/modes/rpc/rpc-types.d.ts +765 -0
- package/dist/types/modes/runtime-init.d.ts +21 -0
- package/dist/types/modes/session-observer-registry.d.ts +26 -0
- package/dist/types/modes/shared/agent-wire/approval-gate.d.ts +57 -0
- package/dist/types/modes/shared/agent-wire/command-contract.d.ts +18 -0
- package/dist/types/modes/shared/agent-wire/command-dispatch.d.ts +35 -0
- package/dist/types/modes/shared/agent-wire/command-validation.d.ts +2 -0
- package/dist/types/modes/shared/agent-wire/event-contract.d.ts +84 -0
- package/dist/types/modes/shared/agent-wire/event-envelope.d.ts +38 -0
- package/dist/types/modes/shared/agent-wire/event-observation.d.ts +37 -0
- package/dist/types/modes/shared/agent-wire/handshake.d.ts +56 -0
- package/dist/types/modes/shared/agent-wire/host-tool-bridge.d.ts +16 -0
- package/dist/types/modes/shared/agent-wire/host-uri-bridge.d.ts +17 -0
- package/dist/types/modes/shared/agent-wire/jaw-interview-gate.d.ts +58 -0
- package/dist/types/modes/shared/agent-wire/protocol.d.ts +25 -0
- package/dist/types/modes/shared/agent-wire/responses.d.ts +4 -0
- package/dist/types/modes/shared/agent-wire/scopes.d.ts +18 -0
- package/dist/types/modes/shared/agent-wire/session-registry.d.ts +25 -0
- package/dist/types/modes/shared/agent-wire/ui-request-broker.d.ts +42 -0
- package/dist/types/modes/shared/agent-wire/ui-result.d.ts +27 -0
- package/dist/types/modes/shared/agent-wire/unattended-action-policy.d.ts +27 -0
- package/dist/types/modes/shared/agent-wire/unattended-audit.d.ts +68 -0
- package/dist/types/modes/shared/agent-wire/unattended-run-controller.d.ts +161 -0
- package/dist/types/modes/shared/agent-wire/unattended-session.d.ts +61 -0
- package/dist/types/modes/shared/agent-wire/workflow-gate-broker.d.ts +114 -0
- package/dist/types/modes/shared/agent-wire/workflow-gate-schema.d.ts +39 -0
- package/dist/types/modes/shared.d.ts +15 -0
- package/dist/types/modes/theme/defaults/index.d.ts +499 -0
- package/dist/types/modes/theme/mermaid-cache.d.ts +9 -0
- package/dist/types/modes/theme/shimmer.d.ts +38 -0
- package/dist/types/modes/theme/theme.d.ts +274 -0
- package/dist/types/modes/types.d.ts +311 -0
- package/dist/types/modes/utils/abort-message.d.ts +4 -0
- package/dist/types/modes/utils/compaction-progress.d.ts +20 -0
- package/dist/types/modes/utils/context-usage.d.ts +53 -0
- package/dist/types/modes/utils/help-markdown.d.ts +17 -0
- package/dist/types/modes/utils/hotkeys-markdown.d.ts +5 -0
- package/dist/types/modes/utils/keybinding-matchers.d.ts +10 -0
- package/dist/types/modes/utils/session-transcript-replay.d.ts +24 -0
- package/dist/types/modes/utils/tools-markdown.d.ts +5 -0
- package/dist/types/modes/utils/ui-helpers.d.ts +77 -0
- package/dist/types/notifications/ask-bridge.d.ts +36 -0
- package/dist/types/notifications/config-command-parser.d.ts +27 -0
- package/dist/types/notifications/config.d.ts +37 -0
- package/dist/types/notifications/daemon-control.d.ts +29 -0
- package/dist/types/notifications/daemon-engine.d.ts +64 -0
- package/dist/types/notifications/daemon-inbound.d.ts +93 -0
- package/dist/types/notifications/daemon-loop.d.ts +28 -0
- package/dist/types/notifications/daemon-owner.d.ts +25 -0
- package/dist/types/notifications/daemon-runtime.d.ts +32 -0
- package/dist/types/notifications/discovery.d.ts +45 -0
- package/dist/types/notifications/index.d.ts +34 -0
- package/dist/types/notifications/lifecycle-audit.d.ts +60 -0
- package/dist/types/notifications/lifecycle-command-parser.d.ts +19 -0
- package/dist/types/notifications/lifecycle-control-runtime.d.ts +45 -0
- package/dist/types/notifications/notification-redaction.d.ts +36 -0
- package/dist/types/notifications/protocol.d.ts +43 -0
- package/dist/types/notifications/remote-answer.d.ts +78 -0
- package/dist/types/notifications/reply-bridge.d.ts +21 -0
- package/dist/types/notifications/server.d.ts +38 -0
- package/dist/types/notifications/session-lifecycle.d.ts +22 -0
- package/dist/types/notifications/session-registry.d.ts +31 -0
- package/dist/types/notifications/telegram-api.d.ts +93 -0
- package/dist/types/notifications/telegram-ask-keyboard.d.ts +57 -0
- package/dist/types/notifications/telegram-callback-ingest.d.ts +49 -0
- package/dist/types/notifications/telegram-inbound-router.d.ts +57 -0
- package/dist/types/notifications/telegram-media-policy.d.ts +27 -0
- package/dist/types/notifications/telegram-media-render.d.ts +29 -0
- package/dist/types/notifications/telegram-message-ingest.d.ts +54 -0
- package/dist/types/notifications/telegram-pairing.d.ts +21 -0
- package/dist/types/notifications/threaded-lifecycle.d.ts +23 -0
- package/dist/types/notifications/threaded-shutdown.d.ts +19 -0
- package/dist/types/notifications/threaded-surface.d.ts +71 -0
- package/dist/types/notifications/transport-shell.d.ts +47 -0
- package/dist/types/notifications/transport-state.d.ts +44 -0
- package/dist/types/notifications/workspace-path-confinement.d.ts +12 -0
- package/dist/types/plan-mode/approved-plan.d.ts +49 -0
- package/dist/types/plan-mode/state.d.ts +6 -0
- package/dist/types/registry/agent-registry.d.ts +62 -0
- package/dist/types/reminders/star-reminder.d.ts +115 -0
- package/dist/types/runtime-mcp/client.d.ts +74 -0
- package/dist/types/runtime-mcp/config-writer.d.ts +53 -0
- package/dist/types/runtime-mcp/config.d.ts +75 -0
- package/dist/types/runtime-mcp/discoverable-tool-metadata.d.ts +7 -0
- package/dist/types/runtime-mcp/index.d.ts +18 -0
- package/dist/types/runtime-mcp/json-rpc.d.ts +22 -0
- package/dist/types/runtime-mcp/loader.d.ts +43 -0
- package/dist/types/runtime-mcp/manager.d.ts +193 -0
- package/dist/types/runtime-mcp/oauth-discovery.d.ts +40 -0
- package/dist/types/runtime-mcp/oauth-flow.d.ts +59 -0
- package/dist/types/runtime-mcp/render.d.ts +25 -0
- package/dist/types/runtime-mcp/smithery-auth.d.ts +16 -0
- package/dist/types/runtime-mcp/smithery-connect.d.ts +38 -0
- package/dist/types/runtime-mcp/smithery-registry.d.ts +51 -0
- package/dist/types/runtime-mcp/tool-bridge.d.ts +86 -0
- package/dist/types/runtime-mcp/tool-cache.d.ts +8 -0
- package/dist/types/runtime-mcp/transports/http.d.ts +36 -0
- package/dist/types/runtime-mcp/transports/index.d.ts +5 -0
- package/dist/types/runtime-mcp/transports/stdio.d.ts +28 -0
- package/dist/types/runtime-mcp/types.d.ts +333 -0
- package/dist/types/sdk.d.ts +234 -0
- package/dist/types/secrets/index.d.ts +10 -0
- package/dist/types/secrets/obfuscator.d.ts +23 -0
- package/dist/types/secrets/regex.d.ts +2 -0
- package/dist/types/session/agent-session.d.ts +1052 -0
- package/dist/types/session/agent-storage.d.ts +100 -0
- package/dist/types/session/artifacts.d.ts +61 -0
- package/dist/types/session/auth-broker-config.d.ts +13 -0
- package/dist/types/session/auth-storage.d.ts +6 -0
- package/dist/types/session/blob-store.d.ts +112 -0
- package/dist/types/session/client-bridge.d.ts +88 -0
- package/dist/types/session/contribution-prep.d.ts +47 -0
- package/dist/types/session/history-storage.d.ts +16 -0
- package/dist/types/session/messages.d.ts +165 -0
- package/dist/types/session/pabcd-stage-header.d.ts +18 -0
- package/dist/types/session/session-dump-format.d.ts +22 -0
- package/dist/types/session/session-manager.d.ts +571 -0
- package/dist/types/session/session-storage.d.ts +88 -0
- package/dist/types/session/streaming-output.d.ts +196 -0
- package/dist/types/session/tool-choice-queue.d.ts +78 -0
- package/dist/types/session/yield-queue.d.ts +24 -0
- package/dist/types/setup/hermes-setup.d.ts +71 -0
- package/dist/types/setup/model-onboarding-guidance.d.ts +9 -0
- package/dist/types/setup/provider-onboarding.d.ts +52 -0
- package/dist/types/skill-state/active-state.d.ts +115 -0
- package/dist/types/skill-state/initial-phase.d.ts +12 -0
- package/dist/types/skill-state/jaw-interview-mutation-guard.d.ts +33 -0
- package/dist/types/skill-state/workflow-hud.d.ts +76 -0
- package/dist/types/skill-state/workflow-state-contract.d.ts +60 -0
- package/dist/types/skill-state/workflow-state-version.d.ts +3 -0
- package/dist/types/slash-commands/acp-builtins.d.ts +18 -0
- package/dist/types/slash-commands/builtin-registry.d.ts +24 -0
- package/dist/types/slash-commands/helpers/context-report.d.ts +7 -0
- package/dist/types/slash-commands/helpers/format.d.ts +10 -0
- package/dist/types/slash-commands/helpers/mcp.d.ts +3 -0
- package/dist/types/slash-commands/helpers/parse.d.ts +33 -0
- package/dist/types/slash-commands/helpers/ssh.d.ts +3 -0
- package/dist/types/slash-commands/helpers/todo.d.ts +3 -0
- package/dist/types/slash-commands/helpers/usage-report.d.ts +11 -0
- package/dist/types/slash-commands/types.d.ts +120 -0
- package/dist/types/ssh/config-writer.d.ts +49 -0
- package/dist/types/ssh/connection-manager.d.ts +33 -0
- package/dist/types/ssh/ssh-executor.d.ts +37 -0
- package/dist/types/ssh/sshfs-mount.d.ts +6 -0
- package/dist/types/ssh/utils.d.ts +2 -0
- package/dist/types/stt/downloader.d.ts +9 -0
- package/dist/types/stt/index.d.ts +3 -0
- package/dist/types/stt/recorder.d.ts +13 -0
- package/dist/types/stt/setup.d.ts +18 -0
- package/dist/types/stt/stt-controller.d.ts +16 -0
- package/dist/types/stt/transcriber.d.ts +16 -0
- package/dist/types/system-prompt.d.ts +100 -0
- package/dist/types/task/agents.d.ts +28 -0
- package/dist/types/task/commands.d.ts +35 -0
- package/dist/types/task/discovery.d.ts +19 -0
- package/dist/types/task/executor.d.ts +113 -0
- package/dist/types/task/fork-context-advisory.d.ts +13 -0
- package/dist/types/task/id.d.ts +7 -0
- package/dist/types/task/index.d.ts +43 -0
- package/dist/types/task/jwc-command.d.ts +7 -0
- package/dist/types/task/model-presets.d.ts +17 -0
- package/dist/types/task/name-generator.d.ts +16 -0
- package/dist/types/task/output-manager.d.ts +36 -0
- package/dist/types/task/parallel.d.ts +34 -0
- package/dist/types/task/receipt.d.ts +86 -0
- package/dist/types/task/render.d.ts +28 -0
- package/dist/types/task/roi-reconciliation.d.ts +27 -0
- package/dist/types/task/simple-mode.d.ts +8 -0
- package/dist/types/task/spawn-gate.d.ts +38 -0
- package/dist/types/task/subprocess-tool-registry.d.ts +72 -0
- package/dist/types/task/types.d.ts +506 -0
- package/dist/types/task/worktree.d.ts +94 -0
- package/dist/types/thinking.d.ts +31 -0
- package/dist/types/tool-discovery/tool-index.d.ts +113 -0
- package/dist/types/tools/archive-reader.d.ts +40 -0
- package/dist/types/tools/ask.d.ts +152 -0
- package/dist/types/tools/ast-edit.d.ts +77 -0
- package/dist/types/tools/ast-grep.d.ts +69 -0
- package/dist/types/tools/auto-generated-guard.d.ts +17 -0
- package/dist/types/tools/background.d.ts +124 -0
- package/dist/types/tools/bash-allowed-prefixes.d.ts +5 -0
- package/dist/types/tools/bash-command-fixup.d.ts +11 -0
- package/dist/types/tools/bash-interactive.d.ts +16 -0
- package/dist/types/tools/bash-interceptor.d.ts +24 -0
- package/dist/types/tools/bash-pty-selection.d.ts +7 -0
- package/dist/types/tools/bash-skill-urls.d.ts +31 -0
- package/dist/types/tools/bash.d.ts +156 -0
- package/dist/types/tools/browser/actions.d.ts +54 -0
- package/dist/types/tools/browser/attach.d.ts +34 -0
- package/dist/types/tools/browser/launch.d.ts +62 -0
- package/dist/types/tools/browser/readable.d.ts +17 -0
- package/dist/types/tools/browser/registry.d.ts +42 -0
- package/dist/types/tools/browser/render.d.ts +50 -0
- package/dist/types/tools/browser/tab-protocol.d.ts +144 -0
- package/dist/types/tools/browser/tab-supervisor.d.ts +63 -0
- package/dist/types/tools/browser/tab-worker-entry.d.ts +1 -0
- package/dist/types/tools/browser/tab-worker.d.ts +19 -0
- package/dist/types/tools/browser.d.ts +194 -0
- package/dist/types/tools/calculator.d.ts +76 -0
- package/dist/types/tools/checkpoint.d.ts +63 -0
- package/dist/types/tools/computer-use-backend.d.ts +6 -0
- package/dist/types/tools/computer-use.d.ts +100 -0
- package/dist/types/tools/conflict-detect.d.ts +205 -0
- package/dist/types/tools/context.d.ts +19 -0
- package/dist/types/tools/cron.d.ts +116 -0
- package/dist/types/tools/debug.d.ts +209 -0
- package/dist/types/tools/eval.d.ts +108 -0
- package/dist/types/tools/fetch.d.ts +61 -0
- package/dist/types/tools/file-recorder.d.ts +13 -0
- package/dist/types/tools/find.d.ts +95 -0
- package/dist/types/tools/fs-cache-invalidation.d.ts +15 -0
- package/dist/types/tools/gh-format.d.ts +6 -0
- package/dist/types/tools/gh-renderer.d.ts +25 -0
- package/dist/types/tools/gh.d.ts +356 -0
- package/dist/types/tools/github-cache.d.ts +103 -0
- package/dist/types/tools/grouped-file-output.d.ts +36 -0
- package/dist/types/tools/hindsight-recall.d.ts +21 -0
- package/dist/types/tools/hindsight-reflect.d.ts +23 -0
- package/dist/types/tools/hindsight-retain.d.ts +27 -0
- package/dist/types/tools/image-gen.d.ts +79 -0
- package/dist/types/tools/index.d.ts +281 -0
- package/dist/types/tools/inspect-image-renderer.d.ts +26 -0
- package/dist/types/tools/inspect-image.d.ts +31 -0
- package/dist/types/tools/irc.d.ts +79 -0
- package/dist/types/tools/job.d.ts +65 -0
- package/dist/types/tools/json-tree.d.ts +23 -0
- package/dist/types/tools/jtd-to-json-schema.d.ts +29 -0
- package/dist/types/tools/jtd-to-typescript.d.ts +26 -0
- package/dist/types/tools/jtd-utils.d.ts +42 -0
- package/dist/types/tools/list-limit.d.ts +12 -0
- package/dist/types/tools/match-line-format.d.ts +11 -0
- package/dist/types/tools/monitor.d.ts +65 -0
- package/dist/types/tools/output-meta.d.ts +204 -0
- package/dist/types/tools/path-utils.d.ts +147 -0
- package/dist/types/tools/plan-mode-guard.d.ts +18 -0
- package/dist/types/tools/read.d.ts +85 -0
- package/dist/types/tools/recipe/index.d.ts +45 -0
- package/dist/types/tools/recipe/render.d.ts +36 -0
- package/dist/types/tools/recipe/runner.d.ts +60 -0
- package/dist/types/tools/recipe/runners/cargo.d.ts +16 -0
- package/dist/types/tools/recipe/runners/index.d.ts +2 -0
- package/dist/types/tools/recipe/runners/just.d.ts +2 -0
- package/dist/types/tools/recipe/runners/make.d.ts +2 -0
- package/dist/types/tools/recipe/runners/pkg.d.ts +2 -0
- package/dist/types/tools/recipe/runners/task.d.ts +2 -0
- package/dist/types/tools/render-mermaid.d.ts +37 -0
- package/dist/types/tools/render-utils.d.ts +158 -0
- package/dist/types/tools/renderers.d.ts +26 -0
- package/dist/types/tools/resolve.d.ts +90 -0
- package/dist/types/tools/review.d.ts +63 -0
- package/dist/types/tools/search-tool-bm25.d.ts +65 -0
- package/dist/types/tools/search.d.ts +93 -0
- package/dist/types/tools/skill.d.ts +47 -0
- package/dist/types/tools/sqlite-reader.d.ts +93 -0
- package/dist/types/tools/ssh.d.ts +67 -0
- package/dist/types/tools/subagent-render.d.ts +25 -0
- package/dist/types/tools/subagent.d.ts +87 -0
- package/dist/types/tools/telegram-send.d.ts +53 -0
- package/dist/types/tools/todo-write.d.ts +120 -0
- package/dist/types/tools/tool-errors.d.ts +33 -0
- package/dist/types/tools/tool-result.d.ts +30 -0
- package/dist/types/tools/tool-timeouts.d.ts +51 -0
- package/dist/types/tools/vim.d.ts +58 -0
- package/dist/types/tools/write.d.ts +59 -0
- package/dist/types/tools/yield.d.ts +25 -0
- package/dist/types/tui/code-cell.d.ts +32 -0
- package/dist/types/tui/file-list.d.ts +22 -0
- package/dist/types/tui/hyperlink.d.ts +42 -0
- package/dist/types/tui/index.d.ts +11 -0
- package/dist/types/tui/output-block.d.ts +28 -0
- package/dist/types/tui/status-line.d.ts +18 -0
- package/dist/types/tui/tree-list.d.ts +19 -0
- package/dist/types/tui/types.d.ts +13 -0
- package/dist/types/tui/utils.d.ts +36 -0
- package/dist/types/utils/changelog.d.ts +36 -0
- package/dist/types/utils/clipboard.d.ts +22 -0
- package/dist/types/utils/command-args.d.ts +9 -0
- package/dist/types/utils/commit-message-generator.d.ts +7 -0
- package/dist/types/utils/edit-mode.d.ts +13 -0
- package/dist/types/utils/event-bus.d.ts +6 -0
- package/dist/types/utils/external-editor.d.ts +17 -0
- package/dist/types/utils/file-display-mode.d.ts +27 -0
- package/dist/types/utils/file-mentions.d.ts +11 -0
- package/dist/types/utils/git.d.ts +361 -0
- package/dist/types/utils/image-loading.d.ts +26 -0
- package/dist/types/utils/image-resize.d.ts +39 -0
- package/dist/types/utils/lang-from-path.d.ts +8 -0
- package/dist/types/utils/markit.d.ts +7 -0
- package/dist/types/utils/open.d.ts +2 -0
- package/dist/types/utils/session-color.d.ts +10 -0
- package/dist/types/utils/shell-snapshot.d.ts +5 -0
- package/dist/types/utils/sixel.d.ts +21 -0
- package/dist/types/utils/title-generator.d.ts +31 -0
- package/dist/types/utils/tokenizer-download.d.ts +4 -0
- package/dist/types/utils/tokenizer-encoding.d.ts +7 -0
- package/dist/types/utils/tool-choice.d.ts +20 -0
- package/dist/types/utils/tools-manager.d.ts +9 -0
- package/dist/types/vim/buffer.d.ts +41 -0
- package/dist/types/vim/commands.d.ts +6 -0
- package/dist/types/vim/engine.d.ts +47 -0
- package/dist/types/vim/parser.d.ts +3 -0
- package/dist/types/vim/render.d.ts +25 -0
- package/dist/types/vim/types.d.ts +182 -0
- package/dist/types/web/kagi.d.ts +23 -0
- package/dist/types/web/parallel.d.ts +58 -0
- package/dist/types/web/public-fetch-url.d.ts +1 -0
- package/dist/types/web/scrapers/artifacthub.d.ts +6 -0
- package/dist/types/web/scrapers/arxiv.d.ts +5 -0
- package/dist/types/web/scrapers/aur.d.ts +5 -0
- package/dist/types/web/scrapers/biorxiv.d.ts +5 -0
- package/dist/types/web/scrapers/bluesky.d.ts +5 -0
- package/dist/types/web/scrapers/brew.d.ts +5 -0
- package/dist/types/web/scrapers/cheatsh.d.ts +8 -0
- package/dist/types/web/scrapers/chocolatey.d.ts +5 -0
- package/dist/types/web/scrapers/choosealicense.d.ts +2 -0
- package/dist/types/web/scrapers/cisa-kev.d.ts +5 -0
- package/dist/types/web/scrapers/clojars.d.ts +5 -0
- package/dist/types/web/scrapers/coingecko.d.ts +5 -0
- package/dist/types/web/scrapers/crates-io.d.ts +5 -0
- package/dist/types/web/scrapers/crossref.d.ts +2 -0
- package/dist/types/web/scrapers/devto.d.ts +5 -0
- package/dist/types/web/scrapers/discogs.d.ts +8 -0
- package/dist/types/web/scrapers/discourse.d.ts +5 -0
- package/dist/types/web/scrapers/dockerhub.d.ts +5 -0
- package/dist/types/web/scrapers/docs-rs.d.ts +2 -0
- package/dist/types/web/scrapers/fdroid.d.ts +5 -0
- package/dist/types/web/scrapers/firefox-addons.d.ts +2 -0
- package/dist/types/web/scrapers/flathub.d.ts +2 -0
- package/dist/types/web/scrapers/github-gist.d.ts +5 -0
- package/dist/types/web/scrapers/github.d.ts +12 -0
- package/dist/types/web/scrapers/gitlab.d.ts +5 -0
- package/dist/types/web/scrapers/go-pkg.d.ts +5 -0
- package/dist/types/web/scrapers/hackage.d.ts +5 -0
- package/dist/types/web/scrapers/hackernews.d.ts +2 -0
- package/dist/types/web/scrapers/hex.d.ts +5 -0
- package/dist/types/web/scrapers/huggingface.d.ts +2 -0
- package/dist/types/web/scrapers/iacr.d.ts +5 -0
- package/dist/types/web/scrapers/index.d.ts +84 -0
- package/dist/types/web/scrapers/jetbrains-marketplace.d.ts +2 -0
- package/dist/types/web/scrapers/lemmy.d.ts +2 -0
- package/dist/types/web/scrapers/lobsters.d.ts +5 -0
- package/dist/types/web/scrapers/mastodon.d.ts +5 -0
- package/dist/types/web/scrapers/maven.d.ts +6 -0
- package/dist/types/web/scrapers/mdn.d.ts +2 -0
- package/dist/types/web/scrapers/metacpan.d.ts +5 -0
- package/dist/types/web/scrapers/musicbrainz.d.ts +5 -0
- package/dist/types/web/scrapers/npm.d.ts +5 -0
- package/dist/types/web/scrapers/nuget.d.ts +5 -0
- package/dist/types/web/scrapers/nvd.d.ts +5 -0
- package/dist/types/web/scrapers/ollama.d.ts +2 -0
- package/dist/types/web/scrapers/open-vsx.d.ts +5 -0
- package/dist/types/web/scrapers/opencorporates.d.ts +5 -0
- package/dist/types/web/scrapers/openlibrary.d.ts +5 -0
- package/dist/types/web/scrapers/orcid.d.ts +5 -0
- package/dist/types/web/scrapers/osv.d.ts +5 -0
- package/dist/types/web/scrapers/packagist.d.ts +5 -0
- package/dist/types/web/scrapers/pub-dev.d.ts +5 -0
- package/dist/types/web/scrapers/pubmed.d.ts +5 -0
- package/dist/types/web/scrapers/pypi.d.ts +5 -0
- package/dist/types/web/scrapers/rawg.d.ts +2 -0
- package/dist/types/web/scrapers/readthedocs.d.ts +2 -0
- package/dist/types/web/scrapers/reddit.d.ts +5 -0
- package/dist/types/web/scrapers/repology.d.ts +5 -0
- package/dist/types/web/scrapers/rfc.d.ts +5 -0
- package/dist/types/web/scrapers/rubygems.d.ts +5 -0
- package/dist/types/web/scrapers/searchcode.d.ts +2 -0
- package/dist/types/web/scrapers/sec-edgar.d.ts +5 -0
- package/dist/types/web/scrapers/semantic-scholar.d.ts +2 -0
- package/dist/types/web/scrapers/snapcraft.d.ts +2 -0
- package/dist/types/web/scrapers/sourcegraph.d.ts +2 -0
- package/dist/types/web/scrapers/spdx.d.ts +5 -0
- package/dist/types/web/scrapers/spotify.d.ts +8 -0
- package/dist/types/web/scrapers/stackoverflow.d.ts +6 -0
- package/dist/types/web/scrapers/terraform.d.ts +5 -0
- package/dist/types/web/scrapers/tldr.d.ts +7 -0
- package/dist/types/web/scrapers/twitter.d.ts +5 -0
- package/dist/types/web/scrapers/types.d.ts +78 -0
- package/dist/types/web/scrapers/utils.d.ts +26 -0
- package/dist/types/web/scrapers/vimeo.d.ts +5 -0
- package/dist/types/web/scrapers/vscode-marketplace.d.ts +5 -0
- package/dist/types/web/scrapers/w3c.d.ts +2 -0
- package/dist/types/web/scrapers/wikidata.d.ts +5 -0
- package/dist/types/web/scrapers/wikipedia.d.ts +5 -0
- package/dist/types/web/scrapers/youtube.d.ts +5 -0
- package/dist/types/web/search/index.d.ts +95 -0
- package/dist/types/web/search/provider.d.ts +35 -0
- package/dist/types/web/search/providers/anthropic.d.ts +32 -0
- package/dist/types/web/search/providers/base.d.ts +90 -0
- package/dist/types/web/search/providers/brave.d.ts +27 -0
- package/dist/types/web/search/providers/codex.d.ts +35 -0
- package/dist/types/web/search/providers/duckduckgo.d.ts +57 -0
- package/dist/types/web/search/providers/exa.d.ts +52 -0
- package/dist/types/web/search/providers/gemini.d.ts +59 -0
- package/dist/types/web/search/providers/jina.d.ts +26 -0
- package/dist/types/web/search/providers/kagi.d.ts +24 -0
- package/dist/types/web/search/providers/kimi.d.ts +27 -0
- package/dist/types/web/search/providers/parallel.d.ts +15 -0
- package/dist/types/web/search/providers/perplexity.d.ts +38 -0
- package/dist/types/web/search/providers/searxng.d.ts +44 -0
- package/dist/types/web/search/providers/synthetic.d.ts +21 -0
- package/dist/types/web/search/providers/tavily.d.ts +29 -0
- package/dist/types/web/search/providers/utils.d.ts +52 -0
- package/dist/types/web/search/providers/xai.d.ts +62 -0
- package/dist/types/web/search/providers/zai.d.ts +28 -0
- package/dist/types/web/search/render.d.ts +35 -0
- package/dist/types/web/search/types.d.ts +348 -0
- package/dist/types/web/search/utils.d.ts +4 -0
- package/dist/types/workspace-tree.d.ts +42 -0
- package/examples/README.md +21 -0
- package/examples/custom-tools/README.md +104 -0
- package/examples/custom-tools/hello/index.ts +20 -0
- package/examples/extensions/README.md +120 -0
- package/examples/extensions/api-demo.ts +79 -0
- package/examples/extensions/chalk-logger.ts +25 -0
- package/examples/extensions/hello.ts +31 -0
- package/examples/extensions/pirate.ts +43 -0
- package/examples/extensions/plan-mode.ts +549 -0
- package/examples/extensions/reload-runtime.ts +38 -0
- package/examples/extensions/tools.ts +144 -0
- package/examples/extensions/with-deps/index.ts +36 -0
- package/examples/extensions/with-deps/package-lock.json +31 -0
- package/examples/extensions/with-deps/package.json +16 -0
- package/examples/hooks/README.md +56 -0
- package/examples/hooks/auto-commit-on-exit.ts +48 -0
- package/examples/hooks/confirm-destructive.ts +58 -0
- package/examples/hooks/custom-compaction.ts +115 -0
- package/examples/hooks/dirty-repo-guard.ts +51 -0
- package/examples/hooks/file-trigger.ts +40 -0
- package/examples/hooks/git-checkpoint.ts +52 -0
- package/examples/hooks/handoff.ts +149 -0
- package/examples/hooks/permission-gate.ts +33 -0
- package/examples/hooks/protected-paths.ts +29 -0
- package/examples/hooks/qna.ts +118 -0
- package/examples/hooks/status-line.ts +39 -0
- package/examples/sdk/01-minimal.ts +21 -0
- package/examples/sdk/02-custom-model.ts +49 -0
- package/examples/sdk/03-custom-prompt.ts +46 -0
- package/examples/sdk/04-skills.ts +43 -0
- package/examples/sdk/06-extensions.ts +82 -0
- package/examples/sdk/06-hooks.ts +61 -0
- package/examples/sdk/07-context-files.ts +35 -0
- package/examples/sdk/08-prompt-templates.ts +41 -0
- package/examples/sdk/08-slash-commands.ts +46 -0
- package/examples/sdk/09-api-keys-and-oauth.ts +54 -0
- package/examples/sdk/11-sessions.ts +47 -0
- package/examples/sdk/README.md +172 -0
- package/package.json +539 -0
- package/scripts/build-binary.ts +84 -0
- package/scripts/format-prompts.ts +68 -0
- package/scripts/generate-docs-index.ts +71 -0
- package/scripts/generate-template.ts +33 -0
- package/src/async/index.ts +2 -0
- package/src/async/job-manager.ts +1299 -0
- package/src/async/support.ts +6 -0
- package/src/autoresearch/command-resume.md +14 -0
- package/src/autoresearch/dashboard.ts +446 -0
- package/src/autoresearch/git.ts +319 -0
- package/src/autoresearch/helpers.ts +218 -0
- package/src/autoresearch/index.ts +536 -0
- package/src/autoresearch/prompt-setup.md +43 -0
- package/src/autoresearch/prompt.md +103 -0
- package/src/autoresearch/resume-message.md +10 -0
- package/src/autoresearch/state.ts +273 -0
- package/src/autoresearch/storage.ts +699 -0
- package/src/autoresearch/tools/init-experiment.ts +272 -0
- package/src/autoresearch/tools/log-experiment.ts +524 -0
- package/src/autoresearch/tools/run-experiment.ts +475 -0
- package/src/autoresearch/tools/update-notes.ts +109 -0
- package/src/autoresearch/types.ts +168 -0
- package/src/bun-imports.d.ts +28 -0
- package/src/capability/context-file.ts +44 -0
- package/src/capability/extension-module.ts +34 -0
- package/src/capability/extension.ts +47 -0
- package/src/capability/fs.ts +107 -0
- package/src/capability/hook.ts +40 -0
- package/src/capability/index.ts +436 -0
- package/src/capability/instruction.ts +37 -0
- package/src/capability/mcp.ts +74 -0
- package/src/capability/prompt.ts +35 -0
- package/src/capability/rule.ts +244 -0
- package/src/capability/settings.ts +34 -0
- package/src/capability/skill.ts +56 -0
- package/src/capability/slash-command.ts +40 -0
- package/src/capability/ssh.ts +41 -0
- package/src/capability/system-prompt.ts +34 -0
- package/src/capability/tool.ts +38 -0
- package/src/capability/types.ts +168 -0
- package/src/cli/agents-cli.ts +141 -0
- package/src/cli/args.ts +309 -0
- package/src/cli/auth-broker-cli.ts +747 -0
- package/src/cli/auth-gateway-cli.ts +411 -0
- package/src/cli/classify-install-target.ts +50 -0
- package/src/cli/commands/init-xdg.ts +27 -0
- package/src/cli/config-cli.ts +426 -0
- package/src/cli/fast-help.ts +80 -0
- package/src/cli/file-processor.ts +123 -0
- package/src/cli/grep-cli.ts +160 -0
- package/src/cli/initial-message.ts +58 -0
- package/src/cli/list-models.ts +194 -0
- package/src/cli/notify-cli.ts +135 -0
- package/src/cli/plugin-cli.ts +942 -0
- package/src/cli/read-cli.ts +57 -0
- package/src/cli/session-picker.ts +52 -0
- package/src/cli/setup-cli.ts +537 -0
- package/src/cli/shell-cli.ts +176 -0
- package/src/cli/skills-cli.ts +88 -0
- package/src/cli/ssh-cli.ts +179 -0
- package/src/cli/stats-cli.ts +238 -0
- package/src/cli/update-cli.ts +468 -0
- package/src/cli/web-search-cli.ts +133 -0
- package/src/cli/worktree-cli.ts +291 -0
- package/src/cli.ts +150 -0
- package/src/commands/acp.ts +24 -0
- package/src/commands/agents.ts +57 -0
- package/src/commands/auth-broker.ts +96 -0
- package/src/commands/auth-gateway.ts +63 -0
- package/src/commands/chat.ts +25 -0
- package/src/commands/codex-native-hook.ts +12 -0
- package/src/commands/commit.ts +46 -0
- package/src/commands/config.ts +51 -0
- package/src/commands/contribution-prep.ts +41 -0
- package/src/commands/coordinator.ts +71 -0
- package/src/commands/goal.ts +37 -0
- package/src/commands/grep.ts +48 -0
- package/src/commands/harness.ts +1137 -0
- package/src/commands/interview.ts +42 -0
- package/src/commands/launch.ts +178 -0
- package/src/commands/mcp-serve.ts +63 -0
- package/src/commands/memory.ts +34 -0
- package/src/commands/notify.ts +45 -0
- package/src/commands/orchestrate.ts +55 -0
- package/src/commands/planphase.ts +19 -0
- package/src/commands/plugin.ts +78 -0
- package/src/commands/ralplan.ts +25 -0
- package/src/commands/read.ts +35 -0
- package/src/commands/session.ts +151 -0
- package/src/commands/setup.ts +85 -0
- package/src/commands/shell.ts +29 -0
- package/src/commands/skills.ts +49 -0
- package/src/commands/ssh.ts +60 -0
- package/src/commands/state.ts +25 -0
- package/src/commands/stats.ts +29 -0
- package/src/commands/team.ts +217 -0
- package/src/commands/ultragoal.ts +40 -0
- package/src/commands/update.ts +21 -0
- package/src/commands/web-search.ts +42 -0
- package/src/commands/worktree.ts +57 -0
- package/src/commit/agentic/agent.ts +316 -0
- package/src/commit/agentic/fallback.ts +96 -0
- package/src/commit/agentic/index.ts +356 -0
- package/src/commit/agentic/prompts/analyze-file.md +22 -0
- package/src/commit/agentic/prompts/session-user.md +25 -0
- package/src/commit/agentic/prompts/split-confirm.md +1 -0
- package/src/commit/agentic/prompts/system.md +38 -0
- package/src/commit/agentic/state.ts +60 -0
- package/src/commit/agentic/tools/analyze-file.ts +127 -0
- package/src/commit/agentic/tools/git-file-diff.ts +191 -0
- package/src/commit/agentic/tools/git-hunk.ts +50 -0
- package/src/commit/agentic/tools/git-overview.ts +81 -0
- package/src/commit/agentic/tools/index.ts +54 -0
- package/src/commit/agentic/tools/propose-changelog.ts +144 -0
- package/src/commit/agentic/tools/propose-commit.ts +109 -0
- package/src/commit/agentic/tools/recent-commits.ts +81 -0
- package/src/commit/agentic/tools/schemas.ts +23 -0
- package/src/commit/agentic/tools/split-commit.ts +238 -0
- package/src/commit/agentic/topo-sort.ts +44 -0
- package/src/commit/agentic/trivial.ts +51 -0
- package/src/commit/agentic/validation.ts +183 -0
- package/src/commit/analysis/conventional.ts +64 -0
- package/src/commit/analysis/index.ts +4 -0
- package/src/commit/analysis/scope.ts +242 -0
- package/src/commit/analysis/summary.ts +105 -0
- package/src/commit/analysis/validation.ts +66 -0
- package/src/commit/changelog/detect.ts +40 -0
- package/src/commit/changelog/generate.ts +97 -0
- package/src/commit/changelog/index.ts +234 -0
- package/src/commit/changelog/parse.ts +44 -0
- package/src/commit/cli.ts +85 -0
- package/src/commit/git/diff.ts +148 -0
- package/src/commit/index.ts +5 -0
- package/src/commit/map-reduce/index.ts +69 -0
- package/src/commit/map-reduce/map-phase.ts +193 -0
- package/src/commit/map-reduce/reduce-phase.ts +49 -0
- package/src/commit/map-reduce/utils.ts +9 -0
- package/src/commit/message.ts +11 -0
- package/src/commit/model-selection.ts +51 -0
- package/src/commit/pipeline.ts +244 -0
- package/src/commit/prompts/analysis-system.md +148 -0
- package/src/commit/prompts/analysis-user.md +38 -0
- package/src/commit/prompts/changelog-system.md +50 -0
- package/src/commit/prompts/changelog-user.md +18 -0
- package/src/commit/prompts/file-observer-system.md +24 -0
- package/src/commit/prompts/file-observer-user.md +8 -0
- package/src/commit/prompts/reduce-system.md +50 -0
- package/src/commit/prompts/reduce-user.md +17 -0
- package/src/commit/prompts/summary-retry.md +3 -0
- package/src/commit/prompts/summary-system.md +38 -0
- package/src/commit/prompts/summary-user.md +13 -0
- package/src/commit/prompts/types-description.md +2 -0
- package/src/commit/shared-llm.ts +77 -0
- package/src/commit/types.ts +118 -0
- package/src/commit/utils/exclusions.ts +42 -0
- package/src/commit/utils.ts +58 -0
- package/src/config/config-file.ts +232 -0
- package/src/config/file-lock.ts +121 -0
- package/src/config/keybindings.ts +553 -0
- package/src/config/mcp-schema.json +230 -0
- package/src/config/model-equivalence.ts +816 -0
- package/src/config/model-profile-activation.ts +165 -0
- package/src/config/model-profiles.ts +188 -0
- package/src/config/model-registry.ts +2751 -0
- package/src/config/model-resolver.ts +1355 -0
- package/src/config/models-config-schema.ts +254 -0
- package/src/config/oauth-provider-aliases.ts +49 -0
- package/src/config/prompt-templates.ts +310 -0
- package/src/config/resolve-config-value.ts +94 -0
- package/src/config/settings-schema.ts +3235 -0
- package/src/config/settings.ts +979 -0
- package/src/config/skill-settings-defaults.ts +35 -0
- package/src/config.ts +212 -0
- package/src/coordinator/contract.ts +20 -0
- package/src/coordinator-mcp/policy.ts +174 -0
- package/src/coordinator-mcp/safety.ts +80 -0
- package/src/coordinator-mcp/server.ts +1319 -0
- package/src/cursor.ts +372 -0
- package/src/dap/client.ts +689 -0
- package/src/dap/config.ts +150 -0
- package/src/dap/defaults.json +211 -0
- package/src/dap/index.ts +4 -0
- package/src/dap/session.ts +1306 -0
- package/src/dap/types.ts +600 -0
- package/src/debug/crash-diagnostics.ts +223 -0
- package/src/debug/index.ts +459 -0
- package/src/debug/log-formatting.ts +58 -0
- package/src/debug/log-viewer.ts +908 -0
- package/src/debug/profiler.ts +162 -0
- package/src/debug/raw-sse-buffer.ts +270 -0
- package/src/debug/raw-sse.ts +213 -0
- package/src/debug/report-bundle.ts +365 -0
- package/src/debug/runtime-gauges.ts +20 -0
- package/src/debug/system-info.ts +111 -0
- package/src/defaults/jwc/mcp-defaults.json +8 -0
- package/src/defaults/jwc/skill-fragments/browse/web-ai.md +130 -0
- package/src/defaults/jwc/skills/browse/SKILL.md +113 -0
- package/src/defaults/jwc/skills/goal/SKILL.md +323 -0
- package/src/defaults/jwc/skills/goal/ai-slop-cleaner.md +61 -0
- package/src/defaults/jwc/skills/jaw-interview/SKILL.md +891 -0
- package/src/defaults/jwc/skills/jaw-interview/auto-answer-uncertain.md +37 -0
- package/src/defaults/jwc/skills/jaw-interview/auto-research-greenfield.md +42 -0
- package/src/defaults/jwc/skills/plan/SKILL.md +201 -0
- package/src/defaults/jwc/skills/search/SKILL.md +120 -0
- package/src/defaults/jwc/skills/team/SKILL.md +441 -0
- package/src/defaults/jwc-defaults.ts +316 -0
- package/src/discovery/agents-md.ts +67 -0
- package/src/discovery/agents.ts +230 -0
- package/src/discovery/builtin.ts +932 -0
- package/src/discovery/claude-plugins.ts +407 -0
- package/src/discovery/claude.ts +313 -0
- package/src/discovery/cli-jaw.ts +36 -0
- package/src/discovery/cline.ts +83 -0
- package/src/discovery/codex.ts +330 -0
- package/src/discovery/cursor.ts +220 -0
- package/src/discovery/gemini.ts +383 -0
- package/src/discovery/github.ts +118 -0
- package/src/discovery/helpers.ts +1010 -0
- package/src/discovery/index.ts +77 -0
- package/src/discovery/mcp-json.ts +171 -0
- package/src/discovery/opencode.ts +398 -0
- package/src/discovery/plugin-dir-roots.ts +28 -0
- package/src/discovery/ssh.ts +153 -0
- package/src/discovery/substitute-plugin-root.ts +29 -0
- package/src/discovery/vscode.ts +105 -0
- package/src/discovery/windsurf.ts +147 -0
- package/src/edit/apply-patch/index.ts +87 -0
- package/src/edit/apply-patch/parser.ts +174 -0
- package/src/edit/diff.ts +873 -0
- package/src/edit/file-read-cache.ts +95 -0
- package/src/edit/index.ts +528 -0
- package/src/edit/modes/apply-patch.lark +19 -0
- package/src/edit/modes/apply-patch.ts +53 -0
- package/src/edit/modes/patch.ts +1835 -0
- package/src/edit/modes/replace.ts +1161 -0
- package/src/edit/normalize.ts +375 -0
- package/src/edit/notebook.ts +222 -0
- package/src/edit/read-file.ts +25 -0
- package/src/edit/renderer.ts +683 -0
- package/src/edit/streaming.ts +561 -0
- package/src/eval/backend.ts +43 -0
- package/src/eval/index.ts +4 -0
- package/src/eval/js/context-manager.ts +414 -0
- package/src/eval/js/executor.ts +134 -0
- package/src/eval/js/index.ts +46 -0
- package/src/eval/js/shared/helpers.ts +237 -0
- package/src/eval/js/shared/indirect-eval.ts +30 -0
- package/src/eval/js/shared/prelude.ts +2 -0
- package/src/eval/js/shared/prelude.txt +70 -0
- package/src/eval/js/shared/rewrite-imports.ts +415 -0
- package/src/eval/js/shared/runtime.ts +301 -0
- package/src/eval/js/shared/types.ts +18 -0
- package/src/eval/js/tool-bridge.ts +144 -0
- package/src/eval/js/worker-core.ts +146 -0
- package/src/eval/js/worker-entry.ts +24 -0
- package/src/eval/js/worker-protocol.ts +41 -0
- package/src/eval/py/display.ts +71 -0
- package/src/eval/py/executor.ts +622 -0
- package/src/eval/py/index.ts +58 -0
- package/src/eval/py/kernel.ts +683 -0
- package/src/eval/py/prelude.py +462 -0
- package/src/eval/py/prelude.ts +3 -0
- package/src/eval/py/runner.py +910 -0
- package/src/eval/py/runtime.ts +210 -0
- package/src/eval/py/tool-bridge.ts +137 -0
- package/src/eval/types.ts +48 -0
- package/src/exa/factory.ts +60 -0
- package/src/exa/index.ts +27 -0
- package/src/exa/mcp-client.ts +364 -0
- package/src/exa/render.ts +244 -0
- package/src/exa/researcher.ts +36 -0
- package/src/exa/search.ts +47 -0
- package/src/exa/types.ts +166 -0
- package/src/exa/websets.ts +248 -0
- package/src/exec/bash-executor.ts +362 -0
- package/src/exec/exec.ts +53 -0
- package/src/exec/idle-timeout-watchdog.ts +126 -0
- package/src/exec/non-interactive-env.ts +73 -0
- package/src/export/custom-share.ts +65 -0
- package/src/export/html/index.ts +168 -0
- package/src/export/html/template.css +1060 -0
- package/src/export/html/template.generated.ts +2 -0
- package/src/export/html/template.html +47 -0
- package/src/export/html/template.js +2268 -0
- package/src/export/html/template.macro.ts +25 -0
- package/src/export/html/vendor/highlight.min.js +1213 -0
- package/src/export/html/vendor/marked.min.js +6 -0
- package/src/export/ttsr.ts +444 -0
- package/src/extensibility/custom-commands/bundled/ci-green/index.ts +25 -0
- package/src/extensibility/custom-commands/bundled/review/index.ts +456 -0
- package/src/extensibility/custom-commands/index.ts +2 -0
- package/src/extensibility/custom-commands/loader.ts +238 -0
- package/src/extensibility/custom-commands/types.ts +113 -0
- package/src/extensibility/custom-tools/index.ts +7 -0
- package/src/extensibility/custom-tools/loader.ts +245 -0
- package/src/extensibility/custom-tools/types.ts +255 -0
- package/src/extensibility/custom-tools/wrapper.ts +47 -0
- package/src/extensibility/extensions/compact-handler.ts +40 -0
- package/src/extensibility/extensions/get-commands-handler.ts +80 -0
- package/src/extensibility/extensions/index.ts +15 -0
- package/src/extensibility/extensions/loader.ts +555 -0
- package/src/extensibility/extensions/runner.ts +900 -0
- package/src/extensibility/extensions/types.ts +1314 -0
- package/src/extensibility/extensions/wrapper.ts +189 -0
- package/src/extensibility/hooks/index.ts +5 -0
- package/src/extensibility/hooks/loader.ts +257 -0
- package/src/extensibility/hooks/runner.ts +425 -0
- package/src/extensibility/hooks/tool-wrapper.ts +107 -0
- package/src/extensibility/hooks/types.ts +599 -0
- package/src/extensibility/jwc-plugins/activation.ts +87 -0
- package/src/extensibility/jwc-plugins/index.ts +9 -0
- package/src/extensibility/jwc-plugins/injection.ts +114 -0
- package/src/extensibility/jwc-plugins/loader.ts +131 -0
- package/src/extensibility/jwc-plugins/paths.ts +66 -0
- package/src/extensibility/jwc-plugins/schema.ts +79 -0
- package/src/extensibility/jwc-plugins/state.ts +29 -0
- package/src/extensibility/jwc-plugins/tools.ts +47 -0
- package/src/extensibility/jwc-plugins/types.ts +97 -0
- package/src/extensibility/jwc-plugins/validation.ts +76 -0
- package/src/extensibility/plugins/doctor.ts +66 -0
- package/src/extensibility/plugins/git-url.ts +281 -0
- package/src/extensibility/plugins/index.ts +9 -0
- package/src/extensibility/plugins/installer.ts +192 -0
- package/src/extensibility/plugins/legacy-pi-compat.ts +336 -0
- package/src/extensibility/plugins/loader.ts +288 -0
- package/src/extensibility/plugins/manager.ts +739 -0
- package/src/extensibility/plugins/marketplace/cache.ts +136 -0
- package/src/extensibility/plugins/marketplace/fetcher.ts +317 -0
- package/src/extensibility/plugins/marketplace/index.ts +6 -0
- package/src/extensibility/plugins/marketplace/manager.ts +770 -0
- package/src/extensibility/plugins/marketplace/registry.ts +196 -0
- package/src/extensibility/plugins/marketplace/source-resolver.ts +147 -0
- package/src/extensibility/plugins/marketplace/types.ts +191 -0
- package/src/extensibility/plugins/parser.ts +105 -0
- package/src/extensibility/plugins/types.ts +194 -0
- package/src/extensibility/shared-events.ts +344 -0
- package/src/extensibility/skills.ts +449 -0
- package/src/extensibility/slash-commands.ts +249 -0
- package/src/extensibility/tool-proxy.ts +25 -0
- package/src/extensibility/typebox.ts +418 -0
- package/src/extensibility/utils.ts +44 -0
- package/src/goals/goal-planning-start.ts +21 -0
- package/src/goals/index.ts +3 -0
- package/src/goals/runtime.ts +418 -0
- package/src/goals/state.ts +70 -0
- package/src/goals/tools/goal-tool.ts +230 -0
- package/src/harness-control-plane/classifier.ts +128 -0
- package/src/harness-control-plane/control-endpoint.ts +148 -0
- package/src/harness-control-plane/finalize.ts +306 -0
- package/src/harness-control-plane/operate.ts +225 -0
- package/src/harness-control-plane/owner.ts +664 -0
- package/src/harness-control-plane/phase-rollup.ts +96 -0
- package/src/harness-control-plane/preserve.ts +102 -0
- package/src/harness-control-plane/receipt-ingest.ts +127 -0
- package/src/harness-control-plane/receipt-spool.ts +147 -0
- package/src/harness-control-plane/receipts.ts +320 -0
- package/src/harness-control-plane/rpc-adapter.ts +282 -0
- package/src/harness-control-plane/seams.ts +39 -0
- package/src/harness-control-plane/session-lease.ts +388 -0
- package/src/harness-control-plane/state-machine.ts +119 -0
- package/src/harness-control-plane/storage.ts +423 -0
- package/src/harness-control-plane/types.ts +240 -0
- package/src/hashline/anchors.ts +113 -0
- package/src/hashline/apply.ts +737 -0
- package/src/hashline/bigrams.json +649 -0
- package/src/hashline/constants.ts +25 -0
- package/src/hashline/diff-preview.ts +43 -0
- package/src/hashline/diff.ts +56 -0
- package/src/hashline/execute.ts +267 -0
- package/src/hashline/grammar.lark +21 -0
- package/src/hashline/hash.ts +196 -0
- package/src/hashline/index.ts +13 -0
- package/src/hashline/input.ts +130 -0
- package/src/hashline/parser.ts +246 -0
- package/src/hashline/prefixes.ts +101 -0
- package/src/hashline/recovery.ts +113 -0
- package/src/hashline/stream.ts +123 -0
- package/src/hashline/types.ts +68 -0
- package/src/hindsight/backend.ts +205 -0
- package/src/hindsight/bank.ts +131 -0
- package/src/hindsight/client.ts +598 -0
- package/src/hindsight/config.ts +175 -0
- package/src/hindsight/content.ts +211 -0
- package/src/hindsight/index.ts +8 -0
- package/src/hindsight/mental-models.ts +382 -0
- package/src/hindsight/seeds.json +32 -0
- package/src/hindsight/state.ts +469 -0
- package/src/hindsight/transcript.ts +71 -0
- package/src/hooks/codex-native-hooks-config.ts +143 -0
- package/src/hooks/native-skill-hook.ts +305 -0
- package/src/hooks/skill-keywords.ts +95 -0
- package/src/hooks/skill-state.ts +654 -0
- package/src/index.ts +56 -0
- package/src/internal-urls/agent-protocol.ts +176 -0
- package/src/internal-urls/artifact-protocol.ts +75 -0
- package/src/internal-urls/docs-index.generated.ts +92 -0
- package/src/internal-urls/index.ts +21 -0
- package/src/internal-urls/issue-pr-protocol.ts +577 -0
- package/src/internal-urls/json-query.ts +126 -0
- package/src/internal-urls/jwc-protocol.ts +91 -0
- package/src/internal-urls/local-protocol.ts +249 -0
- package/src/internal-urls/mcp-protocol.ts +151 -0
- package/src/internal-urls/memory-protocol.ts +165 -0
- package/src/internal-urls/parse.ts +72 -0
- package/src/internal-urls/registry-helpers.ts +28 -0
- package/src/internal-urls/router.ts +79 -0
- package/src/internal-urls/rule-protocol.ts +38 -0
- package/src/internal-urls/skill-protocol.ts +103 -0
- package/src/internal-urls/types.ts +114 -0
- package/src/jaw-interview/structured-renderer.ts +83 -0
- package/src/jwc-runtime/actor-registry.ts +365 -0
- package/src/jwc-runtime/agent-identity.ts +16 -0
- package/src/jwc-runtime/cli-jaw-home.ts +14 -0
- package/src/jwc-runtime/cli-jaw-vocab.ts +69 -0
- package/src/jwc-runtime/cli-write-receipt.ts +31 -0
- package/src/jwc-runtime/goal-cli.ts +428 -0
- package/src/jwc-runtime/goal-engine.ts +2214 -0
- package/src/jwc-runtime/goal-guard.ts +300 -0
- package/src/jwc-runtime/goal-mode-request.ts +331 -0
- package/src/jwc-runtime/jaw-interview-runtime.ts +809 -0
- package/src/jwc-runtime/launch-tmux.ts +296 -0
- package/src/jwc-runtime/launch-worktree.ts +291 -0
- package/src/jwc-runtime/legacy-storage.ts +132 -0
- package/src/jwc-runtime/memory-runtime.ts +434 -0
- package/src/jwc-runtime/orchestrate-runtime.ts +612 -0
- package/src/jwc-runtime/orchestrate-state.ts +395 -0
- package/src/jwc-runtime/plan-writer.ts +661 -0
- package/src/jwc-runtime/restricted-role-agent-bash.ts +5 -0
- package/src/jwc-runtime/session-state-sidecar.ts +89 -0
- package/src/jwc-runtime/stage-skill-map.ts +48 -0
- package/src/jwc-runtime/state-graph.ts +86 -0
- package/src/jwc-runtime/state-migrations.ts +183 -0
- package/src/jwc-runtime/state-renderer.ts +340 -0
- package/src/jwc-runtime/state-runtime.ts +1978 -0
- package/src/jwc-runtime/state-schema.ts +218 -0
- package/src/jwc-runtime/state-validation.ts +50 -0
- package/src/jwc-runtime/state-writer.ts +765 -0
- package/src/jwc-runtime/team-runtime.ts +4181 -0
- package/src/jwc-runtime/tmux-common.ts +130 -0
- package/src/jwc-runtime/tmux-sessions.ts +169 -0
- package/src/jwc-runtime/workflow-command-ref.ts +240 -0
- package/src/jwc-runtime/workflow-manifest.generated.json +1606 -0
- package/src/jwc-runtime/workflow-manifest.ts +427 -0
- package/src/lsp/client.ts +974 -0
- package/src/lsp/clients/biome-client.ts +202 -0
- package/src/lsp/clients/index.ts +50 -0
- package/src/lsp/clients/lsp-linter-client.ts +93 -0
- package/src/lsp/clients/swiftlint-client.ts +120 -0
- package/src/lsp/config.ts +492 -0
- package/src/lsp/defaults.json +493 -0
- package/src/lsp/edits.ts +166 -0
- package/src/lsp/index.ts +2282 -0
- package/src/lsp/lspmux.ts +233 -0
- package/src/lsp/render.ts +692 -0
- package/src/lsp/startup-events.ts +13 -0
- package/src/lsp/types.ts +443 -0
- package/src/lsp/utils.ts +678 -0
- package/src/main.ts +1159 -0
- package/src/mem0/backend.ts +75 -0
- package/src/mem0/client.ts +122 -0
- package/src/mem0/config.ts +82 -0
- package/src/mem0/index.ts +5 -0
- package/src/mem0/scope.ts +54 -0
- package/src/mem0/state.ts +142 -0
- package/src/memories/index.ts +1111 -0
- package/src/memories/local-query.ts +699 -0
- package/src/memories/memory-config.ts +175 -0
- package/src/memories/memory-fts.ts +179 -0
- package/src/memories/memory-model-resolution.ts +84 -0
- package/src/memories/memory-quality.ts +163 -0
- package/src/memories/storage.ts +588 -0
- package/src/memory-backend/index.ts +4 -0
- package/src/memory-backend/local-backend.ts +50 -0
- package/src/memory-backend/off-backend.ts +16 -0
- package/src/memory-backend/resolve.ts +27 -0
- package/src/memory-backend/types.ts +82 -0
- package/src/migrate-config-dir-startup.ts +15 -0
- package/src/migrate-config-dir.ts +80 -0
- package/src/modes/acp/acp-agent.ts +2218 -0
- package/src/modes/acp/acp-client-bridge.ts +154 -0
- package/src/modes/acp/acp-event-mapper.ts +912 -0
- package/src/modes/acp/acp-mode.ts +23 -0
- package/src/modes/acp/index.ts +2 -0
- package/src/modes/acp/terminal-auth.ts +37 -0
- package/src/modes/background-row-model.ts +17 -0
- package/src/modes/bridge/auth.ts +41 -0
- package/src/modes/bridge/bridge-client-bridge.ts +47 -0
- package/src/modes/bridge/bridge-mode.ts +644 -0
- package/src/modes/bridge/bridge-ui-context.ts +200 -0
- package/src/modes/bridge/event-stream.ts +70 -0
- package/src/modes/components/_cli-jaw-entry.ts +36 -0
- package/src/modes/components/agent-dashboard.ts +1120 -0
- package/src/modes/components/assistant-message.ts +361 -0
- package/src/modes/components/background-footer-detail.ts +27 -0
- package/src/modes/components/background-footer-panel-model.ts +96 -0
- package/src/modes/components/background-footer-panel.ts +89 -0
- package/src/modes/components/bash-execution.ts +261 -0
- package/src/modes/components/bordered-loader.ts +41 -0
- package/src/modes/components/branch-summary-message.ts +65 -0
- package/src/modes/components/btw-panel.ts +104 -0
- package/src/modes/components/compaction-summary-message.ts +71 -0
- package/src/modes/components/composer-chrome.ts +42 -0
- package/src/modes/components/composer-footer.ts +113 -0
- package/src/modes/components/countdown-timer.ts +75 -0
- package/src/modes/components/custom-editor.ts +515 -0
- package/src/modes/components/custom-message.ts +85 -0
- package/src/modes/components/custom-provider-wizard.ts +318 -0
- package/src/modes/components/diff.ts +363 -0
- package/src/modes/components/dynamic-border.ts +25 -0
- package/src/modes/components/eval-execution.ts +196 -0
- package/src/modes/components/execution-shared.ts +112 -0
- package/src/modes/components/extensions/extension-dashboard.ts +350 -0
- package/src/modes/components/extensions/extension-list.ts +492 -0
- package/src/modes/components/extensions/index.ts +9 -0
- package/src/modes/components/extensions/inspector-panel.ts +317 -0
- package/src/modes/components/extensions/state-manager.ts +628 -0
- package/src/modes/components/extensions/types.ts +191 -0
- package/src/modes/components/footer.ts +270 -0
- package/src/modes/components/full-transcript-overlay.ts +133 -0
- package/src/modes/components/help-selector.ts +274 -0
- package/src/modes/components/history-search.ts +158 -0
- package/src/modes/components/hook-editor.ts +151 -0
- package/src/modes/components/hook-input.ts +79 -0
- package/src/modes/components/hook-message.ts +68 -0
- package/src/modes/components/hook-selector.ts +873 -0
- package/src/modes/components/index.ts +36 -0
- package/src/modes/components/jobs-overlay-model.ts +109 -0
- package/src/modes/components/jobs-overlay.ts +172 -0
- package/src/modes/components/keybinding-hints.ts +65 -0
- package/src/modes/components/login-dialog.ts +164 -0
- package/src/modes/components/message-frame.ts +88 -0
- package/src/modes/components/model-selector.ts +1653 -0
- package/src/modes/components/oauth-selector.ts +248 -0
- package/src/modes/components/pabcd-border.ts +98 -0
- package/src/modes/components/plugin-selector.ts +95 -0
- package/src/modes/components/plugin-settings.ts +489 -0
- package/src/modes/components/provider-onboarding-selector.ts +94 -0
- package/src/modes/components/queue-mode-selector.ts +56 -0
- package/src/modes/components/quota-panel.ts +101 -0
- package/src/modes/components/read-tool-group.ts +295 -0
- package/src/modes/components/runtime-mcp-add-wizard.ts +1341 -0
- package/src/modes/components/session-observer-overlay.ts +839 -0
- package/src/modes/components/session-selector.ts +343 -0
- package/src/modes/components/settings-defs.ts +175 -0
- package/src/modes/components/settings-selector.ts +644 -0
- package/src/modes/components/show-images-selector.ts +45 -0
- package/src/modes/components/skill-hud/render.ts +93 -0
- package/src/modes/components/skill-message.ts +110 -0
- package/src/modes/components/status-line/context-thresholds.ts +68 -0
- package/src/modes/components/status-line/git-utils.ts +42 -0
- package/src/modes/components/status-line/index.ts +4 -0
- package/src/modes/components/status-line/presets.ts +107 -0
- package/src/modes/components/status-line/segments.ts +657 -0
- package/src/modes/components/status-line/separators.ts +55 -0
- package/src/modes/components/status-line/token-rate.ts +66 -0
- package/src/modes/components/status-line/types.ts +102 -0
- package/src/modes/components/status-line/workflow-readers.ts +97 -0
- package/src/modes/components/status-line.ts +917 -0
- package/src/modes/components/theme-selector.ts +63 -0
- package/src/modes/components/thinking-selector.ts +52 -0
- package/src/modes/components/todo-reminder.ts +40 -0
- package/src/modes/components/tool-execution.ts +990 -0
- package/src/modes/components/tool-transcript-overlay.ts +81 -0
- package/src/modes/components/tree-selector.ts +930 -0
- package/src/modes/components/ttsr-notification.ts +100 -0
- package/src/modes/components/user-message-selector.ts +141 -0
- package/src/modes/components/user-message.ts +53 -0
- package/src/modes/components/visual-truncate.ts +63 -0
- package/src/modes/components/welcome.ts +522 -0
- package/src/modes/controllers/btw-controller.ts +105 -0
- package/src/modes/controllers/command-controller-shared.ts +108 -0
- package/src/modes/controllers/command-controller.ts +1703 -0
- package/src/modes/controllers/event-controller.ts +1054 -0
- package/src/modes/controllers/extension-ui-controller.ts +1010 -0
- package/src/modes/controllers/input-controller.ts +1422 -0
- package/src/modes/controllers/runtime-mcp-command-controller.ts +1934 -0
- package/src/modes/controllers/selector-controller.ts +1605 -0
- package/src/modes/controllers/ssh-command-controller.ts +384 -0
- package/src/modes/controllers/todo-command-controller.ts +485 -0
- package/src/modes/data/emojis.json +1 -0
- package/src/modes/emoji-autocomplete.ts +285 -0
- package/src/modes/index.ts +35 -0
- package/src/modes/interactive-mode.ts +2938 -0
- package/src/modes/jobs-observer.ts +352 -0
- package/src/modes/oauth-manual-input.ts +42 -0
- package/src/modes/print-mode.ts +121 -0
- package/src/modes/prompt-action-autocomplete.ts +409 -0
- package/src/modes/rpc/host-tools.ts +1 -0
- package/src/modes/rpc/host-uris.ts +1 -0
- package/src/modes/rpc/rpc-client.ts +914 -0
- package/src/modes/rpc/rpc-mode.ts +784 -0
- package/src/modes/rpc/rpc-types.ts +601 -0
- package/src/modes/runtime-init.ts +116 -0
- package/src/modes/session-observer-registry.ts +146 -0
- package/src/modes/shared/agent-wire/approval-gate.ts +151 -0
- package/src/modes/shared/agent-wire/command-contract.ts +18 -0
- package/src/modes/shared/agent-wire/command-dispatch.ts +438 -0
- package/src/modes/shared/agent-wire/command-validation.ts +164 -0
- package/src/modes/shared/agent-wire/event-contract.ts +148 -0
- package/src/modes/shared/agent-wire/event-envelope.ts +141 -0
- package/src/modes/shared/agent-wire/event-observation.ts +424 -0
- package/src/modes/shared/agent-wire/handshake.ts +157 -0
- package/src/modes/shared/agent-wire/host-tool-bridge.ts +194 -0
- package/src/modes/shared/agent-wire/host-uri-bridge.ts +236 -0
- package/src/modes/shared/agent-wire/jaw-interview-gate.ts +253 -0
- package/src/modes/shared/agent-wire/protocol.ts +46 -0
- package/src/modes/shared/agent-wire/responses.ts +17 -0
- package/src/modes/shared/agent-wire/scopes.ts +91 -0
- package/src/modes/shared/agent-wire/session-registry.ts +109 -0
- package/src/modes/shared/agent-wire/ui-request-broker.ts +150 -0
- package/src/modes/shared/agent-wire/ui-result.ts +48 -0
- package/src/modes/shared/agent-wire/unattended-action-policy.ts +341 -0
- package/src/modes/shared/agent-wire/unattended-audit.ts +175 -0
- package/src/modes/shared/agent-wire/unattended-run-controller.ts +406 -0
- package/src/modes/shared/agent-wire/unattended-session.ts +180 -0
- package/src/modes/shared/agent-wire/workflow-gate-broker.ts +324 -0
- package/src/modes/shared/agent-wire/workflow-gate-schema.ts +331 -0
- package/src/modes/shared.ts +55 -0
- package/src/modes/theme/defaults/abyss-bite-light.json +124 -0
- package/src/modes/theme/defaults/abyss-bite.json +124 -0
- package/src/modes/theme/defaults/blue-crab.json +126 -0
- package/src/modes/theme/defaults/index.ts +11 -0
- package/src/modes/theme/defaults/red-claw.json +123 -0
- package/src/modes/theme/mermaid-cache.ts +29 -0
- package/src/modes/theme/shimmer.ts +219 -0
- package/src/modes/theme/theme-schema.json +429 -0
- package/src/modes/theme/theme.ts +2472 -0
- package/src/modes/types.ts +343 -0
- package/src/modes/utils/abort-message.ts +41 -0
- package/src/modes/utils/compaction-progress.ts +174 -0
- package/src/modes/utils/context-usage.ts +398 -0
- package/src/modes/utils/help-markdown.ts +50 -0
- package/src/modes/utils/hotkeys-markdown.ts +61 -0
- package/src/modes/utils/keybinding-matchers.ts +30 -0
- package/src/modes/utils/session-transcript-replay.ts +520 -0
- package/src/modes/utils/tools-markdown.ts +27 -0
- package/src/modes/utils/ui-helpers.ts +846 -0
- package/src/notifications/ask-bridge.ts +74 -0
- package/src/notifications/config-command-parser.ts +76 -0
- package/src/notifications/config.ts +102 -0
- package/src/notifications/daemon-control.ts +73 -0
- package/src/notifications/daemon-engine.ts +165 -0
- package/src/notifications/daemon-inbound.ts +220 -0
- package/src/notifications/daemon-loop.ts +60 -0
- package/src/notifications/daemon-owner.ts +53 -0
- package/src/notifications/daemon-runtime.ts +84 -0
- package/src/notifications/discovery.ts +119 -0
- package/src/notifications/index.ts +34 -0
- package/src/notifications/lifecycle-audit.ts +94 -0
- package/src/notifications/lifecycle-command-parser.ts +51 -0
- package/src/notifications/lifecycle-control-runtime.ts +127 -0
- package/src/notifications/notification-redaction.ts +57 -0
- package/src/notifications/protocol.ts +61 -0
- package/src/notifications/remote-answer.ts +241 -0
- package/src/notifications/reply-bridge.ts +85 -0
- package/src/notifications/server.ts +280 -0
- package/src/notifications/session-lifecycle.ts +46 -0
- package/src/notifications/session-registry.ts +164 -0
- package/src/notifications/telegram-api.ts +259 -0
- package/src/notifications/telegram-ask-keyboard.ts +137 -0
- package/src/notifications/telegram-callback-ingest.ts +126 -0
- package/src/notifications/telegram-inbound-router.ts +166 -0
- package/src/notifications/telegram-media-policy.ts +50 -0
- package/src/notifications/telegram-media-render.ts +40 -0
- package/src/notifications/telegram-message-ingest.ts +121 -0
- package/src/notifications/telegram-pairing.ts +69 -0
- package/src/notifications/threaded-lifecycle.ts +27 -0
- package/src/notifications/threaded-shutdown.ts +37 -0
- package/src/notifications/threaded-surface.ts +187 -0
- package/src/notifications/transport-shell.ts +152 -0
- package/src/notifications/transport-state.ts +161 -0
- package/src/notifications/workspace-path-confinement.ts +65 -0
- package/src/plan-mode/approved-plan.ts +163 -0
- package/src/plan-mode/state.ts +6 -0
- package/src/prompts/agents/architect.md +95 -0
- package/src/prompts/agents/critic.md +68 -0
- package/src/prompts/agents/executor.md +64 -0
- package/src/prompts/agents/explore.md +58 -0
- package/src/prompts/agents/frontmatter.md +14 -0
- package/src/prompts/agents/init.md +34 -0
- package/src/prompts/agents/plan.md +49 -0
- package/src/prompts/agents/planner.md +63 -0
- package/src/prompts/agents/reviewer.md +141 -0
- package/src/prompts/agents/task.md +16 -0
- package/src/prompts/ci-green-request.md +36 -0
- package/src/prompts/goals/goal-continuation.md +33 -0
- package/src/prompts/goals/goal-mode-active.md +23 -0
- package/src/prompts/jaw/orchestrate-a.md +20 -0
- package/src/prompts/jaw/orchestrate-audit-architect.md +17 -0
- package/src/prompts/jaw/orchestrate-audit-planner.md +17 -0
- package/src/prompts/jaw/orchestrate-b.md +17 -0
- package/src/prompts/jaw/orchestrate-c.md +18 -0
- package/src/prompts/jaw/orchestrate-d.md +32 -0
- package/src/prompts/jaw/orchestrate-i.md +17 -0
- package/src/prompts/jaw/orchestrate-p.md +23 -0
- package/src/prompts/memories/consolidation.md +30 -0
- package/src/prompts/memories/read-path.md +10 -0
- package/src/prompts/memories/stage_one_input.md +6 -0
- package/src/prompts/memories/stage_one_system.md +21 -0
- package/src/prompts/memories/unavailable.md +9 -0
- package/src/prompts/review-request.md +70 -0
- package/src/prompts/system/agent-creation-architect.md +75 -0
- package/src/prompts/system/agent-creation-user.md +6 -0
- package/src/prompts/system/auto-continue.md +1 -0
- package/src/prompts/system/btw-user.md +8 -0
- package/src/prompts/system/commit-message-system.md +2 -0
- package/src/prompts/system/custom-system-prompt.md +64 -0
- package/src/prompts/system/eager-todo.md +13 -0
- package/src/prompts/system/executor-self-fork.md +3 -0
- package/src/prompts/system/irc-incoming.md +8 -0
- package/src/prompts/system/plan-mode-active.md +116 -0
- package/src/prompts/system/plan-mode-approved.md +28 -0
- package/src/prompts/system/plan-mode-compact-instructions.md +16 -0
- package/src/prompts/system/plan-mode-reference.md +14 -0
- package/src/prompts/system/plan-mode-subagent.md +34 -0
- package/src/prompts/system/plan-mode-tool-decision-reminder.md +9 -0
- package/src/prompts/system/project-prompt.md +46 -0
- package/src/prompts/system/subagent-system-prompt.md +89 -0
- package/src/prompts/system/subagent-user-prompt.md +3 -0
- package/src/prompts/system/subagent-yield-reminder.md +12 -0
- package/src/prompts/system/system-prompt.md +409 -0
- package/src/prompts/system/title-system.md +2 -0
- package/src/prompts/system/ttsr-interrupt.md +7 -0
- package/src/prompts/system/ttsr-tool-reminder.md +5 -0
- package/src/prompts/system/web-search.md +25 -0
- package/src/prompts/tools/apply-patch.md +65 -0
- package/src/prompts/tools/ask.md +29 -0
- package/src/prompts/tools/ast-edit.md +39 -0
- package/src/prompts/tools/ast-grep.md +42 -0
- package/src/prompts/tools/async-result.md +8 -0
- package/src/prompts/tools/background.md +19 -0
- package/src/prompts/tools/bash.md +50 -0
- package/src/prompts/tools/browser.md +14 -0
- package/src/prompts/tools/calculator.md +10 -0
- package/src/prompts/tools/checkpoint.md +16 -0
- package/src/prompts/tools/computer-use.md +15 -0
- package/src/prompts/tools/cron.md +25 -0
- package/src/prompts/tools/debug.md +33 -0
- package/src/prompts/tools/eval.md +75 -0
- package/src/prompts/tools/find.md +34 -0
- package/src/prompts/tools/github.md +20 -0
- package/src/prompts/tools/goal.md +20 -0
- package/src/prompts/tools/hashline.md +130 -0
- package/src/prompts/tools/image-gen.md +7 -0
- package/src/prompts/tools/inspect-image-system.md +20 -0
- package/src/prompts/tools/inspect-image.md +32 -0
- package/src/prompts/tools/irc.md +49 -0
- package/src/prompts/tools/job.md +22 -0
- package/src/prompts/tools/lsp.md +42 -0
- package/src/prompts/tools/monitor.md +32 -0
- package/src/prompts/tools/patch.md +70 -0
- package/src/prompts/tools/read.md +82 -0
- package/src/prompts/tools/recall.md +6 -0
- package/src/prompts/tools/recipe.md +16 -0
- package/src/prompts/tools/reflect.md +6 -0
- package/src/prompts/tools/render-mermaid.md +9 -0
- package/src/prompts/tools/replace.md +36 -0
- package/src/prompts/tools/resolve.md +9 -0
- package/src/prompts/tools/retain.md +7 -0
- package/src/prompts/tools/rewind.md +13 -0
- package/src/prompts/tools/search-tool-bm25.md +37 -0
- package/src/prompts/tools/search.md +25 -0
- package/src/prompts/tools/skill.md +28 -0
- package/src/prompts/tools/ssh.md +35 -0
- package/src/prompts/tools/subagent.md +56 -0
- package/src/prompts/tools/task-summary.md +22 -0
- package/src/prompts/tools/task.md +106 -0
- package/src/prompts/tools/todo-write.md +50 -0
- package/src/prompts/tools/vim.md +98 -0
- package/src/prompts/tools/web-search.md +10 -0
- package/src/prompts/tools/write.md +14 -0
- package/src/registry/agent-registry.ts +140 -0
- package/src/reminders/star-reminder.ts +422 -0
- package/src/runtime-mcp/client.ts +485 -0
- package/src/runtime-mcp/config-writer.ts +225 -0
- package/src/runtime-mcp/config.ts +365 -0
- package/src/runtime-mcp/discoverable-tool-metadata.ts +25 -0
- package/src/runtime-mcp/index.ts +29 -0
- package/src/runtime-mcp/json-rpc.ts +84 -0
- package/src/runtime-mcp/loader.ts +124 -0
- package/src/runtime-mcp/manager.ts +1211 -0
- package/src/runtime-mcp/oauth-discovery.ts +349 -0
- package/src/runtime-mcp/oauth-flow.ts +409 -0
- package/src/runtime-mcp/render.ts +123 -0
- package/src/runtime-mcp/smithery-auth.ts +104 -0
- package/src/runtime-mcp/smithery-connect.ts +145 -0
- package/src/runtime-mcp/smithery-registry.ts +477 -0
- package/src/runtime-mcp/tool-bridge.ts +416 -0
- package/src/runtime-mcp/tool-cache.ts +117 -0
- package/src/runtime-mcp/transports/http.ts +503 -0
- package/src/runtime-mcp/transports/index.ts +6 -0
- package/src/runtime-mcp/transports/stdio.ts +326 -0
- package/src/runtime-mcp/types.ts +423 -0
- package/src/sdk.ts +2248 -0
- package/src/secrets/index.ts +120 -0
- package/src/secrets/obfuscator.ts +352 -0
- package/src/secrets/regex.ts +21 -0
- package/src/session/agent-session.ts +10343 -0
- package/src/session/agent-storage.ts +466 -0
- package/src/session/artifacts.ts +135 -0
- package/src/session/auth-broker-config.ts +102 -0
- package/src/session/auth-storage.ts +23 -0
- package/src/session/blob-store.ts +372 -0
- package/src/session/client-bridge.ts +85 -0
- package/src/session/contribution-prep.ts +320 -0
- package/src/session/history-storage.ts +311 -0
- package/src/session/messages.ts +406 -0
- package/src/session/pabcd-stage-header.ts +77 -0
- package/src/session/session-dump-format.ts +209 -0
- package/src/session/session-manager.ts +3914 -0
- package/src/session/session-storage.ts +415 -0
- package/src/session/streaming-output.ts +1114 -0
- package/src/session/tool-choice-queue.ts +213 -0
- package/src/session/yield-queue.ts +155 -0
- package/src/setup/hermes/templates/operator-instructions.v1.md +29 -0
- package/src/setup/hermes-setup.ts +429 -0
- package/src/setup/model-onboarding-guidance.ts +41 -0
- package/src/setup/provider-onboarding.ts +358 -0
- package/src/skill-state/active-state.ts +788 -0
- package/src/skill-state/initial-phase.ts +21 -0
- package/src/skill-state/jaw-interview-mutation-guard.ts +490 -0
- package/src/skill-state/workflow-hud.ts +208 -0
- package/src/skill-state/workflow-state-contract.ts +167 -0
- package/src/skill-state/workflow-state-version.ts +3 -0
- package/src/slash-commands/acp-builtins.ts +55 -0
- package/src/slash-commands/builtin-registry.ts +1879 -0
- package/src/slash-commands/helpers/context-report.ts +149 -0
- package/src/slash-commands/helpers/format.ts +46 -0
- package/src/slash-commands/helpers/mcp.ts +532 -0
- package/src/slash-commands/helpers/parse.ts +85 -0
- package/src/slash-commands/helpers/ssh.ts +195 -0
- package/src/slash-commands/helpers/todo.ts +279 -0
- package/src/slash-commands/helpers/usage-report.ts +105 -0
- package/src/slash-commands/types.ts +127 -0
- package/src/ssh/config-writer.ts +183 -0
- package/src/ssh/connection-manager.ts +482 -0
- package/src/ssh/ssh-executor.ts +133 -0
- package/src/ssh/sshfs-mount.ts +140 -0
- package/src/ssh/utils.ts +8 -0
- package/src/stt/downloader.ts +71 -0
- package/src/stt/index.ts +3 -0
- package/src/stt/recorder.ts +351 -0
- package/src/stt/setup.ts +52 -0
- package/src/stt/stt-controller.ts +160 -0
- package/src/stt/transcribe.py +70 -0
- package/src/stt/transcriber.ts +91 -0
- package/src/system-prompt.ts +661 -0
- package/src/task/agents.ts +189 -0
- package/src/task/commands.ts +131 -0
- package/src/task/discovery.ts +136 -0
- package/src/task/executor.ts +1664 -0
- package/src/task/fork-context-advisory.ts +99 -0
- package/src/task/id.ts +33 -0
- package/src/task/index.ts +2173 -0
- package/src/task/jwc-command.ts +26 -0
- package/src/task/model-presets.ts +53 -0
- package/src/task/name-generator.ts +1577 -0
- package/src/task/output-manager.ts +108 -0
- package/src/task/parallel.ts +116 -0
- package/src/task/receipt.ts +304 -0
- package/src/task/render.ts +1075 -0
- package/src/task/roi-reconciliation.ts +90 -0
- package/src/task/simple-mode.ts +27 -0
- package/src/task/spawn-gate.ts +132 -0
- package/src/task/subprocess-tool-registry.ts +88 -0
- package/src/task/types.ts +433 -0
- package/src/task/worktree.ts +506 -0
- package/src/thinking.ts +93 -0
- package/src/tool-discovery/tool-index.ts +408 -0
- package/src/tools/archive-reader.ts +321 -0
- package/src/tools/ask.ts +1011 -0
- package/src/tools/ast-edit.ts +555 -0
- package/src/tools/ast-grep.ts +424 -0
- package/src/tools/auto-generated-guard.ts +305 -0
- package/src/tools/background.ts +500 -0
- package/src/tools/bash-allowed-prefixes.ts +169 -0
- package/src/tools/bash-command-fixup.ts +37 -0
- package/src/tools/bash-interactive.ts +388 -0
- package/src/tools/bash-interceptor.ts +67 -0
- package/src/tools/bash-pty-selection.ts +15 -0
- package/src/tools/bash-skill-urls.ts +248 -0
- package/src/tools/bash.ts +1242 -0
- package/src/tools/browser/actions.ts +189 -0
- package/src/tools/browser/attach.ts +175 -0
- package/src/tools/browser/launch.ts +651 -0
- package/src/tools/browser/readable.ts +95 -0
- package/src/tools/browser/registry.ts +194 -0
- package/src/tools/browser/render.ts +212 -0
- package/src/tools/browser/tab-protocol.ts +105 -0
- package/src/tools/browser/tab-supervisor.ts +577 -0
- package/src/tools/browser/tab-worker-entry.ts +21 -0
- package/src/tools/browser/tab-worker.ts +1054 -0
- package/src/tools/browser.ts +380 -0
- package/src/tools/calculator.ts +540 -0
- package/src/tools/checkpoint.ts +134 -0
- package/src/tools/computer-use-backend.ts +75 -0
- package/src/tools/computer-use.ts +228 -0
- package/src/tools/conflict-detect.ts +672 -0
- package/src/tools/context.ts +39 -0
- package/src/tools/cron.ts +713 -0
- package/src/tools/debug.ts +1014 -0
- package/src/tools/eval.ts +1101 -0
- package/src/tools/fetch.ts +1485 -0
- package/src/tools/file-recorder.ts +35 -0
- package/src/tools/find.ts +543 -0
- package/src/tools/fs-cache-invalidation.ts +28 -0
- package/src/tools/gh-format.ts +12 -0
- package/src/tools/gh-renderer.ts +428 -0
- package/src/tools/gh.ts +3737 -0
- package/src/tools/github-cache.ts +548 -0
- package/src/tools/grouped-file-output.ts +96 -0
- package/src/tools/hindsight-recall.ts +66 -0
- package/src/tools/hindsight-reflect.ts +55 -0
- package/src/tools/hindsight-retain.ts +54 -0
- package/src/tools/image-gen.ts +1284 -0
- package/src/tools/index.ts +580 -0
- package/src/tools/inspect-image-renderer.ts +103 -0
- package/src/tools/inspect-image.ts +167 -0
- package/src/tools/irc.ts +239 -0
- package/src/tools/job.ts +530 -0
- package/src/tools/json-tree.ts +243 -0
- package/src/tools/jtd-to-json-schema.ts +219 -0
- package/src/tools/jtd-to-typescript.ts +136 -0
- package/src/tools/jtd-utils.ts +102 -0
- package/src/tools/list-limit.ts +40 -0
- package/src/tools/match-line-format.ts +22 -0
- package/src/tools/monitor.ts +255 -0
- package/src/tools/output-meta.ts +754 -0
- package/src/tools/path-utils.ts +741 -0
- package/src/tools/plan-mode-guard.ts +68 -0
- package/src/tools/puppeteer/00_stealth_tampering.txt +63 -0
- package/src/tools/puppeteer/01_stealth_activity.txt +20 -0
- package/src/tools/puppeteer/02_stealth_hairline.txt +11 -0
- package/src/tools/puppeteer/03_stealth_botd.txt +384 -0
- package/src/tools/puppeteer/04_stealth_iframe.txt +81 -0
- package/src/tools/puppeteer/05_stealth_webgl.txt +75 -0
- package/src/tools/puppeteer/06_stealth_screen.txt +72 -0
- package/src/tools/puppeteer/07_stealth_fonts.txt +97 -0
- package/src/tools/puppeteer/08_stealth_audio.txt +51 -0
- package/src/tools/puppeteer/09_stealth_locale.txt +46 -0
- package/src/tools/puppeteer/10_stealth_plugins.txt +206 -0
- package/src/tools/puppeteer/11_stealth_hardware.txt +8 -0
- package/src/tools/puppeteer/12_stealth_codecs.txt +40 -0
- package/src/tools/puppeteer/13_stealth_worker.txt +74 -0
- package/src/tools/read.ts +2333 -0
- package/src/tools/recipe/index.ts +80 -0
- package/src/tools/recipe/render.ts +19 -0
- package/src/tools/recipe/runner.ts +219 -0
- package/src/tools/recipe/runners/cargo.ts +131 -0
- package/src/tools/recipe/runners/index.ts +8 -0
- package/src/tools/recipe/runners/just.ts +73 -0
- package/src/tools/recipe/runners/make.ts +101 -0
- package/src/tools/recipe/runners/pkg.ts +167 -0
- package/src/tools/recipe/runners/task.ts +72 -0
- package/src/tools/render-mermaid.ts +68 -0
- package/src/tools/render-utils.ts +774 -0
- package/src/tools/renderers.ts +79 -0
- package/src/tools/resolve.ts +258 -0
- package/src/tools/review.ts +252 -0
- package/src/tools/search-tool-bm25.ts +364 -0
- package/src/tools/search.ts +787 -0
- package/src/tools/skill.ts +170 -0
- package/src/tools/sqlite-reader.ts +736 -0
- package/src/tools/ssh.ts +310 -0
- package/src/tools/subagent-render.ts +160 -0
- package/src/tools/subagent.ts +698 -0
- package/src/tools/telegram-send.ts +178 -0
- package/src/tools/todo-write.ts +695 -0
- package/src/tools/tool-errors.ts +62 -0
- package/src/tools/tool-result.ts +86 -0
- package/src/tools/tool-timeouts.ts +30 -0
- package/src/tools/vim.ts +949 -0
- package/src/tools/write.ts +953 -0
- package/src/tools/yield.ts +268 -0
- package/src/tui/code-cell.ts +201 -0
- package/src/tui/file-list.ts +55 -0
- package/src/tui/hyperlink.ts +126 -0
- package/src/tui/index.ts +12 -0
- package/src/tui/output-block.ts +150 -0
- package/src/tui/status-line.ts +39 -0
- package/src/tui/tree-list.ts +84 -0
- package/src/tui/types.ts +15 -0
- package/src/tui/utils.ts +103 -0
- package/src/utils/changelog.ts +121 -0
- package/src/utils/clipboard.ts +156 -0
- package/src/utils/command-args.ts +76 -0
- package/src/utils/commit-message-generator.ts +135 -0
- package/src/utils/edit-mode.ts +42 -0
- package/src/utils/event-bus.ts +33 -0
- package/src/utils/external-editor.ts +65 -0
- package/src/utils/file-display-mode.ts +45 -0
- package/src/utils/file-mentions.ts +376 -0
- package/src/utils/git.ts +1536 -0
- package/src/utils/image-loading.ts +102 -0
- package/src/utils/image-resize.ts +309 -0
- package/src/utils/lang-from-path.ts +239 -0
- package/src/utils/markit.ts +89 -0
- package/src/utils/open.ts +20 -0
- package/src/utils/session-color.ts +43 -0
- package/src/utils/shell-snapshot.ts +187 -0
- package/src/utils/sixel.ts +69 -0
- package/src/utils/title-generator.ts +237 -0
- package/src/utils/tokenizer-download.ts +106 -0
- package/src/utils/tokenizer-encoding.ts +29 -0
- package/src/utils/tool-choice.ts +62 -0
- package/src/utils/tools-manager.ts +363 -0
- package/src/vim/buffer.ts +309 -0
- package/src/vim/commands.ts +382 -0
- package/src/vim/engine.ts +2409 -0
- package/src/vim/parser.ts +134 -0
- package/src/vim/render.ts +252 -0
- package/src/vim/types.ts +197 -0
- package/src/web/kagi.ts +183 -0
- package/src/web/parallel.ts +349 -0
- package/src/web/public-fetch-url.ts +74 -0
- package/src/web/scrapers/artifacthub.ts +207 -0
- package/src/web/scrapers/arxiv.ts +83 -0
- package/src/web/scrapers/aur.ts +162 -0
- package/src/web/scrapers/biorxiv.ts +133 -0
- package/src/web/scrapers/bluesky.ts +262 -0
- package/src/web/scrapers/brew.ts +172 -0
- package/src/web/scrapers/cheatsh.ts +68 -0
- package/src/web/scrapers/chocolatey.ts +196 -0
- package/src/web/scrapers/choosealicense.ts +95 -0
- package/src/web/scrapers/cisa-kev.ts +87 -0
- package/src/web/scrapers/clojars.ts +154 -0
- package/src/web/scrapers/coingecko.ts +177 -0
- package/src/web/scrapers/crates-io.ts +97 -0
- package/src/web/scrapers/crossref.ts +136 -0
- package/src/web/scrapers/devto.ts +147 -0
- package/src/web/scrapers/discogs.ts +306 -0
- package/src/web/scrapers/discourse.ts +197 -0
- package/src/web/scrapers/dockerhub.ts +138 -0
- package/src/web/scrapers/docs-rs.ts +653 -0
- package/src/web/scrapers/fdroid.ts +134 -0
- package/src/web/scrapers/firefox-addons.ts +191 -0
- package/src/web/scrapers/flathub.ts +223 -0
- package/src/web/scrapers/github-gist.ts +58 -0
- package/src/web/scrapers/github.ts +452 -0
- package/src/web/scrapers/gitlab.ts +401 -0
- package/src/web/scrapers/go-pkg.ts +266 -0
- package/src/web/scrapers/hackage.ts +140 -0
- package/src/web/scrapers/hackernews.ts +189 -0
- package/src/web/scrapers/hex.ts +105 -0
- package/src/web/scrapers/huggingface.ts +321 -0
- package/src/web/scrapers/iacr.ts +89 -0
- package/src/web/scrapers/index.ts +252 -0
- package/src/web/scrapers/jetbrains-marketplace.ts +159 -0
- package/src/web/scrapers/lemmy.ts +203 -0
- package/src/web/scrapers/lobsters.ts +175 -0
- package/src/web/scrapers/mastodon.ts +292 -0
- package/src/web/scrapers/maven.ts +138 -0
- package/src/web/scrapers/mdn.ts +173 -0
- package/src/web/scrapers/metacpan.ts +222 -0
- package/src/web/scrapers/musicbrainz.ts +250 -0
- package/src/web/scrapers/npm.ts +98 -0
- package/src/web/scrapers/nuget.ts +183 -0
- package/src/web/scrapers/nvd.ts +222 -0
- package/src/web/scrapers/ollama.ts +239 -0
- package/src/web/scrapers/open-vsx.ts +106 -0
- package/src/web/scrapers/opencorporates.ts +292 -0
- package/src/web/scrapers/openlibrary.ts +336 -0
- package/src/web/scrapers/orcid.ts +286 -0
- package/src/web/scrapers/osv.ts +176 -0
- package/src/web/scrapers/packagist.ts +160 -0
- package/src/web/scrapers/pub-dev.ts +143 -0
- package/src/web/scrapers/pubmed.ts +211 -0
- package/src/web/scrapers/pypi.ts +112 -0
- package/src/web/scrapers/rawg.ts +110 -0
- package/src/web/scrapers/readthedocs.ts +120 -0
- package/src/web/scrapers/reddit.ts +95 -0
- package/src/web/scrapers/repology.ts +251 -0
- package/src/web/scrapers/rfc.ts +201 -0
- package/src/web/scrapers/rubygems.ts +103 -0
- package/src/web/scrapers/searchcode.ts +189 -0
- package/src/web/scrapers/sec-edgar.ts +261 -0
- package/src/web/scrapers/semantic-scholar.ts +171 -0
- package/src/web/scrapers/snapcraft.ts +187 -0
- package/src/web/scrapers/sourcegraph.ts +336 -0
- package/src/web/scrapers/spdx.ts +108 -0
- package/src/web/scrapers/spotify.ts +198 -0
- package/src/web/scrapers/stackoverflow.ts +120 -0
- package/src/web/scrapers/terraform.ts +277 -0
- package/src/web/scrapers/tldr.ts +47 -0
- package/src/web/scrapers/twitter.ts +93 -0
- package/src/web/scrapers/types.ts +358 -0
- package/src/web/scrapers/utils.ts +133 -0
- package/src/web/scrapers/vimeo.ts +133 -0
- package/src/web/scrapers/vscode-marketplace.ts +187 -0
- package/src/web/scrapers/w3c.ts +156 -0
- package/src/web/scrapers/wikidata.ts +344 -0
- package/src/web/scrapers/wikipedia.ts +84 -0
- package/src/web/scrapers/youtube.ts +319 -0
- package/src/web/search/index.ts +416 -0
- package/src/web/search/provider.ts +236 -0
- package/src/web/search/providers/anthropic.ts +319 -0
- package/src/web/search/providers/base.ts +102 -0
- package/src/web/search/providers/brave.ts +149 -0
- package/src/web/search/providers/codex.ts +598 -0
- package/src/web/search/providers/duckduckgo.ts +279 -0
- package/src/web/search/providers/exa.ts +193 -0
- package/src/web/search/providers/gemini.ts +462 -0
- package/src/web/search/providers/jina.ts +101 -0
- package/src/web/search/providers/kagi.ts +75 -0
- package/src/web/search/providers/kimi.ts +171 -0
- package/src/web/search/providers/parallel.ts +210 -0
- package/src/web/search/providers/perplexity.ts +575 -0
- package/src/web/search/providers/searxng.ts +309 -0
- package/src/web/search/providers/synthetic.ts +108 -0
- package/src/web/search/providers/tavily.ts +173 -0
- package/src/web/search/providers/utils.ts +128 -0
- package/src/web/search/providers/xai.ts +174 -0
- package/src/web/search/providers/zai.ts +320 -0
- package/src/web/search/render.ts +299 -0
- package/src/web/search/types.ts +445 -0
- package/src/web/search/utils.ts +17 -0
- package/src/workspace-tree.ts +286 -0
|
@@ -0,0 +1,2173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task tool - Delegate tasks to specialized agents.
|
|
3
|
+
*
|
|
4
|
+
* Discovers agent definitions from:
|
|
5
|
+
* - Bundled agents (shipped with gjc-coding-agent)
|
|
6
|
+
* - ~/.jwc/agent/agents/*.md (user-level)
|
|
7
|
+
* - .jwc/agents/*.md (project-level)
|
|
8
|
+
*
|
|
9
|
+
* Supports:
|
|
10
|
+
* - Single agent execution
|
|
11
|
+
* - Parallel execution with concurrency limits
|
|
12
|
+
* - Progress tracking via JSON events
|
|
13
|
+
* - Session artifacts for debugging
|
|
14
|
+
*/
|
|
15
|
+
import { createHash } from "node:crypto";
|
|
16
|
+
|
|
17
|
+
import * as fs from "node:fs/promises";
|
|
18
|
+
import * as os from "node:os";
|
|
19
|
+
import path from "node:path";
|
|
20
|
+
import type { AgentTool, AgentToolResult, AgentToolUpdateCallback } from "@jawcode-dev/agent-core";
|
|
21
|
+
import type { Model, Usage } from "@jawcode-dev/ai";
|
|
22
|
+
import { $env, prompt, Snowflake } from "@jawcode-dev/utils";
|
|
23
|
+
import type { ToolSession } from "..";
|
|
24
|
+
import { AsyncJobManager } from "../async";
|
|
25
|
+
import { resolveAgentModelPatterns } from "../config/model-resolver";
|
|
26
|
+
import {
|
|
27
|
+
allocateActorRecord,
|
|
28
|
+
buildWorkflowActorKey,
|
|
29
|
+
findRunningActor,
|
|
30
|
+
markActorFailed,
|
|
31
|
+
markActorIdle,
|
|
32
|
+
markActorMaintained,
|
|
33
|
+
markActorPaused,
|
|
34
|
+
markActorRunning,
|
|
35
|
+
readActorRegistry,
|
|
36
|
+
resolveCompatibleActor,
|
|
37
|
+
upsertActor,
|
|
38
|
+
type WorkflowActorKey,
|
|
39
|
+
type WorkflowActorRecord,
|
|
40
|
+
type WorkflowActorRegistry,
|
|
41
|
+
type WorkflowActorStage,
|
|
42
|
+
workflowActorId,
|
|
43
|
+
writeActorRegistryAtomic,
|
|
44
|
+
} from "../jwc-runtime/actor-registry";
|
|
45
|
+
import { readPabcdStateWithFallback } from "../jwc-runtime/orchestrate-state";
|
|
46
|
+
import type { Theme } from "../modes/theme/theme";
|
|
47
|
+
import executorSelfForkPrompt from "../prompts/system/executor-self-fork.md" with { type: "text" };
|
|
48
|
+
import planModeSubagentPrompt from "../prompts/system/plan-mode-subagent.md" with { type: "text" };
|
|
49
|
+
import subagentUserPromptTemplate from "../prompts/system/subagent-user-prompt.md" with { type: "text" };
|
|
50
|
+
import taskDescriptionTemplate from "../prompts/tools/task.md" with { type: "text" };
|
|
51
|
+
import taskSummaryTemplate from "../prompts/tools/task-summary.md" with { type: "text" };
|
|
52
|
+
import type { ForkContextSeed } from "../session/agent-session";
|
|
53
|
+
import { formatBytes, formatDuration } from "../tools/render-utils";
|
|
54
|
+
import {
|
|
55
|
+
type AgentDefinition,
|
|
56
|
+
type AgentProgress,
|
|
57
|
+
type CacheAffinityMetadata,
|
|
58
|
+
type ForkContextMode,
|
|
59
|
+
type ForkContextPolicy,
|
|
60
|
+
getTaskSchema,
|
|
61
|
+
type SingleResult,
|
|
62
|
+
type TaskItem,
|
|
63
|
+
type TaskParams,
|
|
64
|
+
type TaskToolDetails,
|
|
65
|
+
type TaskToolSchemaInstance,
|
|
66
|
+
} from "./types";
|
|
67
|
+
// Import review tools for side effects (registers subagent tool handlers)
|
|
68
|
+
import "../tools/review";
|
|
69
|
+
import type { LocalProtocolOptions } from "../internal-urls";
|
|
70
|
+
import { generateCommitMessage } from "../utils/commit-message-generator";
|
|
71
|
+
import * as git from "../utils/git";
|
|
72
|
+
import { discoverAgents, filterVisibleAgents, getAgent } from "./discovery";
|
|
73
|
+
import { runSubprocess } from "./executor";
|
|
74
|
+
import { getTaskIdValidationError, validateAllocatedTaskId } from "./id";
|
|
75
|
+
import { resolveModelHint } from "./model-presets";
|
|
76
|
+
import { AgentOutputManager } from "./output-manager";
|
|
77
|
+
import { mapWithConcurrencyLimit, Semaphore } from "./parallel";
|
|
78
|
+
import { assertNoRawTaskFields, buildTaskReceipt, buildTaskRoiSummary } from "./receipt";
|
|
79
|
+
import { renderResult, renderCall as renderTaskCall } from "./render";
|
|
80
|
+
import { getTaskSimpleModeCapabilities, type TaskSimpleMode } from "./simple-mode";
|
|
81
|
+
import { DEFAULT_SPAWN_THRESHOLD, evaluateReviewerExploreGate, evaluateSpawnGate } from "./spawn-gate";
|
|
82
|
+
import {
|
|
83
|
+
applyNestedPatches,
|
|
84
|
+
captureBaseline,
|
|
85
|
+
captureDeltaPatch,
|
|
86
|
+
cleanupIsolation,
|
|
87
|
+
cleanupTaskBranches,
|
|
88
|
+
commitToBranch,
|
|
89
|
+
ensureIsolation,
|
|
90
|
+
getRepoRoot,
|
|
91
|
+
type IsolationHandle,
|
|
92
|
+
mergeTaskBranches,
|
|
93
|
+
parseIsolationMode,
|
|
94
|
+
type WorktreeBaseline,
|
|
95
|
+
} from "./worktree";
|
|
96
|
+
|
|
97
|
+
interface TaskResumeDescriptor {
|
|
98
|
+
toolCallId: string;
|
|
99
|
+
params: TaskParams;
|
|
100
|
+
task: TaskItem & { id: string };
|
|
101
|
+
sessionFile: string | null;
|
|
102
|
+
forkContextSeed?: ForkContextSeed;
|
|
103
|
+
agentSource: AgentDefinition["source"];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function isTaskResumeDescriptor(value: unknown): value is TaskResumeDescriptor {
|
|
107
|
+
return typeof value === "object" && value !== null && "task" in value && "params" in value;
|
|
108
|
+
}
|
|
109
|
+
function renderSubagentUserPrompt(assignment: string, simpleMode: TaskSimpleMode): string {
|
|
110
|
+
return prompt.render(subagentUserPromptTemplate, {
|
|
111
|
+
assignment: assignment.trim(),
|
|
112
|
+
independentMode: simpleMode === "independent",
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
function createUsageTotals(): Usage {
|
|
116
|
+
return {
|
|
117
|
+
input: 0,
|
|
118
|
+
output: 0,
|
|
119
|
+
cacheRead: 0,
|
|
120
|
+
cacheWrite: 0,
|
|
121
|
+
totalTokens: 0,
|
|
122
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function addUsageTotals(target: Usage, usage: Partial<Usage>): void {
|
|
127
|
+
const input = usage.input ?? 0;
|
|
128
|
+
const output = usage.output ?? 0;
|
|
129
|
+
const cacheRead = usage.cacheRead ?? 0;
|
|
130
|
+
const cacheWrite = usage.cacheWrite ?? 0;
|
|
131
|
+
const totalTokens = usage.totalTokens ?? input + output + cacheRead + cacheWrite;
|
|
132
|
+
const cost =
|
|
133
|
+
usage.cost ??
|
|
134
|
+
({
|
|
135
|
+
input: 0,
|
|
136
|
+
output: 0,
|
|
137
|
+
cacheRead: 0,
|
|
138
|
+
cacheWrite: 0,
|
|
139
|
+
total: 0,
|
|
140
|
+
} satisfies Usage["cost"]);
|
|
141
|
+
|
|
142
|
+
target.input += input;
|
|
143
|
+
target.output += output;
|
|
144
|
+
target.cacheRead += cacheRead;
|
|
145
|
+
target.cacheWrite += cacheWrite;
|
|
146
|
+
target.totalTokens += totalTokens;
|
|
147
|
+
target.cost.input += cost.input;
|
|
148
|
+
target.cost.output += cost.output;
|
|
149
|
+
target.cost.cacheRead += cost.cacheRead;
|
|
150
|
+
target.cost.cacheWrite += cost.cacheWrite;
|
|
151
|
+
target.cost.total += cost.total;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function hashTaskValue(value: unknown): string {
|
|
155
|
+
return createHash("sha256").update(JSON.stringify(value)).digest("hex").slice(0, 16);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function firstModelPattern(value: string | string[] | undefined): string {
|
|
159
|
+
if (Array.isArray(value)) return value[0] ?? "default";
|
|
160
|
+
return value ?? "default";
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function providerFromModelPattern(value: string): string {
|
|
164
|
+
const slash = value.indexOf("/");
|
|
165
|
+
return slash > 0 ? value.slice(0, slash) : "unknown";
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function isPabcdActorStage(value: unknown): value is WorkflowActorStage {
|
|
169
|
+
return value === "i" || value === "p" || value === "a" || value === "b" || value === "c" || value === "d";
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function buildActorBusyResult(
|
|
173
|
+
task: TaskItem & { id: string },
|
|
174
|
+
index: number,
|
|
175
|
+
agentName: string,
|
|
176
|
+
agentSource: AgentDefinition["source"],
|
|
177
|
+
modelOverride: string | string[] | undefined,
|
|
178
|
+
simpleMode: TaskSimpleMode,
|
|
179
|
+
actor: WorkflowActorRecord,
|
|
180
|
+
): SingleResult {
|
|
181
|
+
const output = `PABCD actor ${actor.id} (${actor.lane}) is already running for this stage. Wait for that subagent to finish before reusing the same resume lane.`;
|
|
182
|
+
return {
|
|
183
|
+
index,
|
|
184
|
+
id: task.id,
|
|
185
|
+
agent: agentName,
|
|
186
|
+
agentSource,
|
|
187
|
+
task: renderSubagentUserPrompt(task.assignment, simpleMode),
|
|
188
|
+
assignment: task.assignment.trim(),
|
|
189
|
+
description: task.description,
|
|
190
|
+
exitCode: 1,
|
|
191
|
+
output,
|
|
192
|
+
stderr: output,
|
|
193
|
+
truncated: false,
|
|
194
|
+
durationMs: 0,
|
|
195
|
+
tokens: 0,
|
|
196
|
+
modelOverride,
|
|
197
|
+
error: output,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function buildActorContextUnavailableResult(
|
|
202
|
+
task: TaskItem & { id: string },
|
|
203
|
+
index: number,
|
|
204
|
+
agentName: string,
|
|
205
|
+
agentSource: AgentDefinition["source"],
|
|
206
|
+
modelOverride: string | string[] | undefined,
|
|
207
|
+
simpleMode: TaskSimpleMode,
|
|
208
|
+
actor: WorkflowActorRecord,
|
|
209
|
+
reason: string,
|
|
210
|
+
): SingleResult {
|
|
211
|
+
const output = `PABCD actor ${actor.id} (${actor.lane}) cannot be resumed in this process: ${reason}.`;
|
|
212
|
+
return {
|
|
213
|
+
index,
|
|
214
|
+
id: task.id,
|
|
215
|
+
agent: agentName,
|
|
216
|
+
agentSource,
|
|
217
|
+
task: renderSubagentUserPrompt(task.assignment, simpleMode),
|
|
218
|
+
assignment: task.assignment.trim(),
|
|
219
|
+
description: task.description,
|
|
220
|
+
exitCode: 1,
|
|
221
|
+
output,
|
|
222
|
+
stderr: output,
|
|
223
|
+
truncated: false,
|
|
224
|
+
durationMs: 0,
|
|
225
|
+
tokens: 0,
|
|
226
|
+
modelOverride,
|
|
227
|
+
error: "context_unavailable",
|
|
228
|
+
cacheAffinity: { affine: false, reason: "not_applicable" },
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function validateTaskIdsForScheduling(tasks: readonly TaskItem[]): string | undefined {
|
|
233
|
+
const invalid: string[] = [];
|
|
234
|
+
for (let i = 0; i < tasks.length; i++) {
|
|
235
|
+
const error = getTaskIdValidationError(tasks[i]?.id);
|
|
236
|
+
if (error) invalid.push(`index ${i}: ${error}`);
|
|
237
|
+
}
|
|
238
|
+
return invalid.length > 0 ? `Invalid task ids: ${invalid.join(" ")}` : undefined;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Re-export types and utilities
|
|
242
|
+
export { loadBundledAgents as BUNDLED_AGENTS } from "./agents";
|
|
243
|
+
export { discoverCommands, expandCommand, getCommand } from "./commands";
|
|
244
|
+
export { discoverAgents, getAgent } from "./discovery";
|
|
245
|
+
export {
|
|
246
|
+
isValidAllocatedTaskId,
|
|
247
|
+
isValidTaskId,
|
|
248
|
+
TASK_ID_DESCRIPTION,
|
|
249
|
+
TASK_ID_PATTERN,
|
|
250
|
+
validateAllocatedTaskId,
|
|
251
|
+
validateTaskId,
|
|
252
|
+
} from "./id";
|
|
253
|
+
export { AgentOutputManager } from "./output-manager";
|
|
254
|
+
export type { TaskResultReceipt } from "./receipt";
|
|
255
|
+
export {
|
|
256
|
+
assertNoRawTaskFields,
|
|
257
|
+
buildTaskReceipt,
|
|
258
|
+
buildTaskRoi,
|
|
259
|
+
buildTaskRoiSummary,
|
|
260
|
+
findRawTaskLeakKeys,
|
|
261
|
+
sanitizeTaskToolDetails,
|
|
262
|
+
} from "./receipt";
|
|
263
|
+
export type {
|
|
264
|
+
AgentDefinition,
|
|
265
|
+
AgentProgress,
|
|
266
|
+
SingleResult,
|
|
267
|
+
SubagentLifecyclePayload,
|
|
268
|
+
SubagentProgressPayload,
|
|
269
|
+
TaskParams,
|
|
270
|
+
TaskToolDetails,
|
|
271
|
+
} from "./types";
|
|
272
|
+
export {
|
|
273
|
+
TASK_SUBAGENT_EVENT_CHANNEL,
|
|
274
|
+
TASK_SUBAGENT_LIFECYCLE_CHANNEL,
|
|
275
|
+
TASK_SUBAGENT_PROGRESS_CHANNEL,
|
|
276
|
+
taskSchema,
|
|
277
|
+
} from "./types";
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Render the tool description from a cached agent list and current settings.
|
|
281
|
+
*/
|
|
282
|
+
function renderDescription(
|
|
283
|
+
agents: AgentDefinition[],
|
|
284
|
+
maxConcurrency: number,
|
|
285
|
+
isolationEnabled: boolean,
|
|
286
|
+
asyncEnabled: boolean,
|
|
287
|
+
disabledAgents: string[],
|
|
288
|
+
simpleMode: TaskSimpleMode,
|
|
289
|
+
ircEnabled: boolean,
|
|
290
|
+
parentSpawns: string,
|
|
291
|
+
): string {
|
|
292
|
+
const spawningDisabled = parentSpawns === "";
|
|
293
|
+
let filteredAgents = filterVisibleAgents(agents);
|
|
294
|
+
filteredAgents =
|
|
295
|
+
disabledAgents.length > 0 ? filteredAgents.filter(a => !disabledAgents.includes(a.name)) : filteredAgents;
|
|
296
|
+
if (spawningDisabled) {
|
|
297
|
+
filteredAgents = [];
|
|
298
|
+
} else if (parentSpawns !== "*") {
|
|
299
|
+
const allowed = new Set(
|
|
300
|
+
parentSpawns
|
|
301
|
+
.split(",")
|
|
302
|
+
.map(s => s.trim())
|
|
303
|
+
.filter(Boolean),
|
|
304
|
+
);
|
|
305
|
+
filteredAgents = filteredAgents.filter(a => allowed.has(a.name));
|
|
306
|
+
}
|
|
307
|
+
const { contextEnabled, customSchemaEnabled } = getTaskSimpleModeCapabilities(simpleMode);
|
|
308
|
+
return prompt.render(taskDescriptionTemplate, {
|
|
309
|
+
agents: filteredAgents,
|
|
310
|
+
spawningDisabled,
|
|
311
|
+
MAX_CONCURRENCY: maxConcurrency,
|
|
312
|
+
isolationEnabled,
|
|
313
|
+
asyncEnabled,
|
|
314
|
+
contextEnabled,
|
|
315
|
+
customSchemaEnabled,
|
|
316
|
+
ircEnabled,
|
|
317
|
+
defaultMode: simpleMode === "default",
|
|
318
|
+
schemaFreeMode: simpleMode === "schema-free",
|
|
319
|
+
independentMode: simpleMode === "independent",
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function createTaskModeError(text: string): AgentToolResult<TaskToolDetails> {
|
|
324
|
+
return {
|
|
325
|
+
content: [{ type: "text", text }],
|
|
326
|
+
details: { projectAgentsDir: null, results: [], totalDurationMs: 0 },
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function validateTaskModeParams(simpleMode: TaskSimpleMode, params: TaskParams): string | undefined {
|
|
331
|
+
const { contextEnabled, customSchemaEnabled } = getTaskSimpleModeCapabilities(simpleMode);
|
|
332
|
+
const disallowedFields: string[] = [];
|
|
333
|
+
if (!contextEnabled && params.context !== undefined) {
|
|
334
|
+
disallowedFields.push("context");
|
|
335
|
+
}
|
|
336
|
+
if (!customSchemaEnabled && params.schema !== undefined) {
|
|
337
|
+
disallowedFields.push("schema");
|
|
338
|
+
}
|
|
339
|
+
if (!contextEnabled) {
|
|
340
|
+
const inheritedTaskIds = (params.tasks ?? [])
|
|
341
|
+
.filter(task => task.inheritContext !== undefined && task.inheritContext !== "none")
|
|
342
|
+
.map(task => task.id);
|
|
343
|
+
if (inheritedTaskIds.length > 0) {
|
|
344
|
+
disallowedFields.push(`inheritContext for task(s) ${inheritedTaskIds.join(", ")}`);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
if (disallowedFields.length === 0) {
|
|
348
|
+
return undefined;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
if (simpleMode === "schema-free") {
|
|
352
|
+
return "task.simple is set to schema-free, so the task tool does not accept `schema`. Remove it and rely on the selected agent definition or inherited session schema.";
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
if (disallowedFields.length === 1) {
|
|
356
|
+
return `task.simple is set to independent, so the task tool does not accept ${disallowedFields[0].startsWith("inheritContext") ? disallowedFields[0] : `\`${disallowedFields[0]}\``}. Put everything the subagent needs inside each task assignment.`;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
return `task.simple is set to independent, so the task tool does not accept ${disallowedFields.map(field => (field.startsWith("inheritContext") ? field : `\`${field}\``)).join(", ")}. Put all required background and output expectations inside each task assignment or the selected agent definition.`;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
function getForkContextPolicy(agent: AgentDefinition): ForkContextPolicy {
|
|
363
|
+
return agent.forkContext ?? "forbidden";
|
|
364
|
+
}
|
|
365
|
+
const FORK_CONTEXT_MODES = [
|
|
366
|
+
"none",
|
|
367
|
+
"receipt",
|
|
368
|
+
"last-turn",
|
|
369
|
+
"bounded",
|
|
370
|
+
"full",
|
|
371
|
+
] as const satisfies readonly ForkContextMode[];
|
|
372
|
+
const FORK_CONTEXT_MODE_SET = new Set<unknown>(FORK_CONTEXT_MODES);
|
|
373
|
+
const FORK_CONTEXT_REQUEST_MODES = ["receipt", "last-turn", "bounded", "full"] as const satisfies readonly Exclude<
|
|
374
|
+
ForkContextMode,
|
|
375
|
+
"none"
|
|
376
|
+
>[];
|
|
377
|
+
const FORK_CONTEXT_REQUEST_MODE_SET = new Set<unknown>(FORK_CONTEXT_REQUEST_MODES);
|
|
378
|
+
|
|
379
|
+
function isValidForkContextMode(value: unknown): value is ForkContextMode {
|
|
380
|
+
return FORK_CONTEXT_MODE_SET.has(value);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
function requestsForkContext(
|
|
384
|
+
task: Pick<TaskItem, "inheritContext">,
|
|
385
|
+
): task is TaskItem & { inheritContext: Exclude<ForkContextMode, "none"> } {
|
|
386
|
+
return FORK_CONTEXT_REQUEST_MODE_SET.has(task.inheritContext);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
function resolveForkSeedParamsForMode(
|
|
390
|
+
mode: ForkContextMode,
|
|
391
|
+
configuredMaxMessages: number | undefined,
|
|
392
|
+
configuredMaxTokens: number,
|
|
393
|
+
model: Model | undefined,
|
|
394
|
+
): { maxMessages: number; maxTokens: number } | undefined {
|
|
395
|
+
const capMessages = (defaultMaxMessages: number): number =>
|
|
396
|
+
configuredMaxMessages === undefined
|
|
397
|
+
? defaultMaxMessages
|
|
398
|
+
: Math.min(defaultMaxMessages, Math.max(0, Math.trunc(configuredMaxMessages)));
|
|
399
|
+
switch (mode) {
|
|
400
|
+
case "none":
|
|
401
|
+
return undefined;
|
|
402
|
+
case "receipt":
|
|
403
|
+
return { maxMessages: 1, maxTokens: 64 };
|
|
404
|
+
case "last-turn":
|
|
405
|
+
return { maxMessages: 2, maxTokens: 250 };
|
|
406
|
+
case "bounded":
|
|
407
|
+
return { maxMessages: capMessages(50), maxTokens: 250 };
|
|
408
|
+
case "full":
|
|
409
|
+
return { maxMessages: capMessages(500), maxTokens: resolveForkContextMaxTokens(configuredMaxTokens, model) };
|
|
410
|
+
default:
|
|
411
|
+
return undefined;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
function validateForkContextRequests(
|
|
416
|
+
tasks: readonly TaskItem[],
|
|
417
|
+
agent: AgentDefinition,
|
|
418
|
+
forkContextEnabled: boolean,
|
|
419
|
+
): string | undefined {
|
|
420
|
+
const invalidTaskIds = tasks
|
|
421
|
+
.filter(task => task.inheritContext !== undefined && !isValidForkContextMode(task.inheritContext as unknown))
|
|
422
|
+
.map(task => task.id);
|
|
423
|
+
if (invalidTaskIds.length > 0) {
|
|
424
|
+
return `Invalid inheritContext for task(s) ${invalidTaskIds.join(", ")}. Allowed modes: ${FORK_CONTEXT_MODES.join(", ")}.`;
|
|
425
|
+
}
|
|
426
|
+
const requested = tasks.filter(requestsForkContext);
|
|
427
|
+
if (requested.length === 0) return undefined;
|
|
428
|
+
const taskIds = requested.map(task => task.id).join(", ");
|
|
429
|
+
if (!forkContextEnabled) {
|
|
430
|
+
return `Cannot inherit parent context for task(s) ${taskIds}: task.forkContext.enabled is false.`;
|
|
431
|
+
}
|
|
432
|
+
if (getForkContextPolicy(agent) !== "allowed") {
|
|
433
|
+
return `Cannot inherit parent context for task(s) ${taskIds}: agent '${agent.name}' does not declare forkContext: allowed.`;
|
|
434
|
+
}
|
|
435
|
+
return undefined;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
export function resolveForkContextMaxTokens(configured: number, model: Model | undefined): number {
|
|
439
|
+
if (configured > 0) return Math.trunc(configured);
|
|
440
|
+
const contextWindow = model?.contextWindow ?? 0;
|
|
441
|
+
return contextWindow > 0 ? Math.max(1, Math.floor(contextWindow * 0.15)) : 15_000;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
445
|
+
// Tool Class
|
|
446
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Task tool - Delegate tasks to specialized agents.
|
|
450
|
+
*
|
|
451
|
+
* Requires async initialization to discover available agents.
|
|
452
|
+
* Use `TaskTool.create(session)` to instantiate.
|
|
453
|
+
*/
|
|
454
|
+
export class TaskTool implements AgentTool<TaskToolSchemaInstance, TaskToolDetails, Theme> {
|
|
455
|
+
readonly name = "task";
|
|
456
|
+
readonly label = "Task";
|
|
457
|
+
readonly summary = "Spawn a subagent to complete a parallel task";
|
|
458
|
+
readonly strict = true;
|
|
459
|
+
readonly loadMode = "discoverable";
|
|
460
|
+
readonly renderResult = renderResult;
|
|
461
|
+
readonly #discoveredAgents: AgentDefinition[];
|
|
462
|
+
readonly #blockedAgent: string | undefined;
|
|
463
|
+
readonly #spawningAgentType: string | undefined;
|
|
464
|
+
|
|
465
|
+
get parameters(): TaskToolSchemaInstance {
|
|
466
|
+
const isolationEnabled = this.session.settings.get("task.isolation.mode") !== "none";
|
|
467
|
+
return getTaskSchema({ isolationEnabled, simpleMode: this.#getTaskSimpleMode() });
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
renderCall(args: unknown, options: Parameters<typeof renderTaskCall>[1], theme: Theme) {
|
|
471
|
+
return renderTaskCall(args as TaskParams, options, theme);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/** Dynamic description that reflects current disabled-agent settings */
|
|
475
|
+
get description(): string {
|
|
476
|
+
const disabledAgents = this.session.settings.get("task.disabledAgents") as string[];
|
|
477
|
+
const maxConcurrency = this.session.settings.get("task.maxConcurrency");
|
|
478
|
+
const isolationMode = this.session.settings.get("task.isolation.mode");
|
|
479
|
+
return renderDescription(
|
|
480
|
+
this.#discoveredAgents,
|
|
481
|
+
maxConcurrency,
|
|
482
|
+
isolationMode !== "none",
|
|
483
|
+
true,
|
|
484
|
+
disabledAgents,
|
|
485
|
+
this.#getTaskSimpleMode(),
|
|
486
|
+
this.session.settings.get("irc.enabled") === true,
|
|
487
|
+
this.session.getSessionSpawns() ?? "*",
|
|
488
|
+
);
|
|
489
|
+
}
|
|
490
|
+
private constructor(
|
|
491
|
+
private readonly session: ToolSession,
|
|
492
|
+
discoveredAgents: AgentDefinition[],
|
|
493
|
+
) {
|
|
494
|
+
this.#blockedAgent = $env.PI_BLOCKED_AGENT;
|
|
495
|
+
this.#spawningAgentType = session.currentAgentType;
|
|
496
|
+
this.#discoveredAgents = discoveredAgents;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
#getTaskSimpleMode(): TaskSimpleMode {
|
|
500
|
+
return this.session.settings.get("task.simple");
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* Create a TaskTool instance with async agent discovery.
|
|
505
|
+
*/
|
|
506
|
+
static async create(session: ToolSession): Promise<TaskTool> {
|
|
507
|
+
const { agents } = await discoverAgents(session.cwd);
|
|
508
|
+
return new TaskTool(session, agents);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
async execute(
|
|
512
|
+
_toolCallId: string,
|
|
513
|
+
rawParams: unknown,
|
|
514
|
+
signal?: AbortSignal,
|
|
515
|
+
onUpdate?: AgentToolUpdateCallback<TaskToolDetails>,
|
|
516
|
+
): Promise<AgentToolResult<TaskToolDetails>> {
|
|
517
|
+
const params = rawParams as TaskParams;
|
|
518
|
+
const requestedAgentName = params.agent;
|
|
519
|
+
const agentLookupName = requestedAgentName === "executor_ext" ? "executor" : requestedAgentName;
|
|
520
|
+
const simpleMode = this.#getTaskSimpleMode();
|
|
521
|
+
const validationError = validateTaskModeParams(simpleMode, params);
|
|
522
|
+
if (validationError) {
|
|
523
|
+
return createTaskModeError(validationError);
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
const taskItems = params.tasks ?? [];
|
|
527
|
+
const taskIdValidationError = validateTaskIdsForScheduling(taskItems);
|
|
528
|
+
if (taskIdValidationError) {
|
|
529
|
+
return createTaskModeError(taskIdValidationError);
|
|
530
|
+
}
|
|
531
|
+
if (taskItems.length === 0) {
|
|
532
|
+
return this.#executeSync(_toolCallId, params, signal, onUpdate);
|
|
533
|
+
}
|
|
534
|
+
const agent = getAgent(this.#discoveredAgents, agentLookupName);
|
|
535
|
+
if (!agent) {
|
|
536
|
+
const available =
|
|
537
|
+
filterVisibleAgents(this.#discoveredAgents)
|
|
538
|
+
.map(a => a.name)
|
|
539
|
+
.join(", ") || "none";
|
|
540
|
+
return {
|
|
541
|
+
content: [{ type: "text", text: `Unknown agent "${params.agent}". Available: ${available}` }],
|
|
542
|
+
details: { projectAgentsDir: null, results: [], totalDurationMs: 0 },
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
const disabledAgents = this.session.settings.get("task.disabledAgents") as string[];
|
|
547
|
+
if (disabledAgents.length > 0 && disabledAgents.includes(requestedAgentName)) {
|
|
548
|
+
const enabled = filterVisibleAgents(this.#discoveredAgents)
|
|
549
|
+
.filter(a => !disabledAgents.includes(a.name))
|
|
550
|
+
.map(a => a.name);
|
|
551
|
+
return {
|
|
552
|
+
content: [
|
|
553
|
+
{
|
|
554
|
+
type: "text",
|
|
555
|
+
text: `Agent "${params.agent}" is disabled in settings. Enable it via /agents, or use a different agent type.${enabled.length > 0 ? ` Available: ${enabled.join(", ")}` : ""}`,
|
|
556
|
+
},
|
|
557
|
+
],
|
|
558
|
+
details: { projectAgentsDir: null, results: [], totalDurationMs: 0 },
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
const forkContextValidationError = validateForkContextRequests(
|
|
563
|
+
taskItems,
|
|
564
|
+
agent,
|
|
565
|
+
this.session.settings.get("task.forkContext.enabled"),
|
|
566
|
+
);
|
|
567
|
+
if (forkContextValidationError) {
|
|
568
|
+
return createTaskModeError(forkContextValidationError);
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
const batchGateDecision = evaluateSpawnGate({ childCount: taskItems.length, plan: params.spawnPlan });
|
|
572
|
+
if (batchGateDecision.outcome === "rejected") {
|
|
573
|
+
return {
|
|
574
|
+
content: [
|
|
575
|
+
{
|
|
576
|
+
type: "text",
|
|
577
|
+
text: `Task spawn gate rejected this batch: ${batchGateDecision.reason}. Batches with more than ${DEFAULT_SPAWN_THRESHOLD} tasks require spawnPlan fields: ${batchGateDecision.missingFields.join(", ")}.`,
|
|
578
|
+
},
|
|
579
|
+
],
|
|
580
|
+
details: { projectAgentsDir: null, results: [], totalDurationMs: 0 },
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
const reviewerExploreDecision = evaluateReviewerExploreGate({
|
|
585
|
+
spawningAgentType: this.#spawningAgentType,
|
|
586
|
+
targetAgent: requestedAgentName,
|
|
587
|
+
plan: params.spawnPlan,
|
|
588
|
+
});
|
|
589
|
+
if (reviewerExploreDecision.outcome === "rejected") {
|
|
590
|
+
return {
|
|
591
|
+
content: [
|
|
592
|
+
{
|
|
593
|
+
type: "text",
|
|
594
|
+
text: `Task spawn gate rejected reviewer->explore: ${reviewerExploreDecision.reason}. Provide spawnPlan fields: ${reviewerExploreDecision.missingFields.join(", ")}.`,
|
|
595
|
+
},
|
|
596
|
+
],
|
|
597
|
+
details: { projectAgentsDir: null, results: [], totalDurationMs: 0 },
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
const manager = AsyncJobManager.instance();
|
|
602
|
+
if (!manager) {
|
|
603
|
+
return {
|
|
604
|
+
content: [{ type: "text", text: "Subagent background execution is unavailable in this session." }],
|
|
605
|
+
details: { projectAgentsDir: null, results: [], totalDurationMs: 0 },
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
const outputManager =
|
|
610
|
+
this.session.agentOutputManager ?? new AgentOutputManager(this.session.getArtifactsDir ?? (() => null));
|
|
611
|
+
const uniqueIds = await outputManager.allocateBatch(taskItems.map(t => t.id));
|
|
612
|
+
const fallbackAgentSource =
|
|
613
|
+
this.#discoveredAgents.find(agent => agent.name === params.agent)?.source ?? "bundled";
|
|
614
|
+
const progressByTaskId = new Map<string, AgentProgress>();
|
|
615
|
+
for (let index = 0; index < taskItems.length; index++) {
|
|
616
|
+
const taskItem = taskItems[index];
|
|
617
|
+
const assignment = taskItem.assignment.trim();
|
|
618
|
+
progressByTaskId.set(taskItem.id, {
|
|
619
|
+
index,
|
|
620
|
+
id: taskItem.id,
|
|
621
|
+
agent: params.agent,
|
|
622
|
+
agentSource: fallbackAgentSource,
|
|
623
|
+
status: "pending",
|
|
624
|
+
task: renderSubagentUserPrompt(assignment, simpleMode),
|
|
625
|
+
assignment,
|
|
626
|
+
description: taskItem.description,
|
|
627
|
+
recentTools: [],
|
|
628
|
+
recentOutput: [],
|
|
629
|
+
toolCount: 0,
|
|
630
|
+
tokens: 0,
|
|
631
|
+
cost: 0,
|
|
632
|
+
durationMs: 0,
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
const startedJobs: Array<{ jobId: string; taskId: string }> = [];
|
|
637
|
+
const failedSchedules: string[] = [];
|
|
638
|
+
let completedJobs = 0;
|
|
639
|
+
let failedJobs = 0;
|
|
640
|
+
|
|
641
|
+
const getProgressSnapshot = (): AgentProgress[] => {
|
|
642
|
+
return Array.from(progressByTaskId.values())
|
|
643
|
+
.sort((a, b) => a.index - b.index)
|
|
644
|
+
.map(progress => structuredClone(progress));
|
|
645
|
+
};
|
|
646
|
+
|
|
647
|
+
const buildAsyncDetails = (state: "running" | "completed" | "failed", jobId: string): TaskToolDetails => ({
|
|
648
|
+
projectAgentsDir: null,
|
|
649
|
+
results: [],
|
|
650
|
+
totalDurationMs: 0,
|
|
651
|
+
progress: getProgressSnapshot(),
|
|
652
|
+
async: { state, jobId, type: "task" },
|
|
653
|
+
});
|
|
654
|
+
|
|
655
|
+
const emitAsyncUpdate = (state: "running" | "completed" | "failed", text: string): void => {
|
|
656
|
+
const primaryJobId = startedJobs[0]?.jobId ?? "task";
|
|
657
|
+
onUpdate?.({
|
|
658
|
+
content: [{ type: "text", text }],
|
|
659
|
+
details: buildAsyncDetails(state, primaryJobId),
|
|
660
|
+
});
|
|
661
|
+
};
|
|
662
|
+
|
|
663
|
+
const maxConcurrency = this.session.settings.get("task.maxConcurrency");
|
|
664
|
+
if (typeof manager.setResumeRunner === "function") {
|
|
665
|
+
manager.setResumeRunner((_subagentId, message, resumeDescriptor) => {
|
|
666
|
+
const descriptor = isTaskResumeDescriptor(resumeDescriptor?.data) ? resumeDescriptor.data : undefined;
|
|
667
|
+
if (!descriptor) return undefined;
|
|
668
|
+
const forkSeeds = descriptor.forkContextSeed
|
|
669
|
+
? new Map([[descriptor.task.id, descriptor.forkContextSeed]])
|
|
670
|
+
: undefined;
|
|
671
|
+
return manager.register(
|
|
672
|
+
"task",
|
|
673
|
+
descriptor.task.id,
|
|
674
|
+
async ({ signal: runSignal }) => {
|
|
675
|
+
const result = await this.#executeSync(
|
|
676
|
+
descriptor.toolCallId,
|
|
677
|
+
{ ...descriptor.params, tasks: [descriptor.task] },
|
|
678
|
+
runSignal,
|
|
679
|
+
undefined,
|
|
680
|
+
[descriptor.task.id],
|
|
681
|
+
forkSeeds,
|
|
682
|
+
{
|
|
683
|
+
runMode: message ? "message" : "resume",
|
|
684
|
+
resumeMessage: message,
|
|
685
|
+
sessionFiles: new Map([[descriptor.task.id, descriptor.sessionFile]]),
|
|
686
|
+
},
|
|
687
|
+
);
|
|
688
|
+
const finalText = result.content.find(part => part.type === "text")?.text ?? "(no output)";
|
|
689
|
+
const singleResult = result.details?.results[0];
|
|
690
|
+
return singleResult?.paused ? { kind: "paused" } : finalText;
|
|
691
|
+
},
|
|
692
|
+
{
|
|
693
|
+
id: `${descriptor.task.id}-resume-${Snowflake.next()}`,
|
|
694
|
+
ownerId: this.session.getAgentId?.() ?? undefined,
|
|
695
|
+
metadata: {
|
|
696
|
+
subagent: {
|
|
697
|
+
id: descriptor.task.id,
|
|
698
|
+
agent: descriptor.params.agent,
|
|
699
|
+
agentSource: descriptor.agentSource,
|
|
700
|
+
description: descriptor.task.description,
|
|
701
|
+
assignment: descriptor.task.assignment.trim(),
|
|
702
|
+
},
|
|
703
|
+
},
|
|
704
|
+
},
|
|
705
|
+
);
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
const semaphore = new Semaphore(maxConcurrency);
|
|
709
|
+
const buildForkContextSeedForTask = async (task: TaskItem): Promise<ForkContextSeed | undefined> => {
|
|
710
|
+
if (params.agent === "executor") return undefined;
|
|
711
|
+
if (!requestsForkContext(task)) return undefined;
|
|
712
|
+
if (!this.session.buildForkContextSeed) {
|
|
713
|
+
throw new Error("Current session cannot build fork-context seeds.");
|
|
714
|
+
}
|
|
715
|
+
const configuredMaxMessages = this.session.settings.has("task.forkContext.maxMessages")
|
|
716
|
+
? this.session.settings.get("task.forkContext.maxMessages")
|
|
717
|
+
: undefined;
|
|
718
|
+
const configuredMaxTokens = this.session.settings.get("task.forkContext.maxTokens");
|
|
719
|
+
const seedParams = resolveForkSeedParamsForMode(
|
|
720
|
+
task.inheritContext,
|
|
721
|
+
configuredMaxMessages,
|
|
722
|
+
configuredMaxTokens,
|
|
723
|
+
this.session.model,
|
|
724
|
+
);
|
|
725
|
+
if (!seedParams) return undefined;
|
|
726
|
+
return await this.session.buildForkContextSeed({
|
|
727
|
+
...seedParams,
|
|
728
|
+
signal,
|
|
729
|
+
});
|
|
730
|
+
};
|
|
731
|
+
const frozenForkSeeds = new Map<string, ForkContextSeed>();
|
|
732
|
+
const parentSessionFileForBatch = this.session.getSessionFile();
|
|
733
|
+
const batchArtifactsDir = parentSessionFileForBatch ? parentSessionFileForBatch.slice(0, -6) : null;
|
|
734
|
+
|
|
735
|
+
for (let i = 0; i < taskItems.length; i++) {
|
|
736
|
+
const taskItem = taskItems[i];
|
|
737
|
+
if (signal?.aborted) {
|
|
738
|
+
failedSchedules.push(`${taskItem.id}: cancelled before scheduling`);
|
|
739
|
+
const progress = progressByTaskId.get(taskItem.id);
|
|
740
|
+
if (progress) {
|
|
741
|
+
progress.status = "aborted";
|
|
742
|
+
}
|
|
743
|
+
continue;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
const uniqueId = validateAllocatedTaskId(uniqueIds[i] ?? "");
|
|
747
|
+
const frozenForkSeed = await buildForkContextSeedForTask(taskItem);
|
|
748
|
+
if (frozenForkSeed) frozenForkSeeds.set(uniqueId, frozenForkSeed);
|
|
749
|
+
const singleParams: TaskParams = { ...params, tasks: [taskItem] };
|
|
750
|
+
const label = uniqueId;
|
|
751
|
+
try {
|
|
752
|
+
const subtaskSessionFile = batchArtifactsDir ? path.join(batchArtifactsDir, `${uniqueId}.jsonl`) : null;
|
|
753
|
+
const jobId = manager.register(
|
|
754
|
+
"task",
|
|
755
|
+
label,
|
|
756
|
+
async ({ signal: runSignal, reportProgress }) => {
|
|
757
|
+
const startedAt = Date.now();
|
|
758
|
+
const progress = progressByTaskId.get(taskItem.id);
|
|
759
|
+
await semaphore.acquire();
|
|
760
|
+
if (runSignal.aborted) {
|
|
761
|
+
semaphore.release();
|
|
762
|
+
if (progress) {
|
|
763
|
+
progress.status = "aborted";
|
|
764
|
+
}
|
|
765
|
+
throw new Error("Aborted before execution");
|
|
766
|
+
}
|
|
767
|
+
if (progress) {
|
|
768
|
+
progress.status = "running";
|
|
769
|
+
}
|
|
770
|
+
await reportProgress(
|
|
771
|
+
`Running background task ${taskItem.id}...`,
|
|
772
|
+
buildAsyncDetails("running", startedJobs[0]?.jobId ?? label) as unknown as Record<string, unknown>,
|
|
773
|
+
);
|
|
774
|
+
try {
|
|
775
|
+
const result = await this.#executeSync(
|
|
776
|
+
_toolCallId,
|
|
777
|
+
singleParams,
|
|
778
|
+
runSignal,
|
|
779
|
+
undefined,
|
|
780
|
+
[uniqueId],
|
|
781
|
+
frozenForkSeeds,
|
|
782
|
+
{
|
|
783
|
+
sessionFiles: new Map([[uniqueId, subtaskSessionFile]]),
|
|
784
|
+
},
|
|
785
|
+
);
|
|
786
|
+
const finalText = result.content.find(part => part.type === "text")?.text ?? "(no output)";
|
|
787
|
+
const singleResult = result.details?.results[0];
|
|
788
|
+
if (progress) {
|
|
789
|
+
progress.status = singleResult?.paused
|
|
790
|
+
? "paused"
|
|
791
|
+
: singleResult?.aborted
|
|
792
|
+
? "aborted"
|
|
793
|
+
: singleResult?.status === "completed"
|
|
794
|
+
? "completed"
|
|
795
|
+
: "failed";
|
|
796
|
+
progress.durationMs = singleResult?.durationMs ?? Math.max(0, Date.now() - startedAt);
|
|
797
|
+
progress.tokens = singleResult?.tokens ?? 0;
|
|
798
|
+
progress.contextTokens = singleResult?.contextTokens;
|
|
799
|
+
progress.contextWindow = singleResult?.contextWindow;
|
|
800
|
+
progress.cost = singleResult?.usage?.cost.total ?? 0;
|
|
801
|
+
progress.extractedToolData = undefined;
|
|
802
|
+
progress.retryFailure = singleResult?.retryFailure
|
|
803
|
+
? {
|
|
804
|
+
attempt: singleResult.retryFailure.attempt,
|
|
805
|
+
errorMessage: singleResult.retryFailure.errorSummary,
|
|
806
|
+
}
|
|
807
|
+
: undefined;
|
|
808
|
+
progress.retryState = undefined;
|
|
809
|
+
}
|
|
810
|
+
completedJobs += 1;
|
|
811
|
+
if (singleResult && ((singleResult.aborted ?? false) || singleResult.exitCode !== 0)) {
|
|
812
|
+
failedJobs += 1;
|
|
813
|
+
}
|
|
814
|
+
const remaining = taskItems.length - completedJobs;
|
|
815
|
+
const isDone = remaining === 0;
|
|
816
|
+
await reportProgress(
|
|
817
|
+
isDone
|
|
818
|
+
? `Background task batch complete: ${completedJobs}/${taskItems.length} finished.`
|
|
819
|
+
: `Background task batch progress: ${completedJobs}/${taskItems.length} finished (${remaining} running).`,
|
|
820
|
+
buildAsyncDetails(
|
|
821
|
+
isDone ? (failedJobs > 0 || failedSchedules.length > 0 ? "failed" : "completed") : "running",
|
|
822
|
+
startedJobs[0]?.jobId ?? label,
|
|
823
|
+
) as unknown as Record<string, unknown>,
|
|
824
|
+
);
|
|
825
|
+
if (isDone) {
|
|
826
|
+
emitAsyncUpdate(
|
|
827
|
+
failedJobs > 0 || failedSchedules.length > 0 ? "failed" : "completed",
|
|
828
|
+
`Background task batch complete: ${completedJobs}/${taskItems.length} finished.`,
|
|
829
|
+
);
|
|
830
|
+
}
|
|
831
|
+
if (singleResult?.paused) {
|
|
832
|
+
return { kind: "paused" };
|
|
833
|
+
}
|
|
834
|
+
return finalText;
|
|
835
|
+
} catch (error) {
|
|
836
|
+
if (progress) {
|
|
837
|
+
progress.status = "failed";
|
|
838
|
+
progress.durationMs = Math.max(0, Date.now() - startedAt);
|
|
839
|
+
}
|
|
840
|
+
completedJobs += 1;
|
|
841
|
+
failedJobs += 1;
|
|
842
|
+
const remaining = taskItems.length - completedJobs;
|
|
843
|
+
const isDone = remaining === 0;
|
|
844
|
+
await reportProgress(
|
|
845
|
+
isDone
|
|
846
|
+
? `Background task batch complete with failures: ${failedJobs} failed.`
|
|
847
|
+
: `Background task batch progress: ${completedJobs}/${taskItems.length} finished (${remaining} running).`,
|
|
848
|
+
buildAsyncDetails(
|
|
849
|
+
isDone ? "failed" : "running",
|
|
850
|
+
startedJobs[0]?.jobId ?? label,
|
|
851
|
+
) as unknown as Record<string, unknown>,
|
|
852
|
+
);
|
|
853
|
+
if (isDone) {
|
|
854
|
+
emitAsyncUpdate(
|
|
855
|
+
"failed",
|
|
856
|
+
`Background task batch complete with failures: ${failedJobs} failed.`,
|
|
857
|
+
);
|
|
858
|
+
}
|
|
859
|
+
throw error;
|
|
860
|
+
} finally {
|
|
861
|
+
semaphore.release();
|
|
862
|
+
}
|
|
863
|
+
},
|
|
864
|
+
{
|
|
865
|
+
id: label,
|
|
866
|
+
ownerId: this.session.getAgentId?.() ?? undefined,
|
|
867
|
+
metadata: {
|
|
868
|
+
subagent: {
|
|
869
|
+
id: uniqueId,
|
|
870
|
+
agent: params.agent,
|
|
871
|
+
agentSource: fallbackAgentSource,
|
|
872
|
+
description: taskItem.description,
|
|
873
|
+
assignment: taskItem.assignment.trim(),
|
|
874
|
+
},
|
|
875
|
+
},
|
|
876
|
+
onProgress: (text, details) => {
|
|
877
|
+
const progressDetails =
|
|
878
|
+
(details as TaskToolDetails | undefined) ??
|
|
879
|
+
buildAsyncDetails("running", startedJobs[0]?.jobId ?? label);
|
|
880
|
+
onUpdate?.({ content: [{ type: "text", text }], details: progressDetails });
|
|
881
|
+
},
|
|
882
|
+
},
|
|
883
|
+
);
|
|
884
|
+
startedJobs.push({ jobId, taskId: taskItem.id });
|
|
885
|
+
if (typeof manager.registerResumeDescriptor === "function") {
|
|
886
|
+
manager.registerResumeDescriptor({
|
|
887
|
+
subagentId: uniqueId,
|
|
888
|
+
ownerId: this.session.getAgentId?.() ?? undefined,
|
|
889
|
+
data: {
|
|
890
|
+
toolCallId: _toolCallId,
|
|
891
|
+
params,
|
|
892
|
+
task: { ...taskItem, id: uniqueId },
|
|
893
|
+
sessionFile: subtaskSessionFile,
|
|
894
|
+
forkContextSeed: frozenForkSeed,
|
|
895
|
+
agentSource: fallbackAgentSource,
|
|
896
|
+
} satisfies TaskResumeDescriptor,
|
|
897
|
+
});
|
|
898
|
+
}
|
|
899
|
+
if (typeof manager.registerSubagentRecord === "function") {
|
|
900
|
+
manager.registerSubagentRecord({
|
|
901
|
+
subagentId: uniqueId,
|
|
902
|
+
ownerId: this.session.getAgentId?.() ?? undefined,
|
|
903
|
+
currentJobId: jobId,
|
|
904
|
+
historicalJobIds: [],
|
|
905
|
+
status: manager.getJob(jobId)?.status ?? "running",
|
|
906
|
+
sessionFile: subtaskSessionFile,
|
|
907
|
+
resumable: !!batchArtifactsDir,
|
|
908
|
+
});
|
|
909
|
+
}
|
|
910
|
+
} catch (error) {
|
|
911
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
912
|
+
failedSchedules.push(`${taskItem.id}: ${message}`);
|
|
913
|
+
const progress = progressByTaskId.get(taskItem.id);
|
|
914
|
+
if (progress) {
|
|
915
|
+
progress.status = "failed";
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
if (startedJobs.length === 0) {
|
|
921
|
+
const failureText = `Failed to start background task jobs: ${failedSchedules.join("; ")}`;
|
|
922
|
+
return {
|
|
923
|
+
content: [{ type: "text", text: failureText }],
|
|
924
|
+
details: { projectAgentsDir: null, results: [], totalDurationMs: 0 },
|
|
925
|
+
};
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
emitAsyncUpdate(
|
|
929
|
+
"running",
|
|
930
|
+
`Launching ${startedJobs.length} background ${startedJobs.length === 1 ? "task" : "tasks"}...`,
|
|
931
|
+
);
|
|
932
|
+
|
|
933
|
+
const scheduleFailureSummary =
|
|
934
|
+
failedSchedules.length > 0
|
|
935
|
+
? ` Failed to schedule ${failedSchedules.length} task${failedSchedules.length === 1 ? "" : "s"}.`
|
|
936
|
+
: "";
|
|
937
|
+
|
|
938
|
+
const ircEnabled = this.session.settings.get("irc.enabled") === true;
|
|
939
|
+
const taskIdByItemId = new Map<string, string>();
|
|
940
|
+
for (let i = 0; i < taskItems.length; i++) {
|
|
941
|
+
taskIdByItemId.set(taskItems[i].id, uniqueIds[i]);
|
|
942
|
+
}
|
|
943
|
+
const startedListing = startedJobs
|
|
944
|
+
.map(({ taskId, jobId }) => {
|
|
945
|
+
const id = taskIdByItemId.get(taskId) ?? taskId;
|
|
946
|
+
const desc = progressByTaskId.get(taskId)?.description;
|
|
947
|
+
const prefix = `- \`${id}\` (job \`${jobId}\`)`;
|
|
948
|
+
return desc ? `${prefix} — ${desc}` : prefix;
|
|
949
|
+
})
|
|
950
|
+
.join("\n");
|
|
951
|
+
const coordinationHint = ircEnabled
|
|
952
|
+
? ` DM these ids via \`irc\` to coordinate while they run. Use \`subagent\` to list, inspect, or await with a timeout; a timeout only bounds your wait and is never a cancellation reason. Cancel only when the subagent has actually failed, gone off-track, or become unrecoverably wrong; \`job\` remains available for generic background jobs.`
|
|
953
|
+
: ` Use \`subagent\` to list, inspect, or await with a timeout; a timeout only bounds your wait and is never a cancellation reason. Cancel only when the subagent has actually failed, gone off-track, or become unrecoverably wrong; \`job\` remains available for generic background jobs.`;
|
|
954
|
+
|
|
955
|
+
return {
|
|
956
|
+
content: [
|
|
957
|
+
{
|
|
958
|
+
type: "text",
|
|
959
|
+
text: `Started ${startedJobs.length} background task job${startedJobs.length === 1 ? "" : "s"} using ${params.agent}.${scheduleFailureSummary} Results will be delivered when complete.\n${startedListing}\n${coordinationHint}`,
|
|
960
|
+
},
|
|
961
|
+
],
|
|
962
|
+
details: {
|
|
963
|
+
projectAgentsDir: null,
|
|
964
|
+
results: [],
|
|
965
|
+
totalDurationMs: 0,
|
|
966
|
+
progress: getProgressSnapshot(),
|
|
967
|
+
async: { state: "running", jobId: startedJobs[0].jobId, type: "task" },
|
|
968
|
+
},
|
|
969
|
+
};
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
async #executeSync(
|
|
973
|
+
_toolCallId: string,
|
|
974
|
+
params: TaskParams,
|
|
975
|
+
signal?: AbortSignal,
|
|
976
|
+
onUpdate?: AgentToolUpdateCallback<TaskToolDetails>,
|
|
977
|
+
preAllocatedIds?: string[],
|
|
978
|
+
prebuiltForkContextSeeds?: ReadonlyMap<string, ForkContextSeed>,
|
|
979
|
+
executionOverrides?: {
|
|
980
|
+
runMode?: "initial" | "resume" | "message";
|
|
981
|
+
resumeMessage?: string;
|
|
982
|
+
sessionFiles?: ReadonlyMap<string, string | null>;
|
|
983
|
+
},
|
|
984
|
+
): Promise<AgentToolResult<TaskToolDetails>> {
|
|
985
|
+
const startTime = Date.now();
|
|
986
|
+
const { agents, projectAgentsDir } = await discoverAgents(this.session.cwd);
|
|
987
|
+
const { agent: requestedAgentName, context, schema: outputSchema } = params;
|
|
988
|
+
const agentName = requestedAgentName === "executor_ext" ? "executor_ext" : requestedAgentName;
|
|
989
|
+
const agentLookupName = requestedAgentName === "executor_ext" ? "executor" : requestedAgentName;
|
|
990
|
+
const simpleMode = this.#getTaskSimpleMode();
|
|
991
|
+
const { contextEnabled, customSchemaEnabled } = getTaskSimpleModeCapabilities(simpleMode);
|
|
992
|
+
const sharedContext = contextEnabled ? context?.trim() : undefined;
|
|
993
|
+
const isolationMode = this.session.settings.get("task.isolation.mode");
|
|
994
|
+
const isolationRequested = "isolated" in params ? params.isolated === true : false;
|
|
995
|
+
const isIsolated = isolationMode !== "none" && isolationRequested;
|
|
996
|
+
const mergeMode = this.session.settings.get("task.isolation.merge");
|
|
997
|
+
const commitStyle = this.session.settings.get("task.isolation.commits");
|
|
998
|
+
const maxConcurrency = this.session.settings.get("task.maxConcurrency");
|
|
999
|
+
const taskDepth = this.session.taskDepth ?? 0;
|
|
1000
|
+
const subagentLspEnabled = (this.session.enableLsp ?? true) && this.session.settings.get("task.enableLsp");
|
|
1001
|
+
|
|
1002
|
+
if (isolationMode === "none" && "isolated" in params) {
|
|
1003
|
+
return {
|
|
1004
|
+
content: [
|
|
1005
|
+
{
|
|
1006
|
+
type: "text",
|
|
1007
|
+
text: "Task isolation is disabled.",
|
|
1008
|
+
},
|
|
1009
|
+
],
|
|
1010
|
+
details: {
|
|
1011
|
+
projectAgentsDir,
|
|
1012
|
+
results: [],
|
|
1013
|
+
totalDurationMs: 0,
|
|
1014
|
+
},
|
|
1015
|
+
};
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
// Validate agent exists
|
|
1019
|
+
const agent = getAgent(agents, agentLookupName);
|
|
1020
|
+
if (!agent) {
|
|
1021
|
+
const available =
|
|
1022
|
+
filterVisibleAgents(agents)
|
|
1023
|
+
.map(a => a.name)
|
|
1024
|
+
.join(", ") || "none";
|
|
1025
|
+
return {
|
|
1026
|
+
content: [
|
|
1027
|
+
{
|
|
1028
|
+
type: "text",
|
|
1029
|
+
text: `Unknown agent "${agentName}". Available: ${available}`,
|
|
1030
|
+
},
|
|
1031
|
+
],
|
|
1032
|
+
details: {
|
|
1033
|
+
projectAgentsDir,
|
|
1034
|
+
results: [],
|
|
1035
|
+
totalDurationMs: 0,
|
|
1036
|
+
},
|
|
1037
|
+
};
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
// Check if agent is disabled in settings
|
|
1041
|
+
const disabledAgents = this.session.settings.get("task.disabledAgents") as string[];
|
|
1042
|
+
if (disabledAgents.length > 0 && disabledAgents.includes(agentName)) {
|
|
1043
|
+
const enabled = filterVisibleAgents(agents)
|
|
1044
|
+
.filter(a => !disabledAgents.includes(a.name))
|
|
1045
|
+
.map(a => a.name);
|
|
1046
|
+
return {
|
|
1047
|
+
content: [
|
|
1048
|
+
{
|
|
1049
|
+
type: "text",
|
|
1050
|
+
text: `Agent "${agentName}" is disabled in settings. Enable it via /agents, or use a different agent type.${enabled.length > 0 ? ` Available: ${enabled.join(", ")}` : ""}`,
|
|
1051
|
+
},
|
|
1052
|
+
],
|
|
1053
|
+
details: {
|
|
1054
|
+
projectAgentsDir,
|
|
1055
|
+
results: [],
|
|
1056
|
+
totalDurationMs: 0,
|
|
1057
|
+
},
|
|
1058
|
+
};
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
const forkContextValidationError = validateForkContextRequests(
|
|
1062
|
+
params.tasks ?? [],
|
|
1063
|
+
agent,
|
|
1064
|
+
this.session.settings.get("task.forkContext.enabled"),
|
|
1065
|
+
);
|
|
1066
|
+
if (forkContextValidationError) {
|
|
1067
|
+
return createTaskModeError(forkContextValidationError);
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
const planModeState = this.session.getPlanModeState?.();
|
|
1071
|
+
const planModeTools = ["read", "search", "find", "lsp", "web_search"];
|
|
1072
|
+
const planModeAgent: typeof agent = planModeState?.enabled
|
|
1073
|
+
? {
|
|
1074
|
+
...agent,
|
|
1075
|
+
systemPrompt: `${planModeSubagentPrompt}\n\n${agent.systemPrompt}`,
|
|
1076
|
+
tools: planModeTools,
|
|
1077
|
+
spawns: undefined,
|
|
1078
|
+
}
|
|
1079
|
+
: agent;
|
|
1080
|
+
const effectiveAgent: typeof agent =
|
|
1081
|
+
agentName === "executor"
|
|
1082
|
+
? {
|
|
1083
|
+
...planModeAgent,
|
|
1084
|
+
systemPrompt: `${planModeAgent.systemPrompt}\n\n${executorSelfForkPrompt}`,
|
|
1085
|
+
}
|
|
1086
|
+
: planModeAgent;
|
|
1087
|
+
|
|
1088
|
+
// Apply per-agent model override from settings (highest priority)
|
|
1089
|
+
const agentModelOverrides = this.session.settings.get("task.agentModelOverrides");
|
|
1090
|
+
const settingsModelOverride =
|
|
1091
|
+
agentName === "executor"
|
|
1092
|
+
? undefined
|
|
1093
|
+
: agentName === "executor_ext"
|
|
1094
|
+
? (agentModelOverrides.executor_ext ?? agentModelOverrides.executor)
|
|
1095
|
+
: agentModelOverrides[agentName];
|
|
1096
|
+
const parentActiveModelPattern = this.session.getActiveModelString?.();
|
|
1097
|
+
const modelOverride = resolveAgentModelPatterns({
|
|
1098
|
+
settingsOverride: settingsModelOverride,
|
|
1099
|
+
agentModel: effectiveAgent.model,
|
|
1100
|
+
settings: this.session.settings,
|
|
1101
|
+
activeModelPattern: parentActiveModelPattern,
|
|
1102
|
+
fallbackModelPattern: this.session.getModelString?.(),
|
|
1103
|
+
});
|
|
1104
|
+
const thinkingLevelOverride = effectiveAgent.thinkingLevel;
|
|
1105
|
+
|
|
1106
|
+
// Output schema priority: task call > agent frontmatter > inherited parent session.
|
|
1107
|
+
// task.simple can disable the task-call override while leaving agent/session schemas intact.
|
|
1108
|
+
const effectiveOutputSchema = customSchemaEnabled
|
|
1109
|
+
? (outputSchema ?? effectiveAgent.output ?? this.session.outputSchema)
|
|
1110
|
+
: (effectiveAgent.output ?? this.session.outputSchema);
|
|
1111
|
+
|
|
1112
|
+
// Handle empty or missing tasks
|
|
1113
|
+
if (!params.tasks || params.tasks.length === 0) {
|
|
1114
|
+
return {
|
|
1115
|
+
content: [
|
|
1116
|
+
{
|
|
1117
|
+
type: "text",
|
|
1118
|
+
text: contextEnabled
|
|
1119
|
+
? "No tasks provided. Use: { agent, context?, tasks: [{ id, description, assignment }, ...] }"
|
|
1120
|
+
: "No tasks provided. Use: { agent, tasks: [{ id, description, assignment }, ...] }",
|
|
1121
|
+
},
|
|
1122
|
+
],
|
|
1123
|
+
details: {
|
|
1124
|
+
projectAgentsDir,
|
|
1125
|
+
results: [],
|
|
1126
|
+
totalDurationMs: 0,
|
|
1127
|
+
},
|
|
1128
|
+
};
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
const tasks = params.tasks;
|
|
1132
|
+
const missingTaskIndexes: number[] = [];
|
|
1133
|
+
const idIndexes = new Map<string, number[]>();
|
|
1134
|
+
|
|
1135
|
+
for (let i = 0; i < tasks.length; i++) {
|
|
1136
|
+
const id = tasks[i]?.id;
|
|
1137
|
+
if (typeof id !== "string" || id.trim() === "") {
|
|
1138
|
+
missingTaskIndexes.push(i);
|
|
1139
|
+
continue;
|
|
1140
|
+
}
|
|
1141
|
+
const normalizedId = id.toLowerCase();
|
|
1142
|
+
const indexes = idIndexes.get(normalizedId);
|
|
1143
|
+
if (indexes) {
|
|
1144
|
+
indexes.push(i);
|
|
1145
|
+
} else {
|
|
1146
|
+
idIndexes.set(normalizedId, [i]);
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
const duplicateIds: Array<{ id: string; indexes: number[] }> = [];
|
|
1151
|
+
for (const [normalizedId, indexes] of idIndexes.entries()) {
|
|
1152
|
+
if (indexes.length > 1) {
|
|
1153
|
+
duplicateIds.push({
|
|
1154
|
+
id: tasks[indexes[0]]?.id ?? normalizedId,
|
|
1155
|
+
indexes,
|
|
1156
|
+
});
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
if (missingTaskIndexes.length > 0 || duplicateIds.length > 0) {
|
|
1161
|
+
const problems: string[] = [];
|
|
1162
|
+
if (missingTaskIndexes.length > 0) {
|
|
1163
|
+
problems.push(`Missing task ids at indexes: ${missingTaskIndexes.join(", ")}`);
|
|
1164
|
+
}
|
|
1165
|
+
if (duplicateIds.length > 0) {
|
|
1166
|
+
const details = duplicateIds.map(entry => `${entry.id} (indexes ${entry.indexes.join(", ")})`).join("; ");
|
|
1167
|
+
problems.push(`Duplicate task ids detected (case-insensitive): ${details}`);
|
|
1168
|
+
}
|
|
1169
|
+
return {
|
|
1170
|
+
content: [{ type: "text", text: `Invalid tasks: ${problems.join(". ")}` }],
|
|
1171
|
+
details: {
|
|
1172
|
+
projectAgentsDir,
|
|
1173
|
+
results: [],
|
|
1174
|
+
totalDurationMs: 0,
|
|
1175
|
+
},
|
|
1176
|
+
};
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
const batchGateDecision = evaluateSpawnGate({ childCount: tasks.length, plan: params.spawnPlan });
|
|
1180
|
+
if (batchGateDecision.outcome === "rejected") {
|
|
1181
|
+
return {
|
|
1182
|
+
content: [
|
|
1183
|
+
{
|
|
1184
|
+
type: "text",
|
|
1185
|
+
text: `Task spawn gate rejected this batch: ${batchGateDecision.reason}. Batches with more than ${DEFAULT_SPAWN_THRESHOLD} tasks require spawnPlan fields: ${batchGateDecision.missingFields.join(", ")}.`,
|
|
1186
|
+
},
|
|
1187
|
+
],
|
|
1188
|
+
details: {
|
|
1189
|
+
projectAgentsDir,
|
|
1190
|
+
results: [],
|
|
1191
|
+
totalDurationMs: Date.now() - startTime,
|
|
1192
|
+
},
|
|
1193
|
+
};
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
const reviewerExploreDecision = evaluateReviewerExploreGate({
|
|
1197
|
+
spawningAgentType: this.#spawningAgentType,
|
|
1198
|
+
targetAgent: agentName,
|
|
1199
|
+
plan: params.spawnPlan,
|
|
1200
|
+
});
|
|
1201
|
+
if (reviewerExploreDecision.outcome === "rejected") {
|
|
1202
|
+
return {
|
|
1203
|
+
content: [
|
|
1204
|
+
{
|
|
1205
|
+
type: "text",
|
|
1206
|
+
text: `Task spawn gate rejected reviewer->explore: ${reviewerExploreDecision.reason}. Provide spawnPlan fields: ${reviewerExploreDecision.missingFields.join(", ")}.`,
|
|
1207
|
+
},
|
|
1208
|
+
],
|
|
1209
|
+
details: {
|
|
1210
|
+
projectAgentsDir,
|
|
1211
|
+
results: [],
|
|
1212
|
+
totalDurationMs: Date.now() - startTime,
|
|
1213
|
+
},
|
|
1214
|
+
};
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
let repoRoot: string | null = null;
|
|
1218
|
+
let baseline: WorktreeBaseline | null = null;
|
|
1219
|
+
if (isIsolated) {
|
|
1220
|
+
try {
|
|
1221
|
+
repoRoot = await getRepoRoot(this.session.cwd);
|
|
1222
|
+
baseline = await captureBaseline(repoRoot);
|
|
1223
|
+
} catch (err) {
|
|
1224
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
1225
|
+
return {
|
|
1226
|
+
content: [
|
|
1227
|
+
{
|
|
1228
|
+
type: "text",
|
|
1229
|
+
text: `Isolated task execution requires a git repository. ${message}`,
|
|
1230
|
+
},
|
|
1231
|
+
],
|
|
1232
|
+
details: {
|
|
1233
|
+
projectAgentsDir,
|
|
1234
|
+
results: [],
|
|
1235
|
+
totalDurationMs: Date.now() - startTime,
|
|
1236
|
+
},
|
|
1237
|
+
};
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
const preferredIsolationBackend = parseIsolationMode(isolationMode);
|
|
1242
|
+
|
|
1243
|
+
// Derive artifacts directory
|
|
1244
|
+
const sessionFile = this.session.getSessionFile();
|
|
1245
|
+
const artifactsDir = sessionFile ? sessionFile.slice(0, -6) : null;
|
|
1246
|
+
const tempArtifactsDir = artifactsDir ? null : path.join(os.tmpdir(), `gjc-task-${Snowflake.next()}`);
|
|
1247
|
+
const effectiveArtifactsDir = artifactsDir || tempArtifactsDir!;
|
|
1248
|
+
|
|
1249
|
+
// Share the parent session's local:// root with subagents so they read/write the same scratch space
|
|
1250
|
+
const localProtocolOptions: LocalProtocolOptions = {
|
|
1251
|
+
getArtifactsDir: this.session.getArtifactsDir ?? (() => null),
|
|
1252
|
+
getSessionId: this.session.getSessionId ?? (() => null),
|
|
1253
|
+
};
|
|
1254
|
+
|
|
1255
|
+
// Subagents adopt the parent's ArtifactManager so artifact IDs are unique
|
|
1256
|
+
// across the whole tree and outputs land flat in the parent's dir.
|
|
1257
|
+
const parentArtifactManager = this.session.getArtifactManager?.() ?? undefined;
|
|
1258
|
+
|
|
1259
|
+
// Initialize progress tracking
|
|
1260
|
+
const progressMap = new Map<number, AgentProgress>();
|
|
1261
|
+
|
|
1262
|
+
// Update callback
|
|
1263
|
+
const emitProgress = () => {
|
|
1264
|
+
const progress = Array.from(progressMap.values()).sort((a, b) => a.index - b.index);
|
|
1265
|
+
onUpdate?.({
|
|
1266
|
+
content: [{ type: "text", text: `Running ${params.tasks.length} agents...` }],
|
|
1267
|
+
details: {
|
|
1268
|
+
projectAgentsDir,
|
|
1269
|
+
results: [],
|
|
1270
|
+
totalDurationMs: Date.now() - startTime,
|
|
1271
|
+
progress,
|
|
1272
|
+
},
|
|
1273
|
+
});
|
|
1274
|
+
};
|
|
1275
|
+
|
|
1276
|
+
try {
|
|
1277
|
+
// Check self-recursion prevention
|
|
1278
|
+
if (this.#blockedAgent && agentName === this.#blockedAgent) {
|
|
1279
|
+
return {
|
|
1280
|
+
content: [
|
|
1281
|
+
{
|
|
1282
|
+
type: "text",
|
|
1283
|
+
text: `Cannot spawn ${this.#blockedAgent} agent from within itself (recursion prevention). Use a different agent type.`,
|
|
1284
|
+
},
|
|
1285
|
+
],
|
|
1286
|
+
details: {
|
|
1287
|
+
projectAgentsDir,
|
|
1288
|
+
results: [],
|
|
1289
|
+
totalDurationMs: Date.now() - startTime,
|
|
1290
|
+
},
|
|
1291
|
+
};
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
// Check spawn restrictions from parent
|
|
1295
|
+
const parentSpawns = this.session.getSessionSpawns() ?? "*";
|
|
1296
|
+
const allowedSpawns = parentSpawns.split(",").map(s => s.trim());
|
|
1297
|
+
const isSpawnAllowed = (): boolean => {
|
|
1298
|
+
if (parentSpawns === "") return false; // Empty = deny all
|
|
1299
|
+
if (parentSpawns === "*") return true; // Wildcard = allow all
|
|
1300
|
+
return allowedSpawns.includes(agentName);
|
|
1301
|
+
};
|
|
1302
|
+
|
|
1303
|
+
if (!isSpawnAllowed()) {
|
|
1304
|
+
const allowed =
|
|
1305
|
+
parentSpawns === ""
|
|
1306
|
+
? "none (spawns disabled for this agent)"
|
|
1307
|
+
: filterVisibleAgents(agents)
|
|
1308
|
+
.filter(candidate => allowedSpawns.includes(candidate.name))
|
|
1309
|
+
.map(candidate => candidate.name)
|
|
1310
|
+
.join(", ") || "none";
|
|
1311
|
+
return {
|
|
1312
|
+
content: [{ type: "text", text: `Cannot spawn '${agentName}'. Allowed: ${allowed}` }],
|
|
1313
|
+
details: {
|
|
1314
|
+
projectAgentsDir,
|
|
1315
|
+
results: [],
|
|
1316
|
+
totalDurationMs: Date.now() - startTime,
|
|
1317
|
+
},
|
|
1318
|
+
};
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
// Write parent conversation context for subagents. When IRC is available,
|
|
1322
|
+
// subagents should ask live peers instead of reading a stale markdown dump.
|
|
1323
|
+
await fs.mkdir(effectiveArtifactsDir, { recursive: true });
|
|
1324
|
+
const shouldWriteConversationContext = this.session.settings.get("irc.enabled") !== true;
|
|
1325
|
+
const compactContext = shouldWriteConversationContext ? this.session.getCompactContext?.() : undefined;
|
|
1326
|
+
let contextFilePath: string | undefined;
|
|
1327
|
+
if (compactContext) {
|
|
1328
|
+
contextFilePath = path.join(effectiveArtifactsDir, "context.md");
|
|
1329
|
+
await Bun.write(contextFilePath, compactContext);
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
// Build full prompts with context prepended
|
|
1333
|
+
// Allocate unique IDs across the session to prevent artifact collisions
|
|
1334
|
+
let uniqueIds: string[];
|
|
1335
|
+
if (preAllocatedIds && preAllocatedIds.length === tasks.length) {
|
|
1336
|
+
uniqueIds = preAllocatedIds;
|
|
1337
|
+
} else {
|
|
1338
|
+
const outputManager =
|
|
1339
|
+
this.session.agentOutputManager ?? new AgentOutputManager(this.session.getArtifactsDir ?? (() => null));
|
|
1340
|
+
uniqueIds = await outputManager.allocateBatch(tasks.map(t => t.id));
|
|
1341
|
+
}
|
|
1342
|
+
const tasksWithUniqueIds = tasks.map((t, i) => ({ ...t, id: validateAllocatedTaskId(uniqueIds[i] ?? "") }));
|
|
1343
|
+
|
|
1344
|
+
const availableSkills = [...(this.session.skills ?? [])];
|
|
1345
|
+
// Resolve autoload skills from agent definition against available skills
|
|
1346
|
+
const resolvedAutoloadSkills =
|
|
1347
|
+
agent.autoloadSkills?.length && availableSkills.length > 0
|
|
1348
|
+
? agent.autoloadSkills
|
|
1349
|
+
.map(name => availableSkills.find(s => s.name === name))
|
|
1350
|
+
.filter((s): s is NonNullable<typeof s> => s !== undefined)
|
|
1351
|
+
: [];
|
|
1352
|
+
const contextFiles = this.session.contextFiles;
|
|
1353
|
+
const promptTemplates = this.session.promptTemplates;
|
|
1354
|
+
|
|
1355
|
+
type WorkflowActorRouting =
|
|
1356
|
+
| { kind: "none" }
|
|
1357
|
+
| { kind: "busy"; actor: WorkflowActorRecord }
|
|
1358
|
+
| { kind: "actor"; actor: WorkflowActorRecord; runMode: "initial" | "message" };
|
|
1359
|
+
|
|
1360
|
+
const resolveWorkflowActorForTask = async (
|
|
1361
|
+
task: (typeof tasksWithUniqueIds)[number],
|
|
1362
|
+
modelPattern: string | string[] | undefined,
|
|
1363
|
+
): Promise<WorkflowActorRouting> => {
|
|
1364
|
+
if (executionOverrides?.runMode || executionOverrides?.resumeMessage || agentName === "executor_ext") {
|
|
1365
|
+
return { kind: "none" };
|
|
1366
|
+
}
|
|
1367
|
+
const workflowSessionId = this.session.getSessionId?.();
|
|
1368
|
+
if (!workflowSessionId || !artifactsDir) return { kind: "none" };
|
|
1369
|
+
|
|
1370
|
+
const pabcdState = await readPabcdStateWithFallback(this.session.cwd, workflowSessionId);
|
|
1371
|
+
if (pabcdState?.ok !== true || pabcdState.value.active !== true) {
|
|
1372
|
+
return { kind: "none" };
|
|
1373
|
+
}
|
|
1374
|
+
const phase = pabcdState.value.current_phase;
|
|
1375
|
+
if (!isPabcdActorStage(phase)) return { kind: "none" };
|
|
1376
|
+
const namespaceId = pabcdState.value.ctx?.actor_namespace_id;
|
|
1377
|
+
if (typeof namespaceId !== "string" || namespaceId.length === 0) return { kind: "none" };
|
|
1378
|
+
|
|
1379
|
+
const modelId = firstModelPattern(modelPattern ?? effectiveAgent.model);
|
|
1380
|
+
const actorRoleAgent = agentName === "executor" ? "self-fork" : agentName;
|
|
1381
|
+
const key = buildWorkflowActorKey({
|
|
1382
|
+
namespaceId,
|
|
1383
|
+
workflowSessionId,
|
|
1384
|
+
stage: phase,
|
|
1385
|
+
roleAgent: actorRoleAgent,
|
|
1386
|
+
taskId: task.id,
|
|
1387
|
+
description: task.description,
|
|
1388
|
+
modelId,
|
|
1389
|
+
provider: providerFromModelPattern(modelId),
|
|
1390
|
+
thinkingLevel: thinkingLevelOverride,
|
|
1391
|
+
rolePromptHash: hashTaskValue({
|
|
1392
|
+
prompt: effectiveAgent.systemPrompt,
|
|
1393
|
+
source: effectiveAgent.source,
|
|
1394
|
+
filePath: effectiveAgent.filePath,
|
|
1395
|
+
}),
|
|
1396
|
+
cwdOrWorktree: this.session.cwd,
|
|
1397
|
+
writablePolicy: isIsolated ? `isolated:${mergeMode}` : "workspace",
|
|
1398
|
+
toolSurfaceHash: hashTaskValue({ tools: effectiveAgent.tools ?? [], lsp: subagentLspEnabled }),
|
|
1399
|
+
});
|
|
1400
|
+
|
|
1401
|
+
const registry = await readActorRegistry(this.session.cwd, workflowSessionId);
|
|
1402
|
+
const runningActor = findRunningActor(registry, key);
|
|
1403
|
+
if (runningActor) return { kind: "busy", actor: runningActor };
|
|
1404
|
+
|
|
1405
|
+
const compatibleActor = resolveCompatibleActor(registry, key);
|
|
1406
|
+
if (compatibleActor) return { kind: "actor", actor: compatibleActor, runMode: "message" };
|
|
1407
|
+
|
|
1408
|
+
const actorId = workflowActorId(key);
|
|
1409
|
+
const actor = allocateActorRecord(key, path.join(artifactsDir, `${actorId}.jsonl`));
|
|
1410
|
+
await writeActorRegistryAtomic(this.session.cwd, workflowSessionId, upsertActor(registry, actor));
|
|
1411
|
+
return { kind: "actor", actor, runMode: "initial" };
|
|
1412
|
+
};
|
|
1413
|
+
|
|
1414
|
+
const updateWorkflowActor = async (
|
|
1415
|
+
_actor: WorkflowActorRecord,
|
|
1416
|
+
update: (registry: WorkflowActorRegistry) => WorkflowActorRegistry,
|
|
1417
|
+
): Promise<void> => {
|
|
1418
|
+
const workflowSessionId = this.session.getSessionId?.();
|
|
1419
|
+
if (!workflowSessionId) return;
|
|
1420
|
+
const registry = await readActorRegistry(this.session.cwd, workflowSessionId);
|
|
1421
|
+
await writeActorRegistryAtomic(this.session.cwd, workflowSessionId, update(registry));
|
|
1422
|
+
};
|
|
1423
|
+
|
|
1424
|
+
const maintainWorkflowActorBeforeResume = async (
|
|
1425
|
+
actor: WorkflowActorRecord,
|
|
1426
|
+
): Promise<{ ok: true; cacheAffinity: CacheAffinityMetadata } | { ok: false; reason: string }> => {
|
|
1427
|
+
try {
|
|
1428
|
+
const stat = await fs.stat(actor.sessionFile);
|
|
1429
|
+
if (!stat.isFile()) return { ok: false, reason: "actor session file is not a file" };
|
|
1430
|
+
} catch (error) {
|
|
1431
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1432
|
+
return { ok: false, reason: message || "actor session file is unavailable" };
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
if (actor.needsCompact) {
|
|
1436
|
+
await updateWorkflowActor(actor, registry =>
|
|
1437
|
+
markActorMaintained(registry, actor.id, {
|
|
1438
|
+
compactedAt: new Date().toISOString(),
|
|
1439
|
+
needsCompact: false,
|
|
1440
|
+
}),
|
|
1441
|
+
);
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
return { ok: true, cacheAffinity: { affine: true, reason: "actor_resume", prewarm: "skipped" } };
|
|
1445
|
+
};
|
|
1446
|
+
|
|
1447
|
+
// Initialize progress for all tasks
|
|
1448
|
+
for (let i = 0; i < tasksWithUniqueIds.length; i++) {
|
|
1449
|
+
const taskItem = tasksWithUniqueIds[i];
|
|
1450
|
+
const assignment = taskItem.assignment.trim();
|
|
1451
|
+
progressMap.set(i, {
|
|
1452
|
+
index: i,
|
|
1453
|
+
id: taskItem.id,
|
|
1454
|
+
agent: agentName,
|
|
1455
|
+
agentSource: agent.source,
|
|
1456
|
+
status: "pending",
|
|
1457
|
+
task: renderSubagentUserPrompt(assignment, simpleMode),
|
|
1458
|
+
assignment,
|
|
1459
|
+
recentTools: [],
|
|
1460
|
+
recentOutput: [],
|
|
1461
|
+
toolCount: 0,
|
|
1462
|
+
tokens: 0,
|
|
1463
|
+
cost: 0,
|
|
1464
|
+
durationMs: 0,
|
|
1465
|
+
modelOverride,
|
|
1466
|
+
description: taskItem.description,
|
|
1467
|
+
});
|
|
1468
|
+
}
|
|
1469
|
+
emitProgress();
|
|
1470
|
+
|
|
1471
|
+
const buildForkContextSeed = async (
|
|
1472
|
+
mode: Exclude<ForkContextMode, "none">,
|
|
1473
|
+
): Promise<ForkContextSeed | undefined> => {
|
|
1474
|
+
if (!this.session.buildForkContextSeed) {
|
|
1475
|
+
throw new Error("Current session cannot build fork-context seeds.");
|
|
1476
|
+
}
|
|
1477
|
+
const configuredMaxMessages = this.session.settings.has("task.forkContext.maxMessages")
|
|
1478
|
+
? this.session.settings.get("task.forkContext.maxMessages")
|
|
1479
|
+
: undefined;
|
|
1480
|
+
const configuredMaxTokens = this.session.settings.get("task.forkContext.maxTokens");
|
|
1481
|
+
const params = resolveForkSeedParamsForMode(
|
|
1482
|
+
mode,
|
|
1483
|
+
configuredMaxMessages,
|
|
1484
|
+
configuredMaxTokens,
|
|
1485
|
+
this.session.model,
|
|
1486
|
+
);
|
|
1487
|
+
if (!params) return undefined;
|
|
1488
|
+
return await this.session.buildForkContextSeed({
|
|
1489
|
+
...params,
|
|
1490
|
+
signal,
|
|
1491
|
+
});
|
|
1492
|
+
};
|
|
1493
|
+
|
|
1494
|
+
const runTask = async (
|
|
1495
|
+
task: (typeof tasksWithUniqueIds)[number],
|
|
1496
|
+
index: number,
|
|
1497
|
+
overrides?: {
|
|
1498
|
+
runMode?: "initial" | "resume" | "message";
|
|
1499
|
+
resumeMessage?: string;
|
|
1500
|
+
sessionFile?: string | null;
|
|
1501
|
+
},
|
|
1502
|
+
) => {
|
|
1503
|
+
const userPresets = this.session.settings.get("task.modelPresets") as
|
|
1504
|
+
| Record<string, { best?: string; cheap?: string }>
|
|
1505
|
+
| undefined;
|
|
1506
|
+
const perTaskModel = resolveModelHint(task.model, userPresets);
|
|
1507
|
+
const effectiveModelOverride =
|
|
1508
|
+
agentName === "executor_ext" && perTaskModel && modelOverride.length > 0
|
|
1509
|
+
? [...perTaskModel, ...modelOverride]
|
|
1510
|
+
: (perTaskModel ?? modelOverride);
|
|
1511
|
+
const actorRouting = await resolveWorkflowActorForTask(task, effectiveModelOverride);
|
|
1512
|
+
if (actorRouting.kind === "busy") {
|
|
1513
|
+
return buildActorBusyResult(
|
|
1514
|
+
task,
|
|
1515
|
+
index,
|
|
1516
|
+
agentName,
|
|
1517
|
+
agent.source,
|
|
1518
|
+
effectiveModelOverride,
|
|
1519
|
+
simpleMode,
|
|
1520
|
+
actorRouting.actor,
|
|
1521
|
+
);
|
|
1522
|
+
}
|
|
1523
|
+
let cacheAffinity: CacheAffinityMetadata | undefined =
|
|
1524
|
+
agentName === "executor_ext" ? { affine: false, reason: "executor_ext" } : undefined;
|
|
1525
|
+
if (actorRouting.kind === "actor" && actorRouting.runMode === "message") {
|
|
1526
|
+
const maintenance = await maintainWorkflowActorBeforeResume(actorRouting.actor);
|
|
1527
|
+
if (!maintenance.ok) {
|
|
1528
|
+
return buildActorContextUnavailableResult(
|
|
1529
|
+
task,
|
|
1530
|
+
index,
|
|
1531
|
+
agentName,
|
|
1532
|
+
agent.source,
|
|
1533
|
+
effectiveModelOverride,
|
|
1534
|
+
simpleMode,
|
|
1535
|
+
actorRouting.actor,
|
|
1536
|
+
maintenance.reason,
|
|
1537
|
+
);
|
|
1538
|
+
}
|
|
1539
|
+
cacheAffinity = maintenance.cacheAffinity;
|
|
1540
|
+
} else if (
|
|
1541
|
+
actorRouting.kind === "actor" &&
|
|
1542
|
+
actorRouting.runMode === "initial" &&
|
|
1543
|
+
agentName === "executor"
|
|
1544
|
+
) {
|
|
1545
|
+
cacheAffinity = { affine: true, reason: "self_fork", prewarm: "skipped" };
|
|
1546
|
+
}
|
|
1547
|
+
const shouldCreateExecutorForkSeed =
|
|
1548
|
+
agentName === "executor" &&
|
|
1549
|
+
(actorRouting.kind === "none" ||
|
|
1550
|
+
(actorRouting.kind === "actor" && actorRouting.runMode === "initial")) &&
|
|
1551
|
+
task.inheritContext !== "none" &&
|
|
1552
|
+
this.session.buildForkContextSeed !== undefined;
|
|
1553
|
+
const forkContextMode: Exclude<ForkContextMode, "none"> | undefined = shouldCreateExecutorForkSeed
|
|
1554
|
+
? requestsForkContext(task)
|
|
1555
|
+
? task.inheritContext
|
|
1556
|
+
: "full"
|
|
1557
|
+
: agentName !== "executor" && requestsForkContext(task)
|
|
1558
|
+
? task.inheritContext
|
|
1559
|
+
: undefined;
|
|
1560
|
+
const forkContextSeed =
|
|
1561
|
+
agentName === "executor"
|
|
1562
|
+
? forkContextMode
|
|
1563
|
+
? await buildForkContextSeed(forkContextMode)
|
|
1564
|
+
: undefined
|
|
1565
|
+
: (prebuiltForkContextSeeds?.get(task.id) ??
|
|
1566
|
+
(forkContextMode ? await buildForkContextSeed(forkContextMode) : undefined));
|
|
1567
|
+
const forkContext = forkContextMode
|
|
1568
|
+
? { mode: forkContextMode, clonedTokens: forkContextSeed?.metadata.approximateTokens ?? 0 }
|
|
1569
|
+
: undefined;
|
|
1570
|
+
const actorRunMode = actorRouting.kind === "actor" ? actorRouting.runMode : undefined;
|
|
1571
|
+
const actorResumeMessage =
|
|
1572
|
+
actorRouting.kind === "actor" && actorRouting.runMode === "message"
|
|
1573
|
+
? renderSubagentUserPrompt(task.assignment, simpleMode)
|
|
1574
|
+
: undefined;
|
|
1575
|
+
let taskSessionFile =
|
|
1576
|
+
actorRouting.kind === "actor"
|
|
1577
|
+
? actorRouting.actor.sessionFile
|
|
1578
|
+
: (overrides?.sessionFile ?? executionOverrides?.sessionFiles?.get(task.id) ?? null);
|
|
1579
|
+
if (actorRouting.kind === "actor") {
|
|
1580
|
+
await updateWorkflowActor(actorRouting.actor, registry =>
|
|
1581
|
+
markActorRunning(registry, actorRouting.actor.id, task.id),
|
|
1582
|
+
);
|
|
1583
|
+
}
|
|
1584
|
+
let finalizeWorkflowActorResult = async (result: SingleResult): Promise<void> => {
|
|
1585
|
+
if (actorRouting.kind !== "actor") return;
|
|
1586
|
+
await updateWorkflowActor(actorRouting.actor, registry =>
|
|
1587
|
+
result.paused
|
|
1588
|
+
? markActorPaused(
|
|
1589
|
+
registry,
|
|
1590
|
+
actorRouting.actor.id,
|
|
1591
|
+
taskSessionFile ?? actorRouting.actor.sessionFile,
|
|
1592
|
+
task.id,
|
|
1593
|
+
)
|
|
1594
|
+
: result.exitCode === 0 && !result.error
|
|
1595
|
+
? markActorIdle(
|
|
1596
|
+
registry,
|
|
1597
|
+
actorRouting.actor.id,
|
|
1598
|
+
taskSessionFile ?? actorRouting.actor.sessionFile,
|
|
1599
|
+
task.id,
|
|
1600
|
+
)
|
|
1601
|
+
: markActorFailed(
|
|
1602
|
+
registry,
|
|
1603
|
+
actorRouting.actor.id,
|
|
1604
|
+
result.error ?? result.stderr ?? "subagent failed",
|
|
1605
|
+
task.id,
|
|
1606
|
+
),
|
|
1607
|
+
);
|
|
1608
|
+
};
|
|
1609
|
+
const runSubprocessBaseArgs = {
|
|
1610
|
+
cwd: this.session.cwd,
|
|
1611
|
+
agent: effectiveAgent,
|
|
1612
|
+
task: renderSubagentUserPrompt(task.assignment, simpleMode),
|
|
1613
|
+
assignment: task.assignment.trim(),
|
|
1614
|
+
context: sharedContext,
|
|
1615
|
+
description: task.description,
|
|
1616
|
+
index,
|
|
1617
|
+
id: task.id,
|
|
1618
|
+
subagentId: task.id,
|
|
1619
|
+
taskDepth,
|
|
1620
|
+
modelOverride: effectiveModelOverride,
|
|
1621
|
+
parentActiveModelPattern,
|
|
1622
|
+
parentSessionId: this.session.getSessionId?.() ?? undefined,
|
|
1623
|
+
thinkingLevel: thinkingLevelOverride,
|
|
1624
|
+
outputSchema: effectiveOutputSchema,
|
|
1625
|
+
persistArtifacts: !!artifactsDir,
|
|
1626
|
+
artifactsDir: effectiveArtifactsDir,
|
|
1627
|
+
contextFile: contextFilePath,
|
|
1628
|
+
enableLsp: subagentLspEnabled,
|
|
1629
|
+
signal,
|
|
1630
|
+
eventBus: this.session.eventBus,
|
|
1631
|
+
onProgress: (progress: AgentProgress) => {
|
|
1632
|
+
progressMap.set(index, {
|
|
1633
|
+
...structuredClone(progress),
|
|
1634
|
+
});
|
|
1635
|
+
AsyncJobManager.instance()?.recordSubagentProgress(task.id, progress);
|
|
1636
|
+
emitProgress();
|
|
1637
|
+
},
|
|
1638
|
+
authStorage: this.session.authStorage,
|
|
1639
|
+
modelRegistry: this.session.modelRegistry,
|
|
1640
|
+
settings: this.session.settings,
|
|
1641
|
+
contextFiles,
|
|
1642
|
+
skills: availableSkills,
|
|
1643
|
+
autoloadSkills: resolvedAutoloadSkills,
|
|
1644
|
+
workspaceTree: this.session.workspaceTree,
|
|
1645
|
+
promptTemplates,
|
|
1646
|
+
localProtocolOptions,
|
|
1647
|
+
parentArtifactManager,
|
|
1648
|
+
parentHindsightSessionState: this.session.getHindsightSessionState?.(),
|
|
1649
|
+
parentTelemetry: this.session.getTelemetry?.(),
|
|
1650
|
+
forkContextSeed,
|
|
1651
|
+
};
|
|
1652
|
+
const attemptFreshFallback = async (
|
|
1653
|
+
result: SingleResult,
|
|
1654
|
+
worktree?: string,
|
|
1655
|
+
): Promise<
|
|
1656
|
+
{ result: SingleResult; freshActor: WorkflowActorRecord; freshSessionFile: string } | undefined
|
|
1657
|
+
> => {
|
|
1658
|
+
if (actorRouting.kind !== "actor" || actorRouting.runMode !== "message") return undefined;
|
|
1659
|
+
if (result.paused || result.aborted) return undefined;
|
|
1660
|
+
if (result.exitCode === 0 && !result.error) return undefined;
|
|
1661
|
+
await finalizeWorkflowActorResult(result);
|
|
1662
|
+
const freshSessionFile = path.join(
|
|
1663
|
+
effectiveArtifactsDir,
|
|
1664
|
+
`${workflowActorId(actorRouting.actor)}-${Date.now()}.jsonl`,
|
|
1665
|
+
);
|
|
1666
|
+
const actorKey: WorkflowActorKey = {
|
|
1667
|
+
namespaceId: actorRouting.actor.namespaceId,
|
|
1668
|
+
workflow: actorRouting.actor.workflow,
|
|
1669
|
+
workflowSessionId: actorRouting.actor.workflowSessionId,
|
|
1670
|
+
stage: actorRouting.actor.stage,
|
|
1671
|
+
lane: actorRouting.actor.lane,
|
|
1672
|
+
roleAgent: actorRouting.actor.roleAgent,
|
|
1673
|
+
modelId: actorRouting.actor.modelId,
|
|
1674
|
+
provider: actorRouting.actor.provider,
|
|
1675
|
+
...(actorRouting.actor.thinkingLevel ? { thinkingLevel: actorRouting.actor.thinkingLevel } : {}),
|
|
1676
|
+
rolePromptHash: actorRouting.actor.rolePromptHash,
|
|
1677
|
+
cwdOrWorktree: actorRouting.actor.cwdOrWorktree,
|
|
1678
|
+
writablePolicy: actorRouting.actor.writablePolicy,
|
|
1679
|
+
toolSurfaceHash: actorRouting.actor.toolSurfaceHash,
|
|
1680
|
+
};
|
|
1681
|
+
const freshActor = allocateActorRecord(actorKey, freshSessionFile);
|
|
1682
|
+
const wfSessionId = this.session.getSessionId?.();
|
|
1683
|
+
if (wfSessionId) {
|
|
1684
|
+
const reg = await readActorRegistry(this.session.cwd, wfSessionId);
|
|
1685
|
+
await writeActorRegistryAtomic(
|
|
1686
|
+
this.session.cwd,
|
|
1687
|
+
wfSessionId,
|
|
1688
|
+
markActorRunning(upsertActor(reg, freshActor), freshActor.id, task.id),
|
|
1689
|
+
);
|
|
1690
|
+
}
|
|
1691
|
+
let freshResult: SingleResult;
|
|
1692
|
+
try {
|
|
1693
|
+
freshResult = await runSubprocess({
|
|
1694
|
+
...runSubprocessBaseArgs,
|
|
1695
|
+
...(worktree ? { worktree } : {}),
|
|
1696
|
+
runMode: "initial",
|
|
1697
|
+
resumeMessage: undefined,
|
|
1698
|
+
sessionFile: freshSessionFile,
|
|
1699
|
+
cacheAffinity: undefined,
|
|
1700
|
+
});
|
|
1701
|
+
} catch (err) {
|
|
1702
|
+
if (wfSessionId) {
|
|
1703
|
+
const reg = await readActorRegistry(this.session.cwd, wfSessionId);
|
|
1704
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
1705
|
+
await writeActorRegistryAtomic(
|
|
1706
|
+
this.session.cwd,
|
|
1707
|
+
wfSessionId,
|
|
1708
|
+
markActorFailed(reg, freshActor.id, msg || "fresh spawn threw", task.id),
|
|
1709
|
+
);
|
|
1710
|
+
}
|
|
1711
|
+
throw err;
|
|
1712
|
+
}
|
|
1713
|
+
if (wfSessionId) {
|
|
1714
|
+
const reg2 = await readActorRegistry(this.session.cwd, wfSessionId);
|
|
1715
|
+
const updatedReg = freshResult.paused
|
|
1716
|
+
? markActorPaused(reg2, freshActor.id, freshSessionFile, task.id)
|
|
1717
|
+
: freshResult.exitCode === 0 && !freshResult.error
|
|
1718
|
+
? markActorIdle(reg2, freshActor.id, freshSessionFile, task.id)
|
|
1719
|
+
: markActorFailed(
|
|
1720
|
+
reg2,
|
|
1721
|
+
freshActor.id,
|
|
1722
|
+
freshResult.error ?? freshResult.stderr ?? "fresh spawn failed",
|
|
1723
|
+
task.id,
|
|
1724
|
+
);
|
|
1725
|
+
await writeActorRegistryAtomic(this.session.cwd, wfSessionId, updatedReg);
|
|
1726
|
+
}
|
|
1727
|
+
return { result: freshResult, freshActor, freshSessionFile };
|
|
1728
|
+
};
|
|
1729
|
+
if (!isIsolated) {
|
|
1730
|
+
const result = await runSubprocess({
|
|
1731
|
+
...runSubprocessBaseArgs,
|
|
1732
|
+
runMode: actorRunMode ?? overrides?.runMode ?? executionOverrides?.runMode,
|
|
1733
|
+
resumeMessage: actorResumeMessage ?? overrides?.resumeMessage ?? executionOverrides?.resumeMessage,
|
|
1734
|
+
sessionFile: taskSessionFile,
|
|
1735
|
+
cacheAffinity,
|
|
1736
|
+
});
|
|
1737
|
+
const freshFallback = await attemptFreshFallback(result);
|
|
1738
|
+
if (freshFallback) {
|
|
1739
|
+
const freshWithForkContext = forkContext
|
|
1740
|
+
? { ...freshFallback.result, forkContext }
|
|
1741
|
+
: freshFallback.result;
|
|
1742
|
+
return freshWithForkContext;
|
|
1743
|
+
}
|
|
1744
|
+
const resultWithForkContext = forkContext ? { ...result, forkContext } : result;
|
|
1745
|
+
await finalizeWorkflowActorResult(resultWithForkContext);
|
|
1746
|
+
return resultWithForkContext;
|
|
1747
|
+
}
|
|
1748
|
+
|
|
1749
|
+
const taskStart = Date.now();
|
|
1750
|
+
let isolationHandle: IsolationHandle | undefined;
|
|
1751
|
+
try {
|
|
1752
|
+
if (!repoRoot || !baseline) {
|
|
1753
|
+
throw new Error("Isolated task execution not initialized.");
|
|
1754
|
+
}
|
|
1755
|
+
const taskBaseline = structuredClone(baseline);
|
|
1756
|
+
|
|
1757
|
+
isolationHandle = await ensureIsolation(repoRoot, task.id, preferredIsolationBackend);
|
|
1758
|
+
const isolationDir = isolationHandle.mergedDir;
|
|
1759
|
+
|
|
1760
|
+
let result = await runSubprocess({
|
|
1761
|
+
...runSubprocessBaseArgs,
|
|
1762
|
+
worktree: isolationDir,
|
|
1763
|
+
runMode: actorRunMode ?? overrides?.runMode ?? executionOverrides?.runMode,
|
|
1764
|
+
resumeMessage: actorResumeMessage ?? overrides?.resumeMessage ?? executionOverrides?.resumeMessage,
|
|
1765
|
+
sessionFile: taskSessionFile,
|
|
1766
|
+
cacheAffinity,
|
|
1767
|
+
});
|
|
1768
|
+
// Fresh-spawn fallback for isolated path
|
|
1769
|
+
const freshFallback = await attemptFreshFallback(result, isolationDir);
|
|
1770
|
+
if (freshFallback) {
|
|
1771
|
+
if (
|
|
1772
|
+
freshFallback.result.paused ||
|
|
1773
|
+
freshFallback.result.exitCode !== 0 ||
|
|
1774
|
+
freshFallback.result.error
|
|
1775
|
+
) {
|
|
1776
|
+
// Fresh also failed/paused — helper already finalized, return directly
|
|
1777
|
+
const freshWithForkContext = forkContext
|
|
1778
|
+
? { ...freshFallback.result, forkContext }
|
|
1779
|
+
: freshFallback.result;
|
|
1780
|
+
return freshWithForkContext;
|
|
1781
|
+
}
|
|
1782
|
+
// Fresh succeeded — rebind for merge/patch post-processing
|
|
1783
|
+
result = freshFallback.result;
|
|
1784
|
+
taskSessionFile = freshFallback.freshSessionFile;
|
|
1785
|
+
finalizeWorkflowActorResult = async (r: SingleResult): Promise<void> => {
|
|
1786
|
+
const wfSid = this.session.getSessionId?.();
|
|
1787
|
+
if (!wfSid) return;
|
|
1788
|
+
const reg = await readActorRegistry(this.session.cwd, wfSid);
|
|
1789
|
+
const updated = r.paused
|
|
1790
|
+
? markActorPaused(reg, freshFallback.freshActor.id, freshFallback.freshSessionFile, task.id)
|
|
1791
|
+
: r.exitCode === 0 && !r.error
|
|
1792
|
+
? markActorIdle(reg, freshFallback.freshActor.id, freshFallback.freshSessionFile, task.id)
|
|
1793
|
+
: markActorFailed(
|
|
1794
|
+
reg,
|
|
1795
|
+
freshFallback.freshActor.id,
|
|
1796
|
+
r.error ?? r.stderr ?? "failed",
|
|
1797
|
+
task.id,
|
|
1798
|
+
);
|
|
1799
|
+
await writeActorRegistryAtomic(this.session.cwd, wfSid, updated);
|
|
1800
|
+
};
|
|
1801
|
+
}
|
|
1802
|
+
const resultWithForkContext = forkContext ? { ...result, forkContext } : result;
|
|
1803
|
+
if (mergeMode === "branch" && resultWithForkContext.exitCode === 0) {
|
|
1804
|
+
try {
|
|
1805
|
+
const commitMsg =
|
|
1806
|
+
commitStyle === "ai" && this.session.modelRegistry
|
|
1807
|
+
? async (diff: string) => {
|
|
1808
|
+
return generateCommitMessage(
|
|
1809
|
+
diff,
|
|
1810
|
+
this.session.modelRegistry!,
|
|
1811
|
+
this.session.settings,
|
|
1812
|
+
this.session.getSessionId?.() ?? undefined,
|
|
1813
|
+
);
|
|
1814
|
+
}
|
|
1815
|
+
: undefined;
|
|
1816
|
+
const commitResult = await commitToBranch(
|
|
1817
|
+
isolationDir,
|
|
1818
|
+
taskBaseline,
|
|
1819
|
+
task.id,
|
|
1820
|
+
task.description,
|
|
1821
|
+
commitMsg,
|
|
1822
|
+
);
|
|
1823
|
+
const producedChanges = Boolean(commitResult?.branchName || commitResult?.nestedPatches.length);
|
|
1824
|
+
const mergedResult: SingleResult = {
|
|
1825
|
+
...resultWithForkContext,
|
|
1826
|
+
branchName: commitResult?.branchName,
|
|
1827
|
+
nestedPatches: commitResult?.nestedPatches,
|
|
1828
|
+
producedChanges,
|
|
1829
|
+
};
|
|
1830
|
+
await finalizeWorkflowActorResult(mergedResult);
|
|
1831
|
+
return mergedResult;
|
|
1832
|
+
} catch (mergeErr) {
|
|
1833
|
+
// Agent succeeded but branch commit failed — clean up stale branch
|
|
1834
|
+
const branchName = `gjc/task/${task.id}`;
|
|
1835
|
+
await git.branch.tryDelete(repoRoot, branchName);
|
|
1836
|
+
const msg = mergeErr instanceof Error ? mergeErr.message : String(mergeErr);
|
|
1837
|
+
const failedMergeResult: SingleResult = {
|
|
1838
|
+
...resultWithForkContext,
|
|
1839
|
+
error: `Merge failed: ${msg}`,
|
|
1840
|
+
};
|
|
1841
|
+
await finalizeWorkflowActorResult(failedMergeResult);
|
|
1842
|
+
return failedMergeResult;
|
|
1843
|
+
}
|
|
1844
|
+
}
|
|
1845
|
+
if (resultWithForkContext.exitCode === 0) {
|
|
1846
|
+
try {
|
|
1847
|
+
const delta = await captureDeltaPatch(isolationDir, taskBaseline);
|
|
1848
|
+
const artifactId = validateAllocatedTaskId(task.id);
|
|
1849
|
+
const patchPath = path.join(effectiveArtifactsDir, `${artifactId}.patch`);
|
|
1850
|
+
await Bun.write(patchPath, delta.rootPatch);
|
|
1851
|
+
const producedChanges = Boolean(delta.rootPatch.trim() || delta.nestedPatches.length);
|
|
1852
|
+
const patchResult: SingleResult = {
|
|
1853
|
+
...resultWithForkContext,
|
|
1854
|
+
patchPath,
|
|
1855
|
+
nestedPatches: delta.nestedPatches,
|
|
1856
|
+
producedChanges,
|
|
1857
|
+
};
|
|
1858
|
+
await finalizeWorkflowActorResult(patchResult);
|
|
1859
|
+
return patchResult;
|
|
1860
|
+
} catch (patchErr) {
|
|
1861
|
+
const msg = patchErr instanceof Error ? patchErr.message : String(patchErr);
|
|
1862
|
+
const failedPatchResult: SingleResult = {
|
|
1863
|
+
...resultWithForkContext,
|
|
1864
|
+
error: `Patch capture failed: ${msg}`,
|
|
1865
|
+
};
|
|
1866
|
+
await finalizeWorkflowActorResult(failedPatchResult);
|
|
1867
|
+
return failedPatchResult;
|
|
1868
|
+
}
|
|
1869
|
+
}
|
|
1870
|
+
await finalizeWorkflowActorResult(resultWithForkContext);
|
|
1871
|
+
return resultWithForkContext;
|
|
1872
|
+
} catch (err) {
|
|
1873
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
1874
|
+
const assignment = task.assignment.trim();
|
|
1875
|
+
const failedResult: SingleResult = {
|
|
1876
|
+
index,
|
|
1877
|
+
id: task.id,
|
|
1878
|
+
agent: agent.name,
|
|
1879
|
+
agentSource: agent.source,
|
|
1880
|
+
task: renderSubagentUserPrompt(assignment, simpleMode),
|
|
1881
|
+
assignment,
|
|
1882
|
+
description: task.description,
|
|
1883
|
+
exitCode: 1,
|
|
1884
|
+
output: "",
|
|
1885
|
+
stderr: message,
|
|
1886
|
+
truncated: false,
|
|
1887
|
+
durationMs: Date.now() - taskStart,
|
|
1888
|
+
tokens: 0,
|
|
1889
|
+
modelOverride,
|
|
1890
|
+
forkContext,
|
|
1891
|
+
error: message,
|
|
1892
|
+
};
|
|
1893
|
+
await finalizeWorkflowActorResult(failedResult);
|
|
1894
|
+
return failedResult;
|
|
1895
|
+
} finally {
|
|
1896
|
+
if (isolationHandle) {
|
|
1897
|
+
await cleanupIsolation(isolationHandle);
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
};
|
|
1901
|
+
|
|
1902
|
+
// Execute in parallel with concurrency limit
|
|
1903
|
+
const { results: partialResults, aborted } = await mapWithConcurrencyLimit(
|
|
1904
|
+
tasksWithUniqueIds,
|
|
1905
|
+
maxConcurrency,
|
|
1906
|
+
runTask,
|
|
1907
|
+
signal,
|
|
1908
|
+
);
|
|
1909
|
+
|
|
1910
|
+
// Fill in skipped tasks (undefined entries from abort) with placeholder results
|
|
1911
|
+
const results: SingleResult[] = partialResults.map((result, index) => {
|
|
1912
|
+
if (result !== undefined) {
|
|
1913
|
+
return result;
|
|
1914
|
+
}
|
|
1915
|
+
const task = tasksWithUniqueIds[index];
|
|
1916
|
+
const assignment = task.assignment.trim();
|
|
1917
|
+
return {
|
|
1918
|
+
index,
|
|
1919
|
+
id: task.id,
|
|
1920
|
+
agent: agentName,
|
|
1921
|
+
agentSource: agent.source,
|
|
1922
|
+
task: renderSubagentUserPrompt(assignment, simpleMode),
|
|
1923
|
+
assignment,
|
|
1924
|
+
description: task.description,
|
|
1925
|
+
exitCode: 1,
|
|
1926
|
+
output: "",
|
|
1927
|
+
stderr: "Skipped (cancelled before start)",
|
|
1928
|
+
truncated: false,
|
|
1929
|
+
durationMs: 0,
|
|
1930
|
+
tokens: 0,
|
|
1931
|
+
modelOverride,
|
|
1932
|
+
error: "Cancelled before start",
|
|
1933
|
+
aborted: true,
|
|
1934
|
+
abortReason: "Cancelled before start",
|
|
1935
|
+
};
|
|
1936
|
+
});
|
|
1937
|
+
if (!artifactsDir) {
|
|
1938
|
+
for (const result of results) {
|
|
1939
|
+
delete result.outputMeta;
|
|
1940
|
+
delete result.outputPath;
|
|
1941
|
+
}
|
|
1942
|
+
}
|
|
1943
|
+
|
|
1944
|
+
const forkContextClonedTokens = results.reduce(
|
|
1945
|
+
(total, result) => total + (result.forkContext?.clonedTokens ?? 0),
|
|
1946
|
+
0,
|
|
1947
|
+
);
|
|
1948
|
+
|
|
1949
|
+
// Aggregate usage from executor results (already accumulated incrementally)
|
|
1950
|
+
const aggregatedUsage = createUsageTotals();
|
|
1951
|
+
let hasAggregatedUsage = false;
|
|
1952
|
+
for (const result of results) {
|
|
1953
|
+
if (result.usage) {
|
|
1954
|
+
addUsageTotals(aggregatedUsage, result.usage);
|
|
1955
|
+
hasAggregatedUsage = true;
|
|
1956
|
+
}
|
|
1957
|
+
}
|
|
1958
|
+
|
|
1959
|
+
const patchPaths: string[] = [];
|
|
1960
|
+
for (const result of results) {
|
|
1961
|
+
if (result.patchPath) {
|
|
1962
|
+
patchPaths.push(result.patchPath);
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
1965
|
+
|
|
1966
|
+
let mergeSummary = "";
|
|
1967
|
+
let changesApplied: boolean | null = null;
|
|
1968
|
+
let hadAnyChanges = false;
|
|
1969
|
+
let mergedBranchesForNestedPatches: Set<string> | null = null;
|
|
1970
|
+
if (isIsolated && repoRoot) {
|
|
1971
|
+
try {
|
|
1972
|
+
if (mergeMode === "branch") {
|
|
1973
|
+
// Branch mode: merge task branches sequentially
|
|
1974
|
+
const branchEntries = results
|
|
1975
|
+
.filter(r => r.branchName && r.exitCode === 0 && !r.aborted)
|
|
1976
|
+
.map(r => ({ branchName: r.branchName!, taskId: r.id, description: r.description }));
|
|
1977
|
+
|
|
1978
|
+
if (branchEntries.length === 0) {
|
|
1979
|
+
changesApplied = true;
|
|
1980
|
+
hadAnyChanges = false;
|
|
1981
|
+
mergeSummary = "\n\nNo changes to apply.";
|
|
1982
|
+
} else {
|
|
1983
|
+
const mergeResult = await mergeTaskBranches(repoRoot, branchEntries);
|
|
1984
|
+
mergedBranchesForNestedPatches = new Set(mergeResult.merged);
|
|
1985
|
+
changesApplied = mergeResult.failed.length === 0;
|
|
1986
|
+
hadAnyChanges = changesApplied && mergeResult.merged.length > 0;
|
|
1987
|
+
|
|
1988
|
+
if (changesApplied) {
|
|
1989
|
+
mergeSummary = hadAnyChanges
|
|
1990
|
+
? `\n\nMerged ${mergeResult.merged.length} branch${mergeResult.merged.length === 1 ? "" : "es"}: ${mergeResult.merged.join(", ")}`
|
|
1991
|
+
: "\n\nNo changes to apply.";
|
|
1992
|
+
} else {
|
|
1993
|
+
const mergedPart =
|
|
1994
|
+
mergeResult.merged.length > 0 ? `Merged: ${mergeResult.merged.join(", ")}.\n` : "";
|
|
1995
|
+
const failedPart = `Failed: ${mergeResult.failed.join(", ")}.`;
|
|
1996
|
+
const conflictPart = mergeResult.conflict ? `\nConflict: ${mergeResult.conflict}` : "";
|
|
1997
|
+
mergeSummary = `\n\n<system-notification>Branch merge failed. ${mergedPart}${failedPart}${conflictPart}\nUnmerged branches remain for manual resolution.</system-notification>`;
|
|
1998
|
+
}
|
|
1999
|
+
}
|
|
2000
|
+
|
|
2001
|
+
// Clean up merged branches (keep failed ones for manual resolution)
|
|
2002
|
+
const allBranches = branchEntries.map(b => b.branchName);
|
|
2003
|
+
if (changesApplied) {
|
|
2004
|
+
await cleanupTaskBranches(repoRoot, allBranches);
|
|
2005
|
+
}
|
|
2006
|
+
} else {
|
|
2007
|
+
// Patch mode: combine and apply patches
|
|
2008
|
+
const patchesInOrder = results.map(result => result.patchPath).filter(Boolean) as string[];
|
|
2009
|
+
const missingPatch = results.some(result => !result.patchPath);
|
|
2010
|
+
if (missingPatch) {
|
|
2011
|
+
changesApplied = false;
|
|
2012
|
+
hadAnyChanges = false;
|
|
2013
|
+
} else {
|
|
2014
|
+
const patchStats = await Promise.all(
|
|
2015
|
+
patchesInOrder.map(async patchPath => ({
|
|
2016
|
+
patchPath,
|
|
2017
|
+
size: (await fs.stat(patchPath)).size,
|
|
2018
|
+
})),
|
|
2019
|
+
);
|
|
2020
|
+
const nonEmptyPatches = patchStats.filter(patch => patch.size > 0).map(patch => patch.patchPath);
|
|
2021
|
+
if (nonEmptyPatches.length === 0) {
|
|
2022
|
+
changesApplied = true;
|
|
2023
|
+
hadAnyChanges = false;
|
|
2024
|
+
} else {
|
|
2025
|
+
const patchTexts = await Promise.all(
|
|
2026
|
+
nonEmptyPatches.map(async patchPath => Bun.file(patchPath).text()),
|
|
2027
|
+
);
|
|
2028
|
+
const combinedPatch = patchTexts
|
|
2029
|
+
.map(text => (text.endsWith("\n") ? text : `${text}\n`))
|
|
2030
|
+
.join("");
|
|
2031
|
+
if (!combinedPatch.trim()) {
|
|
2032
|
+
changesApplied = true;
|
|
2033
|
+
hadAnyChanges = false;
|
|
2034
|
+
} else {
|
|
2035
|
+
changesApplied = await git.patch.canApplyText(repoRoot, combinedPatch);
|
|
2036
|
+
if (changesApplied) {
|
|
2037
|
+
try {
|
|
2038
|
+
await git.patch.applyText(repoRoot, combinedPatch);
|
|
2039
|
+
hadAnyChanges = true;
|
|
2040
|
+
} catch {
|
|
2041
|
+
changesApplied = false;
|
|
2042
|
+
hadAnyChanges = false;
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
}
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
2048
|
+
|
|
2049
|
+
if (changesApplied) {
|
|
2050
|
+
mergeSummary = hadAnyChanges ? "\n\nApplied patches: yes" : "\n\nNo changes to apply.";
|
|
2051
|
+
} else {
|
|
2052
|
+
const notification =
|
|
2053
|
+
"<system-notification>Patches were not applied and must be handled manually.</system-notification>";
|
|
2054
|
+
const patchList =
|
|
2055
|
+
patchPaths.length > 0
|
|
2056
|
+
? `\n\nPatch artifacts: ${patchPaths.length} preserved for internal merge recovery.`
|
|
2057
|
+
: "";
|
|
2058
|
+
mergeSummary = `\n\n${notification}${patchList}`;
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
2061
|
+
} catch (mergeErr) {
|
|
2062
|
+
const msg = mergeErr instanceof Error ? mergeErr.message : String(mergeErr);
|
|
2063
|
+
changesApplied = false;
|
|
2064
|
+
hadAnyChanges = false;
|
|
2065
|
+
mergeSummary = `\n\n<system-notification>Merge phase failed: ${msg}\nTask outputs are preserved but changes were not applied.</system-notification>`;
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
|
|
2069
|
+
// Apply nested repo patches (separate from parent git)
|
|
2070
|
+
if (isIsolated && repoRoot && (mergeMode === "branch" || changesApplied !== false)) {
|
|
2071
|
+
const allNestedPatches = results
|
|
2072
|
+
.filter(r => {
|
|
2073
|
+
if (!r.nestedPatches || r.nestedPatches.length === 0 || r.exitCode !== 0 || r.aborted) {
|
|
2074
|
+
return false;
|
|
2075
|
+
}
|
|
2076
|
+
if (mergeMode !== "branch") {
|
|
2077
|
+
return true;
|
|
2078
|
+
}
|
|
2079
|
+
if (!r.branchName || !mergedBranchesForNestedPatches) {
|
|
2080
|
+
return false;
|
|
2081
|
+
}
|
|
2082
|
+
return mergedBranchesForNestedPatches.has(r.branchName);
|
|
2083
|
+
})
|
|
2084
|
+
.flatMap(r => r.nestedPatches!);
|
|
2085
|
+
if (allNestedPatches.length > 0) {
|
|
2086
|
+
try {
|
|
2087
|
+
const commitMsg =
|
|
2088
|
+
commitStyle === "ai" && this.session.modelRegistry
|
|
2089
|
+
? async (diff: string) => {
|
|
2090
|
+
return generateCommitMessage(
|
|
2091
|
+
diff,
|
|
2092
|
+
this.session.modelRegistry!,
|
|
2093
|
+
this.session.settings,
|
|
2094
|
+
this.session.getSessionId?.() ?? undefined,
|
|
2095
|
+
);
|
|
2096
|
+
}
|
|
2097
|
+
: undefined;
|
|
2098
|
+
await applyNestedPatches(repoRoot, allNestedPatches, commitMsg);
|
|
2099
|
+
} catch {
|
|
2100
|
+
// Nested patch failures are non-fatal to the parent merge
|
|
2101
|
+
mergeSummary +=
|
|
2102
|
+
"\n\n<system-notification>Some nested repository patches failed to apply.</system-notification>";
|
|
2103
|
+
}
|
|
2104
|
+
}
|
|
2105
|
+
}
|
|
2106
|
+
|
|
2107
|
+
// Build final output - match plugin format
|
|
2108
|
+
const cancelledCount = results.filter(r => r.aborted).length;
|
|
2109
|
+
const successCount = results.filter(r => r.exitCode === 0 && !r.error && !r.aborted).length;
|
|
2110
|
+
const totalDuration = Date.now() - startTime;
|
|
2111
|
+
|
|
2112
|
+
const receipts = results.map(buildTaskReceipt);
|
|
2113
|
+
const roiSummary = buildTaskRoiSummary(receipts);
|
|
2114
|
+
const summaries = receipts.map(r => {
|
|
2115
|
+
const status = r.status === "merge_failed" ? "merge failed" : r.status;
|
|
2116
|
+
return {
|
|
2117
|
+
agent: r.agent,
|
|
2118
|
+
status,
|
|
2119
|
+
id: r.id,
|
|
2120
|
+
synopsis: r.preview,
|
|
2121
|
+
outputUri: r.outputRef?.uri,
|
|
2122
|
+
meta: r.outputRef
|
|
2123
|
+
? {
|
|
2124
|
+
lineCount: r.outputRef.lineCount,
|
|
2125
|
+
charSize: formatBytes(r.outputRef.sizeBytes),
|
|
2126
|
+
}
|
|
2127
|
+
: undefined,
|
|
2128
|
+
};
|
|
2129
|
+
});
|
|
2130
|
+
|
|
2131
|
+
const summary = prompt.render(taskSummaryTemplate, {
|
|
2132
|
+
successCount,
|
|
2133
|
+
totalCount: results.length,
|
|
2134
|
+
cancelledCount,
|
|
2135
|
+
hasCancelledNote: aborted && cancelledCount > 0,
|
|
2136
|
+
duration: formatDuration(totalDuration),
|
|
2137
|
+
summaries,
|
|
2138
|
+
agentName,
|
|
2139
|
+
mergeSummary,
|
|
2140
|
+
});
|
|
2141
|
+
|
|
2142
|
+
// Cleanup temp directory if used
|
|
2143
|
+
const shouldCleanupTempArtifacts =
|
|
2144
|
+
tempArtifactsDir && (!isIsolated || changesApplied === true || changesApplied === null);
|
|
2145
|
+
if (shouldCleanupTempArtifacts) {
|
|
2146
|
+
await fs.rm(tempArtifactsDir, { recursive: true, force: true });
|
|
2147
|
+
}
|
|
2148
|
+
|
|
2149
|
+
const details: TaskToolDetails = {
|
|
2150
|
+
projectAgentsDir,
|
|
2151
|
+
results: receipts,
|
|
2152
|
+
totalDurationMs: totalDuration,
|
|
2153
|
+
usage: hasAggregatedUsage ? aggregatedUsage : undefined,
|
|
2154
|
+
forkContextClonedTokens: forkContextClonedTokens > 0 ? forkContextClonedTokens : undefined,
|
|
2155
|
+
roiSummary,
|
|
2156
|
+
};
|
|
2157
|
+
assertNoRawTaskFields(details, "task.return.details");
|
|
2158
|
+
return {
|
|
2159
|
+
content: [{ type: "text", text: summary }],
|
|
2160
|
+
details,
|
|
2161
|
+
};
|
|
2162
|
+
} catch (err) {
|
|
2163
|
+
return {
|
|
2164
|
+
content: [{ type: "text", text: `Task execution failed: ${err}` }],
|
|
2165
|
+
details: {
|
|
2166
|
+
projectAgentsDir,
|
|
2167
|
+
results: [],
|
|
2168
|
+
totalDurationMs: Date.now() - startTime,
|
|
2169
|
+
},
|
|
2170
|
+
};
|
|
2171
|
+
}
|
|
2172
|
+
}
|
|
2173
|
+
}
|