@tea-agent/loop-agent 0.1.0-fe-test.5 → 0.1.0-fe-test.6
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/AGENTS.md +1 -1
- package/CHANGELOG.md +441 -2525
- package/README.md +19 -12
- package/dist/adapters/loop-agent.js +34 -0
- package/dist/application/dag/args.js +8 -0
- package/dist/application/dag/run-dag.js +5 -0
- package/dist/application/evaluation/budget.js +40 -1
- package/dist/application/evaluation/corpus-hash.js +10 -15
- package/dist/application/evaluation/corpus.js +2 -1
- package/dist/application/evaluation/frontend-browser-acceptance.js +77 -0
- package/dist/application/evaluation/frontend-corpus-browser-acceptance.js +175 -0
- package/dist/application/evaluation/frontend-gateway-evidence.js +226 -0
- package/dist/application/evaluation/frontend-pair-registration.js +143 -0
- package/dist/application/evaluation/frontend-paired-summary.js +150 -0
- package/dist/application/evaluation/frontend-run-observation.js +144 -0
- package/dist/application/evaluation/frontend-shared-evidence.js +105 -0
- package/dist/application/evaluation/types.js +45 -12
- package/dist/application/task-lifecycle/advance.js +64 -15
- package/dist/application/task-lifecycle/observe.js +69 -30
- package/dist/application/task-lifecycle/plan-transitions.js +5 -4
- package/dist/build-stamp.json +3 -3
- package/dist/cli/command-definitions.js +18 -5
- package/dist/cli/program.js +8 -5
- package/dist/cli/update/init-surface-notifier.js +2 -0
- package/dist/cli/update/policy.js +2 -0
- package/dist/commands/client-recovery.js +20 -55
- package/dist/commands/cursor-prompt.js +2 -0
- package/dist/commands/dag-approve.js +2 -0
- package/dist/commands/dag-final-verification.js +2 -0
- package/dist/commands/dag-init-hybrid.js +2 -0
- package/dist/commands/dag-reconcile-tasks.js +2 -0
- package/dist/commands/dag-reject.js +2 -0
- package/dist/commands/dag-report.js +2 -0
- package/dist/commands/dag-rerun.js +2 -0
- package/dist/commands/dag-resume.js +2 -0
- package/dist/commands/dag-workflow-compile.js +2 -0
- package/dist/commands/dag-workflow-plan.js +2 -0
- package/dist/commands/dag-workflow-validate.js +2 -0
- package/dist/commands/delegate.js +2 -0
- package/dist/commands/examples.js +2 -0
- package/dist/commands/import-prd.js +2 -0
- package/dist/commands/init-legacy-audit.js +330 -0
- package/dist/commands/init-model-catalog.js +2 -0
- package/dist/commands/init-upgrade.js +644 -104
- package/dist/commands/init.js +700 -338
- package/dist/commands/instructions.js +2 -0
- package/dist/commands/knowledge.js +2 -0
- package/dist/commands/loop-benchmark.js +2 -0
- package/dist/commands/operator-guide.js +99 -0
- package/dist/commands/operator.js +16 -3
- package/dist/commands/pi-prompt.js +2 -0
- package/dist/commands/pi-reuse-benchmark.js +2 -0
- package/dist/commands/promote-run.js +2 -0
- package/dist/commands/stats.js +1 -1
- package/dist/commands/study-init.js +2 -0
- package/dist/commands/task-advance.js +32 -0
- package/dist/commands/task-source-prepare.js +18 -2
- package/dist/commands/worktree-create.js +2 -0
- package/dist/commands/worktree-remove.js +2 -0
- package/dist/executors/dag-pi/guards.js +4 -0
- package/dist/executors/dag-pi/model-config.js +30 -0
- package/dist/executors/dag-pi/plan/fact-adoption.js +55 -0
- package/dist/executors/dag-pi/plan/facts.js +180 -0
- package/dist/executors/dag-pi/plan/finalize-tools.js +259 -0
- package/dist/executors/dag-pi/plan/ledger-contract.js +55 -0
- package/dist/executors/dag-pi/plan/record-tools.js +861 -0
- package/dist/executors/dag-pi/plan/schema.js +129 -0
- package/dist/executors/dag-pi/plan/tool-helpers.js +16 -0
- package/dist/executors/dag-pi/sessions/index.js +6 -0
- package/dist/executors/dag-pi/sessions/plan-batches.js +280 -0
- package/dist/executors/dag-pi/sessions/plan-prompts.js +367 -0
- package/dist/executors/dag-pi/sessions/scout-parallel.js +197 -0
- package/dist/executors/dag-pi/sessions/segmented-plan.js +1184 -0
- package/dist/executors/dag-pi/sessions/writer-evidence.js +60 -0
- package/dist/executors/dag-pi/tools/contract-tools.js +515 -0
- package/dist/executors/dag-pi/tools/design-terminal-tools.js +159 -0
- package/dist/executors/dag-pi/tools/plan-decision-tools.js +529 -0
- package/dist/executors/dag-pi/tools/review-terminal-tools.js +159 -0
- package/dist/executors/dag-pi/tools/scout-evidence-tools.js +270 -0
- package/dist/executors/dag-pi-executor.js +1516 -3181
- package/dist/executors/pi-executor.js +112 -4
- package/dist/executors/pi-sdk-executor.js +258 -44
- package/dist/executors/pi-writer-tool-policy.js +60 -4
- package/dist/executors/playwright-cli-launcher.js +31 -45
- package/dist/executors/shell-executor.js +313 -48
- package/dist/executors/shell-presets.js +1 -1
- package/dist/executors/shell-verification.js +3 -0
- package/dist/executors/shell-write-guard.js +77 -102
- package/dist/governance/exec-plans.js +16 -4
- package/dist/governance/harness.js +2 -7
- package/dist/governance/manifest-types.js +28 -9
- package/dist/governance/project-capability-scanner.js +263 -0
- package/dist/governance/project-config.js +96 -0
- package/dist/governance/resource-catalog.js +151 -0
- package/dist/infrastructure/console/app-data.js +12 -2
- package/dist/infrastructure/console/operation-store.js +48 -14
- package/dist/infrastructure/evaluation/corpus-store.js +37 -12
- package/dist/shared/artifacts-core.js +2 -0
- package/dist/shared/backend-dogfood-preflight.js +47 -0
- package/dist/shared/dag-failure-category.js +9 -0
- package/dist/shared/file-identity.js +23 -0
- package/dist/shared/frontend-execution-policy.js +23 -0
- package/dist/shared/git-progress.js +2 -0
- package/dist/shared/git-workspace-status.js +482 -0
- package/dist/shared/one-shot-prompt-args.js +2 -0
- package/dist/shared/operator/capabilities.js +185 -0
- package/dist/shared/package-metadata.js +29 -11
- package/dist/shared/path-safety.js +2 -2
- package/dist/shared/pi-context-pressure/extension.js +49 -16
- package/dist/shared/pi-context-pressure/index.js +1 -0
- package/dist/shared/pi-context-pressure/sift-bridge.js +1 -1
- package/dist/shared/pi-context-pressure/telemetry.js +4 -0
- package/dist/shared/pi-context-pressure/tool-result-pruner.js +98 -0
- package/dist/shared/pi-provider-recovery.js +182 -0
- package/dist/shared/pi-retry-settings.js +40 -0
- package/dist/shared/reference-context.js +2 -0
- package/dist/shared/update/npm-client.js +49 -1
- package/dist/shared/wizard-local-telemetry.js +51 -0
- package/dist/task/config-types.js +51 -2
- package/dist/task/contract/apply.js +36 -2
- package/dist/task/contract/project.js +22 -0
- package/dist/task/contract/recover.js +6 -0
- package/dist/task/contract/schema.js +12 -0
- package/dist/task/frontend-preflight.js +1 -1
- package/dist/task/source-prepare/artifact-meta.js +9 -2
- package/dist/task/source-prepare/build-draft.js +61 -0
- package/dist/task/source-prepare/fragment-inventory.js +4 -1
- package/dist/task/source-prepare/ledger-reconciliation.js +2 -2
- package/dist/task/source-prepare/ledger-review.js +6 -9
- package/dist/task/source-prepare/parse-intent.js +165 -14
- package/dist/task/source-prepare/path-policy.js +17 -7
- package/dist/task/source-prepare/prepare.js +6 -1
- package/dist/task/source-prepare/semantic-intake.js +33 -28
- package/dist/task/source-prepare/source-execution.js +65 -0
- package/dist/task/source-prepare/source-fidelity-pi.js +49 -17
- package/dist/task/source-prepare/source-provider-budget.js +290 -0
- package/dist/task/source-references.js +48 -23
- package/dist/task/task-demand-routing.js +5 -2
- package/dist/worker/cli.js +3 -5
- package/dist/worker/console/chat/assistant-content.js +5 -13
- package/dist/worker/console/chat/browser-automation.js +937 -0
- package/dist/worker/console/chat/browser-content.js +74 -0
- package/dist/worker/console/chat/browser-diagnostics.js +250 -0
- package/dist/worker/console/chat/browser-evaluation.js +58 -0
- package/dist/worker/console/chat/browser-operation-queue.js +19 -0
- package/dist/worker/console/chat/browser-pick.js +113 -0
- package/dist/worker/console/chat/browser-policy.js +113 -0
- package/dist/worker/console/chat/browser-routes.js +329 -0
- package/dist/worker/console/chat/browser-screenshot-result.js +47 -0
- package/dist/worker/console/chat/browser-storage.js +89 -0
- package/dist/worker/console/chat/chat-event-store.js +73 -18
- package/dist/worker/console/chat/context-insights.js +788 -0
- package/dist/worker/console/chat/conversation-nodes.js +383 -0
- package/dist/worker/console/chat/db-connections.js +854 -0
- package/dist/worker/console/chat/explore-tools.js +18 -2
- package/dist/worker/console/chat/pet/pet-affinity.js +169 -0
- package/dist/worker/console/chat/pet/pet-persist.js +109 -0
- package/dist/worker/console/chat/pet/pet-registry.js +142 -0
- package/dist/worker/console/chat/pet/pet-remarks.js +48 -0
- package/dist/worker/console/chat/pet/pet-routes.js +125 -0
- package/dist/worker/console/chat/pet/pet-service.js +262 -0
- package/dist/worker/console/chat/pet/pet-state.js +99 -0
- package/dist/worker/console/chat/pi-mode-loop-isolation.js +170 -0
- package/dist/worker/console/chat/pi-runtime/custom-tools/ask-user-question.js +44 -0
- package/dist/worker/console/chat/pi-runtime/custom-tools/browser-tools.js +135 -0
- package/dist/worker/console/chat/pi-runtime/custom-tools/explore-tools.js +202 -0
- package/dist/worker/console/chat/pi-runtime/custom-tools/goal-tools.js +79 -0
- package/dist/worker/console/chat/pi-runtime/custom-tools/operator-tools.js +94 -0
- package/dist/worker/console/chat/pi-runtime/custom-tools/scheduled-goal-tools.js +22 -0
- package/dist/worker/console/chat/pi-runtime/custom-tools/sql-tools.js +670 -0
- package/dist/worker/console/chat/pi-runtime/custom-tools/todo-write.js +38 -0
- package/dist/worker/console/chat/pi-runtime/inspection-types.js +28 -0
- package/dist/worker/console/chat/pi-runtime/inspection.js +439 -0
- package/dist/worker/console/chat/pi-runtime/progressive-tools.js +195 -0
- package/dist/worker/console/chat/pi-runtime/sdk-bindings.js +153 -0
- package/dist/worker/console/chat/pi-runtime/sdk-session.js +5 -0
- package/dist/worker/console/chat/pi-runtime.js +793 -1230
- package/dist/worker/console/chat/provider-error.js +0 -12
- package/dist/worker/console/chat/repo-browser.js +132 -6
- package/dist/worker/console/chat/repo-preview-kind.js +155 -0
- package/dist/worker/console/chat/resource-loader.js +4 -1
- package/dist/worker/console/chat/routes.js +861 -148
- package/dist/worker/console/chat/scheduled-goal-booking.js +59 -0
- package/dist/worker/console/chat/scheduled-goal-delivery.js +27 -0
- package/dist/worker/console/chat/scheduled-goal-request.js +198 -0
- package/dist/worker/console/chat/scm-routes.js +217 -0
- package/dist/worker/console/chat/scm-service.js +283 -0
- package/dist/worker/console/chat/scm-tools.js +111 -0
- package/dist/worker/console/chat/sdd-data-alignment.js +85 -41
- package/dist/worker/console/chat/session-catalog.js +32 -0
- package/dist/worker/console/chat/session-mode-view.js +49 -0
- package/dist/worker/console/chat/session-mode.js +224 -0
- package/dist/worker/console/chat/session-store.js +232 -32
- package/dist/worker/console/chat/shortcuts.js +13 -0
- package/dist/worker/console/chat/subagents/agent-tool.js +62 -0
- package/dist/worker/console/chat/subagents/explore-agent.js +169 -0
- package/dist/worker/console/chat/subagents/index.js +5 -0
- package/dist/worker/console/chat/subagents/orchestrator.js +273 -0
- package/dist/worker/console/chat/subagents/tool-policy.js +53 -0
- package/dist/worker/console/chat/subagents/types.js +13 -0
- package/dist/worker/console/chat/terminal-routes.js +216 -0
- package/dist/worker/console/chat/terminal-sessions.js +348 -0
- package/dist/worker/console/chat/terminal-tools.js +211 -0
- package/dist/worker/console/chat/timeline-message-order.js +22 -0
- package/dist/worker/console/chat/tool-preview.js +136 -0
- package/dist/worker/console/chat/tools.js +69 -1
- package/dist/worker/console/chat/turn-order.js +13 -0
- package/dist/worker/console/chat/turn-process.js +210 -36
- package/dist/worker/console/chat/user-turn-outline.js +19 -0
- package/dist/worker/console/console-shutdown.js +34 -0
- package/dist/worker/console/console-update-and-init.js +1 -19
- package/dist/worker/console/console-update-runtime.js +7 -22
- package/dist/worker/console/dag-confirmation.js +3 -0
- package/dist/worker/console/dag-execution-receipt.js +3 -0
- package/dist/worker/console/interview/tools.js +1 -0
- package/dist/worker/console/operator-actions.js +95 -4
- package/dist/worker/console/operator-user-error.js +28 -1
- package/dist/worker/console/pi-readiness.js +4 -4
- package/dist/worker/console/prd-intake-bridge.js +47 -1
- package/dist/worker/console/recovery-cta.js +14 -14
- package/dist/worker/console/routes.js +13 -0
- package/dist/worker/console/scheduled-goal-host.js +98 -0
- package/dist/worker/console/scheduled-goal-operation-adapter.js +127 -0
- package/dist/worker/console/server.js +33 -31
- package/dist/worker/console/static/app-icon.svg +39 -0
- package/dist/worker/console/static/assets/{abnfDiagram-N423BO3Z-BZogYNl1.js → abnfDiagram-N423BO3Z-DASc69AM.js} +1 -1
- package/dist/worker/console/static/assets/{arc-DcJTLe2v.js → arc-h09p-LAc.js} +1 -1
- package/dist/worker/console/static/assets/{architectureDiagram-T3A2C74G-B39EQQ9n.js → architectureDiagram-T3A2C74G-CZ3dtLkh.js} +1 -1
- package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-CitCGV56.js → blockDiagram-VBNYF7ZC-DMrRhMXG.js} +1 -1
- package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-rvWuOHLG.js → c4Diagram-5PPSVZJV-DQxisHV6.js} +1 -1
- package/dist/worker/console/static/assets/channel-D1zgKZfg.js +1 -0
- package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-DGXplIJs.js → chunk-2GRJ4B5K-CefVN9zh.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-ur9OqjPn.js → chunk-2Q5K7J3B-DmR1Koq2.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5RXB4S5H-D1KqU_Vi.js → chunk-5RXB4S5H-NlzrSW7L.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5VM5RSS4-BlVZrbtM.js → chunk-5VM5RSS4-DfelJv-0.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-BAzz3nQy.js → chunk-6Q2QTUOP-BK6RFy58.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-GF5L2VYU-CP_nYuCV.js → chunk-GF5L2VYU-BAeh9lz4.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-JWPE2WC7-CWvKQ80X.js → chunk-JWPE2WC7-ChPS5WzG.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-KBJHAD2P-CyUki8wp.js → chunk-KBJHAD2P-BoVe5IM6.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-RYQCIY6F-5NYzNKfY.js → chunk-RYQCIY6F-C4q_0Lw9.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-XXDRQBXY-DHdUgjS-.js → chunk-XXDRQBXY-Bb9TvjeY.js} +1 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-CXNNsY2M.js +1 -0
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-CXNNsY2M.js +1 -0
- package/dist/worker/console/static/assets/{cose-bilkent-JH36ORCC-ANQ5g_t6.js → cose-bilkent-JH36ORCC-DmNnL8Ff.js} +1 -1
- package/dist/worker/console/static/assets/{cynefin-VYW2F7L2-CruT_4-0.js → cynefin-VYW2F7L2-Contvx58.js} +1 -1
- package/dist/worker/console/static/assets/{cynefinDiagram-MW4NZA55-rbFo77ID.js → cynefinDiagram-MW4NZA55-Cigq7cjk.js} +1 -1
- package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-asstxBQs.js → dagre-VZM6K2ZE-dEbC0nxb.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-7IWD3JNH-DzTyBZwI.js → diagram-7IWD3JNH-CzIztESV.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-gw8ccH3B.js → diagram-B4RE2ZJO-Bo14zbaY.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-LBJQPF4R-B8RpZzOf.js → diagram-LBJQPF4R-C4xUyil6.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-Q27KOJAE-B1zJkCS9.js → diagram-Q27KOJAE-CaBY_uYa.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-UB23O5K3-B6JLWZmO.js → diagram-UB23O5K3-ClUXUeiu.js} +1 -1
- package/dist/worker/console/static/assets/{ebnfDiagram-BXEA7PRR-q2iZP-Ps.js → ebnfDiagram-BXEA7PRR-BbGCgjC6.js} +1 -1
- package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-B3dbbktQ.js → erDiagram-JOGREHBK-Dr-AcwSl.js} +1 -1
- package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-C-zc6-kB.js → flowDiagram-UKHOOZJN-BG8Gcfyc.js} +1 -1
- package/dist/worker/console/static/assets/{ganttDiagram-PKOTCBZU-BSolnot9.js → ganttDiagram-PKOTCBZU-CFVaPs5r.js} +1 -1
- package/dist/worker/console/static/assets/{gitGraphDiagram-DS77QQ5N-Bo8jGxTk.js → gitGraphDiagram-DS77QQ5N-ChJ8pm-O.js} +1 -1
- package/dist/worker/console/static/assets/index-B_5GhVIO.js +488 -0
- package/dist/worker/console/static/assets/index-C7YMBluX.css +1 -0
- package/dist/worker/console/static/assets/{infoDiagram-6WML65LV-DQaZqJOH.js → infoDiagram-6WML65LV-C5J9-uCZ.js} +1 -1
- package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-DsdX1WnE.js → ishikawaDiagram-WSZJBQD7-BcfjqzDv.js} +1 -1
- package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-CP5EYDZL.js → journeyDiagram-NVQOT4AX-BzzCO-rD.js} +1 -1
- package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-DAm14Dr8.js → kanban-definition-27J2QSJJ-NCHUZ46h.js} +1 -1
- package/dist/worker/console/static/assets/{linear-gZECoLc5.js → linear-BKZlWCUU.js} +1 -1
- package/dist/worker/console/static/assets/{mermaid.core-BRJNIM6p.js → mermaid.core-DbTaQjFE.js} +5 -5
- package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-Cja3kLkR.js → mindmap-definition-FAOFIHXS-CroYl5xQ.js} +1 -1
- package/dist/worker/console/static/assets/{pegDiagram-VL7TDLO6-22ZGFisL.js → pegDiagram-VL7TDLO6-DgMBx-9k.js} +1 -1
- package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-BXin0Y1o.js → pieDiagram-7S7Q4E2Y-CyWDmbq1.js} +1 -1
- package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-Cw6T69Yt.js → quadrantDiagram-CIZ2JOQS-BgGEOqSP.js} +1 -1
- package/dist/worker/console/static/assets/{railroadDiagram-AXF67PYL-C1-gTieN.js → railroadDiagram-AXF67PYL-BMZ7oeeV.js} +1 -1
- package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP--H5N2iI1.js → requirementDiagram-LRYGKXZP-DxqyGhcc.js} +1 -1
- package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-CgWAPeRz.js → sankeyDiagram-W5VNT64P-DnSvNCG8.js} +1 -1
- package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-CrKqzGvt.js → sequenceDiagram-SI44F4Z6-BiZh6f-R.js} +1 -1
- package/dist/worker/console/static/assets/{sizeCapture-X5ZJPWSS-BB3wG06K.js → sizeCapture-X5ZJPWSS-BKXSI8WB.js} +1 -1
- package/dist/worker/console/static/assets/{stateDiagram-OKZ733FA-DjsGgdgY.js → stateDiagram-OKZ733FA-CfSgoYFm.js} +1 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-DgHi3vjb.js +1 -0
- package/dist/worker/console/static/assets/{swimlanes-SLNWSIFB-DYKEbvAR.js → swimlanes-SLNWSIFB-CyGADcHe.js} +2 -2
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-Bgvdt1Y0.js +8 -0
- package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-eQOb5k9Y.js → timeline-definition-Z64GVDOM-HmPaSPOK.js} +1 -1
- package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-B2-l9FIu.js → vennDiagram-T6HMQDX7-VA2VBbez.js} +1 -1
- package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-BX2Cda3l.js → wardleyDiagram-T6FBY63Y-BxjiBPZa.js} +1 -1
- package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-D9S892ph.js → xychartDiagram-ELKLHX3M--hUY-qFj.js} +1 -1
- package/dist/worker/console/static/index.html +5 -2
- package/dist/worker/console/static/manifest.webmanifest +19 -0
- package/dist/worker/console/static/pets/ember/pet.json +167 -0
- package/dist/worker/console/static/pets/ember/spritesheet.png +0 -0
- package/dist/worker/console/static-src/app/console-types.js +9 -1
- package/dist/worker/console/static-src/chat-view-types.js +1 -1
- package/dist/worker/console/static-src/operator-chat/active-turn-tail.js +10 -0
- package/dist/worker/console/static-src/operator-chat/animation-frame-batcher.js +38 -0
- package/dist/worker/console/static-src/operator-chat/chat-link.js +114 -0
- package/dist/worker/console/static-src/operator-chat/chat-scroll-position.js +24 -0
- package/dist/worker/console/static-src/operator-chat/chat-sse-events.js +360 -14
- package/dist/worker/console/static-src/operator-chat/chat-stream-continuity.js +101 -0
- package/dist/worker/console/static-src/operator-chat/compaction-message.js +10 -2
- package/dist/worker/console/static-src/operator-chat/composer-session-ledger.js +192 -0
- package/dist/worker/console/static-src/operator-chat/context-insights-store.js +64 -0
- package/dist/worker/console/static-src/operator-chat/details-rail-surfaces.js +99 -0
- package/dist/worker/console/static-src/operator-chat/file-palette-nav.js +81 -0
- package/dist/worker/console/static-src/operator-chat/open-preview-in-browser.js +57 -9
- package/dist/worker/console/static-src/operator-chat/pending-user-message.js +66 -0
- package/dist/worker/console/static-src/operator-chat/process-label.js +63 -0
- package/dist/worker/console/static-src/operator-chat/slash-palette-nav.js +15 -5
- package/dist/worker/console/static-src/operator-chat/timeline-merge.js +29 -0
- package/dist/worker/console/static-src/operator-chat/tools-catalog.js +36 -8
- package/dist/worker/console/static-src/operator-chat/transcript-mode.js +21 -0
- package/dist/worker/console/static-src/operator-chat/turn-group-equality.js +16 -0
- package/dist/worker/console/static-src/operator-chat/turn-process-disclosure.js +18 -0
- package/dist/worker/console/static-src/operator-chat/turn-state-projection.js +166 -0
- package/dist/worker/console/static-src/operator-chat/turn-stream-controller.js +58 -2
- package/dist/worker/console/static-src/operator-chat/use-searchable-hidden.js +51 -0
- package/dist/worker/console/static-src/operator-chat/use-stat-dialog.js +95 -0
- package/dist/worker/console/static-src/operator-chat/useChatSessions.js +338 -93
- package/dist/worker/console/static-src/operator-chat/useChatStream.js +310 -106
- package/dist/worker/console/static-src/operator-chat/useChatThread.js +179 -75
- package/dist/worker/console/static-src/operator-chat/useComposer.js +281 -79
- package/dist/worker/console/static-src/operator-chat/useRepoBrowser.js +21 -3
- package/dist/worker/console/static-src/operator-chat/useRuntimeControls.js +36 -17
- package/dist/worker/console/static-src/operator-chat/useRuntimeSnapshot.js +18 -0
- package/dist/worker/console/static-src/operator-chat/useWorkspaceBrowserGate.js +4 -0
- package/dist/worker/console/static-src/operator-chat/user-turn-anchor-equality.js +21 -0
- package/dist/worker/console/static-src/prd-file-import.js +3 -1
- package/dist/worker/console/static-src/shell/console-update-reload.js +1 -1
- package/dist/worker/console/workspace-context.js +54 -1
- package/dist/worker/console/workspace-initialization.js +218 -0
- package/dist/worker/delivery/git-transaction.js +2 -0
- package/dist/worker/delivery/package.js +4 -1
- package/dist/worker/feature/fullstack-validate.js +2 -0
- package/dist/worker/loop-agent/loop-agent-client.js +8 -2
- package/dist/worker/materialize/harness-task-lineage.js +4 -2
- package/dist/worker/materialize/harness-task-materializer.js +4 -1
- package/dist/worker/metrics/projector.js +1 -1
- package/dist/worker/observability/event-store.js +4 -1
- package/dist/worker/observability/read-model.js +27 -3
- package/dist/worker/observe/node-context-insights.js +479 -0
- package/dist/worker/observe/node-transparency.js +103 -72
- package/dist/worker/observe/routes.js +24 -1
- package/dist/worker/observe/static/console-theme.css +178 -0
- package/dist/worker/observe/static/console-theme.js +74 -0
- package/dist/worker/observe/static/dag-inspector-humanize.js +3 -0
- package/dist/worker/observe/static/dom.js +20 -1
- package/dist/worker/observe/static/format-pool.d.ts +2 -0
- package/dist/worker/observe/static/format-pool.js +6 -0
- package/dist/worker/observe/static/format.js +7 -0
- package/dist/worker/observe/static/inspect-workspace.js +34 -7
- package/dist/worker/observe/static/inspector-submission.js +32 -0
- package/dist/worker/observe/static/kpi.js +1 -0
- package/dist/worker/observe/static/operator-chrome.css +85 -0
- package/dist/worker/observe/static/operator-chrome.js +13 -1
- package/dist/worker/observe/static/relations.js +2 -0
- package/dist/worker/observe/static/router.js +13 -0
- package/dist/worker/observe/static/run-processing.js +2 -0
- package/dist/worker/observe/static/shell-chrome.js +36 -3
- package/dist/worker/observe/static/state.js +35 -2
- package/dist/worker/observe/static/styles.css +263 -39
- package/dist/worker/observe/static/task-failure-labels.d.ts +4 -0
- package/dist/worker/observe/static/task-failure-labels.js +67 -0
- package/dist/worker/observe/static/task-history.js +12 -0
- package/dist/worker/observe/static/views/batch.js +6 -13
- package/dist/worker/observe/static/views/dag-graph.js +50 -3
- package/dist/worker/observe/static/views/dag-inspector.js +742 -268
- package/dist/worker/observe/static/views/dag-trajectory.js +3 -0
- package/dist/worker/observe/static/views/dag.d.ts +6 -0
- package/dist/worker/observe/static/views/dag.js +49 -11
- package/dist/worker/observe/static/views/dags.js +2 -0
- package/dist/worker/observe/static/views/dashboard.js +21 -12
- package/dist/worker/observe/static/views/failures.js +21 -11
- package/dist/worker/observe/static/views/feature.js +11 -29
- package/dist/worker/observe/static/views/pool.js +37 -28
- package/dist/worker/observe/static/views/run.js +48 -5
- package/dist/worker/observe/static/views/session-timeline.js +189 -240
- package/dist/worker/observe/static/views/task.js +81 -62
- package/dist/worker/outcomes/declared-artifacts.js +2 -0
- package/dist/worker/preflight.js +3 -0
- package/dist/worker/scheduler/scheduled-goal-dispatch.js +118 -0
- package/dist/worker/scheduler/scheduled-goal-evidence.js +230 -0
- package/dist/worker/scheduler/scheduled-goal-recovery.js +62 -0
- package/dist/worker/scheduler/scheduled-goal-store.js +709 -0
- package/dist/worker/scheduler/scheduled-goal-supervisor.js +132 -0
- package/dist/worker/scheduler/scheduled-goal-time.js +102 -0
- package/dist/worker/scheduler/scheduled-goal-types.js +95 -0
- package/dist/worker/task-spec/validate.js +4 -1
- package/dist/workflows/dag/backend-test-case-coverage-analysis.js +3 -1
- package/dist/workflows/dag/backend-test-layout.js +27 -7
- package/dist/workflows/dag/backend-test-markdown-workflow.js +9 -25
- package/dist/workflows/dag/backend-test-plan-protocol.js +82 -5
- package/dist/workflows/dag/backend-test-pytest-collection.js +4 -1
- package/dist/workflows/dag/budget-enforcement.js +82 -3
- package/dist/workflows/dag/checkpoint.js +686 -0
- package/dist/workflows/dag/dag-retry-schema.js +14 -0
- package/dist/workflows/dag/decision-envelope.js +2 -0
- package/dist/workflows/dag/dynamic-runtime/shared.js +2 -2
- package/dist/workflows/dag/final-verification.js +45 -10
- package/dist/workflows/dag/frontend-capacity.js +9 -0
- package/dist/workflows/dag/frontend-closeout.js +5 -1
- package/dist/workflows/dag/frontend-committed-facts.js +461 -0
- package/dist/workflows/dag/frontend-contract-facts.js +133 -0
- package/dist/workflows/dag/frontend-design-policy.js +107 -21
- package/dist/workflows/dag/frontend-durable-tools.js +225 -0
- package/dist/workflows/dag/frontend-execution-groups.js +24 -0
- package/dist/workflows/dag/frontend-implementation-contract.js +554 -26
- package/dist/workflows/dag/frontend-input-projection.js +76 -0
- package/dist/workflows/dag/frontend-plan-canary.js +103 -0
- package/dist/workflows/dag/frontend-plan-decision-contract.js +795 -0
- package/dist/workflows/dag/frontend-plan-progress.js +92 -0
- package/dist/workflows/dag/frontend-plan-recovery-policy.js +18 -0
- package/dist/workflows/dag/frontend-plan-render.js +21 -5
- package/dist/workflows/dag/frontend-provider-capability-matrix.js +8 -61
- package/dist/workflows/dag/frontend-recovery-controller.js +7 -7
- package/dist/workflows/dag/frontend-recovery-lineage.js +13 -0
- package/dist/workflows/dag/frontend-recovery-plan.js +10 -5
- package/dist/workflows/dag/frontend-recovery-run.js +148 -47
- package/dist/workflows/dag/frontend-repair-assertions.js +36 -0
- package/dist/workflows/dag/frontend-repair.js +79 -76
- package/dist/workflows/dag/frontend-review-context.js +71 -69
- package/dist/workflows/dag/frontend-review-scopes.js +237 -0
- package/dist/workflows/dag/frontend-risk.js +101 -12
- package/dist/workflows/dag/frontend-root-observation.js +261 -0
- package/dist/workflows/dag/frontend-session-budget.js +376 -0
- package/dist/workflows/dag/frontend-session-context.js +10 -0
- package/dist/workflows/dag/frontend-shape-facts.js +12 -2
- package/dist/workflows/dag/frontend-shape.js +27 -32
- package/dist/workflows/dag/frontend-test-case-checklist.js +12 -3
- package/dist/workflows/dag/frontend-test-case-generation-assessment.js +21 -2
- package/dist/workflows/dag/frontend-test-case-quality.js +3 -3
- package/dist/workflows/dag/frontend-test-environment-probe.js +0 -2
- package/dist/workflows/dag/frontend-test-execution-evidence.js +328 -0
- package/dist/workflows/dag/frontend-test-framework-adapters.js +309 -0
- package/dist/workflows/dag/frontend-test-layout.js +41 -12
- package/dist/workflows/dag/frontend-typed-event-store.js +57 -26
- package/dist/workflows/dag/frontend-verification-trace.js +65 -48
- package/dist/workflows/dag/frontend-writer-admission.js +6 -48
- package/dist/workflows/dag/frontend-writer-status.js +0 -23
- package/dist/workflows/dag/hybrid/sources.js +1831 -0
- package/dist/workflows/dag/hybrid/templates/backend-test.js +1822 -0
- package/dist/workflows/dag/hybrid/templates/frontend-test.js +807 -0
- package/dist/workflows/dag/hybrid/templates/frontend.js +1529 -0
- package/dist/workflows/dag/hybrid/templates/index.js +8 -0
- package/dist/workflows/dag/hybrid/templates/kg-bootstrap.js +449 -0
- package/dist/workflows/dag/hybrid/templates/knowledge-sync.js +495 -0
- package/dist/workflows/dag/hybrid/templates/shared.js +101 -0
- package/dist/workflows/dag/hybrid/templates/standard.js +265 -0
- package/dist/workflows/dag/hybrid/types.js +32 -0
- package/dist/workflows/dag/init-hybrid.js +57 -7167
- package/dist/workflows/dag/interrupt-request.js +2 -0
- package/dist/workflows/dag/lifecycle.js +11 -2
- package/dist/workflows/dag/node-execution.js +257 -247
- package/dist/workflows/dag/output-protocol.js +1 -0
- package/dist/workflows/dag/prompt.js +4 -0
- package/dist/workflows/dag/reconcile-run.js +2 -0
- package/dist/workflows/dag/repair-artifact.js +3 -1
- package/dist/workflows/dag/report.js +2 -0
- package/dist/workflows/dag/rerun-feedback.js +36 -4
- package/dist/workflows/dag/rerun-plan.js +106 -4
- package/dist/workflows/dag/rerun-run.js +7 -0
- package/dist/workflows/dag/rerun-task.js +75 -1
- package/dist/workflows/dag/retry-policy.js +34 -10
- package/dist/workflows/dag/runner-exit-diagnostics.js +125 -0
- package/dist/workflows/dag/runner.js +38 -1074
- package/dist/workflows/dag/scheduler.js +2 -4
- package/dist/workflows/dag/skill-instructions.js +102 -32
- package/dist/workflows/dag/skill-snapshot.js +3 -0
- package/dist/workflows/dag/skills.js +7 -7
- package/dist/workflows/dag/structured-output-repair.js +4 -1
- package/dist/workflows/dag/terminal-status.js +502 -0
- package/dist/workflows/dag/test-artifact-namespace.js +73 -0
- package/dist/workflows/dag/types.js +58 -7
- package/dist/workflows/dag/validate.js +38 -13
- package/dist/workflows/dag/workspace-checkpoint.js +79 -1
- package/dist/workflows/loop/benchmark.js +11 -8
- package/docs/README.md +2 -1
- package/docs/architecture/dag-execution.md +4 -4
- package/docs/architecture/runtime-boundaries.md +29 -23
- package/docs/governance/README.md +1 -0
- package/docs/governance/harness-methodology-verification.md +11 -0
- package/docs/init-surface.manifest.json +44 -295
- package/docs/operations/README.md +4 -0
- package/docs/templates/README.md +5 -5
- package/docs/templates/agent-dag.base.json +9 -9
- package/docs/templates/agent-dag.final-verification.json +6 -6
- package/docs/templates/agent-dag.schema.json +2 -2
- package/docs/templates/agent-dag.supervised-implementation.json +12 -12
- package/docs/templates/backend-test-dag.generate-pytest.prompt.md +3 -3
- package/docs/templates/backend-test-dag.json +708 -703
- package/docs/templates/backend-test-dag.review-cases.prompt.md +3 -3
- package/docs/templates/frontend-design-contract.md +4 -4
- package/docs/templates/frontend-implementation-contract.schema.json +99 -22
- package/docs/templates/frontend-implementation-dag.json +7 -7
- package/docs/templates/frontend-test-case-checklist.md +2 -2
- package/docs/templates/frontend-test-case.example.md +2 -0
- package/docs/templates/frontend-test-dag.generate-cases.prompt.md +1 -1
- package/docs/templates/frontend-test-dag.json +46 -37
- package/docs/templates/frontend-test-dag.retrieve-context.prompt.md +2 -2
- package/docs/templates/frontend-test-dag.retrospect.prompt.md +1 -1
- package/docs/templates/frontend-test-dag.review-cases.prompt.md +1 -1
- package/docs/templates/hybrid-dag.json +9 -9
- package/docs/templates/knowledge-sync-dag.json +8 -8
- package/harness.json +1 -1
- package/package.json +27 -8
- package/resource-catalog.v1.json +1981 -0
- package/resources/agent-bridge/loop-agent/SKILL.md +40 -0
- package/resources/init-history/legacy-surface.v1.json +33 -0
- package/skills/fe-test-ui-scout/SKILL.md +4 -4
- package/skills/fe-test-ui-scout/references/ledger-schema.md +1 -1
- package/skills/frontend-bounded-implement/references/code-standards.md +3 -3
- package/skills/frontend-contract/SKILL.md +2 -1
- package/skills/frontend-contract/references/contract-protocol.md +22 -4
- package/skills/frontend-design-review/SKILL.md +16 -18
- package/skills/frontend-design-review/references/review-checklist.md +3 -4
- package/skills/frontend-plan/SKILL.md +25 -3
- package/skills/frontend-plan/references/decision-contract.md +117 -8
- package/skills/frontend-plan/references/design-decisions.md +32 -0
- package/skills/frontend-review/SKILL.md +29 -36
- package/skills/frontend-review/references/review-findings.md +8 -3
- package/skills/frontend-scout/references/scout-evidence.md +4 -0
- package/skills/init-update/SKILL.md +34 -0
- package/skills/init-update/agents/openai.yaml +6 -0
- package/skills/loop-agent/references/command-reference.md +8 -0
- package/skills/loop-agent/references/hybrid-dag.md +1 -1
- package/skills/playwright-cli/SKILL.md +1 -1
- package/skills/playwright-cli-case-generator/SKILL.md +7 -5
- package/dist/commands/new-task.js +0 -5
- package/dist/commands/status.js +0 -57
- package/dist/commands/task-contract.js +0 -269
- package/dist/shared/prompts.js +0 -26
- package/dist/task/config.js +0 -2
- package/dist/task/contract/validate-draft.js +0 -106
- package/dist/task/goal.js +0 -3
- package/dist/task/index.js +0 -12
- package/dist/task/lifecycle.js +0 -1
- package/dist/task/operator/capabilities.js +0 -6
- package/dist/task/operator/envelope.js +0 -2
- package/dist/task/operator/index.js +0 -5
- package/dist/task/operator/registry.js +0 -2
- package/dist/task/paths.js +0 -1
- package/dist/task/source-state.js +0 -1
- package/dist/task/subagent-guidance.js +0 -1
- package/dist/worker/console/chat/sift-bridge.js +0 -1
- package/dist/worker/console/index.js +0 -20
- package/dist/worker/console/static/assets/channel-CXqdP5pW.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-D9C3agF7.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-D9C3agF7.js +0 -1
- package/dist/worker/console/static/assets/index-CAZ2fC_X.css +0 -1
- package/dist/worker/console/static/assets/index-DhfjOafu.js +0 -449
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-Tp7V0U4q.js +0 -1
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-DUZWZWi8.js +0 -8
- package/dist/worker/scheduler/index.js +0 -25
- package/dist/workflows/dag/facts.js +0 -4
- package/dist/workflows/dag/frontend-shadow-dual-write.js +0 -941
- package/dist/workflows/dag/index.js +0 -6
- package/dist/workflows/dynamic/index.js +0 -7
- /package/dist/{task/operator/types.js → executors/dag-pi/plan/session.js} +0 -0
|
@@ -392,6 +392,147 @@ const COMMON_MUTATION_ERRORS = [
|
|
|
392
392
|
];
|
|
393
393
|
export function buildOperatorCapabilitiesDocument() {
|
|
394
394
|
const actions = [
|
|
395
|
+
{
|
|
396
|
+
action: "prepareScheduledTask", cli: "console scheduled task preparation", kind: "mutation",
|
|
397
|
+
inputSchemaVersion: 1, resultSchemaVersion: 1, envelopeSchemaVersion: 1, requiredErrorCodes: ["INVALID_INPUT"],
|
|
398
|
+
description: "Preferred entry for natural-language one-time scheduled tasks, including read-only inspection reports. Call this directly after understanding the goal, output scope, executable acceptance and time; the server uses the CURRENT project directory and creates the immutable PRD, managed Task and strict writeSet gate, binds THIS Chat automatically and returns a REAL planned goal/confirmation card. No pre-existing task, worktree or session ID is needed: never ask the user for these internal fields and do not manually create/edit them with bash/write/newTask/importPrd. Keep preparation concise: preserve the user goal without inventing extra requirements. Omit budget for ordinary tasks: the host freezes 5 goal attempts, 5 DAG runs and 4 supervisor calls, with a 15-minute latest-start grace and a 240-minute execution window, all shown before confirmation. maxTurns counts goal attempts, not model tool calls. Explicit budget or maxDurationMinutes is never raised. Use minimal independent acceptance commands (AC-1, AC-2), preferably existing test/build scripts or test -s scheduled-report.md for a report; no compound shell/pipelines/substitution, language-specific grep checks or redundant scope assertions (the host enforces scope). Infer routine defaults and verification commands from the repository; ask only about genuinely ambiguous goal/scope/time. For read-only requests allow just an ordinary report file in the current project directory, e.g. scheduled-report.md, not .harness/. Use schedule.delayMinutes for relative time (counted after preparation finishes), or localAt + IANA timezone for an exact date/time. The current workspace must match committed HEAD; never auto-commit/stash/reset existing changes. The card exposes the exact time, bounded defaults and committed base before one human confirmation. Same request in this Chat is idempotent. Only a returned goalId with state=planned is a prepared reservation; textual drafts, Tasks or failed operations are NOT bookings. Never replace a requested schedule with immediate execution or sleep, never call runDag or self-confirm. On failure explain the returned stage, correct business inputs and retry this tool; do not mutate imported PRD/runtime artifacts. For a new distinct appointment, make its goal/time distinct.",
|
|
399
|
+
inputParams: [{ name: "request", type: "object", required: true, description: "Business goal, workflow, allowedPaths, acceptance and schedule; optional forbiddenPaths/budget. Runtime identity is server-owned." }],
|
|
400
|
+
modelCallable: "always", humanConfirmation: "none",
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
"action": "prepareScheduledGoal",
|
|
404
|
+
"cli": "console scheduled goal service",
|
|
405
|
+
"kind": "mutation",
|
|
406
|
+
"inputSchemaVersion": 1,
|
|
407
|
+
"resultSchemaVersion": 1,
|
|
408
|
+
"envelopeSchemaVersion": 1,
|
|
409
|
+
"requiredErrorCodes": [
|
|
410
|
+
"INVALID_INPUT"
|
|
411
|
+
],
|
|
412
|
+
"description": "Advanced entry ONLY for an already prepared Task. For a new natural-language reservation use prepareScheduledTask instead. Requires the current repository or its linked worktree at frozenBase and a managed Task already strict-prepared at its writeSet gate. booking must include managedTaskId, originalGoal, chatSessionRef, workflow, worktreeRef, frozenBase, allowedPaths, forbiddenPaths, acceptance {policy, criteria [{acId,description,command}]}, budget {maxTurns,maxDagRuns,maxSupervisorCalls}, time {executeAtUtc,latestStartUtc,stopAtUtc,expiresAt,timezone,allowedHours,misfirePolicy}. This entry never fills omitted budget; for implementation work supply at least maxTurns=5, maxDagRuns=5, maxSupervisorCalls=4. Resolve natural-language dates with the user timezone; ask about ambiguous time/AC/scope. No execution or authorization occurs. Show the complete scope/time/budget for one browser confirmation. Never call runDag for this reservation.",
|
|
413
|
+
"inputParams": [
|
|
414
|
+
{
|
|
415
|
+
"name": "booking",
|
|
416
|
+
"type": "object",
|
|
417
|
+
"required": true,
|
|
418
|
+
"description": "Complete frozen booking inputs; never supply prepared, controllerRef, approval or owner tokens."
|
|
419
|
+
}
|
|
420
|
+
],
|
|
421
|
+
"modelCallable": "always",
|
|
422
|
+
"humanConfirmation": "none"
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
"action": "confirmScheduledGoal",
|
|
426
|
+
"cli": "console scheduled goal service",
|
|
427
|
+
"kind": "mutation",
|
|
428
|
+
"inputSchemaVersion": 1,
|
|
429
|
+
"resultSchemaVersion": 1,
|
|
430
|
+
"envelopeSchemaVersion": 1,
|
|
431
|
+
"requiredErrorCodes": [
|
|
432
|
+
"INVALID_INPUT"
|
|
433
|
+
],
|
|
434
|
+
"description": "Human browser confirmation of the exact displayed ScheduledGoal envelope.",
|
|
435
|
+
"inputParams": [
|
|
436
|
+
{
|
|
437
|
+
"name": "goalId",
|
|
438
|
+
"type": "string",
|
|
439
|
+
"required": true,
|
|
440
|
+
"description": "Prepared goal id"
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
"name": "stateVersion",
|
|
444
|
+
"type": "number",
|
|
445
|
+
"required": true,
|
|
446
|
+
"description": "Displayed state version"
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
"name": "envelopeHash",
|
|
450
|
+
"type": "string",
|
|
451
|
+
"required": true,
|
|
452
|
+
"description": "Displayed envelope hash"
|
|
453
|
+
}
|
|
454
|
+
],
|
|
455
|
+
"modelCallable": "never",
|
|
456
|
+
"humanConfirmation": "required"
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
"action": "cancelScheduledGoal",
|
|
460
|
+
"cli": "console scheduled goal service",
|
|
461
|
+
"kind": "mutation",
|
|
462
|
+
"inputSchemaVersion": 1,
|
|
463
|
+
"resultSchemaVersion": 1,
|
|
464
|
+
"envelopeSchemaVersion": 1,
|
|
465
|
+
"requiredErrorCodes": [
|
|
466
|
+
"INVALID_INPUT"
|
|
467
|
+
],
|
|
468
|
+
"description": "Cancel future ScheduledGoal admission; in-flight/unknown ownership remains until reconciled.",
|
|
469
|
+
"inputParams": [
|
|
470
|
+
{
|
|
471
|
+
"name": "goalId",
|
|
472
|
+
"type": "string",
|
|
473
|
+
"required": true,
|
|
474
|
+
"description": "Goal id"
|
|
475
|
+
},
|
|
476
|
+
{
|
|
477
|
+
"name": "stateVersion",
|
|
478
|
+
"type": "number",
|
|
479
|
+
"required": true,
|
|
480
|
+
"description": "Current state version"
|
|
481
|
+
},
|
|
482
|
+
{
|
|
483
|
+
"name": "reason",
|
|
484
|
+
"type": "string",
|
|
485
|
+
"required": true,
|
|
486
|
+
"description": "Human cancellation reason"
|
|
487
|
+
}
|
|
488
|
+
],
|
|
489
|
+
"modelCallable": "never",
|
|
490
|
+
"humanConfirmation": "required"
|
|
491
|
+
},
|
|
492
|
+
{
|
|
493
|
+
"action": "scheduledGoalGet",
|
|
494
|
+
"cli": "console scheduled goal service",
|
|
495
|
+
"kind": "read",
|
|
496
|
+
"inputSchemaVersion": 1,
|
|
497
|
+
"resultSchemaVersion": 1,
|
|
498
|
+
"envelopeSchemaVersion": 1,
|
|
499
|
+
"requiredErrorCodes": [
|
|
500
|
+
"INVALID_INPUT"
|
|
501
|
+
],
|
|
502
|
+
"description": "Read a durable ScheduledGoal booking and separate execution, acceptance, delivery and reconciliation results. Never implies authorization.",
|
|
503
|
+
"inputParams": [
|
|
504
|
+
{
|
|
505
|
+
"name": "goalId",
|
|
506
|
+
"type": "string",
|
|
507
|
+
"required": true,
|
|
508
|
+
"description": "Goal id"
|
|
509
|
+
}
|
|
510
|
+
],
|
|
511
|
+
"modelCallable": "always",
|
|
512
|
+
"humanConfirmation": "none"
|
|
513
|
+
},
|
|
514
|
+
{
|
|
515
|
+
"action": "scheduledGoalList",
|
|
516
|
+
"cli": "console scheduled goal service",
|
|
517
|
+
"kind": "read",
|
|
518
|
+
"inputSchemaVersion": 1,
|
|
519
|
+
"resultSchemaVersion": 1,
|
|
520
|
+
"envelopeSchemaVersion": 1,
|
|
521
|
+
"requiredErrorCodes": [
|
|
522
|
+
"INVALID_INPUT"
|
|
523
|
+
],
|
|
524
|
+
"description": "List durable ScheduledGoals, including those whose original Chat was archived or deleted.",
|
|
525
|
+
"inputParams": [
|
|
526
|
+
{
|
|
527
|
+
"name": "chatSessionRef",
|
|
528
|
+
"type": "string",
|
|
529
|
+
"required": false,
|
|
530
|
+
"description": "Optional original Chat session id"
|
|
531
|
+
}
|
|
532
|
+
],
|
|
533
|
+
"modelCallable": "always",
|
|
534
|
+
"humanConfirmation": "none"
|
|
535
|
+
},
|
|
395
536
|
{
|
|
396
537
|
action: "operatorCapabilities",
|
|
397
538
|
cli: "loop-agent operator capabilities --json",
|
|
@@ -714,6 +855,24 @@ export function buildOperatorCapabilitiesDocument() {
|
|
|
714
855
|
required: false,
|
|
715
856
|
description: "optional verify commands (label:command or shell)",
|
|
716
857
|
},
|
|
858
|
+
{
|
|
859
|
+
name: "requirementOwnership",
|
|
860
|
+
type: "array",
|
|
861
|
+
required: false,
|
|
862
|
+
description: "optional frozen requirement→file ownership for frontend-implementation DAGs: [{requirementIds, implementationFiles?, verificationFiles?}] — machine-enforced at plan finalize",
|
|
863
|
+
},
|
|
864
|
+
{
|
|
865
|
+
name: "capabilityBoundary",
|
|
866
|
+
type: "object",
|
|
867
|
+
required: false,
|
|
868
|
+
description: "optional frozen test capability boundary {allowed?, forbidden?, requiredClauses?} composed into dependencyPolicy by the runtime",
|
|
869
|
+
},
|
|
870
|
+
{
|
|
871
|
+
name: "interactionIds",
|
|
872
|
+
type: "array",
|
|
873
|
+
required: false,
|
|
874
|
+
description: "optional frozen interaction id vocabulary — contract interaction names are machine-checked against it at plan finalize",
|
|
875
|
+
},
|
|
717
876
|
],
|
|
718
877
|
modelCallable: "always",
|
|
719
878
|
humanConfirmation: "none",
|
|
@@ -1069,6 +1228,26 @@ export function buildOperatorCapabilitiesDocument() {
|
|
|
1069
1228
|
required: false,
|
|
1070
1229
|
description: "verification entries as label:command strings",
|
|
1071
1230
|
},
|
|
1231
|
+
{
|
|
1232
|
+
name: "requirementOwnership",
|
|
1233
|
+
type: "array",
|
|
1234
|
+
itemsType: "string",
|
|
1235
|
+
required: false,
|
|
1236
|
+
description: "frozen requirement→file ownership: [{requirementIds, implementationFiles?, verificationFiles?}] — machine-enforced at plan finalize",
|
|
1237
|
+
},
|
|
1238
|
+
{
|
|
1239
|
+
name: "capabilityBoundary",
|
|
1240
|
+
type: "object",
|
|
1241
|
+
required: false,
|
|
1242
|
+
description: "frozen test capability boundary {allowed?, forbidden?, requiredClauses?} composed into dependencyPolicy by the runtime",
|
|
1243
|
+
},
|
|
1244
|
+
{
|
|
1245
|
+
name: "interactionIds",
|
|
1246
|
+
type: "array",
|
|
1247
|
+
itemsType: "string",
|
|
1248
|
+
required: false,
|
|
1249
|
+
description: "frozen interaction id vocabulary — contract interaction names are machine-checked against it at plan finalize",
|
|
1250
|
+
},
|
|
1072
1251
|
{
|
|
1073
1252
|
name: "approveGate",
|
|
1074
1253
|
type: "string",
|
|
@@ -1770,6 +1949,12 @@ export const OPERATOR_COMMAND_COVERAGE = Object.freeze([
|
|
|
1770
1949
|
action: "doctor",
|
|
1771
1950
|
source: "loop-agent",
|
|
1772
1951
|
},
|
|
1952
|
+
{
|
|
1953
|
+
command: "loop-agent promote-run",
|
|
1954
|
+
coverage: "excluded",
|
|
1955
|
+
action: null,
|
|
1956
|
+
source: "loop-agent",
|
|
1957
|
+
},
|
|
1773
1958
|
{
|
|
1774
1959
|
command: "loop-agent task advance",
|
|
1775
1960
|
coverage: "model-callable",
|
|
@@ -106,8 +106,9 @@ export function computeBinarySha256(filePath) {
|
|
|
106
106
|
* Compute a portable, deterministic content fingerprint for the installed
|
|
107
107
|
* package rooted at `packageRoot`.
|
|
108
108
|
*
|
|
109
|
-
* The fingerprint covers
|
|
110
|
-
*
|
|
109
|
+
* The fingerprint covers executable code plus package-owned Skills, templates,
|
|
110
|
+
* bridge resources, and their generated catalog. It is independent of the
|
|
111
|
+
* absolute installation path.
|
|
111
112
|
*
|
|
112
113
|
* Sorting uses code-point order (UTF-8 byte comparison), NOT localeCompare,
|
|
113
114
|
* to ensure deterministic behaviour across locales.
|
|
@@ -118,35 +119,43 @@ export function computePackageFingerprint(packageRoot) {
|
|
|
118
119
|
"bin/**",
|
|
119
120
|
"dist/**",
|
|
120
121
|
"skills/**",
|
|
122
|
+
"docs/templates/**",
|
|
123
|
+
"resources/**",
|
|
124
|
+
"resource-catalog.v1.json",
|
|
121
125
|
];
|
|
122
126
|
// Collecting entries ---------------------------------------------------
|
|
123
127
|
const entries = [];
|
|
124
128
|
// 1) package.json (required single file)
|
|
125
129
|
addRequiredFile(entries, path.join(packageRoot, "package.json"), "");
|
|
126
|
-
// 2)
|
|
127
|
-
for (const dir of ["bin", "dist", "skills"]) {
|
|
130
|
+
// 2) Package-owned executable and controller-resource trees.
|
|
131
|
+
for (const dir of ["bin", "dist", "skills", "docs/templates", "resources"]) {
|
|
128
132
|
const absoluteDir = path.join(packageRoot, dir);
|
|
129
133
|
collectTree(entries, absoluteDir, dir);
|
|
130
134
|
}
|
|
131
|
-
// 3)
|
|
135
|
+
// 3) The generated catalog binds logical resource ids to those bytes. It is
|
|
136
|
+
// optional only for source/test fixtures; published packages always ship it.
|
|
137
|
+
addOptionalFile(entries, path.join(packageRoot, "resource-catalog.v1.json"), "");
|
|
138
|
+
// 4) Deterministic sort by relative path (code-point / byte order)
|
|
132
139
|
entries.sort((a, b) => {
|
|
133
140
|
const aBuf = Buffer.from(a.relativePath, "utf-8");
|
|
134
141
|
const bBuf = Buffer.from(b.relativePath, "utf-8");
|
|
135
142
|
const minLen = Math.min(aBuf.length, bBuf.length);
|
|
136
143
|
for (let i = 0; i < minLen; i++) {
|
|
137
|
-
|
|
138
|
-
|
|
144
|
+
const aByte = aBuf[i];
|
|
145
|
+
const bByte = bBuf[i];
|
|
146
|
+
if (aByte !== bByte)
|
|
147
|
+
return (aByte ?? 0) - (bByte ?? 0);
|
|
139
148
|
}
|
|
140
149
|
return aBuf.length - bBuf.length;
|
|
141
150
|
});
|
|
142
|
-
//
|
|
151
|
+
// 5) Cumulative hash: hash of (<relativePath> + "\t" + <contentHash>) lines
|
|
143
152
|
const cumulative = createHash("sha256");
|
|
144
153
|
for (const entry of entries) {
|
|
145
154
|
cumulative.update(`${entry.relativePath}\t${entry.contentHash}\n`);
|
|
146
155
|
}
|
|
147
156
|
return {
|
|
148
157
|
algorithm: "sha256",
|
|
149
|
-
scopeVersion:
|
|
158
|
+
scopeVersion: 2,
|
|
150
159
|
scope,
|
|
151
160
|
value: `sha256:${cumulative.digest("hex")}`,
|
|
152
161
|
fileCount: entries.length,
|
|
@@ -183,8 +192,8 @@ export function resolveBinPaths(requested, resolvedAt, inputs) {
|
|
|
183
192
|
// Search PATH
|
|
184
193
|
const pathEnv = env.PATH ?? env.Path ?? env.path ?? "";
|
|
185
194
|
const candidates = resolveFromPath(requested, pathEnv, osPlatform, env.PATHEXT ?? env.Pathext ?? env.pathext, cwd);
|
|
186
|
-
|
|
187
|
-
|
|
195
|
+
const entry = candidates[0];
|
|
196
|
+
if (entry !== undefined) {
|
|
188
197
|
assertRegularFile(entry, requested);
|
|
189
198
|
return { requested, entry, realEntry: realpathSync(entry), resolvedAt };
|
|
190
199
|
}
|
|
@@ -314,6 +323,15 @@ function addRequiredFile(entries, absolutePath, relativeDir) {
|
|
|
314
323
|
: path.basename(absolutePath);
|
|
315
324
|
entries.push({ relativePath, contentHash });
|
|
316
325
|
}
|
|
326
|
+
function addOptionalFile(entries, absolutePath, relativeDir) {
|
|
327
|
+
try {
|
|
328
|
+
addRequiredFile(entries, absolutePath, relativeDir);
|
|
329
|
+
}
|
|
330
|
+
catch (error) {
|
|
331
|
+
if (!isNotFound(error))
|
|
332
|
+
throw error;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
317
335
|
function collectTree(entries, absoluteDir, relativeDir) {
|
|
318
336
|
let stats;
|
|
319
337
|
try {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { constants as fsConstants } from "node:fs";
|
|
2
2
|
import { lstat, open, realpath } from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
import { sameFileIdentity } from "./file-identity.js";
|
|
4
5
|
function assertContained(root, target, label) {
|
|
5
6
|
if (target === root || !target.startsWith(`${root}${path.sep}`)) {
|
|
6
7
|
throw new Error(`${label}: path escapes boundary: ${target}`);
|
|
@@ -81,8 +82,7 @@ export async function readFileBoundarySafe(input) {
|
|
|
81
82
|
if (current.isSymbolicLink() ||
|
|
82
83
|
!current.isFile() ||
|
|
83
84
|
current.nlink !== 1 ||
|
|
84
|
-
current
|
|
85
|
-
current.ino !== opened.ino) {
|
|
85
|
+
!sameFileIdentity(opened, current)) {
|
|
86
86
|
throw new Error(`${input.label}: path changed while opening`);
|
|
87
87
|
}
|
|
88
88
|
return await handle.readFile();
|
|
@@ -1,49 +1,64 @@
|
|
|
1
|
+
import { shouldRewriteAssistantTransientProviderError } from "../pi-provider-recovery.js";
|
|
1
2
|
import { buildOverflowCheckpoint } from "./checkpoint.js";
|
|
3
|
+
import { prunePiToolResultMessages, } from "./tool-result-pruner.js";
|
|
2
4
|
import { shouldRewriteAssistantOverflow } from "./overflow.js";
|
|
3
5
|
import { clearRetrieveBypass, compressProviderPayload, createSiftRetrieveToolDefinition, SIFT_RETRIEVE_TOOL_NAME, } from "./sift-bridge.js";
|
|
4
6
|
import { emptyContextPressureCounters, incrementCounter, } from "./telemetry.js";
|
|
5
7
|
export function createCompactionController() {
|
|
6
8
|
return {
|
|
7
9
|
proactiveCompaction: false,
|
|
10
|
+
pruneArmed: false,
|
|
8
11
|
counters: emptyContextPressureCounters(),
|
|
9
12
|
};
|
|
10
13
|
}
|
|
11
14
|
export function createContextPressureExtension(options) {
|
|
12
15
|
const l2 = options.policy.mode !== "off";
|
|
13
16
|
const l1 = Boolean(options.sift);
|
|
14
|
-
|
|
17
|
+
const pruner = l2 && options.prune !== undefined;
|
|
18
|
+
const transientRecovery = options.normalizeTransientProviderErrors === true;
|
|
19
|
+
if (!l2 && !l1 && !transientRecovery)
|
|
15
20
|
return undefined;
|
|
16
21
|
return {
|
|
17
22
|
name: options.name ?? "operator-chat-context-pressure",
|
|
18
23
|
hidden: true,
|
|
19
24
|
factory: (api) => {
|
|
20
|
-
if (l2) {
|
|
25
|
+
if (l2 || transientRecovery) {
|
|
21
26
|
api.on("message_end", (event) => {
|
|
22
27
|
const message = event.message;
|
|
23
28
|
if (!message || typeof message !== "object")
|
|
24
29
|
return undefined;
|
|
25
30
|
const rec = message;
|
|
26
|
-
if (
|
|
27
|
-
|
|
31
|
+
if (l2) {
|
|
32
|
+
if (typeof rec.errorMessage === "string") {
|
|
33
|
+
options.controller.lastError = rec.errorMessage;
|
|
34
|
+
}
|
|
35
|
+
if (rec.role === "assistant") {
|
|
36
|
+
clearRetrieveBypassIfPresent(options.sift);
|
|
37
|
+
}
|
|
38
|
+
const rewritten = shouldRewriteAssistantOverflow(message);
|
|
39
|
+
if (rewritten) {
|
|
40
|
+
incrementCounter(options.controller.counters, "overflow");
|
|
41
|
+
return {
|
|
42
|
+
message: {
|
|
43
|
+
...rec,
|
|
44
|
+
errorMessage: rewritten,
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
28
48
|
}
|
|
29
|
-
if (
|
|
30
|
-
|
|
49
|
+
if (transientRecovery) {
|
|
50
|
+
return shouldRewriteAssistantTransientProviderError(message);
|
|
31
51
|
}
|
|
32
|
-
|
|
33
|
-
if (!rewritten)
|
|
34
|
-
return undefined;
|
|
35
|
-
incrementCounter(options.controller.counters, "overflow");
|
|
36
|
-
return {
|
|
37
|
-
message: {
|
|
38
|
-
...rec,
|
|
39
|
-
errorMessage: rewritten,
|
|
40
|
-
},
|
|
41
|
-
};
|
|
52
|
+
return undefined;
|
|
42
53
|
});
|
|
54
|
+
}
|
|
55
|
+
if (l2) {
|
|
43
56
|
api.on("session_before_compact", (event) => {
|
|
44
57
|
const reason = event.reason;
|
|
45
58
|
if (reason === "overflow") {
|
|
46
59
|
incrementCounter(options.controller.counters, "overflow");
|
|
60
|
+
if (pruner)
|
|
61
|
+
options.controller.pruneArmed = true;
|
|
47
62
|
}
|
|
48
63
|
if (reason === "manual") {
|
|
49
64
|
incrementCounter(options.controller.counters, "manual");
|
|
@@ -69,6 +84,24 @@ export function createContextPressureExtension(options) {
|
|
|
69
84
|
};
|
|
70
85
|
});
|
|
71
86
|
}
|
|
87
|
+
if (pruner) {
|
|
88
|
+
api.on("context", (event) => {
|
|
89
|
+
if (!options.controller.pruneArmed)
|
|
90
|
+
return undefined;
|
|
91
|
+
const messages = Array.isArray(event.messages) ? event.messages : [];
|
|
92
|
+
try {
|
|
93
|
+
const result = prunePiToolResultMessages(messages, options.prune);
|
|
94
|
+
if (!result.changed)
|
|
95
|
+
return undefined;
|
|
96
|
+
options.controller.counters.toolResultPruned += result.messagesPruned;
|
|
97
|
+
options.controller.counters.charsPrunedEstimate += result.charsRemoved;
|
|
98
|
+
return { messages: result.messages };
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
72
105
|
if (l1 && options.sift) {
|
|
73
106
|
const sift = options.sift;
|
|
74
107
|
api.on("before_provider_request", (event) => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { isContextOverflow, CONTEXT_OVERFLOW_PHRASES, OVERFLOW_FIXTURES, NORMALIZED_OVERFLOW_PREFIX, shouldRewriteAssistantOverflow, normalizeOverflowErrorMessage, buildGeneratedOverflowClassifierSource, } from "./overflow.js";
|
|
2
2
|
export { parseCompactionPolicy, deriveEffectiveWindow, conservativeTokenEstimate, projectPromptPressure, applyProcessCompactionOverride, inMemoryCompactionSettings, PI_DEFAULT_RESERVE_TOKENS, DEFAULT_KEEP_RECENT_TOKENS, } from "./compaction-policy.js";
|
|
3
3
|
export { buildOverflowCheckpoint } from "./checkpoint.js";
|
|
4
|
+
export { PI_TOOL_RESULT_PRUNE_MARKER, DEFAULT_PI_TOOL_RESULT_PRUNE_CONFIG, resolvePiToolResultPruneConfig, parsePiToolResultPruneConfig, piCodePointLength, prunePiToolResultMessages, } from "./tool-result-pruner.js";
|
|
4
5
|
export { createContextPressureExtension, createCompactionController, } from "./extension.js";
|
|
5
6
|
export { createSiftBridgeState, parseSiftBridgeConfig, compressProviderPayload, executeSiftRetrieve, housekeepSiftStash, createSiftRetrieveToolDefinition, SIFT_RETRIEVE_TOOL_NAME, SIFT_POLICY_VERSION, } from "./sift-bridge.js";
|
|
6
7
|
export { isConsoleSiftEnabled, isDagSiftEnabled, readContextPressureMode, parseEnabledFlag, parseContextPressureMode, } from "./env.js";
|
|
@@ -268,7 +268,7 @@ export function sliceUtf8Range(text, offset, maxBytes) {
|
|
|
268
268
|
}
|
|
269
269
|
const buffer = Buffer.from(text, "utf8");
|
|
270
270
|
let end = Math.min(totalBytes, start + limit);
|
|
271
|
-
while (end > start && (buffer[end] & 0b1100_0000) === 0b1000_0000) {
|
|
271
|
+
while (end > start && ((buffer[end] ?? 0) & 0b1100_0000) === 0b1000_0000) {
|
|
272
272
|
end -= 1;
|
|
273
273
|
}
|
|
274
274
|
const slice = buffer.subarray(start, end).toString("utf8");
|
|
@@ -9,6 +9,8 @@ export function emptyContextPressureCounters() {
|
|
|
9
9
|
l0CompactFailed: 0,
|
|
10
10
|
tokensSavedEstimate: 0,
|
|
11
11
|
blocksCompressed: 0,
|
|
12
|
+
toolResultPruned: 0,
|
|
13
|
+
charsPrunedEstimate: 0,
|
|
12
14
|
};
|
|
13
15
|
}
|
|
14
16
|
export function incrementCounter(counters, reason, amount = 1) {
|
|
@@ -47,5 +49,7 @@ export function projectSafeTelemetry(counters) {
|
|
|
47
49
|
failOpen: counters.failOpen,
|
|
48
50
|
tokensSavedEstimate: counters.tokensSavedEstimate,
|
|
49
51
|
blocksCompressed: counters.blocksCompressed,
|
|
52
|
+
toolResultPruned: counters.toolResultPruned,
|
|
53
|
+
charsPrunedEstimate: counters.charsPrunedEstimate,
|
|
50
54
|
};
|
|
51
55
|
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/** Deterministic, model-free pruning of Pi tool-result messages. */
|
|
2
|
+
import { parseBoundedNumber, parseEnabledFlag } from "./env.js";
|
|
3
|
+
export const PI_TOOL_RESULT_PRUNE_MARKER = "\n\n[... tool result middle pruned ...]\n\n";
|
|
4
|
+
export const DEFAULT_PI_TOOL_RESULT_PRUNE_CONFIG = Object.freeze({ thresholdChars: 8192, headChars: 4096, tailChars: 1024 });
|
|
5
|
+
export function parsePiToolResultPruneConfig(env = process.env) {
|
|
6
|
+
const enabled = parseEnabledFlag(env.HARNESS_TOOL_RESULT_PRUNE, true);
|
|
7
|
+
const diagnostics = enabled.diagnostic ? [enabled.diagnostic] : [];
|
|
8
|
+
const threshold = parseBoundedNumber(env.HARNESS_TOOL_RESULT_PRUNE_THRESHOLD_CHARS, 8192, 1, 1_000_000);
|
|
9
|
+
const head = parseBoundedNumber(env.HARNESS_TOOL_RESULT_PRUNE_HEAD_CHARS, 4096, 0, 1_000_000);
|
|
10
|
+
const tail = parseBoundedNumber(env.HARNESS_TOOL_RESULT_PRUNE_TAIL_CHARS, 1024, 0, 1_000_000);
|
|
11
|
+
for (const item of [threshold, head, tail])
|
|
12
|
+
if (item.diagnostic)
|
|
13
|
+
diagnostics.push(item.diagnostic);
|
|
14
|
+
try {
|
|
15
|
+
return { enabled: enabled.enabled, config: resolvePiToolResultPruneConfig({ thresholdChars: Math.floor(threshold.value), headChars: Math.floor(head.value), tailChars: Math.floor(tail.value) }), diagnostics };
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
diagnostics.push(error instanceof Error ? error.message : String(error));
|
|
19
|
+
return { enabled: false, config: DEFAULT_PI_TOOL_RESULT_PRUNE_CONFIG, diagnostics };
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function resolvePiToolResultPruneConfig(config = {}) {
|
|
23
|
+
const keys = new Set(["thresholdChars", "headChars", "tailChars"]);
|
|
24
|
+
for (const key of Object.keys(config))
|
|
25
|
+
if (!keys.has(key))
|
|
26
|
+
throw new Error(`PiToolResultPruneConfig: unknown key "${key}"`);
|
|
27
|
+
const out = { thresholdChars: config.thresholdChars ?? 8192, headChars: config.headChars ?? 4096, tailChars: config.tailChars ?? 1024 };
|
|
28
|
+
if (!Number.isInteger(out.thresholdChars) || out.thresholdChars <= 0)
|
|
29
|
+
throw new Error("thresholdChars must be positive integer");
|
|
30
|
+
if (!Number.isInteger(out.headChars) || out.headChars < 0)
|
|
31
|
+
throw new Error("headChars must be non-negative integer");
|
|
32
|
+
if (!Number.isInteger(out.tailChars) || out.tailChars < 0)
|
|
33
|
+
throw new Error("tailChars must be non-negative integer");
|
|
34
|
+
if (out.headChars + Array.from(PI_TOOL_RESULT_PRUNE_MARKER).length + out.tailChars > out.thresholdChars)
|
|
35
|
+
throw new Error("prune budgets exceed threshold");
|
|
36
|
+
return Object.freeze(out);
|
|
37
|
+
}
|
|
38
|
+
export function piCodePointLength(text) { return Array.from(text).length; }
|
|
39
|
+
function textBlock(value) { return value && typeof value === "object" && value.type === "text" && typeof value.text === "string"; }
|
|
40
|
+
function isToolResult(message) { return message.role === "tool" || message.role === "toolResult" || message.type === "tool_result" || message.role === "tool_result"; }
|
|
41
|
+
function pruneBlocks(input, cfg) {
|
|
42
|
+
const before = input.reduce((n, b) => n + (textBlock(b) ? piCodePointLength(b.text) : 0), 0);
|
|
43
|
+
if (before <= cfg.thresholdChars)
|
|
44
|
+
return { blocks: null, before, after: before };
|
|
45
|
+
const cutStart = cfg.headChars, cutEnd = before - cfg.tailChars;
|
|
46
|
+
let consumed = 0, inserted = false;
|
|
47
|
+
const out = [];
|
|
48
|
+
for (const block of input) {
|
|
49
|
+
if (!textBlock(block)) {
|
|
50
|
+
out.push(block);
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
const points = Array.from(block.text);
|
|
54
|
+
const bs = consumed, be = bs + points.length;
|
|
55
|
+
const headEnd = Math.min(points.length, Math.max(0, cutStart - bs));
|
|
56
|
+
const tailStart = Math.min(points.length, Math.max(0, cutEnd - bs));
|
|
57
|
+
const marker = !inserted && bs < cutEnd && be > cutStart ? PI_TOOL_RESULT_PRUNE_MARKER : "";
|
|
58
|
+
if (marker)
|
|
59
|
+
inserted = true;
|
|
60
|
+
const text = points.slice(0, headEnd).join("") + marker + points.slice(tailStart).join("");
|
|
61
|
+
if (text)
|
|
62
|
+
out.push({ ...block, text });
|
|
63
|
+
consumed = be;
|
|
64
|
+
}
|
|
65
|
+
const after = out.reduce((n, b) => n + (textBlock(b) ? piCodePointLength(b.text) : 0), 0);
|
|
66
|
+
if (!inserted || after > cfg.thresholdChars || after >= before)
|
|
67
|
+
throw new Error("Pi tool-result prune invariant failed");
|
|
68
|
+
return { blocks: out, before, after };
|
|
69
|
+
}
|
|
70
|
+
/** Returns a new transcript; input/full originals are never mutated or persisted. */
|
|
71
|
+
export function prunePiToolResultMessages(messages, config) {
|
|
72
|
+
const cfg = resolvePiToolResultPruneConfig(config);
|
|
73
|
+
const output = messages.slice();
|
|
74
|
+
let charsRemoved = 0, messagesPruned = 0;
|
|
75
|
+
for (let i = 0; i < output.length; i++) {
|
|
76
|
+
const message = output[i];
|
|
77
|
+
if (!message || !isToolResult(message))
|
|
78
|
+
continue;
|
|
79
|
+
if (typeof message.content === "string") {
|
|
80
|
+
const r = pruneBlocks([{ type: "text", text: message.content }], cfg);
|
|
81
|
+
if (r.blocks) {
|
|
82
|
+
output[i] = { ...message, content: r.blocks[0].text };
|
|
83
|
+
charsRemoved += r.before - r.after;
|
|
84
|
+
messagesPruned++;
|
|
85
|
+
}
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (!Array.isArray(message.content))
|
|
89
|
+
continue;
|
|
90
|
+
const r = pruneBlocks(message.content, cfg);
|
|
91
|
+
if (r.blocks) {
|
|
92
|
+
output[i] = { ...message, content: r.blocks };
|
|
93
|
+
charsRemoved += r.before - r.after;
|
|
94
|
+
messagesPruned++;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return { messages: output, changed: messagesPruned > 0, charsRemoved, messagesPruned };
|
|
98
|
+
}
|