@tea-agent/loop-agent 0.1.0-fe-test.4 → 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 +442 -2524
- 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 +1517 -3180
- 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 +358 -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/map.js +15 -2
- 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 +14 -3
- package/dist/workflows/dag/frontend-test-case-generation-assessment.js +88 -0
- package/dist/workflows/dag/frontend-test-case-manifest.js +6 -1
- 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-test-result-contract.js +15 -1
- 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 -7077
- 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 +79 -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 +48 -39
- 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
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { harnessManifestSchema, verificationCommandsSchema, workflowPolicySchema, workerPolicySchema, worktreeManifestConfigSchema, } from "./manifest-types.js";
|
|
5
|
+
function isSafeProjectPath(value) {
|
|
6
|
+
if (!value || path.isAbsolute(value))
|
|
7
|
+
return false;
|
|
8
|
+
return !value.replaceAll("\\", "/").split("/").some((part) => part === "" || part === "." || part === "..");
|
|
9
|
+
}
|
|
10
|
+
const nullablePathMapSchema = z.record(z.string(), z.string().refine(isSafeProjectPath, "path must be a safe project-relative path").nullable());
|
|
11
|
+
/** Shared, credential-free overrides that are safe to commit with the project. */
|
|
12
|
+
export const projectConfigSchema = z
|
|
13
|
+
.object({
|
|
14
|
+
$schema: z.string().optional(),
|
|
15
|
+
version: z.literal(1),
|
|
16
|
+
verification: verificationCommandsSchema.optional(),
|
|
17
|
+
entrypoints: nullablePathMapSchema.optional(),
|
|
18
|
+
artifacts: nullablePathMapSchema.optional(),
|
|
19
|
+
workflowPolicy: workflowPolicySchema.optional(),
|
|
20
|
+
workerPolicy: workerPolicySchema.optional(),
|
|
21
|
+
worktree: worktreeManifestConfigSchema.optional(),
|
|
22
|
+
})
|
|
23
|
+
.strict();
|
|
24
|
+
const EMPTY_VERIFICATION = { quick: [], standard: [], full: [] };
|
|
25
|
+
function appendUnique(left, right) {
|
|
26
|
+
return [...new Set([...left, ...right])];
|
|
27
|
+
}
|
|
28
|
+
function mergeVerification(tracked, local) {
|
|
29
|
+
const shared = tracked ?? EMPTY_VERIFICATION;
|
|
30
|
+
const machine = local ?? EMPTY_VERIFICATION;
|
|
31
|
+
const sources = [];
|
|
32
|
+
if ([...shared.quick, ...shared.standard, ...shared.full].length > 0)
|
|
33
|
+
sources.push("tracked");
|
|
34
|
+
if ([...machine.quick, ...machine.standard, ...machine.full].length > 0)
|
|
35
|
+
sources.push("local");
|
|
36
|
+
return {
|
|
37
|
+
quick: appendUnique(shared.quick, machine.quick),
|
|
38
|
+
standard: appendUnique(shared.standard, machine.standard),
|
|
39
|
+
full: appendUnique(shared.full, machine.full),
|
|
40
|
+
reproducibility: sources.includes("local") ? "local-only" : sources.includes("tracked") ? "tracked" : "inferred",
|
|
41
|
+
sources,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
async function readOptionalJson(file) {
|
|
45
|
+
try {
|
|
46
|
+
return JSON.parse(await readFile(file, "utf8"));
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
if (error.code === "ENOENT")
|
|
50
|
+
return undefined;
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Load package defaults, tracked project policy, then machine-local runtime
|
|
56
|
+
* settings. Local verification is additive by construction: it cannot remove
|
|
57
|
+
* or replace a command committed in project.json.
|
|
58
|
+
*/
|
|
59
|
+
export async function loadNormalizedProjectConfig(repoRoot) {
|
|
60
|
+
const localPath = path.join(repoRoot, "harness.json");
|
|
61
|
+
const trackedPath = path.join(repoRoot, ".loop-agent", "project.json");
|
|
62
|
+
const [localRaw, trackedRaw] = await Promise.all([
|
|
63
|
+
readOptionalJson(localPath),
|
|
64
|
+
readOptionalJson(trackedPath),
|
|
65
|
+
]);
|
|
66
|
+
if (localRaw === undefined)
|
|
67
|
+
throw Object.assign(new Error("harness.json not found"), { code: "HARNESS_NOT_FOUND" });
|
|
68
|
+
const local = harnessManifestSchema.parse(localRaw);
|
|
69
|
+
const tracked = trackedRaw === undefined ? undefined : projectConfigSchema.parse(trackedRaw);
|
|
70
|
+
const verification = mergeVerification(tracked?.verification, local.verification);
|
|
71
|
+
const localInput = localRaw;
|
|
72
|
+
const localFields = { ...local };
|
|
73
|
+
delete localFields.modelProfiles;
|
|
74
|
+
const manifest = harnessManifestSchema.parse({
|
|
75
|
+
...localFields,
|
|
76
|
+
entrypoints: { ...(tracked?.entrypoints ?? {}), ...(local.entrypoints ?? {}) },
|
|
77
|
+
artifacts: { ...(tracked?.artifacts ?? {}), ...(local.artifacts ?? {}) },
|
|
78
|
+
workflowPolicy: Object.hasOwn(localInput, "workflowPolicy") ? local.workflowPolicy : tracked?.workflowPolicy ?? local.workflowPolicy,
|
|
79
|
+
workerPolicy: Object.hasOwn(localInput, "workerPolicy") ? local.workerPolicy : tracked?.workerPolicy ?? local.workerPolicy,
|
|
80
|
+
worktree: Object.hasOwn(localInput, "worktree") ? local.worktree : tracked?.worktree ?? local.worktree,
|
|
81
|
+
verification: {
|
|
82
|
+
quick: verification.quick,
|
|
83
|
+
standard: verification.standard,
|
|
84
|
+
full: verification.full,
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
return {
|
|
88
|
+
schemaVersion: 1,
|
|
89
|
+
manifest,
|
|
90
|
+
verification,
|
|
91
|
+
sources: {
|
|
92
|
+
tracked: tracked ? ".loop-agent/project.json" : null,
|
|
93
|
+
local: "harness.json",
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { lstat, readFile, realpath, stat } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import { findPackageRoot } from "../shared/package-metadata.js";
|
|
7
|
+
const SHA256_RE = /^[a-f0-9]{64}$/;
|
|
8
|
+
function isSafePackagePath(value) {
|
|
9
|
+
if (!value || path.isAbsolute(value) || value.includes("\\"))
|
|
10
|
+
return false;
|
|
11
|
+
const parts = value.split("/");
|
|
12
|
+
return parts.every((part) => part !== "" && part !== "." && part !== "..");
|
|
13
|
+
}
|
|
14
|
+
export const resourceCatalogEntrySchema = z
|
|
15
|
+
.object({
|
|
16
|
+
id: z.string().trim().min(1).regex(/^[A-Za-z0-9][A-Za-z0-9:._/-]*$/),
|
|
17
|
+
path: z.string().refine(isSafePackagePath, "path must stay within the package root"),
|
|
18
|
+
kind: z.enum(["document", "skill", "template", "schema", "prompt", "script", "other"]),
|
|
19
|
+
bytes: z.number().int().nonnegative(),
|
|
20
|
+
sha256: z.string().regex(SHA256_RE),
|
|
21
|
+
schemaVersion: z.number().int().positive(),
|
|
22
|
+
})
|
|
23
|
+
.strict();
|
|
24
|
+
export const resourceCatalogSchema = z
|
|
25
|
+
.object({
|
|
26
|
+
schemaVersion: z.literal(1),
|
|
27
|
+
entries: z.array(resourceCatalogEntrySchema),
|
|
28
|
+
})
|
|
29
|
+
.strict()
|
|
30
|
+
.superRefine((catalog, ctx) => {
|
|
31
|
+
const ids = new Set();
|
|
32
|
+
const paths = new Set();
|
|
33
|
+
for (const [index, entry] of catalog.entries.entries()) {
|
|
34
|
+
if (ids.has(entry.id))
|
|
35
|
+
ctx.addIssue({ code: "custom", path: ["entries", index, "id"], message: "duplicate resource id" });
|
|
36
|
+
if (paths.has(entry.path))
|
|
37
|
+
ctx.addIssue({ code: "custom", path: ["entries", index, "path"], message: "duplicate resource path" });
|
|
38
|
+
ids.add(entry.id);
|
|
39
|
+
paths.add(entry.path);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
export const CONTROLLER_RESOURCE_IDS = {
|
|
43
|
+
loopAgentBridgeSkill: "agent-bridge:loop-agent",
|
|
44
|
+
};
|
|
45
|
+
export function builtinSkillResourceId(name) {
|
|
46
|
+
return `builtin-skill:${name}`;
|
|
47
|
+
}
|
|
48
|
+
export function builtinSkillReferenceResourceId(name, relativePath) {
|
|
49
|
+
return `builtin-skill-resource:${name}/${relativePath}`;
|
|
50
|
+
}
|
|
51
|
+
export class ResourceCatalogError extends Error {
|
|
52
|
+
code;
|
|
53
|
+
constructor(code, message) {
|
|
54
|
+
super(message);
|
|
55
|
+
this.code = code;
|
|
56
|
+
this.name = "ResourceCatalogError";
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function sha256(bytes) {
|
|
60
|
+
return createHash("sha256").update(bytes).digest("hex");
|
|
61
|
+
}
|
|
62
|
+
async function assertContainedRegularFile(root, candidate) {
|
|
63
|
+
const [rootReal, candidateReal, linkInfo] = await Promise.all([
|
|
64
|
+
realpath(root),
|
|
65
|
+
realpath(candidate),
|
|
66
|
+
lstat(candidate),
|
|
67
|
+
]);
|
|
68
|
+
const relative = path.relative(rootReal, candidateReal);
|
|
69
|
+
if (!relative || relative.startsWith("..") || path.isAbsolute(relative)) {
|
|
70
|
+
throw new ResourceCatalogError("RESOURCE_PATH_ESCAPE", `resource resolves outside package root: ${candidate}`);
|
|
71
|
+
}
|
|
72
|
+
if (!linkInfo.isFile() || linkInfo.isSymbolicLink() || linkInfo.nlink !== 1) {
|
|
73
|
+
throw new ResourceCatalogError("RESOURCE_NOT_REGULAR", `resource is not a regular file: ${candidate}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/** Lazy package resource provider: load the small catalog once, hash bytes only when used. */
|
|
77
|
+
export class ControllerContextProvider {
|
|
78
|
+
packageRoot;
|
|
79
|
+
identity;
|
|
80
|
+
entries;
|
|
81
|
+
constructor(packageRoot, catalog, catalogBytes) {
|
|
82
|
+
this.packageRoot = packageRoot;
|
|
83
|
+
this.entries = new Map(catalog.entries.map((entry) => [entry.id, entry]));
|
|
84
|
+
this.identity = { schemaVersion: 1, catalogDigest: sha256(catalogBytes) };
|
|
85
|
+
}
|
|
86
|
+
static async load(packageRoot, catalogName = "resource-catalog.v1.json") {
|
|
87
|
+
const catalogPath = path.join(packageRoot, catalogName);
|
|
88
|
+
await assertContainedRegularFile(packageRoot, catalogPath);
|
|
89
|
+
const bytes = await readFile(catalogPath);
|
|
90
|
+
let parsed;
|
|
91
|
+
try {
|
|
92
|
+
parsed = JSON.parse(bytes.toString("utf8"));
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
throw new ResourceCatalogError("RESOURCE_CATALOG_INVALID", `invalid resource catalog JSON: ${String(error)}`);
|
|
96
|
+
}
|
|
97
|
+
const catalog = resourceCatalogSchema.safeParse(parsed);
|
|
98
|
+
if (!catalog.success) {
|
|
99
|
+
throw new ResourceCatalogError("RESOURCE_CATALOG_INVALID", `invalid resource catalog: ${catalog.error.message}`);
|
|
100
|
+
}
|
|
101
|
+
return new ControllerContextProvider(packageRoot, catalog.data, bytes);
|
|
102
|
+
}
|
|
103
|
+
list() {
|
|
104
|
+
return [...this.entries.values()].map((entry) => ({ ...entry }));
|
|
105
|
+
}
|
|
106
|
+
entry(id) {
|
|
107
|
+
const entry = this.entries.get(id);
|
|
108
|
+
return entry ? { ...entry } : undefined;
|
|
109
|
+
}
|
|
110
|
+
async read(id) {
|
|
111
|
+
const entry = this.entries.get(id);
|
|
112
|
+
if (!entry)
|
|
113
|
+
throw new ResourceCatalogError("RESOURCE_NOT_FOUND", `resource not found: ${id}`);
|
|
114
|
+
const file = path.join(this.packageRoot, ...entry.path.split("/"));
|
|
115
|
+
await assertContainedRegularFile(this.packageRoot, file);
|
|
116
|
+
const before = await stat(file);
|
|
117
|
+
const bytes = await readFile(file);
|
|
118
|
+
const after = await stat(file);
|
|
119
|
+
if (before.dev !== after.dev || before.ino !== after.ino || before.size !== after.size || before.mtimeMs !== after.mtimeMs) {
|
|
120
|
+
throw new ResourceCatalogError("RESOURCE_CHANGED_DURING_READ", `resource changed while reading: ${id}`);
|
|
121
|
+
}
|
|
122
|
+
if (bytes.byteLength !== entry.bytes || sha256(bytes) !== entry.sha256) {
|
|
123
|
+
throw new ResourceCatalogError("RESOURCE_HASH_MISMATCH", `resource does not match catalog: ${id}`);
|
|
124
|
+
}
|
|
125
|
+
return bytes;
|
|
126
|
+
}
|
|
127
|
+
async readText(id) {
|
|
128
|
+
const entry = this.entries.get(id);
|
|
129
|
+
if (!entry)
|
|
130
|
+
throw new ResourceCatalogError("RESOURCE_NOT_FOUND", `resource not found: ${id}`);
|
|
131
|
+
const bytes = await this.read(id);
|
|
132
|
+
return {
|
|
133
|
+
id,
|
|
134
|
+
relativePath: entry.path,
|
|
135
|
+
absolutePath: path.join(this.packageRoot, ...entry.path.split("/")),
|
|
136
|
+
kind: entry.kind,
|
|
137
|
+
schemaVersion: entry.schemaVersion,
|
|
138
|
+
bytes: entry.bytes,
|
|
139
|
+
sha256: entry.sha256,
|
|
140
|
+
text: bytes.toString("utf8"),
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
export async function createControllerContextProvider(options = {}) {
|
|
145
|
+
const packageRoot = options.packageRoot
|
|
146
|
+
?? findPackageRoot(path.dirname(fileURLToPath(import.meta.url)));
|
|
147
|
+
if (!packageRoot) {
|
|
148
|
+
throw new ResourceCatalogError("PACKAGE_ROOT_NOT_FOUND", "cannot locate the loop-agent package root for controller resources");
|
|
149
|
+
}
|
|
150
|
+
return ControllerContextProvider.load(packageRoot, options.catalogName ?? "resource-catalog.v1.json");
|
|
151
|
+
}
|
|
@@ -45,6 +45,9 @@ export function openConsoleAppData(options) {
|
|
|
45
45
|
chats: path.join(repoNamespace, "chats"),
|
|
46
46
|
chatSessions: path.join(repoNamespace, "chat-sessions"),
|
|
47
47
|
chatEvents: path.join(repoNamespace, "chat-events"),
|
|
48
|
+
browserProfile: path.join(repoNamespace, "browser-profile"),
|
|
49
|
+
browserDownloads: path.join(repoNamespace, "browser-downloads"),
|
|
50
|
+
browserScreenshots: path.join(repoNamespace, "browser-screenshots"),
|
|
48
51
|
resourcePreferences: path.join(repoNamespace, "resource-preferences.json"),
|
|
49
52
|
};
|
|
50
53
|
for (const dir of [
|
|
@@ -60,6 +63,9 @@ export function openConsoleAppData(options) {
|
|
|
60
63
|
paths.chats,
|
|
61
64
|
paths.chatSessions,
|
|
62
65
|
paths.chatEvents,
|
|
66
|
+
paths.browserProfile,
|
|
67
|
+
paths.browserDownloads,
|
|
68
|
+
paths.browserScreenshots,
|
|
63
69
|
path.dirname(paths.resourcePreferences),
|
|
64
70
|
]) {
|
|
65
71
|
ensureSecureDir(dir);
|
|
@@ -284,13 +290,17 @@ export async function removeStaged(filePath) {
|
|
|
284
290
|
await rm(filePath, { force: true });
|
|
285
291
|
}
|
|
286
292
|
/** Synchronous helpers used by boot-time path checks. */
|
|
287
|
-
export function writeSecureJsonSync(filePath, value) {
|
|
293
|
+
export function writeSecureJsonSync(filePath, value, options) {
|
|
288
294
|
const dir = path.dirname(filePath);
|
|
289
295
|
ensureSecureDir(dir);
|
|
290
296
|
const resolved = assertSafeAppDataPath(dir, filePath);
|
|
291
297
|
const tmp = `${resolved}.${process.pid}.${randomBytes(4).toString("hex")}.tmp`;
|
|
298
|
+
const pretty = options?.pretty !== false;
|
|
299
|
+
const body = pretty
|
|
300
|
+
? `${JSON.stringify(value, null, 2)}\n`
|
|
301
|
+
: `${JSON.stringify(value)}\n`;
|
|
292
302
|
try {
|
|
293
|
-
writeFileSync(tmp,
|
|
303
|
+
writeFileSync(tmp, body, {
|
|
294
304
|
encoding: "utf8",
|
|
295
305
|
mode: 0o600,
|
|
296
306
|
});
|
|
@@ -6,6 +6,26 @@ import { buildFrontendSplitAggregateCloseout, computeFrontendSplitDigest, finali
|
|
|
6
6
|
import { frontendCloseoutFactsSchema, frontendTestHandoffSchema, } from "../../workflows/dag/frontend-closeout.js";
|
|
7
7
|
import { listJsonFiles, readJsonIfExists, sha256Json, writeSecureJson, } from "./app-data.js";
|
|
8
8
|
export const TERMINAL_OPERATION_STATES = new Set(["succeeded", "failed", "timed-out", "restarting"]);
|
|
9
|
+
/**
|
|
10
|
+
* Operation states that hold an admission slot. needs-reconcile requires
|
|
11
|
+
* inspection but does not itself prove a live operation; callers still check
|
|
12
|
+
* DAG/Worker/chat activity separately. restarting is the terminal receipt of
|
|
13
|
+
* a successful Console handoff, retained across boots, not a live slot.
|
|
14
|
+
* A needs-reconcile record remains visible as a non-business outcome, but
|
|
15
|
+
* must never strand later mutations after its runtime is gone.
|
|
16
|
+
*/
|
|
17
|
+
export const OCCUPIED_OPERATION_STATES = new Set(["queued", "starting", "running"]);
|
|
18
|
+
/** True when the state can still make progress and therefore holds the slot. */
|
|
19
|
+
export function isOperationOccupied(state) {
|
|
20
|
+
return OCCUPIED_OPERATION_STATES.has(state);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* True when no further state transition will ever occur: a business terminal
|
|
24
|
+
* (succeeded/failed/timed-out/restarting) or a stranded needs-reconcile.
|
|
25
|
+
*/
|
|
26
|
+
export function isOperationSettled(state) {
|
|
27
|
+
return TERMINAL_OPERATION_STATES.has(state) || state === "needs-reconcile";
|
|
28
|
+
}
|
|
9
29
|
function operationFile(appData, operationId) {
|
|
10
30
|
return path.join(appData.operations, `${operationId}.json`);
|
|
11
31
|
}
|
|
@@ -359,14 +379,11 @@ export class OperationStore {
|
|
|
359
379
|
for (const op of await this.list()) {
|
|
360
380
|
if (TERMINAL_OPERATION_STATES.has(op.state))
|
|
361
381
|
continue;
|
|
362
|
-
// A consoleUpdateAndInit
|
|
363
|
-
//
|
|
364
|
-
//
|
|
365
|
-
// handoff target. Mark it succeeded instead of surfacing the
|
|
366
|
-
// generic needs-reconcile failure copy to the operator.
|
|
382
|
+
// A consoleUpdateAndInit that proved its handoff before the process
|
|
383
|
+
// died must not be reported as a stranded failure: the booting
|
|
384
|
+
// process IS the handoff target, so the update actually succeeded.
|
|
367
385
|
if (op.action === "consoleUpdateAndInit" &&
|
|
368
|
-
op
|
|
369
|
-
isProvenConsoleUpdateHandoff(op.result)) {
|
|
386
|
+
isProvenConsoleUpdateHandoff(op)) {
|
|
370
387
|
changed.push(await this.update(op.operationId, {
|
|
371
388
|
state: "succeeded",
|
|
372
389
|
errorCode: undefined,
|
|
@@ -398,17 +415,34 @@ export function isTerminalOperationState(state) {
|
|
|
398
415
|
return TERMINAL_OPERATION_STATES.has(state);
|
|
399
416
|
}
|
|
400
417
|
/**
|
|
401
|
-
* True when a consoleUpdateAndInit
|
|
402
|
-
* (install verified +
|
|
403
|
-
*
|
|
404
|
-
*
|
|
418
|
+
* True when a consoleUpdateAndInit record proves the handoff actually
|
|
419
|
+
* succeeded (install verified + new Console spawned), so boot reconcile can
|
|
420
|
+
* close it as succeeded even though the dying process never wrote its
|
|
421
|
+
* terminal state.
|
|
422
|
+
*
|
|
423
|
+
* The proof reads the maintenance projection rather than only `result.state`.
|
|
424
|
+
* The old check required `result.state === "restarting"`, but the executor
|
|
425
|
+
* writes `state` and `maintenance` together (`console-update-and-init.ts`),
|
|
426
|
+
* so any path that recorded the handoff proof together with a non-restarting
|
|
427
|
+
* `state` — most importantly the `needs-reconcile` record that
|
|
428
|
+
* `acceptConsoleUpdateAndInit` writes when the executor throws *after* a
|
|
429
|
+
* successful handoff — could never satisfy it. Such records were stranded
|
|
430
|
+
* forever: boot reconcile skipped them and they blocked later updates.
|
|
431
|
+
*
|
|
432
|
+
* `handoff.status === "requested"` is only ever set on the success path, and
|
|
433
|
+
* `package.status === "failed"` explicitly disqualifies a record, so this
|
|
434
|
+
* stays fail-closed for genuine failures.
|
|
405
435
|
*/
|
|
406
|
-
function isProvenConsoleUpdateHandoff(
|
|
436
|
+
export function isProvenConsoleUpdateHandoff(operation) {
|
|
437
|
+
if (!operation || operation.action !== "consoleUpdateAndInit")
|
|
438
|
+
return false;
|
|
439
|
+
const result = operation.result;
|
|
407
440
|
if (!result || typeof result !== "object")
|
|
408
441
|
return false;
|
|
409
442
|
const shape = result;
|
|
410
|
-
|
|
411
|
-
|
|
443
|
+
if (shape.maintenance?.handoff?.status !== "requested")
|
|
444
|
+
return false;
|
|
445
|
+
return shape.maintenance?.package?.status !== "failed";
|
|
412
446
|
}
|
|
413
447
|
export function clipPreview(text, max = 4096) {
|
|
414
448
|
if (text.length <= max)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { readFileBoundarySafe } from "../../shared/path-safety.js";
|
|
1
2
|
import { access, mkdir, readdir, readFile, rename, rm } from "node:fs/promises";
|
|
2
3
|
import path from "node:path";
|
|
3
4
|
import { mkdtemp } from "node:fs/promises";
|
|
@@ -30,28 +31,27 @@ async function pathExists(filePath) {
|
|
|
30
31
|
function serializeManifest(manifest) {
|
|
31
32
|
return `${JSON.stringify(manifest, null, 2)}\n`;
|
|
32
33
|
}
|
|
34
|
+
function compareArtifactPaths(a, b) {
|
|
35
|
+
return a.path < b.path ? -1 : a.path > b.path ? 1 : 0;
|
|
36
|
+
}
|
|
33
37
|
function normalizeTasksForStorage(tasks) {
|
|
34
38
|
return [...tasks]
|
|
35
39
|
.map((task) => ({
|
|
36
40
|
...task,
|
|
37
41
|
taskRef: task.taskRef.replace(/\\/g, "/"),
|
|
38
42
|
seeds: [...task.seeds].sort((a, b) => a - b),
|
|
43
|
+
...("category" in task ? {
|
|
44
|
+
requirements: [...task.requirements].sort(compareArtifactPaths),
|
|
45
|
+
initialFiles: [...task.initialFiles].sort(compareArtifactPaths),
|
|
46
|
+
oracleFiles: [...task.oracleFiles].sort(compareArtifactPaths),
|
|
47
|
+
} : {}),
|
|
39
48
|
}))
|
|
40
49
|
.sort((a, b) => a.taskRef < b.taskRef ? -1 : a.taskRef > b.taskRef ? 1 : 0);
|
|
41
50
|
}
|
|
42
51
|
export async function materializeCorpusManifest(raw) {
|
|
43
52
|
const input = corpusManifestInputSchema.parse(raw);
|
|
44
53
|
const tasks = normalizeTasksForStorage(input.tasks);
|
|
45
|
-
const
|
|
46
|
-
schemaVersion: 1,
|
|
47
|
-
corpusId: input.corpusId,
|
|
48
|
-
createdAt: input.createdAt,
|
|
49
|
-
...(input.description !== undefined
|
|
50
|
-
? { description: input.description }
|
|
51
|
-
: {}),
|
|
52
|
-
tasks,
|
|
53
|
-
};
|
|
54
|
-
const corpusHash = computeCorpusHash(withoutHash);
|
|
54
|
+
const corpusHash = computeCorpusHash(input);
|
|
55
55
|
if (input.corpusHash) {
|
|
56
56
|
const provided = formatContentSha(normalizeContentSha(input.corpusHash));
|
|
57
57
|
if (provided !== corpusHash) {
|
|
@@ -59,10 +59,30 @@ export async function materializeCorpusManifest(raw) {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
return corpusManifestSchema.parse({
|
|
62
|
-
...
|
|
62
|
+
...input,
|
|
63
|
+
tasks,
|
|
63
64
|
corpusHash,
|
|
64
65
|
});
|
|
65
66
|
}
|
|
67
|
+
export async function assertCorpusArtifacts(repoRoot, manifest) {
|
|
68
|
+
if (manifest.schemaVersion !== 2)
|
|
69
|
+
return;
|
|
70
|
+
const snapshots = new Map();
|
|
71
|
+
for (const task of manifest.tasks)
|
|
72
|
+
for (const ref of [...task.requirements, ...task.initialFiles, ...task.oracleFiles]) {
|
|
73
|
+
const bytes = await readFileBoundarySafe({ boundaryRoot: repoRoot,
|
|
74
|
+
targetPath: path.resolve(repoRoot, ref.path), label: "frontend corpus artifact" });
|
|
75
|
+
if (sha256Hex(bytes) !== ref.sha256)
|
|
76
|
+
throw Error(`corpus artifact hash mismatch: ${ref.path}`);
|
|
77
|
+
snapshots.set(ref.path, bytes);
|
|
78
|
+
}
|
|
79
|
+
for (const [file, expected] of snapshots) {
|
|
80
|
+
const actual = await readFileBoundarySafe({ boundaryRoot: repoRoot,
|
|
81
|
+
targetPath: path.resolve(repoRoot, file), label: "frontend corpus artifact recheck" });
|
|
82
|
+
if (!actual.equals(expected))
|
|
83
|
+
throw Error(`corpus artifact changed during collection: ${file}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
66
86
|
async function assertManifestIntegrity(repoRoot, corpusId, rawManifest) {
|
|
67
87
|
const integrityPath = path.join(corpusDir(repoRoot, corpusId), MANIFEST_INTEGRITY_FILE);
|
|
68
88
|
const expected = (await readFile(integrityPath, "utf-8")).trim();
|
|
@@ -98,6 +118,7 @@ export async function readCorpusManifest(repoRoot, corpusId) {
|
|
|
98
118
|
if (recomputed !== stored.corpusHash) {
|
|
99
119
|
throw new Error(`corpusHash mismatch for ${corpusId}: expected ${recomputed}, got ${stored.corpusHash}`);
|
|
100
120
|
}
|
|
121
|
+
await assertCorpusArtifacts(repoRoot, stored);
|
|
101
122
|
return stored;
|
|
102
123
|
}
|
|
103
124
|
export async function listCorpusIds(repoRoot) {
|
|
@@ -117,7 +138,11 @@ export async function listCorpusIds(repoRoot) {
|
|
|
117
138
|
}
|
|
118
139
|
}
|
|
119
140
|
export async function registerCorpusManifest(input) {
|
|
120
|
-
const
|
|
141
|
+
const repoRoot = input.repoRoot;
|
|
142
|
+
const manifest = corpusManifestSchema.parse(input.manifest);
|
|
143
|
+
if (computeCorpusHash(manifest) !== manifest.corpusHash)
|
|
144
|
+
throw Error("corpusHash mismatch");
|
|
145
|
+
await assertCorpusArtifacts(repoRoot, manifest);
|
|
121
146
|
assertCorpusId(manifest.corpusId);
|
|
122
147
|
const manifestPath = corpusManifestPath(repoRoot, manifest.corpusId);
|
|
123
148
|
if (await pathExists(manifestPath)) {
|
|
@@ -81,6 +81,8 @@ function isUnchangedNewTaskTemplate(step, content) {
|
|
|
81
81
|
}
|
|
82
82
|
function firstRequiredSectionIsEmpty(step, content) {
|
|
83
83
|
const [, firstSectionHeading] = REQUIRED_HEADINGS[step];
|
|
84
|
+
if (!firstSectionHeading)
|
|
85
|
+
return false;
|
|
84
86
|
const headingIndex = content.indexOf(firstSectionHeading);
|
|
85
87
|
if (headingIndex < 0) {
|
|
86
88
|
return false;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { buildControllerIdentityFromEntry, readBuildStamp } from "./package-metadata.js";
|
|
5
|
+
export function sha256File(file) {
|
|
6
|
+
return `sha256:${createHash("sha256").update(readFileSync(file)).digest("hex")}`;
|
|
7
|
+
}
|
|
8
|
+
export function classifyBackendDogfoodProvenance(input) {
|
|
9
|
+
if (input.tarballPath)
|
|
10
|
+
return { kind: "local-tarball", version: input.identity.packageVersion, tarballSha256: sha256File(input.tarballPath) };
|
|
11
|
+
if (input.distTag)
|
|
12
|
+
return { kind: "published-npm", version: input.identity.packageVersion, distTag: input.distTag };
|
|
13
|
+
return { kind: "local-candidate", version: input.identity.packageVersion };
|
|
14
|
+
}
|
|
15
|
+
export function buildBackendDogfoodIdentityEvidence(input) {
|
|
16
|
+
const controller = buildControllerIdentityFromEntry({ requested: input.controllerEntry, entry: path.resolve(input.controllerEntry) });
|
|
17
|
+
if (!controller)
|
|
18
|
+
throw new Error("BACKEND_DOGFOOD_IDENTITY_UNRESOLVED");
|
|
19
|
+
const fingerprint = controller.packageFingerprint.value;
|
|
20
|
+
if (fingerprint !== input.expectedFingerprint)
|
|
21
|
+
throw new Error(`BACKEND_DOGFOOD_CONTROLLER_MISMATCH: expected ${input.expectedFingerprint}, got ${fingerprint}`);
|
|
22
|
+
const consoleIdentity = input.consoleHost
|
|
23
|
+
? undefined
|
|
24
|
+
: buildControllerIdentityFromEntry({
|
|
25
|
+
requested: input.consoleControllerEntry ?? path.join(controller.packageRoot, "bin", "agent-worker.js"),
|
|
26
|
+
entry: input.consoleControllerEntry ?? path.join(controller.packageRoot, "bin", "agent-worker.js"),
|
|
27
|
+
});
|
|
28
|
+
if (!input.consoleHost && !consoleIdentity)
|
|
29
|
+
throw new Error("BACKEND_DOGFOOD_CONSOLE_IDENTITY_UNRESOLVED");
|
|
30
|
+
const consoleHost = {
|
|
31
|
+
packageName: String(input.consoleHost?.packageName ?? consoleIdentity?.packageName),
|
|
32
|
+
packageVersion: String(input.consoleHost?.packageVersion ?? consoleIdentity?.packageVersion),
|
|
33
|
+
packageFingerprint: String(input.consoleHost?.packageFingerprint ?? consoleIdentity?.packageFingerprint.value),
|
|
34
|
+
};
|
|
35
|
+
const expected = `${controller.packageName}@${controller.packageVersion}@${fingerprint}`;
|
|
36
|
+
const actual = `${consoleHost.packageName}@${consoleHost.packageVersion}@${consoleHost.packageFingerprint}`;
|
|
37
|
+
if (actual !== expected)
|
|
38
|
+
throw new Error(`BACKEND_DOGFOOD_CONSOLE_IDENTITY_MISMATCH: expected ${expected}, got ${actual}`);
|
|
39
|
+
return {
|
|
40
|
+
schemaVersion: 1,
|
|
41
|
+
controller,
|
|
42
|
+
provenance: classifyBackendDogfoodProvenance({ identity: controller, distTag: input.distTag, tarballPath: input.tarballPath }),
|
|
43
|
+
buildCommitSha: readBuildStamp(controller.packageRoot)?.gitSha ?? null,
|
|
44
|
+
consoleHost,
|
|
45
|
+
dagController: { packageName: controller.packageName, packageVersion: controller.packageVersion, packageFingerprint: fingerprint },
|
|
46
|
+
};
|
|
47
|
+
}
|
|
@@ -59,10 +59,19 @@ const RAW_TO_NORMALIZED = {
|
|
|
59
59
|
quota: "executor",
|
|
60
60
|
"rate-limit": "executor",
|
|
61
61
|
unavailable: "executor",
|
|
62
|
+
// Gateway reachability outage: still an executor-class failure, but named so
|
|
63
|
+
// reports do not read as a capability mismatch.
|
|
64
|
+
"upstream-unavailable": "executor",
|
|
62
65
|
// Context window overflow (400 request-too-large): the session needs
|
|
63
66
|
// compaction / fresh context before retrying — an executor-side
|
|
64
67
|
// environment condition, not a plan-quality defect.
|
|
65
68
|
"context-overflow": "executor",
|
|
69
|
+
// stopReason=length output-capacity truncation: same executor-side
|
|
70
|
+
// capacity class as context-overflow. Legacy thinking-exhausted labels
|
|
71
|
+
// (pre-output-limit artifacts) map to the same class.
|
|
72
|
+
"output-limit": "executor",
|
|
73
|
+
"writer-thinking-exhausted": "executor",
|
|
74
|
+
"planner-thinking-exhausted": "executor",
|
|
66
75
|
// Deterministic capability/policy refusal: missing verified launcher JS
|
|
67
76
|
// entry, capability allowlist rejection, or missing bounded write tool
|
|
68
77
|
// profile. These are environment/config defects the operator repairs
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compare two stat records as the same file identity.
|
|
3
|
+
*
|
|
4
|
+
* POSIX: `dev` and `ino` together identify the inode; both must match.
|
|
5
|
+
*
|
|
6
|
+
* win32: libuv reports `dev` inconsistently across stat APIs — `fstat()`
|
|
7
|
+
* (from an open handle) returns the volume serial number while `lstat()`
|
|
8
|
+
* (from a path) returns 0. A cross-API comparison therefore always fails on
|
|
9
|
+
* Windows even when the path still refers to the same file, breaking every
|
|
10
|
+
* guard that rechecks identity after opening (user-reported on 0.42.1 and
|
|
11
|
+
* 0.43.0, Node 23.x). On win32 the `dev` field is skipped and `ino` plus the
|
|
12
|
+
* caller-side type/link/realpath checks remain the identity boundary.
|
|
13
|
+
*
|
|
14
|
+
* When both stats come from the same API the comparison is exact on every
|
|
15
|
+
* platform; the win32 relaxation only affects cross-API rechecks.
|
|
16
|
+
*/
|
|
17
|
+
export function sameFileIdentity(opened, current, platform = process.platform) {
|
|
18
|
+
if (current.ino !== opened.ino)
|
|
19
|
+
return false;
|
|
20
|
+
if (platform !== "win32" && current.dev !== opened.dev)
|
|
21
|
+
return false;
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** Execution hints and estimation reserves, never model-name capacity defaults. */
|
|
3
|
+
export const frontendExecutionPolicySchema = z.object({
|
|
4
|
+
scopeTargetBytes: z.number().int().positive().default(24_000),
|
|
5
|
+
maxScopeUnits: z.number().int().positive().default(4),
|
|
6
|
+
maxCoverageConcurrency: z.number().int().min(1).max(4).default(4),
|
|
7
|
+
outputReserveTokens: z.number().int().positive().default(4096),
|
|
8
|
+
readGrowthReserveTokens: z.number().int().nonnegative().default(2048),
|
|
9
|
+
safetyRatio: z.number().min(0).max(0.5).default(0.15),
|
|
10
|
+
}).strict();
|
|
11
|
+
export function frontendModelCapabilities(model) {
|
|
12
|
+
const value = model && typeof model === "object" ? model : {};
|
|
13
|
+
const positive = (v) => typeof v === "number" && Number.isFinite(v) && v > 0 ? v : null;
|
|
14
|
+
return { model: typeof value.id === "string" ? `${value.provider ?? "unknown"}/${value.id}` : null, source: Object.keys(value).length ? "model-registry" : "unknown", inputLimit: positive(value.inputLimit), totalContextLimit: positive(value.contextWindow), outputLimit: positive(value.maxTokens), reasoningControllability: "unknown" };
|
|
15
|
+
}
|
|
16
|
+
export function measureFrontendRequestEnvelope(context, model, policy) {
|
|
17
|
+
const bytes = Buffer.byteLength(JSON.stringify(context));
|
|
18
|
+
const estimatedTokens = Math.ceil(bytes / 3);
|
|
19
|
+
const capabilities = frontendModelCapabilities(model);
|
|
20
|
+
const outputReserve = Math.min(policy.outputReserveTokens, capabilities.outputLimit ?? policy.outputReserveTokens);
|
|
21
|
+
const availableInputTokens = Math.min(capabilities.inputLimit ?? Infinity, capabilities.totalContextLimit === null ? Infinity : Math.floor(capabilities.totalContextLimit * (1 - policy.safetyRatio)) - outputReserve - policy.readGrowthReserveTokens);
|
|
22
|
+
return { bytes, estimatedTokens, estimatorVersion: "utf8-bytes-div3-v1-estimate", capabilities, availableInputTokens: Number.isFinite(availableInputTokens) ? availableInputTokens : null, exceedsEstimate: estimatedTokens > availableInputTokens };
|
|
23
|
+
}
|
|
@@ -112,6 +112,8 @@ function globToRegExp(pattern) {
|
|
|
112
112
|
let regex = '^';
|
|
113
113
|
for (let i = 0; i < normalized.length; i += 1) {
|
|
114
114
|
const char = normalized[i];
|
|
115
|
+
if (char === undefined)
|
|
116
|
+
continue;
|
|
115
117
|
const next = normalized[i + 1];
|
|
116
118
|
if (char === '*' && next === '*') {
|
|
117
119
|
const afterGlobstar = normalized[i + 2];
|