@ashx-j/lunr 0.2.26 → 0.2.28
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 +25 -1
- package/LICENSE +22 -0
- package/dist/builtin-extensions/ashxj-thinking.d.ts +1 -1
- package/dist/builtin-extensions/ashxj-thinking.d.ts.map +1 -1
- package/dist/builtin-extensions/ashxj-thinking.js +1 -1
- package/dist/builtin-extensions/ashxj-thinking.js.map +1 -1
- package/dist/builtin-extensions/ashxj-tui.d.ts +11 -1
- package/dist/builtin-extensions/ashxj-tui.d.ts.map +1 -1
- package/dist/builtin-extensions/ashxj-tui.js +6 -10
- package/dist/builtin-extensions/ashxj-tui.js.map +1 -1
- package/dist/builtin-extensions/lunr-cron.d.ts +4 -5
- package/dist/builtin-extensions/lunr-cron.d.ts.map +1 -1
- package/dist/builtin-extensions/lunr-cron.js +94 -108
- package/dist/builtin-extensions/lunr-cron.js.map +1 -1
- package/dist/builtin-extensions/lunr-local-providers/local-servers.d.ts.map +1 -1
- package/dist/builtin-extensions/lunr-local-providers/local-servers.js +3 -1
- package/dist/builtin-extensions/lunr-local-providers/local-servers.js.map +1 -1
- package/dist/builtin-extensions/narumiruna-pi-goal/src/accounting.d.ts.map +1 -1
- package/dist/builtin-extensions/narumiruna-pi-goal/src/accounting.js +5 -2
- package/dist/builtin-extensions/narumiruna-pi-goal/src/accounting.js.map +1 -1
- package/dist/builtin-extensions/narumiruna-pi-goal/src/commands.d.ts.map +1 -1
- package/dist/builtin-extensions/narumiruna-pi-goal/src/commands.js +2 -2
- package/dist/builtin-extensions/narumiruna-pi-goal/src/commands.js.map +1 -1
- package/dist/builtin-extensions/narumiruna-pi-goal/src/goal.d.ts.map +1 -1
- package/dist/builtin-extensions/narumiruna-pi-goal/src/goal.js +1 -1
- package/dist/builtin-extensions/narumiruna-pi-goal/src/goal.js.map +1 -1
- package/dist/builtin-extensions/narumiruna-pi-goal/src/runtime.d.ts.map +1 -1
- package/dist/builtin-extensions/narumiruna-pi-goal/src/runtime.js +1 -1
- package/dist/builtin-extensions/narumiruna-pi-goal/src/runtime.js.map +1 -1
- package/dist/builtin-extensions/pi-intercom/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-intercom/index.js +2 -2
- package/dist/builtin-extensions/pi-intercom/index.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/index.d.ts +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/index.js +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/index.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/index.js +1 -15
- package/dist/builtin-extensions/pi-lsp-extension/src/index.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/lsp-client.d.ts +6 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/lsp-client.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/lsp-client.js +187 -132
- package/dist/builtin-extensions/pi-lsp-extension/src/lsp-client.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/lsp-manager.d.ts +8 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/lsp-manager.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/lsp-manager.js +142 -112
- package/dist/builtin-extensions/pi-lsp-extension/src/lsp-manager.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-rewrite.d.ts +12 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-rewrite.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-rewrite.js +14 -7
- package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-rewrite.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/rewrite-engine.d.ts +11 -3
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/rewrite-engine.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/rewrite-engine.js +67 -41
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/rewrite-engine.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/search-engine.d.ts +4 -2
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/search-engine.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/search-engine.js +3 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/search-engine.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/commands.d.ts +2 -1
- package/dist/builtin-extensions/pi-mcp-adapter/commands.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/commands.js +6 -6
- package/dist/builtin-extensions/pi-mcp-adapter/commands.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/config.d.ts +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/config.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/config.js +11 -5
- package/dist/builtin-extensions/pi-mcp-adapter/config.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tool-executor.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tool-executor.js +2 -2
- package/dist/builtin-extensions/pi-mcp-adapter/direct-tool-executor.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/host-html-template.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/host-html-template.js +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/host-html-template.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/index.js +48 -40
- package/dist/builtin-extensions/pi-mcp-adapter/index.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/init.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/init.js +3 -1
- package/dist/builtin-extensions/pi-mcp-adapter/init.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-auth-flow.d.ts +12 -40
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-auth-flow.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-auth-flow.js +166 -235
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-auth-flow.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-callback-server.d.ts +5 -0
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-callback-server.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-callback-server.js +43 -13
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-callback-server.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-oauth-provider.d.ts +14 -3
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-oauth-provider.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-oauth-provider.js +73 -21
- package/dist/builtin-extensions/pi-mcp-adapter/mcp-oauth-provider.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/proxy-modes.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/proxy-modes.js +4 -4
- package/dist/builtin-extensions/pi-mcp-adapter/proxy-modes.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/server-manager.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/server-manager.js +2 -2
- package/dist/builtin-extensions/pi-mcp-adapter/server-manager.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/state.d.ts +2 -0
- package/dist/builtin-extensions/pi-mcp-adapter/state.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/state.js.map +1 -1
- package/dist/builtin-extensions/pi-ollama-cloud/index.d.ts +1 -1
- package/dist/builtin-extensions/pi-ollama-cloud/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-ollama-cloud/index.js +1 -1
- package/dist/builtin-extensions/pi-ollama-cloud/index.js.map +1 -1
- package/dist/builtin-extensions/pi-ollama-cloud/models.d.ts +11 -5
- package/dist/builtin-extensions/pi-ollama-cloud/models.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-ollama-cloud/models.js +12 -32
- package/dist/builtin-extensions/pi-ollama-cloud/models.js.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/index.js +5 -3
- package/dist/builtin-extensions/pi-prompt-template-model/index.js.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.d.ts +2 -1
- package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.js +21 -12
- package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.js.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.js +7 -24
- package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/index.js +39 -77
- package/dist/builtin-extensions/pi-subagents/src/extension/index.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/chain-root-attachment.d.ts +4 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/chain-root-attachment.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/chain-root-attachment.js +2 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/chain-root-attachment.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.d.ts +6 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.js +17 -31
- package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.js +7 -2
- package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.d.ts +5 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.js +78 -42
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.js +8 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.d.ts +0 -3
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js +134 -28
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js +26 -5
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.js +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.d.ts +7 -8
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.js +60 -32
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/session-tokens.d.ts +7 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/session-tokens.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/session-tokens.js +70 -38
- package/dist/builtin-extensions/pi-subagents/src/shared/session-tokens.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts +9 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/types.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/utils.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/utils.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/utils.js +15 -5
- package/dist/builtin-extensions/pi-subagents/src/shared/utils.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.js +4 -3
- package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js +13 -62
- package/dist/builtin-extensions/pi-subagents/src/slash/slash-commands.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render.js +18 -9
- package/dist/builtin-extensions/pi-subagents/src/tui/render.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/review.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/review.js +3 -3
- package/dist/builtin-extensions/pi-subagents/src/watchdog/review.js.map +1 -1
- package/dist/builtin-extensions/pi-tps.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-tps.js +28 -17
- package/dist/builtin-extensions/pi-tps.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/activity.d.ts +1 -0
- package/dist/builtin-extensions/pi-web-access/activity.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/activity.js +27 -5
- package/dist/builtin-extensions/pi-web-access/activity.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/bounded-body.d.ts +3 -0
- package/dist/builtin-extensions/pi-web-access/bounded-body.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/bounded-body.js +43 -0
- package/dist/builtin-extensions/pi-web-access/bounded-body.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/content-page.d.ts +24 -0
- package/dist/builtin-extensions/pi-web-access/content-page.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-web-access/content-page.js +57 -0
- package/dist/builtin-extensions/pi-web-access/content-page.js.map +1 -0
- package/dist/builtin-extensions/pi-web-access/extract.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/extract.js +7 -2
- package/dist/builtin-extensions/pi-web-access/extract.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/github-extract.d.ts +0 -1
- package/dist/builtin-extensions/pi-web-access/github-extract.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/github-extract.js +147 -36
- package/dist/builtin-extensions/pi-web-access/github-extract.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/index.js +48 -73
- package/dist/builtin-extensions/pi-web-access/index.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/session-cleanup.d.ts +12 -4
- package/dist/builtin-extensions/pi-web-access/session-cleanup.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/session-cleanup.js +35 -12
- package/dist/builtin-extensions/pi-web-access/session-cleanup.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/storage.d.ts +9 -6
- package/dist/builtin-extensions/pi-web-access/storage.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/storage.js +36 -24
- package/dist/builtin-extensions/pi-web-access/storage.js.map +1 -1
- package/dist/builtin-extensions/simple-pi-memory.d.ts +1 -1
- package/dist/builtin-extensions/simple-pi-memory.d.ts.map +1 -1
- package/dist/builtin-extensions/simple-pi-memory.js +1 -1
- package/dist/builtin-extensions/simple-pi-memory.js.map +1 -1
- package/dist/catalog/models.json +1 -1
- package/dist/catalog/providers/google-vertex.json +1 -1
- package/dist/catalog/providers/google.json +1 -1
- package/dist/catalog/publication.json +3 -3
- package/dist/cli/install-cli.d.ts.map +1 -1
- package/dist/cli/install-cli.js +38 -30
- package/dist/cli/install-cli.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +13 -0
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +75 -11
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +1 -0
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +1 -0
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +46 -21
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +344 -126
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/browser/runtime.d.ts +2 -0
- package/dist/core/browser/runtime.d.ts.map +1 -1
- package/dist/core/browser/runtime.js +80 -45
- package/dist/core/browser/runtime.js.map +1 -1
- package/dist/core/browser/setup.d.ts.map +1 -1
- package/dist/core/browser/setup.js +12 -1
- package/dist/core/browser/setup.js.map +1 -1
- package/dist/core/cache-stats.d.ts +1 -1
- package/dist/core/cache-stats.d.ts.map +1 -1
- package/dist/core/cache-stats.js +1 -1
- package/dist/core/cache-stats.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts +2 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +1 -0
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +5 -11
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +38 -92
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/computer-use/adapter.d.ts.map +1 -1
- package/dist/core/computer-use/adapter.js +7 -2
- package/dist/core/computer-use/adapter.js.map +1 -1
- package/dist/core/computer-use/image.d.ts.map +1 -1
- package/dist/core/computer-use/image.js +17 -5
- package/dist/core/computer-use/image.js.map +1 -1
- package/dist/core/computer-use/schemas.d.ts.map +1 -1
- package/dist/core/computer-use/schemas.js +23 -6
- package/dist/core/computer-use/schemas.js.map +1 -1
- package/dist/core/computer-use/workflow.d.ts.map +1 -1
- package/dist/core/computer-use/workflow.js +459 -119
- package/dist/core/computer-use/workflow.js.map +1 -1
- package/dist/core/context-breakdown.d.ts +2 -2
- package/dist/core/context-breakdown.d.ts.map +1 -1
- package/dist/core/context-breakdown.js +22 -20
- package/dist/core/context-breakdown.js.map +1 -1
- package/dist/core/cron/jobs.d.ts +26 -8
- package/dist/core/cron/jobs.d.ts.map +1 -1
- package/dist/core/cron/jobs.js +357 -232
- package/dist/core/cron/jobs.js.map +1 -1
- package/dist/core/cron/origin-context.d.ts +1 -0
- package/dist/core/cron/origin-context.d.ts.map +1 -1
- package/dist/core/cron/origin-context.js.map +1 -1
- package/dist/core/cron/scheduler.d.ts +22 -17
- package/dist/core/cron/scheduler.d.ts.map +1 -1
- package/dist/core/cron/scheduler.js +153 -73
- package/dist/core/cron/scheduler.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +1 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +8 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +11 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +4 -0
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +22 -1
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/large-subagent-launch.d.ts +1 -1
- package/dist/core/large-subagent-launch.d.ts.map +1 -1
- package/dist/core/large-subagent-launch.js +7 -7
- package/dist/core/large-subagent-launch.js.map +1 -1
- package/dist/core/model-registry.d.ts +2 -0
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +5 -0
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-runtime.d.ts +4 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +40 -4
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/permissions.d.ts +3 -3
- package/dist/core/permissions.d.ts.map +1 -1
- package/dist/core/permissions.js +11 -35
- package/dist/core/permissions.js.map +1 -1
- package/dist/core/plan-mode.d.ts +5 -13
- package/dist/core/plan-mode.d.ts.map +1 -1
- package/dist/core/plan-mode.js +126 -116
- package/dist/core/plan-mode.js.map +1 -1
- package/dist/core/project-trust.d.ts.map +1 -1
- package/dist/core/project-trust.js +1 -1
- package/dist/core/project-trust.js.map +1 -1
- package/dist/core/prompt-resource-bridge.d.ts +12 -0
- package/dist/core/prompt-resource-bridge.d.ts.map +1 -0
- package/dist/core/prompt-resource-bridge.js +9 -0
- package/dist/core/prompt-resource-bridge.js.map +1 -0
- package/dist/core/protected-targets.d.ts +6 -0
- package/dist/core/protected-targets.d.ts.map +1 -0
- package/dist/core/protected-targets.js +45 -0
- package/dist/core/protected-targets.js.map +1 -0
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +7 -0
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/rollback.d.ts +19 -3
- package/dist/core/rollback.d.ts.map +1 -1
- package/dist/core/rollback.js +172 -56
- package/dist/core/rollback.js.map +1 -1
- package/dist/core/runtime-credentials.d.ts +3 -0
- package/dist/core/runtime-credentials.d.ts.map +1 -1
- package/dist/core/runtime-credentials.js +14 -1
- package/dist/core/runtime-credentials.js.map +1 -1
- package/dist/core/sdk.d.ts +3 -0
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +1 -0
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts +11 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +111 -33
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/session-ownership.d.ts.map +1 -1
- package/dist/core/session-ownership.js +8 -3
- package/dist/core/session-ownership.js.map +1 -1
- package/dist/core/session-retention.d.ts.map +1 -1
- package/dist/core/session-retention.js +18 -7
- package/dist/core/session-retention.js.map +1 -1
- package/dist/core/session-startup-settings.d.ts +10 -0
- package/dist/core/session-startup-settings.d.ts.map +1 -0
- package/dist/core/session-startup-settings.js +70 -0
- package/dist/core/session-startup-settings.js.map +1 -0
- package/dist/core/subscriptions.d.ts +16 -7
- package/dist/core/subscriptions.d.ts.map +1 -1
- package/dist/core/subscriptions.js +96 -55
- package/dist/core/subscriptions.js.map +1 -1
- package/dist/core/trust-manager.d.ts +2 -1
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +6 -1
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/core/update-check.d.ts.map +1 -1
- package/dist/core/update-check.js.map +1 -1
- package/dist/core/usage-accounting.d.ts +47 -0
- package/dist/core/usage-accounting.d.ts.map +1 -0
- package/dist/core/usage-accounting.js +205 -0
- package/dist/core/usage-accounting.js.map +1 -0
- package/dist/core/usage-adapters/kimi-coding.d.ts +2 -2
- package/dist/core/usage-adapters/kimi-coding.d.ts.map +1 -1
- package/dist/core/usage-adapters/kimi-coding.js +2 -2
- package/dist/core/usage-adapters/kimi-coding.js.map +1 -1
- package/dist/core/usage-adapters/openai-codex.d.ts +3 -2
- package/dist/core/usage-adapters/openai-codex.d.ts.map +1 -1
- package/dist/core/usage-adapters/openai-codex.js +3 -3
- package/dist/core/usage-adapters/openai-codex.js.map +1 -1
- package/dist/core/usage-adapters/xai.d.ts +2 -2
- package/dist/core/usage-adapters/xai.d.ts.map +1 -1
- package/dist/core/usage-adapters/xai.js +3 -3
- package/dist/core/usage-adapters/xai.js.map +1 -1
- package/dist/core/usage-adapters/zai.d.ts +2 -2
- package/dist/core/usage-adapters/zai.d.ts.map +1 -1
- package/dist/core/usage-adapters/zai.js +2 -2
- package/dist/core/usage-adapters/zai.js.map +1 -1
- package/dist/core/usage-history.d.ts +1 -18
- package/dist/core/usage-history.d.ts.map +1 -1
- package/dist/core/usage-history.js +46 -114
- package/dist/core/usage-history.js.map +1 -1
- package/dist/core/usage-service.d.ts +9 -2
- package/dist/core/usage-service.d.ts.map +1 -1
- package/dist/core/usage-service.js +95 -50
- package/dist/core/usage-service.js.map +1 -1
- package/dist/gateway/agent-bridge.d.ts +9 -1
- package/dist/gateway/agent-bridge.d.ts.map +1 -1
- package/dist/gateway/agent-bridge.js +91 -37
- package/dist/gateway/agent-bridge.js.map +1 -1
- package/dist/gateway/buttons.d.ts +8 -1
- package/dist/gateway/buttons.d.ts.map +1 -1
- package/dist/gateway/buttons.js +76 -18
- package/dist/gateway/buttons.js.map +1 -1
- package/dist/gateway/commands.d.ts +1 -0
- package/dist/gateway/commands.d.ts.map +1 -1
- package/dist/gateway/commands.js +10 -4
- package/dist/gateway/commands.js.map +1 -1
- package/dist/gateway/cron.d.ts +12 -11
- package/dist/gateway/cron.d.ts.map +1 -1
- package/dist/gateway/cron.js +65 -56
- package/dist/gateway/cron.js.map +1 -1
- package/dist/gateway/index.d.ts.map +1 -1
- package/dist/gateway/index.js +2 -1
- package/dist/gateway/index.js.map +1 -1
- package/dist/gateway/mobile-commands.d.ts +1 -0
- package/dist/gateway/mobile-commands.d.ts.map +1 -1
- package/dist/gateway/mobile-commands.js +69 -15
- package/dist/gateway/mobile-commands.js.map +1 -1
- package/dist/gateway/presenter.d.ts +12 -2
- package/dist/gateway/presenter.d.ts.map +1 -1
- package/dist/gateway/presenter.js +73 -38
- package/dist/gateway/presenter.js.map +1 -1
- package/dist/gateway/router.d.ts +2 -2
- package/dist/gateway/router.d.ts.map +1 -1
- package/dist/gateway/router.js +17 -2
- package/dist/gateway/router.js.map +1 -1
- package/dist/gateway/service.d.ts +2 -0
- package/dist/gateway/service.d.ts.map +1 -1
- package/dist/gateway/service.js +153 -0
- package/dist/gateway/service.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +86 -33
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +6 -4
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/context-view.d.ts.map +1 -1
- package/dist/modes/interactive/components/context-view.js +2 -2
- package/dist/modes/interactive/components/context-view.js.map +1 -1
- package/dist/modes/interactive/components/copyable-text.d.ts.map +1 -1
- package/dist/modes/interactive/components/copyable-text.js +3 -2
- package/dist/modes/interactive/components/copyable-text.js.map +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +1 -1
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +8 -12
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/usage-view.d.ts +5 -0
- package/dist/modes/interactive/components/usage-view.d.ts.map +1 -1
- package/dist/modes/interactive/components/usage-view.js +21 -6
- package/dist/modes/interactive/components/usage-view.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +3 -7
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +151 -131
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/smooth-streaming.d.ts.map +1 -1
- package/dist/modes/interactive/smooth-streaming.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +2 -1
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/node-runtime/{adapter-VFG7WNPX.js → adapter-247RTYLS.js} +4 -5
- package/dist/node-runtime/agent-session-services-RTUGP3XR.js +54 -0
- package/dist/node-runtime/{brave-UWDA3I22.js → brave-2AFFAXNN.js} +1 -1
- package/dist/node-runtime/{builtin-extensions-I2HIFEMY.js → builtin-extensions-N4EUD6SB.js} +8 -7
- package/dist/node-runtime/{chunk-QH6YL7VK.js → chunk-252ZVPPF.js} +3 -3
- package/dist/node-runtime/{chunk-PCEW76PM.js → chunk-2OIPYKLZ.js} +6 -6
- package/dist/node-runtime/{chunk-XBWPBZBN.js → chunk-2SWW7KMW.js} +1 -1
- package/dist/node-runtime/{chunk-UQUCFAJ3.js → chunk-2VIW3IMF.js} +40 -7
- package/dist/node-runtime/{chunk-UOEDI7RP.js → chunk-4KNKQGHM.js} +2 -2
- package/dist/node-runtime/chunk-4QRUZ64T.js +1203 -0
- package/dist/node-runtime/{chunk-FQMM2EZ2.js → chunk-64XTQNLA.js} +29 -7
- package/dist/node-runtime/{chunk-SPVDBUOS.js → chunk-6O3IW3IA.js} +2 -2
- package/dist/node-runtime/{chunk-5ZQXRPMC.js → chunk-6ZZHGUSA.js} +2 -2
- package/dist/node-runtime/{chunk-WIF24I7G.js → chunk-APVM5NEU.js} +149 -144
- package/dist/node-runtime/{chunk-LWYIVUGV.js → chunk-B2IBAXNX.js} +48 -31
- package/dist/node-runtime/{chunk-M3LZLQW2.js → chunk-BDRGN3L2.js} +1 -0
- package/dist/node-runtime/{chunk-LJTIVM7I.js → chunk-BMRXLQWQ.js} +464 -160
- package/dist/node-runtime/{chunk-GJ2RDBRL.js → chunk-BYC6RKCN.js} +4 -2
- package/dist/node-runtime/{chunk-T4DA4XE7.js → chunk-DFMPRAQQ.js} +162 -82
- package/dist/node-runtime/{chunk-SN2KSMPQ.js → chunk-DQSCFU7R.js} +13 -7
- package/dist/node-runtime/{chunk-UVWCDQYF.js → chunk-E5DQGNJI.js} +455 -278
- package/dist/node-runtime/{chunk-4SBQAI4T.js → chunk-EBLAZVSA.js} +2058 -73
- package/dist/node-runtime/{chunk-CSFI6YXL.js → chunk-ES6PBSIE.js} +1 -1
- package/dist/node-runtime/{chunk-IF24A3FH.js → chunk-EVM653DD.js} +4 -4
- package/dist/node-runtime/{chunk-HTFRRDSF.js → chunk-F2SMQ6ES.js} +3 -2
- package/dist/node-runtime/chunk-F2V2F4ZG.js +114 -0
- package/dist/node-runtime/{chunk-IKU6Y7DL.js → chunk-FE3WZI7F.js} +9 -6
- package/dist/node-runtime/{chunk-6VYZ5UFP.js → chunk-FLGEEH27.js} +1 -1
- package/dist/node-runtime/{chunk-5EFIU3OM.js → chunk-FTKEZL27.js} +1 -1
- package/dist/node-runtime/{chunk-RGQAEOM5.js → chunk-FYIFPFXE.js} +23 -6
- package/dist/node-runtime/{chunk-HMBGROQK.js → chunk-GLDXBBL6.js} +3 -3
- package/dist/node-runtime/{chunk-KWA4OC2J.js → chunk-H6YBCWKG.js} +1 -1
- package/dist/node-runtime/{chunk-2MI5OPMN.js → chunk-HNNHHJAB.js} +68 -50
- package/dist/node-runtime/{chunk-I74LN5JG.js → chunk-HUD2RFJW.js} +2 -2
- package/dist/node-runtime/{chunk-XHIRAZ26.js → chunk-IAZSK7KK.js} +1 -1
- package/dist/node-runtime/{chunk-GYIXXQAO.js → chunk-ICKGAKWX.js} +23 -59
- package/dist/node-runtime/{chunk-X3PGBLQ7.js → chunk-IHHTWSXN.js} +9 -9
- package/dist/node-runtime/{chunk-DAPBPCBP.js → chunk-IPP5BIV5.js} +25 -3
- package/dist/node-runtime/{chunk-QFWG2RVL.js → chunk-IXG6F4NT.js} +11 -0
- package/dist/node-runtime/{chunk-L24TPBS4.js → chunk-JEK35V2M.js} +45 -31
- package/dist/node-runtime/{chunk-RDDAZOMU.js → chunk-JL4HYQXK.js} +1 -1
- package/dist/node-runtime/{chunk-2HMIRK7W.js → chunk-LHV3V67B.js} +5 -5
- package/dist/node-runtime/{chunk-UAEOTO52.js → chunk-MNQXDFPV.js} +6 -2
- package/dist/node-runtime/{chunk-MPKSOJBT.js → chunk-NHATCSOI.js} +4 -7
- package/dist/node-runtime/{chunk-RMQZU2YU.js → chunk-NNNR3QIY.js} +1 -1
- package/dist/node-runtime/{chunk-2KIPT4HJ.js → chunk-PWHTSQC4.js} +83 -21
- package/dist/node-runtime/{chunk-RWTKOC3B.js → chunk-QBTJG3UM.js} +1 -1
- package/dist/node-runtime/{chunk-RCR3XAQY.js → chunk-QT3F6UEV.js} +233 -169
- package/dist/node-runtime/{chunk-GS42T6MX.js → chunk-QW3AAHWN.js} +1 -1
- package/dist/node-runtime/{chunk-DVQSHCVP.js → chunk-R4WSB2MQ.js} +5 -5
- package/dist/node-runtime/{chunk-B4HP6ZWM.js → chunk-RHCGYWO7.js} +1 -1
- package/dist/node-runtime/{chunk-2CFDTH5B.js → chunk-RLGY2QIL.js} +45 -59
- package/dist/node-runtime/{chunk-CDVHZOOK.js → chunk-RY3FJ6WI.js} +29 -27
- package/dist/node-runtime/{chunk-KKUTQQV7.js → chunk-RYRGL7P4.js} +1 -1
- package/dist/node-runtime/{chunk-I54LGHWM.js → chunk-STMX7W5I.js} +3 -3
- package/dist/node-runtime/chunk-SWWHZ2RI.js +158 -0
- package/dist/node-runtime/{chunk-5Q4A37RB.js → chunk-TCT6PCUR.js} +32 -11
- package/dist/node-runtime/{chunk-P7XBVXGT.js → chunk-U3YVZ6UC.js} +18 -14
- package/dist/node-runtime/{chunk-D5UCKPBQ.js → chunk-UBWW2PID.js} +1 -1
- package/dist/node-runtime/{chunk-E75WFZ33.js → chunk-UNUZICC4.js} +3 -3
- package/dist/node-runtime/{chunk-RAK2QA2B.js → chunk-UYRKUKFE.js} +4 -4
- package/dist/node-runtime/{chunk-LWJXTA6Z.js → chunk-VSUEAI7O.js} +1377 -45
- package/dist/node-runtime/{chunk-NAY6UUQZ.js → chunk-WDIVLMOH.js} +1 -1
- package/dist/node-runtime/{chunk-E24EO34J.js → chunk-WPXUR3HE.js} +1 -1
- package/dist/node-runtime/{chunk-SLVOAQOY.js → chunk-WXYNALHD.js} +113 -1
- package/dist/node-runtime/{chunk-KJ6DWS3K.js → chunk-XEOCUEUJ.js} +121 -60
- package/dist/node-runtime/chunk-YD3IZAZ7.js +47 -0
- package/dist/node-runtime/chunk-YSB6URMT.js +41 -0
- package/dist/node-runtime/{chunk-YWOJIGFY.js → chunk-ZEVFBFNF.js} +95 -142
- package/dist/node-runtime/{chunk-5B6VKFEV.js → chunk-ZIQUS5QO.js} +1 -1
- package/dist/node-runtime/cli-runtime.js +4 -4
- package/dist/node-runtime/{command-FSBU2EVZ.js → command-YRT7I2BW.js} +5 -5
- package/dist/node-runtime/{commands-NAAL7KNT.js → commands-2ETOWWRA.js} +16 -16
- package/dist/node-runtime/{commands-EMBQQVVT.js → commands-D6A6H4TS.js} +11 -18
- package/dist/node-runtime/{config-QDD5PUE2.js → config-CU7M7BTK.js} +1 -1
- package/dist/node-runtime/{config-D4QUPAHX.js → config-DS7XLMEM.js} +2 -2
- package/dist/node-runtime/{direct-tool-executor-4D7UXYU4.js → direct-tool-executor-2QJXVQD2.js} +6 -11
- package/dist/node-runtime/{exa-LL64QZR2.js → exa-6VBZNPGE.js} +1 -1
- package/dist/node-runtime/{export-html-VM4J2MNR.js → export-html-DBQRRMAY.js} +4 -4
- package/dist/node-runtime/{extension-input-E7BJZ35H.js → extension-input-VBBMX7YV.js} +5 -5
- package/dist/node-runtime/{extension-selector-WU42XDTU.js → extension-selector-T5AOG5XB.js} +5 -5
- package/dist/node-runtime/{extract-EQJE7FZZ.js → extract-BFX2N35A.js} +3 -3
- package/dist/node-runtime/{gateway-DQM333YV.js → gateway-V6K2CDWN.js} +51 -42
- package/dist/node-runtime/{gemini-search-35OCRFLN.js → gemini-search-C66QHDT6.js} +2 -2
- package/dist/node-runtime/{gemini-url-context-UQY3PHHW.js → gemini-url-context-T7DEK73R.js} +3 -3
- package/dist/node-runtime/{github-extract-F64RZOEA.js → github-extract-HOGE3D6F.js} +107 -38
- package/dist/node-runtime/{goal-NJEE5CTU.js → goal-J7TYMOBK.js} +14 -8
- package/dist/node-runtime/index.js +51 -48
- package/dist/node-runtime/{init-P5AUV77I.js → init-JBQJIPYI.js} +3 -6
- package/dist/node-runtime/{install-cli-NN4YAU44.js → install-cli-INGHIVBY.js} +30 -25
- package/dist/node-runtime/interactive-mode-ASZ7APYP.js +75 -0
- package/dist/node-runtime/{interactive-view-NGFAMHPW.js → interactive-view-K33PM4OS.js} +8 -8
- package/dist/node-runtime/{lsp-manager-3ASUSO4T.js → lsp-manager-S554V5HR.js} +240 -155
- package/dist/node-runtime/{lunr-browser-IR7TL3J7.js → lunr-browser-H4FDOR3C.js} +7 -7
- package/dist/node-runtime/{lunr-computer-use-Y23CCDIJ.js → lunr-computer-use-VDP2QNRQ.js} +9 -9
- package/dist/node-runtime/{lunr-cron-USHC4LXH.js → lunr-cron-WD3YH4CR.js} +93 -80
- package/dist/node-runtime/main.js +43 -41
- package/dist/node-runtime/{mobile-commands-O5LCHL32.js → mobile-commands-ICUXFW5V.js} +12 -12
- package/dist/node-runtime/{model-runtime-OO5HFLWE.js → model-runtime-MZ2JMDV4.js} +4 -4
- package/dist/node-runtime/{openai-search-B3MSNCQA.js → openai-search-K72LJDYN.js} +1 -1
- package/dist/node-runtime/{package-manager-cli-Q7BL6KZO.js → package-manager-cli-CYM262SI.js} +20 -20
- package/dist/node-runtime/{parallel-AI2MNSCU.js → parallel-X724NCNU.js} +1 -1
- package/dist/node-runtime/{perplexity-QVJW3I35.js → perplexity-RDHQHVMK.js} +2 -2
- package/dist/node-runtime/{pi-intercom-QM53RLTS.js → pi-intercom-NHHEPBMI.js} +2 -2
- package/dist/node-runtime/{pi-mcp-adapter-3PHF4KZ4.js → pi-mcp-adapter-PP3GQJQ2.js} +98 -94
- package/dist/node-runtime/{pi-ollama-cloud-2F3Y2QNM.js → pi-ollama-cloud-4MNWIMFN.js} +11 -24
- package/dist/node-runtime/{pi-prompt-template-model-QWTCGLJU.js → pi-prompt-template-model-FTGELLS5.js} +32 -36
- package/dist/node-runtime/{pi-subagents-7IBSSGEW.js → pi-subagents-QPU3OXE4.js} +114 -167
- package/dist/node-runtime/{pi-web-access-WTGMNZ32.js → pi-web-access-Z3LP246C.js} +144 -108
- package/dist/node-runtime/{print-mode-XQ76CYMT.js → print-mode-2XHN5SUA.js} +3 -3
- package/dist/node-runtime/{process-registry-4FAKZQOL.js → process-registry-Q4QWIU33.js} +3 -3
- package/dist/node-runtime/{proxy-modes-5FAPSZEZ.js → proxy-modes-VEGC6QG5.js} +8 -15
- package/dist/node-runtime/rpc-entry.js +43 -41
- package/dist/node-runtime/{rpc-mode-O3XV4SID.js → rpc-mode-32DHJPEJ.js} +4 -4
- package/dist/node-runtime/{runtime-4VA6JKNF.js → runtime-EDUUGAQD.js} +56 -46
- package/dist/node-runtime/{runtime-EFPPD2UW.js → runtime-UGXM4NPQ.js} +2 -2
- package/dist/node-runtime/{runtime-bridges-7WVCLI76.js → runtime-bridges-DNKMNJCF.js} +7 -7
- package/dist/node-runtime/{service-MDQIPQ26.js → service-IHLGFLBT.js} +6 -4
- package/dist/node-runtime/{session-handoff-GWARVEWT.js → session-handoff-LYH53ESV.js} +4 -4
- package/dist/node-runtime/{session-manager-JB5J6XBN.js → session-manager-ZJ3N5Q74.js} +3 -3
- package/dist/node-runtime/{session-selector-GIM4DHQ2.js → session-selector-I73U3EIO.js} +7 -7
- package/dist/node-runtime/{settings-manager-DJDM5AHM.js → settings-manager-P2TKGYTR.js} +5 -5
- package/dist/node-runtime/{setup-JBKOLJ6F.js → setup-H7CCELIL.js} +15 -1
- package/dist/node-runtime/{setup-PFBWRNUI.js → setup-OLQ4GXWS.js} +17 -17
- package/dist/node-runtime/{src-IVPNZ2BX.js → src-6RV4PXKJ.js} +64 -36
- package/dist/node-runtime/{subagent-executor-LPZ4BHWE.js → subagent-executor-UI6SHG3X.js} +412 -288
- package/dist/node-runtime/{tavily-WEZFVFP7.js → tavily-KZBFYQB6.js} +1 -1
- package/dist/node-runtime/{theme-UOO5RVFN.js → theme-YLVZKKZD.js} +2 -2
- package/dist/node-runtime/{trust-manager-MMISNCYO.js → trust-manager-ZCU76D23.js} +2 -2
- package/dist/node-runtime/{update-cli-HNMOTNGX.js → update-cli-F3XXJANQ.js} +6 -6
- package/dist/node-runtime/{usage-service-LFB2SWYV.js → usage-service-CPAGBED5.js} +1 -1
- package/dist/node-runtime/{video-extract-OOZHR7SU.js → video-extract-UPKYIBW3.js} +3 -3
- package/dist/node-runtime/{workflow-OHPBEFO4.js → workflow-ICDI4N3J.js} +208 -78
- package/dist/node-runtime/{youtube-extract-FNPAUNHU.js → youtube-extract-77NT7FWH.js} +4 -4
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/exif-orientation.d.ts.map +1 -1
- package/dist/utils/exif-orientation.js +25 -10
- package/dist/utils/exif-orientation.js.map +1 -1
- package/dist/utils/image-resize-core.d.ts.map +1 -1
- package/dist/utils/image-resize-core.js +2 -0
- package/dist/utils/image-resize-core.js.map +1 -1
- package/dist/utils/paths.d.ts +4 -0
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +33 -2
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/sanitize-terminal-text.d.ts +7 -0
- package/dist/utils/sanitize-terminal-text.d.ts.map +1 -0
- package/dist/utils/sanitize-terminal-text.js +67 -0
- package/dist/utils/sanitize-terminal-text.js.map +1 -0
- package/docs/browser.md +1 -1
- package/docs/custom-provider.md +3 -3
- package/docs/extensions.md +8 -4
- package/docs/features.md +25 -7
- package/docs/keybindings.md +1 -1
- package/docs/models.md +5 -5
- package/docs/packages.md +1 -1
- package/docs/providers.md +2 -2
- package/docs/rpc.md +7 -7
- package/docs/security.md +10 -5
- package/docs/sessions.md +2 -2
- package/docs/skills.md +1 -1
- package/docs/terminal-setup.md +7 -7
- package/docs/themes.md +1 -1
- package/docs/usage.md +1 -1
- package/examples/extensions/auto-commit-on-exit.ts +1 -1
- package/examples/extensions/bash-spawn-hook.ts +1 -1
- package/examples/extensions/built-in-tool-renderer.ts +1 -1
- package/examples/extensions/claude-rules.ts +1 -1
- package/examples/extensions/commands.ts +1 -1
- package/examples/extensions/custom-compaction.ts +1 -1
- package/examples/extensions/custom-provider-anthropic/index.ts +3 -3
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/doom-overlay/index.ts +1 -1
- package/examples/extensions/git-merge-and-resolve.ts +2 -2
- package/examples/extensions/gondolin/index.ts +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/hidden-thinking-label.ts +1 -1
- package/examples/extensions/inline-bash.ts +2 -2
- package/examples/extensions/input-transform-streaming.ts +2 -2
- package/examples/extensions/input-transform.ts +2 -2
- package/examples/extensions/interactive-shell.ts +1 -1
- package/examples/extensions/kimi-deferred-tools.ts +1 -1
- package/examples/extensions/mac-system-theme.ts +1 -1
- package/examples/extensions/minimal-mode.ts +1 -1
- package/examples/extensions/modal-editor.ts +1 -1
- package/examples/extensions/model-status.ts +1 -1
- package/examples/extensions/notify.ts +3 -3
- package/examples/extensions/overlay-qa-tests.ts +1 -1
- package/examples/extensions/overlay-test.ts +1 -1
- package/examples/extensions/pirate.ts +1 -1
- package/examples/extensions/preset.ts +3 -3
- package/examples/extensions/project-trust.ts +4 -4
- package/examples/extensions/prompt-customizer.ts +1 -1
- package/examples/extensions/rainbow-editor.ts +1 -1
- package/examples/extensions/rpc-demo.ts +1 -1
- package/examples/extensions/sandbox/index.ts +7 -7
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/shutdown-command.ts +5 -5
- package/examples/extensions/ssh.ts +2 -2
- package/examples/extensions/subagent/README.md +3 -3
- package/examples/extensions/subagent/index.ts +2 -2
- package/examples/extensions/titlebar-spinner.ts +1 -1
- package/examples/extensions/tool-override.ts +1 -1
- package/examples/extensions/tools.ts +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/extensions/working-indicator.ts +1 -1
- package/examples/extensions/working-message-test.ts +1 -1
- package/examples/sdk/01-minimal.ts +1 -1
- package/examples/sdk/03-custom-prompt.ts +1 -1
- package/examples/sdk/04-skills.ts +1 -1
- package/examples/sdk/06-extensions.ts +2 -2
- package/examples/sdk/08-prompt-templates.ts +1 -1
- package/install-lock/package-lock.json +24 -24
- package/install-lock/package.json +2 -2
- package/npm-shrinkwrap.json +60 -24
- package/package.json +9 -9
- package/dist/modes/interactive/components/exit-card.d.ts +0 -22
- package/dist/modes/interactive/components/exit-card.d.ts.map +0 -1
- package/dist/modes/interactive/components/exit-card.js +0 -69
- package/dist/modes/interactive/components/exit-card.js.map +0 -1
- package/dist/node-runtime/agent-session-services-5YXS2PLF.js +0 -51
- package/dist/node-runtime/chunk-2IDTZAG5.js +0 -1415
- package/dist/node-runtime/chunk-3MISGG4S.js +0 -769
- package/dist/node-runtime/chunk-4HXHDDCF.js +0 -16
- package/dist/node-runtime/chunk-5B5QN3ZQ.js +0 -356
- package/dist/node-runtime/chunk-7IQGBKBJ.js +0 -2033
- package/dist/node-runtime/chunk-AUXVGBO4.js +0 -19
- package/dist/node-runtime/chunk-PTFBPO3C.js +0 -50
- package/dist/node-runtime/interactive-mode-YOHZVMKX.js +0 -74
- package/dist/node-runtime/mcp-auth-flow-QVLFVLEO.js +0 -33
|
@@ -141,7 +141,6 @@ import {
|
|
|
141
141
|
resolveSkillsWithFallback,
|
|
142
142
|
resolveStepBehavior,
|
|
143
143
|
resolveSubagentIntercomTarget,
|
|
144
|
-
resolveSubagentRequestParams,
|
|
145
144
|
resolveSubagentResultStatus,
|
|
146
145
|
resolveSubagentRunId,
|
|
147
146
|
resolveTopLevelParallelConcurrency,
|
|
@@ -179,7 +178,7 @@ import {
|
|
|
179
178
|
writeNestedControlRequest,
|
|
180
179
|
writeNestedEvent,
|
|
181
180
|
writePrivateAtomicJson
|
|
182
|
-
} from "./chunk-
|
|
181
|
+
} from "./chunk-RLGY2QIL.js";
|
|
183
182
|
import {
|
|
184
183
|
DEFAULT_CONTROL_CONFIG,
|
|
185
184
|
buildControlEvent,
|
|
@@ -197,42 +196,49 @@ import {
|
|
|
197
196
|
READ_ONLY_WRITE_SPAWN_ERROR,
|
|
198
197
|
resolveChildPermissions,
|
|
199
198
|
snapshotParentPermissionMode
|
|
200
|
-
} from "./chunk-
|
|
201
|
-
import "./chunk-
|
|
199
|
+
} from "./chunk-ZEVFBFNF.js";
|
|
200
|
+
import "./chunk-YSB6URMT.js";
|
|
201
|
+
import "./chunk-6ZZHGUSA.js";
|
|
202
202
|
import "./chunk-53YJI7JU.js";
|
|
203
|
-
import "./chunk-
|
|
204
|
-
import "./chunk-
|
|
205
|
-
import "./chunk-5Q4A37RB.js";
|
|
203
|
+
import "./chunk-IAZSK7KK.js";
|
|
204
|
+
import "./chunk-TCT6PCUR.js";
|
|
206
205
|
import {
|
|
207
206
|
subagentCommunicationEnabled
|
|
208
|
-
} from "./chunk-
|
|
209
|
-
import "./chunk-
|
|
210
|
-
import "./chunk-
|
|
207
|
+
} from "./chunk-HUD2RFJW.js";
|
|
208
|
+
import "./chunk-4KNKQGHM.js";
|
|
209
|
+
import "./chunk-LHV3V67B.js";
|
|
211
210
|
import "./chunk-URD2SLIT.js";
|
|
212
|
-
import
|
|
213
|
-
|
|
211
|
+
import {
|
|
212
|
+
resolveSubagentRequestParams
|
|
213
|
+
} from "./chunk-APVM5NEU.js";
|
|
214
|
+
import "./chunk-F2V2F4ZG.js";
|
|
215
|
+
import "./chunk-BDRGN3L2.js";
|
|
214
216
|
import "./chunk-FY4A63RK.js";
|
|
215
|
-
import "./chunk-
|
|
216
|
-
import "./chunk-
|
|
217
|
+
import "./chunk-RYRGL7P4.js";
|
|
218
|
+
import "./chunk-ES6PBSIE.js";
|
|
217
219
|
import {
|
|
218
220
|
SessionManager
|
|
219
|
-
} from "./chunk-
|
|
221
|
+
} from "./chunk-PWHTSQC4.js";
|
|
220
222
|
import "./chunk-FVDOXRUD.js";
|
|
221
223
|
import "./chunk-UJOCPOMX.js";
|
|
222
224
|
import "./chunk-IMLCWLPI.js";
|
|
223
|
-
import "./chunk-
|
|
225
|
+
import "./chunk-MNQXDFPV.js";
|
|
224
226
|
import "./chunk-RQ2Q5IYR.js";
|
|
225
|
-
import
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
227
|
+
import {
|
|
228
|
+
collectUsageRequests,
|
|
229
|
+
totalRequestUsage
|
|
230
|
+
} from "./chunk-SWWHZ2RI.js";
|
|
231
|
+
import "./chunk-RHCGYWO7.js";
|
|
232
|
+
import "./chunk-QW3AAHWN.js";
|
|
233
|
+
import "./chunk-JL4HYQXK.js";
|
|
234
|
+
import "./chunk-64XTQNLA.js";
|
|
229
235
|
import "./chunk-Q4Q6D4IY.js";
|
|
230
236
|
import "./chunk-BRJX2PRC.js";
|
|
231
237
|
|
|
232
238
|
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js
|
|
233
239
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
234
|
-
import * as
|
|
235
|
-
import * as
|
|
240
|
+
import * as fs16 from "node:fs";
|
|
241
|
+
import * as path16 from "node:path";
|
|
236
242
|
|
|
237
243
|
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-clarify.js
|
|
238
244
|
import { matchesKey, visibleWidth, truncateToWidth } from "@ashx-j/lunr-tui";
|
|
@@ -916,16 +922,72 @@ var ChainClarifyComponent = class {
|
|
|
916
922
|
};
|
|
917
923
|
|
|
918
924
|
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.js
|
|
919
|
-
import * as
|
|
920
|
-
import * as
|
|
925
|
+
import * as fs8 from "node:fs";
|
|
926
|
+
import * as path7 from "node:path";
|
|
927
|
+
|
|
928
|
+
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/shared/session-tokens.js
|
|
929
|
+
import * as fs from "node:fs";
|
|
930
|
+
import * as path from "node:path";
|
|
931
|
+
function parseSessionRequests(sessionPath) {
|
|
932
|
+
if (!sessionPath)
|
|
933
|
+
return [];
|
|
934
|
+
try {
|
|
935
|
+
let files = fs.statSync(sessionPath).isDirectory() ? fs.readdirSync(sessionPath).filter((name) => name.endsWith(".jsonl")).map((name) => path.join(sessionPath, name)) : [sessionPath], requests = /* @__PURE__ */ new Map();
|
|
936
|
+
for (let file of files) {
|
|
937
|
+
let entries = [];
|
|
938
|
+
for (let line of fs.readFileSync(file, "utf-8").split(`
|
|
939
|
+
`))
|
|
940
|
+
try {
|
|
941
|
+
let entry = JSON.parse(line);
|
|
942
|
+
entry?.type && entries.push(entry);
|
|
943
|
+
} catch {
|
|
944
|
+
}
|
|
945
|
+
for (let request of collectUsageRequests(entries))
|
|
946
|
+
requests.set(request.id, request);
|
|
947
|
+
}
|
|
948
|
+
return [...requests.values()];
|
|
949
|
+
} catch {
|
|
950
|
+
return [];
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
function parseSessionUsage(sessionPath) {
|
|
954
|
+
let requests = parseSessionRequests(sessionPath);
|
|
955
|
+
if (requests.length === 0)
|
|
956
|
+
return null;
|
|
957
|
+
let total = totalRequestUsage(requests);
|
|
958
|
+
return {
|
|
959
|
+
input: total.input,
|
|
960
|
+
output: total.output,
|
|
961
|
+
cacheRead: total.cacheRead,
|
|
962
|
+
cacheWrite: total.cacheWrite,
|
|
963
|
+
cost: total.cost,
|
|
964
|
+
turns: requests.length,
|
|
965
|
+
unknownRequests: total.unknownRequests,
|
|
966
|
+
partialRequests: total.partialRequests,
|
|
967
|
+
unknownCosts: total.unknownCosts
|
|
968
|
+
};
|
|
969
|
+
}
|
|
970
|
+
function sessionUsageDelta(current, previous) {
|
|
971
|
+
return {
|
|
972
|
+
unknownRequests: Math.max(0, (current.unknownRequests ?? 0) - (previous?.unknownRequests ?? 0)),
|
|
973
|
+
partialRequests: Math.max(0, (current.partialRequests ?? 0) - (previous?.partialRequests ?? 0)),
|
|
974
|
+
unknownCosts: Math.max(0, (current.unknownCosts ?? 0) - (previous?.unknownCosts ?? 0)),
|
|
975
|
+
input: Math.max(0, current.input - (previous?.input ?? 0)),
|
|
976
|
+
output: Math.max(0, current.output - (previous?.output ?? 0)),
|
|
977
|
+
cacheRead: Math.max(0, current.cacheRead - (previous?.cacheRead ?? 0)),
|
|
978
|
+
cacheWrite: Math.max(0, current.cacheWrite - (previous?.cacheWrite ?? 0)),
|
|
979
|
+
cost: Math.max(0, current.cost - (previous?.cost ?? 0)),
|
|
980
|
+
turns: Math.max(0, current.turns - (previous?.turns ?? 0))
|
|
981
|
+
};
|
|
982
|
+
}
|
|
921
983
|
|
|
922
984
|
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js
|
|
923
985
|
import { spawn } from "node:child_process";
|
|
924
986
|
import { existsSync as existsSync2, unlinkSync } from "node:fs";
|
|
925
987
|
|
|
926
988
|
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/shared/child-transcript.js
|
|
927
|
-
import * as
|
|
928
|
-
import * as
|
|
989
|
+
import * as fs2 from "node:fs";
|
|
990
|
+
import * as path2 from "node:path";
|
|
929
991
|
var CHILD_TRANSCRIPT_ARTIFACT_VERSION = 1, DEFAULT_MAX_CHILD_TRANSCRIPT_BYTES = 50 * 1024 * 1024;
|
|
930
992
|
function errorMessage(error) {
|
|
931
993
|
return error instanceof Error ? error.message : String(error);
|
|
@@ -973,7 +1035,7 @@ function createChildTranscriptWriter(input) {
|
|
|
973
1035
|
if (bytesWritten + markerBytes > maxBytes)
|
|
974
1036
|
return !1;
|
|
975
1037
|
try {
|
|
976
|
-
return
|
|
1038
|
+
return fs2.appendFileSync(input.transcriptPath, marker, "utf-8"), bytesWritten += markerBytes, !0;
|
|
977
1039
|
} catch (error) {
|
|
978
1040
|
return writeError = `Failed to write child transcript '${input.transcriptPath}': ${errorMessage(error)}`, !1;
|
|
979
1041
|
}
|
|
@@ -997,13 +1059,13 @@ function createChildTranscriptWriter(input) {
|
|
|
997
1059
|
return;
|
|
998
1060
|
}
|
|
999
1061
|
try {
|
|
1000
|
-
|
|
1062
|
+
fs2.appendFileSync(input.transcriptPath, line, "utf-8"), bytesWritten += bytes;
|
|
1001
1063
|
} catch (error) {
|
|
1002
1064
|
writeError = `Failed to write child transcript '${input.transcriptPath}': ${errorMessage(error)}`;
|
|
1003
1065
|
}
|
|
1004
1066
|
};
|
|
1005
1067
|
try {
|
|
1006
|
-
|
|
1068
|
+
fs2.mkdirSync(path2.dirname(input.transcriptPath), { recursive: !0 }), fs2.writeFileSync(input.transcriptPath, "", "utf-8");
|
|
1007
1069
|
} catch (error) {
|
|
1008
1070
|
writeError = `Failed to initialize child transcript '${input.transcriptPath}': ${errorMessage(error)}`;
|
|
1009
1071
|
}
|
|
@@ -1225,17 +1287,17 @@ function evaluateCompletionMutationGuard(input) {
|
|
|
1225
1287
|
}
|
|
1226
1288
|
|
|
1227
1289
|
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-spawn.js
|
|
1228
|
-
import * as
|
|
1229
|
-
import * as
|
|
1290
|
+
import * as fs3 from "node:fs";
|
|
1291
|
+
import * as path3 from "node:path";
|
|
1230
1292
|
import { fileURLToPath } from "node:url";
|
|
1231
1293
|
var PI_CODING_AGENT_PACKAGE = "@ashx-j/lunr", PI_SUBAGENT_PI_BINARY_ENV = "PI_SUBAGENT_PI_BINARY";
|
|
1232
1294
|
function findPiPackageRootFromEntry(entryPoint) {
|
|
1233
|
-
let dir =
|
|
1234
|
-
for (; dir !==
|
|
1235
|
-
let packageJsonPath =
|
|
1236
|
-
if (
|
|
1295
|
+
let dir = path3.dirname(entryPoint);
|
|
1296
|
+
for (; dir !== path3.dirname(dir); ) {
|
|
1297
|
+
let packageJsonPath = path3.join(dir, "package.json");
|
|
1298
|
+
if (fs3.existsSync(packageJsonPath) && JSON.parse(fs3.readFileSync(packageJsonPath, "utf-8")).name === PI_CODING_AGENT_PACKAGE)
|
|
1237
1299
|
return dir;
|
|
1238
|
-
dir =
|
|
1300
|
+
dir = path3.dirname(dir);
|
|
1239
1301
|
}
|
|
1240
1302
|
}
|
|
1241
1303
|
function resolveInstalledPiPackageRoot() {
|
|
@@ -1244,7 +1306,7 @@ function resolveInstalledPiPackageRoot() {
|
|
|
1244
1306
|
function resolvePiPackageRoot() {
|
|
1245
1307
|
try {
|
|
1246
1308
|
let entry = process.argv[1];
|
|
1247
|
-
return entry ? findPiPackageRootFromEntry(
|
|
1309
|
+
return entry ? findPiPackageRootFromEntry(fs3.realpathSync(entry)) : void 0;
|
|
1248
1310
|
} catch {
|
|
1249
1311
|
return;
|
|
1250
1312
|
}
|
|
@@ -1253,10 +1315,10 @@ function isRunnableNodeScript(filePath, existsSync11) {
|
|
|
1253
1315
|
return existsSync11(filePath) ? /\.(?:mjs|cjs|js)$/i.test(filePath) : !1;
|
|
1254
1316
|
}
|
|
1255
1317
|
function normalizePath(filePath) {
|
|
1256
|
-
return
|
|
1318
|
+
return path3.isAbsolute(filePath) ? filePath : path3.resolve(filePath);
|
|
1257
1319
|
}
|
|
1258
1320
|
function resolvePiCliScript(deps = {}) {
|
|
1259
|
-
let existsSync11 = deps.existsSync ??
|
|
1321
|
+
let existsSync11 = deps.existsSync ?? fs3.existsSync, realpathSync5 = deps.realpathSync ?? fs3.realpathSync, readFileSync9 = deps.readFileSync ?? ((filePath, encoding) => fs3.readFileSync(filePath, encoding)), argv1 = deps.argv1 ?? process.argv[1];
|
|
1260
1322
|
if (argv1) {
|
|
1261
1323
|
let argvPath = normalizePath(argv1);
|
|
1262
1324
|
if (isRunnableNodeScript(argvPath, existsSync11))
|
|
@@ -1271,15 +1333,15 @@ function resolvePiCliScript(deps = {}) {
|
|
|
1271
1333
|
let packageJsonPath = (deps.resolvePackageJson ?? (() => {
|
|
1272
1334
|
let root = deps.piPackageRoot ?? resolvePiPackageRoot();
|
|
1273
1335
|
if (root)
|
|
1274
|
-
return
|
|
1336
|
+
return path3.join(root, "package.json");
|
|
1275
1337
|
let packageRoot = deps.resolvePackageEntry ? findPiPackageRootFromEntry(deps.resolvePackageEntry()) : resolveInstalledPiPackageRoot();
|
|
1276
1338
|
if (!packageRoot)
|
|
1277
1339
|
throw new Error(`Could not resolve ${PI_CODING_AGENT_PACKAGE} package root`);
|
|
1278
|
-
return
|
|
1279
|
-
}))(), binField = JSON.parse(
|
|
1340
|
+
return path3.join(packageRoot, "package.json");
|
|
1341
|
+
}))(), binField = JSON.parse(readFileSync9(packageJsonPath, "utf-8")).bin, binPath = typeof binField == "string" ? binField : binField?.pi ?? Object.values(binField ?? {})[0];
|
|
1280
1342
|
if (!binPath)
|
|
1281
1343
|
return;
|
|
1282
|
-
let candidate =
|
|
1344
|
+
let candidate = path3.resolve(path3.dirname(packageJsonPath), binPath);
|
|
1283
1345
|
if (isRunnableNodeScript(candidate, existsSync11))
|
|
1284
1346
|
return candidate;
|
|
1285
1347
|
} catch {
|
|
@@ -1298,7 +1360,7 @@ function getPiSpawnCommand(args, deps = {}) {
|
|
|
1298
1360
|
}
|
|
1299
1361
|
|
|
1300
1362
|
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/shared/jsonl-writer.js
|
|
1301
|
-
import * as
|
|
1363
|
+
import * as fs4 from "node:fs";
|
|
1302
1364
|
var DEFAULT_MAX_JSONL_BYTES = 50 * 1024 * 1024;
|
|
1303
1365
|
function createJsonlWriter(filePath, source, deps = {}) {
|
|
1304
1366
|
if (!filePath)
|
|
@@ -1308,7 +1370,7 @@ function createJsonlWriter(filePath, source, deps = {}) {
|
|
|
1308
1370
|
async close() {
|
|
1309
1371
|
}
|
|
1310
1372
|
};
|
|
1311
|
-
let createWriteStream2 = deps.createWriteStream ?? ((targetPath) =>
|
|
1373
|
+
let createWriteStream2 = deps.createWriteStream ?? ((targetPath) => fs4.createWriteStream(targetPath, { flags: "a" })), stream;
|
|
1312
1374
|
try {
|
|
1313
1375
|
stream = createWriteStream2(filePath);
|
|
1314
1376
|
} catch {
|
|
@@ -1346,13 +1408,6 @@ function createJsonlWriter(filePath, source, deps = {}) {
|
|
|
1346
1408
|
}
|
|
1347
1409
|
|
|
1348
1410
|
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/shared/post-exit-stdio-guard.js
|
|
1349
|
-
function trySignalChild(child, signal) {
|
|
1350
|
-
try {
|
|
1351
|
-
return child.kill(signal);
|
|
1352
|
-
} catch {
|
|
1353
|
-
return !1;
|
|
1354
|
-
}
|
|
1355
|
-
}
|
|
1356
1411
|
function attachPostExitStdioGuard(child, options) {
|
|
1357
1412
|
let { idleMs, hardMs } = options, exited = !1, stdoutEnded = !1, stderrEnded = !1, idleTimer, hardTimer, destroyUnendedStdio = () => {
|
|
1358
1413
|
if (!stdoutEnded)
|
|
@@ -1380,12 +1435,12 @@ function attachPostExitStdioGuard(child, options) {
|
|
|
1380
1435
|
}
|
|
1381
1436
|
|
|
1382
1437
|
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/shared/single-output.js
|
|
1383
|
-
import * as
|
|
1384
|
-
import * as
|
|
1438
|
+
import * as fs5 from "node:fs";
|
|
1439
|
+
import * as path4 from "node:path";
|
|
1385
1440
|
function extractChildWrittenOutput(messages, outputPath, cwd) {
|
|
1386
1441
|
if (!messages?.length || !outputPath)
|
|
1387
1442
|
return;
|
|
1388
|
-
let resolvedTarget =
|
|
1443
|
+
let resolvedTarget = path4.resolve(cwd ?? ".", outputPath), comparableTarget = process.platform === "win32" ? resolvedTarget.toLowerCase() : resolvedTarget, successfulCallIds = /* @__PURE__ */ new Set();
|
|
1389
1444
|
for (let message of messages)
|
|
1390
1445
|
message.role === "toolResult" && message.isError === !1 && typeof message.toolCallId == "string" && successfulCallIds.add(message.toolCallId);
|
|
1391
1446
|
let content;
|
|
@@ -1397,7 +1452,7 @@ function extractChildWrittenOutput(messages, outputPath, cwd) {
|
|
|
1397
1452
|
let args = typeof part.arguments == "object" && part.arguments !== null && !Array.isArray(part.arguments) ? part.arguments : {};
|
|
1398
1453
|
if (typeof args.path != "string" || typeof args.content != "string")
|
|
1399
1454
|
continue;
|
|
1400
|
-
let resolvedWritePath =
|
|
1455
|
+
let resolvedWritePath = path4.resolve(cwd ?? ".", args.path);
|
|
1401
1456
|
(process.platform === "win32" ? resolvedWritePath.toLowerCase() : resolvedWritePath) === comparableTarget && (content = args.content);
|
|
1402
1457
|
}
|
|
1403
1458
|
return content;
|
|
@@ -1413,12 +1468,12 @@ function normalizeSingleOutputOverride(output, defaultOutput) {
|
|
|
1413
1468
|
function resolveSingleOutputPath(output, runtimeCwd, requestedCwd, relativeBaseDir) {
|
|
1414
1469
|
if (typeof output != "string" || !output || output === "false" || output === "true")
|
|
1415
1470
|
return;
|
|
1416
|
-
if (
|
|
1471
|
+
if (path4.isAbsolute(output))
|
|
1417
1472
|
return output;
|
|
1418
1473
|
if (relativeBaseDir)
|
|
1419
|
-
return
|
|
1420
|
-
let baseCwd = requestedCwd ?
|
|
1421
|
-
return
|
|
1474
|
+
return path4.resolve(relativeBaseDir, output);
|
|
1475
|
+
let baseCwd = requestedCwd ? path4.isAbsolute(requestedCwd) ? requestedCwd : path4.resolve(runtimeCwd, requestedCwd) : runtimeCwd;
|
|
1476
|
+
return path4.resolve(baseCwd, output);
|
|
1422
1477
|
}
|
|
1423
1478
|
function formatOutputPathInstruction(outputPath, capabilities) {
|
|
1424
1479
|
return [
|
|
@@ -1461,7 +1516,7 @@ function formatByteSize(bytes) {
|
|
|
1461
1516
|
return `${value.toFixed(1)} ${units[unitIndex]}`;
|
|
1462
1517
|
}
|
|
1463
1518
|
function formatSavedOutputReference(savedPath, fullOutput) {
|
|
1464
|
-
let absolutePath =
|
|
1519
|
+
let absolutePath = path4.resolve(savedPath), bytes = Buffer.byteLength(fullOutput, "utf-8"), lines = countLines(fullOutput);
|
|
1465
1520
|
return {
|
|
1466
1521
|
path: absolutePath,
|
|
1467
1522
|
bytes,
|
|
@@ -1476,7 +1531,7 @@ function validateFileOnlyOutputMode(outputMode, outputPath, context) {
|
|
|
1476
1531
|
function captureSingleOutputSnapshot(outputPath) {
|
|
1477
1532
|
if (outputPath)
|
|
1478
1533
|
try {
|
|
1479
|
-
let stat =
|
|
1534
|
+
let stat = fs5.statSync(outputPath);
|
|
1480
1535
|
return { exists: !0, mtimeMs: stat.mtimeMs, size: stat.size };
|
|
1481
1536
|
} catch {
|
|
1482
1537
|
return { exists: !1 };
|
|
@@ -1486,7 +1541,7 @@ function persistSingleOutput(outputPath, fullOutput) {
|
|
|
1486
1541
|
if (!outputPath)
|
|
1487
1542
|
return {};
|
|
1488
1543
|
try {
|
|
1489
|
-
return
|
|
1544
|
+
return fs5.mkdirSync(path4.dirname(outputPath), { recursive: !0 }), fs5.writeFileSync(outputPath, fullOutput, "utf-8"), { savedPath: outputPath };
|
|
1490
1545
|
} catch (err) {
|
|
1491
1546
|
return { error: err instanceof Error ? err.message : String(err) };
|
|
1492
1547
|
}
|
|
@@ -1496,7 +1551,7 @@ function resolveSingleOutput(outputPath, fallbackOutput, beforeRun) {
|
|
|
1496
1551
|
return { fullOutput: fallbackOutput };
|
|
1497
1552
|
let changedSinceStart = !1;
|
|
1498
1553
|
try {
|
|
1499
|
-
let stat =
|
|
1554
|
+
let stat = fs5.statSync(outputPath);
|
|
1500
1555
|
changedSinceStart = !beforeRun?.exists || stat.mtimeMs !== beforeRun.mtimeMs || stat.size !== beforeRun.size;
|
|
1501
1556
|
} catch (error) {
|
|
1502
1557
|
let code = error && typeof error == "object" && "code" in error ? error.code : void 0;
|
|
@@ -1508,7 +1563,7 @@ function resolveSingleOutput(outputPath, fallbackOutput, beforeRun) {
|
|
|
1508
1563
|
}
|
|
1509
1564
|
if (changedSinceStart)
|
|
1510
1565
|
try {
|
|
1511
|
-
return { fullOutput:
|
|
1566
|
+
return { fullOutput: fs5.readFileSync(outputPath, "utf-8"), savedPath: outputPath };
|
|
1512
1567
|
} catch (error) {
|
|
1513
1568
|
return {
|
|
1514
1569
|
fullOutput: fallbackOutput,
|
|
@@ -1608,10 +1663,10 @@ function projectChildLifecycle(event, terminalAssistantStop = !1) {
|
|
|
1608
1663
|
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js
|
|
1609
1664
|
var artifactOutputByResult = /* @__PURE__ */ new WeakMap(), acceptanceOutputByResult = /* @__PURE__ */ new WeakMap();
|
|
1610
1665
|
function emptyUsage() {
|
|
1611
|
-
return { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, turns: 0 };
|
|
1666
|
+
return { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, turns: 0, unknownRequests: 0, partialRequests: 0, unknownCosts: 0 };
|
|
1612
1667
|
}
|
|
1613
1668
|
function sumUsage(target, source) {
|
|
1614
|
-
target.input += source.input, target.output += source.output, target.cacheRead += source.cacheRead, target.cacheWrite += source.cacheWrite, target.cost += source.cost, target.turns += source.turns;
|
|
1669
|
+
target.input += source.input, target.output += source.output, target.cacheRead += source.cacheRead, target.cacheWrite += source.cacheWrite, target.cost += source.cost, target.turns += source.turns, target.unknownRequests += source.unknownRequests ?? 0, target.partialRequests += source.partialRequests ?? 0, target.unknownCosts += source.unknownCosts ?? 0;
|
|
1615
1670
|
}
|
|
1616
1671
|
function formatTimeoutMessage(timeoutMs) {
|
|
1617
1672
|
return `Subagent timed out after ${timeoutMs}ms.`;
|
|
@@ -1682,7 +1737,7 @@ function snapshotResult(result2, progress) {
|
|
|
1682
1737
|
};
|
|
1683
1738
|
}
|
|
1684
1739
|
async function runSingleAttempt(runtimeCwd, spec, task, model, options, shared) {
|
|
1685
|
-
let effectiveThinking = options.thinkingOverride, modelArg = applyThinkingSuffix(model, effectiveThinking, options.thinkingOverride !== void 0), watchdogConfig = resolveWatchdogConfig(options.cwd ?? runtimeCwd), childWatchdog = watchdogConfig.ok ? resolveChildWatchdogConfig({
|
|
1740
|
+
let usageBeforeAttempt = parseSessionUsage(options.sessionFile ?? options.sessionDir), effectiveThinking = options.thinkingOverride, modelArg = applyThinkingSuffix(model, effectiveThinking, options.thinkingOverride !== void 0), watchdogConfig = resolveWatchdogConfig(options.cwd ?? runtimeCwd), childWatchdog = watchdogConfig.ok ? resolveChildWatchdogConfig({
|
|
1686
1741
|
config: watchdogConfig.config,
|
|
1687
1742
|
agent: spec.childId,
|
|
1688
1743
|
runId: options.runId,
|
|
@@ -1783,7 +1838,35 @@ async function runSingleAttempt(runtimeCwd, spec, task, model, options, shared)
|
|
|
1783
1838
|
env: spawnEnv,
|
|
1784
1839
|
stdio: ["ignore", "pipe", "pipe"],
|
|
1785
1840
|
windowsHide: !0
|
|
1786
|
-
}), jsonlWriter = createJsonlWriter(shared.jsonlPath, proc.stdout),
|
|
1841
|
+
}), jsonlWriter = createJsonlWriter(shared.jsonlPath, proc.stdout), spawned = typeof proc.pid == "number" && proc.pid > 0;
|
|
1842
|
+
proc.once("spawn", () => {
|
|
1843
|
+
spawned = !0;
|
|
1844
|
+
});
|
|
1845
|
+
let processClosed = !1, settled = !1, detached = !1, intercomStarted = !1, assistantError, removeAbortListener, removeInterruptListener, activityTimer, timeoutTimer, timeoutTerminationTimer, timeoutHardKillTimer, turnBudgetSoftReached = !1, turnBudgetTerminationTimer, turnBudgetHardKillTimer, protocolHardKillTimer, cancellationHardKillTimer, interruptTerminationTimer, terminationCheckTimer, terminationUnconfirmedReported = !1, clearCancellationTimers = () => {
|
|
1846
|
+
terminationCheckTimer && clearTimeout(terminationCheckTimer), terminationCheckTimer = void 0, cancellationHardKillTimer && clearTimeout(cancellationHardKillTimer), interruptTerminationTimer && clearTimeout(interruptTerminationTimer), cancellationHardKillTimer = void 0, interruptTerminationTimer = void 0;
|
|
1847
|
+
}, recordProcessError = (error) => {
|
|
1848
|
+
result2.error || (result2.error = error instanceof Error ? error.message : String(error)), progress.error = result2.error, !childExited && !processClosed && !settled && !detached && (progress.status = "running", fireUpdate());
|
|
1849
|
+
}, signalChild = (signal) => {
|
|
1850
|
+
if (childExited || processClosed || settled || detached)
|
|
1851
|
+
return !1;
|
|
1852
|
+
let sent = !1;
|
|
1853
|
+
try {
|
|
1854
|
+
sent = proc.kill(signal);
|
|
1855
|
+
} catch (error) {
|
|
1856
|
+
recordProcessError(error);
|
|
1857
|
+
}
|
|
1858
|
+
return !sent && !childExited && !processClosed && !settled && !detached && recordProcessError(`Subagent ${signal} could not be delivered; child exit is not confirmed.`), signal === "SIGKILL" && !childExited && !processClosed && !settled && !detached && !terminationCheckTimer && !terminationUnconfirmedReported && (terminationCheckTimer = setTimeout(() => {
|
|
1859
|
+
if (terminationCheckTimer = void 0, childExited || processClosed || settled || detached)
|
|
1860
|
+
return;
|
|
1861
|
+
terminationUnconfirmedReported = !0;
|
|
1862
|
+
let message = `Subagent termination unconfirmed after SIGKILL${proc.pid ? ` (diagnostic PID ${proc.pid})` : ""}. This foreground call still owns the child and waits for its exit. Verify the child process before starting replacement work.`;
|
|
1863
|
+
progress.status = "running", progress.error = message, progress.activityState = "needs_attention", progress.durationMs = Date.now() - startTime, appendRecentOutput(progress, [message]), emitUpdateSnapshot(message);
|
|
1864
|
+
}, 2e3), terminationCheckTimer.unref?.()), sent;
|
|
1865
|
+
}, scheduleCancellationHardKill = (delayMs) => {
|
|
1866
|
+
cancellationHardKillTimer || childExited || processClosed || settled || detached || (cancellationHardKillTimer = setTimeout(() => {
|
|
1867
|
+
cancellationHardKillTimer = void 0, !childExited && !processClosed && !settled && !detached && signalChild("SIGKILL");
|
|
1868
|
+
}, delayMs), cancellationHardKillTimer.unref?.());
|
|
1869
|
+
}, clearTurnBudgetTimers = () => {
|
|
1787
1870
|
turnBudgetTerminationTimer && (clearTimeout(turnBudgetTerminationTimer), turnBudgetTerminationTimer = void 0), turnBudgetHardKillTimer && (clearTimeout(turnBudgetHardKillTimer), turnBudgetHardKillTimer = void 0);
|
|
1788
1871
|
}, clearTimeoutTimers = () => {
|
|
1789
1872
|
timeoutTimer && (clearTimeout(timeoutTimer), timeoutTimer = void 0), timeoutTerminationTimer && (clearTimeout(timeoutTerminationTimer), timeoutTerminationTimer = void 0), timeoutHardKillTimer && (clearTimeout(timeoutHardKillTimer), timeoutHardKillTimer = void 0);
|
|
@@ -1805,9 +1888,11 @@ async function runSingleAttempt(runtimeCwd, spec, task, model, options, shared)
|
|
|
1805
1888
|
return;
|
|
1806
1889
|
}
|
|
1807
1890
|
childExited || finalDrainTimer || settled || processClosed || detached || (finalDrainTimer = setTimeout(() => {
|
|
1808
|
-
settled || processClosed || detached
|
|
1809
|
-
|
|
1810
|
-
|
|
1891
|
+
if (settled || processClosed || detached)
|
|
1892
|
+
return;
|
|
1893
|
+
forcedTerminationSignal = signalChild("SIGTERM") || forcedTerminationSignal, !cleanTerminalAssistantStopReceived && !agentSettledReceived && !assistantError && (result2.error = result2.error ?? `Subagent process did not exit within ${FINAL_STOP_GRACE_MS}ms after its terminal event. Forcing termination.`), finalHardKillTimer = setTimeout(() => {
|
|
1894
|
+
settled || processClosed || detached || (forcedTerminationSignal = signalChild("SIGKILL") || forcedTerminationSignal);
|
|
1895
|
+
}, HARD_KILL_MS), finalHardKillTimer.unref?.();
|
|
1811
1896
|
}, FINAL_STOP_GRACE_MS), finalDrainTimer.unref?.());
|
|
1812
1897
|
};
|
|
1813
1898
|
function armWatchdogTail() {
|
|
@@ -1841,7 +1926,7 @@ async function runSingleAttempt(runtimeCwd, spec, task, model, options, shared)
|
|
|
1841
1926
|
return;
|
|
1842
1927
|
options.intercomEvents?.emit(INTERCOM_DETACH_RESPONSE_EVENT, { requestId, accepted: !0, runId: options.runId, agent: spec.childId, childIndex: options.index ?? 0 }), detachForIntercom();
|
|
1843
1928
|
}), finish = (code) => {
|
|
1844
|
-
settled || (settled = !0, clearFinalDrainTimers(), clearWatchdogTailTimer(), clearStdioGuard(), clearTimeoutTimers(), clearTurnBudgetTimers(), protocolHardKillTimer && (clearTimeout(protocolHardKillTimer), protocolHardKillTimer = void 0), activityTimer && (clearInterval(activityTimer), activityTimer = void 0), unsubscribeIntercomDetach?.(), removeAbortListener?.(), removeInterruptListener?.(), resolve7(code));
|
|
1929
|
+
settled || (settled = !0, clearCancellationTimers(), clearFinalDrainTimers(), clearWatchdogTailTimer(), clearStdioGuard(), clearTimeoutTimers(), clearTurnBudgetTimers(), protocolHardKillTimer && (clearTimeout(protocolHardKillTimer), protocolHardKillTimer = void 0), activityTimer && (clearInterval(activityTimer), activityTimer = void 0), unsubscribeIntercomDetach?.(), removeAbortListener?.(), removeInterruptListener?.(), resolve7(code));
|
|
1845
1930
|
}, drainPendingControlEvents = () => {
|
|
1846
1931
|
if (pendingControlEvents.length === 0)
|
|
1847
1932
|
return;
|
|
@@ -1900,10 +1985,10 @@ async function runSingleAttempt(runtimeCwd, spec, task, model, options, shared)
|
|
|
1900
1985
|
if (!budget || result2.timedOut || result2.turnBudgetExceeded || interruptedByControl || processClosed || settled || detached)
|
|
1901
1986
|
return;
|
|
1902
1987
|
let message = turnBudgetExceededMessage(budget, turnCount);
|
|
1903
|
-
result2.turnBudgetExceeded = !0, result2.wrapUpRequested = !0, result2.turnBudget = turnBudgetState(budget, turnCount, !0), result2.error = message, result2.finalOutput = message, progress.status = "failed", progress.error = message, progress.durationMs = Date.now() - startTime, fireUpdate(),
|
|
1904
|
-
processClosed || settled || detached || result2.timedOut ||
|
|
1988
|
+
result2.turnBudgetExceeded = !0, result2.wrapUpRequested = !0, result2.turnBudget = turnBudgetState(budget, turnCount, !0), result2.error = message, result2.finalOutput = message, progress.status = "failed", progress.error = message, progress.durationMs = Date.now() - startTime, fireUpdate(), signalChild("SIGINT"), turnBudgetTerminationTimer = setTimeout(() => {
|
|
1989
|
+
processClosed || settled || detached || result2.timedOut || signalChild("SIGTERM");
|
|
1905
1990
|
}, 1e3), turnBudgetTerminationTimer.unref?.(), turnBudgetHardKillTimer = setTimeout(() => {
|
|
1906
|
-
processClosed || settled || detached || result2.timedOut ||
|
|
1991
|
+
processClosed || settled || detached || result2.timedOut || signalChild("SIGKILL");
|
|
1907
1992
|
}, 4e3), turnBudgetHardKillTimer.unref?.();
|
|
1908
1993
|
}, updateTurnBudget = (turnCount, terminalAssistantStop) => {
|
|
1909
1994
|
let budget = options.turnBudget;
|
|
@@ -2008,7 +2093,7 @@ async function runSingleAttempt(runtimeCwd, spec, task, model, options, shared)
|
|
|
2008
2093
|
let stopReason = evt.message.stopReason, hasToolCall = Array.isArray(evt.message.content) && evt.message.content.some((part) => part.type === "toolCall"), terminalAssistantStop = stopReason === "stop" && !hasToolCall;
|
|
2009
2094
|
updateTurnBudget(result2.usage.turns, terminalAssistantStop);
|
|
2010
2095
|
let u = evt.message.usage;
|
|
2011
|
-
if (u && (result2.usage.input += u.input || 0, result2.usage.output += u.output || 0, result2.usage.cacheRead += u.cacheRead || 0, result2.usage.cacheWrite += u.cacheWrite || 0, result2.usage.cost += u.cost?.total || 0, progress.tokens = result2.usage.input + result2.usage.output), !result2.model && evt.message.model) {
|
|
2096
|
+
if (u && (result2.usage.input += u.input || 0, result2.usage.output += u.output || 0, result2.usage.cacheRead += u.cacheRead || 0, result2.usage.cacheWrite += u.cacheWrite || 0, result2.usage.cost += u.cost?.total || 0, result2.usage.unknownRequests += +(u.measurement === "unknown"), result2.usage.partialRequests += +(u.measurement === "partial"), result2.usage.unknownCosts += +(u.costSource === "unknown"), progress.tokens = result2.usage.input + result2.usage.output + result2.usage.cacheRead + result2.usage.cacheWrite), !result2.model && evt.message.model) {
|
|
2012
2097
|
result2.model = evt.message.model;
|
|
2013
2098
|
let parsed = splitKnownThinkingSuffix(evt.message.model);
|
|
2014
2099
|
parsed.thinkingSuffix && (result2.thinking = parsed.thinkingSuffix.slice(1)), progress.model = result2.model, progress.thinking = result2.thinking;
|
|
@@ -2048,15 +2133,15 @@ async function runSingleAttempt(runtimeCwd, spec, task, model, options, shared)
|
|
|
2048
2133
|
let now = Date.now();
|
|
2049
2134
|
updateActivityState(now) && (progress.durationMs = now - startTime, fireUpdate());
|
|
2050
2135
|
}, 1e3), activityTimer.unref?.()), attemptTimeout && (timeoutTimer = setTimeout(() => {
|
|
2051
|
-
processClosed || settled || detached || interruptedByControl || (result2.timedOut = !0, result2.error = attemptTimeout.message, result2.finalOutput = attemptTimeout.message, progress.status = "failed", progress.error = attemptTimeout.message, progress.durationMs = Date.now() - startTime, fireUpdate(),
|
|
2052
|
-
processClosed || settled || detached ||
|
|
2136
|
+
processClosed || settled || detached || interruptedByControl || (result2.timedOut = !0, result2.error = attemptTimeout.message, result2.finalOutput = attemptTimeout.message, progress.status = "failed", progress.error = attemptTimeout.message, progress.durationMs = Date.now() - startTime, fireUpdate(), signalChild("SIGINT"), timeoutTerminationTimer = setTimeout(() => {
|
|
2137
|
+
processClosed || settled || detached || signalChild("SIGTERM");
|
|
2053
2138
|
}, 1e3), timeoutTerminationTimer.unref?.(), timeoutHardKillTimer = setTimeout(() => {
|
|
2054
|
-
processClosed || settled || detached ||
|
|
2139
|
+
processClosed || settled || detached || signalChild("SIGKILL");
|
|
2055
2140
|
}, 4e3), timeoutHardKillTimer.unref?.());
|
|
2056
2141
|
}, attemptTimeout.remainingMs), timeoutTimer.unref?.());
|
|
2057
2142
|
let stderrTail = createBoundedByteTail(), stdoutReader = createBoundedLineReader({ onLine: processLine, onLimit: (limit) => {
|
|
2058
|
-
result2.protocolError || (result2.protocolError = limit, result2.error = formatProtocolOutputLimit(limit), progress.status = "failed", progress.error = result2.error, progress.durationMs = Date.now() - startTime, fireUpdate(), childExited || (
|
|
2059
|
-
childExited ||
|
|
2143
|
+
result2.protocolError || (result2.protocolError = limit, result2.error = formatProtocolOutputLimit(limit), progress.status = "failed", progress.error = result2.error, progress.durationMs = Date.now() - startTime, fireUpdate(), childExited || (signalChild("SIGTERM"), protocolHardKillTimer = setTimeout(() => {
|
|
2144
|
+
childExited || signalChild("SIGKILL");
|
|
2060
2145
|
}, 3e3), protocolHardKillTimer.unref?.()));
|
|
2061
2146
|
} }), stderrReader = createBoundedLineReader({
|
|
2062
2147
|
stream: "stderr",
|
|
@@ -2064,15 +2149,19 @@ async function runSingleAttempt(runtimeCwd, spec, task, model, options, shared)
|
|
|
2064
2149
|
onLine: (line) => shared.transcriptWriter?.writeStderrLine(line),
|
|
2065
2150
|
onLimit: (limit) => shared.transcriptWriter?.writeStderrLine(formatProtocolOutputLimit(limit))
|
|
2066
2151
|
}), clearStdioGuard = attachPostExitStdioGuard(proc, { idleMs: 2e3, hardMs: 8e3 });
|
|
2067
|
-
|
|
2152
|
+
proc.stdout.on("data", (chunk) => stdoutReader.push(chunk)), proc.stderr.on("data", (chunk) => {
|
|
2068
2153
|
stderrTail.push(chunk), stderrReader.push(chunk);
|
|
2069
|
-
})
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2154
|
+
});
|
|
2155
|
+
let confirmChildExit = () => {
|
|
2156
|
+
childExited = !0, terminationUnconfirmedReported && (progress.error = result2.error, progress.activityState = void 0), clearCancellationTimers(), clearFinalDrainTimers();
|
|
2157
|
+
};
|
|
2158
|
+
if (proc.on("exit", confirmChildExit), proc.on("close", (code, signal) => {
|
|
2159
|
+
confirmChildExit(), clearFinalDrainTimers(), clearStdioGuard(), jsonlWriter.close().catch(() => {
|
|
2073
2160
|
});
|
|
2074
2161
|
let toolDiagnosticError = readChildToolDiagnosticError(toolDiagnosticPath);
|
|
2075
2162
|
cleanupTempDir(tempDir), stdoutReader.end(), stderrReader.end();
|
|
2163
|
+
let persistedUsage = parseSessionUsage(options.sessionFile ?? options.sessionDir ?? result2.sessionFile);
|
|
2164
|
+
persistedUsage && (result2.usageRequests = parseSessionRequests(options.sessionFile ?? options.sessionDir ?? result2.sessionFile), result2.usage = options.sessionFile ? persistedUsage : sessionUsageDelta(persistedUsage, usageBeforeAttempt), progress.tokens = result2.usage.input + result2.usage.output + result2.usage.cacheRead + result2.usage.cacheWrite);
|
|
2076
2165
|
let stderr = stderrTail.text(), closeError = result2.error ?? toolDiagnosticError ?? assistantError, forcedDrainAfterFinalSuccess = forcedTerminationSignal && (cleanTerminalAssistantStopReceived || agentSettledReceived) && !closeError;
|
|
2077
2166
|
code !== 0 && stderr.trim() && !closeError && !forcedDrainAfterFinalSuccess && (closeError = stderr.trim());
|
|
2078
2167
|
let finalCode = forcedDrainAfterFinalSuccess ? 0 : forcedTerminationSignal || signal ? code ?? 1 : code ?? 0;
|
|
@@ -2100,19 +2189,23 @@ async function runSingleAttempt(runtimeCwd, spec, task, model, options, shared)
|
|
|
2100
2189
|
}
|
|
2101
2190
|
!result2.error && closeError && (result2.error = closeError), processClosed = !0, finish(finalCode);
|
|
2102
2191
|
}), proc.on("error", (error) => {
|
|
2192
|
+
if (spawned) {
|
|
2193
|
+
recordProcessError(error);
|
|
2194
|
+
return;
|
|
2195
|
+
}
|
|
2103
2196
|
clearFinalDrainTimers(), clearStdioGuard(), jsonlWriter.close().catch(() => {
|
|
2104
2197
|
}), cleanupTempDir(tempDir), stdoutReader.end(), stderrReader.end(), result2.error || (result2.error = error instanceof Error ? error.message : String(error)), finish(1);
|
|
2105
2198
|
}), options.signal) {
|
|
2106
2199
|
let kill = () => {
|
|
2107
|
-
processClosed || detached || (
|
|
2200
|
+
childExited || processClosed || settled || detached || (signalChild("SIGTERM"), scheduleCancellationHardKill(3e3));
|
|
2108
2201
|
};
|
|
2109
2202
|
options.signal.aborted ? kill() : (options.signal.addEventListener("abort", kill, { once: !0 }), removeAbortListener = () => options.signal?.removeEventListener("abort", kill));
|
|
2110
2203
|
}
|
|
2111
2204
|
if (options.interruptSignal) {
|
|
2112
2205
|
let interrupt = () => {
|
|
2113
|
-
processClosed || detached || settled || result2.timedOut || (interruptedByControl = !0, clearTimeoutTimers(), progress.status = "running", progress.durationMs = Date.now() - startTime, result2.interrupted = !0, result2.finalOutput = "Interrupted. Waiting for explicit next action.", progress.activityState = void 0, fireUpdate(),
|
|
2114
|
-
settled || processClosed || detached ||
|
|
2115
|
-
}, 1e3).unref?.());
|
|
2206
|
+
processClosed || detached || settled || result2.timedOut || (interruptedByControl = !0, clearTimeoutTimers(), progress.status = "running", progress.durationMs = Date.now() - startTime, result2.interrupted = !0, result2.finalOutput = "Interrupted. Waiting for explicit next action.", progress.activityState = void 0, fireUpdate(), signalChild("SIGINT"), interruptTerminationTimer = setTimeout(() => {
|
|
2207
|
+
childExited || settled || processClosed || detached || signalChild("SIGTERM");
|
|
2208
|
+
}, 1e3), interruptTerminationTimer.unref?.(), scheduleCancellationHardKill(4e3));
|
|
2116
2209
|
};
|
|
2117
2210
|
options.interruptSignal.aborted ? interrupt() : (options.interruptSignal.addEventListener("abort", interrupt, { once: !0 }), removeInterruptListener = () => options.interruptSignal?.removeEventListener("abort", interrupt));
|
|
2118
2211
|
}
|
|
@@ -2303,9 +2396,9 @@ ${acceptanceFailure2}` : acceptanceFailure2, recoveredResult.progress && (recove
|
|
|
2303
2396
|
Acceptance evaluation failed: ${message}` : `Acceptance evaluation failed: ${message}`, options.onDetachedExit?.(recoveredResult);
|
|
2304
2397
|
});
|
|
2305
2398
|
}
|
|
2306
|
-
} : options, lastResult, modelsToTry = candidates.length > 0 ? candidates : [void 0];
|
|
2399
|
+
} : options, priorRequestIds = new Set(parseSessionRequests(options.sessionFile ?? options.sessionDir).map((request) => request.id)), lastResult, modelsToTry = candidates.length > 0 ? candidates : [void 0];
|
|
2307
2400
|
for (let i = 0; i < modelsToTry.length; i++) {
|
|
2308
|
-
let candidate = modelsToTry[i], outputSnapshot = captureSingleOutputSnapshot(options.outputPath), result3 = await runSingleAttempt(runtimeCwd, spec, taskWithAcceptance, candidate, detachedAwareOptions, {
|
|
2401
|
+
let candidate = modelsToTry[i], outputSnapshot = captureSingleOutputSnapshot(options.outputPath), usageBeforeAttempt = parseSessionUsage(options.sessionFile ?? options.sessionDir), result3 = await runSingleAttempt(runtimeCwd, spec, taskWithAcceptance, candidate, detachedAwareOptions, {
|
|
2309
2402
|
sessionEnabled,
|
|
2310
2403
|
systemPrompt,
|
|
2311
2404
|
resolvedSkillNames: resolvedSkills.length > 0 ? resolvedSkills.map((skill) => skill.name) : void 0,
|
|
@@ -2316,8 +2409,8 @@ Acceptance evaluation failed: ${message}` : `Acceptance evaluation failed: ${mes
|
|
|
2316
2409
|
attemptNotes,
|
|
2317
2410
|
outputSnapshot,
|
|
2318
2411
|
originalTask: task
|
|
2319
|
-
});
|
|
2320
|
-
lastResult = result3, result3.model ? attemptedModels.push(result3.model) : candidate && attemptedModels.push(candidate), sumUsage(aggregateUsage, result3.usage), totalToolCount += result3.progressSummary?.toolCount ?? 0, totalDurationMs += result3.progressSummary?.durationMs ?? 0;
|
|
2412
|
+
}), persistedUsage = parseSessionUsage(options.sessionFile ?? options.sessionDir ?? result3.sessionFile);
|
|
2413
|
+
persistedUsage && (result3.usage = sessionUsageDelta(persistedUsage, usageBeforeAttempt)), lastResult = result3, result3.model ? attemptedModels.push(result3.model) : candidate && attemptedModels.push(candidate), sumUsage(aggregateUsage, result3.usage), totalToolCount += result3.progressSummary?.toolCount ?? 0, totalDurationMs += result3.progressSummary?.durationMs ?? 0;
|
|
2321
2414
|
let attemptSucceeded = result3.exitCode === 0 && !result3.error, attempt = {
|
|
2322
2415
|
model: result3.model ?? candidate ?? spec.model ?? "default",
|
|
2323
2416
|
success: attemptSucceeded,
|
|
@@ -2339,10 +2432,10 @@ Acceptance evaluation failed: ${message}` : `Acceptance evaluation failed: ${mes
|
|
|
2339
2432
|
messages: [],
|
|
2340
2433
|
usage: emptyUsage(),
|
|
2341
2434
|
error: "Subagent did not produce a result."
|
|
2342
|
-
};
|
|
2343
|
-
if (result2.usage = aggregateUsage, result2.attemptedModels = attemptedModels.length > 0 ? attemptedModels : void 0, result2.modelAttempts = modelAttempts.length > 0 ? modelAttempts : void 0, result2.progressSummary = {
|
|
2435
|
+
}, cumulativeResumeUsage = options.sessionFile ? parseSessionUsage(options.sessionFile) : null;
|
|
2436
|
+
if (result2.usage = cumulativeResumeUsage ?? aggregateUsage, result2.usageRequests = parseSessionRequests(options.sessionFile ?? options.sessionDir ?? result2.sessionFile).filter((request) => !!options.sessionFile || !priorRequestIds.has(request.id)), result2.usageRequests.length === 0 && (result2.usageRequests = void 0), result2.attemptedModels = attemptedModels.length > 0 ? attemptedModels : void 0, result2.modelAttempts = modelAttempts.length > 0 ? modelAttempts : void 0, result2.progressSummary = {
|
|
2344
2437
|
toolCount: totalToolCount,
|
|
2345
|
-
tokens:
|
|
2438
|
+
tokens: result2.usage.input + result2.usage.output + result2.usage.cacheRead + result2.usage.cacheWrite,
|
|
2346
2439
|
durationMs: totalDurationMs
|
|
2347
2440
|
}, attemptNotes.length > 0 && result2.progress && (result2.progress.recentOutput = [...attemptNotes, ...result2.progress.recentOutput], result2.progress.recentOutput.length > 50 && result2.progress.recentOutput.splice(50)), transcriptWriter && (result2.transcriptPath = artifactPathsResult?.transcriptPath), transcriptWriter?.getError() && (result2.transcriptError = transcriptWriter.getError()), artifactPathsResult && options.artifactConfig?.enabled !== !1) {
|
|
2348
2441
|
if (result2.artifactPaths = artifactPathsResult, options.artifactConfig?.includeOutput !== !1 && writeArtifact(artifactPathsResult.outputPath, artifactOutputByResult.get(result2) ?? result2.finalOutput ?? ""), options.maxOutput) {
|
|
@@ -2372,10 +2465,10 @@ ${acceptanceFailure}` : acceptanceFailure, result2.progress && (result2.progress
|
|
|
2372
2465
|
}
|
|
2373
2466
|
|
|
2374
2467
|
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/shared/run-history.js
|
|
2375
|
-
import * as
|
|
2376
|
-
import * as
|
|
2468
|
+
import * as fs6 from "node:fs";
|
|
2469
|
+
import * as path5 from "node:path";
|
|
2377
2470
|
function getHistoryPath() {
|
|
2378
|
-
return
|
|
2471
|
+
return path5.join(getAgentDir(), "run-history.jsonl");
|
|
2379
2472
|
}
|
|
2380
2473
|
function recordRun(agent, task, exitCode, durationMs) {
|
|
2381
2474
|
try {
|
|
@@ -2387,7 +2480,7 @@ function recordRun(agent, task, exitCode, durationMs) {
|
|
|
2387
2480
|
duration: durationMs,
|
|
2388
2481
|
...exitCode !== 0 ? { exit: exitCode } : {}
|
|
2389
2482
|
}, historyPath = getHistoryPath();
|
|
2390
|
-
|
|
2483
|
+
fs6.mkdirSync(path5.dirname(historyPath), { recursive: !0 }), fs6.appendFileSync(historyPath, `${JSON.stringify(entry)}
|
|
2391
2484
|
`);
|
|
2392
2485
|
} catch {
|
|
2393
2486
|
}
|
|
@@ -2395,9 +2488,9 @@ function recordRun(agent, task, exitCode, durationMs) {
|
|
|
2395
2488
|
|
|
2396
2489
|
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/shared/worktree.js
|
|
2397
2490
|
import { spawnSync } from "node:child_process";
|
|
2398
|
-
import * as
|
|
2491
|
+
import * as fs7 from "node:fs";
|
|
2399
2492
|
import * as os from "node:os";
|
|
2400
|
-
import * as
|
|
2493
|
+
import * as path6 from "node:path";
|
|
2401
2494
|
var DEFAULT_WORKTREE_SETUP_HOOK_TIMEOUT_MS = 3e4;
|
|
2402
2495
|
function runGit(cwd, args) {
|
|
2403
2496
|
let result2 = spawnSync("git", ["-C", cwd, ...args], { encoding: "utf-8" });
|
|
@@ -2423,9 +2516,9 @@ function resolveRepoState(cwd) {
|
|
|
2423
2516
|
return { toplevel, cwdRelative, baseCommit };
|
|
2424
2517
|
}
|
|
2425
2518
|
function normalizeComparableCwd(cwd) {
|
|
2426
|
-
let resolved =
|
|
2519
|
+
let resolved = path6.resolve(cwd);
|
|
2427
2520
|
try {
|
|
2428
|
-
return
|
|
2521
|
+
return fs7.realpathSync(resolved);
|
|
2429
2522
|
} catch {
|
|
2430
2523
|
return resolved;
|
|
2431
2524
|
}
|
|
@@ -2436,7 +2529,7 @@ function findWorktreeTaskCwdConflict(tasks, sharedCwd) {
|
|
|
2436
2529
|
let task = tasks[index];
|
|
2437
2530
|
if (!task.cwd)
|
|
2438
2531
|
continue;
|
|
2439
|
-
let taskCwd =
|
|
2532
|
+
let taskCwd = path6.isAbsolute(task.cwd) ? task.cwd : path6.resolve(sharedCwd, task.cwd);
|
|
2440
2533
|
if (normalizeComparableCwd(taskCwd) !== normalizedSharedCwd)
|
|
2441
2534
|
return { index, agent: task.agent, cwd: task.cwd };
|
|
2442
2535
|
}
|
|
@@ -2457,9 +2550,9 @@ function resolveWorktreeBaseDir(configuredBaseDir, repoRoot) {
|
|
|
2457
2550
|
let trimmed = rawBaseDir.trim();
|
|
2458
2551
|
if (!trimmed)
|
|
2459
2552
|
throw new Error("worktree base directory cannot be empty");
|
|
2460
|
-
let expanded = trimmed.startsWith("~/") ?
|
|
2553
|
+
let expanded = trimmed.startsWith("~/") ? path6.join(os.homedir(), trimmed.slice(2)) : trimmed, resolved = path6.isAbsolute(expanded) ? expanded : path6.resolve(repoRoot, expanded);
|
|
2461
2554
|
try {
|
|
2462
|
-
|
|
2555
|
+
fs7.mkdirSync(resolved, { recursive: !0 });
|
|
2463
2556
|
} catch (error) {
|
|
2464
2557
|
let message = error instanceof Error ? error.message : String(error);
|
|
2465
2558
|
throw new Error(`failed to create worktree base directory ${resolved}: ${message}`);
|
|
@@ -2467,25 +2560,25 @@ function resolveWorktreeBaseDir(configuredBaseDir, repoRoot) {
|
|
|
2467
2560
|
return resolved;
|
|
2468
2561
|
}
|
|
2469
2562
|
function buildWorktreePath(baseDir, runId, index) {
|
|
2470
|
-
return
|
|
2563
|
+
return path6.join(baseDir, `pi-worktree-${runId}-${index}`);
|
|
2471
2564
|
}
|
|
2472
2565
|
function resolveRepoCwdRelative(cwd) {
|
|
2473
2566
|
let repoCheck = runGit(cwd, ["rev-parse", "--is-inside-work-tree"]);
|
|
2474
2567
|
if (repoCheck.status !== 0 || repoCheck.stdout.trim() !== "true")
|
|
2475
2568
|
throw new Error("worktree isolation requires a git repository");
|
|
2476
|
-
let rawPrefix = runGitChecked(cwd, ["rev-parse", "--show-prefix"]).trim(), normalizedPrefix = rawPrefix ?
|
|
2569
|
+
let rawPrefix = runGitChecked(cwd, ["rev-parse", "--show-prefix"]).trim(), normalizedPrefix = rawPrefix ? path6.normalize(rawPrefix.replace(/[\\/]+$/, "")) : "";
|
|
2477
2570
|
return normalizedPrefix === "." ? "" : normalizedPrefix;
|
|
2478
2571
|
}
|
|
2479
2572
|
function resolveExpectedWorktreeAgentCwd(cwd, runId, index, baseDir) {
|
|
2480
2573
|
let cwdRelative = resolveRepoCwdRelative(cwd), repoRoot = runGitChecked(cwd, ["rev-parse", "--show-toplevel"]).trim(), worktreePath = buildWorktreePath(resolveWorktreeBaseDir(baseDir, repoRoot), runId, index);
|
|
2481
|
-
return cwdRelative ?
|
|
2574
|
+
return cwdRelative ? path6.join(worktreePath, cwdRelative) : worktreePath;
|
|
2482
2575
|
}
|
|
2483
2576
|
function linkNodeModulesIfPresent(toplevel, worktreePath) {
|
|
2484
|
-
let nodeModulesPath =
|
|
2485
|
-
if (!
|
|
2577
|
+
let nodeModulesPath = path6.join(toplevel, "node_modules"), nodeModulesLinkPath = path6.join(worktreePath, "node_modules");
|
|
2578
|
+
if (!fs7.existsSync(nodeModulesPath) || fs7.existsSync(nodeModulesLinkPath))
|
|
2486
2579
|
return !1;
|
|
2487
2580
|
try {
|
|
2488
|
-
return
|
|
2581
|
+
return fs7.symlinkSync(nodeModulesPath, nodeModulesLinkPath), !0;
|
|
2489
2582
|
} catch {
|
|
2490
2583
|
return !1;
|
|
2491
2584
|
}
|
|
@@ -2503,16 +2596,16 @@ function resolveWorktreeSetupHook(repoRoot, config) {
|
|
|
2503
2596
|
let hookPath = config.hookPath.trim();
|
|
2504
2597
|
if (!hookPath)
|
|
2505
2598
|
throw new Error("worktree setup hook path cannot be empty");
|
|
2506
|
-
let expandedHookPath = hookPath.startsWith("~/") ?
|
|
2507
|
-
if (
|
|
2599
|
+
let expandedHookPath = hookPath.startsWith("~/") ? path6.join(os.homedir(), hookPath.slice(2)) : hookPath, resolvedPath;
|
|
2600
|
+
if (path6.isAbsolute(expandedHookPath))
|
|
2508
2601
|
resolvedPath = expandedHookPath;
|
|
2509
2602
|
else if (expandedHookPath.includes("/") || expandedHookPath.includes("\\"))
|
|
2510
|
-
resolvedPath =
|
|
2603
|
+
resolvedPath = path6.resolve(repoRoot, expandedHookPath);
|
|
2511
2604
|
else
|
|
2512
2605
|
throw new Error("worktree setup hook must be an absolute path or a repo-relative path");
|
|
2513
|
-
if (!
|
|
2606
|
+
if (!fs7.existsSync(resolvedPath))
|
|
2514
2607
|
throw new Error(`worktree setup hook not found: ${resolvedPath}`);
|
|
2515
|
-
if (
|
|
2608
|
+
if (fs7.statSync(resolvedPath).isDirectory())
|
|
2516
2609
|
throw new Error(`worktree setup hook must be a file, got directory: ${resolvedPath}`);
|
|
2517
2610
|
return {
|
|
2518
2611
|
hookPath: resolvedPath,
|
|
@@ -2523,14 +2616,14 @@ function normalizeSyntheticPath(worktreePath, rawPath) {
|
|
|
2523
2616
|
let trimmed = rawPath.trim();
|
|
2524
2617
|
if (!trimmed)
|
|
2525
2618
|
throw new Error("synthetic path cannot be empty");
|
|
2526
|
-
if (
|
|
2619
|
+
if (path6.isAbsolute(trimmed))
|
|
2527
2620
|
throw new Error(`synthetic path must be relative: ${rawPath}`);
|
|
2528
|
-
let resolved =
|
|
2621
|
+
let resolved = path6.resolve(worktreePath, trimmed), relative2 = path6.relative(worktreePath, resolved);
|
|
2529
2622
|
if (!relative2 || relative2 === ".")
|
|
2530
2623
|
throw new Error(`synthetic path cannot target the worktree root: ${rawPath}`);
|
|
2531
|
-
if (relative2 === ".." || relative2.startsWith(`..${
|
|
2624
|
+
if (relative2 === ".." || relative2.startsWith(`..${path6.sep}`) || path6.isAbsolute(relative2))
|
|
2532
2625
|
throw new Error(`synthetic path escapes the worktree root: ${rawPath}`);
|
|
2533
|
-
return
|
|
2626
|
+
return path6.normalize(relative2);
|
|
2534
2627
|
}
|
|
2535
2628
|
function hasTrackedEntries(worktreePath, relativePath) {
|
|
2536
2629
|
let result2 = runGit(worktreePath, ["ls-files", "--", relativePath]);
|
|
@@ -2587,7 +2680,7 @@ function createSingleWorktree(toplevel, cwdRelative, runId, index, baseCommit, s
|
|
|
2587
2680
|
let message = add.stderr.trim() || add.stdout.trim() || `failed to create worktree ${worktreePath}`;
|
|
2588
2681
|
throw new Error(message);
|
|
2589
2682
|
}
|
|
2590
|
-
let agentCwd = cwdRelative ?
|
|
2683
|
+
let agentCwd = cwdRelative ? path6.join(worktreePath, cwdRelative) : worktreePath;
|
|
2591
2684
|
try {
|
|
2592
2685
|
let nodeModulesLinked = linkNodeModulesIfPresent(toplevel, worktreePath), syntheticPaths = nodeModulesLinked ? ["node_modules"] : [];
|
|
2593
2686
|
if (setupHook) {
|
|
@@ -2625,26 +2718,26 @@ function createSingleWorktree(toplevel, cwdRelative, runId, index, baseCommit, s
|
|
|
2625
2718
|
}
|
|
2626
2719
|
}
|
|
2627
2720
|
function removeSyntheticPath(worktree, syntheticPath) {
|
|
2628
|
-
let resolved =
|
|
2629
|
-
if (!relative2 || relative2 === "." || relative2 === ".." || relative2.startsWith(`..${
|
|
2721
|
+
let resolved = path6.resolve(worktree.path, syntheticPath), relative2 = path6.relative(worktree.path, resolved);
|
|
2722
|
+
if (!relative2 || relative2 === "." || relative2 === ".." || relative2.startsWith(`..${path6.sep}`) || path6.isAbsolute(relative2))
|
|
2630
2723
|
return;
|
|
2631
2724
|
let stat;
|
|
2632
2725
|
try {
|
|
2633
|
-
stat =
|
|
2726
|
+
stat = fs7.lstatSync(resolved);
|
|
2634
2727
|
} catch (error) {
|
|
2635
2728
|
if ((error && typeof error == "object" && "code" in error ? error.code : void 0) === "ENOENT")
|
|
2636
2729
|
return;
|
|
2637
2730
|
throw error;
|
|
2638
2731
|
}
|
|
2639
2732
|
if (stat.isSymbolicLink()) {
|
|
2640
|
-
|
|
2733
|
+
fs7.unlinkSync(resolved);
|
|
2641
2734
|
return;
|
|
2642
2735
|
}
|
|
2643
2736
|
if (stat.isDirectory()) {
|
|
2644
|
-
|
|
2737
|
+
fs7.rmSync(resolved, { recursive: !0, force: !0 });
|
|
2645
2738
|
return;
|
|
2646
2739
|
}
|
|
2647
|
-
|
|
2740
|
+
fs7.rmSync(resolved, { force: !0 });
|
|
2648
2741
|
}
|
|
2649
2742
|
function removeSyntheticPathsBeforeDiff(worktree) {
|
|
2650
2743
|
if (worktree.syntheticPaths.length === 0)
|
|
@@ -2677,7 +2770,7 @@ function parseNumstat(numstat) {
|
|
|
2677
2770
|
function captureWorktreeDiff(setup, worktree, agent, patchPath) {
|
|
2678
2771
|
removeSyntheticPathsBeforeDiff(worktree), runGitChecked(worktree.path, ["add", "-A"]);
|
|
2679
2772
|
let diffStat = runGitChecked(worktree.path, ["diff", "--cached", "--stat", setup.baseCommit]).trim(), patch = runGitChecked(worktree.path, ["diff", "--cached", setup.baseCommit]), numstat = runGitChecked(worktree.path, ["diff", "--cached", "--numstat", setup.baseCommit]);
|
|
2680
|
-
if (
|
|
2773
|
+
if (fs7.writeFileSync(patchPath, patch, "utf-8"), !patch.trim())
|
|
2681
2774
|
return emptyDiff(worktree.index, agent, worktree.branch, patchPath);
|
|
2682
2775
|
let parsed = parseNumstat(numstat);
|
|
2683
2776
|
return {
|
|
@@ -2693,7 +2786,7 @@ function captureWorktreeDiff(setup, worktree, agent, patchPath) {
|
|
|
2693
2786
|
}
|
|
2694
2787
|
function writeEmptyPatch(patchPath) {
|
|
2695
2788
|
try {
|
|
2696
|
-
|
|
2789
|
+
fs7.writeFileSync(patchPath, "", "utf-8");
|
|
2697
2790
|
} catch {
|
|
2698
2791
|
}
|
|
2699
2792
|
}
|
|
@@ -2730,13 +2823,13 @@ function createWorktrees(cwd, runId, count, options) {
|
|
|
2730
2823
|
}
|
|
2731
2824
|
function diffWorktrees(setup, agents, diffsDir) {
|
|
2732
2825
|
try {
|
|
2733
|
-
|
|
2826
|
+
fs7.mkdirSync(diffsDir, { recursive: !0 });
|
|
2734
2827
|
} catch {
|
|
2735
2828
|
return [];
|
|
2736
2829
|
}
|
|
2737
2830
|
let diffs = [];
|
|
2738
2831
|
for (let index = 0; index < setup.worktrees.length; index++) {
|
|
2739
|
-
let worktree = setup.worktrees[index], agent = agents[index] ?? `task-${index + 1}`, patchPath =
|
|
2832
|
+
let worktree = setup.worktrees[index], agent = agents[index] ?? `task-${index + 1}`, patchPath = path6.join(diffsDir, `task-${index}-${safePatchAgentName(agent)}.patch`);
|
|
2740
2833
|
try {
|
|
2741
2834
|
diffs.push(captureWorktreeDiff(setup, worktree, agent, patchPath));
|
|
2742
2835
|
} catch {
|
|
@@ -2760,7 +2853,7 @@ function formatWorktreeDiffSummary(diffs) {
|
|
|
2760
2853
|
let lines = ["=== Worktree Changes ===", ""];
|
|
2761
2854
|
for (let diff of changed)
|
|
2762
2855
|
lines.push(`--- Task ${diff.index + 1} (${diff.agent}): ${diff.filesChanged} files changed, +${diff.insertions} -${diff.deletions} ---`), diff.diffStat.trim().length > 0 && lines.push(diff.diffStat), lines.push("");
|
|
2763
|
-
let patchesDir =
|
|
2856
|
+
let patchesDir = path6.dirname(changed[0].patchPath);
|
|
2764
2857
|
return lines.push(`Full patches: ${patchesDir}`), lines.join(`
|
|
2765
2858
|
`).trimEnd();
|
|
2766
2859
|
}
|
|
@@ -3325,11 +3418,11 @@ async function runParallelChainTasks(input) {
|
|
|
3325
3418
|
let effectiveModel = effectiveModels[taskIndex], maxSubagentDepth = resolveChildMaxSubagentDepth(input.maxSubagentDepth, taskChildConfig?.maxSubagentDepth), toolBudget = resolveChainToolBudget({ stepBudget: task.toolBudget, runBudget: input.toolBudget, agentBudget: taskChildConfig?.toolBudget, configBudget: input.configToolBudget });
|
|
3326
3419
|
if (toolBudget.error)
|
|
3327
3420
|
throw new Error(toolBudget.error);
|
|
3328
|
-
let taskCwd = input.worktreeSetup ? input.worktreeSetup.worktrees[taskIndex].agentCwd : resolveChildCwd(input.cwd ?? input.ctx.cwd, task.cwd), outputPath = typeof behavior.output == "string" ?
|
|
3421
|
+
let taskCwd = input.worktreeSetup ? input.worktreeSetup.worktrees[taskIndex].agentCwd : resolveChildCwd(input.cwd ?? input.ctx.cwd, task.cwd), outputPath = typeof behavior.output == "string" ? path7.isAbsolute(behavior.output) ? behavior.output : path7.join(input.chainDir, behavior.output) : void 0;
|
|
3329
3422
|
taskStr = withChainHandoff(injectSingleOutputInstruction(taskStr, outputPath, taskChildConfig), input.stepIndex < input.totalSteps - 1);
|
|
3330
3423
|
let interruptController = new AbortController();
|
|
3331
3424
|
input.foregroundControl && (input.foregroundControl.currentAgent = task.description || task.agent, input.foregroundControl.currentChildId = task.agent, input.foregroundControl.currentIndex = input.globalTaskIndex + taskIndex, input.foregroundControl.currentActivityState = void 0, input.foregroundControl.updatedAt = Date.now(), input.foregroundControl.interrupt = () => interruptController.signal.aborted ? !1 : (interruptController.abort(), input.foregroundControl.currentActivityState = void 0, input.foregroundControl.updatedAt = Date.now(), !0));
|
|
3332
|
-
let structuredRuntime = task.outputSchema ? createStructuredOutputRuntime(task.outputSchema,
|
|
3425
|
+
let structuredRuntime = task.outputSchema ? createStructuredOutputRuntime(task.outputSchema, path7.join(input.chainDir, "structured-output")) : void 0, result2 = await runSync(input.ctx.cwd, normalizeChildSpec({
|
|
3333
3426
|
task: taskStr,
|
|
3334
3427
|
description: task.description,
|
|
3335
3428
|
permissions: task.permissions,
|
|
@@ -3412,7 +3505,17 @@ async function runParallelChainTasks(input) {
|
|
|
3412
3505
|
} : void 0
|
|
3413
3506
|
});
|
|
3414
3507
|
return input.foregroundControl?.currentIndex === input.globalTaskIndex + taskIndex && (input.foregroundControl.interrupt = void 0, input.foregroundControl.updatedAt = Date.now()), result2.exitCode !== 0 && failFast && (aborted = !0), recordRun(task.agent, cleanTask, result2.exitCode, result2.progressSummary?.durationMs ?? 0), result2;
|
|
3415
|
-
}, input.globalSemaphore
|
|
3508
|
+
}, input.globalSemaphore, {
|
|
3509
|
+
signal: input.signal,
|
|
3510
|
+
onAbort: (task) => ({
|
|
3511
|
+
agent: task.agent,
|
|
3512
|
+
task: "(cancelled)",
|
|
3513
|
+
exitCode: 1,
|
|
3514
|
+
messages: [],
|
|
3515
|
+
usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, turns: 0 },
|
|
3516
|
+
error: "Subagent launch cancelled."
|
|
3517
|
+
})
|
|
3518
|
+
});
|
|
3416
3519
|
}
|
|
3417
3520
|
async function executeChain(params) {
|
|
3418
3521
|
let { chain: chainSteps, agents, ctx, signal, runId, cwd, shareEnabled, sessionDirForIndex, sessionFileForIndex, sessionFileForTask, thinkingOverrideForTask, artifactsDir, artifactConfig, includeProgress, clarify, onUpdate, onControlEvent, controlConfig, onDetachedExit, childIntercomTarget, orchestratorIntercomTarget, communicationEnabled, foregroundControl, intercomEvents, chainSkills: chainSkillsParam, chainDir: chainDirBase, modelScope } = params, chainSkills = chainSkillsParam ?? [], results = [], outputs = {}, dynamicChildren = {}, dynamicGroupStatuses = {}, allProgress = [], allArtifactPaths = [], chainAgents = chainSteps.map((step) => isParallelStep(step) ? `[${step.parallel.map((t) => t.description || t.label || t.agent || "child").join("+")}]` : isDynamicParallelStep(step) ? `expand:${step.parallel.description || step.parallel.label || step.parallel.agent || "child"}` : step.description || step.label || step.agent || "child"), totalSteps = chainSteps.length, makeDetailsInput = (overrides = {}) => ({
|
|
@@ -3517,7 +3620,7 @@ async function executeChain(params) {
|
|
|
3517
3620
|
try {
|
|
3518
3621
|
let agentNames = step.parallel.map((task) => task.agent), parallelBehaviors = resolveParallelBehaviors(step.parallel, stepIndex, chainSkills).map((behavior, taskIndex) => suppressProgressForReadOnlyTask(behavior, parallelTemplates[taskIndex] ?? step.parallel[taskIndex]?.task, originalTask));
|
|
3519
3622
|
for (let taskIndex = 0; taskIndex < step.parallel.length; taskIndex++) {
|
|
3520
|
-
let behavior = parallelBehaviors[taskIndex], outputPath = typeof behavior.output == "string" ?
|
|
3623
|
+
let behavior = parallelBehaviors[taskIndex], outputPath = typeof behavior.output == "string" ? path7.isAbsolute(behavior.output) ? behavior.output : path7.join(chainDir, behavior.output) : void 0, validationError = validateFileOnlyOutputMode(behavior.outputMode, outputPath, `Parallel chain step ${stepIndex + 1} task ${taskIndex + 1} (${step.parallel[taskIndex].agent})`);
|
|
3521
3624
|
if (validationError)
|
|
3522
3625
|
return buildChainExecutionErrorResult(validationError, makeDetailsInput({ currentStepIndex: stepIndex, currentFlatIndex: globalTaskIndex + taskIndex }));
|
|
3523
3626
|
}
|
|
@@ -3615,7 +3718,7 @@ ${failureSummary}`;
|
|
|
3615
3718
|
outputName && (outputs[outputName] = outputEntryFromResult(parallelResults[taskIndex], stepIndex));
|
|
3616
3719
|
}
|
|
3617
3720
|
let taskResults = parallelResults.map((result2, i) => {
|
|
3618
|
-
let outputTarget = parallelBehaviors[i]?.output, outputTargetPath = typeof outputTarget == "string" ?
|
|
3721
|
+
let outputTarget = parallelBehaviors[i]?.output, outputTargetPath = typeof outputTarget == "string" ? path7.isAbsolute(outputTarget) ? outputTarget : path7.join(chainDir, outputTarget) : void 0;
|
|
3619
3722
|
return {
|
|
3620
3723
|
agent: result2.agent,
|
|
3621
3724
|
taskIndex: i,
|
|
@@ -3624,10 +3727,10 @@ ${failureSummary}`;
|
|
|
3624
3727
|
error: result2.error,
|
|
3625
3728
|
timedOut: result2.timedOut,
|
|
3626
3729
|
outputTargetPath,
|
|
3627
|
-
outputTargetExists: outputTargetPath ?
|
|
3730
|
+
outputTargetExists: outputTargetPath ? fs8.existsSync(outputTargetPath) : void 0
|
|
3628
3731
|
};
|
|
3629
3732
|
});
|
|
3630
|
-
prev = aggregateParallelOutputs(taskResults), prev = appendParallelWorktreeSummary(prev, worktreeSetup,
|
|
3733
|
+
prev = aggregateParallelOutputs(taskResults), prev = appendParallelWorktreeSummary(prev, worktreeSetup, path7.join(chainDir, "worktree-diffs", `step-${stepIndex}`), agentNames);
|
|
3631
3734
|
} finally {
|
|
3632
3735
|
worktreeSetup && cleanupWorktrees(worktreeSetup);
|
|
3633
3736
|
}
|
|
@@ -3689,7 +3792,7 @@ ${failureSummary}`;
|
|
|
3689
3792
|
failFast: step.failFast
|
|
3690
3793
|
}, parallelTemplates = materialized.parallel.map((task) => task.task ?? "{previous}"), parallelBehaviors = resolveParallelBehaviors(dynamicParallelStep.parallel, stepIndex, chainSkills).map((behavior, taskIndex) => suppressProgressForReadOnlyTask(behavior, parallelTemplates[taskIndex] ?? dynamicParallelStep.parallel[taskIndex]?.task, originalTask));
|
|
3691
3794
|
for (let taskIndex = 0; taskIndex < dynamicParallelStep.parallel.length; taskIndex++) {
|
|
3692
|
-
let behavior = parallelBehaviors[taskIndex], outputPath = typeof behavior.output == "string" ?
|
|
3795
|
+
let behavior = parallelBehaviors[taskIndex], outputPath = typeof behavior.output == "string" ? path7.isAbsolute(behavior.output) ? behavior.output : path7.join(chainDir, behavior.output) : void 0, validationError = validateFileOnlyOutputMode(behavior.outputMode, outputPath, `Dynamic chain step ${stepIndex + 1} item ${taskIndex + 1} (${dynamicParallelStep.parallel[taskIndex].agent})`);
|
|
3693
3796
|
if (validationError)
|
|
3694
3797
|
return dynamicGroupStatuses[stepIndex] = { status: "failed", error: validationError }, buildChainExecutionErrorResult(validationError, makeDetailsInput({ currentStepIndex: stepIndex, currentFlatIndex: globalTaskIndex + taskIndex }));
|
|
3695
3798
|
}
|
|
@@ -3850,14 +3953,14 @@ ${failureSummary}`;
|
|
|
3850
3953
|
thinking: seqStep.thinking,
|
|
3851
3954
|
availableModels,
|
|
3852
3955
|
preferredProvider: ctx.model?.provider
|
|
3853
|
-
}), outputPath = typeof behavior.output == "string" ?
|
|
3956
|
+
}), outputPath = typeof behavior.output == "string" ? path7.isAbsolute(behavior.output) ? behavior.output : path7.join(chainDir, behavior.output) : void 0;
|
|
3854
3957
|
stepTask = withChainHandoff(injectSingleOutputInstruction(stepTask, outputPath, agentConfig), stepIndex < totalSteps - 1);
|
|
3855
3958
|
let validationError = validateFileOnlyOutputMode(behavior.outputMode, outputPath, `Chain step ${stepIndex + 1} (${seqStep.agent})`);
|
|
3856
3959
|
if (validationError)
|
|
3857
3960
|
return buildChainExecutionErrorResult(validationError, makeDetailsInput({ currentStepIndex: stepIndex, currentFlatIndex: globalTaskIndex }));
|
|
3858
3961
|
let maxSubagentDepth = resolveChildMaxSubagentDepth(params.maxSubagentDepth, agentConfig.maxSubagentDepth), childIndex = globalTaskIndex, interruptController = new AbortController();
|
|
3859
3962
|
foregroundControl && (foregroundControl.currentAgent = seqStep.description || seqStep.agent, foregroundControl.currentChildId = seqStep.agent, foregroundControl.currentIndex = childIndex, foregroundControl.currentActivityState = void 0, foregroundControl.updatedAt = Date.now(), foregroundControl.interrupt = () => interruptController.signal.aborted ? !1 : (interruptController.abort(), foregroundControl.currentActivityState = void 0, foregroundControl.updatedAt = Date.now(), !0));
|
|
3860
|
-
let structuredRuntime = seqStep.outputSchema ? createStructuredOutputRuntime(seqStep.outputSchema,
|
|
3963
|
+
let structuredRuntime = seqStep.outputSchema ? createStructuredOutputRuntime(seqStep.outputSchema, path7.join(chainDir, "structured-output")) : void 0, toolBudget = resolveChainToolBudget({ stepBudget: seqStep.toolBudget, runBudget: params.toolBudget, agentBudget: agentConfig?.toolBudget, configBudget: params.configToolBudget });
|
|
3861
3964
|
if (toolBudget.error)
|
|
3862
3965
|
return buildChainExecutionErrorResult(toolBudget.error, {
|
|
3863
3966
|
results,
|
|
@@ -3978,9 +4081,9 @@ ${failureSummary}`;
|
|
|
3978
4081
|
};
|
|
3979
4082
|
if (behavior.output)
|
|
3980
4083
|
try {
|
|
3981
|
-
let expectedPath =
|
|
3982
|
-
if (!
|
|
3983
|
-
let mdFiles =
|
|
4084
|
+
let expectedPath = path7.isAbsolute(behavior.output) ? behavior.output : path7.join(chainDir, behavior.output);
|
|
4085
|
+
if (!fs8.existsSync(expectedPath)) {
|
|
4086
|
+
let mdFiles = fs8.readdirSync(chainDir).filter((file) => file.endsWith(".md") && file !== "progress.md"), warning = mdFiles.length > 0 ? `Agent wrote to different file(s): ${mdFiles.join(", ")} instead of ${behavior.output}` : `Agent did not create expected output file: ${behavior.output}`;
|
|
3984
4087
|
r.error = r.error ? `${r.error}
|
|
3985
4088
|
${warning}` : warning;
|
|
3986
4089
|
}
|
|
@@ -3996,37 +4099,37 @@ ${warning}` : warning;
|
|
|
3996
4099
|
}
|
|
3997
4100
|
|
|
3998
4101
|
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/extension/doctor.js
|
|
3999
|
-
import * as
|
|
4000
|
-
import * as
|
|
4102
|
+
import * as fs10 from "node:fs";
|
|
4103
|
+
import * as path9 from "node:path";
|
|
4001
4104
|
|
|
4002
4105
|
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.js
|
|
4003
4106
|
import { spawn as spawn2 } from "node:child_process";
|
|
4004
|
-
import * as
|
|
4005
|
-
import * as
|
|
4107
|
+
import * as fs9 from "node:fs";
|
|
4108
|
+
import * as path8 from "node:path";
|
|
4006
4109
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
4007
4110
|
import { createRequire } from "node:module";
|
|
4008
4111
|
var require2 = createRequire(new URL("../builtin-extensions/pi-subagents/src/runs/background/async-execution.js", import.meta.url).href), piPackageRoot = resolvePiPackageRoot();
|
|
4009
4112
|
function resolveJitiCliFromPackageJson(packageJsonPath) {
|
|
4010
|
-
if (!
|
|
4113
|
+
if (!fs9.existsSync(packageJsonPath))
|
|
4011
4114
|
return;
|
|
4012
|
-
let packageRoot =
|
|
4115
|
+
let packageRoot = path8.dirname(packageJsonPath), binField = JSON.parse(fs9.readFileSync(packageJsonPath, "utf-8")).bin, candidates = [typeof binField == "string" ? binField : binField?.jiti ?? Object.values(binField ?? {})[0], "lib/jiti-cli.mjs"].filter((candidate) => !!candidate);
|
|
4013
4116
|
for (let candidate of candidates) {
|
|
4014
|
-
let cliPath =
|
|
4015
|
-
if (
|
|
4117
|
+
let cliPath = path8.resolve(packageRoot, candidate);
|
|
4118
|
+
if (fs9.existsSync(cliPath))
|
|
4016
4119
|
return cliPath;
|
|
4017
4120
|
}
|
|
4018
4121
|
}
|
|
4019
4122
|
function resolveJitiCliPath() {
|
|
4020
4123
|
let candidates = [
|
|
4021
4124
|
() => require2.resolve("jiti/package.json"),
|
|
4022
|
-
() => piPackageRoot ? createRequire(
|
|
4125
|
+
() => piPackageRoot ? createRequire(path8.join(piPackageRoot, "package.json")).resolve("jiti/package.json") : void 0,
|
|
4023
4126
|
() => {
|
|
4024
4127
|
if (!process.argv[1])
|
|
4025
4128
|
return;
|
|
4026
|
-
let piEntry =
|
|
4129
|
+
let piEntry = fs9.realpathSync(process.argv[1]);
|
|
4027
4130
|
return createRequire(piEntry).resolve("jiti/package.json");
|
|
4028
4131
|
},
|
|
4029
|
-
() => piPackageRoot ?
|
|
4132
|
+
() => piPackageRoot ? path8.join(piPackageRoot, "node_modules", "jiti", "package.json") : void 0
|
|
4030
4133
|
];
|
|
4031
4134
|
for (let candidate of candidates)
|
|
4032
4135
|
try {
|
|
@@ -4053,12 +4156,12 @@ function isAsyncAvailable() {
|
|
|
4053
4156
|
return jitiCliPath !== void 0;
|
|
4054
4157
|
}
|
|
4055
4158
|
function isNodeExecutableName(execPath) {
|
|
4056
|
-
let basename3 =
|
|
4159
|
+
let basename3 = path8.basename(execPath).toLowerCase();
|
|
4057
4160
|
return basename3 === "node" || basename3 === "node.exe" || basename3 === "nodejs" || basename3 === "nodejs.exe";
|
|
4058
4161
|
}
|
|
4059
4162
|
function canUseCurrentNodeExecutable(execPath) {
|
|
4060
4163
|
try {
|
|
4061
|
-
return
|
|
4164
|
+
return fs9.accessSync(execPath, process.platform === "win32" ? fs9.constants.F_OK : fs9.constants.X_OK), !0;
|
|
4062
4165
|
} catch {
|
|
4063
4166
|
return !1;
|
|
4064
4167
|
}
|
|
@@ -4070,14 +4173,14 @@ function resolveAsyncRunnerLogPaths(cfg) {
|
|
|
4070
4173
|
let asyncDir = typeof cfg.asyncDir == "string" ? cfg.asyncDir : void 0;
|
|
4071
4174
|
if (asyncDir)
|
|
4072
4175
|
return {
|
|
4073
|
-
stdoutPath:
|
|
4074
|
-
stderrPath:
|
|
4176
|
+
stdoutPath: path8.join(asyncDir, "runner.stdout.log"),
|
|
4177
|
+
stderrPath: path8.join(asyncDir, "runner.stderr.log")
|
|
4075
4178
|
};
|
|
4076
4179
|
}
|
|
4077
4180
|
function closeFd(fd) {
|
|
4078
4181
|
if (fd !== void 0)
|
|
4079
4182
|
try {
|
|
4080
|
-
|
|
4183
|
+
fs9.closeSync(fd);
|
|
4081
4184
|
} catch {
|
|
4082
4185
|
}
|
|
4083
4186
|
}
|
|
@@ -4092,9 +4195,9 @@ function waitForStartupInterval(delayMs = 20) {
|
|
|
4092
4195
|
;
|
|
4093
4196
|
}
|
|
4094
4197
|
function readRunnerStartup(startupPath, expectedState, expectedToken) {
|
|
4095
|
-
if (
|
|
4198
|
+
if (fs9.existsSync(startupPath))
|
|
4096
4199
|
try {
|
|
4097
|
-
let payload = JSON.parse(
|
|
4200
|
+
let payload = JSON.parse(fs9.readFileSync(startupPath, "utf-8"));
|
|
4098
4201
|
return payload.state === "error" && typeof payload.error == "string" ? { ok: !1, error: payload.error } : payload.state !== expectedState ? void 0 : typeof payload.token != "string" || expectedToken !== void 0 && payload.token !== expectedToken ? { ok: !1, error: `Async runner wrote an invalid ${expectedState} startup handshake: ${startupPath}` } : { ok: !0, token: payload.token };
|
|
4099
4202
|
} catch (error) {
|
|
4100
4203
|
return { ok: !1, error: `Failed to read async runner startup handshake '${startupPath}': ${error instanceof Error ? error.message : String(error)}` };
|
|
@@ -4116,10 +4219,10 @@ function waitForRunnerStartup(startupPath, expectedState, timeoutMs, expectedTok
|
|
|
4116
4219
|
function writeRunnerStartupControl(filePath, payload) {
|
|
4117
4220
|
let tempPath = `${filePath}.${process.pid}.${Date.now()}.${Math.random().toString(36).slice(2)}.tmp`;
|
|
4118
4221
|
try {
|
|
4119
|
-
|
|
4222
|
+
fs9.writeFileSync(tempPath, JSON.stringify(payload), { encoding: "utf-8", mode: 384 }), fs9.renameSync(tempPath, filePath);
|
|
4120
4223
|
} catch (error) {
|
|
4121
4224
|
try {
|
|
4122
|
-
|
|
4225
|
+
fs9.rmSync(tempPath, { force: !0 });
|
|
4123
4226
|
} catch {
|
|
4124
4227
|
}
|
|
4125
4228
|
throw error;
|
|
@@ -4151,19 +4254,19 @@ function spawnRunner(cfg, suffix, cwd) {
|
|
|
4151
4254
|
if (!jitiCliPath)
|
|
4152
4255
|
return { error: "upstream jiti for TypeScript execution could not be found; ensure package dependencies are installed" };
|
|
4153
4256
|
try {
|
|
4154
|
-
if (!
|
|
4257
|
+
if (!fs9.statSync(cwd).isDirectory())
|
|
4155
4258
|
return { error: `cwd is not a directory: ${cwd}` };
|
|
4156
4259
|
} catch {
|
|
4157
4260
|
return { error: `cwd does not exist: ${cwd}` };
|
|
4158
4261
|
}
|
|
4159
|
-
|
|
4262
|
+
fs9.mkdirSync(TEMP_ROOT_DIR, { recursive: !0 });
|
|
4160
4263
|
let cfgPath = getAsyncConfigPath(suffix);
|
|
4161
|
-
|
|
4162
|
-
let runnerTsPath =
|
|
4163
|
-
startupPath &&
|
|
4264
|
+
fs9.writeFileSync(cfgPath, JSON.stringify(cfg));
|
|
4265
|
+
let runnerTsPath = path8.join(path8.dirname(fileURLToPath2(new URL("../builtin-extensions/pi-subagents/src/runs/background/async-execution.js", import.meta.url).href)), "subagent-runner.ts"), runner = fs9.existsSync(runnerTsPath) ? runnerTsPath : runnerTsPath.replace(/\.ts$/, ".js"), nodeCommand = resolveAsyncRunnerNodeCommand(), startupPath = typeof cfg.revivalLease == "object" && typeof cfg.asyncDir == "string" ? path8.join(cfg.asyncDir, "runner-startup.json") : void 0, startupAckPath = startupPath ? path8.join(path8.dirname(startupPath), "runner-startup-ack.json") : void 0, startupProceedPath = startupPath ? path8.join(path8.dirname(startupPath), "runner-startup-proceed.json") : void 0;
|
|
4266
|
+
startupPath && fs9.rmSync(startupPath, { force: !0 }), startupAckPath && fs9.rmSync(startupAckPath, { force: !0 }), startupProceedPath && fs9.rmSync(startupProceedPath, { force: !0 });
|
|
4164
4267
|
let logPaths = resolveAsyncRunnerLogPaths(cfg), stdoutFd, stderrFd;
|
|
4165
4268
|
try {
|
|
4166
|
-
logPaths && (
|
|
4269
|
+
logPaths && (fs9.mkdirSync(path8.dirname(logPaths.stdoutPath), { recursive: !0 }), stdoutFd = fs9.openSync(logPaths.stdoutPath, "a"), stderrFd = fs9.openSync(logPaths.stderrPath, "a"));
|
|
4167
4270
|
let proc = spawn2(nodeCommand, [jitiCliPath, runner, cfgPath], {
|
|
4168
4271
|
cwd,
|
|
4169
4272
|
detached: !0,
|
|
@@ -4197,7 +4300,7 @@ function spawnRunner(cfg, suffix, cwd) {
|
|
|
4197
4300
|
return terminateRunnerBeforeProceed(proc.pid), { error: `Failed to authorize async runner startup: ${error instanceof Error ? error.message : String(error)}` };
|
|
4198
4301
|
}
|
|
4199
4302
|
try {
|
|
4200
|
-
|
|
4303
|
+
fs9.rmSync(startupPath, { force: !0 });
|
|
4201
4304
|
} catch {
|
|
4202
4305
|
}
|
|
4203
4306
|
}
|
|
@@ -4254,10 +4357,10 @@ function buildAsyncRunnerSteps(id, params) {
|
|
|
4254
4357
|
}), toolBudgetInput = spec.toolBudget ?? params.toolBudget ?? params.configToolBudget, resolvedToolBudget = validateToolBudgetConfig(toolBudgetInput, spec.toolBudget ? "toolBudget" : "config.toolBudget");
|
|
4255
4358
|
if (resolvedToolBudget.error)
|
|
4256
4359
|
throw new AsyncStartValidationError(resolvedToolBudget.error);
|
|
4257
|
-
let stepCwd = resolveChildCwd(runnerCwd, s.cwd), instructionCwd = behaviorCwd ?? stepCwd, behavior = suppressProgressForReadOnlyTask(resolvedBehavior ?? resolveStepBehavior(buildStepOverrides(s), chainSkills), s.task, originalTask), inheritedRelativeParallelOutput = parallelOutputNamespace && s.output === void 0 && typeof behavior.output == "string" && !
|
|
4360
|
+
let stepCwd = resolveChildCwd(runnerCwd, s.cwd), instructionCwd = behaviorCwd ?? stepCwd, behavior = suppressProgressForReadOnlyTask(resolvedBehavior ?? resolveStepBehavior(buildStepOverrides(s), chainSkills), s.task, originalTask), inheritedRelativeParallelOutput = parallelOutputNamespace && s.output === void 0 && typeof behavior.output == "string" && !path8.isAbsolute(behavior.output);
|
|
4258
4361
|
inheritedRelativeParallelOutput && parallelOutputNamespace.taskIndex !== void 0 && (behavior = {
|
|
4259
4362
|
...behavior,
|
|
4260
|
-
output:
|
|
4363
|
+
output: path8.join(`parallel-${parallelOutputNamespace.stepIndex}`, String(parallelOutputNamespace.taskIndex), behavior.output)
|
|
4261
4364
|
});
|
|
4262
4365
|
let namespaceOutputPath = !!(inheritedRelativeParallelOutput && parallelOutputNamespace.taskIndex === void 0), skillNames = behavior.skills === !1 ? [] : behavior.skills, { resolved: resolvedSkills, missing: missingSkills } = resolveSkillsWithFallback(skillNames, stepCwd, ctx.cwd, void 0, stepCwd);
|
|
4263
4366
|
if (missingSkills.includes("pi-subagents"))
|
|
@@ -4331,7 +4434,7 @@ ${injection}` : injection;
|
|
|
4331
4434
|
acceptanceInput: s.acceptance,
|
|
4332
4435
|
acceptanceRole: spec.effectivePermissions === "read-only" ? "read-only" : "writer",
|
|
4333
4436
|
...s.outputSchema ? { structuredOutputSchema: s.outputSchema } : {},
|
|
4334
|
-
...s.outputSchema ? { structuredOutput: createStructuredOutputRuntime(s.outputSchema,
|
|
4437
|
+
...s.outputSchema ? { structuredOutput: createStructuredOutputRuntime(s.outputSchema, path8.join(asyncDir, "structured-output")) } : {},
|
|
4335
4438
|
...resolvedToolBudget.budget ? { toolBudget: resolvedToolBudget.budget } : {}
|
|
4336
4439
|
};
|
|
4337
4440
|
}, flatStepIndex = 0, nextFlatStep = () => {
|
|
@@ -4428,9 +4531,9 @@ ${injection}` : injection;
|
|
|
4428
4531
|
}
|
|
4429
4532
|
}
|
|
4430
4533
|
function executeAsyncChain(id, params) {
|
|
4431
|
-
let { chain, ctx, cwd, maxOutput, artifactsDir, artifactConfig, shareEnabled, sessionRoot, sessionFilesByFlatIndex, thinkingOverridesByFlatIndex, maxSubagentDepth, worktreeSetupHook, worktreeSetupHookTimeoutMs, worktreeBaseDir, controlConfig, controlIntercomTarget, childIntercomTarget, nestedRoute } = params, resultMode = params.resultMode ?? "chain", inheritedNestedRoute = resolveInheritedNestedRouteFromEnv(), nestedAddress = inheritedNestedRoute ? resolveNestedParentAddressFromEnv() : void 0, asyncDir = inheritedNestedRoute ?
|
|
4534
|
+
let { chain, ctx, cwd, maxOutput, artifactsDir, artifactConfig, shareEnabled, sessionRoot, sessionFilesByFlatIndex, thinkingOverridesByFlatIndex, maxSubagentDepth, worktreeSetupHook, worktreeSetupHookTimeoutMs, worktreeBaseDir, controlConfig, controlIntercomTarget, childIntercomTarget, nestedRoute } = params, resultMode = params.resultMode ?? "chain", inheritedNestedRoute = resolveInheritedNestedRouteFromEnv(), nestedAddress = inheritedNestedRoute ? resolveNestedParentAddressFromEnv() : void 0, asyncDir = inheritedNestedRoute ? path8.join(TEMP_ROOT_DIR, "nested-subagent-runs", inheritedNestedRoute.rootRunId, id) : path8.join(ASYNC_DIR, id);
|
|
4432
4535
|
try {
|
|
4433
|
-
|
|
4536
|
+
fs9.mkdirSync(asyncDir, { recursive: !0 });
|
|
4434
4537
|
} catch (error) {
|
|
4435
4538
|
let message = error instanceof Error ? error.message : String(error);
|
|
4436
4539
|
return {
|
|
@@ -4450,8 +4553,8 @@ function executeAsyncChain(id, params) {
|
|
|
4450
4553
|
chainSkills: params.chainSkills,
|
|
4451
4554
|
sessionFilesByFlatIndex,
|
|
4452
4555
|
thinkingOverridesByFlatIndex,
|
|
4453
|
-
progressDir: params.progressDir ?? (artifactsDir ?
|
|
4454
|
-
outputBaseDir: artifactsDir ?
|
|
4556
|
+
progressDir: params.progressDir ?? (artifactsDir ? path8.join(artifactsDir, "progress", id) : resultMode === "parallel" ? path8.join(asyncDir, "progress") : void 0),
|
|
4557
|
+
outputBaseDir: artifactsDir ? path8.join(artifactsDir, "outputs", id) : void 0,
|
|
4455
4558
|
dynamicFanoutMaxItems: params.dynamicFanoutMaxItems,
|
|
4456
4559
|
maxSubagentDepth,
|
|
4457
4560
|
waitToolEnabled: params.waitToolEnabled,
|
|
@@ -4462,7 +4565,7 @@ function executeAsyncChain(id, params) {
|
|
|
4462
4565
|
});
|
|
4463
4566
|
if ("error" in built) {
|
|
4464
4567
|
try {
|
|
4465
|
-
|
|
4568
|
+
fs9.rmSync(asyncDir, { recursive: !0, force: !0 });
|
|
4466
4569
|
} catch {
|
|
4467
4570
|
}
|
|
4468
4571
|
return formatAsyncStartError(resultMode, built.error);
|
|
@@ -4472,14 +4575,14 @@ function executeAsyncChain(id, params) {
|
|
|
4472
4575
|
spawnResult = spawnRunner({
|
|
4473
4576
|
id,
|
|
4474
4577
|
steps,
|
|
4475
|
-
resultPath: inheritedNestedRoute ? nestedResultsPath(inheritedNestedRoute.rootRunId, id) :
|
|
4578
|
+
resultPath: inheritedNestedRoute ? nestedResultsPath(inheritedNestedRoute.rootRunId, id) : path8.join(RESULTS_DIR, `${id}.json`),
|
|
4476
4579
|
cwd: runnerCwd,
|
|
4477
4580
|
placeholder: "{previous}",
|
|
4478
4581
|
maxOutput,
|
|
4479
4582
|
artifactsDir: artifactConfig.enabled ? artifactsDir : void 0,
|
|
4480
4583
|
artifactConfig,
|
|
4481
4584
|
share: shareEnabled,
|
|
4482
|
-
sessionDir: sessionRoot ?
|
|
4585
|
+
sessionDir: sessionRoot ? path8.join(sessionRoot, `async-${id}`) : void 0,
|
|
4483
4586
|
asyncDir,
|
|
4484
4587
|
sessionId: ctx.currentSessionId,
|
|
4485
4588
|
piPackageRoot,
|
|
@@ -4603,9 +4706,9 @@ function executeAsyncSingle(id, params) {
|
|
|
4603
4706
|
|
|
4604
4707
|
${injection}` : injection;
|
|
4605
4708
|
}
|
|
4606
|
-
let inheritedNestedRoute = resolveInheritedNestedRouteFromEnv(), nestedAddress = inheritedNestedRoute ? resolveNestedParentAddressFromEnv() : void 0, asyncDir = inheritedNestedRoute ?
|
|
4709
|
+
let inheritedNestedRoute = resolveInheritedNestedRouteFromEnv(), nestedAddress = inheritedNestedRoute ? resolveNestedParentAddressFromEnv() : void 0, asyncDir = inheritedNestedRoute ? path8.join(TEMP_ROOT_DIR, "nested-subagent-runs", inheritedNestedRoute.rootRunId, id) : path8.join(ASYNC_DIR, id);
|
|
4607
4710
|
try {
|
|
4608
|
-
|
|
4711
|
+
fs9.mkdirSync(asyncDir, { recursive: !0 });
|
|
4609
4712
|
} catch (error) {
|
|
4610
4713
|
let message = error instanceof Error ? error.message : String(error);
|
|
4611
4714
|
return {
|
|
@@ -4614,7 +4717,7 @@ ${injection}` : injection;
|
|
|
4614
4717
|
details: { mode: "single", results: [] }
|
|
4615
4718
|
};
|
|
4616
4719
|
}
|
|
4617
|
-
let effectiveOutput = normalizeSingleOutputOverride(params.output ?? spec.output, typeof spec.output == "string" ? spec.output : void 0), outputPath = resolveSingleOutputPath(effectiveOutput, ctx.cwd, runnerCwd, params.outputBaseDir ?? (artifactsDir ?
|
|
4720
|
+
let effectiveOutput = normalizeSingleOutputOverride(params.output ?? spec.output, typeof spec.output == "string" ? spec.output : void 0), outputPath = resolveSingleOutputPath(effectiveOutput, ctx.cwd, runnerCwd, params.outputBaseDir ?? (artifactsDir ? path8.join(artifactsDir, "outputs", id) : void 0)), childToolShape = { tools: spec.effectivePermissions === "read-only" ? ["read", "grep", "find", "ls", "bash"] : void 0 };
|
|
4618
4721
|
systemPrompt = injectOutputPathSystemPrompt(systemPrompt, outputPath, childToolShape);
|
|
4619
4722
|
let outputMode = params.outputMode ?? spec.outputMode ?? "inline", validationError = validateFileOnlyOutputMode(outputMode, outputPath, `Async single run (${agent})`);
|
|
4620
4723
|
if (validationError)
|
|
@@ -4632,7 +4735,7 @@ ${injection}` : injection;
|
|
|
4632
4735
|
let deadlineAt = params.absoluteDeadlineAt ?? (params.timeoutMs !== void 0 ? Date.now() + params.timeoutMs : void 0), timeoutMs = params.absoluteDeadlineAt !== void 0 && deadlineAt !== void 0 ? deadlineAt - Date.now() : params.timeoutMs;
|
|
4633
4736
|
if (timeoutMs !== void 0 && timeoutMs <= 0)
|
|
4634
4737
|
return formatAsyncStartError("single", "The source run's absolute deadline expired before recovery could launch.");
|
|
4635
|
-
let initialTurnBudget = params.turnBudget ? initialTurnBudgetState(params.turnBudget) : void 0, resolvedSessionDir = params.sessionDir ?? (sessionRoot ?
|
|
4738
|
+
let initialTurnBudget = params.turnBudget ? initialTurnBudgetState(params.turnBudget) : void 0, resolvedSessionDir = params.sessionDir ?? (sessionRoot ? path8.join(sessionRoot, `async-${id}`) : void 0), resolvedAcceptance = resolveAsyncSingleAcceptance({
|
|
4636
4739
|
restoredAcceptance: params.restoredAcceptance,
|
|
4637
4740
|
launchAcceptance: params.acceptance ?? spec.acceptance,
|
|
4638
4741
|
agentName: agent,
|
|
@@ -4668,7 +4771,7 @@ ${injection}` : injection;
|
|
|
4668
4771
|
artifactConfig
|
|
4669
4772
|
};
|
|
4670
4773
|
try {
|
|
4671
|
-
writePrivateAtomicJson(
|
|
4774
|
+
writePrivateAtomicJson(path8.join(asyncDir, "recovery-descriptor.json"), recoveryDescriptor);
|
|
4672
4775
|
} catch (error) {
|
|
4673
4776
|
return formatAsyncStartError("single", `Failed to persist async recovery descriptor for '${id}': ${error instanceof Error ? error.message : String(error)}`);
|
|
4674
4777
|
}
|
|
@@ -4705,7 +4808,7 @@ ${injection}` : injection;
|
|
|
4705
4808
|
...resolvedToolBudget.budget ? { toolBudget: resolvedToolBudget.budget } : {}
|
|
4706
4809
|
}
|
|
4707
4810
|
],
|
|
4708
|
-
resultPath: inheritedNestedRoute ? nestedResultsPath(inheritedNestedRoute.rootRunId, id) :
|
|
4811
|
+
resultPath: inheritedNestedRoute ? nestedResultsPath(inheritedNestedRoute.rootRunId, id) : path8.join(RESULTS_DIR, `${id}.json`),
|
|
4709
4812
|
cwd: runnerCwd,
|
|
4710
4813
|
placeholder: "{previous}",
|
|
4711
4814
|
maxOutput,
|
|
@@ -4825,11 +4928,11 @@ function lineFromCheck(label, check) {
|
|
|
4825
4928
|
}
|
|
4826
4929
|
function formatExistingDirectory(label, dirPath) {
|
|
4827
4930
|
try {
|
|
4828
|
-
if (!
|
|
4931
|
+
if (!fs10.existsSync(dirPath))
|
|
4829
4932
|
return `- ${label}: missing (${dirPath})`;
|
|
4830
|
-
if (!
|
|
4933
|
+
if (!fs10.statSync(dirPath).isDirectory())
|
|
4831
4934
|
throw new Error(`not a directory: ${dirPath}`);
|
|
4832
|
-
return
|
|
4935
|
+
return fs10.accessSync(dirPath, fs10.constants.R_OK | fs10.constants.W_OK), `- ${label}: ok (${dirPath})`;
|
|
4833
4936
|
} catch (error) {
|
|
4834
4937
|
return `- ${label}: failed (${dirPath}) \u2014 ${errorText(error)}`;
|
|
4835
4938
|
}
|
|
@@ -4852,13 +4955,13 @@ function formatSkillSourceCounts(skills) {
|
|
|
4852
4955
|
return parts.length > 0 ? parts.join(", ") : "none";
|
|
4853
4956
|
}
|
|
4854
4957
|
function formatConfiguredSessionDir(input) {
|
|
4855
|
-
return input.requestedSessionDir ?
|
|
4958
|
+
return input.requestedSessionDir ? path9.resolve(input.expandTilde?.(input.requestedSessionDir) ?? input.requestedSessionDir) : input.config.defaultSessionDir ? path9.resolve(input.expandTilde?.(input.config.defaultSessionDir) ?? input.config.defaultSessionDir) : "not configured";
|
|
4856
4959
|
}
|
|
4857
4960
|
function formatSessionLines(input) {
|
|
4858
4961
|
let sessionFile = input.currentSessionFile ?? null, lines = [
|
|
4859
4962
|
lineFromCheck("configured session dir", () => `- configured session dir: ${formatConfiguredSessionDir(input)}`),
|
|
4860
4963
|
`- current session file: ${sessionFile ?? "not available"}`,
|
|
4861
|
-
`- current session dir: ${sessionFile ?
|
|
4964
|
+
`- current session dir: ${sessionFile ? path9.dirname(sessionFile) : "not available"}`,
|
|
4862
4965
|
`- current session id: ${input.currentSessionId ?? input.state.currentSessionId ?? "not available"}`
|
|
4863
4966
|
];
|
|
4864
4967
|
return input.sessionError && lines.push(`- session manager: failed \u2014 ${input.sessionError}`), lines;
|
|
@@ -4975,19 +5078,19 @@ var WATCHDOG_TOOL_ACTIONS = ["watchdog.status", "watchdog.check", "watchdog.reco
|
|
|
4975
5078
|
|
|
4976
5079
|
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/background/chain-append.js
|
|
4977
5080
|
import { randomUUID } from "node:crypto";
|
|
4978
|
-
import * as
|
|
4979
|
-
import * as
|
|
5081
|
+
import * as fs11 from "node:fs";
|
|
5082
|
+
import * as path10 from "node:path";
|
|
4980
5083
|
var APPEND_REQUESTS_DIR = "append-requests";
|
|
4981
5084
|
function appendDir(asyncDir) {
|
|
4982
|
-
return
|
|
5085
|
+
return path10.join(asyncDir, APPEND_REQUESTS_DIR);
|
|
4983
5086
|
}
|
|
4984
5087
|
function appendRequestPath(asyncDir, request) {
|
|
4985
|
-
return
|
|
5088
|
+
return path10.join(appendDir(asyncDir), `${request.createdAt}-${request.id}.json`);
|
|
4986
5089
|
}
|
|
4987
5090
|
function listAppendRequestFiles(asyncDir) {
|
|
4988
5091
|
let dir = appendDir(asyncDir);
|
|
4989
5092
|
try {
|
|
4990
|
-
return
|
|
5093
|
+
return fs11.readdirSync(dir).filter((entry) => entry.endsWith(".json")).map((entry) => path10.join(dir, entry)).sort();
|
|
4991
5094
|
} catch (error) {
|
|
4992
5095
|
if (error.code === "ENOENT")
|
|
4993
5096
|
return [];
|
|
@@ -5022,9 +5125,9 @@ function enqueueChainAppendRequest(input) {
|
|
|
5022
5125
|
createdAt: input.now ?? Date.now(),
|
|
5023
5126
|
steps: input.steps
|
|
5024
5127
|
};
|
|
5025
|
-
|
|
5026
|
-
let pendingCount = countPendingChainAppendRequests(input.asyncDir), statusPath =
|
|
5027
|
-
return writeAtomicJson(statusPath, updatedStatus), appendJsonl(
|
|
5128
|
+
fs11.mkdirSync(appendDir(input.asyncDir), { recursive: !0 }), writeAtomicJson(appendRequestPath(input.asyncDir, request), request);
|
|
5129
|
+
let pendingCount = countPendingChainAppendRequests(input.asyncDir), statusPath = path10.join(input.asyncDir, "status.json"), updatedStatus = { ...status, pendingAppends: pendingCount, lastUpdate: request.createdAt };
|
|
5130
|
+
return writeAtomicJson(statusPath, updatedStatus), appendJsonl(path10.join(input.asyncDir, "events.jsonl"), JSON.stringify({
|
|
5028
5131
|
type: "subagent.chain.append.requested",
|
|
5029
5132
|
ts: request.createdAt,
|
|
5030
5133
|
runId: input.runId,
|
|
@@ -5034,7 +5137,7 @@ function enqueueChainAppendRequest(input) {
|
|
|
5034
5137
|
})), { request, pendingCount };
|
|
5035
5138
|
}
|
|
5036
5139
|
function readAppendRequest(filePath) {
|
|
5037
|
-
let raw = JSON.parse(
|
|
5140
|
+
let raw = JSON.parse(fs11.readFileSync(filePath, "utf-8"));
|
|
5038
5141
|
if (!(!raw.id || typeof raw.id != "string") && Number.isFinite(raw.createdAt) && !(!Array.isArray(raw.steps) || raw.steps.length === 0))
|
|
5039
5142
|
return { id: raw.id, createdAt: raw.createdAt, steps: raw.steps };
|
|
5040
5143
|
}
|
|
@@ -5044,8 +5147,8 @@ function readPendingChainAppendRequests(asyncDir) {
|
|
|
5044
5147
|
|
|
5045
5148
|
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/shared/fork-context.js
|
|
5046
5149
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
5047
|
-
import * as
|
|
5048
|
-
import * as
|
|
5150
|
+
import * as fs12 from "node:fs";
|
|
5151
|
+
import * as path11 from "node:path";
|
|
5049
5152
|
function resolveSubagentContext(value) {
|
|
5050
5153
|
return value === "fork" ? "fork" : "fresh";
|
|
5051
5154
|
}
|
|
@@ -5099,7 +5202,7 @@ function sanitizeUnsafeThinkingBlocks(entries) {
|
|
|
5099
5202
|
return sanitized;
|
|
5100
5203
|
}
|
|
5101
5204
|
function readSessionEntries(sessionFile) {
|
|
5102
|
-
return
|
|
5205
|
+
return fs12.readFileSync(sessionFile, "utf-8").split(`
|
|
5103
5206
|
`).filter((line) => line.trim().length > 0).map((line, index) => {
|
|
5104
5207
|
try {
|
|
5105
5208
|
return JSON.parse(line);
|
|
@@ -5128,22 +5231,22 @@ function createForkContextResolver(sessionManager, requestedContext, options = {
|
|
|
5128
5231
|
if (cached)
|
|
5129
5232
|
return cached;
|
|
5130
5233
|
try {
|
|
5131
|
-
if (!
|
|
5234
|
+
if (!fs12.existsSync(parentSessionFile))
|
|
5132
5235
|
throw new Error(`Parent session file does not exist: ${parentSessionFile}. Pi has not persisted enough history to fork yet.`);
|
|
5133
5236
|
let sourceManager = openSession(parentSessionFile, sessionDir), sessionFile = sourceManager.createBranchedSession(leafId);
|
|
5134
5237
|
if (!sessionFile)
|
|
5135
5238
|
throw new Error("Session manager did not return a forked session file.");
|
|
5136
5239
|
let forceThinkingOff = (sanitized) => sanitized && (options.forceThinkingOffForIndex?.(index) ?? !0), thinkingOverride;
|
|
5137
|
-
if (
|
|
5240
|
+
if (fs12.existsSync(sessionFile)) {
|
|
5138
5241
|
let entries = readSessionEntries(sessionFile);
|
|
5139
|
-
sanitizeUnsafeThinkingBlocks(entries) && (forceThinkingOff(!0) && (appendThinkingOffEntry(entries), thinkingOverride = "off"),
|
|
5242
|
+
sanitizeUnsafeThinkingBlocks(entries) && (forceThinkingOff(!0) && (appendThinkingOffEntry(entries), thinkingOverride = "off"), fs12.writeFileSync(sessionFile, `${entries.map((entry) => JSON.stringify(entry)).join(`
|
|
5140
5243
|
`)}
|
|
5141
5244
|
`, "utf-8"));
|
|
5142
5245
|
} else {
|
|
5143
5246
|
let header = sourceManager.getHeader?.(), entries = sourceManager.getEntries?.();
|
|
5144
5247
|
if (!header || !entries)
|
|
5145
5248
|
throw new Error(`Session manager returned a forked session file that does not exist and cannot be persisted by fallback: ${sessionFile}`);
|
|
5146
|
-
forceThinkingOff(sanitizeUnsafeThinkingBlocks(entries)) && (appendThinkingOffEntry(entries), thinkingOverride = "off"),
|
|
5249
|
+
forceThinkingOff(sanitizeUnsafeThinkingBlocks(entries)) && (appendThinkingOffEntry(entries), thinkingOverride = "off"), fs12.mkdirSync(path11.dirname(sessionFile), { recursive: !0 }), fs12.writeFileSync(sessionFile, `${[header, ...entries].map((entry) => JSON.stringify(entry)).join(`
|
|
5147
5250
|
`)}
|
|
5148
5251
|
`, "utf-8");
|
|
5149
5252
|
}
|
|
@@ -5174,8 +5277,8 @@ function lunrContextPolicy(params) {
|
|
|
5174
5277
|
}
|
|
5175
5278
|
|
|
5176
5279
|
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/background/steering.js
|
|
5177
|
-
import * as
|
|
5178
|
-
import * as
|
|
5280
|
+
import * as fs13 from "node:fs";
|
|
5281
|
+
import * as path12 from "node:path";
|
|
5179
5282
|
function incrementStateCount(status, state) {
|
|
5180
5283
|
state === "scheduled" ? status.scheduled++ : state === "routed" ? status.pending++ : state === "delivered" || state === "late" ? status.delivered++ : state === "failed" ? status.failed++ : state === "recovered" && status.recovered++;
|
|
5181
5284
|
}
|
|
@@ -5207,29 +5310,29 @@ function steeringActionIsTerminal(result2) {
|
|
|
5207
5310
|
return result2?.state === "delivered" || result2?.state === "scheduled" || result2?.state === "partial" || result2?.state === "recovered" || result2?.state === "failed";
|
|
5208
5311
|
}
|
|
5209
5312
|
function claimSteeringRecovery(asyncDir, input) {
|
|
5210
|
-
let recoveryDir =
|
|
5211
|
-
|
|
5212
|
-
let claimPath =
|
|
5313
|
+
let recoveryDir = path12.join(asyncDir, "control", "steer-recovery");
|
|
5314
|
+
fs13.mkdirSync(recoveryDir, { recursive: !0, mode: 448 });
|
|
5315
|
+
let claimPath = path12.join(recoveryDir, "claim.json"), fd;
|
|
5213
5316
|
try {
|
|
5214
|
-
fd =
|
|
5317
|
+
fd = fs13.openSync(claimPath, "wx", 384);
|
|
5215
5318
|
} catch (error) {
|
|
5216
5319
|
throw error.code === "EEXIST" ? new Error("Another steering recovery is already committed for this source run.") : error;
|
|
5217
5320
|
}
|
|
5218
5321
|
let writeError;
|
|
5219
5322
|
try {
|
|
5220
|
-
|
|
5323
|
+
fs13.writeFileSync(fd, JSON.stringify({ version: 1, ...input }, null, 2), "utf-8"), fs13.fsyncSync(fd);
|
|
5221
5324
|
} catch (error) {
|
|
5222
5325
|
writeError = error;
|
|
5223
5326
|
} finally {
|
|
5224
|
-
|
|
5327
|
+
fs13.closeSync(fd);
|
|
5225
5328
|
}
|
|
5226
5329
|
if (writeError !== void 0)
|
|
5227
|
-
throw
|
|
5228
|
-
let markerPath =
|
|
5330
|
+
throw fs13.rmSync(claimPath, { force: !0 }), writeError;
|
|
5331
|
+
let markerPath = path12.join(recoveryDir, `${Buffer.from(input.requestId).toString("base64url")}.json`);
|
|
5229
5332
|
try {
|
|
5230
5333
|
writePrivateAtomicJson(markerPath, { version: 1, ...input });
|
|
5231
5334
|
} catch (error) {
|
|
5232
|
-
throw
|
|
5335
|
+
throw fs13.rmSync(claimPath, { force: !0 }), error;
|
|
5233
5336
|
}
|
|
5234
5337
|
return { claimPath, markerPath };
|
|
5235
5338
|
}
|
|
@@ -5280,8 +5383,8 @@ async function waitForSteeringAction(input) {
|
|
|
5280
5383
|
|
|
5281
5384
|
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/foreground/async-steering-action.js
|
|
5282
5385
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
5283
|
-
import * as
|
|
5284
|
-
import * as
|
|
5386
|
+
import * as fs14 from "node:fs";
|
|
5387
|
+
import * as path13 from "node:path";
|
|
5285
5388
|
async function steerAsyncRun(input) {
|
|
5286
5389
|
if (!input.location.asyncDir)
|
|
5287
5390
|
return {
|
|
@@ -5362,7 +5465,7 @@ async function steerAsyncRun(input) {
|
|
|
5362
5465
|
if (status.mode === "single" && status.isNested !== !0 && running.length === 1 && !!finalStatus?.steering && (input.index === void 0 || input.index === 0) && finalResult?.state !== "scheduled" && input.recover) {
|
|
5363
5466
|
let appendSteeringNotice = (state, message) => {
|
|
5364
5467
|
try {
|
|
5365
|
-
|
|
5468
|
+
fs14.appendFileSync(path13.join(asyncDir, "events.jsonl"), `${JSON.stringify({ type: "subagent.steering.notice", ts: Date.now(), runId: status.runId, requestId, state, message, ...status.sessionId ? { currentSessionId: status.sessionId } : {} })}
|
|
5366
5469
|
`);
|
|
5367
5470
|
} catch {
|
|
5368
5471
|
}
|
|
@@ -5375,11 +5478,11 @@ async function steerAsyncRun(input) {
|
|
|
5375
5478
|
input.onRecoveryCommitted?.(requestId, committedAt);
|
|
5376
5479
|
let preCommitStatus = readStatus(asyncDir), preCommitResult = preCommitStatus?.steering ? actionResultFromSteeringStatus(preCommitStatus.steering, status.runId, requestId) : void 0;
|
|
5377
5480
|
if (preCommitResult?.state === "delivered" && preCommitResult.targets.every((target) => target.deliveredAt !== void 0 && target.deliveredAt <= committedAt))
|
|
5378
|
-
return
|
|
5481
|
+
return fs14.rmSync(markerPath, { force: !0 }), fs14.rmSync(claimPath, { force: !0 }), { content: [{ type: "text", text: `Steering delivered for async run ${status.runId} (request ${requestId}).` }], details: { mode: "management", results: [], steering: preCommitResult } };
|
|
5379
5482
|
try {
|
|
5380
5483
|
deliverInterruptRequest({ asyncDir, pid: latest?.pid ?? status.pid, kill: input.kill, source: "steering-recovery" });
|
|
5381
5484
|
} catch (error) {
|
|
5382
|
-
throw
|
|
5485
|
+
throw fs14.rmSync(markerPath, { force: !0 }), fs14.rmSync(claimPath, { force: !0 }), new Error(`Failed to commit steering recovery interrupt: ${error instanceof Error ? error.message : String(error)}`);
|
|
5383
5486
|
}
|
|
5384
5487
|
let pauseDeadline = Date.now() + (input.recoveryTimeoutMs ?? 15e3), paused = null;
|
|
5385
5488
|
for (; Date.now() <= pauseDeadline && !input.signal?.aborted; ) {
|
|
@@ -5401,12 +5504,12 @@ async function steerAsyncRun(input) {
|
|
|
5401
5504
|
let stepSteering = paused.steps?.[ack.index]?.steering;
|
|
5402
5505
|
stepSteering && updateSteeringTarget(stepSteering, ack.requestId, ack.index, state, ack.ts, { reason }), lateAckRecorded = !0;
|
|
5403
5506
|
try {
|
|
5404
|
-
|
|
5507
|
+
fs14.appendFileSync(path13.join(asyncDir, "events.jsonl"), `${JSON.stringify({ type: ack.state === "delivered" ? "subagent.steer.delivered" : "subagent.steer.failed", ts: ack.ts, runId: status.runId, requestId: ack.requestId, index: ack.index, late: !0, message: ack.message })}
|
|
5405
5508
|
`);
|
|
5406
5509
|
} catch {
|
|
5407
5510
|
}
|
|
5408
5511
|
}
|
|
5409
|
-
lateAckRecorded && writeAtomicJson(
|
|
5512
|
+
lateAckRecorded && writeAtomicJson(path13.join(asyncDir, "status.json"), paused);
|
|
5410
5513
|
let recoveryTarget;
|
|
5411
5514
|
try {
|
|
5412
5515
|
recoveryTarget = resolveAsyncResumeTarget({ id: status.runId }, { kill: input.kill });
|
|
@@ -5424,7 +5527,7 @@ async function steerAsyncRun(input) {
|
|
|
5424
5527
|
if (sourceStatus?.state === "paused" && sourceStatus.steering && targetIndex >= 0) {
|
|
5425
5528
|
updateSteeringTarget(sourceStatus.steering, requestId, targetIndex, "recovered", Date.now(), { replacementRunId: revived.details.asyncId });
|
|
5426
5529
|
let stepSteering = sourceStatus.steps?.[targetIndex]?.steering;
|
|
5427
|
-
stepSteering && updateSteeringTarget(stepSteering, requestId, targetIndex, "recovered", Date.now(), { replacementRunId: revived.details.asyncId }), writeAtomicJson(
|
|
5530
|
+
stepSteering && updateSteeringTarget(stepSteering, requestId, targetIndex, "recovered", Date.now(), { replacementRunId: revived.details.asyncId }), writeAtomicJson(path13.join(asyncDir, "status.json"), sourceStatus);
|
|
5428
5531
|
}
|
|
5429
5532
|
let recovered = sourceStatus?.steering ? actionResultFromSteeringStatus(sourceStatus.steering, status.runId, requestId, revived.details.asyncId) : void 0;
|
|
5430
5533
|
return appendSteeringNotice("recovered", `Steering recovered for run ${status.runId}; replacement ${revived.details.asyncId} launched.`), { content: [{ type: "text", text: `Steering recovered for async run ${status.runId}; replacement ${revived.details.asyncId} launched after the source paused.` }], details: { mode: "management", results: [], steering: recovered ?? { requestId, state: "recovered", sourceRunId: status.runId, replacementRunId: revived.details.asyncId, targets: [{ index: input.index ?? 0, state: "recovered" }] } } };
|
|
@@ -5433,7 +5536,7 @@ async function steerAsyncRun(input) {
|
|
|
5433
5536
|
if (failedStatus && failedStatus.state !== "running" && failedStatus.state !== "queued" && failedStatus.steering && targetIndex >= 0) {
|
|
5434
5537
|
updateSteeringTarget(failedStatus.steering, requestId, targetIndex, "failed", Date.now(), { reason });
|
|
5435
5538
|
let stepSteering = failedStatus.steps?.[targetIndex]?.steering;
|
|
5436
|
-
stepSteering && updateSteeringTarget(stepSteering, requestId, targetIndex, "failed", Date.now(), { reason }), failedStatus.activityState = "needs_attention", writeAtomicJson(
|
|
5539
|
+
stepSteering && updateSteeringTarget(stepSteering, requestId, targetIndex, "failed", Date.now(), { reason }), failedStatus.activityState = "needs_attention", writeAtomicJson(path13.join(asyncDir, "status.json"), failedStatus);
|
|
5437
5540
|
}
|
|
5438
5541
|
let failed = failedStatus?.steering ? actionResultFromSteeringStatus(failedStatus.steering, status.runId, requestId) : void 0;
|
|
5439
5542
|
return appendSteeringNotice("failed", `Steering failed for run ${status.runId}: ${reason}`), { content: [{ type: "text", text: `Steering failed for async run ${status.runId} (request ${requestId}): ${reason}` }], isError: !0, details: { mode: "management", results: [], steering: failed ?? { requestId, state: "failed", sourceRunId: status.runId, targets: [{ index: input.index ?? 0, state: "failed", reason }] } } };
|
|
@@ -5448,16 +5551,16 @@ async function steerAsyncRun(input) {
|
|
|
5448
5551
|
}
|
|
5449
5552
|
|
|
5450
5553
|
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/background/chain-root-attachment.js
|
|
5451
|
-
import * as
|
|
5554
|
+
import * as path14 from "node:path";
|
|
5452
5555
|
function resolveAsyncRootResultPath(resultsDir, runId) {
|
|
5453
|
-
return
|
|
5556
|
+
return path14.join(resultsDir, `${runId}.json`);
|
|
5454
5557
|
}
|
|
5455
5558
|
|
|
5456
5559
|
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/background/run-status.js
|
|
5457
|
-
import * as
|
|
5458
|
-
import * as
|
|
5560
|
+
import * as fs15 from "node:fs";
|
|
5561
|
+
import * as path15 from "node:path";
|
|
5459
5562
|
function hasExistingSessionFile(value) {
|
|
5460
|
-
return typeof value == "string" &&
|
|
5563
|
+
return typeof value == "string" && fs15.existsSync(value);
|
|
5461
5564
|
}
|
|
5462
5565
|
function formatResumeGuidance(runId, children, fallbackSessionFile, options = {}) {
|
|
5463
5566
|
if (options.stopped)
|
|
@@ -5493,9 +5596,9 @@ function formatSteeringSummary(input) {
|
|
|
5493
5596
|
}
|
|
5494
5597
|
function rememberedForegroundChildOutput(child) {
|
|
5495
5598
|
let outputPath = child.artifactPaths?.outputPath ?? child.savedOutputPath;
|
|
5496
|
-
if (outputPath &&
|
|
5599
|
+
if (outputPath && fs15.existsSync(outputPath))
|
|
5497
5600
|
try {
|
|
5498
|
-
let artifactOutput =
|
|
5601
|
+
let artifactOutput = fs15.readFileSync(outputPath, "utf-8").trim();
|
|
5499
5602
|
if (artifactOutput)
|
|
5500
5603
|
return artifactOutput;
|
|
5501
5604
|
} catch {
|
|
@@ -5668,7 +5771,7 @@ function inspectSubagentStatus(params, deps = {}) {
|
|
|
5668
5771
|
details: { mode: "single", results: [] }
|
|
5669
5772
|
};
|
|
5670
5773
|
}
|
|
5671
|
-
let status = reconciliation.status, effectiveRunId = status?.runId ?? resolvedId ?? "unknown", logPath =
|
|
5774
|
+
let status = reconciliation.status, effectiveRunId = status?.runId ?? resolvedId ?? "unknown", logPath = path15.join(asyncDir, `subagent-log-${effectiveRunId}.md`), eventsPath = path15.join(asyncDir, "events.jsonl");
|
|
5672
5775
|
if (status) {
|
|
5673
5776
|
if (params.view === "transcript") {
|
|
5674
5777
|
if (currentSessionId && status.sessionId !== currentSessionId)
|
|
@@ -5712,22 +5815,22 @@ function inspectSubagentStatus(params, deps = {}) {
|
|
|
5712
5815
|
`Dir: ${asyncDir}`,
|
|
5713
5816
|
outputPath ? `Output: ${outputPath}` : void 0,
|
|
5714
5817
|
reconciliation.message ? `Diagnosis: ${reconciliation.message}` : void 0,
|
|
5715
|
-
reconciliation.resultPath &&
|
|
5818
|
+
reconciliation.resultPath && fs15.existsSync(reconciliation.resultPath) ? `Result: ${reconciliation.resultPath}` : void 0
|
|
5716
5819
|
].filter((line) => !!line);
|
|
5717
5820
|
for (let [index, step] of (status.steps ?? []).entries()) {
|
|
5718
5821
|
let stepActivityText = step.status === "running" ? formatActivityLabel(step.lastActivityAt, step.activityState) : void 0, modelThinking = formatModelSelection(step.modelSelection, step.model, step.thinking), modelText = modelThinking ? ` (${modelThinking})` : "", steeringText2 = formatSteeringSummary(step), steeringSuffix = steeringText2 ? `, steering: ${steeringText2}` : "", errorText2 = step.error ? `, error: ${step.error}` : "", acceptanceText = step.acceptance?.status ? `, acceptance: ${step.acceptance.status}` : "", budgetText = step.turnBudget ? `, turn budget: ${step.turnBudget.turnCount}/${step.turnBudget.maxTurns}+${step.turnBudget.graceTurns} (${step.turnBudget.outcome})` : "", display = step.label ? `${step.label} (${step.agent})` : step.agent, phase = step.phase ? `[${step.phase}] ` : "";
|
|
5719
5822
|
lines.push(`${stepLineLabel(status, index)}: ${phase}${display} ${step.status}${modelText}${stepActivityText ? `, ${stepActivityText}` : ""}${steeringSuffix}${acceptanceText}${budgetText}${errorText2}`), lines.push(...formatNestedRunStatusLines(step.children, { indent: " ", commandHints: !0, maxLines: 20 }));
|
|
5720
|
-
let stepOutputPath =
|
|
5721
|
-
stepOutputPath !== outputPath &&
|
|
5823
|
+
let stepOutputPath = path15.join(asyncDir, `output-${index}.log`);
|
|
5824
|
+
stepOutputPath !== outputPath && fs15.existsSync(stepOutputPath) && lines.push(` Output: ${stepOutputPath}`), step.status === "running" && (lines.push(` Intercom target: ${resolveSubagentIntercomTarget(status.runId, step.childId ?? step.agent, index)} (if registered)`), lines.push(` Steer: subagent({ action: "steer", id: "${status.runId}", index: ${index}, message: "..." })`));
|
|
5722
5825
|
}
|
|
5723
5826
|
let attached = new Set((status.steps ?? []).flatMap((step) => step.children?.map((child) => child.id) ?? [])), unattached = nestedChildren.filter((child) => !attached.has(child.id));
|
|
5724
|
-
return lines.push(...formatNestedRunStatusLines(unattached, { indent: "", commandHints: !0, maxLines: 20 })), nestedWarning && lines.push(`Warning: ${nestedWarning}`), status.sessionFile && lines.push(`Session: ${status.sessionFile}`), status.state === "running" && lines.push(`Steer running child: subagent({ action: "steer", id: "${status.runId}", message: "..." })`), status.state !== "running" && lines.push(formatResumeGuidance(status.runId, status.steps ?? [], status.sessionFile, { stopped: status.state === "stopped" || status.stopped === !0 })),
|
|
5827
|
+
return lines.push(...formatNestedRunStatusLines(unattached, { indent: "", commandHints: !0, maxLines: 20 })), nestedWarning && lines.push(`Warning: ${nestedWarning}`), status.sessionFile && lines.push(`Session: ${status.sessionFile}`), status.state === "running" && lines.push(`Steer running child: subagent({ action: "steer", id: "${status.runId}", message: "..." })`), status.state !== "running" && lines.push(formatResumeGuidance(status.runId, status.steps ?? [], status.sessionFile, { stopped: status.state === "stopped" || status.stopped === !0 })), fs15.existsSync(logPath) && lines.push(`Log: ${logPath}`), fs15.existsSync(eventsPath) && lines.push(`Events: ${eventsPath}`), { content: [{ type: "text", text: lines.join(`
|
|
5725
5828
|
`) }], details: { mode: "single", results: [] } };
|
|
5726
5829
|
}
|
|
5727
5830
|
}
|
|
5728
5831
|
if (resultPath)
|
|
5729
5832
|
try {
|
|
5730
|
-
let raw =
|
|
5833
|
+
let raw = fs15.readFileSync(resultPath, "utf-8"), data = JSON.parse(raw);
|
|
5731
5834
|
if (params.view === "transcript")
|
|
5732
5835
|
try {
|
|
5733
5836
|
return { content: [{ type: "text", text: formatAsyncResultTranscript(data, resultPath, { index: params.index, lines: params.lines }) }], details: { mode: "single", results: [] } };
|
|
@@ -5754,7 +5857,7 @@ function inspectSubagentStatus(params, deps = {}) {
|
|
|
5754
5857
|
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js
|
|
5755
5858
|
var MUTATING_MANAGEMENT_ACTIONS = /* @__PURE__ */ new Set(["create", "update", "delete", "eject", "disable", "enable", "reset"]);
|
|
5756
5859
|
function resolveRequestedCwd(runtimeCwd, requestedCwd) {
|
|
5757
|
-
return requestedCwd ?
|
|
5860
|
+
return requestedCwd ? path16.resolve(runtimeCwd, requestedCwd) : runtimeCwd;
|
|
5758
5861
|
}
|
|
5759
5862
|
function getForegroundControl(state, runId) {
|
|
5760
5863
|
if (runId)
|
|
@@ -5786,7 +5889,7 @@ function nestedResolutionScopeForExecutor(deps) {
|
|
|
5786
5889
|
};
|
|
5787
5890
|
}
|
|
5788
5891
|
function trustedSessionRootsForStatus(ctx, deps) {
|
|
5789
|
-
let roots = deps.config.defaultSessionDir ? [
|
|
5892
|
+
let roots = deps.config.defaultSessionDir ? [path16.resolve(deps.expandTilde(deps.config.defaultSessionDir))] : [], parentSessionFile = ctx.sessionManager.getSessionFile() ?? null;
|
|
5790
5893
|
return parentSessionFile && roots.push(deps.getSubagentSessionRoot(parentSessionFile)), [...new Set(roots)];
|
|
5791
5894
|
}
|
|
5792
5895
|
function reserveSubagentSpawns(input) {
|
|
@@ -5908,7 +6011,8 @@ ${output}` : ""}` : output || input.result.error || "Detached child exited witho
|
|
|
5908
6011
|
cwd: input.cwd,
|
|
5909
6012
|
sessionFile: input.result.sessionFile,
|
|
5910
6013
|
sessionId: input.sessionId,
|
|
5911
|
-
taskIndex: input.index
|
|
6014
|
+
taskIndex: input.index,
|
|
6015
|
+
results: [{ childId: input.result.childId, agent: input.result.agent, sessionFile: input.result.sessionFile, usage: input.result.usage, usageRequests: input.result.usageRequests, success, output: summary }]
|
|
5912
6016
|
});
|
|
5913
6017
|
}
|
|
5914
6018
|
function resolveForegroundResumeTarget(params, state) {
|
|
@@ -5933,10 +6037,10 @@ function resolveForegroundResumeTarget(params, state) {
|
|
|
5933
6037
|
let child = run.children[index];
|
|
5934
6038
|
if (!child.sessionFile)
|
|
5935
6039
|
throw new Error(`Foreground run '${run.runId}' child ${index} does not have a persisted session file to resume from.`);
|
|
5936
|
-
if (
|
|
6040
|
+
if (path16.extname(child.sessionFile) !== ".jsonl")
|
|
5937
6041
|
throw new Error(`Foreground run '${run.runId}' child ${index} session file must be a .jsonl file: ${child.sessionFile}`);
|
|
5938
|
-
let sessionFile =
|
|
5939
|
-
if (!
|
|
6042
|
+
let sessionFile = path16.resolve(child.sessionFile);
|
|
6043
|
+
if (!fs16.existsSync(sessionFile))
|
|
5940
6044
|
throw new Error(`Foreground run '${run.runId}' child ${index} session file does not exist: ${child.sessionFile}`);
|
|
5941
6045
|
return { runId: run.runId, mode: run.mode, state: "complete", agent: child.agent, index, intercomTarget: resolveSubagentIntercomTarget(run.runId, child.agent, index), cwd: run.cwd, sessionFile };
|
|
5942
6046
|
}
|
|
@@ -5988,18 +6092,15 @@ function resolveResumeTarget(params, state, options = {}) {
|
|
|
5988
6092
|
}
|
|
5989
6093
|
throw foregroundError && !isAsyncRunNotFound(asyncError) || foregroundError ? foregroundError : asyncError || new Error("Run not found. Provide id or runId.");
|
|
5990
6094
|
}
|
|
5991
|
-
function getAsyncInterruptTarget(state, runId, location
|
|
6095
|
+
function getAsyncInterruptTarget(state, runId, location) {
|
|
5992
6096
|
if (location?.asyncDir)
|
|
5993
6097
|
return {
|
|
5994
|
-
asyncId: location.resolvedId ?? runId ??
|
|
6098
|
+
asyncId: location.resolvedId ?? runId ?? path16.basename(location.asyncDir),
|
|
5995
6099
|
asyncDir: location.asyncDir
|
|
5996
6100
|
};
|
|
5997
6101
|
if (runId) {
|
|
5998
6102
|
let direct = state.asyncJobs.get(runId);
|
|
5999
|
-
|
|
6000
|
-
return { asyncId: direct.asyncId, asyncDir: direct.asyncDir };
|
|
6001
|
-
if (options.fallbackToNewest === !1)
|
|
6002
|
-
return;
|
|
6103
|
+
return direct ? { asyncId: direct.asyncId, asyncDir: direct.asyncDir } : void 0;
|
|
6003
6104
|
}
|
|
6004
6105
|
let newest;
|
|
6005
6106
|
for (let job of state.asyncJobs.values())
|
|
@@ -6026,6 +6127,12 @@ function interruptAsyncRun(state, runId, kill, location) {
|
|
|
6026
6127
|
if (!target)
|
|
6027
6128
|
return null;
|
|
6028
6129
|
let status = reconcileAsyncRun(target.asyncDir, { kill }).status;
|
|
6130
|
+
if (state.currentSessionId && status?.sessionId !== state.currentSessionId)
|
|
6131
|
+
return {
|
|
6132
|
+
content: [{ type: "text", text: `Async run '${target.asyncId}' was not found in the active session.` }],
|
|
6133
|
+
isError: !0,
|
|
6134
|
+
details: { mode: "management", results: [] }
|
|
6135
|
+
};
|
|
6029
6136
|
if (!status || status.state !== "running" || typeof status.pid != "number")
|
|
6030
6137
|
return {
|
|
6031
6138
|
content: [{ type: "text", text: `No running async run with an interrupt-capable pid was found for '${runId ?? "current"}'.` }],
|
|
@@ -6049,7 +6156,7 @@ function interruptAsyncRun(state, runId, kill, location) {
|
|
|
6049
6156
|
}
|
|
6050
6157
|
}
|
|
6051
6158
|
function stopAsyncRun(state, runId, kill, location) {
|
|
6052
|
-
let target = getAsyncInterruptTarget(state, runId, location
|
|
6159
|
+
let target = getAsyncInterruptTarget(state, runId, location);
|
|
6053
6160
|
if (!target)
|
|
6054
6161
|
return null;
|
|
6055
6162
|
let status = reconcileAsyncRun(target.asyncDir, { kill }).status;
|
|
@@ -6256,27 +6363,27 @@ function nestedRunAgent(run) {
|
|
|
6256
6363
|
return run.agent ?? run.agents?.[0] ?? (run.steps?.length === 1 ? run.steps[0]?.agent : void 0);
|
|
6257
6364
|
}
|
|
6258
6365
|
function pathWithin(base, candidate) {
|
|
6259
|
-
let resolvedBase =
|
|
6260
|
-
return resolvedCandidate === resolvedBase || resolvedCandidate.startsWith(`${resolvedBase}${
|
|
6366
|
+
let resolvedBase = path16.resolve(base), resolvedCandidate = path16.resolve(candidate);
|
|
6367
|
+
return resolvedCandidate === resolvedBase || resolvedCandidate.startsWith(`${resolvedBase}${path16.sep}`);
|
|
6261
6368
|
}
|
|
6262
6369
|
function validateNestedSessionFile(run, trustedSessionRoots) {
|
|
6263
6370
|
let sessionFile = nestedRunSessionFile(run);
|
|
6264
6371
|
if (!sessionFile)
|
|
6265
6372
|
throw new Error(`Nested run '${run.id}' does not have a persisted session file to resume from.`);
|
|
6266
|
-
if (
|
|
6373
|
+
if (path16.extname(sessionFile) !== ".jsonl")
|
|
6267
6374
|
throw new Error(`Nested run '${run.id}' session file must be a .jsonl file: ${sessionFile}`);
|
|
6268
|
-
let resolved =
|
|
6269
|
-
if (!
|
|
6375
|
+
let resolved = path16.resolve(sessionFile);
|
|
6376
|
+
if (!path16.isAbsolute(sessionFile))
|
|
6270
6377
|
throw new Error(`Nested run '${run.id}' session file must be absolute: ${sessionFile}`);
|
|
6271
|
-
if (!
|
|
6378
|
+
if (!fs16.existsSync(resolved))
|
|
6272
6379
|
throw new Error(`Nested run '${run.id}' session file does not exist: ${sessionFile}`);
|
|
6273
|
-
let stat =
|
|
6380
|
+
let stat = fs16.lstatSync(resolved);
|
|
6274
6381
|
if (!stat.isFile() || stat.isSymbolicLink())
|
|
6275
6382
|
throw new Error(`Nested run '${run.id}' session file is not a regular file: ${sessionFile}`);
|
|
6276
|
-
let realSessionFile =
|
|
6277
|
-
if (!trustedSessionRoots.filter((root) =>
|
|
6383
|
+
let realSessionFile = fs16.realpathSync(resolved);
|
|
6384
|
+
if (!trustedSessionRoots.filter((root) => fs16.existsSync(root)).map((root) => fs16.realpathSync(root)).some((root) => pathWithin(root, realSessionFile)))
|
|
6278
6385
|
throw new Error(`Nested run '${run.id}' session file is outside trusted nested session roots: ${sessionFile}`);
|
|
6279
|
-
if (!realSessionFile.split(
|
|
6386
|
+
if (!realSessionFile.split(path16.sep).includes(run.id))
|
|
6280
6387
|
throw new Error(`Nested run '${run.id}' session file is not under that nested run's session directory: ${sessionFile}`);
|
|
6281
6388
|
return realSessionFile;
|
|
6282
6389
|
}
|
|
@@ -6296,7 +6403,7 @@ function resolveNestedResumeTarget(match, trustedSessionRoots) {
|
|
|
6296
6403
|
agent,
|
|
6297
6404
|
index: 0,
|
|
6298
6405
|
intercomTarget: resolveSubagentIntercomTarget(run.id, agent, 0),
|
|
6299
|
-
cwd: asyncDir ?
|
|
6406
|
+
cwd: asyncDir ? path16.dirname(asyncDir) : void 0,
|
|
6300
6407
|
sessionFile: validateNestedSessionFile(run, trustedSessionRoots)
|
|
6301
6408
|
};
|
|
6302
6409
|
}
|
|
@@ -6323,7 +6430,7 @@ function directNestedAsyncInterrupt(target) {
|
|
|
6323
6430
|
let run = target.match.run, asyncDir = resolveNestedAsyncDir(target.match.rootRunId, run);
|
|
6324
6431
|
if (!asyncDir)
|
|
6325
6432
|
return;
|
|
6326
|
-
let status = reconcileAsyncRun(asyncDir, { resultsDir:
|
|
6433
|
+
let status = reconcileAsyncRun(asyncDir, { resultsDir: path16.join(RESULTS_DIR, "nested", target.match.rootRunId) }).status, pid = typeof status?.pid == "number" && status.pid > 0 ? status.pid : run.pid;
|
|
6327
6434
|
if (!(!status || status.state !== "running" || typeof pid != "number" || pid <= 0))
|
|
6328
6435
|
try {
|
|
6329
6436
|
return deliverInterruptRequest({ asyncDir, pid, source: "nested-interrupt" }), { content: [{ type: "text", text: `Interrupt requested for nested async run ${run.id}.` }], details: { mode: "management", results: [] } };
|
|
@@ -6336,7 +6443,7 @@ async function directNestedAsyncSteer(input) {
|
|
|
6336
6443
|
let run = input.target.match.run, asyncDir = resolveNestedAsyncDir(input.target.match.rootRunId, run);
|
|
6337
6444
|
if (!asyncDir)
|
|
6338
6445
|
return;
|
|
6339
|
-
let status = reconcileAsyncRun(asyncDir, { resultsDir:
|
|
6446
|
+
let status = reconcileAsyncRun(asyncDir, { resultsDir: path16.join(RESULTS_DIR, "nested", input.target.match.rootRunId) }).status;
|
|
6340
6447
|
if (!status || status.state !== "running" && status.state !== "queued")
|
|
6341
6448
|
return;
|
|
6342
6449
|
let steps = status.steps ?? [];
|
|
@@ -6430,7 +6537,7 @@ async function resumeAsyncRun(input) {
|
|
|
6430
6537
|
if (resolved.match.run.state === "running" || resolved.match.run.state === "queued")
|
|
6431
6538
|
return resumeLiveNestedRun({ target: resolved, message: followUp });
|
|
6432
6539
|
let trustedSessionRoots = [
|
|
6433
|
-
...input.deps.config.defaultSessionDir ? [
|
|
6540
|
+
...input.deps.config.defaultSessionDir ? [path16.resolve(input.deps.expandTilde(input.deps.config.defaultSessionDir))] : [],
|
|
6434
6541
|
...parentSessionFile ? [input.deps.getSubagentSessionRoot(parentSessionFile)] : []
|
|
6435
6542
|
];
|
|
6436
6543
|
target = resolveNestedResumeTarget(resolved, trustedSessionRoots);
|
|
@@ -6496,7 +6603,7 @@ ${followUp}`, 500, { source: "async-resume", runId: target.runId, agent: target.
|
|
|
6496
6603
|
goal,
|
|
6497
6604
|
attachRoot: {
|
|
6498
6605
|
runId: target.runId,
|
|
6499
|
-
asyncDir: target.asyncDir ??
|
|
6606
|
+
asyncDir: target.asyncDir ?? path16.join(ASYNC_DIR, target.runId),
|
|
6500
6607
|
resultPath: resolveAsyncRootResultPath(RESULTS_DIR, target.runId),
|
|
6501
6608
|
index: target.index,
|
|
6502
6609
|
agent: target.agent,
|
|
@@ -7440,7 +7547,7 @@ function buildParallelWorktreeTaskCwdError(tasks, sharedCwd) {
|
|
|
7440
7547
|
return formatWorktreeTaskCwdConflict(conflict, sharedCwd);
|
|
7441
7548
|
}
|
|
7442
7549
|
function resolveSingleRunOutputBaseDir(deps, artifactsDir, runId) {
|
|
7443
|
-
return deps.config.singleRunOutputBaseDir ?
|
|
7550
|
+
return deps.config.singleRunOutputBaseDir ? path16.resolve(deps.expandTilde(deps.config.singleRunOutputBaseDir)) : path16.join(artifactsDir, "outputs", runId);
|
|
7444
7551
|
}
|
|
7445
7552
|
function buildChainWorktreeTaskCwdError(chain, sharedCwd) {
|
|
7446
7553
|
for (let stepIndex = 0; stepIndex < chain.length; stepIndex++) {
|
|
@@ -7460,7 +7567,7 @@ function resolveParallelTaskCwd(task, paramsCwd, worktreeSetup, index) {
|
|
|
7460
7567
|
function buildParallelWorktreeSuffix(worktreeSetup, artifactsDir, tasks) {
|
|
7461
7568
|
if (!worktreeSetup)
|
|
7462
7569
|
return "";
|
|
7463
|
-
let diffsDir =
|
|
7570
|
+
let diffsDir = path16.join(artifactsDir, "worktree-diffs"), diffs = diffWorktrees(worktreeSetup, tasks.map((task) => task.agent), diffsDir);
|
|
7464
7571
|
return formatWorktreeDiffSummary(diffs);
|
|
7465
7572
|
}
|
|
7466
7573
|
function findDuplicateParallelOutputPath(input) {
|
|
@@ -7559,7 +7666,17 @@ async function runForegroundParallelTasks(input) {
|
|
|
7559
7666
|
}).finally(() => {
|
|
7560
7667
|
input.foregroundControl?.currentIndex === index && (input.foregroundControl.interrupt = void 0, input.foregroundControl.updatedAt = Date.now());
|
|
7561
7668
|
});
|
|
7562
|
-
}, input.globalSemaphore
|
|
7669
|
+
}, input.globalSemaphore, {
|
|
7670
|
+
signal: input.signal,
|
|
7671
|
+
onAbort: (task) => ({
|
|
7672
|
+
agent: task.agent,
|
|
7673
|
+
task: task.task ?? "",
|
|
7674
|
+
exitCode: 1,
|
|
7675
|
+
messages: [],
|
|
7676
|
+
usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, turns: 0 },
|
|
7677
|
+
error: "Subagent launch cancelled."
|
|
7678
|
+
})
|
|
7679
|
+
});
|
|
7563
7680
|
}
|
|
7564
7681
|
async function runParallelPath(data, deps) {
|
|
7565
7682
|
let { params, effectiveCwd, agents, ctx, signal, runId, sessionDirForIndex, sessionFileForIndex, sessionFileForTask, thinkingOverrideForTask, shareEnabled, artifactConfig, artifactsDir, backgroundRequestedWhileClarifying, onUpdate, sessionRoot, controlConfig, contextPolicy } = data, onControlEvent = createForegroundControlNotifier(data, deps), childIntercomTarget = data.intercomBridge.active ? resolveSubagentIntercomTarget : void 0, allProgress = [], allArtifactPaths = [], tasks = params.tasks, maxParallelTasks = resolveTopLevelParallelMaxTasks(deps.config.parallel?.maxTasks), parallelConcurrency = resolveTopLevelParallelConcurrency(params.concurrency, deps.config.parallel?.concurrency);
|
|
@@ -7684,7 +7801,7 @@ async function runParallelPath(data, deps) {
|
|
|
7684
7801
|
if (errorResult)
|
|
7685
7802
|
return errorResult;
|
|
7686
7803
|
try {
|
|
7687
|
-
let outputBaseDir =
|
|
7804
|
+
let outputBaseDir = path16.join(artifactsDir, "outputs", runId), duplicateOutputError = findDuplicateParallelOutputPath({
|
|
7688
7805
|
tasks,
|
|
7689
7806
|
behaviors,
|
|
7690
7807
|
paramsCwd: effectiveCwd,
|
|
@@ -7699,7 +7816,7 @@ async function runParallelPath(data, deps) {
|
|
|
7699
7816
|
if (validationError)
|
|
7700
7817
|
return buildParallelModeError(validationError);
|
|
7701
7818
|
}
|
|
7702
|
-
let parallelProgressPrecreated = firstProgressIndex !== -1, parallelProgressDir =
|
|
7819
|
+
let parallelProgressPrecreated = firstProgressIndex !== -1, parallelProgressDir = path16.join(artifactsDir, "progress", runId);
|
|
7703
7820
|
parallelProgressPrecreated && writeInitialProgressFile(parallelProgressDir);
|
|
7704
7821
|
for (let i = 0; i < taskTexts.length; i++)
|
|
7705
7822
|
shouldForkAgent(contextPolicy, tasks[i].agent) && (taskTexts[i] = wrapForkTask(taskTexts[i]));
|
|
@@ -8122,7 +8239,7 @@ function createSubagentExecutor(deps) {
|
|
|
8122
8239
|
let targetRunId = paramsWithResolvedCwd.runId ?? paramsWithResolvedCwd.id;
|
|
8123
8240
|
if (paramsWithResolvedCwd.dir)
|
|
8124
8241
|
try {
|
|
8125
|
-
let location = resolveAsyncRunLocation(paramsWithResolvedCwd, ASYNC_DIR, RESULTS_DIR), runId2 = location.resolvedId ?? targetRunId ??
|
|
8242
|
+
let location = resolveAsyncRunLocation(paramsWithResolvedCwd, ASYNC_DIR, RESULTS_DIR), runId2 = location.resolvedId ?? targetRunId ?? path16.basename(location.asyncDir ?? paramsWithResolvedCwd.dir);
|
|
8126
8243
|
return steerAsyncRun({ state: deps.state, runId: runId2, message, index: paramsWithResolvedCwd.index, kill: deps.kill, location, signal, recover: ({ absoluteDeadlineAt, ...limits }) => resumeAsyncRun({ params: { ...limits, action: "resume", id: runId2, message }, requestCwd, ctx, deps, absoluteDeadlineAt }) });
|
|
8127
8244
|
} catch (error) {
|
|
8128
8245
|
return { content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }], isError: !0, details: { mode: "management", results: [] } };
|
|
@@ -8150,7 +8267,7 @@ function createSubagentExecutor(deps) {
|
|
|
8150
8267
|
if (paramsWithResolvedCwd.dir)
|
|
8151
8268
|
try {
|
|
8152
8269
|
let location = resolveAsyncRunLocation(paramsWithResolvedCwd, ASYNC_DIR, RESULTS_DIR);
|
|
8153
|
-
return stopAsyncRun(deps.state, location.resolvedId ?? targetRunId ??
|
|
8270
|
+
return stopAsyncRun(deps.state, location.resolvedId ?? targetRunId ?? path16.basename(location.asyncDir ?? paramsWithResolvedCwd.dir), deps.kill, location);
|
|
8154
8271
|
} catch (error) {
|
|
8155
8272
|
return { content: [{ type: "text", text: error instanceof Error ? error.message : String(error) }], isError: !0, details: { mode: "management", results: [] } };
|
|
8156
8273
|
}
|
|
@@ -8173,7 +8290,14 @@ function createSubagentExecutor(deps) {
|
|
|
8173
8290
|
};
|
|
8174
8291
|
}
|
|
8175
8292
|
if (action === "interrupt") {
|
|
8176
|
-
let targetRunId = paramsWithResolvedCwd.runId ?? paramsWithResolvedCwd.id
|
|
8293
|
+
let targetRunId = paramsWithResolvedCwd.runId ?? paramsWithResolvedCwd.id;
|
|
8294
|
+
if (targetRunId !== void 0 && !targetRunId.trim())
|
|
8295
|
+
return {
|
|
8296
|
+
content: [{ type: "text", text: "Explicit interrupt id must be non-empty." }],
|
|
8297
|
+
isError: !0,
|
|
8298
|
+
details: { mode: "management", results: [] }
|
|
8299
|
+
};
|
|
8300
|
+
let resolved;
|
|
8177
8301
|
if (targetRunId)
|
|
8178
8302
|
try {
|
|
8179
8303
|
resolved = resolveSubagentRunId(targetRunId, { state: deps.state, nested: nestedResolutionScopeForExecutor(deps) });
|
|
@@ -8277,18 +8401,18 @@ function createSubagentExecutor(deps) {
|
|
|
8277
8401
|
enabled: effectiveParams.artifacts !== !1
|
|
8278
8402
|
}, artifactsDir = getArtifactsDir(parentSessionFile, effectiveCwd), sessionRoot;
|
|
8279
8403
|
if (effectiveParams.sessionDir)
|
|
8280
|
-
sessionRoot =
|
|
8404
|
+
sessionRoot = path16.resolve(deps.expandTilde(effectiveParams.sessionDir));
|
|
8281
8405
|
else {
|
|
8282
|
-
let baseSessionRoot = deps.config.defaultSessionDir ?
|
|
8283
|
-
sessionRoot =
|
|
8406
|
+
let baseSessionRoot = deps.config.defaultSessionDir ? path16.resolve(deps.expandTilde(deps.config.defaultSessionDir)) : deps.getSubagentSessionRoot(parentSessionFile);
|
|
8407
|
+
sessionRoot = path16.join(baseSessionRoot, runId);
|
|
8284
8408
|
}
|
|
8285
8409
|
try {
|
|
8286
|
-
|
|
8410
|
+
fs16.mkdirSync(sessionRoot, { recursive: !0 });
|
|
8287
8411
|
} catch (error) {
|
|
8288
8412
|
let message = error instanceof Error ? error.message : String(error);
|
|
8289
8413
|
return toExecutionErrorResult(effectiveParams, new Error(`Failed to create session directory '${sessionRoot}': ${message}`));
|
|
8290
8414
|
}
|
|
8291
|
-
let sessionDirForIndex = (idx) =>
|
|
8415
|
+
let sessionDirForIndex = (idx) => path16.join(sessionRoot, `run-${idx ?? 0}`), forkSessionFileForTask = (agentName, idx = 0, modelOverride) => {
|
|
8292
8416
|
if (shouldForkAgent(contextPolicy, agentName))
|
|
8293
8417
|
return prepareForkThinking(agentName, idx, modelOverride), forkSessionFileForIndex(idx);
|
|
8294
8418
|
}, forkThinkingOverrideForTask = (agentName, idx = 0, modelOverride) => {
|
|
@@ -8297,7 +8421,7 @@ function createSubagentExecutor(deps) {
|
|
|
8297
8421
|
prepareForkThinking(agentName, idx, modelOverride);
|
|
8298
8422
|
let override = forkThinkingOverrideForIndex(idx);
|
|
8299
8423
|
return override === "off" && forkThinkingDowngrades.set(idx, agentName), override;
|
|
8300
|
-
}, childSessionFileForTask = (agentName, idx, modelOverride) => forkSessionFileForTask(agentName, idx, modelOverride) ??
|
|
8424
|
+
}, childSessionFileForTask = (agentName, idx, modelOverride) => forkSessionFileForTask(agentName, idx, modelOverride) ?? path16.join(sessionDirForIndex(idx), "session.jsonl"), childSessionFileForIndex = (idx) => path16.join(sessionDirForIndex(idx), "session.jsonl");
|
|
8301
8425
|
try {
|
|
8302
8426
|
effectiveParams.clarify === !0 && ctx.hasUI || preflightForkSessionsForStaticTasks(effectiveParams, contextPolicy, forkSessionFileForTask, deps.config.chain?.dynamicFanout?.maxItems);
|
|
8303
8427
|
} catch (error) {
|