@astralyn/pi 1.4.10 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +88 -0
- package/dist/bundle/chunks/anthropic-messages-G5ZGBHOH.js +6 -0
- package/dist/bundle/chunks/azure-openai-responses-EMPTMYNF.js +2 -0
- package/dist/bundle/chunks/bedrock-converse-stream.js +22 -15
- package/dist/bundle/chunks/chunk-AXX7FFFD.js +2 -0
- package/dist/bundle/chunks/chunk-FNGB3ASD.js +2 -0
- package/dist/bundle/chunks/chunk-FPALVF3F.js +4 -0
- package/dist/bundle/chunks/chunk-H3UF54OB.js +9 -0
- package/dist/bundle/chunks/chunk-IC6JXX2J.js +10 -0
- package/dist/bundle/chunks/{chunk-UCH27AVQ.js → chunk-IRUUTK4W.js} +1 -1
- package/dist/bundle/chunks/{chunk-MZJC45TM.js → chunk-J7L6O5XA.js} +3 -3
- package/dist/bundle/chunks/{chunk-DLVLAQEG.js → chunk-KBFO53OG.js} +3 -3
- package/dist/bundle/chunks/{chunk-TPVFPFJP.js → chunk-P7VXFB2M.js} +1 -1
- package/dist/bundle/chunks/chunk-PSYLMRL6.js +9 -0
- package/dist/bundle/chunks/chunk-QNZARXLE.js +82 -0
- package/dist/bundle/chunks/chunk-R3YHAMWH.js +1503 -0
- package/dist/bundle/chunks/chunk-RAIYJ5FC.js +4 -0
- package/dist/bundle/chunks/{chunk-OV2VMHBX.js → chunk-SR6EWNPW.js} +1 -1
- package/dist/bundle/chunks/chunk-TA3YH2ZI.js +16 -0
- package/dist/bundle/chunks/{chunk-MF3T3ETJ.js → chunk-THAJ4BZF.js} +58 -62
- package/dist/bundle/chunks/{chunk-24FY4C5S.js → chunk-TRSJS3FM.js} +1 -1
- package/dist/bundle/chunks/chunk-ZRI3ICDE.js +2 -0
- package/dist/bundle/chunks/{cli-MBFCFGI2.js → cli-LAZQG54B.js} +11 -9
- package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-7BKATOEJ.js → cloudflare-workers-ai-system-one-4L2ABUJE.js} +1 -1
- package/dist/bundle/chunks/{execute-FQKRO4XJ.js → execute-ACWDKC3C.js} +1 -1
- package/dist/bundle/chunks/github-copilot.js +1 -1
- package/dist/bundle/chunks/{google-generative-ai-HTUSU45F.js → google-generative-ai-OOVDGS5W.js} +1 -1
- package/dist/bundle/chunks/{google-vertex-AVQV4P76.js → google-vertex-IK5RNG7J.js} +1 -1
- package/dist/bundle/chunks/image-resize-worker.js +1 -1
- package/dist/bundle/chunks/kimi-coding.js +1 -1
- package/dist/bundle/chunks/{llama-cpp-classify-27QYLJZY.js → llama-cpp-classify-XHAVT37C.js} +1 -1
- package/dist/bundle/chunks/meta.js +1 -1
- package/dist/bundle/chunks/mistral-conversations-Z56KY4OJ.js +5 -0
- package/dist/bundle/chunks/{openai-codex-responses-Q25MHDFX.js → openai-codex-responses-5NAH3SK6.js} +1 -1
- package/dist/bundle/chunks/openai-completions-S7S6PO3J.js +7 -0
- package/dist/bundle/chunks/{openai-decisions-3WYFPGSK.js → openai-decisions-7A36EAHE.js} +1 -1
- package/dist/bundle/chunks/{openai-responses-E4BNZIQK.js → openai-responses-ZQRZJKH4.js} +1 -1
- package/dist/bundle/chunks/{openrouter-images-CBP3OPOD.js → openrouter-images-X7PX72ON.js} +1 -1
- package/dist/bundle/chunks/pi-messages-TXNWPLI4.js +8 -0
- package/dist/bundle/chunks/radius.js +1 -1
- package/dist/bundle/chunks/{runtime-3RPOJS5T.js → runtime-X3XOMNXQ.js} +1 -1
- package/dist/bundle/chunks/{typesafe-system-one-BNICP2LS.js → typesafe-system-one-XJGMSHWL.js} +1 -1
- package/dist/bundle/chunks/virtual-modules-T2KLVAFL.js +2 -0
- package/dist/bundle/cli.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +8 -7
- package/dist/cli/args.js.map +1 -1
- package/dist/config.d.ts +10 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +24 -5
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +0 -5
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +12 -28
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session.d.ts +21 -14
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +67 -96
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts +4 -2
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +16 -4
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/exec.d.ts +9 -1
- package/dist/core/exec.d.ts.map +1 -1
- package/dist/core/exec.js +104 -60
- package/dist/core/exec.js.map +1 -1
- package/dist/core/export-html/template.css +9 -0
- package/dist/core/export-html/template.js +165 -45
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
- package/dist/core/export-html/tool-renderer.js +5 -0
- package/dist/core/export-html/tool-renderer.js.map +1 -1
- package/dist/core/extensions/index.d.ts +2 -2
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +20 -12
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/pi-ai-extension-view.d.ts +19 -0
- package/dist/core/extensions/pi-ai-extension-view.d.ts.map +1 -0
- package/dist/core/extensions/pi-ai-extension-view.js +22 -0
- package/dist/core/extensions/pi-ai-extension-view.js.map +1 -0
- package/dist/core/extensions/runner.d.ts +0 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +7 -12
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +41 -23
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/extensions/virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/virtual-modules.js +8 -7
- package/dist/core/extensions/virtual-modules.js.map +1 -1
- package/dist/core/mcp-servers.d.ts +11 -4
- package/dist/core/mcp-servers.d.ts.map +1 -1
- package/dist/core/mcp-servers.js +15 -5
- package/dist/core/mcp-servers.js.map +1 -1
- package/dist/core/model-config.d.ts +1678 -2029
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +2 -3
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +16 -10
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/package-manager.d.ts +14 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +160 -46
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/pi-ai-schemas.d.ts +163 -0
- package/dist/core/pi-ai-schemas.d.ts.map +1 -0
- package/dist/core/pi-ai-schemas.js +21 -0
- package/dist/core/pi-ai-schemas.js.map +1 -0
- package/dist/core/pi-manifest.d.ts +1 -0
- package/dist/core/pi-manifest.d.ts.map +1 -1
- package/dist/core/pi-manifest.js +4 -0
- package/dist/core/pi-manifest.js.map +1 -1
- package/dist/core/project-trust.js +1 -1
- package/dist/core/project-trust.js.map +1 -1
- package/dist/core/quiescence.d.ts +24 -0
- package/dist/core/quiescence.d.ts.map +1 -0
- package/dist/core/quiescence.js +81 -0
- package/dist/core/quiescence.js.map +1 -0
- package/dist/core/resource-loader.d.ts +4 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +41 -28
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +3 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts +7 -0
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +32 -13
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +2 -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/settings-schema.d.ts +4 -2
- package/dist/core/settings-schema.d.ts.map +1 -1
- package/dist/core/settings-schema.js +8 -1
- package/dist/core/settings-schema.js.map +1 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +6 -14
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-command-name.d.ts +6 -0
- package/dist/core/slash-command-name.d.ts.map +1 -0
- package/dist/core/slash-command-name.js +11 -0
- package/dist/core/slash-command-name.js.map +1 -0
- package/dist/core/slash-commands.js +2 -2
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/source-info.d.ts +9 -0
- package/dist/core/source-info.d.ts.map +1 -1
- package/dist/core/source-info.js +13 -0
- package/dist/core/source-info.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +5 -6
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tasks/codec.d.ts +14 -0
- package/dist/core/tasks/codec.d.ts.map +1 -1
- package/dist/core/tasks/codec.js +57 -4
- package/dist/core/tasks/codec.js.map +1 -1
- package/dist/core/tasks/delivery.d.ts +4 -20
- package/dist/core/tasks/delivery.d.ts.map +1 -1
- package/dist/core/tasks/delivery.js +5 -58
- package/dist/core/tasks/delivery.js.map +1 -1
- package/dist/core/tasks/limits.d.ts +3 -19
- package/dist/core/tasks/limits.d.ts.map +1 -1
- package/dist/core/tasks/limits.js +3 -24
- package/dist/core/tasks/limits.js.map +1 -1
- package/dist/core/tasks/record.d.ts +1 -7
- package/dist/core/tasks/record.d.ts.map +1 -1
- package/dist/core/tasks/record.js +0 -18
- package/dist/core/tasks/record.js.map +1 -1
- package/dist/core/tasks/reminder.d.ts +3 -2
- package/dist/core/tasks/reminder.d.ts.map +1 -1
- package/dist/core/tasks/reminder.js +4 -3
- package/dist/core/tasks/reminder.js.map +1 -1
- package/dist/core/tasks/runtime.d.ts +1 -14
- package/dist/core/tasks/runtime.d.ts.map +1 -1
- package/dist/core/tasks/runtime.js +3 -96
- package/dist/core/tasks/runtime.js.map +1 -1
- package/dist/core/tasks/session.d.ts +9 -5
- package/dist/core/tasks/session.d.ts.map +1 -1
- package/dist/core/tasks/session.js +22 -24
- package/dist/core/tasks/session.js.map +1 -1
- package/dist/core/tasks/types.d.ts +3 -92
- package/dist/core/tasks/types.d.ts.map +1 -1
- package/dist/core/tasks/types.js +3 -3
- package/dist/core/tasks/types.js.map +1 -1
- package/dist/core/tools/bash.d.ts +8 -7
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +6 -5
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit.d.ts +3 -3
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +2 -4
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/find.d.ts +2 -2
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts +2 -2
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +1 -1
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/ls.d.ts +2 -2
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/powershell.d.ts +1 -5
- package/dist/core/tools/powershell.d.ts.map +1 -1
- package/dist/core/tools/read.d.ts +2 -2
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts +4 -6
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +19 -41
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/renderers/bash.d.ts.map +1 -1
- package/dist/core/tools/renderers/bash.js +3 -25
- package/dist/core/tools/renderers/bash.js.map +1 -1
- package/dist/core/tools/renderers/write.d.ts.map +1 -1
- package/dist/core/tools/renderers/write.js +18 -19
- package/dist/core/tools/renderers/write.js.map +1 -1
- package/dist/core/tools/shell-execution.d.ts +20 -13
- package/dist/core/tools/shell-execution.d.ts.map +1 -1
- package/dist/core/tools/shell-execution.js +165 -183
- package/dist/core/tools/shell-execution.js.map +1 -1
- package/dist/core/tools/shell-tool.d.ts +9 -14
- package/dist/core/tools/shell-tool.d.ts.map +1 -1
- package/dist/core/tools/shell-tool.js +38 -66
- package/dist/core/tools/shell-tool.js.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts +14 -4
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js +2 -3
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/core/tools/write.d.ts +2 -2
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +30 -13
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/core/usage-totals.d.ts +0 -9
- package/dist/core/usage-totals.d.ts.map +1 -1
- package/dist/core/usage-totals.js +24 -91
- package/dist/core/usage-totals.js.map +1 -1
- package/dist/extensions/agent/activity-lines.d.ts +2 -3
- package/dist/extensions/agent/activity-lines.d.ts.map +1 -1
- package/dist/extensions/agent/activity-lines.js +5 -9
- package/dist/extensions/agent/activity-lines.js.map +1 -1
- package/dist/extensions/agent/activity.d.ts +0 -2
- package/dist/extensions/agent/activity.d.ts.map +1 -1
- package/dist/extensions/agent/activity.js +1 -1
- package/dist/extensions/agent/activity.js.map +1 -1
- package/dist/extensions/agent/progress.d.ts +0 -3
- package/dist/extensions/agent/progress.d.ts.map +1 -1
- package/dist/extensions/agent/progress.js +2 -8
- package/dist/extensions/agent/progress.js.map +1 -1
- package/dist/extensions/agent/render.js +1 -1
- package/dist/extensions/agent/render.js.map +1 -1
- package/dist/extensions/agent/tool.d.ts.map +1 -1
- package/dist/extensions/agent/tool.js +0 -6
- package/dist/extensions/agent/tool.js.map +1 -1
- package/dist/{core/isolated-session.d.ts → extensions/agent/worker-session.d.ts} +6 -6
- package/dist/extensions/agent/worker-session.d.ts.map +1 -0
- package/dist/{core/isolated-session.js → extensions/agent/worker-session.js} +9 -9
- package/dist/extensions/agent/worker-session.js.map +1 -0
- package/dist/extensions/agent/worker.d.ts +0 -3
- package/dist/extensions/agent/worker.d.ts.map +1 -1
- package/dist/extensions/agent/worker.js +2 -3
- package/dist/extensions/agent/worker.js.map +1 -1
- package/dist/extensions/btw/agent.d.ts.map +1 -1
- package/dist/extensions/btw/agent.js +2 -1
- package/dist/extensions/btw/agent.js.map +1 -1
- package/dist/extensions/cached-compaction/render.d.ts.map +1 -1
- package/dist/extensions/cached-compaction/render.js +3 -3
- package/dist/extensions/cached-compaction/render.js.map +1 -1
- package/dist/extensions/cached-compaction/summary.d.ts +1 -1
- package/dist/extensions/cached-compaction/summary.d.ts.map +1 -1
- package/dist/extensions/cached-compaction/summary.js +13 -16
- package/dist/extensions/cached-compaction/summary.js.map +1 -1
- package/dist/extensions/codemode/renderer.d.ts.map +1 -1
- package/dist/extensions/codemode/renderer.js +6 -2
- package/dist/extensions/codemode/renderer.js.map +1 -1
- package/dist/extensions/codemode/tool.d.ts +2 -1
- package/dist/extensions/codemode/tool.d.ts.map +1 -1
- package/dist/extensions/codemode/tool.js +33 -8
- package/dist/extensions/codemode/tool.js.map +1 -1
- package/dist/extensions/deepwiki/schema.d.ts.map +1 -1
- package/dist/extensions/deepwiki/schema.js +1 -1
- package/dist/extensions/deepwiki/schema.js.map +1 -1
- package/dist/extensions/llama/ui.d.ts.map +1 -1
- package/dist/extensions/llama/ui.js +16 -4
- package/dist/extensions/llama/ui.js.map +1 -1
- package/dist/extensions/mcp/cli.d.ts.map +1 -1
- package/dist/extensions/mcp/cli.js +34 -8
- package/dist/extensions/mcp/cli.js.map +1 -1
- package/dist/extensions/mcp/oauth.d.ts +1 -1
- package/dist/extensions/mcp/oauth.d.ts.map +1 -1
- package/dist/extensions/mcp/oauth.js +36 -13
- package/dist/extensions/mcp/oauth.js.map +1 -1
- package/dist/extensions/mcp/ui.d.ts +1 -0
- package/dist/extensions/mcp/ui.d.ts.map +1 -1
- package/dist/extensions/mcp/ui.js +33 -24
- package/dist/extensions/mcp/ui.js.map +1 -1
- package/dist/extensions/run-summary/index.d.ts +1 -1
- package/dist/extensions/run-summary/index.d.ts.map +1 -1
- package/dist/extensions/run-summary/index.js +11 -23
- package/dist/extensions/run-summary/index.js.map +1 -1
- package/dist/extensions/statusline/usage.d.ts.map +1 -1
- package/dist/extensions/statusline/usage.js +2 -1
- package/dist/extensions/statusline/usage.js.map +1 -1
- package/dist/extensions/tasks/tool/actions.d.ts +1 -2
- package/dist/extensions/tasks/tool/actions.d.ts.map +1 -1
- package/dist/extensions/tasks/tool/actions.js +7 -79
- package/dist/extensions/tasks/tool/actions.js.map +1 -1
- package/dist/extensions/tasks/tool/constants.d.ts +1 -3
- package/dist/extensions/tasks/tool/constants.d.ts.map +1 -1
- package/dist/extensions/tasks/tool/constants.js +1 -3
- package/dist/extensions/tasks/tool/constants.js.map +1 -1
- package/dist/extensions/tasks/tool/schema.d.ts +1 -2
- package/dist/extensions/tasks/tool/schema.d.ts.map +1 -1
- package/dist/extensions/tasks/tool/schema.js +7 -15
- package/dist/extensions/tasks/tool/schema.js.map +1 -1
- package/dist/extensions/tasks/tool/types.d.ts +1 -19
- package/dist/extensions/tasks/tool/types.d.ts.map +1 -1
- package/dist/extensions/tasks/tool/types.js.map +1 -1
- package/dist/extensions/tasks/tool.d.ts +1 -2
- package/dist/extensions/tasks/tool.d.ts.map +1 -1
- package/dist/extensions/tasks/tool.js +2 -4
- package/dist/extensions/tasks/tool.js.map +1 -1
- package/dist/extensions/tasks/ui/completion-render.d.ts +5 -1
- package/dist/extensions/tasks/ui/completion-render.d.ts.map +1 -1
- package/dist/extensions/tasks/ui/completion-render.js +25 -70
- package/dist/extensions/tasks/ui/completion-render.js.map +1 -1
- package/dist/extensions/tasks/ui/inspector.d.ts +1 -1
- package/dist/extensions/tasks/ui/inspector.d.ts.map +1 -1
- package/dist/extensions/tasks/ui/inspector.js +0 -6
- package/dist/extensions/tasks/ui/inspector.js.map +1 -1
- package/dist/extensions/tasks/ui/manager.d.ts +1 -1
- package/dist/extensions/tasks/ui/manager.d.ts.map +1 -1
- package/dist/extensions/tasks/ui/manager.js.map +1 -1
- package/dist/extensions/tasks/ui/render.d.ts +2 -16
- package/dist/extensions/tasks/ui/render.d.ts.map +1 -1
- package/dist/extensions/tasks/ui/render.js +3 -79
- package/dist/extensions/tasks/ui/render.js.map +1 -1
- package/dist/extensions/tasks/ui/views.d.ts +2 -4
- package/dist/extensions/tasks/ui/views.d.ts.map +1 -1
- package/dist/extensions/tasks/ui/views.js +3 -7
- package/dist/extensions/tasks/ui/views.js.map +1 -1
- package/dist/extensions/tool-presentation/fallback.d.ts.map +1 -0
- package/dist/{modes/interactive/tool-view → extensions/tool-presentation}/fallback.js +5 -5
- package/dist/extensions/tool-presentation/fallback.js.map +1 -0
- package/dist/extensions/tool-presentation/index.js +1 -1
- package/dist/extensions/tool-presentation/index.js.map +1 -1
- package/dist/{modes/interactive/tool-view → extensions/tool-presentation}/shell.d.ts +1 -1
- package/dist/extensions/tool-presentation/shell.d.ts.map +1 -0
- package/dist/{modes/interactive/tool-view → extensions/tool-presentation}/shell.js +3 -3
- package/dist/extensions/tool-presentation/shell.js.map +1 -0
- package/dist/extensions/tool-search/tool.d.ts +21 -6
- package/dist/extensions/tool-search/tool.d.ts.map +1 -1
- package/dist/extensions/tool-search/tool.js +104 -36
- package/dist/extensions/tool-search/tool.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +15 -8
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +5 -3
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +61 -45
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/config-selector-skills.d.ts +54 -0
- package/dist/modes/interactive/components/config-selector-skills.d.ts.map +1 -0
- package/dist/modes/interactive/components/config-selector-skills.js +178 -0
- package/dist/modes/interactive/components/config-selector-skills.js.map +1 -0
- package/dist/modes/interactive/components/config-selector.d.ts +2 -11
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +31 -181
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +7 -0
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-entry.js +2 -1
- package/dist/modes/interactive/components/custom-entry.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +2 -1
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts +2 -0
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +4 -0
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts +5 -0
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +103 -10
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/markdown-transform.d.ts +2 -1
- package/dist/modes/interactive/components/markdown-transform.d.ts.map +1 -1
- package/dist/modes/interactive/components/markdown-transform.js +3 -2
- package/dist/modes/interactive/components/markdown-transform.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +1 -0
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +17 -6
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts +1 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +13 -4
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +14 -3
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-search.d.ts +4 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-search.js +86 -22
- package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +2 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +15 -23
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-submenu.js +2 -0
- package/dist/modes/interactive/components/settings-submenu.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +7 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +48 -9
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts +1 -0
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +5 -6
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.d.ts +1 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.js +9 -1
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts +3 -1
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +4 -2
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/editor-host.d.ts.map +1 -1
- package/dist/modes/interactive/editor-host.js +3 -2
- package/dist/modes/interactive/editor-host.js.map +1 -1
- package/dist/modes/interactive/external-editor.d.ts +1 -0
- package/dist/modes/interactive/external-editor.d.ts.map +1 -1
- package/dist/modes/interactive/external-editor.js +17 -5
- package/dist/modes/interactive/external-editor.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +8 -12
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +169 -112
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/model-search.d.ts +10 -0
- package/dist/modes/interactive/model-search.d.ts.map +1 -1
- package/dist/modes/interactive/model-search.js +21 -0
- package/dist/modes/interactive/model-search.js.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts +10 -0
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +30 -23
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/interactive/tool-view/chat.d.ts +2 -2
- package/dist/modes/interactive/tool-view/chat.d.ts.map +1 -1
- package/dist/modes/interactive/tool-view/chat.js +22 -19
- package/dist/modes/interactive/tool-view/chat.js.map +1 -1
- package/dist/modes/interactive/transcript-layout.d.ts +2 -0
- package/dist/modes/interactive/transcript-layout.d.ts.map +1 -1
- package/dist/modes/interactive/transcript-layout.js +5 -2
- package/dist/modes/interactive/transcript-layout.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +1 -0
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +9 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +23 -23
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +1 -3
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +55 -4
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/utils/ansi.d.ts.map +1 -1
- package/dist/utils/ansi.js +5 -2
- package/dist/utils/ansi.js.map +1 -1
- package/dist/utils/clipboard-command.d.ts.map +1 -1
- package/dist/utils/clipboard-command.js +4 -0
- package/dist/utils/clipboard-command.js.map +1 -1
- package/dist/utils/git.d.ts +1 -1
- package/dist/utils/git.d.ts.map +1 -1
- package/dist/utils/git.js.map +1 -1
- package/dist/utils/image-resize-core.d.ts.map +1 -1
- package/dist/utils/image-resize-core.js +5 -3
- package/dist/utils/image-resize-core.js.map +1 -1
- package/dist/utils/open-browser.d.ts.map +1 -1
- package/dist/utils/open-browser.js +4 -1
- package/dist/utils/open-browser.js.map +1 -1
- package/dist/utils/paths.d.ts +17 -0
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +42 -1
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +14 -0
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/syntax-highlight.d.ts +5 -0
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js +7 -0
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +30 -35
- package/dist/utils/tools-manager.js.map +1 -1
- package/dist/utils/usage.d.ts +5 -0
- package/dist/utils/usage.d.ts.map +1 -0
- package/dist/utils/usage.js +16 -0
- package/dist/utils/usage.js.map +1 -0
- package/docs/bundled/README.md +1 -1
- package/docs/bundled/extensions/agent.md +7 -7
- package/docs/bundled/extensions/run-summary.md +4 -4
- package/docs/bundled/extensions/statusline.md +1 -1
- package/docs/bundled/tasks.md +12 -27
- package/docs/bundled/tool-presentation.md +2 -2
- package/docs/custom-provider.md +1 -1
- package/docs/environment-variables.md +2 -0
- package/docs/extensions.md +41 -28
- package/docs/keybindings.md +1 -1
- package/docs/llama-cpp.md +17 -12
- package/docs/mcp.md +6 -4
- package/docs/models-configuration.md +1 -1
- package/docs/models.md +7 -85
- package/docs/packages.md +26 -1
- package/docs/rpc.md +1 -1
- package/docs/sdk.md +10 -8
- package/docs/session-format.md +3 -3
- package/docs/sessions.md +10 -0
- package/docs/settings.md +5 -4
- package/docs/terminal-setup.md +2 -2
- package/docs/tmux.md +6 -0
- package/docs/tui.md +12 -7
- package/docs/usage.md +19 -9
- package/docs/windows.md +29 -0
- package/examples/extensions/README.md +2 -1
- package/examples/extensions/custom-provider-anthropic/index.ts +27 -31
- 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/debug-provider.ts +2 -2
- package/examples/extensions/gondolin/package-lock.json +19 -29
- package/examples/extensions/gondolin/package.json +2 -2
- package/examples/extensions/preset.ts +2 -0
- package/examples/extensions/reload-runtime.ts +17 -5
- package/examples/extensions/tools.ts +2 -0
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/package.json +11 -12
- package/schemas/models.schema.json +36 -36
- package/schemas/settings.schema.json +17 -0
- package/dist/bundle/chunks/anthropic-messages-HWL6AS7T.js +0 -6
- package/dist/bundle/chunks/azure-openai-responses-4YYPDYV5.js +0 -2
- package/dist/bundle/chunks/chunk-6GTUUUCJ.js +0 -1499
- package/dist/bundle/chunks/chunk-6JS2SOFO.js +0 -11
- package/dist/bundle/chunks/chunk-ANCZPKX7.js +0 -2
- package/dist/bundle/chunks/chunk-FEZ5RM2B.js +0 -2
- package/dist/bundle/chunks/chunk-LPF7HQ3S.js +0 -4
- package/dist/bundle/chunks/chunk-MMNIHCU7.js +0 -2
- package/dist/bundle/chunks/chunk-R267VV5T.js +0 -82
- package/dist/bundle/chunks/chunk-RVKT7OUB.js +0 -9
- package/dist/bundle/chunks/chunk-SA2AQYEI.js +0 -7
- package/dist/bundle/chunks/chunk-ZAIGBRV5.js +0 -16
- package/dist/bundle/chunks/mistral-conversations-V2JJTMJ5.js +0 -5
- package/dist/bundle/chunks/openai-completions-TXZXILJR.js +0 -7
- package/dist/bundle/chunks/pi-messages-LBJQ4NGP.js +0 -8
- package/dist/bundle/chunks/virtual-modules-6IJ6V2CG.js +0 -2
- package/dist/core/isolated-session.d.ts.map +0 -1
- package/dist/core/isolated-session.js.map +0 -1
- package/dist/core/tasks/wait.d.ts +0 -19
- package/dist/core/tasks/wait.d.ts.map +0 -1
- package/dist/core/tasks/wait.js +0 -45
- package/dist/core/tasks/wait.js.map +0 -1
- package/dist/modes/interactive/tool-view/fallback.d.ts.map +0 -1
- package/dist/modes/interactive/tool-view/fallback.js.map +0 -1
- package/dist/modes/interactive/tool-view/shell.d.ts.map +0 -1
- package/dist/modes/interactive/tool-view/shell.js.map +0 -1
- package/dist/modes/interactive/tool-view/tool-execution.d.ts +0 -14
- package/dist/modes/interactive/tool-view/tool-execution.d.ts.map +0 -1
- package/dist/modes/interactive/tool-view/tool-execution.js +0 -13
- package/dist/modes/interactive/tool-view/tool-execution.js.map +0 -1
- package/dist/utils/path-identity.d.ts +0 -12
- package/dist/utils/path-identity.d.ts.map +0 -1
- package/dist/utils/path-identity.js +0 -63
- package/dist/utils/path-identity.js.map +0 -1
- package/docs/images/doom-extension.png +0 -0
- package/docs/images/exy.png +0 -0
- package/examples/extensions/sandbox/index.ts +0 -321
- package/examples/extensions/sandbox/package-lock.json +0 -92
- package/examples/extensions/sandbox/package.json +0 -19
- package/npm-shrinkwrap.json +0 -4207
- /package/dist/{modes/interactive/tool-view → extensions/tool-presentation}/fallback.d.ts +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["../../../src/core/tasks/limits.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["../../../src/core/tasks/limits.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,qFAAqF;AACrF,iHAAiH;AACjH,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAExC,sCAAsC;AACtC,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAEhE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,GAAG,MAAM,GAAG,MAAM,CAEnF"}
|
|
@@ -1,35 +1,14 @@
|
|
|
1
|
-
import { finiteLimit } from "../../utils/number.js";
|
|
2
1
|
import { boundReadBytes } from "./output.js";
|
|
3
|
-
/**
|
|
4
|
-
* Shared observation-window limits, the one definition used by the runtime and the tasks tool.
|
|
5
|
-
* Execution timeouts are configured separately by each executor.
|
|
6
|
-
*
|
|
7
|
-
* A wait returns as soon as its task settles, and steering or another completion interrupts it, so
|
|
8
|
-
* the default only bounds how long a wait on unfinished work blocks before the model has control
|
|
9
|
-
* again. It is the longest window that stays inside the common five-minute prompt-cache lifetime,
|
|
10
|
-
* with a minute's margin for the request around it: a longer one makes the next request miss the
|
|
11
|
-
* cache or need a warming refresh.
|
|
12
|
-
*/
|
|
13
|
-
export const TASKS_WAIT_DEFAULT_MS = 4 * 60_000;
|
|
14
|
-
export const TASKS_WAIT_MIN_MS = 1_000;
|
|
15
|
-
export const TASKS_WAIT_MAX_MS = 10 * 60_000;
|
|
2
|
+
/** Shared read limits, the one definition used by the runtime and the tasks tool. */
|
|
16
3
|
/** Floor for a model-requested read slice; the default and ceiling are TASK_READ_BYTES and TASK_RESULT_BYTES. */
|
|
17
4
|
export const TASKS_READ_MIN_BYTES = 256;
|
|
18
|
-
/** The wait window the runtime honours: any finite value up to the ceiling, including 0. */
|
|
19
|
-
export function boundWaitMs(waitMs) {
|
|
20
|
-
return finiteLimit(waitMs, TASKS_WAIT_DEFAULT_MS, TASKS_WAIT_MAX_MS);
|
|
21
|
-
}
|
|
22
|
-
/** The wait window a tool call runs, which the pending-call renderer also shows. */
|
|
23
|
-
export function clampWaitMs(waitMs) {
|
|
24
|
-
return Math.max(TASKS_WAIT_MIN_MS, boundWaitMs(waitMs));
|
|
25
|
-
}
|
|
26
5
|
/** The read size a tool call runs. */
|
|
27
6
|
export function clampReadBytes(bytes) {
|
|
28
7
|
return Math.max(TASKS_READ_MIN_BYTES, boundReadBytes(bytes));
|
|
29
8
|
}
|
|
30
9
|
/**
|
|
31
|
-
* The end a read starts from when the caller names none, the one definition every read
|
|
32
|
-
*
|
|
10
|
+
* The end a read starts from when the caller names none, the one definition every read
|
|
11
|
+
* and projection shares: a report's beginning is its summary, a log's end is its outcome.
|
|
33
12
|
*/
|
|
34
13
|
export function defaultReadMode(task) {
|
|
35
14
|
return task.output === "report" ? "head" : "tail";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limits.js","sourceRoot":"","sources":["../../../src/core/tasks/limits.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"limits.js","sourceRoot":"","sources":["../../../src/core/tasks/limits.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG7C,qFAAqF;AACrF,iHAAiH;AACjH,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAExC,sCAAsC;AACtC,MAAM,UAAU,cAAc,CAAC,KAAyB;IACvD,OAAO,IAAI,CAAC,GAAG,CAAC,oBAAoB,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;AAC9D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,IAAkC;IACjE,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;AACnD,CAAC","sourcesContent":["import { boundReadBytes } from \"./output.ts\";\nimport type { TaskSnapshot } from \"./types.ts\";\n\n/** Shared read limits, the one definition used by the runtime and the tasks tool. */\n/** Floor for a model-requested read slice; the default and ceiling are TASK_READ_BYTES and TASK_RESULT_BYTES. */\nexport const TASKS_READ_MIN_BYTES = 256;\n\n/** The read size a tool call runs. */\nexport function clampReadBytes(bytes: number | undefined): number {\n\treturn Math.max(TASKS_READ_MIN_BYTES, boundReadBytes(bytes));\n}\n\n/**\n * The end a read starts from when the caller names none, the one definition every read\n * and projection shares: a report's beginning is its summary, a log's end is its outcome.\n */\nexport function defaultReadMode(task: Pick<TaskSnapshot, \"output\">): \"head\" | \"tail\" {\n\treturn task.output === \"report\" ? \"head\" : \"tail\";\n}\n"]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { type TaskPresenter, type TaskSnapshot } from "./types.ts";
|
|
1
|
+
import { type TaskSnapshot } from "./types.ts";
|
|
3
2
|
export declare const EXPIRED_OUTPUT = "Output has expired: the managed log was released; showing the stored result.";
|
|
4
3
|
type OutputCleanup = () => void | Promise<void>;
|
|
5
4
|
/**
|
|
@@ -21,16 +20,11 @@ export declare class TaskRecord {
|
|
|
21
20
|
private pins;
|
|
22
21
|
private cleanup?;
|
|
23
22
|
private expiredReason?;
|
|
24
|
-
private presenter?;
|
|
25
23
|
constructor(task: TaskSnapshot);
|
|
26
24
|
/** A terminal record rebuilt from persisted history: nothing is left to run or deliver. */
|
|
27
25
|
static restored(task: TaskSnapshot, readError: string | undefined): TaskRecord;
|
|
28
26
|
/** Terminal: nothing is left to run. Derived from the status so it can never disagree with it. */
|
|
29
27
|
get settled(): boolean;
|
|
30
|
-
/** The executor's live Output renderer; held in memory for a running task only. */
|
|
31
|
-
setPresenter(presenter: TaskPresenter | undefined): void;
|
|
32
|
-
/** Live Output while running; `undefined` once settled, without a presenter, or if the presenter throws. */
|
|
33
|
-
present(width: number, theme: Theme): string[] | undefined;
|
|
34
28
|
/** Called once, after the terminal snapshot is final. */
|
|
35
29
|
settle(): void;
|
|
36
30
|
update(mutate: (task: TaskSnapshot) => void): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../../../src/core/tasks/record.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../../../src/core/tasks/record.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/D,eAAO,MAAM,cAAc,iFAAiF,CAAC;AAU7G,KAAK,aAAa,GAAG,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAEhD;;;;;;GAMG;AACH,qBAAa,UAAU;IACtB,mEAAmE;IACnE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;IACtC,yFAAyF;IACzF,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;IACvC,OAAO,CAAC,MAAM,CAAC,CAAe;IAC9B,OAAO,CAAC,iBAAiB,CAAc;IACvC,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,IAAI,CAAK;IACjB,OAAO,CAAC,OAAO,CAAC,CAAgB;IAChC,OAAO,CAAC,aAAa,CAAC,CAAS;gBAEnB,IAAI,EAAE,YAAY;IAQ9B,2FAA2F;IAC3F,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU;IAO9E,kGAAkG;IAClG,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,yDAAyD;IACzD,MAAM,IAAI,IAAI;IAId,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,GAAG,IAAI;IAQlD,mGAAmG;IACnG,QAAQ,IAAI,YAAY;IAKxB,2DAA2D;IAC3D,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAIlC,6FAA6F;IAC7F,GAAG,IAAI,MAAM,IAAI;IAUjB,sEAAsE;IACtE,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,kFAAkF;IAClF,IAAI,SAAS,IAAI,MAAM,GAAG,SAAS,CAElC;IAED,gGAAgG;IAChG,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,IAAI;IAQzD;;;OAGG;IACH,YAAY,IAAI,aAAa,GAAG,SAAS;CAUzC"}
|
|
@@ -36,26 +36,8 @@ export class TaskRecord {
|
|
|
36
36
|
get settled() {
|
|
37
37
|
return isTaskTerminal(this.working.status);
|
|
38
38
|
}
|
|
39
|
-
/** The executor's live Output renderer; held in memory for a running task only. */
|
|
40
|
-
setPresenter(presenter) {
|
|
41
|
-
this.presenter = presenter;
|
|
42
|
-
}
|
|
43
|
-
/** Live Output while running; `undefined` once settled, without a presenter, or if the presenter throws. */
|
|
44
|
-
present(width, theme) {
|
|
45
|
-
if (this.settled || !this.presenter)
|
|
46
|
-
return undefined;
|
|
47
|
-
try {
|
|
48
|
-
const lines = this.presenter(width, theme);
|
|
49
|
-
return Array.isArray(lines) ? lines : undefined;
|
|
50
|
-
}
|
|
51
|
-
catch {
|
|
52
|
-
// An executor bug must not break the panel; it falls back to the default view.
|
|
53
|
-
return undefined;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
39
|
/** Called once, after the terminal snapshot is final. */
|
|
57
40
|
settle() {
|
|
58
|
-
this.presenter = undefined;
|
|
59
41
|
this.resolveSettlement();
|
|
60
42
|
}
|
|
61
43
|
update(mutate) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record.js","sourceRoot":"","sources":["../../../src/core/tasks/record.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"record.js","sourceRoot":"","sources":["../../../src/core/tasks/record.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAqB,MAAM,YAAY,CAAC;AAE/D,MAAM,CAAC,MAAM,cAAc,GAAG,8EAA8E,CAAC;AAE7G,SAAS,MAAM,CAAI,KAAQ;IAC1B,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5E,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;YAAE,MAAM,CAAC,KAAK,CAAC,CAAC;QACxD,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAID;;;;;;GAMG;AACH,MAAM,OAAO,UAAU;IAatB,YAAY,IAAkB;QALtB,aAAQ,GAAG,IAAI,CAAC;QAChB,SAAI,GAAG,CAAC,CAAC;QAKhB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;YAC/C,IAAI,CAAC,iBAAiB,GAAG,OAAO,CAAC;QAClC,CAAC,CAAC,CAAC;IACJ,CAAC;IAED,2FAA2F;IAC3F,MAAM,CAAC,QAAQ,CAAC,IAAkB,EAAE,SAA6B;QAChE,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;QACpC,MAAM,CAAC,aAAa,GAAG,SAAS,CAAC;QACjC,M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AAY,EAAE,OAAuB;QACjD,IAAI,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAC1E,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;YACpB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACxB,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,YAAY;QACX,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,OAAO,SAAS,CAAC;QACtE,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;QACzB,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;YACpB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC7B,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,aAAa,GAAG,cAAc,CAAC;QACpC,OAAO,OAAO,CAAC;IAChB,CAAC;CACD","sourcesContent":["import { isTaskTerminal, type TaskSnapshot } from \"./types.ts\";\n\nexport const EXPIRED_OUTPUT = \"Output has expired: the managed log was released; showing the stored result.\";\n\nfunction freeze<T>(value: T): T {\n\tif (value !== null && typeof value === \"object\" && !Object.isFrozen(value)) {\n\t\tfor (const child of Object.values(value)) freeze(child);\n\t\tObject.freeze(value);\n\t}\n\treturn value;\n}\n\ntype OutputCleanup = () => void | Promise<void>;\n\n/**\n * The runtime's state for one task: its working snapshot, whether it is on the selected branch,\n * the pins that keep it retained, and the managed output it owns. Whether a completion reached\n * the model is a session concern held outside the runtime as a pin. Every lifecycle fact changes\n * through a named method here; the working snapshot changes only through `update()`, which also\n * drops the frozen copy that readers share, so a mutation can never leave a stale snapshot behind.\n */\nexport class TaskRecord {\n\t/** Read-only view of the working copy; change it with update(). */\n\treadonly task: Readonly<TaskSnapshot>;\n\t/** Settles once the task is terminal and its final snapshot is stored. Never rejects. */\n\treadonly settlement: Promise<void>;\n\tprivate readonly working: TaskSnapshot;\n\tprivate frozen?: TaskSnapshot;\n\tprivate resolveSettlement!: () => void;\n\tprivate onBranch = true;\n\tprivate pins = 0;\n\tprivate cleanup?: OutputCleanup;\n\tprivate expiredReason?: string;\n\n\tconstructor(task: TaskSnapshot) {\n\t\tthis.working = task;\n\t\tthis.task = task;\n\t\tthis.settlement = new Promise<void>((resolve) => {\n\t\t\tthis.resolveSettlement = resolve;\n\t\t});\n\t}\n\n\t/** A terminal record rebuilt from persisted history: nothing is left to run or deliver. */\n\tstatic restored(task: TaskSnapshot, readError: string | undefined): TaskRecord {\n\t\tconst record = new TaskRecord(task);\n\t\trecord.expiredReason = readError;\n\t\trecord.settle();\n\t\treturn record;\n\t}\n\n\t/** Terminal: nothing is left to run. Derived from the status so it can never disagree with it. */\n\tget settled(): boolean {\n\t\treturn isTaskTerminal(this.working.status);\n\t}\n\n\t/** Called once, after the terminal snapshot is final. */\n\tsettle(): void {\n\t\tthis.resolveSettlement();\n\t}\n\n\tupdate(mutate: (task: TaskSnapshot) => void): void {\n\t\ttry {\n\t\t\tmutate(this.working);\n\t\t} finally {\n\t\t\tthis.frozen = undefined;\n\t\t}\n\t}\n\n\t/** Readers share one frozen copy, so polling and status rendering never clone unchanged output. */\n\tsnapshot(): TaskSnapshot {\n\t\tthis.frozen ??= freeze(structuredClone(this.working));\n\t\treturn this.frozen;\n\t}\n\n\t/** Whether the launch anchor is on the selected branch. */\n\tget visible(): boolean {\n\t\treturn this.onBranch;\n\t}\n\n\tsetVisible(visible: boolean): void {\n\t\tthis.onBranch = visible;\n\t}\n\n\t/** Keep the record, and its output, retained until the returned release runs. Idempotent. */\n\tpin(): () => void {\n\t\tthis.pins++;\n\t\tlet released = false;\n\t\treturn () => {\n\t\t\tif (released) return;\n\t\t\treleased = true;\n\t\t\tthis.pins--;\n\t\t};\n\t}\n\n\t/** Settled and unpinned: bounded history that retention may evict. */\n\tget inHistory(): boolean {\n\t\treturn this.settled && this.pins === 0;\n\t}\n\n\t/** Why the output could not be read from a log: it expired, or was never kept. */\n\tget readError(): string | undefined {\n\t\treturn this.expiredReason;\n\t}\n\n\t/** Register the one output file this task owns; `cleanup` deletes it when retention lets go. */\n\tattachOutput(path: string, cleanup?: OutputCleanup): void {\n\t\tif (this.cleanup) throw new Error(\"Managed output is already registered\");\n\t\tthis.cleanup = cleanup;\n\t\tthis.update((task) => {\n\t\t\ttask.outputPath = path;\n\t\t});\n\t}\n\n\t/**\n\t * Release the managed output once nothing retains it. Returns the owner's cleanup to run, if\n\t * any; the snapshot keeps its final bounded text, so an expired file is never needed again.\n\t */\n\texpireOutput(): OutputCleanup | undefined {\n\t\tif (!this.settled || this.pins > 0 || !this.cleanup) return undefined;\n\t\tconst cleanup = this.cleanup;\n\t\tthis.cleanup = undefined;\n\t\tthis.update((task) => {\n\t\t\ttask.outputPath = undefined;\n\t\t});\n\t\tthis.expiredReason = EXPIRED_OUTPUT;\n\t\treturn cleanup;\n\t}\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AgentMessage } from "@earendil-works/pi-agent-core";
|
|
2
|
-
import type
|
|
2
|
+
import { type TaskSnapshot } from "./types.ts";
|
|
3
3
|
/**
|
|
4
4
|
* A one-shot, request-local reminder after compaction. It is never persisted and
|
|
5
5
|
* creates no turn. Failed requests keep it eligible; an assistant response consumes it.
|
|
@@ -8,7 +8,8 @@ export declare class TaskContextReminder {
|
|
|
8
8
|
private pending;
|
|
9
9
|
private projected;
|
|
10
10
|
compacted(): void;
|
|
11
|
-
|
|
11
|
+
/** `runningBackground` is read only while a reminder is pending. */
|
|
12
|
+
project(messages: AgentMessage[], runningBackground: () => TaskSnapshot[]): AgentMessage[];
|
|
12
13
|
assistantCompleted(): void;
|
|
13
14
|
reset(): void;
|
|
14
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reminder.d.ts","sourceRoot":"","sources":["../../../src/core/tasks/reminder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAElE,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"reminder.d.ts","sourceRoot":"","sources":["../../../src/core/tasks/reminder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAElE,OAAO,EAAmB,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAOhE;;;GAGG;AACH,qBAAa,mBAAmB;IAC/B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,SAAS,CAAS;IAE1B,SAAS,IAAI,IAAI;IAKjB,oEAAoE;IACpE,OAAO,CAAC,QAAQ,EAAE,YAAY,EAAE,EAAE,iBAAiB,EAAE,MAAM,YAAY,EAAE,GAAG,YAAY,EAAE;IAyB1F,kBAAkB,IAAI,IAAI;IAI1B,KAAK,IAAI,IAAI;CAIb"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { boundText } from "./output.js";
|
|
2
|
-
import {
|
|
2
|
+
import { TASKS_TOOL_NAME } from "./types.js";
|
|
3
3
|
function taskLine(task) {
|
|
4
4
|
const title = boundText(task.title.replace(/\s+/gu, " ").trim(), 240);
|
|
5
5
|
return boundText(`${task.id} ${task.kind} ${task.status} ${title}`, 1024);
|
|
@@ -17,10 +17,11 @@ export class TaskContextReminder {
|
|
|
17
17
|
this.pending = true;
|
|
18
18
|
this.projected = false;
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
/** `runningBackground` is read only while a reminder is pending. */
|
|
21
|
+
project(messages, runningBackground) {
|
|
21
22
|
if (!this.pending)
|
|
22
23
|
return messages;
|
|
23
|
-
const tasks =
|
|
24
|
+
const tasks = runningBackground();
|
|
24
25
|
if (tasks.length === 0) {
|
|
25
26
|
this.reset();
|
|
26
27
|
return messages;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reminder.js","sourceRoot":"","sources":["../../../src/core/tasks/reminder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"reminder.js","sourceRoot":"","sources":["../../../src/core/tasks/reminder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,eAAe,EAAqB,MAAM,YAAY,CAAC;AAEhE,SAAS,QAAQ,CAAC,IAAkB;IACnC,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC;IACtE,OAAO,SAAS,CAAC,GAAG,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,IAAI,KAAK,EAAE,EAAE,IAAI,CAAC,CAAC;AAC3E,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,mBAAmB;IAAhC;QACS,YAAO,GAAG,KAAK,CAAC;QAChB,cAAS,GAAG,KAAK,CAAC;IAyC3B,CAAC;IAvCA,SAAS;QACR,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IACxB,CAAC;IAED,oEAAoE;IACpE,OAAO,CAAC,QAAwB,EAAE,iBAAuC;QACxE,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,OAAO,QAAQ,CAAC;QACnC,MAAM,KAAK,GAAG,iBAAiB,EAAE,CAAC;QAClC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,IAAI,CAAC,KAAK,EAAE,CAAC;YACb,OAAO,QAAQ,CAAC;QACjB,CAAC;QACD,MAAM,QAAQ,GAAiB;YAC9B,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE;gBACR;oBACC,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE;wBACL,0FAA0F;wBAC1F,OAAO,eAAe,uGAAuG;wBAC7H,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC;qBACtB,CAAC,IAAI,CAAC,IAAI,CAAC;iBACZ;aACD;YACD,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;SACrB,CAAC;QACF,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,OAAO,CAAC,GAAG,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAChC,CAAC;IAED,kBAAkB;QACjB,IAAI,IAAI,CAAC,SAAS;YAAE,IAAI,CAAC,KAAK,EAAE,CAAC;IAClC,CAAC;IAED,KAAK;QACJ,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IACxB,CAAC;CACD","sourcesContent":["import type { AgentMessage } from \"@earendil-works/pi-agent-core\";\nimport { boundText } from \"./output.ts\";\nimport { TASKS_TOOL_NAME, type TaskSnapshot } from \"./types.ts\";\n\nfunction taskLine(task: TaskSnapshot): string {\n\tconst title = boundText(task.title.replace(/\\s+/gu, \" \").trim(), 240);\n\treturn boundText(`${task.id} ${task.kind} ${task.status} ${title}`, 1024);\n}\n\n/**\n * A one-shot, request-local reminder after compaction. It is never persisted and\n * creates no turn. Failed requests keep it eligible; an assistant response consumes it.\n */\nexport class TaskContextReminder {\n\tprivate pending = false;\n\tprivate projected = false;\n\n\tcompacted(): void {\n\t\tthis.pending = true;\n\t\tthis.projected = false;\n\t}\n\n\t/** `runningBackground` is read only while a reminder is pending. */\n\tproject(messages: AgentMessage[], runningBackground: () => TaskSnapshot[]): AgentMessage[] {\n\t\tif (!this.pending) return messages;\n\t\tconst tasks = runningBackground();\n\t\tif (tasks.length === 0) {\n\t\t\tthis.reset();\n\t\t\treturn messages;\n\t\t}\n\t\tconst reminder: AgentMessage = {\n\t\t\trole: \"user\",\n\t\t\tcontent: [\n\t\t\t\t{\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\ttext: [\n\t\t\t\t\t\t\"Context was compacted. These background tasks are still active; do not start duplicates.\",\n\t\t\t\t\t\t`Use ${TASKS_TOOL_NAME} list/read/kill to inspect or stop them. Each completion wakes you automatically; do not wait for it.`,\n\t\t\t\t\t\t...tasks.map(taskLine),\n\t\t\t\t\t].join(\"\\n\"),\n\t\t\t\t},\n\t\t\t],\n\t\t\ttimestamp: Date.now(),\n\t\t};\n\t\tthis.projected = true;\n\t\treturn [...messages, reminder];\n\t}\n\n\tassistantCompleted(): void {\n\t\tif (this.projected) this.reset();\n\t}\n\n\treset(): void {\n\t\tthis.pending = false;\n\t\tthis.projected = false;\n\t}\n}\n"]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { AgentToolResult } from "@earendil-works/pi-agent-core";
|
|
2
|
-
import type
|
|
3
|
-
import { type TaskExecution, type TaskRead, type TaskReadOptions, type TaskRuntimeOptions, type TaskSnapshot, type TasksContext, type TaskToolOutcome, type TaskWaitAnyOptions, type TaskWaitAnyResult, type TaskWaitOptions, type TaskWaitResult } from "./types.ts";
|
|
2
|
+
import { type TaskExecution, type TaskRead, type TaskReadOptions, type TaskRuntimeOptions, type TaskSnapshot, type TasksContext, type TaskToolOutcome } from "./types.ts";
|
|
4
3
|
/** Session-local supervision. Executors own their processes, items and output files. */
|
|
5
4
|
export declare class TaskRuntime implements TasksContext {
|
|
6
5
|
private readonly store;
|
|
@@ -12,7 +11,6 @@ export declare class TaskRuntime implements TasksContext {
|
|
|
12
11
|
private readonly maxHistory;
|
|
13
12
|
private readonly maxRetained;
|
|
14
13
|
private readonly options;
|
|
15
|
-
private readonly closing;
|
|
16
14
|
private configuredEnabled;
|
|
17
15
|
private _closed;
|
|
18
16
|
constructor(options?: TaskRuntimeOptions);
|
|
@@ -32,8 +30,6 @@ export declare class TaskRuntime implements TasksContext {
|
|
|
32
30
|
refresh(): void;
|
|
33
31
|
/** Whether new work may move to or start in the background: enabled, and the host can manage it. */
|
|
34
32
|
private get admitsBackground();
|
|
35
|
-
/** Handed-off work that has not settled: the waitAny cohort and the statusline count. */
|
|
36
|
-
private activeBackground;
|
|
37
33
|
/**
|
|
38
34
|
* Foreground work is bounded by its caller; only background work holds a slot, including work
|
|
39
35
|
* whose caller is still waiting for the executor to accept (a detaching task).
|
|
@@ -51,16 +47,7 @@ export declare class TaskRuntime implements TasksContext {
|
|
|
51
47
|
private lookup;
|
|
52
48
|
get(id: string): TaskSnapshot;
|
|
53
49
|
read(id: string, options?: TaskReadOptions): Promise<TaskRead>;
|
|
54
|
-
presentOutput(id: string, width: number, theme: Theme): string[] | undefined;
|
|
55
50
|
private resultText;
|
|
56
|
-
/**
|
|
57
|
-
* One observation: hold delivery for the observed records, wait, read, then register the
|
|
58
|
-
* receipt with the host, and only then release. Nothing the caller does between those steps
|
|
59
|
-
* can leak a settled result into an automatic notification or lose it.
|
|
60
|
-
*/
|
|
61
|
-
private observe;
|
|
62
|
-
wait(id: string, options?: TaskWaitOptions): Promise<TaskWaitResult>;
|
|
63
|
-
waitAny(options?: TaskWaitAnyOptions): Promise<TaskWaitAnyResult>;
|
|
64
51
|
kill(id: string): boolean;
|
|
65
52
|
private cancel;
|
|
66
53
|
subscribe(listener: () => void): () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/core/tasks/runtime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/core/tasks/runtime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAiBrE,OAAO,EAIN,KAAK,aAAa,EAElB,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,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AIlB,gBAAgB,IAAI,MAAM;IAW1B,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAK9B,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAQ3B,kEAAkE;IAClE,OAAO,CAAC,SAAS;IAOjB,IAAI,IAAI,YAAY,EAAE;IAItB,OAAO,CAAC,MAAM;IAad,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,YAAY;IAIvB,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAuBxE,OAAO,CAAC,UAAU;IAIlB,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAIzB,OAAO,CAAC,MAAM;IAId,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;IAQ3C,yFAAyF;IACzF,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,IAAI;IAI9B,OAAO,CAAC,GAAG;IAQX,KAAK,IAAI,IAAI;IAYP,QAAQ,CAAC,OAAO,SAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAK7C,mFAAmF;IACnF,mBAAmB,CAAC,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,YAAY,EAAE;IAOnE;;;OAGG;IACG,mBAAmB,CAAC,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;YAW1D,KAAK;IAgBnB,OAAO,CAAC,IAAI;CAWZ"}
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import { finiteLimit } from "../../utils/number.js";
|
|
3
3
|
import { Execution } from "./execution.js";
|
|
4
|
-
import { defaultReadMode
|
|
4
|
+
import { defaultReadMode } from "./limits.js";
|
|
5
5
|
import { boundFacts, boundInput, boundText, errorText, readOutputSlice, sliceText, TASK_LABEL_BYTES, TASK_TITLE_BYTES, } from "./output.js";
|
|
6
6
|
import { TaskRecord } from "./record.js";
|
|
7
7
|
import { TaskScheduler } from "./scheduler.js";
|
|
8
8
|
import { TaskStore } from "./store.js";
|
|
9
9
|
import { TASK_BACKGROUND_REJECTION, TASK_KIND_PATTERN, TASK_MANAGEMENT_REJECTION, TaskLookupError, } from "./types.js";
|
|
10
|
-
import { waitForFirst } from "./wait.js";
|
|
11
10
|
/** Session-local supervision. Executors own their processes, items and output files. */
|
|
12
11
|
export class TaskRuntime {
|
|
13
12
|
constructor(options = {}) {
|
|
14
13
|
this.executions = new Map();
|
|
15
14
|
this.scheduler = new TaskScheduler();
|
|
16
15
|
this.listeners = new Set();
|
|
17
|
-
this.closing = new AbortController();
|
|
18
16
|
this._closed = false;
|
|
19
17
|
this.options = options;
|
|
20
18
|
this.configuredEnabled = options.enabled ?? false;
|
|
@@ -55,7 +53,7 @@ export class TaskRuntime {
|
|
|
55
53
|
this.store.restoreHistory(records, toolResults);
|
|
56
54
|
}
|
|
57
55
|
get enabled() {
|
|
58
|
-
return this.configuredEnabled && !this.closed
|
|
56
|
+
return this.configuredEnabled && !this.closed;
|
|
59
57
|
}
|
|
60
58
|
setEnabled(enabled) {
|
|
61
59
|
this.configuredEnabled = enabled;
|
|
@@ -69,10 +67,6 @@ export class TaskRuntime {
|
|
|
69
67
|
get admitsBackground() {
|
|
70
68
|
return this.enabled && (this.options.canManageBackground?.() ?? true);
|
|
71
69
|
}
|
|
72
|
-
/** Handed-off work that has not settled: the waitAny cohort and the statusline count. */
|
|
73
|
-
activeBackground() {
|
|
74
|
-
return this.store.unsettled().filter((record) => record.task.mode === "background");
|
|
75
|
-
}
|
|
76
70
|
/**
|
|
77
71
|
* Foreground work is bounded by its caller; only background work holds a slot, including work
|
|
78
72
|
* whose caller is still waiting for the executor to accept (a detaching task).
|
|
@@ -85,13 +79,11 @@ export class TaskRuntime {
|
|
|
85
79
|
}
|
|
86
80
|
async execute(execution) {
|
|
87
81
|
// Admission and registration happen synchronously, before invoking user code or awaiting anything.
|
|
88
|
-
if (execution.background && this.options.backgroundAllowed === false)
|
|
89
|
-
throw new Error(TASK_BACKGROUND_REJECTION);
|
|
90
82
|
if (this.closed)
|
|
91
83
|
throw new Error("Task service is closed");
|
|
92
84
|
if (execution.background) {
|
|
93
85
|
if (!this.enabled)
|
|
94
|
-
throw new Error(
|
|
86
|
+
throw new Error(TASK_BACKGROUND_REJECTION);
|
|
95
87
|
if (!this.admitsBackground)
|
|
96
88
|
throw new Error(TASK_MANAGEMENT_REJECTION);
|
|
97
89
|
if (this.backgroundActive() >= this.maxBackground)
|
|
@@ -125,7 +117,6 @@ export class TaskRuntime {
|
|
|
125
117
|
startedAt: Date.now(),
|
|
126
118
|
};
|
|
127
119
|
const record = new TaskRecord(task);
|
|
128
|
-
record.setPresenter(execution.present);
|
|
129
120
|
const active = new Execution(this.host, record, execution);
|
|
130
121
|
this.store.add(record);
|
|
131
122
|
this.executions.set(task.id, active);
|
|
@@ -212,92 +203,9 @@ export class TaskRuntime {
|
|
|
212
203
|
release();
|
|
213
204
|
}
|
|
214
205
|
}
|
|
215
|
-
presentOutput(id, width, theme) {
|
|
216
|
-
let record;
|
|
217
|
-
try {
|
|
218
|
-
record = this.lookup(id);
|
|
219
|
-
}
|
|
220
|
-
catch {
|
|
221
|
-
return undefined;
|
|
222
|
-
}
|
|
223
|
-
return record.present(width, theme);
|
|
224
|
-
}
|
|
225
206
|
resultText(task) {
|
|
226
207
|
return task.result?.text || task.error || "No output yet.";
|
|
227
208
|
}
|
|
228
|
-
/**
|
|
229
|
-
* One observation: hold delivery for the observed records, wait, read, then register the
|
|
230
|
-
* receipt with the host, and only then release. Nothing the caller does between those steps
|
|
231
|
-
* can leak a settled result into an automatic notification or lose it.
|
|
232
|
-
*/
|
|
233
|
-
async observe(records, options,
|
|
234
|
-
/** Record to read when none settled; a cohort has none. */
|
|
235
|
-
fallback) {
|
|
236
|
-
const { signal } = options;
|
|
237
|
-
// Retention pins the records; the host keeps them out of automatic delivery until released.
|
|
238
|
-
const releases = records.map((record) => this.pin(record));
|
|
239
|
-
releases.push(this.options.waits?.hold(records.map((record) => record.task.id)) ?? (() => { }));
|
|
240
|
-
try {
|
|
241
|
-
const start = Date.now();
|
|
242
|
-
const interrupt = this.options.waits?.interruptSignal;
|
|
243
|
-
await waitForFirst({
|
|
244
|
-
hasSettled: () => records.some((record) => record.settled),
|
|
245
|
-
subscribe: (listener) => this.subscribe(listener),
|
|
246
|
-
timeoutMs: options.timeoutMs ?? TASKS_WAIT_DEFAULT_MS,
|
|
247
|
-
signal,
|
|
248
|
-
interrupt,
|
|
249
|
-
closed: this.closing.signal,
|
|
250
|
-
});
|
|
251
|
-
const waitedMs = Date.now() - start;
|
|
252
|
-
const settled = records
|
|
253
|
-
.filter((record) => record.settled)
|
|
254
|
-
.sort((left, right) => (left.task.endedAt ?? 0) - (right.task.endedAt ?? 0))[0];
|
|
255
|
-
const outcome = settled
|
|
256
|
-
? "settled"
|
|
257
|
-
: this.closed
|
|
258
|
-
? "closed"
|
|
259
|
-
: interrupt?.aborted
|
|
260
|
-
? "interrupted"
|
|
261
|
-
: "timed_out";
|
|
262
|
-
const running = records
|
|
263
|
-
.filter((record) => record.visible && !record.settled)
|
|
264
|
-
.map((record) => record.snapshot());
|
|
265
|
-
const observed = settled ?? fallback;
|
|
266
|
-
const read = options.read && observed && outcome !== "interrupted"
|
|
267
|
-
? await this.read(observed.task.id, options.read)
|
|
268
|
-
: undefined;
|
|
269
|
-
signal?.throwIfAborted();
|
|
270
|
-
if (settled && settled.task.mode === "background" && options.toolCallId)
|
|
271
|
-
this.options.waits?.bind(options.toolCallId, settled.task.id);
|
|
272
|
-
return { outcome, waitedMs, settled, running, read };
|
|
273
|
-
}
|
|
274
|
-
finally {
|
|
275
|
-
for (const release of releases)
|
|
276
|
-
release();
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
async wait(id, options = {}) {
|
|
280
|
-
if (options.signal?.aborted)
|
|
281
|
-
throw options.signal.reason ?? new Error("Wait aborted");
|
|
282
|
-
const record = this.lookup(id);
|
|
283
|
-
const { outcome, waitedMs, read } = await this.observe([record], options, record);
|
|
284
|
-
return { outcome, waitedMs, task: record.snapshot(), ...(read ? { read } : {}) };
|
|
285
|
-
}
|
|
286
|
-
async waitAny(options = {}) {
|
|
287
|
-
if (options.signal?.aborted)
|
|
288
|
-
throw options.signal.reason ?? new Error("Wait aborted");
|
|
289
|
-
const records = this.activeBackground().filter((record) => record.visible);
|
|
290
|
-
if (records.length === 0)
|
|
291
|
-
return { outcome: "no_tasks", waitedMs: 0, running: [] };
|
|
292
|
-
const { outcome, waitedMs, settled, running, read } = await this.observe(records, options);
|
|
293
|
-
return {
|
|
294
|
-
outcome,
|
|
295
|
-
waitedMs,
|
|
296
|
-
running,
|
|
297
|
-
...(settled ? { task: settled.snapshot() } : {}),
|
|
298
|
-
...(read ? { read } : {}),
|
|
299
|
-
};
|
|
300
|
-
}
|
|
301
209
|
kill(id) {
|
|
302
210
|
return this.cancel(this.lookup(id));
|
|
303
211
|
}
|
|
@@ -332,7 +240,6 @@ export class TaskRuntime {
|
|
|
332
240
|
this.executions.get(record.task.id)?.releaseParent();
|
|
333
241
|
this.cancel(record);
|
|
334
242
|
}
|
|
335
|
-
this.closing.abort();
|
|
336
243
|
this.options.onClosed?.();
|
|
337
244
|
this.store.trim();
|
|
338
245
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../../src/core/tasks/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAsB,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EACN,UAAU,EACV,UAAU,EACV,SAAS,EACT,SAAS,EACT,eAAe,EACf,SAA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F,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CACzB;gBACD,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;oBAC7B,KAAK,GAAG,UAAU,CAAC,OAAO,EAAE,WAAW,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;gBACjE,CAAC,CAAC;aACF,CAAC,CAAC;QACJ,CAAC;gBAAS,CAAC;YACV,IAAI,KAAK,KAAK,SAAS;gBAAE,YAAY,CAAC,KAAK,CAAC,CAAC;QAC9C,CAAC;IACF,CAAC;IAEO,IAAI;QACX,IAAI,IAAI,CAAC,MAAM;YAAE,OAAO;QACxB,KAAK,MAAM,QAAQ,IAAI,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YAC5C,IAAI,IAAI,CAAC,MAAM;gBAAE,MAAM;YACvB,IAAI,CAAC;gBACJ,QAAQ,EAAE,CAAC;YACZ,CAAC;YAAC,MAAM,CAAC;gBACR,iDAAiD;YAClD,CAAC;QACF,CAAC;IACF,CAAC;CACD","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport type { AgentToolResult } from \"@earendil-works/pi-agent-core\";\nimport type { Theme } from \"../../modes/interactive/theme/theme.ts\";\nimport { finiteLimit } from \"../../utils/number.ts\";\nimport { Execution, type ExecutionHost } from \"./execution.ts\";\nimport { defaultReadMode, TASKS_WAIT_DEFAULT_MS } from \"./limits.ts\";\nimport {\n\tboundFacts,\n\tboundInput,\n\tboundText,\n\terrorText,\n\treadOutputSlice,\n\tsliceText,\n\tTASK_LABEL_BYTES,\n\tTASK_TITLE_BYTES,\n} from \"./output.ts\";\nimport { TaskRecord } from \"./record.ts\";\nimport { TaskScheduler } from \"./scheduler.ts\";\nimport { TaskStore } from \"./store.ts\";\nimport {\n\tTASK_BACKGROUND_REJECTION,\n\tTASK_KIND_PATTERN,\n\tTASK_MANAGEMENT_REJECTION,\n\ttype TaskExecution,\n\tTaskLookupError,\n\ttype TaskRead,\n\ttype TaskReadOptions,\n\ttype TaskRuntimeOptions,\n\ttype TaskSnapshot,\n\ttype TasksContext,\n\ttype TaskToolOutcome,\n\ttype TaskWaitAnyOptions,\n\ttype TaskWaitAnyResult,\n\ttype TaskWaitOptions,\n\ttype TaskWaitOutcome,\n\ttype TaskWaitResult,\n} from \"./types.ts\";\nimport { waitForFirst } from \"./wait.ts\";\n\n/** Session-local supervision. Executors own their processes, items and output files. */\nexport class TaskRuntime implements TasksContext {\n\tprivate readonly store: TaskStore;\n\tprivate readonly executions = new Map<string, Execution<unknown>>();\n\tprivate readonly scheduler = new TaskScheduler();\n\tprivate readonly listeners = new Set<() => void>();\n\tprivate readonly host: ExecutionHost;\n\tprivate readonly maxBackground: number;\n\tprivate readonly maxHistory: number;\n\tprivate readonly maxRetained: number;\n\tprivate readonly options: TaskRuntimeOptions;\n\tprivate readonly closing = new AbortController();\n\tprivate configuredEnabled: boolean;\n\tprivate _closed = false;\n\n\tconstructor(options: TaskRuntimeOptions = {}) {\n\t\tthis.options = options;\n\t\tthis.configuredEnabled = options.enabled ?? false;\n\t\tthis.maxBackground = Math.max(1, finiteLimit(options.maxBackground, 8, 128));\n\t\tthis.maxHistory = finiteLimit(options.maxHistory, 32, 1024);\n\t\t// Separate foreground and background histories, plus the protected-record allowance.\n\t\tthis.maxRetained = this.maxBackground + 2 * Math.max(1, this.maxHistory) + this.maxHistory;\n\t\tthis.store = new TaskStore(this.maxHistory, this.maxRetained, () => this.closed, options.onCleanupError);\n\t\tconst runtime = this;\n\t\tthis.host = {\n\t\t\tget closed() {\n\t\t\t\treturn runtime.closed;\n\t\t\t},\n\t\t\temit: () => this.emit(),\n\t\t\tsettle: (task, usage) => this.options.onSettled?.(task, usage),\n\t\t\treleased: (execution) => {\n\t\t\t\tthis.executions.delete(execution.task.id);\n\t\t\t\tthis.scheduler.release(execution);\n\t\t\t\tthis.store.trim();\n\t\t\t\tthis.emit();\n\t\t\t},\n\t\t};\n\t}\n\n\tget closed(): boolean {\n\t\treturn this._closed;\n\t}\n\n\tget session(): TaskRuntimeOptions[\"session\"] {\n\t\treturn this.options.session;\n\t}\n\n\t/**\n\t * Rehydrate terminal snapshots only, newest endedAt in each history (later input wins\n\t * ties). Existing runtime records win ID collisions. No execution, accounting,\n\t * notification, or deletion ownership is restored. Foreground records take their output\n\t * from the branch's tool results. The host supplies the current branch; closed services\n\t * ignore restoration.\n\t */\n\trestoreHistory(\n\t\trecords: readonly unknown[],\n\t\ttoolResults?: ReadonlyMap<string, AgentToolResult<unknown>[\"content\"]>,\n\t): void {\n\t\tthis.store.restoreHistory(records, toolResults);\n\t}\n\n\tget enabled(): boolean {\n\t\treturn this.configuredEnabled && !this.closed && this.options.backgroundAllowed !== false;\n\t}\n\n\tsetEnabled(enabled: boolean): void {\n\t\tthis.configuredEnabled = enabled;\n\t\tthis.emit();\n\t}\n\n\t/** Tell subscribers that something the runtime reads from its host changed, such as `canManageBackground`. */\n\trefresh(): void {\n\t\tthis.emit();\n\t}\n\n\t/** Whether new work may move to or start in the background: enabled, and the host can manage it. */\n\tprivate get admitsBackground(): boolean {\n\t\treturn this.enabled && (this.options.canManageBackground?.() ?? true);\n\t}\n\n\t/** Handed-off work that has not settled: the waitAny cohort and the statusline count. */\n\tprivate activeBackground(): TaskRecord[] {\n\t\treturn this.store.unsettled().filter((record) => record.task.mode === \"background\");\n\t}\n\n\t/**\n\t * Foreground work is bounded by its caller; only background work holds a slot, including work\n\t * whose caller is still waiting for the executor to accept (a detaching task).\n\t */\n\tprivate backgroundActive(): number {\n\t\treturn [...this.executions.values()].filter((execution) => execution.holdsBackgroundSlot).length;\n\t}\n\n\tprivate limitError(): Error {\n\t\treturn new Error(\n\t\t\t`Background task limit reached (${this.maxBackground}); stop or wait for a background task, or run in the foreground.`,\n\t\t);\n\t}\n\n\tasync execute<T>(execution: TaskExecution<T>): Promise<TaskToolOutcome<T>> {\n\t\t// Admission and registration happen synchronously, before invoking user code or awaiting anything.\n\t\tif (execution.background && this.options.backgroundAllowed === false) throw new Error(TASK_BACKGROUND_REJECTION);\n\t\tif (this.closed) throw new Error(\"Task service is closed\");\n\t\tif (execution.background) {\n\t\t\tif (!this.enabled) throw new Error(\"Background execution is not available in this host\");\n\t\t\tif (!this.admitsBackground) throw new Error(TASK_MANAGEMENT_REJECTION);\n\t\t\tif (this.backgroundActive() >= this.maxBackground) throw this.limitError();\n\t\t\tif (this.store.retainedCount() >= this.maxRetained) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Task history retention limit reached; deliver pending notifications or release task pins and delivery leases\",\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tif (execution.signal?.aborted) throw execution.signal.reason ?? new Error(\"Execution aborted\");\n\t\tif (!TASK_KIND_PATTERN.test(execution.kind)) throw new Error(\"Invalid task source\");\n\t\tconst concurrency = execution.concurrency;\n\t\tif (concurrency && (!concurrency.key || !Number.isSafeInteger(concurrency.limit) || concurrency.limit < 1))\n\t\t\tthrow new Error(\"Invalid task concurrency\");\n\t\tconst anchorId = this.options.anchor?.() ?? null;\n\t\tif (anchorId !== null && Buffer.byteLength(anchorId) > 8192) throw new Error(\"Task branch anchor is too large\");\n\t\tconst task: TaskSnapshot = {\n\t\t\tid: `${execution.kind}-${randomUUID()}`,\n\t\t\tkind: execution.kind,\n\t\t\tlabel: boundText(execution.label ?? execution.kind, TASK_LABEL_BYTES),\n\t\t\ttitle: boundText(execution.title, TASK_TITLE_BYTES),\n\t\t\toutput: execution.output ?? \"log\",\n\t\t\t...(execution.input ? { input: boundInput(execution.input) } : {}),\n\t\t\t...(execution.facts?.length ? { facts: boundFacts(execution.facts) } : {}),\n\t\t\ttoolCallId: boundText(execution.toolCallId, 512),\n\t\t\tanchorId,\n\t\t\tmode: \"foreground\",\n\t\t\tstatus: \"queued\",\n\t\t\tstartedAt: Date.now(),\n\t\t};\n\t\tconst record = new TaskRecord(task);\n\t\trecord.setPresenter(execution.present);\n\t\tconst active = new Execution(this.host, record, execution);\n\t\tthis.store.add(record);\n\t\tthis.executions.set(task.id, active as Execution<unknown>);\n\t\tthis.scheduler.schedule(active);\n\t\t// Queued background work returns at once; started work hands off after its own accept().\n\t\tactive.handOffIfQueued();\n\t\tthis.emit();\n\t\treturn active.caller;\n\t}\n\n\tprivate detachable(record: TaskRecord): boolean {\n\t\treturn this.executions.get(record.task.id)?.detachable ?? false;\n\t}\n\n\tdetachForeground(): number {\n\t\tif (!this.admitsBackground) return 0;\n\t\tconst eligible = [...this.executions.values()]\n\t\t\t.filter((execution) => execution.detachable)\n\t\t\t.sort((left, right) => left.task.startedAt - right.task.startedAt);\n\t\tif (!eligible.length) return 0;\n\t\tconst free = this.maxBackground - this.backgroundActive();\n\t\tif (free <= 0) throw this.limitError();\n\t\treturn this.detachAll(eligible.slice(0, free));\n\t}\n\n\tcanDetach(id: string): boolean {\n\t\tconst record = this.lookup(id);\n\t\treturn this.admitsBackground && this.backgroundActive() < this.maxBackground && this.detachable(record);\n\t}\n\n\tdetach(id: string): boolean {\n\t\tconst record = this.lookup(id);\n\t\tif (!this.admitsBackground || !this.detachable(record)) return false;\n\t\tif (this.backgroundActive() >= this.maxBackground) throw this.limitError();\n\t\tthis.detachAll([this.executions.get(record.task.id)!]);\n\t\treturn true;\n\t}\n\n\t/** Every placement changes before any listener hears about it. */\n\tprivate detachAll(executions: Execution<unknown>[]): number {\n\t\tconst notifications = executions.map((execution) => execution.detach());\n\t\tfor (const notify of notifications) notify();\n\t\tthis.emit();\n\t\treturn executions.length;\n\t}\n\n\tlist(): TaskSnapshot[] {\n\t\treturn this.store.visible().map((record) => record.snapshot());\n\t}\n\n\tprivate lookup(id: string): TaskRecord {\n\t\tconst exact = this.store.get(id);\n\t\tif (exact) return exact;\n\t\tconst matches = this.store.match(id);\n\t\tif (!id || matches.length !== 1) {\n\t\t\tthrow new TaskLookupError(\n\t\t\t\tmatches.length > 1 ? \"ambiguous\" : \"unknown\",\n\t\t\t\tmatches.map((record) => record.snapshot()),\n\t\t\t);\n\t\t}\n\t\treturn matches[0]!;\n\t}\n\n\tget(id: string): TaskSnapshot {\n\t\treturn this.lookup(id).snapshot();\n\t}\n\n\tasync read(id: string, options: TaskReadOptions = {}): Promise<TaskRead> {\n\t\tconst record = this.lookup(id);\n\t\tconst release = this.retain(record.task.id);\n\t\ttry {\n\t\t\tconst task = record.snapshot();\n\t\t\tconst window = { ...options, mode: options.mode ?? defaultReadMode(task) };\n\t\t\tif (task.outputPath) {\n\t\t\t\ttry {\n\t\t\t\t\treturn { task, ...(await readOutputSlice(task.outputPath, window)) };\n\t\t\t\t} catch (error) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttask,\n\t\t\t\t\t\treadError: boundText(`Output could not be read: ${errorText(error)}`, 4096),\n\t\t\t\t\t\t...sliceText(this.resultText(task), window),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn { task, readError: record.readError, ...sliceText(this.resultText(task), window) };\n\t\t} finally {\n\t\t\trelease();\n\t\t}\n\t}\n\n\tpresentOutput(id: string, width: number, theme: Theme): string[] | undefined {\n\t\tlet record: TaskRecord;\n\t\ttry {\n\t\t\trecord = this.lookup(id);\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn record.present(width, theme);\n\t}\n\n\tprivate resultText(task: TaskSnapshot): string {\n\t\treturn task.result?.text || task.error || \"No output yet.\";\n\t}\n\n\t/**\n\t * One observation: hold delivery for the observed records, wait, read, then register the\n\t * receipt with the host, and only then release. Nothing the caller does between those steps\n\t * can leak a settled result into an automatic notification or lose it.\n\t */\n\tprivate async observe(\n\t\trecords: readonly TaskRecord[],\n\t\toptions: TaskWaitOptions,\n\t\t/** Record to read when none settled; a cohort has none. */\n\t\tfallback?: TaskRecord,\n\t): Promise<{\n\t\toutcome: TaskWaitOutcome;\n\t\twaitedMs: number;\n\t\tsettled?: TaskRecord;\n\t\trunning: TaskSnapshot[];\n\t\tread?: TaskRead;\n\t}> {\n\t\tconst { signal } = options;\n\t\t// Retention pins the records; the host keeps them out of automatic delivery until released.\n\t\tconst releases = records.map((record) => this.pin(record));\n\t\treleases.push(this.options.waits?.hold(records.map((record) => record.task.id)) ?? (() => {}));\n\t\ttry {\n\t\t\tconst start = Date.now();\n\t\t\tconst interrupt = this.options.waits?.interruptSignal;\n\t\t\tawait waitForFirst({\n\t\t\t\thasSettled: () => records.some((record) => record.settled),\n\t\t\t\tsubscribe: (listener) => this.subscribe(listener),\n\t\t\t\ttimeoutMs: options.timeoutMs ?? TASKS_WAIT_DEFAULT_MS,\n\t\t\t\tsignal,\n\t\t\t\tinterrupt,\n\t\t\t\tclosed: this.closing.signal,\n\t\t\t});\n\t\t\tconst waitedMs = Date.now() - start;\n\t\t\tconst settled = records\n\t\t\t\t.filter((record) => record.settled)\n\t\t\t\t.sort((left, right) => (left.task.endedAt ?? 0) - (right.task.endedAt ?? 0))[0];\n\t\t\tconst outcome: TaskWaitOutcome = settled\n\t\t\t\t? \"settled\"\n\t\t\t\t: this.closed\n\t\t\t\t\t? \"closed\"\n\t\t\t\t\t: interrupt?.aborted\n\t\t\t\t\t\t? \"interrupted\"\n\t\t\t\t\t\t: \"timed_out\";\n\t\t\tconst running = records\n\t\t\t\t.filter((record) => record.visible && !record.settled)\n\t\t\t\t.map((record) => record.snapshot());\n\t\t\tconst observed = settled ?? fallback;\n\t\t\tconst read =\n\t\t\t\toptions.read && observed && outcome !== \"interrupted\"\n\t\t\t\t\t? await this.read(observed.task.id, options.read)\n\t\t\t\t\t: undefined;\n\t\t\tsignal?.throwIfAborted();\n\t\t\tif (settled && settled.task.mode === \"background\" && options.toolCallId)\n\t\t\t\tthis.options.waits?.bind(options.toolCallId, settled.task.id);\n\t\t\treturn { outcome, waitedMs, settled, running, read };\n\t\t} finally {\n\t\t\tfor (const release of releases) release();\n\t\t}\n\t}\n\n\tasync wait(id: string, options: TaskWaitOptions = {}): Promise<TaskWaitResult> {\n\t\tif (options.signal?.aborted) throw options.signal.reason ?? new Error(\"Wait aborted\");\n\t\tconst record = this.lookup(id);\n\t\tconst { outcome, waitedMs, read } = await this.observe([record], options, record);\n\t\treturn { outcome, waitedMs, task: record.snapshot(), ...(read ? { read } : {}) };\n\t}\n\n\tasync waitAny(options: TaskWaitAnyOptions = {}): Promise<TaskWaitAnyResult> {\n\t\tif (options.signal?.aborted) throw options.signal.reason ?? new Error(\"Wait aborted\");\n\t\tconst records = this.activeBackground().filter((record) => record.visible);\n\t\tif (records.length === 0) return { outcome: \"no_tasks\", waitedMs: 0, running: [] };\n\t\tconst { outcome, waitedMs, settled, running, read } = await this.observe(records, options);\n\t\treturn {\n\t\t\toutcome,\n\t\t\twaitedMs,\n\t\t\trunning,\n\t\t\t...(settled ? { task: settled.snapshot() } : {}),\n\t\t\t...(read ? { read } : {}),\n\t\t};\n\t}\n\n\tkill(id: string): boolean {\n\t\treturn this.cancel(this.lookup(id));\n\t}\n\n\tprivate cancel(record: TaskRecord): boolean {\n\t\treturn this.executions.get(record.task.id)?.cancel() ?? false;\n\t}\n\n\tsubscribe(listener: () => void): () => void {\n\t\tif (this.closed) return () => {};\n\t\tthis.listeners.add(listener);\n\t\treturn () => {\n\t\t\tthis.listeners.delete(listener);\n\t\t};\n\t}\n\n\t/** Retention protects snapshots and logs only; completion delivery never waits on it. */\n\tretain(id: string): () => void {\n\t\treturn this.pin(this.lookup(id));\n\t}\n\n\tprivate pin(record: TaskRecord): () => void {\n\t\tconst release = record.pin();\n\t\treturn () => {\n\t\t\trelease();\n\t\t\tthis.store.trim();\n\t\t};\n\t}\n\n\tclose(): void {\n\t\tif (this.closed) return;\n\t\tthis._closed = true;\n\t\tthis.listeners.clear();\n\t\tfor (const record of this.store.all()) {\n\t\t\tthis.executions.get(record.task.id)?.releaseParent();\n\t\t\tthis.cancel(record);\n\t\t}\n\t\tthis.closing.abort();\n\t\tthis.options.onClosed?.();\n\t\tthis.store.trim();\n\t}\n\n\tasync shutdown(graceMs = 2000): Promise<void> {\n\t\tthis.close();\n\t\tawait this.drain(this.store.all(), graceMs);\n\t}\n\n\t/** Running tasks whose launch anchor is outside the branch made of `ancestors`. */\n\tactiveOutsideBranch(ancestors: ReadonlySet<string>): TaskSnapshot[] {\n\t\treturn this.store\n\t\t\t.unsettled()\n\t\t\t.filter((record) => record.task.anchorId !== null && !ancestors.has(record.task.anchorId))\n\t\t\t.map((record) => record.snapshot());\n\t}\n\n\t/**\n\t * Hidden results stay pending: returning to their branch delivers them again.\n\t * Restored history is already delivered.\n\t */\n\tasync cancelOutsideBranch(ancestors: ReadonlySet<string>): Promise<void> {\n\t\tconst records = this.store.all();\n\t\tfor (const record of records)\n\t\t\trecord.setVisible(record.task.anchorId === null || ancestors.has(record.task.anchorId));\n\t\tconst outside = records.filter((record) => !record.visible);\n\t\tfor (const record of outside) this.cancel(record);\n\t\tthis.store.trim();\n\t\tthis.emit();\n\t\tawait this.drain(outside, 2000);\n\t}\n\n\tprivate async drain(records: TaskRecord[], graceMs: number): Promise<void> {\n\t\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\t\ttry {\n\t\t\tawait Promise.race([\n\t\t\t\tPromise.all(records.map((record) => this.executions.get(record.task.id)?.done)).then(() =>\n\t\t\t\t\tthis.store.cleanupsDone(),\n\t\t\t\t),\n\t\t\t\tnew Promise<void>((resolve) => {\n\t\t\t\t\ttimer = setTimeout(resolve, finiteLimit(graceMs, 2000, 60_000));\n\t\t\t\t}),\n\t\t\t]);\n\t\t} finally {\n\t\t\tif (timer !== undefined) clearTimeout(timer);\n\t\t}\n\t}\n\n\tprivate emit(): void {\n\t\tif (this.closed) return;\n\t\tfor (const listener of [...this.listeners]) {\n\t\t\tif (this.closed) break;\n\t\t\ttry {\n\t\t\t\tlistener();\n\t\t\t} catch {\n\t\t\t\t/* Observers do not own execution or delivery. */\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../../src/core/tasks/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE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CAAC;QACrD,IAAI,CAAC;YACJ,MAAM,OAAO,CAAC,IAAI,CAAC;gBAClB,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CACzF,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CACzB;gBACD,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;oBAC7B,KAAK,GAAG,UAAU,CAAC,OAAO,EAAE,WAAW,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;gBACjE,CAAC,CAAC;aACF,CAAC,CAAC;QACJ,CAAC;gBAAS,CAAC;YACV,IAAI,KAAK,KAAK,SAAS;gBAAE,YAAY,CAAC,KAAK,CAAC,CAAC;QAC9C,CAAC;IACF,CAAC;IAEO,IAAI;QACX,IAAI,IAAI,CAAC,MAAM;YAAE,OAAO;QACxB,KAAK,MAAM,QAAQ,IAAI,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YAC5C,IAAI,IAAI,CAAC,MAAM;gBAAE,MAAM;YACvB,IAAI,CAAC;gBACJ,QAAQ,EAAE,CAAC;YACZ,CAAC;YAAC,MAAM,CAAC;gBACR,iDAAiD;YAClD,CAAC;QACF,CAAC;IACF,CAAC;CACD","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport type { AgentToolResult } from \"@earendil-works/pi-agent-core\";\nimport { finiteLimit } from \"../../utils/number.ts\";\nimport { Execution, type ExecutionHost } from \"./execution.ts\";\nimport { defaultReadMode } from \"./limits.ts\";\nimport {\n\tboundFacts,\n\tboundInput,\n\tboundText,\n\terrorText,\n\treadOutputSlice,\n\tsliceText,\n\tTASK_LABEL_BYTES,\n\tTASK_TITLE_BYTES,\n} from \"./output.ts\";\nimport { TaskRecord } from \"./record.ts\";\nimport { TaskScheduler } from \"./scheduler.ts\";\nimport { TaskStore } from \"./store.ts\";\nimport {\n\tTASK_BACKGROUND_REJECTION,\n\tTASK_KIND_PATTERN,\n\tTASK_MANAGEMENT_REJECTION,\n\ttype TaskExecution,\n\tTaskLookupError,\n\ttype TaskRead,\n\ttype TaskReadOptions,\n\ttype TaskRuntimeOptions,\n\ttype TaskSnapshot,\n\ttype TasksContext,\n\ttype TaskToolOutcome,\n} from \"./types.ts\";\n\n/** Session-local supervision. Executors own their processes, items and output files. */\nexport class TaskRuntime implements TasksContext {\n\tprivate readonly store: TaskStore;\n\tprivate readonly executions = new Map<string, Execution<unknown>>();\n\tprivate readonly scheduler = new TaskScheduler();\n\tprivate readonly listeners = new Set<() => void>();\n\tprivate readonly host: ExecutionHost;\n\tprivate readonly maxBackground: number;\n\tprivate readonly maxHistory: number;\n\tprivate readonly maxRetained: number;\n\tprivate readonly options: TaskRuntimeOptions;\n\tprivate configuredEnabled: boolean;\n\tprivate _closed = false;\n\n\tconstructor(options: TaskRuntimeOptions = {}) {\n\t\tthis.options = options;\n\t\tthis.configuredEnabled = options.enabled ?? false;\n\t\tthis.maxBackground = Math.max(1, finiteLimit(options.maxBackground, 8, 128));\n\t\tthis.maxHistory = finiteLimit(options.maxHistory, 32, 1024);\n\t\t// Separate foreground and background histories, plus the protected-record allowance.\n\t\tthis.maxRetained = this.maxBackground + 2 * Math.max(1, this.maxHistory) + this.maxHistory;\n\t\tthis.store = new TaskStore(this.maxHistory, this.maxRetained, () => this.closed, options.onCleanupError);\n\t\tconst runtime = this;\n\t\tthis.host = {\n\t\t\tget closed() {\n\t\t\t\treturn runtime.closed;\n\t\t\t},\n\t\t\temit: () => this.emit(),\n\t\t\tsettle: (task, usage) => this.options.onSettled?.(task, usage),\n\t\t\treleased: (execution) => {\n\t\t\t\tthis.executions.delete(execution.task.id);\n\t\t\t\tthis.scheduler.release(execution);\n\t\t\t\tthis.store.trim();\n\t\t\t\tthis.emit();\n\t\t\t},\n\t\t};\n\t}\n\n\tget closed(): boolean {\n\t\treturn this._closed;\n\t}\n\n\tget session(): TaskRuntimeOptions[\"session\"] {\n\t\treturn this.options.session;\n\t}\n\n\t/**\n\t * Rehydrate terminal snapshots only, newest endedAt in each history (later input wins\n\t * ties). Existing runtime records win ID collisions. No execution, accounting,\n\t * notification, or deletion ownership is restored. Foreground records take their output\n\t * from the branch's tool results. The host supplies the current branch; closed services\n\t * ignore restoration.\n\t */\n\trestoreHistory(\n\t\trecords: readonly unknown[],\n\t\ttoolResults?: ReadonlyMap<string, AgentToolResult<unknown>[\"content\"]>,\n\t): void {\n\t\tthis.store.restoreHistory(records, toolResults);\n\t}\n\n\tget enabled(): boolean {\n\t\treturn this.configuredEnabled && !this.closed;\n\t}\n\n\tsetEnabled(enabled: boolean): void {\n\t\tthis.configuredEnabled = enabled;\n\t\tthis.emit();\n\t}\n\n\t/** Tell subscribers that something the runtime reads from its host changed, such as `canManageBackground`. */\n\trefresh(): void {\n\t\tthis.emit();\n\t}\n\n\t/** Whether new work may move to or start in the background: enabled, and the host can manage it. */\n\tprivate get admitsBackground(): boolean {\n\t\treturn this.enabled && (this.options.canManageBackground?.() ?? true);\n\t}\n\n\t/**\n\t * Foreground work is bounded by its caller; only background work holds a slot, including work\n\t * whose caller is still waiting for the executor to accept (a detaching task).\n\t */\n\tprivate backgroundActive(): number {\n\t\treturn [...this.executions.values()].filter((execution) => execution.holdsBackgroundSlot).length;\n\t}\n\n\tprivate limitError(): Error {\n\t\treturn new Error(\n\t\t\t`Background task limit reached (${this.maxBackground}); stop or wait for a background task, or run in the foreground.`,\n\t\t);\n\t}\n\n\tasync execute<T>(execution: TaskExecution<T>): Promise<TaskToolOutcome<T>> {\n\t\t// Admission and registration happen synchronously, before invoking user code or awaiting anything.\n\t\tif (this.closed) throw new Error(\"Task service is closed\");\n\t\tif (execution.background) {\n\t\t\tif (!this.enabled) throw new Error(TASK_BACKGROUND_REJECTION);\n\t\t\tif (!this.admitsBackground) throw new Error(TASK_MANAGEMENT_REJECTION);\n\t\t\tif (this.backgroundActive() >= this.maxBackground) throw this.limitError();\n\t\t\tif (this.store.retainedCount() >= this.maxRetained) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Task history retention limit reached; deliver pending notifications or release task pins and delivery leases\",\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tif (execution.signal?.aborted) throw execution.signal.reason ?? new Error(\"Execution aborted\");\n\t\tif (!TASK_KIND_PATTERN.test(execution.kind)) throw new Error(\"Invalid task source\");\n\t\tconst concurrency = execution.concurrency;\n\t\tif (concurrency && (!concurrency.key || !Number.isSafeInteger(concurrency.limit) || concurrency.limit < 1))\n\t\t\tthrow new Error(\"Invalid task concurrency\");\n\t\tconst anchorId = this.options.anchor?.() ?? null;\n\t\tif (anchorId !== null && Buffer.byteLength(anchorId) > 8192) throw new Error(\"Task branch anchor is too large\");\n\t\tconst task: TaskSnapshot = {\n\t\t\tid: `${execution.kind}-${randomUUID()}`,\n\t\t\tkind: execution.kind,\n\t\t\tlabel: boundText(execution.label ?? execution.kind, TASK_LABEL_BYTES),\n\t\t\ttitle: boundText(execution.title, TASK_TITLE_BYTES),\n\t\t\toutput: execution.output ?? \"log\",\n\t\t\t...(execution.input ? { input: boundInput(execution.input) } : {}),\n\t\t\t...(execution.facts?.length ? { facts: boundFacts(execution.facts) } : {}),\n\t\t\ttoolCallId: boundText(execution.toolCallId, 512),\n\t\t\tanchorId,\n\t\t\tmode: \"foreground\",\n\t\t\tstatus: \"queued\",\n\t\t\tstartedAt: Date.now(),\n\t\t};\n\t\tconst record = new TaskRecord(task);\n\t\tconst active = new Execution(this.host, record, execution);\n\t\tthis.store.add(record);\n\t\tthis.executions.set(task.id, active as Execution<unknown>);\n\t\tthis.scheduler.schedule(active);\n\t\t// Queued background work returns at once; started work hands off after its own accept().\n\t\tactive.handOffIfQueued();\n\t\tthis.emit();\n\t\treturn active.caller;\n\t}\n\n\tprivate detachable(record: TaskRecord): boolean {\n\t\treturn this.executions.get(record.task.id)?.detachable ?? false;\n\t}\n\n\tdetachForeground(): number {\n\t\tif (!this.admitsBackground) return 0;\n\t\tconst eligible = [...this.executions.values()]\n\t\t\t.filter((execution) => execution.detachable)\n\t\t\t.sort((left, right) => left.task.startedAt - right.task.startedAt);\n\t\tif (!eligible.length) return 0;\n\t\tconst free = this.maxBackground - this.backgroundActive();\n\t\tif (free <= 0) throw this.limitError();\n\t\treturn this.detachAll(eligible.slice(0, free));\n\t}\n\n\tcanDetach(id: string): boolean {\n\t\tconst record = this.lookup(id);\n\t\treturn this.admitsBackground && this.backgroundActive() < this.maxBackground && this.detachable(record);\n\t}\n\n\tdetach(id: string): boolean {\n\t\tconst record = this.lookup(id);\n\t\tif (!this.admitsBackground || !this.detachable(record)) return false;\n\t\tif (this.backgroundActive() >= this.maxBackground) throw this.limitError();\n\t\tthis.detachAll([this.executions.get(record.task.id)!]);\n\t\treturn true;\n\t}\n\n\t/** Every placement changes before any listener hears about it. */\n\tprivate detachAll(executions: Execution<unknown>[]): number {\n\t\tconst notifications = executions.map((execution) => execution.detach());\n\t\tfor (const notify of notifications) notify();\n\t\tthis.emit();\n\t\treturn executions.length;\n\t}\n\n\tlist(): TaskSnapshot[] {\n\t\treturn this.store.visible().map((record) => record.snapshot());\n\t}\n\n\tprivate lookup(id: string): TaskRecord {\n\t\tconst exact = this.store.get(id);\n\t\tif (exact) return exact;\n\t\tconst matches = this.store.match(id);\n\t\tif (!id || matches.length !== 1) {\n\t\t\tthrow new TaskLookupError(\n\t\t\t\tmatches.length > 1 ? \"ambiguous\" : \"unknown\",\n\t\t\t\tmatches.map((record) => record.snapshot()),\n\t\t\t);\n\t\t}\n\t\treturn matches[0]!;\n\t}\n\n\tget(id: string): TaskSnapshot {\n\t\treturn this.lookup(id).snapshot();\n\t}\n\n\tasync read(id: string, options: TaskReadOptions = {}): Promise<TaskRead> {\n\t\tconst record = this.lookup(id);\n\t\tconst release = this.retain(record.task.id);\n\t\ttry {\n\t\t\tconst task = record.snapshot();\n\t\t\tconst window = { ...options, mode: options.mode ?? defaultReadMode(task) };\n\t\t\tif (task.outputPath) {\n\t\t\t\ttry {\n\t\t\t\t\treturn { task, ...(await readOutputSlice(task.outputPath, window)) };\n\t\t\t\t} catch (error) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttask,\n\t\t\t\t\t\treadError: boundText(`Output could not be read: ${errorText(error)}`, 4096),\n\t\t\t\t\t\t...sliceText(this.resultText(task), window),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn { task, readError: record.readError, ...sliceText(this.resultText(task), window) };\n\t\t} finally {\n\t\t\trelease();\n\t\t}\n\t}\n\n\tprivate resultText(task: TaskSnapshot): string {\n\t\treturn task.result?.text || task.error || \"No output yet.\";\n\t}\n\n\tkill(id: string): boolean {\n\t\treturn this.cancel(this.lookup(id));\n\t}\n\n\tprivate cancel(record: TaskRecord): boolean {\n\t\treturn this.executions.get(record.task.id)?.cancel() ?? false;\n\t}\n\n\tsubscribe(listener: () => void): () => void {\n\t\tif (this.closed) return () => {};\n\t\tthis.listeners.add(listener);\n\t\treturn () => {\n\t\t\tthis.listeners.delete(listener);\n\t\t};\n\t}\n\n\t/** Retention protects snapshots and logs only; completion delivery never waits on it. */\n\tretain(id: string): () => void {\n\t\treturn this.pin(this.lookup(id));\n\t}\n\n\tprivate pin(record: TaskRecord): () => void {\n\t\tconst release = record.pin();\n\t\treturn () => {\n\t\t\trelease();\n\t\t\tthis.store.trim();\n\t\t};\n\t}\n\n\tclose(): void {\n\t\tif (this.closed) return;\n\t\tthis._closed = true;\n\t\tthis.listeners.clear();\n\t\tfor (const record of this.store.all()) {\n\t\t\tthis.executions.get(record.task.id)?.releaseParent();\n\t\t\tthis.cancel(record);\n\t\t}\n\t\tthis.options.onClosed?.();\n\t\tthis.store.trim();\n\t}\n\n\tasync shutdown(graceMs = 2000): Promise<void> {\n\t\tthis.close();\n\t\tawait this.drain(this.store.all(), graceMs);\n\t}\n\n\t/** Running tasks whose launch anchor is outside the branch made of `ancestors`. */\n\tactiveOutsideBranch(ancestors: ReadonlySet<string>): TaskSnapshot[] {\n\t\treturn this.store\n\t\t\t.unsettled()\n\t\t\t.filter((record) => record.task.anchorId !== null && !ancestors.has(record.task.anchorId))\n\t\t\t.map((record) => record.snapshot());\n\t}\n\n\t/**\n\t * Hidden results stay pending: returning to their branch delivers them again.\n\t * Restored history is already delivered.\n\t */\n\tasync cancelOutsideBranch(ancestors: ReadonlySet<string>): Promise<void> {\n\t\tconst records = this.store.all();\n\t\tfor (const record of records)\n\t\t\trecord.setVisible(record.task.anchorId === null || ancestors.has(record.task.anchorId));\n\t\tconst outside = records.filter((record) => !record.visible);\n\t\tfor (const record of outside) this.cancel(record);\n\t\tthis.store.trim();\n\t\tthis.emit();\n\t\tawait this.drain(outside, 2000);\n\t}\n\n\tprivate async drain(records: TaskRecord[], graceMs: number): Promise<void> {\n\t\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\t\ttry {\n\t\t\tawait Promise.race([\n\t\t\t\tPromise.all(records.map((record) => this.executions.get(record.task.id)?.done)).then(() =>\n\t\t\t\t\tthis.store.cleanupsDone(),\n\t\t\t\t),\n\t\t\t\tnew Promise<void>((resolve) => {\n\t\t\t\t\ttimer = setTimeout(resolve, finiteLimit(graceMs, 2000, 60_000));\n\t\t\t\t}),\n\t\t\t]);\n\t\t} finally {\n\t\t\tif (timer !== undefined) clearTimeout(timer);\n\t\t}\n\t}\n\n\tprivate emit(): void {\n\t\tif (this.closed) return;\n\t\tfor (const listener of [...this.listeners]) {\n\t\t\tif (this.closed) break;\n\t\t\ttry {\n\t\t\t\tlistener();\n\t\t\t} catch {\n\t\t\t\t/* Observers do not own execution or delivery. */\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|