@ashx-j/lunr 0.2.19 → 0.2.21
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 +36 -1
- package/README.md +2 -2
- package/dist/builtin-extensions/index.d.ts.map +1 -1
- package/dist/builtin-extensions/index.js +0 -2
- package/dist/builtin-extensions/index.js.map +1 -1
- package/dist/builtin-extensions/lunr-todos.d.ts +6 -5
- package/dist/builtin-extensions/lunr-todos.d.ts.map +1 -1
- package/dist/builtin-extensions/lunr-todos.js +9 -7
- package/dist/builtin-extensions/lunr-todos.js.map +1 -1
- package/dist/builtin-extensions/pi-intercom/broker/spawn.d.ts +6 -4
- package/dist/builtin-extensions/pi-intercom/broker/spawn.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-intercom/broker/spawn.js +114 -61
- package/dist/builtin-extensions/pi-intercom/broker/spawn.js.map +1 -1
- package/dist/builtin-extensions/pi-intercom/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-intercom/index.js +360 -351
- package/dist/builtin-extensions/pi-intercom/index.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/fanout-child.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/fanout-child.js +2 -2
- package/dist/builtin-extensions/pi-subagents/src/extension/fanout-child.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts +8 -6
- package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/index.js +128 -57
- package/dist/builtin-extensions/pi-subagents/src/extension/index.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/schemas.d.ts +18 -8
- package/dist/builtin-extensions/pi-subagents/src/extension/schemas.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/schemas.js +38 -13
- package/dist/builtin-extensions/pi-subagents/src/extension/schemas.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.d.ts +4 -3
- package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.js +24 -14
- package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.d.ts +8 -1
- package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.js +247 -18
- package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/intercom/result-intercom.d.ts +1 -0
- package/dist/builtin-extensions/pi-subagents/src/intercom/result-intercom.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/intercom/result-intercom.js +1 -1
- package/dist/builtin-extensions/pi-subagents/src/intercom/result-intercom.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-ask.d.ts +29 -0
- package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-ask.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-ask.js +179 -0
- package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-ask.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-questions.d.ts +89 -0
- package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-questions.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-questions.js +541 -0
- package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-questions.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.d.ts +11 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.js +38 -12
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-execution.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-job-tracker.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-job-tracker.js +3 -2
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-job-tracker.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-resume.d.ts +2 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-resume.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-resume.js +35 -8
- package/dist/builtin-extensions/pi-subagents/src/runs/background/async-resume.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.d.ts +7 -3
- 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 +26 -4
- 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 +1 -0
- 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 +55 -38
- 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 +100 -0
- 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 +46 -31
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.d.ts +3 -6
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.js +64 -5
- package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/top-level-async.d.ts +15 -2
- package/dist/builtin-extensions/pi-subagents/src/runs/background/top-level-async.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/top-level-async.js +14 -4
- package/dist/builtin-extensions/pi-subagents/src/runs/background/top-level-async.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.js +2 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.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 +21 -8
- 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.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js +1 -1
- 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 +0 -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 +71 -25
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/acceptance.d.ts +2 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/acceptance.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/acceptance.js +75 -18
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/acceptance.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/completion-guard.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/completion-guard.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/completion-guard.js +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/completion-guard.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.d.ts +13 -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 +67 -11
- 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 +1 -0
- 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.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.d.ts +3 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.js +7 -2
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.js +13 -3
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/task-intent.d.ts +2 -2
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/task-intent.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/task-intent.js +5 -10
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/task-intent.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/async-guidance.d.ts +2 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/async-guidance.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/async-guidance.js +3 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/async-guidance.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.d.ts +3 -0
- package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.js +68 -11
- package/dist/builtin-extensions/pi-subagents/src/shared/child-spec.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/formatters.d.ts +12 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/formatters.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/formatters.js +21 -2
- package/dist/builtin-extensions/pi-subagents/src/shared/formatters.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts +21 -4
- package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/types.js +1 -1
- package/dist/builtin-extensions/pi-subagents/src/shared/types.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/delegation-adapters.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/delegation-adapters.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.d.ts +7 -0
- 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 +11 -7
- 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 +6 -0
- 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 +46 -29
- 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 +46 -4
- package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render.js +407 -450
- package/dist/builtin-extensions/pi-subagents/src/tui/render.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/register-main.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/register-main.js +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/register-main.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/tool-actions.d.ts +2 -13
- package/dist/builtin-extensions/pi-subagents/src/watchdog/tool-actions.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/watchdog/tool-actions.js +5 -91
- package/dist/builtin-extensions/pi-subagents/src/watchdog/tool-actions.js.map +1 -1
- package/dist/core/customize.d.ts +2 -0
- package/dist/core/customize.d.ts.map +1 -1
- package/dist/core/customize.js +3 -0
- package/dist/core/customize.js.map +1 -1
- package/dist/core/permissions.d.ts +1 -0
- package/dist/core/permissions.d.ts.map +1 -1
- package/dist/core/permissions.js +8 -4
- package/dist/core/permissions.js.map +1 -1
- package/dist/core/plan-mode.d.ts.map +1 -1
- package/dist/core/plan-mode.js +0 -5
- package/dist/core/plan-mode.js.map +1 -1
- package/dist/core/runtime-bridges.d.ts.map +1 -1
- package/dist/core/runtime-bridges.js +0 -2
- package/dist/core/runtime-bridges.js.map +1 -1
- package/dist/core/settings-manager.d.ts +4 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +11 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/subagent-cancellation.d.ts +21 -0
- package/dist/core/subagent-cancellation.d.ts.map +1 -0
- package/dist/core/subagent-cancellation.js +53 -0
- package/dist/core/subagent-cancellation.js.map +1 -0
- package/dist/core/subagent-spinner-setting.d.ts +6 -0
- package/dist/core/subagent-spinner-setting.d.ts.map +1 -0
- package/dist/core/subagent-spinner-setting.js +12 -0
- package/dist/core/subagent-spinner-setting.js.map +1 -0
- package/dist/core/subagent-spinner.d.ts +4 -0
- package/dist/core/subagent-spinner.d.ts.map +1 -0
- package/dist/core/subagent-spinner.js +6 -0
- package/dist/core/subagent-spinner.js.map +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +12 -18
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +4 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +73 -1
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +12 -0
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/extension-widget-order.d.ts +8 -0
- package/dist/modes/interactive/extension-widget-order.d.ts.map +1 -0
- package/dist/modes/interactive/extension-widget-order.js +37 -0
- package/dist/modes/interactive/extension-widget-order.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +44 -22
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/node-runtime/{agent-session-services-35WNVGMR.js → agent-session-services-C743TYQE.js} +6 -5
- package/dist/node-runtime/{builtin-extensions-322XDDEM.js → builtin-extensions-JCOPAAB5.js} +3 -2
- package/dist/node-runtime/{chunk-XATUM2HK.js → chunk-25I2BHAA.js} +1 -1
- package/dist/node-runtime/{chunk-TXHKBRHZ.js → chunk-2BUAYZ7K.js} +136 -53
- package/dist/node-runtime/chunk-5ZH3ZFIZ.js +308 -0
- package/dist/node-runtime/{chunk-J26TSGDL.js → chunk-6N22HULO.js} +8 -5
- package/dist/node-runtime/chunk-A3KMVBZV.js +60 -0
- package/dist/node-runtime/{chunk-4FX25LWP.js → chunk-AWVD5IEY.js} +20 -421
- package/dist/node-runtime/{chunk-ZRCBN365.js → chunk-GB2MGFLI.js} +12 -12
- package/dist/node-runtime/chunk-LISUTZS3.js +19 -0
- package/dist/node-runtime/{chunk-PNJSG3IZ.js → chunk-LTYWTR3V.js} +1 -369
- package/dist/node-runtime/{chunk-TFBIJTM3.js → chunk-PDNXVXMD.js} +13 -13
- package/dist/node-runtime/{chunk-MCUNIRD5.js → chunk-SY2TFMLO.js} +532 -261
- package/dist/node-runtime/{chunk-HQCKFM2O.js → chunk-VGYZ3APQ.js} +3 -0
- package/dist/node-runtime/{chunk-4DJ6HEGH.js → chunk-VZR3NCM7.js} +3 -3
- package/dist/node-runtime/chunk-W3SILANP.js +24 -0
- package/dist/node-runtime/{chunk-CBGB57XT.js → chunk-WLLDXJRT.js} +10 -0
- package/dist/node-runtime/{chunk-ATGA2WLC.js → chunk-XI77KVKA.js} +399 -36
- package/dist/node-runtime/{chunk-4CSFRBCN.js → chunk-Y5KOEMBH.js} +1 -1
- package/dist/node-runtime/{chunk-AROOY4BB.js → chunk-YMEAYRBE.js} +1 -1
- package/dist/node-runtime/{command-DWUM5X3U.js → command-P4NYCJ2M.js} +1 -1
- package/dist/node-runtime/{customize-XEXL2DGQ.js → customize-LF5VST47.js} +1 -1
- package/dist/node-runtime/{gateway-UZXMFGWY.js → gateway-BM6NLOH4.js} +2 -2
- package/dist/node-runtime/index.js +16 -13
- package/dist/node-runtime/{interactive-mode-QT5IKGQ5.js → interactive-mode-EVVBA64D.js} +11 -8
- package/dist/node-runtime/{lunr-cron-QPBTKBGI.js → lunr-cron-4VHP4E4B.js} +2 -2
- package/dist/node-runtime/main.js +14 -12
- package/dist/node-runtime/{package-manager-cli-7RKSZGEN.js → package-manager-cli-N37546V5.js} +5 -4
- package/dist/node-runtime/{pi-intercom-EEMBGQID.js → pi-intercom-NV2LW6X7.js} +108 -87
- package/dist/node-runtime/{pi-subagents-7YJ3I4VE.js → pi-subagents-6MUIFNDM.js} +1262 -599
- package/dist/node-runtime/rpc-entry.js +14 -12
- package/dist/node-runtime/{runtime-bridges-3RKBDLNA.js → runtime-bridges-2VQTLPOZ.js} +3 -5
- package/dist/node-runtime/{settings-manager-GHPTUN7R.js → settings-manager-CUGAZWAB.js} +2 -1
- package/dist/node-runtime/{subagent-executor-5Q5A4HJ2.js → subagent-executor-MH4A7CCF.js} +181 -294
- package/dist/node-runtime/{update-cli-L3JIBH2U.js → update-cli-XTZMZGOL.js} +2 -1
- package/docs/features.md +22 -4
- package/docs/keybindings.md +3 -1
- package/docs/settings.md +3 -2
- 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/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/package.json +4 -4
- package/dist/builtin-extensions/lunr-settings-tools.d.ts +0 -4
- package/dist/builtin-extensions/lunr-settings-tools.d.ts.map +0 -1
- package/dist/builtin-extensions/lunr-settings-tools.js +0 -120
- package/dist/builtin-extensions/lunr-settings-tools.js.map +0 -1
- package/dist/core/settings-tools-bridge.d.ts +0 -35
- package/dist/core/settings-tools-bridge.d.ts.map +0 -1
- package/dist/core/settings-tools-bridge.js +0 -56
- package/dist/core/settings-tools-bridge.js.map +0 -1
- package/dist/node-runtime/chunk-3NMWLTPV.js +0 -64
|
@@ -2,7 +2,7 @@ import { createRequire as __lunrRequire } from "node:module"; const require = __
|
|
|
2
2
|
import {
|
|
3
3
|
PLAN_MODE_WRITE_SPAWN_ERROR,
|
|
4
4
|
resolveChildPermissions
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-25I2BHAA.js";
|
|
6
6
|
import {
|
|
7
7
|
createReadOnlyTools
|
|
8
8
|
} from "./chunk-WKDK4C5P.js";
|
|
@@ -63,7 +63,8 @@ function resolveTempScopeId(options) {
|
|
|
63
63
|
}
|
|
64
64
|
return "shared";
|
|
65
65
|
}
|
|
66
|
-
var MAX_PARALLEL = Number.MAX_SAFE_INTEGER, MAX_CONCURRENCY = Number.MAX_SAFE_INTEGER, TEMP_ROOT_DIR = path.join(os.tmpdir(), `pi-subagents-${resolveTempScopeId()}`), RESULTS_DIR = path.join(TEMP_ROOT_DIR, "async-subagent-results"), ASYNC_DIR = path.join(TEMP_ROOT_DIR, "async-subagent-runs"), CHAIN_RUNS_DIR = path.join(TEMP_ROOT_DIR, "chain-runs"), TEMP_ARTIFACTS_DIR = path.join(TEMP_ROOT_DIR, "artifacts"), WIDGET_KEY = "subagent-async", SLASH_RESULT_TYPE = "subagent-slash-result", SLASH_TEXT_RESULT_TYPE = "subagent-slash-text-result", SLASH_SUBAGENT_REQUEST_EVENT = "subagent:slash:request", SLASH_SUBAGENT_STARTED_EVENT = "subagent:slash:started", SLASH_SUBAGENT_RESPONSE_EVENT = "subagent:slash:response", SLASH_SUBAGENT_UPDATE_EVENT = "subagent:slash:update", SLASH_SUBAGENT_CANCEL_EVENT = "subagent:slash:cancel", POLL_INTERVAL_MS = 250
|
|
66
|
+
var MAX_PARALLEL = Number.MAX_SAFE_INTEGER, MAX_CONCURRENCY = Number.MAX_SAFE_INTEGER, TEMP_ROOT_DIR = path.join(os.tmpdir(), `pi-subagents-${resolveTempScopeId()}`), RESULTS_DIR = path.join(TEMP_ROOT_DIR, "async-subagent-results"), ASYNC_DIR = path.join(TEMP_ROOT_DIR, "async-subagent-runs"), CHAIN_RUNS_DIR = path.join(TEMP_ROOT_DIR, "chain-runs"), TEMP_ARTIFACTS_DIR = path.join(TEMP_ROOT_DIR, "artifacts"), WIDGET_KEY = "subagent-async", SLASH_RESULT_TYPE = "subagent-slash-result", SLASH_TEXT_RESULT_TYPE = "subagent-slash-text-result", SLASH_SUBAGENT_REQUEST_EVENT = "subagent:slash:request", SLASH_SUBAGENT_STARTED_EVENT = "subagent:slash:started", SLASH_SUBAGENT_RESPONSE_EVENT = "subagent:slash:response", SLASH_SUBAGENT_UPDATE_EVENT = "subagent:slash:update", SLASH_SUBAGENT_CANCEL_EVENT = "subagent:slash:cancel", POLL_INTERVAL_MS = 250;
|
|
67
|
+
var DEFAULT_SUBAGENT_MAX_DEPTH = 2, SUBAGENT_ACTIONS = ["status", "interrupt", "resume", "steer", "stop", "append-step", "doctor", "watchdog.status", "watchdog.check", "watchdog.recommend-model", "schedule", "schedule-list", "schedule-status", "schedule-cancel"];
|
|
67
68
|
var DEFAULT_FORK_PREAMBLE = "You are a delegated subagent running from a fork of the parent session. Treat the inherited conversation as reference-only context, not a live thread to continue. Do not continue or answer prior messages as if they are waiting for a reply. Your sole job is to execute the task below and return a focused result for that task using your tools.";
|
|
68
69
|
function normalizeTopLevelParallelValue(value) {
|
|
69
70
|
let parsed = typeof value == "number" ? value : typeof value == "string" ? Number(value) : NaN;
|
|
@@ -420,7 +421,22 @@ function formatModelThinking(model, thinking) {
|
|
|
420
421
|
return [displayModel, formatThinkingLabel(model, thinking)].filter(Boolean).join(" \xB7 ");
|
|
421
422
|
}
|
|
422
423
|
function formatModelSelection(selection, resolvedModel, thinking) {
|
|
423
|
-
|
|
424
|
+
if (selection?.kind === "tier" && selection.tier)
|
|
425
|
+
return [selection.tier, formatThinkingLabel(resolvedModel, thinking)].filter(Boolean).join(" \xB7 ");
|
|
426
|
+
let selectedModel = selection?.kind === "model" ? selection.model : void 0;
|
|
427
|
+
return formatModelThinking(selectedModel || resolvedModel, thinking);
|
|
428
|
+
}
|
|
429
|
+
function formatModelId(model) {
|
|
430
|
+
if (!model)
|
|
431
|
+
return "";
|
|
432
|
+
let displayModel = splitKnownThinkingSuffix(model).baseModel, slashIdx = displayModel.lastIndexOf("/");
|
|
433
|
+
return slashIdx !== -1 && (displayModel = displayModel.slice(slashIdx + 1)), displayModel;
|
|
434
|
+
}
|
|
435
|
+
function formatCompactModelBadge(selection, resolvedModel) {
|
|
436
|
+
if (selection?.kind === "tier" && selection.tier)
|
|
437
|
+
return selection.tier;
|
|
438
|
+
let explicit = selection?.kind === "model" && typeof selection.model == "string" && selection.model.trim() ? selection.model : void 0;
|
|
439
|
+
return formatModelId(explicit ?? resolvedModel);
|
|
424
440
|
}
|
|
425
441
|
function formatUsage(u, model) {
|
|
426
442
|
let parts = [];
|
|
@@ -1911,7 +1927,7 @@ function resolveRuntimeScriptPath(basePathWithoutExt) {
|
|
|
1911
1927
|
let tsPath = `${basePathWithoutExt}.ts`;
|
|
1912
1928
|
return fs9.existsSync(tsPath) ? tsPath : `${basePathWithoutExt}.js`;
|
|
1913
1929
|
}
|
|
1914
|
-
var PROMPT_RUNTIME_EXTENSION_PATH = resolveRuntimeScriptPath(path10.join(path10.dirname(fileURLToPath(new URL("../builtin-extensions/pi-subagents/src/runs/shared/pi-args.js", import.meta.url).href)), "subagent-prompt-runtime")), FANOUT_CHILD_EXTENSION_PATH = resolveRuntimeScriptPath(path10.join(path10.dirname(fileURLToPath(new URL("../builtin-extensions/pi-subagents/src/runs/shared/pi-args.js", import.meta.url).href)), "..", "..", "extension", "fanout-child")), SUBAGENT_CHILD_ENV = "PI_SUBAGENT_CHILD", SUBAGENT_ORCHESTRATOR_TARGET_ENV = "PI_SUBAGENT_ORCHESTRATOR_TARGET", SUBAGENT_ORCHESTRATOR_SESSION_ID_ENV = "PI_SUBAGENT_ORCHESTRATOR_SESSION_ID", SUBAGENT_SUPERVISOR_CHANNEL_DIR_ENV = "PI_SUBAGENT_SUPERVISOR_CHANNEL_DIR", SUBAGENT_RUN_ID_ENV = "PI_SUBAGENT_RUN_ID", SUBAGENT_CHILD_AGENT_ENV = "PI_SUBAGENT_CHILD_AGENT", SUBAGENT_CHILD_INDEX_ENV = "PI_SUBAGENT_CHILD_INDEX", SUBAGENT_FANOUT_CHILD_ENV = "PI_SUBAGENT_FANOUT_CHILD", SUBAGENT_PARENT_EVENT_SINK_ENV = "PI_SUBAGENT_PARENT_EVENT_SINK", SUBAGENT_PARENT_CONTROL_INBOX_ENV = "PI_SUBAGENT_PARENT_CONTROL_INBOX", SUBAGENT_PARENT_ROOT_RUN_ID_ENV = "PI_SUBAGENT_PARENT_ROOT_RUN_ID", SUBAGENT_PARENT_RUN_ID_ENV = "PI_SUBAGENT_PARENT_RUN_ID", SUBAGENT_PARENT_CHILD_INDEX_ENV = "PI_SUBAGENT_PARENT_CHILD_INDEX", SUBAGENT_PARENT_DEPTH_ENV = "PI_SUBAGENT_PARENT_DEPTH", SUBAGENT_PARENT_PATH_ENV = "PI_SUBAGENT_PARENT_PATH", SUBAGENT_PARENT_CAPABILITY_TOKEN_ENV = "PI_SUBAGENT_PARENT_CAPABILITY_TOKEN", SUBAGENT_PARENT_SESSION_ENV = "PI_SUBAGENT_PARENT_SESSION", SUBAGENT_PARENT_PERMISSION_MODE_ENV = "PI_SUBAGENT_PARENT_PERMISSION_MODE", SUBAGENT_CHILD_PERMISSION_ENV = "PI_SUBAGENT_CHILD_PERMISSION", SUBAGENT_STEER_INBOX_ENV = "PI_SUBAGENT_STEER_INBOX", SUBAGENT_STEER_CAPABILITY_ENV = "PI_SUBAGENT_STEER_CAPABILITY", SUBAGENT_STEER_ACK_DIR_ENV = "PI_SUBAGENT_STEER_ACK_DIR";
|
|
1930
|
+
var PROMPT_RUNTIME_EXTENSION_PATH = resolveRuntimeScriptPath(path10.join(path10.dirname(fileURLToPath(new URL("../builtin-extensions/pi-subagents/src/runs/shared/pi-args.js", import.meta.url).href)), "subagent-prompt-runtime")), FANOUT_CHILD_EXTENSION_PATH = resolveRuntimeScriptPath(path10.join(path10.dirname(fileURLToPath(new URL("../builtin-extensions/pi-subagents/src/runs/shared/pi-args.js", import.meta.url).href)), "..", "..", "extension", "fanout-child")), SUBAGENT_CHILD_ENV = "PI_SUBAGENT_CHILD", SUBAGENT_ORCHESTRATOR_TARGET_ENV = "PI_SUBAGENT_ORCHESTRATOR_TARGET", SUBAGENT_ORCHESTRATOR_SESSION_ID_ENV = "PI_SUBAGENT_ORCHESTRATOR_SESSION_ID", SUBAGENT_SUPERVISOR_SESSION_ID_ENV = "PI_SUBAGENT_SUPERVISOR_SESSION_ID", SUBAGENT_SUPERVISOR_CHANNEL_DIR_ENV = "PI_SUBAGENT_SUPERVISOR_CHANNEL_DIR", SUBAGENT_RUN_ID_ENV = "PI_SUBAGENT_RUN_ID", SUBAGENT_CHILD_AGENT_ENV = "PI_SUBAGENT_CHILD_AGENT", SUBAGENT_CHILD_INDEX_ENV = "PI_SUBAGENT_CHILD_INDEX", SUBAGENT_FANOUT_CHILD_ENV = "PI_SUBAGENT_FANOUT_CHILD", SUBAGENT_PARENT_EVENT_SINK_ENV = "PI_SUBAGENT_PARENT_EVENT_SINK", SUBAGENT_PARENT_CONTROL_INBOX_ENV = "PI_SUBAGENT_PARENT_CONTROL_INBOX", SUBAGENT_PARENT_ROOT_RUN_ID_ENV = "PI_SUBAGENT_PARENT_ROOT_RUN_ID", SUBAGENT_PARENT_RUN_ID_ENV = "PI_SUBAGENT_PARENT_RUN_ID", SUBAGENT_PARENT_CHILD_INDEX_ENV = "PI_SUBAGENT_PARENT_CHILD_INDEX", SUBAGENT_PARENT_DEPTH_ENV = "PI_SUBAGENT_PARENT_DEPTH", SUBAGENT_PARENT_PATH_ENV = "PI_SUBAGENT_PARENT_PATH", SUBAGENT_PARENT_CAPABILITY_TOKEN_ENV = "PI_SUBAGENT_PARENT_CAPABILITY_TOKEN", SUBAGENT_PARENT_SESSION_ENV = "PI_SUBAGENT_PARENT_SESSION", SUBAGENT_PARENT_PERMISSION_MODE_ENV = "PI_SUBAGENT_PARENT_PERMISSION_MODE", SUBAGENT_CHILD_PERMISSION_ENV = "PI_SUBAGENT_CHILD_PERMISSION", SUBAGENT_STEER_INBOX_ENV = "PI_SUBAGENT_STEER_INBOX", SUBAGENT_STEER_CAPABILITY_ENV = "PI_SUBAGENT_STEER_CAPABILITY", SUBAGENT_STEER_ACK_DIR_ENV = "PI_SUBAGENT_STEER_ACK_DIR";
|
|
1915
1931
|
function sanitizeSupervisorChannelSegment(value) {
|
|
1916
1932
|
return value.trim().replace(/[^A-Za-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "unknown";
|
|
1917
1933
|
}
|
|
@@ -1968,9 +1984,9 @@ function buildPiArgs(input) {
|
|
|
1968
1984
|
...input.childAgentName ? { agent: input.childAgentName } : {}
|
|
1969
1985
|
}] : []
|
|
1970
1986
|
];
|
|
1971
|
-
if (env[SUBAGENT_PARENT_EVENT_SINK_ENV] = fanoutAuthorized ? input.parentEventSink ?? process.env[SUBAGENT_PARENT_EVENT_SINK_ENV] ?? "" : "", env[SUBAGENT_PARENT_CONTROL_INBOX_ENV] = fanoutAuthorized ? input.parentControlInbox ?? process.env[SUBAGENT_PARENT_CONTROL_INBOX_ENV] ?? "" : "", env[SUBAGENT_PARENT_ROOT_RUN_ID_ENV] = fanoutAuthorized ? input.parentRootRunId ?? process.env[SUBAGENT_PARENT_ROOT_RUN_ID_ENV] ?? input.runId ?? "" : "", env[SUBAGENT_PARENT_RUN_ID_ENV] = fanoutAuthorized ? parentRunId : "", env[SUBAGENT_PARENT_CHILD_INDEX_ENV] = fanoutAuthorized ? parentChildIndex : "", env[SUBAGENT_PARENT_DEPTH_ENV] = fanoutAuthorized ? String(parentDepth) : "", env[SUBAGENT_PARENT_PATH_ENV] = fanoutAuthorized ? encodeNestedPathEnv(parentPath) : "", env[SUBAGENT_PARENT_CAPABILITY_TOKEN_ENV] = fanoutAuthorized ? input.parentCapabilityToken ?? process.env[SUBAGENT_PARENT_CAPABILITY_TOKEN_ENV] ?? "" : "", env.PI_SUBAGENT_INHERIT_PROJECT_CONTEXT = input.inheritProjectContext ? "1" : "0", env.PI_SUBAGENT_INHERIT_SKILLS = input.inheritSkills ? "1" : "0", input.intercomSessionName && (env.PI_SUBAGENT_INTERCOM_SESSION_NAME = input.intercomSessionName), input.orchestratorIntercomTarget && (env[SUBAGENT_ORCHESTRATOR_TARGET_ENV] = input.orchestratorIntercomTarget), input.parentSessionId && (env[SUBAGENT_ORCHESTRATOR_SESSION_ID_ENV] = input.parentSessionId), input.
|
|
1972
|
-
let childIndex = input.childIndex ?? 0, channelDir = supervisorChannelDir(input.runId,
|
|
1973
|
-
fs9.mkdirSync(path10.join(channelDir, "requests"), { recursive: !0 }), fs9.mkdirSync(path10.join(channelDir, "replies"), { recursive: !0 }), env[SUBAGENT_SUPERVISOR_CHANNEL_DIR_ENV] = channelDir;
|
|
1987
|
+
if (env[SUBAGENT_PARENT_EVENT_SINK_ENV] = fanoutAuthorized ? input.parentEventSink ?? process.env[SUBAGENT_PARENT_EVENT_SINK_ENV] ?? "" : "", env[SUBAGENT_PARENT_CONTROL_INBOX_ENV] = fanoutAuthorized ? input.parentControlInbox ?? process.env[SUBAGENT_PARENT_CONTROL_INBOX_ENV] ?? "" : "", env[SUBAGENT_PARENT_ROOT_RUN_ID_ENV] = fanoutAuthorized ? input.parentRootRunId ?? process.env[SUBAGENT_PARENT_ROOT_RUN_ID_ENV] ?? input.runId ?? "" : "", env[SUBAGENT_PARENT_RUN_ID_ENV] = fanoutAuthorized ? parentRunId : "", env[SUBAGENT_PARENT_CHILD_INDEX_ENV] = fanoutAuthorized ? parentChildIndex : "", env[SUBAGENT_PARENT_DEPTH_ENV] = fanoutAuthorized ? String(parentDepth) : "", env[SUBAGENT_PARENT_PATH_ENV] = fanoutAuthorized ? encodeNestedPathEnv(parentPath) : "", env[SUBAGENT_PARENT_CAPABILITY_TOKEN_ENV] = fanoutAuthorized ? input.parentCapabilityToken ?? process.env[SUBAGENT_PARENT_CAPABILITY_TOKEN_ENV] ?? "" : "", env.PI_SUBAGENT_INHERIT_PROJECT_CONTEXT = input.inheritProjectContext ? "1" : "0", env.PI_SUBAGENT_INHERIT_SKILLS = input.inheritSkills ? "1" : "0", input.intercomSessionName && (env.PI_SUBAGENT_INTERCOM_SESSION_NAME = input.intercomSessionName), input.orchestratorIntercomTarget && (env[SUBAGENT_ORCHESTRATOR_TARGET_ENV] = input.orchestratorIntercomTarget), input.parentSessionId && (env[SUBAGENT_ORCHESTRATOR_SESSION_ID_ENV] = input.parentSessionId), env[SUBAGENT_SUPERVISOR_SESSION_ID_ENV] = input.supervisorSessionId ?? "", input.parentSessionId && input.runId && (input.childId || input.childAgentName)) {
|
|
1988
|
+
let childIndex = input.childIndex ?? 0, channelAgent = input.childId ?? input.childAgentName, channelDir = supervisorChannelDir(input.runId, channelAgent, childIndex);
|
|
1989
|
+
fs9.mkdirSync(path10.join(channelDir, "requests"), { recursive: !0 }), fs9.mkdirSync(path10.join(channelDir, "replies"), { recursive: !0 }), fs9.mkdirSync(path10.join(channelDir, "questions"), { recursive: !0 }), env[SUBAGENT_SUPERVISOR_CHANNEL_DIR_ENV] = channelDir, env[SUBAGENT_CHILD_INDEX_ENV] = String(childIndex);
|
|
1974
1990
|
}
|
|
1975
1991
|
input.runId && (env[SUBAGENT_RUN_ID_ENV] = input.runId), (input.childId || input.childAgentName) && (env[SUBAGENT_CHILD_AGENT_ENV] = input.childId ?? input.childAgentName), input.childIndex !== void 0 && (env[SUBAGENT_CHILD_INDEX_ENV] = String(input.childIndex)), input.mcpDirectTools?.length ? env.MCP_DIRECT_TOOLS = input.mcpDirectTools.join(",") : env.MCP_DIRECT_TOOLS = "__none__", input.structuredOutput && (env[STRUCTURED_OUTPUT_CAPTURE_ENV] = input.structuredOutput.outputPath, env[STRUCTURED_OUTPUT_SCHEMA_ENV] = input.structuredOutput.schemaPath), input.steerInboxDir && (env[SUBAGENT_STEER_INBOX_ENV] = input.steerInboxDir), input.steerCapabilityPath && (env[SUBAGENT_STEER_CAPABILITY_ENV] = input.steerCapabilityPath), input.steerAckDir && (env[SUBAGENT_STEER_ACK_DIR_ENV] = input.steerAckDir);
|
|
1976
1992
|
let encodedToolBudget = encodeToolBudgetEnv(input.toolBudget);
|
|
@@ -1988,11 +2004,7 @@ function cleanupTempDir(tempDir) {
|
|
|
1988
2004
|
|
|
1989
2005
|
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.js
|
|
1990
2006
|
function splitThinkingSuffix(model) {
|
|
1991
|
-
|
|
1992
|
-
return colonIdx === -1 ? { baseModel: model, thinkingSuffix: "" } : {
|
|
1993
|
-
baseModel: model.substring(0, colonIdx),
|
|
1994
|
-
thinkingSuffix: model.substring(colonIdx)
|
|
1995
|
-
};
|
|
2007
|
+
return splitKnownThinkingSuffix(model);
|
|
1996
2008
|
}
|
|
1997
2009
|
var INHERIT_MODEL = "inherit";
|
|
1998
2010
|
function normalizeModelSegment(segment) {
|
|
@@ -2120,14 +2132,61 @@ function resolveRequiredTierModel(tier, availableModels, preferredProvider) {
|
|
|
2120
2132
|
throw new Error(`Model tier '${String(tier)}' resolves to '${baseModel}', but that model is unavailable or unauthenticated. Configure an available model in /settings.`);
|
|
2121
2133
|
return `${resolvedBase}${thinkingSuffix}`;
|
|
2122
2134
|
}
|
|
2135
|
+
function requestedModelString(model) {
|
|
2136
|
+
return typeof model == "string" && model.trim() && model.trim() !== INHERIT_MODEL ? model.trim() : void 0;
|
|
2137
|
+
}
|
|
2123
2138
|
function requestedTier(tier) {
|
|
2124
2139
|
return tier === "light" || tier === "standard" || tier === "heavy" ? tier : void 0;
|
|
2125
2140
|
}
|
|
2141
|
+
function parseExplicitThinking(value, pathLabel = "thinking") {
|
|
2142
|
+
if (value !== void 0) {
|
|
2143
|
+
if (value === !1 || value === "off")
|
|
2144
|
+
return "off";
|
|
2145
|
+
if (typeof value != "string" || !THINKING_LEVELS.includes(value))
|
|
2146
|
+
throw new Error(`${pathLabel} must be one of ${THINKING_LEVELS.join(", ")}.`);
|
|
2147
|
+
return value;
|
|
2148
|
+
}
|
|
2149
|
+
}
|
|
2126
2150
|
function captureModelSelection(input) {
|
|
2127
|
-
let tier = requestedTier(input.tier);
|
|
2128
|
-
if (
|
|
2129
|
-
throw new Error('
|
|
2130
|
-
|
|
2151
|
+
let model = typeof input.model == "string" ? input.model.trim() : "", hasModel = !!model, tier = requestedTier(input.tier);
|
|
2152
|
+
if (hasModel && model === INHERIT_MODEL)
|
|
2153
|
+
throw new Error('model "inherit" is not supported; choose tier: "light", "standard", or "heavy", or an explicit provider/model.');
|
|
2154
|
+
if (hasModel && tier)
|
|
2155
|
+
throw new Error("Choose exactly one of tier or model; do not pass both.");
|
|
2156
|
+
if (hasModel)
|
|
2157
|
+
return { kind: "model", model };
|
|
2158
|
+
if (tier)
|
|
2159
|
+
return { kind: "tier", tier };
|
|
2160
|
+
throw new Error('Every executable child requires tier: "light", "standard", or "heavy", or an explicit model when the user names one.');
|
|
2161
|
+
}
|
|
2162
|
+
function resolveRequiredExplicitModel(model, availableModels, preferredProvider, thinking) {
|
|
2163
|
+
let requested = requestedModelString(model);
|
|
2164
|
+
if (!requested)
|
|
2165
|
+
throw new Error('Explicit model selection requires model as "provider/id".');
|
|
2166
|
+
if (!availableModels?.length)
|
|
2167
|
+
throw new Error(`Model '${requested}' cannot launch because no authenticated models are available.`);
|
|
2168
|
+
let { baseModel, thinkingSuffix } = splitThinkingSuffix(requested), resolvedBase = resolveBaseModelCandidate(baseModel, availableModels, preferredProvider);
|
|
2169
|
+
if (!resolvedBase)
|
|
2170
|
+
throw new Error(`Model '${baseModel}' is unavailable or unauthenticated. Choose an available provider/model or a configured tier.`);
|
|
2171
|
+
let fromSuffix = thinkingSuffix ? thinkingSuffix.slice(1) : void 0, fromParam = parseExplicitThinking(thinking);
|
|
2172
|
+
if (fromSuffix && fromParam && fromSuffix !== fromParam)
|
|
2173
|
+
throw new Error(`Conflicting thinking levels '${fromSuffix}' and '${fromParam}' for model '${requested}'.`);
|
|
2174
|
+
let level = fromParam ?? fromSuffix;
|
|
2175
|
+
if (!level)
|
|
2176
|
+
return resolvedBase;
|
|
2177
|
+
let info = availableModels.find((entry) => entry.fullId === resolvedBase), supported = getSupportedThinkingLevels(info);
|
|
2178
|
+
if (!supported.includes(level))
|
|
2179
|
+
throw new Error(`Thinking level '${level}' is not supported by '${resolvedBase}'. Supported: ${supported.join(", ") || "none"}.`);
|
|
2180
|
+
return applyThinkingSuffix(resolvedBase, level, !0) ?? resolvedBase;
|
|
2181
|
+
}
|
|
2182
|
+
function resolveExecutableChildModel(input) {
|
|
2183
|
+
let selection = input.modelSelection ?? captureModelSelection({ model: input.model, tier: input.tier });
|
|
2184
|
+
if (selection.kind === "tier") {
|
|
2185
|
+
if (input.thinking !== void 0)
|
|
2186
|
+
throw new Error("thinking is only valid with an explicit model; tier children use the configured tier thinking level.");
|
|
2187
|
+
return resolveRequiredTierModel(selection.tier, input.availableModels, input.preferredProvider);
|
|
2188
|
+
}
|
|
2189
|
+
return resolveRequiredExplicitModel(input.model, input.availableModels, input.preferredProvider, input.thinking);
|
|
2131
2190
|
}
|
|
2132
2191
|
function buildModelCandidates(primaryModel, fallbackModels, availableModels, preferredProvider, options) {
|
|
2133
2192
|
let seen = /* @__PURE__ */ new Set(), candidates = [], rawCandidates = [primaryModel, ...fallbackModels ?? []];
|
|
@@ -2272,12 +2331,24 @@ function optionalCount(value) {
|
|
|
2272
2331
|
function isModelSelection(value) {
|
|
2273
2332
|
if (!value || typeof value != "object")
|
|
2274
2333
|
return !1;
|
|
2275
|
-
|
|
2334
|
+
let kind = value.kind;
|
|
2335
|
+
if (kind === "model")
|
|
2336
|
+
return !0;
|
|
2337
|
+
if (kind === "tier") {
|
|
2276
2338
|
let tier = value.tier;
|
|
2277
2339
|
return tier === "light" || tier === "standard" || tier === "heavy";
|
|
2278
2340
|
}
|
|
2279
2341
|
return !1;
|
|
2280
2342
|
}
|
|
2343
|
+
function parseThinking(value, pathLabel) {
|
|
2344
|
+
if (value !== void 0) {
|
|
2345
|
+
if (value === !1)
|
|
2346
|
+
return "off";
|
|
2347
|
+
if (typeof value == "string" && THINKING_LEVELS.includes(value))
|
|
2348
|
+
return value;
|
|
2349
|
+
throw new Error(`${pathLabel}.thinking must be one of ${THINKING_LEVELS.join(", ")}.`);
|
|
2350
|
+
}
|
|
2351
|
+
}
|
|
2281
2352
|
function normalizeChildSpec(input, options) {
|
|
2282
2353
|
let pathLabel = options.pathLabel ?? "task", description = validateChildDescription(input.description, `${pathLabel}.description`), task = typeof input.task == "string" && input.task.trim() ? input.task : options.defaultTask;
|
|
2283
2354
|
if (typeof task != "string" || !task.trim())
|
|
@@ -2285,21 +2356,40 @@ function normalizeChildSpec(input, options) {
|
|
|
2285
2356
|
let requested = parseChildPermissionsInput(input.permissions, `${pathLabel}.permissions`), resolved = resolveChildPermissions(options.parentMode, requested);
|
|
2286
2357
|
if (!resolved.ok)
|
|
2287
2358
|
throw new Error(resolved.error || PLAN_MODE_WRITE_SPAWN_ERROR);
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2359
|
+
let preservedSelection = isModelSelection(input.modelSelection) ? input.modelSelection : void 0, rawModel = optionalString(input.model);
|
|
2360
|
+
if (rawModel === INHERIT_MODEL)
|
|
2361
|
+
throw new Error(`${pathLabel}.model "inherit" is not supported; choose tier or an explicit provider/model.`);
|
|
2362
|
+
let modelSelection, tier, model, thinking;
|
|
2363
|
+
if (preservedSelection)
|
|
2364
|
+
if (modelSelection = preservedSelection, modelSelection.kind === "tier") {
|
|
2365
|
+
if (tier = modelSelection.tier, model = void 0, input.thinking !== void 0)
|
|
2366
|
+
throw new Error(`${pathLabel}.thinking is only valid with an explicit model selection.`);
|
|
2367
|
+
} else {
|
|
2368
|
+
if (model = rawModel ?? optionalString(modelSelection.model), !model)
|
|
2369
|
+
throw new Error(`${pathLabel}.model is required when modelSelection.kind is "model".`);
|
|
2370
|
+
modelSelection.model || (modelSelection = { kind: "model", model }), thinking = parseThinking(input.thinking, pathLabel);
|
|
2371
|
+
}
|
|
2372
|
+
else if (options.resolvedModelIsRuntime) {
|
|
2373
|
+
let selectedTier = input.tier === "light" || input.tier === "standard" || input.tier === "heavy" ? input.tier : void 0;
|
|
2374
|
+
if (!selectedTier)
|
|
2375
|
+
throw new Error(`${pathLabel}.tier is required to resume a child without a stored modelSelection.`);
|
|
2376
|
+
modelSelection = { kind: "tier", tier: selectedTier }, tier = selectedTier, model = void 0;
|
|
2377
|
+
} else if (modelSelection = captureModelSelection({ model: input.model, tier: input.tier }), modelSelection.kind === "tier") {
|
|
2378
|
+
if (tier = modelSelection.tier, model = void 0, input.thinking !== void 0)
|
|
2379
|
+
throw new Error(`${pathLabel}.thinking is only valid with an explicit model selection.`);
|
|
2380
|
+
} else
|
|
2381
|
+
model = rawModel, !modelSelection.model && model && (modelSelection = { kind: "model", model }), thinking = parseThinking(input.thinking, pathLabel);
|
|
2382
|
+
let outputMode = input.outputMode === "inline" || input.outputMode === "file-only" ? input.outputMode : void 0;
|
|
2294
2383
|
return {
|
|
2295
2384
|
childId: options.childId ?? allocateChildId(options.runId, options.index),
|
|
2296
2385
|
task,
|
|
2297
2386
|
description,
|
|
2298
2387
|
requestedPermissions: resolved.requested,
|
|
2299
2388
|
effectivePermissions: resolved.effective,
|
|
2300
|
-
model
|
|
2389
|
+
model,
|
|
2301
2390
|
tier,
|
|
2302
2391
|
modelSelection,
|
|
2392
|
+
thinking,
|
|
2303
2393
|
skill: optionalSkill(input.skill),
|
|
2304
2394
|
cwd: optionalString(input.cwd),
|
|
2305
2395
|
output: optionalOutput(input.output),
|
|
@@ -2330,9 +2420,6 @@ function formatActivityLabel(lastActivityAt, activityState, now = Date.now()) {
|
|
|
2330
2420
|
function isCompletedStepStatus(status) {
|
|
2331
2421
|
return status === "complete" || status === "completed";
|
|
2332
2422
|
}
|
|
2333
|
-
function aggregateStepStatus(steps) {
|
|
2334
|
-
return steps.some((step) => step.status === "running") ? "running" : steps.some((step) => step.status === "failed") ? "failed" : steps.some((step) => step.status === "stopped") ? "stopped" : steps.some((step) => step.status === "paused") ? "paused" : steps.length > 0 && steps.every((step) => isCompletedStepStatus(step.status)) ? "complete" : "pending";
|
|
2335
|
-
}
|
|
2336
2423
|
function formatAgentRunningLabel(count) {
|
|
2337
2424
|
return count === 1 ? "1 agent running" : `${count} agents running`;
|
|
2338
2425
|
}
|
|
@@ -2416,6 +2503,34 @@ function formatNestedRunStatusLines(children, options = {}) {
|
|
|
2416
2503
|
});
|
|
2417
2504
|
}
|
|
2418
2505
|
|
|
2506
|
+
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/foreground/request-params.js
|
|
2507
|
+
var LAUNCH_COMPATIBLE_ACTIONS = /* @__PURE__ */ new Set(["schedule", "append-step", "resume", "steer"]);
|
|
2508
|
+
function omitExecutionModeActionAlias(params) {
|
|
2509
|
+
let action = params.action?.toLowerCase();
|
|
2510
|
+
if (action === "single" && params.task !== void 0) {
|
|
2511
|
+
let rest = { ...params };
|
|
2512
|
+
return delete rest.action, rest;
|
|
2513
|
+
}
|
|
2514
|
+
if ((action === "parallel" || action === "tasks") && (params.tasks?.length ?? 0) > 0) {
|
|
2515
|
+
let rest = { ...params };
|
|
2516
|
+
return delete rest.action, rest;
|
|
2517
|
+
}
|
|
2518
|
+
return params;
|
|
2519
|
+
}
|
|
2520
|
+
function hasLaunchFields(params) {
|
|
2521
|
+
return params.task !== void 0 || Array.isArray(params.tasks) && params.tasks.length > 0 || Array.isArray(params.chain) && params.chain.length > 0;
|
|
2522
|
+
}
|
|
2523
|
+
function omitConflictingControlAction(params) {
|
|
2524
|
+
let action = params.action?.toLowerCase();
|
|
2525
|
+
if (!action || LAUNCH_COMPATIBLE_ACTIONS.has(action) || !hasLaunchFields(params))
|
|
2526
|
+
return params;
|
|
2527
|
+
let rest = { ...params };
|
|
2528
|
+
return delete rest.action, typeof rest.task == "string" && rest.task.length > 0 && (delete rest.tasks, delete rest.chain), rest;
|
|
2529
|
+
}
|
|
2530
|
+
function resolveSubagentRequestParams(params) {
|
|
2531
|
+
return omitConflictingControlAction(omitExecutionModeActionAlias(params));
|
|
2532
|
+
}
|
|
2533
|
+
|
|
2419
2534
|
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-control.js
|
|
2420
2535
|
var CONTROL_EVENT_TYPES = ["active_long_running", "needs_attention"], CONTROL_NOTIFICATION_CHANNELS = ["event", "async", "intercom"], DEFAULT_NOTIFY_ON = ["active_long_running", "needs_attention"], DEFAULT_CONTROL_CONFIG = {
|
|
2421
2536
|
enabled: !0,
|
|
@@ -3804,7 +3919,7 @@ var REVIEW_ONLY_PATTERNS = [
|
|
|
3804
3919
|
/\balways\s+(?:edit|modify|change|fix|patch|apply)\b/i,
|
|
3805
3920
|
/\bapply\s+(?:the\s+)?fix(?:es)?\s+directly\b/i,
|
|
3806
3921
|
/\bmake\s+(?:the\s+)?code\s+changes\b/i
|
|
3807
|
-
], NO_EDIT_PROHIBITION_PATTERN = /\b(?:do not|don't|must not)\s+(?:edit|modify|write(?:\s+to)?|touch|change)\b((?:(?!\b(?:but|and|then)\b)[^.;,:!?\n–—-])*)/gi, GENERIC_PROHIBITION_OBJECT = /^\s*(?:(?:any|all|the|these|those|your|our|existing|project|source|sources|repo|repository)[\s/,-]*)*(?:files?|code|codebase|sources?|anything|repo(?:sitory)?)?\s*$/i, SCOPED_NO_EDIT_CONSTRAINT_PATTERNS = [
|
|
3922
|
+
], NO_EDIT_PROHIBITION_PATTERN = /\b(?:do not|don't|must not)\s+(?:implement|edit|modify|write(?:\s+to)?|touch|change)\b((?:(?!\b(?:but|and|then)\b)[^.;,:!?\n–—-])*)/gi, GENERIC_PROHIBITION_OBJECT = /^\s*(?:(?:any|all|the|these|those|your|our|existing|project|source|sources|repo|repository)[\s/,-]*)*(?:files?|code|codebase|sources?|anything|repo(?:sitory)?)?\s*$/i, SCOPED_NO_EDIT_CONSTRAINT_PATTERNS = [
|
|
3808
3923
|
/\bdo not edit files?\s+outside\b/i,
|
|
3809
3924
|
/\bdo not edit\s+outside\b/i,
|
|
3810
3925
|
/\bdo not edit\s+unrelated files?\b/i,
|
|
@@ -3861,17 +3976,14 @@ function taskHasReadOnlyDeliverable(taskText) {
|
|
|
3861
3976
|
function hasImplementationIntent(taskText) {
|
|
3862
3977
|
return GENERAL_IMPLEMENTATION_PATTERNS.some((pattern) => pattern.test(taskText)) || WORKER_IMPLEMENTATION_PATTERNS.some((pattern) => pattern.test(taskText)) || REVIEWER_REQUIRED_EDIT_PATTERNS.some((pattern) => pattern.test(taskText));
|
|
3863
3978
|
}
|
|
3864
|
-
function
|
|
3865
|
-
|
|
3866
|
-
}
|
|
3867
|
-
function classifyTaskMutationIntent(permissionsOrLegacyName, task) {
|
|
3868
|
-
if (isReadOnlyPermission(permissionsOrLegacyName))
|
|
3979
|
+
function classifyTaskMutationIntent(permissions, task) {
|
|
3980
|
+
if (permissions === "read-only")
|
|
3869
3981
|
return { kind: "read-only" };
|
|
3870
3982
|
let taskText = stripFrameworkInstructions(task), taskTextWithoutScopedConstraints = stripPatterns(taskText, SCOPED_NO_EDIT_CONSTRAINT_PATTERNS), prohibitions = analyzeNoEditProhibitions(taskTextWithoutScopedConstraints);
|
|
3871
3983
|
return prohibitions.present ? prohibitions.blanket ? { kind: "read-only" } : hasImplementationIntent(prohibitions.strippedText) ? { kind: "implementation" } : { kind: "read-only" } : hasImplementationIntent(taskText) ? { kind: "implementation" } : RESEARCH_TASK_PATTERNS.some((pattern) => pattern.test(taskText)) && !hasImplementationIntent(taskText) ? { kind: "read-only" } : taskHasReadOnlyDeliverable(taskTextWithoutScopedConstraints) ? { kind: "read-only" } : { kind: "unknown" };
|
|
3872
3984
|
}
|
|
3873
|
-
function expectsImplementationMutation(
|
|
3874
|
-
return
|
|
3985
|
+
function expectsImplementationMutation(permissions, task) {
|
|
3986
|
+
return classifyTaskMutationIntent(permissions, task).kind === "implementation";
|
|
3875
3987
|
}
|
|
3876
3988
|
var MAY_MUTATE_VERB_PATTERN = /\b(?:fix|implement|update|write|edit|modify|migrate|delete|remove|refactor|commit)\b/i;
|
|
3877
3989
|
function taskMayMutate(task) {
|
|
@@ -3896,7 +4008,7 @@ var LEVEL_RANK = {
|
|
|
3896
4008
|
"diff-summary",
|
|
3897
4009
|
"review-findings",
|
|
3898
4010
|
"manual-notes"
|
|
3899
|
-
]), ACCEPTANCE_CONFIG_KEYS = /* @__PURE__ */ new Set(["level", "criteria", "evidence", "verify", "review", "stopRules", "reason"]), ACCEPTANCE_GATE_KEYS = /* @__PURE__ */ new Set(["id", "must", "evidence", "severity"]), ACCEPTANCE_VERIFY_KEYS = /* @__PURE__ */ new Set(["id", "command", "timeoutMs", "cwd", "env", "allowFailure"]), ACCEPTANCE_REVIEW_KEYS = /* @__PURE__ */ new Set(["agent", "focus", "required"]), EXPLICIT_REVIEWED_UNAVAILABLE = "cannot be requested explicitly because this run cannot supply an independent reviewer result; use checked/verified and orchestrate the reviewer separately, or omit acceptance for read-only review tasks.";
|
|
4011
|
+
]), ACCEPTANCE_CONFIG_KEYS = /* @__PURE__ */ new Set(["level", "criteria", "evidence", "verify", "review", "stopRules", "reason"]), PERSISTED_ACCEPTANCE_KEYS = /* @__PURE__ */ new Set([...ACCEPTANCE_CONFIG_KEYS, "explicit", "inferredReason"]), ACCEPTANCE_GATE_KEYS = /* @__PURE__ */ new Set(["id", "must", "evidence", "severity"]), ACCEPTANCE_VERIFY_KEYS = /* @__PURE__ */ new Set(["id", "command", "timeoutMs", "cwd", "env", "allowFailure"]), ACCEPTANCE_REVIEW_KEYS = /* @__PURE__ */ new Set(["agent", "focus", "required"]), EXPLICIT_REVIEWED_UNAVAILABLE = "cannot be requested explicitly because this run cannot supply an independent reviewer result; use checked/verified and orchestrate the reviewer separately, or omit acceptance for read-only review tasks.", RESOLVED_LEVELS = /* @__PURE__ */ new Set(["none", "attested", "checked", "verified", "reviewed"]);
|
|
3900
4012
|
function normalizeLevel(level) {
|
|
3901
4013
|
return level ?? "auto";
|
|
3902
4014
|
}
|
|
@@ -3946,18 +4058,25 @@ function normalizeAcceptanceInput(input) {
|
|
|
3946
4058
|
function explicitAcceptanceCanDisable(explicit) {
|
|
3947
4059
|
return explicit.level === "none" && typeof explicit.reason == "string" && explicit.reason.trim().length > 0;
|
|
3948
4060
|
}
|
|
3949
|
-
function
|
|
4061
|
+
function validateAcceptanceValue(input, pathLabel, mode) {
|
|
3950
4062
|
let errors = [];
|
|
3951
|
-
if (input === void 0
|
|
4063
|
+
if (input === void 0)
|
|
3952
4064
|
return errors;
|
|
3953
|
-
if (
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
4065
|
+
if (mode === "persisted") {
|
|
4066
|
+
if (!input || typeof input != "object" || Array.isArray(input))
|
|
4067
|
+
return errors.push(`${pathLabel} must be a resolved acceptance object.`), errors;
|
|
4068
|
+
} else {
|
|
4069
|
+
if (input === !1)
|
|
4070
|
+
return errors;
|
|
4071
|
+
if (typeof input == "string")
|
|
4072
|
+
return VALID_LEVELS.has(input) ? input === "none" ? errors.push(`${pathLabel} level "none" requires a reason; use { level: "none", reason: "..." }.`) : input === "reviewed" && errors.push(`${pathLabel} ${EXPLICIT_REVIEWED_UNAVAILABLE}`) : errors.push(`${pathLabel} has invalid level '${input}'.`), errors;
|
|
4073
|
+
if (!input || typeof input != "object" || Array.isArray(input))
|
|
4074
|
+
return errors.push(`${pathLabel} must be a string level, false, or an object.`), errors;
|
|
4075
|
+
}
|
|
4076
|
+
let value = input, allowedKeys = mode === "persisted" ? PERSISTED_ACCEPTANCE_KEYS : ACCEPTANCE_CONFIG_KEYS;
|
|
3958
4077
|
for (let key of Object.keys(value))
|
|
3959
|
-
|
|
3960
|
-
if (value.level !== void 0 && (typeof value.level != "string" || !VALID_LEVELS.has(value.level)) && errors.push(`${pathLabel}.level must be one of auto, none, attested, checked, verified, reviewed.`), value.level === "none" && (typeof value.reason != "string" || !value.reason.trim()) && errors.push(`${pathLabel}.reason is required when level is none.`), value.level === "reviewed" && errors.push(`${pathLabel}.level ${EXPLICIT_REVIEWED_UNAVAILABLE}`), value.reason !== void 0 && typeof value.reason != "string" && errors.push(`${pathLabel}.reason must be a string.`), value.criteria !== void 0 && !Array.isArray(value.criteria) && errors.push(`${pathLabel}.criteria must be an array.`), Array.isArray(value.criteria)) {
|
|
4078
|
+
allowedKeys.has(key) || errors.push(`${pathLabel}.${key} is not supported.`);
|
|
4079
|
+
if (mode === "persisted" ? (typeof value.level != "string" || !RESOLVED_LEVELS.has(value.level)) && errors.push(`${pathLabel}.level must be one of none, attested, checked, verified, reviewed.`) : value.level !== void 0 && (typeof value.level != "string" || !VALID_LEVELS.has(value.level)) && errors.push(`${pathLabel}.level must be one of auto, none, attested, checked, verified, reviewed.`), value.level === "none" && (typeof value.reason != "string" || !value.reason.trim()) && errors.push(`${pathLabel}.reason is required when level is none.`), mode === "launch" && value.level === "reviewed" && errors.push(`${pathLabel}.level ${EXPLICIT_REVIEWED_UNAVAILABLE}`), mode === "persisted" && (value.explicit !== void 0 && typeof value.explicit != "boolean" && errors.push(`${pathLabel}.explicit must be a boolean.`), value.inferredReason !== void 0 && (!Array.isArray(value.inferredReason) || value.inferredReason.some((item) => typeof item != "string")) && errors.push(`${pathLabel}.inferredReason must be an array of strings.`)), value.reason !== void 0 && typeof value.reason != "string" && errors.push(`${pathLabel}.reason must be a string.`), value.criteria !== void 0 && !Array.isArray(value.criteria) && errors.push(`${pathLabel}.criteria must be an array.`), Array.isArray(value.criteria)) {
|
|
3961
4080
|
let criterionIds = /* @__PURE__ */ new Set();
|
|
3962
4081
|
for (let [index, criterion] of value.criteria.entries()) {
|
|
3963
4082
|
if (typeof criterion == "string")
|
|
@@ -4017,6 +4136,29 @@ function validateAcceptanceInput(input, pathLabel = "acceptance") {
|
|
|
4017
4136
|
typeof item != "string" && errors.push(`${pathLabel}.stopRules[${index}] must be a string.`);
|
|
4018
4137
|
return errors;
|
|
4019
4138
|
}
|
|
4139
|
+
function validateAcceptanceInput(input, pathLabel = "acceptance") {
|
|
4140
|
+
return validateAcceptanceValue(input, pathLabel, "launch");
|
|
4141
|
+
}
|
|
4142
|
+
function validatePersistedAcceptance(input, pathLabel = "acceptance") {
|
|
4143
|
+
return validateAcceptanceValue(input, pathLabel, "persisted");
|
|
4144
|
+
}
|
|
4145
|
+
function restorePersistedAcceptance(input, pathLabel = "acceptance") {
|
|
4146
|
+
let errors = validatePersistedAcceptance(input, pathLabel);
|
|
4147
|
+
if (errors.length > 0)
|
|
4148
|
+
throw new Error(errors.join(" "));
|
|
4149
|
+
let value = input, evidence = Array.isArray(value.evidence) ? unique(value.evidence.filter((item) => VALID_EVIDENCE.has(item))) : [];
|
|
4150
|
+
return {
|
|
4151
|
+
level: value.level,
|
|
4152
|
+
explicit: value.explicit === !0,
|
|
4153
|
+
inferredReason: Array.isArray(value.inferredReason) ? value.inferredReason.filter((item) => typeof item == "string") : [],
|
|
4154
|
+
criteria: normalizeCriteria(value.criteria, evidence),
|
|
4155
|
+
evidence,
|
|
4156
|
+
verify: Array.isArray(value.verify) ? value.verify : [],
|
|
4157
|
+
review: value.review,
|
|
4158
|
+
stopRules: Array.isArray(value.stopRules) ? value.stopRules.filter((item) => typeof item == "string") : [],
|
|
4159
|
+
...typeof value.reason == "string" ? { reason: value.reason } : {}
|
|
4160
|
+
};
|
|
4161
|
+
}
|
|
4020
4162
|
function validateExecutionAcceptance(input) {
|
|
4021
4163
|
let errors = validateAcceptanceInput(input.acceptance, "acceptance");
|
|
4022
4164
|
for (let [index, task] of (input.tasks ?? []).entries())
|
|
@@ -4038,9 +4180,11 @@ function normalizeCriteria(criteria, evidence) {
|
|
|
4038
4180
|
}
|
|
4039
4181
|
function resolveEffectiveAcceptance(input) {
|
|
4040
4182
|
let explicit = normalizeAcceptanceInput(input.explicit), inferred = inferLevel(input), explicitLevel = normalizeLevel(explicit.level), level = explicitAcceptanceCanDisable(explicit) ? "none" : explicitLevel === "auto" ? inferred.level : LEVEL_RANK[explicitLevel] >= LEVEL_RANK[inferred.level] ? explicitLevel : inferred.level, evidence = unique([...level === inferred.level ? inferred.evidence : requiredEvidenceForLevel(level), ...explicit.evidence ?? []]), criteria = normalizeCriteria(explicit.criteria?.length ? explicit.criteria : inferred.criteria, evidence), review = explicit.review !== void 0 ? explicit.review : inferred.review;
|
|
4041
|
-
|
|
4183
|
+
level === "reviewed" && input.explicit !== void 0 && explicitLevel !== "reviewed" && explicit.review === void 0 && review && review !== !1 && (review = { ...review, required: !1 });
|
|
4184
|
+
let parentRequestedLevel = input.explicit === void 0 || explicitLevel === "auto" ? void 0 : explicitLevel;
|
|
4185
|
+
return {
|
|
4042
4186
|
level,
|
|
4043
|
-
explicit:
|
|
4187
|
+
explicit: parentRequestedLevel === level,
|
|
4044
4188
|
inferredReason: inferred.reasons,
|
|
4045
4189
|
criteria,
|
|
4046
4190
|
evidence,
|
|
@@ -4603,6 +4747,17 @@ function acceptanceFailureMessage(ledger) {
|
|
|
4603
4747
|
return failedVerify ? `Acceptance verification '${failedVerify.id}' ${failedVerify.status}.` : ledger.reviewResult?.status === "needs-parent-decision" ? "Acceptance review required but no automatic reviewer result is available." : ledger.reviewResult?.status === "blockers" ? "Acceptance review found blockers." : "Acceptance rejected.";
|
|
4604
4748
|
}
|
|
4605
4749
|
|
|
4750
|
+
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/background/top-level-async.js
|
|
4751
|
+
function normalizeAsyncLaunchConfig(config) {
|
|
4752
|
+
return { ...config, asyncByDefault: !0, forceTopLevelAsync: !1 };
|
|
4753
|
+
}
|
|
4754
|
+
function subagentLaunchRunsAsync(params) {
|
|
4755
|
+
return !(params.foregroundOnly === !0 || params.clarify === !0 || params.async === !1);
|
|
4756
|
+
}
|
|
4757
|
+
function isAsyncSubagentExecution(params) {
|
|
4758
|
+
return params.action || !params.task && !params.tasks?.length && !params.chain?.length ? !1 : subagentLaunchRunsAsync(params);
|
|
4759
|
+
}
|
|
4760
|
+
|
|
4606
4761
|
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/shared/turn-budget.js
|
|
4607
4762
|
function resolveTurnBudgetConfig(raw, label = "turnBudget") {
|
|
4608
4763
|
if (raw === void 0)
|
|
@@ -4663,132 +4818,36 @@ function shouldAbortForTurnBudget(budget, turnCount, terminalAssistantStop) {
|
|
|
4663
4818
|
return turnCount < hardLimit ? !1 : turnCount > hardLimit ? !0 : !terminalAssistantStop;
|
|
4664
4819
|
}
|
|
4665
4820
|
|
|
4666
|
-
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.js
|
|
4667
|
-
import * as fs14 from "node:fs";
|
|
4668
|
-
import * as os7 from "node:os";
|
|
4669
|
-
import * as path15 from "node:path";
|
|
4670
|
-
var NATIVE_INTERCOM_EXTENSION_DIR = "native:pi-subagents-supervisor-channel";
|
|
4671
|
-
function defaultAgentDir() {
|
|
4672
|
-
return getAgentDir();
|
|
4673
|
-
}
|
|
4674
|
-
function defaultSubagentConfigDir(agentDir = defaultAgentDir()) {
|
|
4675
|
-
return path15.join(agentDir, "extensions", "subagent");
|
|
4676
|
-
}
|
|
4677
|
-
var DEFAULT_INTERCOM_TARGET_PREFIX = "subagent-chat", INTERCOM_BRIDGE_MARKER = "Intercom orchestration channel:", DEFAULT_INTERCOM_BRIDGE_TEMPLATE = `The inherited thread is reference-only. Do not continue that conversation or send questions, status updates, or completion handoffs to the supervisor in normal assistant text.
|
|
4678
|
-
|
|
4679
|
-
Use contact_supervisor first. It resolves the supervisor session "{orchestratorTarget}" and run metadata automatically.
|
|
4680
|
-
- Need a decision, blocked, approval, or product/API/scope ambiguity: contact_supervisor({ reason: "need_decision", message: "<question>" })
|
|
4681
|
-
- Need structured supervisor input rather than a freeform reply: contact_supervisor({ reason: "interview_request", message: "<what input is needed>", interview: { title: "...", questions: [] } })
|
|
4682
|
-
- After contact_supervisor with reason "need_decision" or "interview_request", stay alive and continue only after the reply arrives. Do not finish your final response with a choose-one question.
|
|
4683
|
-
- Do not ask for clarification when the only conflict is review-only/no-edit versus progress-writing or artifact-writing instructions. If an output path is configured but no write-capable tool is available, return the complete artifact in your final response; the runtime will persist it. Do not contact the supervisor merely because you cannot write that output path directly.
|
|
4684
|
-
- Meaningful progress or unexpected discoveries that change the plan: contact_supervisor({ reason: "progress_update", message: "UPDATE: <summary>" })
|
|
4685
|
-
- Generic intercom is lower-level plumbing/fallback only: intercom({ action: "ask", to: "{orchestratorTarget}", message: "<question>" })
|
|
4686
|
-
|
|
4687
|
-
Do not use contact_supervisor or intercom for routine completion handoffs. If no coordination is needed, return a focused task result.`;
|
|
4688
|
-
function resolveIntercomSessionTarget(sessionName, sessionId) {
|
|
4689
|
-
let trimmedName = sessionName?.trim();
|
|
4690
|
-
if (trimmedName)
|
|
4691
|
-
return trimmedName;
|
|
4692
|
-
let normalizedSessionId = sessionId.startsWith("session-") ? sessionId.slice(8) : sessionId;
|
|
4693
|
-
return `${DEFAULT_INTERCOM_TARGET_PREFIX}-${normalizedSessionId.slice(0, 8)}`;
|
|
4694
|
-
}
|
|
4695
|
-
function sanitizeIntercomTargetPart(value) {
|
|
4696
|
-
return value.trim().toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "") || "agent";
|
|
4697
|
-
}
|
|
4698
|
-
function resolveSubagentIntercomTarget(runId, agent, index) {
|
|
4699
|
-
let stepSuffix = index !== void 0 ? `-${index + 1}` : "";
|
|
4700
|
-
return `subagent-${sanitizeIntercomTargetPart(agent)}-${sanitizeIntercomTargetPart(runId)}${stepSuffix}`;
|
|
4701
|
-
}
|
|
4702
|
-
function resolveIntercomBridgeMode(value) {
|
|
4703
|
-
return value === "off" || value === "always" || value === "fork-only" ? value : "always";
|
|
4704
|
-
}
|
|
4705
|
-
function resolveIntercomBridgeConfig(value) {
|
|
4706
|
-
return !value || typeof value != "object" || Array.isArray(value) ? { mode: "always", instructionFile: "" } : {
|
|
4707
|
-
mode: resolveIntercomBridgeMode(value.mode),
|
|
4708
|
-
instructionFile: typeof value.instructionFile == "string" ? value.instructionFile : ""
|
|
4709
|
-
};
|
|
4710
|
-
}
|
|
4711
|
-
function expandTilde(filePath) {
|
|
4712
|
-
return filePath.startsWith("~/") ? path15.join(os7.homedir(), filePath.slice(2)) : filePath;
|
|
4713
|
-
}
|
|
4714
|
-
function resolveInstructionTemplate(instructionFile, settingsDir) {
|
|
4715
|
-
if (!instructionFile)
|
|
4716
|
-
return DEFAULT_INTERCOM_BRIDGE_TEMPLATE;
|
|
4717
|
-
let expandedPath = expandTilde(instructionFile), resolvedPath = path15.isAbsolute(expandedPath) ? expandedPath : path15.resolve(settingsDir, expandedPath);
|
|
4718
|
-
try {
|
|
4719
|
-
return fs14.readFileSync(resolvedPath, "utf-8");
|
|
4720
|
-
} catch (error) {
|
|
4721
|
-
return console.warn(`Failed to read intercom bridge instructionFile at '${resolvedPath}'. Using default instructions.`, error), DEFAULT_INTERCOM_BRIDGE_TEMPLATE;
|
|
4722
|
-
}
|
|
4723
|
-
}
|
|
4724
|
-
function buildIntercomBridgeInstruction(orchestratorTarget, template) {
|
|
4725
|
-
let instruction = template.replaceAll("{orchestratorTarget}", orchestratorTarget).trim();
|
|
4726
|
-
return instruction.startsWith(INTERCOM_BRIDGE_MARKER) ? instruction : `${INTERCOM_BRIDGE_MARKER}
|
|
4727
|
-
${instruction}`;
|
|
4728
|
-
}
|
|
4729
|
-
function inactiveReason(mode, context, orchestratorTarget) {
|
|
4730
|
-
if (mode === "off")
|
|
4731
|
-
return "bridge mode is off";
|
|
4732
|
-
if (mode === "fork-only" && context !== "fork")
|
|
4733
|
-
return "bridge mode is fork-only and context is not fork";
|
|
4734
|
-
if (!orchestratorTarget)
|
|
4735
|
-
return "orchestrator target is not available";
|
|
4736
|
-
}
|
|
4737
|
-
function diagnoseIntercomBridge(input) {
|
|
4738
|
-
let mode = resolveIntercomBridgeConfig(input.config).mode, orchestratorTarget = input.orchestratorTarget?.trim(), wantsIntercom = mode !== "off" && !(mode === "fork-only" && input.context !== "fork"), reason = inactiveReason(mode, input.context, orchestratorTarget);
|
|
4739
|
-
return {
|
|
4740
|
-
active: reason === void 0,
|
|
4741
|
-
mode,
|
|
4742
|
-
wantsIntercom,
|
|
4743
|
-
supervisorChannelAvailable: !0,
|
|
4744
|
-
extensionDir: NATIVE_INTERCOM_EXTENSION_DIR,
|
|
4745
|
-
...orchestratorTarget ? { orchestratorTarget } : {},
|
|
4746
|
-
...reason ? { reason } : {}
|
|
4747
|
-
};
|
|
4748
|
-
}
|
|
4749
|
-
function resolveIntercomBridge(input) {
|
|
4750
|
-
let config = resolveIntercomBridgeConfig(input.config), mode = config.mode, orchestratorTarget = input.orchestratorTarget?.trim(), agentDir = path15.resolve(input.agentDir ?? defaultAgentDir()), settingsDir = path15.resolve(input.settingsDir ?? defaultSubagentConfigDir(agentDir)), defaultInstruction = buildIntercomBridgeInstruction(orchestratorTarget || "{orchestratorTarget}", DEFAULT_INTERCOM_BRIDGE_TEMPLATE);
|
|
4751
|
-
return inactiveReason(mode, input.context, orchestratorTarget) || !orchestratorTarget ? { active: !1, mode, extensionDir: NATIVE_INTERCOM_EXTENSION_DIR, instruction: defaultInstruction } : {
|
|
4752
|
-
active: !0,
|
|
4753
|
-
mode,
|
|
4754
|
-
orchestratorTarget,
|
|
4755
|
-
extensionDir: NATIVE_INTERCOM_EXTENSION_DIR,
|
|
4756
|
-
instruction: buildIntercomBridgeInstruction(orchestratorTarget, resolveInstructionTemplate(config.instructionFile, settingsDir))
|
|
4757
|
-
};
|
|
4758
|
-
}
|
|
4759
|
-
function applyIntercomBridgeToAgent(agent, bridge) {
|
|
4760
|
-
if (!bridge.active || !bridge.orchestratorTarget)
|
|
4761
|
-
return agent;
|
|
4762
|
-
let bridgeTools = ["intercom", "contact_supervisor"], tools = agent.tools ? [...agent.tools, ...bridgeTools.filter((tool) => !agent.tools?.includes(tool))] : agent.tools, instruction = bridge.instruction, trimmedPrompt = agent.systemPrompt?.trim() || "", systemPrompt = trimmedPrompt.includes(INTERCOM_BRIDGE_MARKER) ? trimmedPrompt : trimmedPrompt ? `${trimmedPrompt}
|
|
4763
|
-
|
|
4764
|
-
${instruction}` : instruction;
|
|
4765
|
-
return tools === agent.tools && systemPrompt === agent.systemPrompt ? agent : {
|
|
4766
|
-
...agent,
|
|
4767
|
-
tools,
|
|
4768
|
-
systemPrompt
|
|
4769
|
-
};
|
|
4770
|
-
}
|
|
4771
|
-
|
|
4772
4821
|
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/background/control-channel.js
|
|
4773
4822
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
4774
|
-
import * as
|
|
4775
|
-
import * as
|
|
4823
|
+
import * as fs14 from "node:fs";
|
|
4824
|
+
import * as path15 from "node:path";
|
|
4776
4825
|
var INTERRUPT_SIGNAL = process.platform === "win32" ? "SIGBREAK" : "SIGUSR2", STEER_REQUESTS_DIR = "steer-requests";
|
|
4777
|
-
var STEER_ACKS_DIR = "steer-acks", STEER_INBOX_CLOSED_FILE = "steer-inbox-closed.json", MAX_STEER_MESSAGE_BYTES = 128 * 1024, MAX_STEER_REQUEST_ID_LENGTH = 256;
|
|
4826
|
+
var STEER_CAPABILITIES_DIR = "steer-capabilities", STEER_ACKS_DIR = "steer-acks", STEER_INBOX_CLOSED_FILE = "steer-inbox-closed.json", MAX_STEER_MESSAGE_BYTES = 128 * 1024, MAX_STEER_REQUEST_ID_LENGTH = 256;
|
|
4778
4827
|
function controlInboxDir(asyncDir) {
|
|
4779
|
-
return
|
|
4828
|
+
return path15.join(asyncDir, "control");
|
|
4780
4829
|
}
|
|
4781
4830
|
function interruptRequestPath(asyncDir) {
|
|
4782
|
-
return
|
|
4831
|
+
return path15.join(controlInboxDir(asyncDir), "interrupt.json");
|
|
4783
4832
|
}
|
|
4784
4833
|
function stopRequestPath(asyncDir) {
|
|
4785
|
-
return
|
|
4834
|
+
return path15.join(controlInboxDir(asyncDir), "stop.json");
|
|
4786
4835
|
}
|
|
4787
4836
|
function steerRequestsDir(asyncDir) {
|
|
4788
|
-
return
|
|
4837
|
+
return path15.join(controlInboxDir(asyncDir), STEER_REQUESTS_DIR);
|
|
4789
4838
|
}
|
|
4790
4839
|
function steerInboxClosedPath(asyncDir) {
|
|
4791
|
-
return
|
|
4840
|
+
return path15.join(controlInboxDir(asyncDir), STEER_INBOX_CLOSED_FILE);
|
|
4841
|
+
}
|
|
4842
|
+
function steerCapabilitiesDir(asyncDir) {
|
|
4843
|
+
return path15.join(controlInboxDir(asyncDir), STEER_CAPABILITIES_DIR);
|
|
4844
|
+
}
|
|
4845
|
+
function steerCapabilityPath(asyncDir, index) {
|
|
4846
|
+
return assertChildIndex(index), path15.join(steerCapabilitiesDir(asyncDir), `${index}.json`);
|
|
4847
|
+
}
|
|
4848
|
+
function assertChildIndex(index) {
|
|
4849
|
+
if (!Number.isInteger(index) || index < 0 || index > 1e6)
|
|
4850
|
+
throw new Error("steer child index must be a non-negative integer.");
|
|
4792
4851
|
}
|
|
4793
4852
|
function steerRequestFileName(request) {
|
|
4794
4853
|
return `${String(request.ts).padStart(13, "0")}-${Buffer.from(request.id).toString("base64url")}.json`;
|
|
@@ -4799,7 +4858,7 @@ function validSteerRequest(request) {
|
|
|
4799
4858
|
function writeSteerRequestToDir(dir, request) {
|
|
4800
4859
|
if (!validSteerRequest(request))
|
|
4801
4860
|
throw new Error("steer request is malformed or exceeds transport limits.");
|
|
4802
|
-
let requestPath =
|
|
4861
|
+
let requestPath = path15.join(dir, steerRequestFileName(request));
|
|
4803
4862
|
return writeAtomicJson(requestPath, request), requestPath;
|
|
4804
4863
|
}
|
|
4805
4864
|
function requestAsyncInterrupt(asyncDir, payload = {}, deps = {}) {
|
|
@@ -4821,7 +4880,7 @@ function requestAsyncSteer(asyncDir, payload, deps = {}) {
|
|
|
4821
4880
|
if (payload.targetIndexes !== void 0 && (!Array.isArray(payload.targetIndexes) || payload.targetIndex !== void 0 || payload.targetIndexes.length === 0 || payload.targetIndexes.length > 1e3 || payload.targetIndexes.some((index) => !Number.isInteger(index) || index < 0 || index > 1e6) || new Set(payload.targetIndexes).size !== payload.targetIndexes.length))
|
|
4822
4881
|
throw new Error("steer targetIndexes must contain 1-1000 unique non-negative integers and cannot be combined with targetIndex.");
|
|
4823
4882
|
let closedPath = steerInboxClosedPath(asyncDir);
|
|
4824
|
-
if (
|
|
4883
|
+
if (fs14.existsSync(closedPath))
|
|
4825
4884
|
throw new Error("Async run no longer accepts steering requests.");
|
|
4826
4885
|
let request = {
|
|
4827
4886
|
type: "steer",
|
|
@@ -4832,10 +4891,17 @@ function requestAsyncSteer(asyncDir, payload, deps = {}) {
|
|
|
4832
4891
|
...payload.targetIndexes !== void 0 ? { targetIndexes: [...payload.targetIndexes] } : {},
|
|
4833
4892
|
...payload.source ? { source: payload.source } : {}
|
|
4834
4893
|
}, requestPath = writeSteerRequestToDir(steerRequestsDir(asyncDir), request);
|
|
4835
|
-
if (
|
|
4836
|
-
throw
|
|
4894
|
+
if (fs14.existsSync(closedPath))
|
|
4895
|
+
throw fs14.rmSync(requestPath, { force: !0 }), new Error("Async run stopped accepting steering before the request was committed.");
|
|
4837
4896
|
return requestPath;
|
|
4838
4897
|
}
|
|
4898
|
+
function parseSteerCapability(raw) {
|
|
4899
|
+
if (!raw || typeof raw != "object" || Array.isArray(raw))
|
|
4900
|
+
return;
|
|
4901
|
+
let input = raw;
|
|
4902
|
+
if (!(input.type !== "steer-capability" || input.protocolVersion !== 1) && !(!Number.isInteger(input.index) || input.index < 0 || input.index > 1e6) && !(!Number.isInteger(input.pid) || input.pid <= 0 || !Number.isFinite(input.readyAt) || input.readyAt <= 0 || typeof input.supported != "boolean"))
|
|
4903
|
+
return { type: "steer-capability", protocolVersion: 1, index: input.index, pid: input.pid, readyAt: input.readyAt, supported: input.supported };
|
|
4904
|
+
}
|
|
4839
4905
|
function parseSteerAck(raw) {
|
|
4840
4906
|
if (!raw || typeof raw != "object" || Array.isArray(raw))
|
|
4841
4907
|
return;
|
|
@@ -4843,8 +4909,15 @@ function parseSteerAck(raw) {
|
|
|
4843
4909
|
if (!(input.type !== "steer-ack" || input.protocolVersion !== 1 || typeof input.requestId != "string" || !/^[^\s]+$/.test(input.requestId) || input.requestId.length > 256) && !(!Number.isInteger(input.index) || input.index < 0 || input.index > 1e6 || !Number.isFinite(input.ts) || input.ts <= 0) && !(input.state !== "delivered" && input.state !== "failed") && !(typeof input.message != "string" || !input.message.trim() || input.message.length > 1e3))
|
|
4844
4910
|
return { type: "steer-ack", protocolVersion: 1, requestId: input.requestId, index: input.index, ts: input.ts, state: input.state, message: input.message.trim() };
|
|
4845
4911
|
}
|
|
4846
|
-
function
|
|
4847
|
-
|
|
4912
|
+
function readSteerCapability(asyncDir, index) {
|
|
4913
|
+
try {
|
|
4914
|
+
return parseSteerCapability(JSON.parse(fs14.readFileSync(steerCapabilityPath(asyncDir, index), "utf-8")));
|
|
4915
|
+
} catch {
|
|
4916
|
+
return;
|
|
4917
|
+
}
|
|
4918
|
+
}
|
|
4919
|
+
function consumeSteerAcks(asyncDir, fsImpl = fs14) {
|
|
4920
|
+
let root = path15.join(controlInboxDir(asyncDir), STEER_ACKS_DIR);
|
|
4848
4921
|
if (!fsImpl.existsSync(root))
|
|
4849
4922
|
return [];
|
|
4850
4923
|
let acks = [], indexNames;
|
|
@@ -4854,14 +4927,14 @@ function consumeSteerAcks(asyncDir, fsImpl = fs15) {
|
|
|
4854
4927
|
return [];
|
|
4855
4928
|
}
|
|
4856
4929
|
for (let indexName of indexNames) {
|
|
4857
|
-
let dir =
|
|
4930
|
+
let dir = path15.join(root, indexName), entries;
|
|
4858
4931
|
try {
|
|
4859
4932
|
entries = fsImpl.readdirSync(dir).filter((name) => name.endsWith(".json")).sort();
|
|
4860
4933
|
} catch {
|
|
4861
4934
|
continue;
|
|
4862
4935
|
}
|
|
4863
4936
|
for (let entry of entries) {
|
|
4864
|
-
let target =
|
|
4937
|
+
let target = path15.join(dir, entry), ack;
|
|
4865
4938
|
try {
|
|
4866
4939
|
ack = parseSteerAck(JSON.parse(fsImpl.readFileSync(target, "utf-8")));
|
|
4867
4940
|
} catch {
|
|
@@ -4886,7 +4959,7 @@ function deliverInterruptRequest(input) {
|
|
|
4886
4959
|
if (error?.code === "ENOSYS")
|
|
4887
4960
|
return;
|
|
4888
4961
|
try {
|
|
4889
|
-
|
|
4962
|
+
fs14.rmSync(requestPath, { force: !0 });
|
|
4890
4963
|
} catch {
|
|
4891
4964
|
}
|
|
4892
4965
|
throw error;
|
|
@@ -4896,6 +4969,112 @@ function deliverStopRequest(input) {
|
|
|
4896
4969
|
requestAsyncStop(input.asyncDir, input.source ? { source: input.source } : {}, { now: input.now });
|
|
4897
4970
|
}
|
|
4898
4971
|
|
|
4972
|
+
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.js
|
|
4973
|
+
import * as fs15 from "node:fs";
|
|
4974
|
+
import * as os7 from "node:os";
|
|
4975
|
+
import * as path16 from "node:path";
|
|
4976
|
+
var NATIVE_INTERCOM_EXTENSION_DIR = "native:pi-subagents-supervisor-channel";
|
|
4977
|
+
function defaultAgentDir() {
|
|
4978
|
+
return getAgentDir();
|
|
4979
|
+
}
|
|
4980
|
+
function defaultSubagentConfigDir(agentDir = defaultAgentDir()) {
|
|
4981
|
+
return path16.join(agentDir, "extensions", "subagent");
|
|
4982
|
+
}
|
|
4983
|
+
var DEFAULT_INTERCOM_TARGET_PREFIX = "subagent-chat", INTERCOM_BRIDGE_MARKER = "Intercom orchestration channel:", DEFAULT_INTERCOM_BRIDGE_TEMPLATE = `The inherited thread is reference-only. Do not continue that conversation or send questions, status updates, or completion handoffs to the supervisor in normal assistant text.
|
|
4984
|
+
|
|
4985
|
+
Use contact_supervisor first. It resolves the supervisor session "{orchestratorTarget}" and run metadata automatically.
|
|
4986
|
+
- Need a decision, blocked, approval, or product/API/scope ambiguity: contact_supervisor({ reason: "need_decision", message: "<question>" })
|
|
4987
|
+
- Need structured supervisor input rather than a freeform reply: contact_supervisor({ reason: "interview_request", message: "<what input is needed>", interview: { title: "...", questions: [] } })
|
|
4988
|
+
- After contact_supervisor with reason "need_decision" or "interview_request", stay alive and continue only after the reply arrives. Do not finish your final response with a choose-one question.
|
|
4989
|
+
- Do not ask for clarification when the only conflict is review-only/no-edit versus progress-writing or artifact-writing instructions. If an output path is configured but no write-capable tool is available, return the complete artifact in your final response; the runtime will persist it. Do not contact the supervisor merely because you cannot write that output path directly.
|
|
4990
|
+
- Meaningful progress or unexpected discoveries that change the plan: contact_supervisor({ reason: "progress_update", message: "UPDATE: <summary>" })
|
|
4991
|
+
- Generic intercom is lower-level plumbing/fallback only: intercom({ action: "ask", to: "{orchestratorTarget}", message: "<question>" })
|
|
4992
|
+
|
|
4993
|
+
Do not use contact_supervisor or intercom for routine completion handoffs. If no coordination is needed, return a focused task result.`;
|
|
4994
|
+
function resolveIntercomSessionTarget(sessionName, sessionId) {
|
|
4995
|
+
let trimmedName = sessionName?.trim();
|
|
4996
|
+
if (trimmedName)
|
|
4997
|
+
return trimmedName;
|
|
4998
|
+
let normalizedSessionId = sessionId.startsWith("session-") ? sessionId.slice(8) : sessionId;
|
|
4999
|
+
return `${DEFAULT_INTERCOM_TARGET_PREFIX}-${normalizedSessionId.slice(0, 8)}`;
|
|
5000
|
+
}
|
|
5001
|
+
function sanitizeIntercomTargetPart(value) {
|
|
5002
|
+
return value.trim().toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "") || "agent";
|
|
5003
|
+
}
|
|
5004
|
+
function resolveSubagentIntercomTarget(runId, agent, index) {
|
|
5005
|
+
let stepSuffix = index !== void 0 ? `-${index + 1}` : "";
|
|
5006
|
+
return `subagent-${sanitizeIntercomTargetPart(agent)}-${sanitizeIntercomTargetPart(runId)}${stepSuffix}`;
|
|
5007
|
+
}
|
|
5008
|
+
function resolveIntercomBridgeMode(value) {
|
|
5009
|
+
return value === "off" || value === "always" || value === "fork-only" ? value : "always";
|
|
5010
|
+
}
|
|
5011
|
+
function resolveIntercomBridgeConfig(value) {
|
|
5012
|
+
return !value || typeof value != "object" || Array.isArray(value) ? { mode: "always", instructionFile: "" } : {
|
|
5013
|
+
mode: resolveIntercomBridgeMode(value.mode),
|
|
5014
|
+
instructionFile: typeof value.instructionFile == "string" ? value.instructionFile : ""
|
|
5015
|
+
};
|
|
5016
|
+
}
|
|
5017
|
+
function expandTilde(filePath) {
|
|
5018
|
+
return filePath.startsWith("~/") ? path16.join(os7.homedir(), filePath.slice(2)) : filePath;
|
|
5019
|
+
}
|
|
5020
|
+
function resolveInstructionTemplate(instructionFile, settingsDir) {
|
|
5021
|
+
if (!instructionFile)
|
|
5022
|
+
return DEFAULT_INTERCOM_BRIDGE_TEMPLATE;
|
|
5023
|
+
let expandedPath = expandTilde(instructionFile), resolvedPath = path16.isAbsolute(expandedPath) ? expandedPath : path16.resolve(settingsDir, expandedPath);
|
|
5024
|
+
try {
|
|
5025
|
+
return fs15.readFileSync(resolvedPath, "utf-8");
|
|
5026
|
+
} catch (error) {
|
|
5027
|
+
return console.warn(`Failed to read intercom bridge instructionFile at '${resolvedPath}'. Using default instructions.`, error), DEFAULT_INTERCOM_BRIDGE_TEMPLATE;
|
|
5028
|
+
}
|
|
5029
|
+
}
|
|
5030
|
+
function buildIntercomBridgeInstruction(orchestratorTarget, template) {
|
|
5031
|
+
let instruction = template.replaceAll("{orchestratorTarget}", orchestratorTarget).trim();
|
|
5032
|
+
return instruction.startsWith(INTERCOM_BRIDGE_MARKER) ? instruction : `${INTERCOM_BRIDGE_MARKER}
|
|
5033
|
+
${instruction}`;
|
|
5034
|
+
}
|
|
5035
|
+
function inactiveReason(mode, context, orchestratorTarget) {
|
|
5036
|
+
if (mode === "off")
|
|
5037
|
+
return "bridge mode is off";
|
|
5038
|
+
if (mode === "fork-only" && context !== "fork")
|
|
5039
|
+
return "bridge mode is fork-only and context is not fork";
|
|
5040
|
+
if (!orchestratorTarget)
|
|
5041
|
+
return "orchestrator target is not available";
|
|
5042
|
+
}
|
|
5043
|
+
function diagnoseIntercomBridge(input) {
|
|
5044
|
+
let mode = resolveIntercomBridgeConfig(input.config).mode, orchestratorTarget = input.orchestratorTarget?.trim(), wantsIntercom = mode !== "off" && !(mode === "fork-only" && input.context !== "fork"), reason = inactiveReason(mode, input.context, orchestratorTarget);
|
|
5045
|
+
return {
|
|
5046
|
+
active: reason === void 0,
|
|
5047
|
+
mode,
|
|
5048
|
+
wantsIntercom,
|
|
5049
|
+
supervisorChannelAvailable: !0,
|
|
5050
|
+
extensionDir: NATIVE_INTERCOM_EXTENSION_DIR,
|
|
5051
|
+
...orchestratorTarget ? { orchestratorTarget } : {},
|
|
5052
|
+
...reason ? { reason } : {}
|
|
5053
|
+
};
|
|
5054
|
+
}
|
|
5055
|
+
function resolveIntercomBridge(input) {
|
|
5056
|
+
let config = resolveIntercomBridgeConfig(input.config), mode = config.mode, orchestratorTarget = input.orchestratorTarget?.trim(), agentDir = path16.resolve(input.agentDir ?? defaultAgentDir()), settingsDir = path16.resolve(input.settingsDir ?? defaultSubagentConfigDir(agentDir)), defaultInstruction = buildIntercomBridgeInstruction(orchestratorTarget || "{orchestratorTarget}", DEFAULT_INTERCOM_BRIDGE_TEMPLATE);
|
|
5057
|
+
return inactiveReason(mode, input.context, orchestratorTarget) || !orchestratorTarget ? { active: !1, mode, extensionDir: NATIVE_INTERCOM_EXTENSION_DIR, instruction: defaultInstruction } : {
|
|
5058
|
+
active: !0,
|
|
5059
|
+
mode,
|
|
5060
|
+
orchestratorTarget,
|
|
5061
|
+
extensionDir: NATIVE_INTERCOM_EXTENSION_DIR,
|
|
5062
|
+
instruction: buildIntercomBridgeInstruction(orchestratorTarget, resolveInstructionTemplate(config.instructionFile, settingsDir))
|
|
5063
|
+
};
|
|
5064
|
+
}
|
|
5065
|
+
function applyIntercomBridgeToAgent(agent, bridge) {
|
|
5066
|
+
if (!bridge.active || !bridge.orchestratorTarget)
|
|
5067
|
+
return agent;
|
|
5068
|
+
let bridgeTools = ["intercom", "contact_supervisor"], tools = agent.tools ? [...agent.tools, ...bridgeTools.filter((tool) => !agent.tools?.includes(tool))] : agent.tools, instruction = bridge.instruction, trimmedPrompt = agent.systemPrompt?.trim() || "", systemPrompt = trimmedPrompt.includes(INTERCOM_BRIDGE_MARKER) ? trimmedPrompt : trimmedPrompt ? `${trimmedPrompt}
|
|
5069
|
+
|
|
5070
|
+
${instruction}` : instruction;
|
|
5071
|
+
return tools === agent.tools && systemPrompt === agent.systemPrompt ? agent : {
|
|
5072
|
+
...agent,
|
|
5073
|
+
tools,
|
|
5074
|
+
systemPrompt
|
|
5075
|
+
};
|
|
5076
|
+
}
|
|
5077
|
+
|
|
4899
5078
|
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/background/async-resume.js
|
|
4900
5079
|
import * as fs16 from "node:fs";
|
|
4901
5080
|
import * as path17 from "node:path";
|
|
@@ -4926,6 +5105,15 @@ function interruptLiveAsyncResumeTarget(input) {
|
|
|
4926
5105
|
function getErrorMessage3(error) {
|
|
4927
5106
|
return error instanceof Error ? error.message : String(error);
|
|
4928
5107
|
}
|
|
5108
|
+
var TURN_BUDGET_RUNTIME_KEYS = /* @__PURE__ */ new Set(["outcome", "turnCount", "wrapUpRequestedAtTurn", "exceededAtTurn"]);
|
|
5109
|
+
function persistedTurnBudgetConfig(raw) {
|
|
5110
|
+
if (!raw || typeof raw != "object" || Array.isArray(raw))
|
|
5111
|
+
return raw;
|
|
5112
|
+
let config = {};
|
|
5113
|
+
for (let [key, value] of Object.entries(raw))
|
|
5114
|
+
TURN_BUDGET_RUNTIME_KEYS.has(key) || (config[key] = value);
|
|
5115
|
+
return config;
|
|
5116
|
+
}
|
|
4929
5117
|
function ensureObject(value, source) {
|
|
4930
5118
|
if (!value || typeof value != "object" || Array.isArray(value))
|
|
4931
5119
|
throw new Error(`Async result file '${source}' must contain a JSON object.`);
|
|
@@ -5149,7 +5337,7 @@ function readAsyncRecoveryDescriptor(asyncDir) {
|
|
|
5149
5337
|
throw new Error(`Invalid async recovery descriptor '${descriptorPath}': ${field} must be a non-empty string.`);
|
|
5150
5338
|
if (parsed.permissions !== "full" && parsed.permissions !== "read-only")
|
|
5151
5339
|
throw new Error(`Invalid async recovery descriptor '${descriptorPath}': permissions must be full or read-only.`);
|
|
5152
|
-
if (parsed.tier !== "light" && parsed.tier !== "standard" && parsed.tier !== "heavy")
|
|
5340
|
+
if (parsed.tier !== void 0 && parsed.tier !== "light" && parsed.tier !== "standard" && parsed.tier !== "heavy")
|
|
5153
5341
|
throw new Error(`Invalid async recovery descriptor '${descriptorPath}': tier must be light, standard, or heavy.`);
|
|
5154
5342
|
if (validateChildDescription(parsed.description, `Async recovery descriptor '${descriptorPath}' description`), parsed.outputMode !== "inline" && parsed.outputMode !== "file-only")
|
|
5155
5343
|
throw new Error(`Invalid async recovery descriptor '${descriptorPath}': outputMode is invalid.`);
|
|
@@ -5170,17 +5358,23 @@ function readAsyncRecoveryDescriptor(asyncDir) {
|
|
|
5170
5358
|
let selection = parsed.modelSelection;
|
|
5171
5359
|
if (!selection || typeof selection != "object")
|
|
5172
5360
|
throw new Error(`Invalid async recovery descriptor '${descriptorPath}': modelSelection must be an object.`);
|
|
5173
|
-
if (selection.kind
|
|
5361
|
+
if (selection.kind === "tier") {
|
|
5362
|
+
if (selection.tier !== "light" && selection.tier !== "standard" && selection.tier !== "heavy")
|
|
5363
|
+
throw new Error(`Invalid async recovery descriptor '${descriptorPath}': modelSelection.tier is invalid.`);
|
|
5364
|
+
} else if (selection.kind === "model") {
|
|
5365
|
+
if (selection.model !== void 0 && (typeof selection.model != "string" || !selection.model.trim()))
|
|
5366
|
+
throw new Error(`Invalid async recovery descriptor '${descriptorPath}': modelSelection.model must be a non-empty string.`);
|
|
5367
|
+
} else
|
|
5174
5368
|
throw new Error(`Invalid async recovery descriptor '${descriptorPath}': modelSelection.kind is invalid.`);
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
}
|
|
5369
|
+
} else if (parsed.tier === void 0)
|
|
5370
|
+
throw new Error(`Invalid async recovery descriptor '${descriptorPath}': tier or modelSelection is required.`);
|
|
5178
5371
|
if (parsed.absoluteDeadlineAt !== void 0 && (!Number.isFinite(parsed.absoluteDeadlineAt) || parsed.absoluteDeadlineAt <= 0))
|
|
5179
5372
|
throw new Error(`Invalid async recovery descriptor '${descriptorPath}': absoluteDeadlineAt must be a positive timestamp.`);
|
|
5180
5373
|
if (parsed.initialTurnBudget !== void 0) {
|
|
5181
|
-
let result = resolveTurnBudgetConfig(parsed.initialTurnBudget, "recoveryDescriptor.initialTurnBudget");
|
|
5374
|
+
let result = resolveTurnBudgetConfig(persistedTurnBudgetConfig(parsed.initialTurnBudget), "recoveryDescriptor.initialTurnBudget");
|
|
5182
5375
|
if (result.error)
|
|
5183
5376
|
throw new Error(`Invalid async recovery descriptor '${descriptorPath}': ${result.error}`);
|
|
5377
|
+
result.turnBudget && (parsed.initialTurnBudget = result.turnBudget);
|
|
5184
5378
|
}
|
|
5185
5379
|
if (parsed.initialToolBudget !== void 0) {
|
|
5186
5380
|
let result = validateToolBudgetConfig(parsed.initialToolBudget, "recoveryDescriptor.initialToolBudget");
|
|
@@ -5226,7 +5420,7 @@ function readAsyncRecoveryDescriptor(asyncDir) {
|
|
|
5226
5420
|
throw new Error(`Invalid async recovery descriptor '${descriptorPath}': controlConfig.notifyChannels is invalid.`);
|
|
5227
5421
|
}
|
|
5228
5422
|
if (parsed.acceptance !== void 0) {
|
|
5229
|
-
let errors =
|
|
5423
|
+
let errors = validatePersistedAcceptance(parsed.acceptance, "recoveryDescriptor.acceptance");
|
|
5230
5424
|
if (errors.length)
|
|
5231
5425
|
throw new Error(`Invalid async recovery descriptor '${descriptorPath}': ${errors.join(" ")}`);
|
|
5232
5426
|
}
|
|
@@ -5279,6 +5473,7 @@ function resolveAsyncResumeTarget(params, deps = {}, options = {}) {
|
|
|
5279
5473
|
sessionFile: selectedStep.sessionFile ?? status?.sessionFile ?? result?.sessionFile,
|
|
5280
5474
|
model: selectedStep.model,
|
|
5281
5475
|
thinking: selectedStep.thinking,
|
|
5476
|
+
modelSelection: selectedStep.modelSelection,
|
|
5282
5477
|
...recoveryDescriptor ? { recoveryDescriptor } : {}
|
|
5283
5478
|
};
|
|
5284
5479
|
if (selectedStep?.status === "pending")
|
|
@@ -5304,6 +5499,7 @@ function resolveAsyncResumeTarget(params, deps = {}, options = {}) {
|
|
|
5304
5499
|
sessionFile: selected.step.sessionFile ?? status?.sessionFile ?? result?.sessionFile,
|
|
5305
5500
|
model: selected.step.model,
|
|
5306
5501
|
thinking: selected.step.thinking,
|
|
5502
|
+
modelSelection: selected.step.modelSelection,
|
|
5307
5503
|
...recoveryDescriptor ? { recoveryDescriptor } : {}
|
|
5308
5504
|
};
|
|
5309
5505
|
}
|
|
@@ -5336,6 +5532,7 @@ function resolveAsyncResumeTarget(params, deps = {}, options = {}) {
|
|
|
5336
5532
|
intercomTarget: resolveSubagentIntercomTarget(runId, childId ?? agent, index),
|
|
5337
5533
|
cwd: status?.cwd ?? result?.cwd,
|
|
5338
5534
|
...resolvedSessionFile ? { sessionFile: resolvedSessionFile } : {},
|
|
5535
|
+
modelSelection: statusSteps[index]?.modelSelection,
|
|
5339
5536
|
...stepModel ? { model: stepModel } : {},
|
|
5340
5537
|
...stepThinking ? { thinking: stepThinking } : {},
|
|
5341
5538
|
...recoveryDescriptor ? { recoveryDescriptor } : {}
|
|
@@ -5357,6 +5554,76 @@ function buildRevivedAsyncTask(target, message) {
|
|
|
5357
5554
|
`);
|
|
5358
5555
|
}
|
|
5359
5556
|
|
|
5557
|
+
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/background/run-id-resolver.js
|
|
5558
|
+
import * as fs17 from "node:fs";
|
|
5559
|
+
import * as path18 from "node:path";
|
|
5560
|
+
function exactAsyncLocation(id, asyncDirRoot, resultsDir) {
|
|
5561
|
+
let asyncDir = path18.join(asyncDirRoot, id), resultPath = path18.join(resultsDir, `${id}.json`);
|
|
5562
|
+
if (!(!fs17.existsSync(asyncDir) && !fs17.existsSync(resultPath)))
|
|
5563
|
+
return {
|
|
5564
|
+
asyncDir: fs17.existsSync(asyncDir) ? asyncDir : null,
|
|
5565
|
+
resultPath: fs17.existsSync(resultPath) ? resultPath : null,
|
|
5566
|
+
resolvedId: id
|
|
5567
|
+
};
|
|
5568
|
+
}
|
|
5569
|
+
function foregroundIds(state) {
|
|
5570
|
+
if (!state)
|
|
5571
|
+
return [];
|
|
5572
|
+
let remembered = state.currentSessionId ? [...state.foregroundRuns?.values() ?? []].filter((run) => run.sessionId === state.currentSessionId).map((run) => run.runId) : [];
|
|
5573
|
+
return [.../* @__PURE__ */ new Set([...state.foregroundControls.keys(), ...remembered])];
|
|
5574
|
+
}
|
|
5575
|
+
function hasExactForegroundId(state, id) {
|
|
5576
|
+
if (!state)
|
|
5577
|
+
return !1;
|
|
5578
|
+
if (state.foregroundControls.has(id))
|
|
5579
|
+
return !0;
|
|
5580
|
+
let remembered = state.foregroundRuns?.get(id);
|
|
5581
|
+
return !!(remembered && state.currentSessionId && remembered.sessionId === state.currentSessionId);
|
|
5582
|
+
}
|
|
5583
|
+
function nestedScopeFromState(state) {
|
|
5584
|
+
if (!state)
|
|
5585
|
+
return;
|
|
5586
|
+
let routes = [], seen = /* @__PURE__ */ new Set(), add = (route) => {
|
|
5587
|
+
if (!route)
|
|
5588
|
+
return;
|
|
5589
|
+
let key = `${route.rootRunId}:${route.eventSink}:${route.controlInbox}`;
|
|
5590
|
+
seen.has(key) || (seen.add(key), routes.push(route));
|
|
5591
|
+
};
|
|
5592
|
+
for (let control of state.foregroundControls.values())
|
|
5593
|
+
add(control.nestedRoute);
|
|
5594
|
+
for (let job of state.asyncJobs.values())
|
|
5595
|
+
add(job.nestedRoute);
|
|
5596
|
+
return { routes };
|
|
5597
|
+
}
|
|
5598
|
+
function asyncPrefixMatches(prefix, asyncDirRoot, resultsDir) {
|
|
5599
|
+
return findAsyncRunPrefixMatches(prefix, asyncDirRoot, resultsDir);
|
|
5600
|
+
}
|
|
5601
|
+
function resolveSubagentRunId(id, deps = {}) {
|
|
5602
|
+
assertSafeNestedId("id", id);
|
|
5603
|
+
let asyncDirRoot = deps.asyncDirRoot ?? ASYNC_DIR, resultsDir = deps.resultsDir ?? RESULTS_DIR, nestedScope = deps.nested ?? nestedScopeFromState(deps.state);
|
|
5604
|
+
if (hasExactForegroundId(deps.state, id))
|
|
5605
|
+
return { kind: "foreground", id };
|
|
5606
|
+
let exactAsync = exactAsyncLocation(id, asyncDirRoot, resultsDir);
|
|
5607
|
+
if (exactAsync)
|
|
5608
|
+
return { kind: "async", id, location: exactAsync };
|
|
5609
|
+
let exactNested = findNestedRunMatchesById(id, nestedScope ? { scope: nestedScope } : {});
|
|
5610
|
+
if (exactNested.length > 1)
|
|
5611
|
+
throw new Error(`Nested run id '${id}' is ambiguous across authorized registries. Provide the full id after stale registries are cleaned up.`);
|
|
5612
|
+
if (exactNested[0])
|
|
5613
|
+
return { kind: "nested", id, match: exactNested[0] };
|
|
5614
|
+
let matches = [];
|
|
5615
|
+
for (let foregroundId of foregroundIds(deps.state).filter((candidate) => candidate.startsWith(id)))
|
|
5616
|
+
matches.push({ kind: "foreground", id: foregroundId });
|
|
5617
|
+
for (let match of asyncPrefixMatches(id, asyncDirRoot, resultsDir))
|
|
5618
|
+
matches.push({ kind: "async", id: match.id, location: match.location });
|
|
5619
|
+
for (let match of findNestedRunMatchesById(id, nestedScope ? { prefix: !0, scope: nestedScope } : { prefix: !0 }))
|
|
5620
|
+
matches.push({ kind: "nested", id: match.run.id, match });
|
|
5621
|
+
let values = [...new Map(matches.map((match) => [`${match.kind}:${match.id}`, match])).values()];
|
|
5622
|
+
if (values.length > 1)
|
|
5623
|
+
throw new Error(`Ambiguous subagent run id prefix '${id}' matched: ${values.map((match) => `${match.kind}:${match.id}`).join(", ")}. Provide a longer id.`);
|
|
5624
|
+
return values[0];
|
|
5625
|
+
}
|
|
5626
|
+
|
|
5360
5627
|
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/extension/control-notices.js
|
|
5361
5628
|
var SUBAGENT_CONTROL_MESSAGE_TYPE = "subagent_control_notice";
|
|
5362
5629
|
function controlNoticeTarget(details) {
|
|
@@ -5407,8 +5674,8 @@ function handleSubagentControlNotice(input) {
|
|
|
5407
5674
|
}
|
|
5408
5675
|
|
|
5409
5676
|
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/background/async-status.js
|
|
5410
|
-
import * as
|
|
5411
|
-
import * as
|
|
5677
|
+
import * as fs18 from "node:fs";
|
|
5678
|
+
import * as path19 from "node:path";
|
|
5412
5679
|
function getErrorMessage4(error) {
|
|
5413
5680
|
return error instanceof Error ? error.message : String(error);
|
|
5414
5681
|
}
|
|
@@ -5416,9 +5683,9 @@ function isNotFoundError3(error) {
|
|
|
5416
5683
|
return typeof error == "object" && error !== null && "code" in error && error.code === "ENOENT";
|
|
5417
5684
|
}
|
|
5418
5685
|
function isAsyncRunDir(root, entry) {
|
|
5419
|
-
let entryPath =
|
|
5686
|
+
let entryPath = path19.join(root, entry);
|
|
5420
5687
|
try {
|
|
5421
|
-
return
|
|
5688
|
+
return fs18.statSync(entryPath).isDirectory();
|
|
5422
5689
|
} catch (error) {
|
|
5423
5690
|
if (isNotFoundError3(error))
|
|
5424
5691
|
return !1;
|
|
@@ -5430,7 +5697,7 @@ function isAsyncRunDir(root, entry) {
|
|
|
5430
5697
|
function outputFileMtime(outputFile) {
|
|
5431
5698
|
if (outputFile)
|
|
5432
5699
|
try {
|
|
5433
|
-
return
|
|
5700
|
+
return fs18.statSync(outputFile).mtimeMs;
|
|
5434
5701
|
} catch (error) {
|
|
5435
5702
|
if (isNotFoundError3(error))
|
|
5436
5703
|
return;
|
|
@@ -5442,7 +5709,7 @@ function outputFileMtime(outputFile) {
|
|
|
5442
5709
|
function deriveAsyncActivityState(asyncDir, status) {
|
|
5443
5710
|
if (status.state !== "running")
|
|
5444
5711
|
return { activityState: status.activityState, lastActivityAt: status.lastActivityAt };
|
|
5445
|
-
let outputPath = status.outputFile ?
|
|
5712
|
+
let outputPath = status.outputFile ? path19.isAbsolute(status.outputFile) ? status.outputFile : path19.join(asyncDir, status.outputFile) : void 0, currentStep = typeof status.currentStep == "number" ? status.steps?.[status.currentStep] : void 0;
|
|
5446
5713
|
return {
|
|
5447
5714
|
activityState: status.activityState,
|
|
5448
5715
|
lastActivityAt: status.lastActivityAt ?? outputFileMtime(outputPath) ?? currentStep?.lastActivityAt ?? currentStep?.startedAt ?? status.startedAt
|
|
@@ -5450,7 +5717,7 @@ function deriveAsyncActivityState(asyncDir, status) {
|
|
|
5450
5717
|
}
|
|
5451
5718
|
function statusToSummary(asyncDir, status, nestedWarnings = [], nestedRoute) {
|
|
5452
5719
|
if (status.sessionId !== void 0 && typeof status.sessionId != "string")
|
|
5453
|
-
throw new Error(`Invalid async status '${
|
|
5720
|
+
throw new Error(`Invalid async status '${path19.join(asyncDir, "status.json")}': sessionId must be a string.`);
|
|
5454
5721
|
let { activityState, lastActivityAt } = deriveAsyncActivityState(asyncDir, status), steps = status.steps ?? [], chainStepCount = status.chainStepCount ?? steps.length, parallelGroups = normalizeParallelGroups(status.parallelGroups, steps.length, chainStepCount), nestedChildren = [];
|
|
5455
5722
|
if (nestedWarnings.length === 0 && nestedRoute)
|
|
5456
5723
|
try {
|
|
@@ -5496,8 +5763,8 @@ function statusToSummary(asyncDir, status, nestedWarnings = [], nestedRoute) {
|
|
|
5496
5763
|
...step.children?.length ? { children: step.children } : {}
|
|
5497
5764
|
};
|
|
5498
5765
|
});
|
|
5499
|
-
return attachRootChildrenToSteps(status.runId ||
|
|
5500
|
-
id: status.runId ||
|
|
5766
|
+
return attachRootChildrenToSteps(status.runId || path19.basename(asyncDir), summarizedSteps, nestedChildren), {
|
|
5767
|
+
id: status.runId || path19.basename(asyncDir),
|
|
5501
5768
|
asyncDir,
|
|
5502
5769
|
...status.sessionId ? { sessionId: status.sessionId } : {},
|
|
5503
5770
|
state: status.state,
|
|
@@ -5567,7 +5834,7 @@ function sortRuns(runs) {
|
|
|
5567
5834
|
function listAsyncRuns(asyncDirRoot, options = {}) {
|
|
5568
5835
|
let entries;
|
|
5569
5836
|
try {
|
|
5570
|
-
entries =
|
|
5837
|
+
entries = fs18.readdirSync(asyncDirRoot).filter((entry) => isAsyncRunDir(asyncDirRoot, entry));
|
|
5571
5838
|
} catch (error) {
|
|
5572
5839
|
if (isNotFoundError3(error))
|
|
5573
5840
|
return [];
|
|
@@ -5577,13 +5844,13 @@ function listAsyncRuns(asyncDirRoot, options = {}) {
|
|
|
5577
5844
|
}
|
|
5578
5845
|
let allowedStates = options.states ? new Set(options.states) : void 0, runs = [], nestedRouteIndex, resolveNestedRoute = (rootRunId) => (nestedRouteIndex || (nestedRouteIndex = buildNestedRouteIndex()), nestedRouteIndex.get(rootRunId));
|
|
5579
5846
|
for (let entry of entries) {
|
|
5580
|
-
let asyncDir =
|
|
5847
|
+
let asyncDir = path19.join(asyncDirRoot, entry), status = (options.reconcile === !1 ? void 0 : reconcileAsyncRun(asyncDir, { resultsDir: options.resultsDir, kill: options.kill, now: options.now }))?.status ?? readStatus(asyncDir);
|
|
5581
5848
|
if (!status || allowedStates && !allowedStates.has(status.state) || options.sessionId && status.sessionId !== options.sessionId)
|
|
5582
5849
|
continue;
|
|
5583
5850
|
let nestedWarnings = [], nestedRoute;
|
|
5584
5851
|
if (options.reconcile !== !1)
|
|
5585
5852
|
try {
|
|
5586
|
-
nestedRoute = resolveNestedRoute(status.runId ||
|
|
5853
|
+
nestedRoute = resolveNestedRoute(status.runId || path19.basename(asyncDir)), nestedRoute && reconcileNestedAsyncDescendants(nestedRoute, { resultsDir: options.resultsDir, kill: options.kill, now: options.now });
|
|
5587
5854
|
} catch (error) {
|
|
5588
5855
|
nestedWarnings.push(`Nested status unavailable: ${getErrorMessage4(error)}`);
|
|
5589
5856
|
}
|
|
@@ -5611,7 +5878,7 @@ function formatStepLine(step) {
|
|
|
5611
5878
|
}
|
|
5612
5879
|
function formatAsyncRunOutputPath(run) {
|
|
5613
5880
|
if (run.outputFile)
|
|
5614
|
-
return
|
|
5881
|
+
return path19.isAbsolute(run.outputFile) ? run.outputFile : path19.join(run.asyncDir, run.outputFile);
|
|
5615
5882
|
}
|
|
5616
5883
|
function formatAsyncRunProgressLabel(run) {
|
|
5617
5884
|
let stepCount = run.steps.length || 1, chainStepCount = run.chainStepCount ?? stepCount, groups = normalizeParallelGroups(run.parallelGroups, run.steps.length, chainStepCount), activeGroup = run.currentStep !== void 0 ? groups.find((group) => run.currentStep >= group.start && run.currentStep < group.start + group.count) : void 0;
|
|
@@ -5645,8 +5912,8 @@ function formatAsyncRunList(runs, heading = "Active async runs") {
|
|
|
5645
5912
|
}
|
|
5646
5913
|
|
|
5647
5914
|
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/runs/background/fleet-view.js
|
|
5648
|
-
import * as
|
|
5649
|
-
import * as
|
|
5915
|
+
import * as fs19 from "node:fs";
|
|
5916
|
+
import * as path20 from "node:path";
|
|
5650
5917
|
var DEFAULT_TRANSCRIPT_LINES = 80, MAX_TRANSCRIPT_LINES = 500, TRANSCRIPT_TAIL_BYTES = 256 * 1024;
|
|
5651
5918
|
function transcriptLineLimit(value) {
|
|
5652
5919
|
return value === void 0 || !Number.isFinite(value) ? DEFAULT_TRANSCRIPT_LINES : Math.max(1, Math.min(MAX_TRANSCRIPT_LINES, Math.trunc(value)));
|
|
@@ -5659,11 +5926,11 @@ function uniqueStrings2(values) {
|
|
|
5659
5926
|
}
|
|
5660
5927
|
function resolveMaybeRelative(asyncDir, filePath) {
|
|
5661
5928
|
if (filePath)
|
|
5662
|
-
return
|
|
5929
|
+
return path20.resolve(asyncDir, filePath);
|
|
5663
5930
|
}
|
|
5664
5931
|
function pathWithin(base, candidate) {
|
|
5665
|
-
let resolvedBase =
|
|
5666
|
-
return resolvedCandidate === resolvedBase || resolvedCandidate.startsWith(`${resolvedBase}${
|
|
5932
|
+
let resolvedBase = path20.resolve(base), resolvedCandidate = path20.resolve(candidate);
|
|
5933
|
+
return resolvedCandidate === resolvedBase || resolvedCandidate.startsWith(`${resolvedBase}${path20.sep}`);
|
|
5667
5934
|
}
|
|
5668
5935
|
function getErrorMessage5(error) {
|
|
5669
5936
|
return error instanceof Error ? error.message : String(error);
|
|
@@ -5674,7 +5941,7 @@ function isNotFoundError4(error) {
|
|
|
5674
5941
|
function readTextTail(filePath, maxLines) {
|
|
5675
5942
|
let stat;
|
|
5676
5943
|
try {
|
|
5677
|
-
stat =
|
|
5944
|
+
stat = fs19.statSync(filePath);
|
|
5678
5945
|
} catch (error) {
|
|
5679
5946
|
return isNotFoundError4(error) ? { path: filePath, lines: [], truncated: !1 } : { path: filePath, lines: [], truncated: !1, error: getErrorMessage5(error) };
|
|
5680
5947
|
}
|
|
@@ -5683,24 +5950,24 @@ function readTextTail(filePath, maxLines) {
|
|
|
5683
5950
|
let fd;
|
|
5684
5951
|
try {
|
|
5685
5952
|
let bytesToRead = Math.min(stat.size, TRANSCRIPT_TAIL_BYTES), start = stat.size - bytesToRead, buffer = Buffer.alloc(bytesToRead);
|
|
5686
|
-
fd =
|
|
5687
|
-
let bytesRead =
|
|
5953
|
+
fd = fs19.openSync(filePath, "r");
|
|
5954
|
+
let bytesRead = fs19.readSync(fd, buffer, 0, bytesToRead, start), lines = buffer.subarray(0, bytesRead).toString("utf-8").split(/\r?\n/);
|
|
5688
5955
|
return start > 0 && lines.length > 0 && (lines = lines.slice(1)), lines.at(-1) === "" && (lines = lines.slice(0, -1)), { path: filePath, lines: lines.slice(-maxLines), truncated: start > 0 || lines.length > maxLines };
|
|
5689
5956
|
} catch (error) {
|
|
5690
5957
|
return { path: filePath, lines: [], truncated: !1, error: getErrorMessage5(error) };
|
|
5691
5958
|
} finally {
|
|
5692
|
-
fd !== void 0 &&
|
|
5959
|
+
fd !== void 0 && fs19.closeSync(fd);
|
|
5693
5960
|
}
|
|
5694
5961
|
}
|
|
5695
5962
|
function readContainedTextTail(filePath, maxLines, trustedRoots, label) {
|
|
5696
5963
|
if (trustedRoots.length === 0)
|
|
5697
5964
|
return { path: filePath, lines: [], truncated: !1, error: `Refusing to read ${label} transcript path without a trusted root: ${filePath}` };
|
|
5698
|
-
let resolvedPath =
|
|
5965
|
+
let resolvedPath = path20.resolve(filePath);
|
|
5699
5966
|
if (!trustedRoots.some((root) => pathWithin(root, resolvedPath)))
|
|
5700
5967
|
return { path: filePath, lines: [], truncated: !1, error: `Refusing to read ${label} transcript path outside trusted roots: ${filePath}` };
|
|
5701
5968
|
let lstat;
|
|
5702
5969
|
try {
|
|
5703
|
-
lstat =
|
|
5970
|
+
lstat = fs19.lstatSync(resolvedPath);
|
|
5704
5971
|
} catch (error) {
|
|
5705
5972
|
return isNotFoundError4(error) ? { path: filePath, lines: [], truncated: !1 } : { path: filePath, lines: [], truncated: !1, error: getErrorMessage5(error) };
|
|
5706
5973
|
}
|
|
@@ -5710,7 +5977,7 @@ function readContainedTextTail(filePath, maxLines, trustedRoots, label) {
|
|
|
5710
5977
|
return { path: filePath, lines: [], truncated: !1, error: `Refusing to read non-file ${label} transcript path: ${filePath}` };
|
|
5711
5978
|
let realPath, realRoots;
|
|
5712
5979
|
try {
|
|
5713
|
-
realPath =
|
|
5980
|
+
realPath = fs19.realpathSync(resolvedPath), realRoots = trustedRoots.filter((root) => fs19.existsSync(root)).map((root) => fs19.realpathSync(root));
|
|
5714
5981
|
} catch (error) {
|
|
5715
5982
|
return { path: filePath, lines: [], truncated: !1, error: getErrorMessage5(error) };
|
|
5716
5983
|
}
|
|
@@ -5801,8 +6068,8 @@ function formatAsyncFleetLines(runs) {
|
|
|
5801
6068
|
for (let step of run.steps) {
|
|
5802
6069
|
let display = step.label ? `${step.label} (${step.agent})` : step.agent, phase = step.phase ? `[${step.phase}] ` : "", stepActivity = formatActivityFacts2(step), modelThinking = formatModelSelection(step.modelSelection, step.model, step.thinking), parts = [`${step.index}. ${phase}${display}`, step.status, stepActivity, modelThinking].filter(Boolean);
|
|
5803
6070
|
lines.push(` ${parts.join(" | ")}`);
|
|
5804
|
-
let output =
|
|
5805
|
-
|
|
6071
|
+
let output = path20.join(run.asyncDir, `output-${step.index}.log`);
|
|
6072
|
+
fs19.existsSync(output) && lines.push(` output: ${shortenPath(output)}`), step.sessionFile && lines.push(` session: ${shortenPath(step.sessionFile)}`), (step.status === "running" || step.recentOutput?.length || fs19.existsSync(output)) && lines.push(` transcript: subagent({ action: "status", id: "${run.id}", index: ${step.index}, view: "transcript" })`), lines.push(...formatNestedRunStatusLines(step.children, { indent: " ", commandHints: !0, maxLines: 12 }));
|
|
5806
6073
|
}
|
|
5807
6074
|
let attached = new Set(run.steps.flatMap((step) => step.children?.map((child) => child.id) ?? [])), unattached = run.nestedChildren?.filter((child) => !attached.has(child.id)) ?? [];
|
|
5808
6075
|
lines.push(...formatNestedRunStatusLines(unattached, { indent: " ", commandHints: !0, maxLines: 12 })), run.error && lines.push(` error: ${run.error}`);
|
|
@@ -5892,14 +6159,14 @@ function appendTranscriptBody(lines, sourceLabel, sourceLines, truncated) {
|
|
|
5892
6159
|
lines.push(` ${line}`);
|
|
5893
6160
|
}
|
|
5894
6161
|
function formatAsyncRunTranscript(status, asyncDir, options = {}) {
|
|
5895
|
-
let lineLimit = transcriptLineLimit(options.lines), selected = selectTranscriptStep(status, options), stepOutputPath = selected.index !== void 0 ?
|
|
6162
|
+
let lineLimit = transcriptLineLimit(options.lines), selected = selectTranscriptStep(status, options), stepOutputPath = selected.index !== void 0 ? path20.join(asyncDir, `output-${selected.index}.log`) : void 0, runOutputPath = resolveMaybeRelative(asyncDir, status.outputFile), logPath = path20.join(asyncDir, `subagent-log-${status.runId}.md`), outputPaths = selected.index !== void 0 ? uniqueStrings2([stepOutputPath, runOutputPath && stepOutputPath && path20.resolve(runOutputPath) === path20.resolve(stepOutputPath) ? runOutputPath : void 0]) : uniqueStrings2([runOutputPath]), sessionFile = selected.index !== void 0 ? selected.step?.sessionFile : status.sessionFile, eventsPath = path20.join(asyncDir, "events.jsonl"), lines = [
|
|
5896
6163
|
`Run: ${status.runId}`,
|
|
5897
6164
|
`State: ${status.state}`,
|
|
5898
6165
|
`Mode: ${status.mode}`,
|
|
5899
6166
|
stepStateLine(status.mode, selected.index, selected.step),
|
|
5900
6167
|
selected.hint
|
|
5901
6168
|
].filter((line) => !!line);
|
|
5902
|
-
appendKnownArtifacts(lines, { outputPaths, sessionFile, eventsPath:
|
|
6169
|
+
appendKnownArtifacts(lines, { outputPaths, sessionFile, eventsPath: fs19.existsSync(eventsPath) ? eventsPath : void 0, logPath: fs19.existsSync(logPath) ? logPath : void 0 });
|
|
5903
6170
|
let warnings = [], transcriptLines = [], transcriptSource = "Transcript tail", truncated = !1;
|
|
5904
6171
|
for (let outputPath of outputPaths) {
|
|
5905
6172
|
let tail = readContainedTextTail(outputPath, lineLimit, [asyncDir], "output");
|
|
@@ -5945,7 +6212,7 @@ function formatNestedRunTranscript(run, options = {}) {
|
|
|
5945
6212
|
`);
|
|
5946
6213
|
}
|
|
5947
6214
|
function formatAsyncResultTranscript(data, resultPath, options = {}) {
|
|
5948
|
-
let lineLimit = transcriptLineLimit(options.lines), runId = data.runId ?? data.id ??
|
|
6215
|
+
let lineLimit = transcriptLineLimit(options.lines), runId = data.runId ?? data.id ?? path20.basename(resultPath, ".json"), children = Array.isArray(data.results) ? data.results : data.agent ? [{ agent: data.agent, output: data.output, summary: data.summary, sessionFile: data.sessionFile, state: data.state, success: data.success, exitCode: data.exitCode }] : [], index = options.index;
|
|
5949
6216
|
if (index !== void 0 && !Number.isInteger(index))
|
|
5950
6217
|
throw new Error("Transcript index must be an integer.");
|
|
5951
6218
|
if (index === void 0 && children.length === 1 && (index = 0), index !== void 0 && (index < 0 || index >= children.length))
|
|
@@ -6083,8 +6350,8 @@ function recommendStrongWatchdogModel(ctx) {
|
|
|
6083
6350
|
}
|
|
6084
6351
|
|
|
6085
6352
|
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/watchdog/settings.js
|
|
6086
|
-
import * as
|
|
6087
|
-
import * as
|
|
6353
|
+
import * as fs20 from "node:fs";
|
|
6354
|
+
import * as path21 from "node:path";
|
|
6088
6355
|
|
|
6089
6356
|
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/watchdog/types.js
|
|
6090
6357
|
var SUBAGENT_WATCHDOG_WARNING_TYPE = "subagent_watchdog_warning", WATCHDOG_WARNING_SEVERITIES = ["concern", "blocker"], WATCHDOG_WARNING_CATEGORIES = [
|
|
@@ -6210,7 +6477,7 @@ function parseNonEmptyString(value, field, meta) {
|
|
|
6210
6477
|
return value.trim();
|
|
6211
6478
|
throw invalid(meta, field, "a non-empty string");
|
|
6212
6479
|
}
|
|
6213
|
-
function
|
|
6480
|
+
function parseThinking2(value, field, meta) {
|
|
6214
6481
|
if (value === !1)
|
|
6215
6482
|
return !1;
|
|
6216
6483
|
if (typeof value == "string" && THINKING_LEVELS.includes(value))
|
|
@@ -6249,19 +6516,19 @@ function parseEndpointPatch(value, field, meta) {
|
|
|
6249
6516
|
let input = parseObject(value, field, meta);
|
|
6250
6517
|
assertKnownFields(input, ENDPOINT_FIELDS, field, meta);
|
|
6251
6518
|
let patch = {};
|
|
6252
|
-
return "enabled" in input && (patch.enabled = parseBoolean(input.enabled, `${field}.enabled`, meta)), "model" in input && (patch.model = parseNonEmptyString(input.model, `${field}.model`, meta)), "thinking" in input && (patch.thinking =
|
|
6519
|
+
return "enabled" in input && (patch.enabled = parseBoolean(input.enabled, `${field}.enabled`, meta)), "model" in input && (patch.model = parseNonEmptyString(input.model, `${field}.model`, meta)), "thinking" in input && (patch.thinking = parseThinking2(input.thinking, `${field}.thinking`, meta)), patch;
|
|
6253
6520
|
}
|
|
6254
6521
|
function parseChildOverridePatch(value, field, meta) {
|
|
6255
6522
|
let input = parseObject(value, field, meta);
|
|
6256
6523
|
assertKnownFields(input, CHILD_OVERRIDE_FIELDS, field, meta);
|
|
6257
6524
|
let patch = {};
|
|
6258
|
-
return "enabled" in input && (patch.enabled = parseBoolean(input.enabled, `${field}.enabled`, meta)), "model" in input && (patch.model = parseNonEmptyString(input.model, `${field}.model`, meta)), "thinking" in input && (patch.thinking =
|
|
6525
|
+
return "enabled" in input && (patch.enabled = parseBoolean(input.enabled, `${field}.enabled`, meta)), "model" in input && (patch.model = parseNonEmptyString(input.model, `${field}.model`, meta)), "thinking" in input && (patch.thinking = parseThinking2(input.thinking, `${field}.thinking`, meta)), patch;
|
|
6259
6526
|
}
|
|
6260
6527
|
function parseChildrenPatch(value, field, meta) {
|
|
6261
6528
|
let input = parseObject(value, field, meta);
|
|
6262
6529
|
assertKnownFields(input, CHILDREN_FIELDS, field, meta);
|
|
6263
6530
|
let patch = {};
|
|
6264
|
-
if ("enabled" in input && (patch.enabled = parseBoolean(input.enabled, `${field}.enabled`, meta)), "model" in input && (patch.model = parseNonEmptyString(input.model, `${field}.model`, meta)), "thinking" in input && (patch.thinking =
|
|
6531
|
+
if ("enabled" in input && (patch.enabled = parseBoolean(input.enabled, `${field}.enabled`, meta)), "model" in input && (patch.model = parseNonEmptyString(input.model, `${field}.model`, meta)), "thinking" in input && (patch.thinking = parseThinking2(input.thinking, `${field}.thinking`, meta)), "watchdogTailTimeoutMs" in input && (patch.watchdogTailTimeoutMs = parseInteger(input.watchdogTailTimeoutMs, `${field}.watchdogTailTimeoutMs`, meta, "a positive integer", (candidate) => candidate >= 1)), "autoFollow" in input && (patch.autoFollow = parseAutoFollowPatch(input.autoFollow, `${field}.autoFollow`, meta)), "overrides" in input) {
|
|
6265
6532
|
let overrides = parseObject(input.overrides, `${field}.overrides`, meta);
|
|
6266
6533
|
patch.overrides = {};
|
|
6267
6534
|
for (let [agent, override] of Object.entries(overrides)) {
|
|
@@ -6297,11 +6564,11 @@ function parseSettingsObject(settings, meta) {
|
|
|
6297
6564
|
return "watchdog" in subagents ? parseWatchdogPatch(subagents.watchdog, "subagents.watchdog", meta) : {};
|
|
6298
6565
|
}
|
|
6299
6566
|
function readSettingsFileStrict(filePath) {
|
|
6300
|
-
if (!
|
|
6567
|
+
if (!fs20.existsSync(filePath))
|
|
6301
6568
|
return {};
|
|
6302
6569
|
let raw;
|
|
6303
6570
|
try {
|
|
6304
|
-
raw =
|
|
6571
|
+
raw = fs20.readFileSync(filePath, "utf-8");
|
|
6305
6572
|
} catch (error) {
|
|
6306
6573
|
let message = error instanceof Error ? error.message : String(error);
|
|
6307
6574
|
throw new Error(`Failed to read settings file '${filePath}': ${message}`, { cause: error });
|
|
@@ -6319,13 +6586,13 @@ function readSettingsFileStrict(filePath) {
|
|
|
6319
6586
|
}
|
|
6320
6587
|
function isDirectory(dir) {
|
|
6321
6588
|
try {
|
|
6322
|
-
return
|
|
6589
|
+
return fs20.statSync(dir).isDirectory();
|
|
6323
6590
|
} catch {
|
|
6324
6591
|
return !1;
|
|
6325
6592
|
}
|
|
6326
6593
|
}
|
|
6327
6594
|
function getUserSettingsPath() {
|
|
6328
|
-
return
|
|
6595
|
+
return path21.join(getAgentDir(), "settings.json");
|
|
6329
6596
|
}
|
|
6330
6597
|
function getWatchdogUserSettingsPath() {
|
|
6331
6598
|
return getUserSettingsPath();
|
|
@@ -6333,16 +6600,16 @@ function getWatchdogUserSettingsPath() {
|
|
|
6333
6600
|
function getProjectSettingsPath(cwd) {
|
|
6334
6601
|
let currentDir = cwd;
|
|
6335
6602
|
for (; ; ) {
|
|
6336
|
-
if (isDirectory(getProjectConfigDir(currentDir)) || isDirectory(
|
|
6337
|
-
return
|
|
6338
|
-
let parentDir =
|
|
6603
|
+
if (isDirectory(getProjectConfigDir(currentDir)) || isDirectory(path21.join(currentDir, ".agents")))
|
|
6604
|
+
return path21.join(getProjectConfigDir(currentDir), "settings.json");
|
|
6605
|
+
let parentDir = path21.dirname(currentDir);
|
|
6339
6606
|
if (parentDir === currentDir)
|
|
6340
6607
|
return;
|
|
6341
6608
|
currentDir = parentDir;
|
|
6342
6609
|
}
|
|
6343
6610
|
}
|
|
6344
6611
|
function getWatchdogProjectSettingsPath(cwd) {
|
|
6345
|
-
return
|
|
6612
|
+
return path21.join(getProjectConfigDir(cwd), "settings.json");
|
|
6346
6613
|
}
|
|
6347
6614
|
function deepMerge(base, patch) {
|
|
6348
6615
|
let next = { ...base };
|
|
@@ -6386,7 +6653,7 @@ function targetSettingsObject(watchdog, target, meta) {
|
|
|
6386
6653
|
return ensureObjectField(overrides, target.agent.trim(), `subagents.watchdog.children.overrides.${target.agent.trim()}`, meta);
|
|
6387
6654
|
}
|
|
6388
6655
|
function writeSettingsFile(settingsPath, settings) {
|
|
6389
|
-
return
|
|
6656
|
+
return fs20.mkdirSync(path21.dirname(settingsPath), { recursive: !0 }), fs20.writeFileSync(settingsPath, `${JSON.stringify(settings, null, 2)}
|
|
6390
6657
|
`, "utf-8"), settingsPath;
|
|
6391
6658
|
}
|
|
6392
6659
|
function writeUserWatchdogEnabled(enabled) {
|
|
@@ -6404,7 +6671,7 @@ function resolveWatchdogConfig(cwd, options = {}) {
|
|
|
6404
6671
|
];
|
|
6405
6672
|
for (let source of sourceSpecs)
|
|
6406
6673
|
if (source.path) {
|
|
6407
|
-
sources.push({ scope: source.scope, path: source.path, exists:
|
|
6674
|
+
sources.push({ scope: source.scope, path: source.path, exists: fs20.existsSync(source.path) });
|
|
6408
6675
|
try {
|
|
6409
6676
|
patch = deepMerge(patch, parseSourceFile(source.path, source.scope));
|
|
6410
6677
|
} catch (error) {
|
|
@@ -6678,8 +6945,8 @@ import { createHash as createHash4 } from "node:crypto";
|
|
|
6678
6945
|
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/watchdog/change-signature.js
|
|
6679
6946
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
6680
6947
|
import { createHash as createHash2 } from "node:crypto";
|
|
6681
|
-
import * as
|
|
6682
|
-
import * as
|
|
6948
|
+
import * as fs21 from "node:fs";
|
|
6949
|
+
import * as path22 from "node:path";
|
|
6683
6950
|
var IGNORED_CHANGE_PREFIXES = [".pi-subagents/", "tmp/", "node_modules/"], IGNORED_CHANGE_PATHS = /* @__PURE__ */ new Set([".pi-subagents", "tmp", "node_modules"]);
|
|
6684
6951
|
function git(cwd, args) {
|
|
6685
6952
|
let result = spawnSync2("git", ["-C", cwd, ...args], { encoding: "utf-8", maxBuffer: 10485760 });
|
|
@@ -6687,28 +6954,28 @@ function git(cwd, args) {
|
|
|
6687
6954
|
return result.stdout;
|
|
6688
6955
|
}
|
|
6689
6956
|
function normalizeRelPath(value) {
|
|
6690
|
-
return value.replaceAll(
|
|
6957
|
+
return value.replaceAll(path22.sep, "/").replace(/^\.\//, "");
|
|
6691
6958
|
}
|
|
6692
6959
|
function ignoredRelPath(relPath) {
|
|
6693
6960
|
let normalized = normalizeRelPath(relPath);
|
|
6694
6961
|
return IGNORED_CHANGE_PATHS.has(normalized) || IGNORED_CHANGE_PREFIXES.some((prefix) => normalized.startsWith(prefix));
|
|
6695
6962
|
}
|
|
6696
6963
|
function hashFile(filePath) {
|
|
6697
|
-
return createHash2("sha256").update(
|
|
6964
|
+
return createHash2("sha256").update(fs21.readFileSync(filePath)).digest("hex");
|
|
6698
6965
|
}
|
|
6699
6966
|
function hashPath(root, relPath) {
|
|
6700
|
-
let normalized = normalizeRelPath(relPath), fullPath =
|
|
6967
|
+
let normalized = normalizeRelPath(relPath), fullPath = path22.join(root, normalized), stat;
|
|
6701
6968
|
try {
|
|
6702
|
-
stat =
|
|
6969
|
+
stat = fs21.lstatSync(fullPath);
|
|
6703
6970
|
} catch (error) {
|
|
6704
6971
|
if (error.code === "ENOENT")
|
|
6705
6972
|
return { path: normalized, state: "deleted" };
|
|
6706
6973
|
throw error;
|
|
6707
6974
|
}
|
|
6708
6975
|
if (stat.isSymbolicLink())
|
|
6709
|
-
return { path: normalized, state: "symlink", target:
|
|
6976
|
+
return { path: normalized, state: "symlink", target: fs21.readlinkSync(fullPath) };
|
|
6710
6977
|
if (stat.isDirectory()) {
|
|
6711
|
-
let entries =
|
|
6978
|
+
let entries = fs21.readdirSync(fullPath).map((entry) => normalizeRelPath(path22.posix.join(normalized, entry))).filter((entry) => !ignoredRelPath(entry)).sort();
|
|
6712
6979
|
return { path: normalized, state: "dir", entries: entries.map((entry) => hashPath(root, entry)) };
|
|
6713
6980
|
}
|
|
6714
6981
|
return stat.isFile() ? { path: normalized, state: "file", mode: stat.mode & 511, size: stat.size, hash: hashFile(fullPath) } : { path: normalized, state: "other", mode: stat.mode };
|
|
@@ -6841,8 +7108,8 @@ var WatchdogEmissionGuard = class {
|
|
|
6841
7108
|
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/watchdog/lsp-diagnostics.js
|
|
6842
7109
|
import { spawn as spawn2 } from "node:child_process";
|
|
6843
7110
|
import { createHash as createHash3 } from "node:crypto";
|
|
6844
|
-
import * as
|
|
6845
|
-
import * as
|
|
7111
|
+
import * as fs22 from "node:fs";
|
|
7112
|
+
import * as path23 from "node:path";
|
|
6846
7113
|
import { pathToFileURL } from "node:url";
|
|
6847
7114
|
var TS_JS_EXTENSIONS = /* @__PURE__ */ new Map([
|
|
6848
7115
|
[".ts", "typescript"],
|
|
@@ -6855,14 +7122,14 @@ var TS_JS_EXTENSIONS = /* @__PURE__ */ new Map([
|
|
|
6855
7122
|
[".cjs", "javascript"]
|
|
6856
7123
|
]), PROVIDER_NAME = "typescript-language-server", MAX_MESSAGE_LENGTH = 500, MAX_STDERR_LENGTH = 2e3, SHUTDOWN_TIMEOUT_MS = 250;
|
|
6857
7124
|
function normalizeRelPath2(value) {
|
|
6858
|
-
return value.replaceAll(
|
|
7125
|
+
return value.replaceAll(path23.sep, "/").replace(/^\.\//, "");
|
|
6859
7126
|
}
|
|
6860
7127
|
function isPathInsideRoot(absPath, root) {
|
|
6861
|
-
let rel =
|
|
6862
|
-
return rel === "" || !rel.startsWith("..") && !
|
|
7128
|
+
let rel = path23.relative(root, absPath);
|
|
7129
|
+
return rel === "" || !rel.startsWith("..") && !path23.isAbsolute(rel);
|
|
6863
7130
|
}
|
|
6864
7131
|
function languageIdForPath(filePath) {
|
|
6865
|
-
return TS_JS_EXTENSIONS.get(
|
|
7132
|
+
return TS_JS_EXTENSIONS.get(path23.extname(filePath).toLowerCase());
|
|
6866
7133
|
}
|
|
6867
7134
|
function trimDiagnosticMessage(message) {
|
|
6868
7135
|
let normalized = message.replace(/\s+/g, " ").trim();
|
|
@@ -6873,7 +7140,7 @@ function severityFromLsp(value) {
|
|
|
6873
7140
|
}
|
|
6874
7141
|
function pathExecutable(filePath) {
|
|
6875
7142
|
try {
|
|
6876
|
-
return
|
|
7143
|
+
return fs22.statSync(filePath).isFile() ? (process.platform === "win32" || fs22.accessSync(filePath, fs22.constants.X_OK), !0) : !1;
|
|
6877
7144
|
} catch {
|
|
6878
7145
|
return !1;
|
|
6879
7146
|
}
|
|
@@ -6886,13 +7153,13 @@ function pathExecutableNames(name) {
|
|
|
6886
7153
|
}
|
|
6887
7154
|
function resolveTypeScriptLanguageServer(root) {
|
|
6888
7155
|
for (let name of pathExecutableNames(PROVIDER_NAME)) {
|
|
6889
|
-
let local =
|
|
7156
|
+
let local = path23.join(root, "node_modules", ".bin", name);
|
|
6890
7157
|
if (pathExecutable(local))
|
|
6891
7158
|
return { command: local, args: ["--stdio"], label: `${PROVIDER_NAME} (project)` };
|
|
6892
7159
|
}
|
|
6893
|
-
for (let dir of (process.env.PATH ?? "").split(
|
|
7160
|
+
for (let dir of (process.env.PATH ?? "").split(path23.delimiter).filter(Boolean))
|
|
6894
7161
|
for (let name of pathExecutableNames(PROVIDER_NAME)) {
|
|
6895
|
-
let candidate =
|
|
7162
|
+
let candidate = path23.join(dir, name);
|
|
6896
7163
|
if (pathExecutable(candidate))
|
|
6897
7164
|
return { command: candidate, args: ["--stdio"], label: PROVIDER_NAME };
|
|
6898
7165
|
}
|
|
@@ -6900,14 +7167,14 @@ function resolveTypeScriptLanguageServer(root) {
|
|
|
6900
7167
|
function collectTargetFiles(root, changedPaths, maxFiles) {
|
|
6901
7168
|
let targets = [], skippedPaths = [];
|
|
6902
7169
|
for (let changedPath of changedPaths) {
|
|
6903
|
-
let relPath = normalizeRelPath2(changedPath), absPath =
|
|
7170
|
+
let relPath = normalizeRelPath2(changedPath), absPath = path23.resolve(root, relPath), languageId = languageIdForPath(absPath);
|
|
6904
7171
|
if (!languageId || !isPathInsideRoot(absPath, root)) {
|
|
6905
7172
|
skippedPaths.push(relPath);
|
|
6906
7173
|
continue;
|
|
6907
7174
|
}
|
|
6908
7175
|
let stat;
|
|
6909
7176
|
try {
|
|
6910
|
-
stat =
|
|
7177
|
+
stat = fs22.statSync(absPath);
|
|
6911
7178
|
} catch (error) {
|
|
6912
7179
|
if (error.code === "ENOENT") {
|
|
6913
7180
|
skippedPaths.push(relPath);
|
|
@@ -7134,7 +7401,7 @@ function initializeParams(root) {
|
|
|
7134
7401
|
},
|
|
7135
7402
|
workspace: { configuration: !1, workspaceFolders: !0 }
|
|
7136
7403
|
},
|
|
7137
|
-
workspaceFolders: [{ uri: rootUri, name:
|
|
7404
|
+
workspaceFolders: [{ uri: rootUri, name: path23.basename(root) || "workspace" }]
|
|
7138
7405
|
};
|
|
7139
7406
|
}
|
|
7140
7407
|
async function waitForDiagnostics(client, targets, timeoutMs, signal) {
|
|
@@ -7157,7 +7424,7 @@ async function collectWithTypeScriptLanguageServer(input) {
|
|
|
7157
7424
|
try {
|
|
7158
7425
|
await client.request("initialize", initializeParams(input.root), remaining(), input.signal), client.notify("initialized", {});
|
|
7159
7426
|
for (let target of input.targets) {
|
|
7160
|
-
let text =
|
|
7427
|
+
let text = fs22.readFileSync(target.absPath, "utf-8");
|
|
7161
7428
|
client.notify("textDocument/didOpen", {
|
|
7162
7429
|
textDocument: { uri: target.uri, languageId: target.languageId, version: 1, text }
|
|
7163
7430
|
}), client.notify("textDocument/didSave", {
|
|
@@ -7191,7 +7458,7 @@ async function collectWithTypeScriptLanguageServer(input) {
|
|
|
7191
7458
|
async function collectWatchdogLspDiagnostics(request) {
|
|
7192
7459
|
if (!request.config.enabled)
|
|
7193
7460
|
return { status: "disabled", checkedPaths: [], skippedPaths: [], diagnostics: [] };
|
|
7194
|
-
let root =
|
|
7461
|
+
let root = path23.resolve(request.root || request.cwd), { targets, skippedPaths } = collectTargetFiles(root, request.changedPaths, request.config.maxFiles);
|
|
7195
7462
|
if (!targets.length)
|
|
7196
7463
|
return {
|
|
7197
7464
|
status: "skipped",
|
|
@@ -7900,7 +8167,7 @@ function buildWatchdogStatus(snapshot, ctx) {
|
|
|
7900
8167
|
`Auto-follow: not implemented${snapshot.autoFollowQueued ? " (queued)" : ""}`,
|
|
7901
8168
|
`Review model call: ${snapshot.reviewDescription}`
|
|
7902
8169
|
];
|
|
7903
|
-
return snapshot.failedReviews > 0 && lines.push(`Failed reviews: ${snapshot.failedReviews}`), snapshot.staleReviews > 0 && lines.push(`Stale reviews: ${snapshot.staleReviews}`), snapshot.changedPaths?.length && lines.push(`Changed paths: ${snapshot.changedPaths.slice(0, 8).join(", ")}${snapshot.changedPaths.length > 8 ? `, +${snapshot.changedPaths.length - 8} more` : ""}`), snapshot.lastWarning && lines.push(`Last warning: ${snapshot.lastWarning.severity} \xB7 ${snapshot.lastWarning.state ?? "candidate"} \xB7 ${snapshot.lastWarning.summary}`), snapshot.lastError && lines.push(`Last error: ${snapshot.lastError}`), snapshot.configOk ? lines.push("", "Config: ok") : lines.push("", "Config errors:", ...snapshot.errors.map((error) => `- ${error.message}`), "Watchdog is disabled until the config is fixed."), lines.push("Sources:", ...snapshot.sources.map(sourceLine), "", "Model commands:", "- /subagents-watchdog recommend-model", "- /subagents-watchdog model recommended", "- /subagents-watchdog model <provider/model[:thinking]>", "- /subagents-watchdog model inherit", "- /subagents-watchdog session model recommended",
|
|
8170
|
+
return snapshot.failedReviews > 0 && lines.push(`Failed reviews: ${snapshot.failedReviews}`), snapshot.staleReviews > 0 && lines.push(`Stale reviews: ${snapshot.staleReviews}`), snapshot.changedPaths?.length && lines.push(`Changed paths: ${snapshot.changedPaths.slice(0, 8).join(", ")}${snapshot.changedPaths.length > 8 ? `, +${snapshot.changedPaths.length - 8} more` : ""}`), snapshot.lastWarning && lines.push(`Last warning: ${snapshot.lastWarning.severity} \xB7 ${snapshot.lastWarning.state ?? "candidate"} \xB7 ${snapshot.lastWarning.summary}`), snapshot.lastError && lines.push(`Last error: ${snapshot.lastError}`), snapshot.configOk ? lines.push("", "Config: ok") : lines.push("", "Config errors:", ...snapshot.errors.map((error) => `- ${error.message}`), "Watchdog is disabled until the config is fixed."), lines.push("Sources:", ...snapshot.sources.map(sourceLine), "", "Model commands:", "- /subagents-watchdog recommend-model", "- /subagents-watchdog model recommended", "- /subagents-watchdog model <provider/model[:thinking]>", "- /subagents-watchdog model inherit", "- /subagents-watchdog session model recommended", "Configure via /subagents-watchdog or /settings; agent watchdog.configure is not available."), lines.join(`
|
|
7904
8171
|
`);
|
|
7905
8172
|
}
|
|
7906
8173
|
function parseTestCommand(input) {
|
|
@@ -8153,6 +8420,9 @@ function registerMainWatchdog(pi, options = {}) {
|
|
|
8153
8420
|
}), runtime;
|
|
8154
8421
|
}
|
|
8155
8422
|
|
|
8423
|
+
// packages/coding-agent/dist/builtin-extensions/pi-subagents/src/shared/async-guidance.js
|
|
8424
|
+
var SUBAGENT_ASYNC_GUIDANCE = "Subagents run async by default. Set async:false when you need the result immediately and have no independent work to do, or need an interactive preview. Otherwise continue independent work or yield for normal interactive completion. Use subagent_wait for same-turn or skill completion. Headless sessions auto-drain current-session work. Use status for one-time inspection. Do not poll or sleep to wait.";
|
|
8425
|
+
|
|
8156
8426
|
export {
|
|
8157
8427
|
childRowLabel,
|
|
8158
8428
|
SUBAGENT_LIFECYCLE_ARTIFACT_VERSION,
|
|
@@ -8181,7 +8451,6 @@ export {
|
|
|
8181
8451
|
SLASH_SUBAGENT_UPDATE_EVENT,
|
|
8182
8452
|
SLASH_SUBAGENT_CANCEL_EVENT,
|
|
8183
8453
|
POLL_INTERVAL_MS,
|
|
8184
|
-
MAX_WIDGET_JOBS,
|
|
8185
8454
|
SUBAGENT_ACTIONS,
|
|
8186
8455
|
DEFAULT_FORK_PREAMBLE,
|
|
8187
8456
|
resolveTopLevelParallelMaxTasks,
|
|
@@ -8218,7 +8487,6 @@ export {
|
|
|
8218
8487
|
buildChainInstructions,
|
|
8219
8488
|
resolveParallelBehaviors,
|
|
8220
8489
|
createParallelDirs,
|
|
8221
|
-
THINKING_LEVELS,
|
|
8222
8490
|
toModelInfo,
|
|
8223
8491
|
resolveEffectiveThinking,
|
|
8224
8492
|
splitKnownThinkingSuffix,
|
|
@@ -8226,6 +8494,7 @@ export {
|
|
|
8226
8494
|
getSupportedThinkingLevels,
|
|
8227
8495
|
formatTokens,
|
|
8228
8496
|
formatModelSelection,
|
|
8497
|
+
formatCompactModelBadge,
|
|
8229
8498
|
formatUsage,
|
|
8230
8499
|
formatDuration,
|
|
8231
8500
|
buildChainSummary,
|
|
@@ -8280,8 +8549,8 @@ export {
|
|
|
8280
8549
|
splitThinkingSuffix,
|
|
8281
8550
|
resolveModelCandidate,
|
|
8282
8551
|
resolveEffectiveSubagentModel,
|
|
8283
|
-
resolveRequiredTierModel,
|
|
8284
8552
|
captureModelSelection,
|
|
8553
|
+
resolveExecutableChildModel,
|
|
8285
8554
|
buildModelCandidates,
|
|
8286
8555
|
isRetryableModelFailure,
|
|
8287
8556
|
formatModelAttemptNote,
|
|
@@ -8291,11 +8560,10 @@ export {
|
|
|
8291
8560
|
normalizeParallelGroups,
|
|
8292
8561
|
flatToLogicalStepIndex,
|
|
8293
8562
|
formatActivityLabel,
|
|
8294
|
-
aggregateStepStatus,
|
|
8295
8563
|
formatAgentRunningLabel,
|
|
8296
|
-
formatParallelOutcome,
|
|
8297
8564
|
formatNestedAggregate,
|
|
8298
8565
|
formatNestedRunStatusLines,
|
|
8566
|
+
resolveSubagentRequestParams,
|
|
8299
8567
|
DEFAULT_CONTROL_CONFIG,
|
|
8300
8568
|
resolveControlConfig,
|
|
8301
8569
|
deriveActivityState,
|
|
@@ -8306,7 +8574,6 @@ export {
|
|
|
8306
8574
|
formatControlIntercomMessage,
|
|
8307
8575
|
writeAtomicJson,
|
|
8308
8576
|
writePrivateAtomicJson,
|
|
8309
|
-
assertSafeNestedId,
|
|
8310
8577
|
createNestedRoute,
|
|
8311
8578
|
resolveInheritedNestedRouteFromEnv,
|
|
8312
8579
|
resolveNestedParentAddressFromEnv,
|
|
@@ -8314,7 +8581,6 @@ export {
|
|
|
8314
8581
|
sanitizeSummary,
|
|
8315
8582
|
findNestedRouteForRootId,
|
|
8316
8583
|
projectNestedRegistryForRoot,
|
|
8317
|
-
findNestedRunMatchesById,
|
|
8318
8584
|
writeNestedEvent,
|
|
8319
8585
|
writeNestedControlRequest,
|
|
8320
8586
|
readNestedControlResults,
|
|
@@ -8333,6 +8599,7 @@ export {
|
|
|
8333
8599
|
resolveSubagentResultStatus,
|
|
8334
8600
|
compactNestedResultChildren,
|
|
8335
8601
|
attachNestedChildrenToResultChildren,
|
|
8602
|
+
formatNestedResultLines,
|
|
8336
8603
|
buildSubagentResultIntercomPayload,
|
|
8337
8604
|
deliverSubagentResultIntercomEvent,
|
|
8338
8605
|
deliverSubagentIntercomMessageEvent,
|
|
@@ -8340,6 +8607,7 @@ export {
|
|
|
8340
8607
|
formatSubagentResultReceipt,
|
|
8341
8608
|
expectsImplementationMutation,
|
|
8342
8609
|
validateAcceptanceInput,
|
|
8610
|
+
restorePersistedAcceptance,
|
|
8343
8611
|
validateExecutionAcceptance,
|
|
8344
8612
|
resolveEffectiveAcceptance,
|
|
8345
8613
|
formatAcceptancePrompt,
|
|
@@ -8348,6 +8616,9 @@ export {
|
|
|
8348
8616
|
evaluateAcceptance,
|
|
8349
8617
|
buildSkippedAcceptanceLedger,
|
|
8350
8618
|
acceptanceFailureMessage,
|
|
8619
|
+
normalizeAsyncLaunchConfig,
|
|
8620
|
+
subagentLaunchRunsAsync,
|
|
8621
|
+
isAsyncSubagentExecution,
|
|
8351
8622
|
inspectSubagentFleet,
|
|
8352
8623
|
formatAsyncRunTranscript,
|
|
8353
8624
|
formatNestedRunTranscript,
|
|
@@ -8360,28 +8631,28 @@ export {
|
|
|
8360
8631
|
initialTurnBudgetState,
|
|
8361
8632
|
turnBudgetState,
|
|
8362
8633
|
shouldAbortForTurnBudget,
|
|
8363
|
-
parseWatchdogThinkingInput,
|
|
8364
8634
|
resolveWatchdogModelInput,
|
|
8365
8635
|
recommendStrongWatchdogModel,
|
|
8366
|
-
writeWatchdogModelSettings,
|
|
8367
8636
|
resolveWatchdogConfig,
|
|
8368
8637
|
buildWatchdogStatus,
|
|
8369
8638
|
registerMainWatchdog,
|
|
8639
|
+
requestAsyncSteer,
|
|
8640
|
+
readSteerCapability,
|
|
8641
|
+
consumeSteerAcks,
|
|
8642
|
+
deliverInterruptRequest,
|
|
8643
|
+
deliverStopRequest,
|
|
8370
8644
|
INTERCOM_BRIDGE_MARKER,
|
|
8371
8645
|
resolveIntercomSessionTarget,
|
|
8372
8646
|
resolveSubagentIntercomTarget,
|
|
8373
8647
|
diagnoseIntercomBridge,
|
|
8374
8648
|
resolveIntercomBridge,
|
|
8375
8649
|
applyIntercomBridgeToAgent,
|
|
8376
|
-
requestAsyncSteer,
|
|
8377
|
-
consumeSteerAcks,
|
|
8378
|
-
deliverInterruptRequest,
|
|
8379
|
-
deliverStopRequest,
|
|
8380
8650
|
interruptLiveAsyncResumeTarget,
|
|
8381
|
-
findAsyncRunPrefixMatches,
|
|
8382
8651
|
resolveAsyncRunLocation,
|
|
8383
8652
|
resolveAsyncResumeTarget,
|
|
8384
8653
|
buildRevivedAsyncTask,
|
|
8654
|
+
resolveSubagentRunId,
|
|
8655
|
+
SUBAGENT_ASYNC_GUIDANCE,
|
|
8385
8656
|
SUBAGENT_CONTROL_MESSAGE_TYPE,
|
|
8386
8657
|
clearPendingForegroundControlNotices,
|
|
8387
8658
|
handleSubagentControlNotice
|