@tea-agent/loop-agent 0.1.0-fe-test.2 → 0.1.0-fe-test.4
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 +6 -3
- package/CHANGELOG.md +607 -93
- package/README.md +11 -5
- package/bin/loop-agent.js +7 -3
- package/dist/adapters/context-transfer/optional-pi-handoff.js +31 -0
- package/dist/adapters/context-transfer/pi-session.js +61 -0
- package/dist/application/dag/generate-task-dag.js +90 -21
- package/dist/application/dag/run-dag.js +41 -0
- package/dist/application/task-lifecycle/advance.js +40 -5
- package/dist/application/task-lifecycle/observe.js +171 -17
- package/dist/application/task-lifecycle/plan-transitions.js +42 -7
- package/dist/application/task-lifecycle/recommendations.js +13 -2
- package/dist/build-stamp.json +3 -3
- package/dist/cli/command-definitions.js +44 -10
- package/dist/cli/program.js +82 -6
- package/dist/cli/update/notifier.js +2 -2
- package/dist/cli/update/runtime-activity.js +1 -29
- package/dist/cli.js +2 -1
- package/dist/commands/client-recovery.js +11 -36
- package/dist/commands/dag-artifact.js +284 -0
- package/dist/commands/dag-context.js +184 -0
- package/dist/commands/dag-follow-up.js +138 -0
- package/dist/commands/dag-rerun-task.js +2 -0
- package/dist/commands/dag-rerun.js +261 -2
- package/dist/commands/init-model-catalog.js +486 -0
- package/dist/commands/init-upgrade.js +265 -97
- package/dist/commands/init.js +455 -28
- package/dist/commands/inspect-next.js +8 -0
- package/dist/commands/task-advance.js +73 -1
- package/dist/commands/task-source-prepare.js +5 -0
- package/dist/commands/task-status.js +1 -0
- package/dist/executors/dag-pi-executor.js +4321 -231
- package/dist/executors/pi-event-serializer.js +42 -1
- package/dist/executors/pi-executor.js +70 -6
- package/dist/executors/pi-extension-resolver.js +245 -0
- package/dist/executors/pi-playwright-cli-tool.js +74 -28
- package/dist/executors/pi-read-budget-policy.js +239 -0
- package/dist/executors/pi-sdk-executor.js +263 -59
- package/dist/executors/pi-writer-tool-policy.js +57 -1
- package/dist/executors/shell-executor.js +1443 -240
- package/dist/executors/shell-write-guard.js +14 -0
- package/dist/executors/workspace-write-snapshot.js +68 -0
- package/dist/governance/checks.js +1 -0
- package/dist/{worker → infrastructure}/console/app-data.js +4 -0
- package/dist/infrastructure/console/artifact-revision-store.js +430 -0
- package/dist/infrastructure/console/context-export-store.js +160 -0
- package/dist/infrastructure/console/dir-lock.js +132 -0
- package/dist/infrastructure/console/operation-store.js +417 -0
- package/dist/infrastructure/harness/artifact-store.js +10 -1
- package/dist/infrastructure/harness/atomic-write.js +35 -2
- package/dist/shared/context-transfer/artifact-revision.js +172 -0
- package/dist/shared/context-transfer.js +418 -0
- package/dist/shared/dag-failure-category.js +150 -0
- package/dist/shared/dag-prompt-override.js +27 -0
- package/dist/shared/openspec-spec.js +70 -4
- package/dist/shared/operator/capabilities.js +65 -4
- package/dist/shared/operator/safe-run-summary.js +1 -0
- package/dist/shared/path-safety.js +93 -0
- package/dist/shared/pi-context-pressure/checkpoint.js +116 -0
- package/dist/shared/pi-context-pressure/compaction-policy.js +151 -0
- package/dist/shared/pi-context-pressure/env.js +58 -0
- package/dist/shared/pi-context-pressure/extension.js +100 -0
- package/dist/shared/pi-context-pressure/index.js +7 -0
- package/dist/shared/pi-context-pressure/overflow.js +252 -0
- package/dist/shared/pi-context-pressure/sift-bridge.js +386 -0
- package/dist/shared/pi-context-pressure/telemetry.js +51 -0
- package/dist/shared/playwright-cli-command-policy.js +15 -0
- package/dist/shared/preview.js +28 -4
- package/dist/shared/update/console-notifier.js +100 -0
- package/dist/{cli → shared}/update/npm-client.js +70 -15
- package/dist/{cli → shared}/update/state.js +41 -13
- package/dist/task/config-types.js +125 -6
- package/dist/task/contract/adopt.js +4 -0
- package/dist/task/contract/apply.js +11 -1
- package/dist/task/contract/constants.js +3 -0
- package/dist/task/contract/diff.js +26 -0
- package/dist/task/contract/hash.js +3 -0
- package/dist/task/contract/import-revision.js +4 -0
- package/dist/task/contract/observe.js +25 -4
- package/dist/task/contract/paths.js +2 -1
- package/dist/task/contract/project.js +23 -1
- package/dist/task/contract/schema.js +9 -1
- package/dist/task/contract/transaction.js +12 -0
- package/dist/task/frontend-project-capability.js +203 -20
- package/dist/task/runtime.js +5 -2
- package/dist/task/source-prepare/build-draft.js +18 -3
- package/dist/task/source-prepare/completeness.js +188 -0
- package/dist/task/source-prepare/fragment-inventory.js +513 -0
- package/dist/task/source-prepare/index.js +3 -0
- package/dist/task/source-prepare/ledger-reconciliation.js +127 -0
- package/dist/task/source-prepare/ledger-review.js +214 -0
- package/dist/task/source-prepare/ledger.js +545 -0
- package/dist/task/source-prepare/parse-intent.js +24 -4
- package/dist/task/source-prepare/prepare.js +368 -2
- package/dist/task/source-prepare/semantic-intake.js +25 -5
- package/dist/task/source-prepare/source-fidelity-pi.js +384 -0
- package/dist/task/source-prepare/types.js +22 -0
- package/dist/task/source-references.js +22 -1
- package/dist/task/task-demand-routing.js +3 -0
- package/dist/worker/cli.js +18 -2
- package/dist/worker/console/chat/assistant-content.js +7 -0
- package/dist/worker/console/chat/chat-event-store.js +159 -18
- package/dist/worker/console/chat/chat-ui-policy.js +4 -2
- package/dist/worker/console/chat/context-panel.js +7 -0
- package/dist/worker/console/chat/deferred-turn.js +103 -0
- package/dist/worker/console/chat/goal-round-driver.js +72 -0
- package/dist/worker/console/chat/goals.js +300 -0
- package/dist/worker/console/chat/model-resolver.js +7 -4
- package/dist/worker/console/chat/operation-card.js +8 -1
- package/dist/worker/console/chat/pi-console-config.js +81 -10
- package/dist/worker/console/chat/pi-runtime.js +868 -30
- package/dist/worker/console/chat/provider-error.js +99 -0
- package/dist/worker/console/chat/repo-browser.js +101 -12
- package/dist/worker/console/chat/resource-preferences-store.js +1 -1
- package/dist/worker/console/chat/routes.js +1451 -145
- package/dist/worker/console/chat/sdd-data-alignment.js +222 -0
- package/dist/worker/console/chat/semantic-activity.js +25 -24
- package/dist/worker/console/chat/session-catalog.js +50 -0
- package/dist/worker/console/chat/session-stats.js +275 -0
- package/dist/worker/console/chat/session-store.js +348 -76
- package/dist/worker/console/chat/shortcuts.js +26 -3
- package/dist/worker/console/chat/sift-bridge.js +1 -0
- package/dist/worker/console/chat/todos.js +115 -0
- package/dist/worker/console/chat/tool-preview.js +42 -0
- package/dist/worker/console/chat/turn-process.js +185 -112
- package/dist/worker/console/chat/user-questions.js +266 -0
- package/dist/worker/console/chat/workspace-landing.js +79 -0
- package/dist/worker/console/console-handoff.js +82 -0
- package/dist/worker/console/console-update-and-init.js +115 -0
- package/dist/worker/console/console-update-runtime.js +84 -0
- package/dist/worker/console/context-transfer-diagnostics.js +198 -0
- package/dist/worker/console/dag-confirmation.js +1 -1
- package/dist/worker/console/dag-execution-receipt.js +54 -3
- package/dist/worker/console/doctor.js +1 -1
- package/dist/worker/console/draft-store.js +50 -1
- package/dist/worker/console/frontend-human-decision-adapter.js +19 -0
- package/dist/worker/console/frontend-split-operation-adapter.js +20 -0
- package/dist/worker/console/human-gate-token.js +1 -1
- package/dist/worker/console/index.js +6 -3
- package/dist/worker/console/inspect-split.js +18 -0
- package/dist/worker/console/interview/assessment.js +1 -1
- package/dist/worker/console/interview/session.js +1 -1
- package/dist/worker/console/native-directory-picker.js +13 -0
- package/dist/worker/console/operation-run-facts.js +19 -3
- package/dist/worker/console/operation-runner.js +45 -4
- package/dist/worker/console/operation-sse.js +1 -1
- package/dist/worker/console/operation-wait.js +1 -1
- package/dist/worker/console/operator-actions.js +534 -15
- package/dist/worker/console/operator-selection.js +6 -2
- package/dist/worker/console/operator-surface-health.js +2 -1
- package/dist/worker/console/operator-user-error.js +171 -2
- package/dist/worker/console/pi-plugins.catalog.json +73658 -0
- package/dist/worker/console/pi-plugins.js +238 -0
- package/dist/worker/console/pi-readiness.js +7 -6
- package/dist/worker/console/prd-intake-bridge.js +13 -0
- package/dist/worker/console/recovery-cta.js +4 -4
- package/dist/worker/console/recovery-error-copy.js +4 -4
- package/dist/worker/console/routes.js +1231 -10
- package/dist/worker/console/security.js +102 -13
- package/dist/worker/console/server.js +762 -159
- package/dist/worker/console/static/assets/{abnfDiagram-N423BO3Z-BmOEx0gA.js → abnfDiagram-N423BO3Z-BZogYNl1.js} +1 -1
- package/dist/worker/console/static/assets/{arc-BGiVVe8b.js → arc-DcJTLe2v.js} +1 -1
- package/dist/worker/console/static/assets/{architectureDiagram-T3A2C74G-nDdu4rgJ.js → architectureDiagram-T3A2C74G-B39EQQ9n.js} +1 -1
- package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-Bb5u0BWf.js → blockDiagram-VBNYF7ZC-CitCGV56.js} +1 -1
- package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-BlhC0j94.js → c4Diagram-5PPSVZJV-rvWuOHLG.js} +1 -1
- package/dist/worker/console/static/assets/channel-CXqdP5pW.js +1 -0
- package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-Ai8_qQXI.js → chunk-2GRJ4B5K-DGXplIJs.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-B9gyCjqX.js → chunk-2Q5K7J3B-ur9OqjPn.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5RXB4S5H-Bzbj3zGH.js → chunk-5RXB4S5H-D1KqU_Vi.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5VM5RSS4-BT415PvT.js → chunk-5VM5RSS4-BlVZrbtM.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-D_A5_5QL.js → chunk-6Q2QTUOP-BAzz3nQy.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-GF5L2VYU-srJkaP3f.js → chunk-GF5L2VYU-CP_nYuCV.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-JWPE2WC7-UYGvEP4l.js → chunk-JWPE2WC7-CWvKQ80X.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-KBJHAD2P-B8luBrrz.js → chunk-KBJHAD2P-CyUki8wp.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-RYQCIY6F-DN7wXZSq.js → chunk-RYQCIY6F-5NYzNKfY.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-XXDRQBXY-DXKyMuKS.js → chunk-XXDRQBXY-DHdUgjS-.js} +1 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-D9C3agF7.js +1 -0
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-D9C3agF7.js +1 -0
- package/dist/worker/console/static/assets/{cose-bilkent-JH36ORCC-dqvoynXj.js → cose-bilkent-JH36ORCC-ANQ5g_t6.js} +1 -1
- package/dist/worker/console/static/assets/{cynefin-VYW2F7L2--PcyL34A.js → cynefin-VYW2F7L2-CruT_4-0.js} +1 -1
- package/dist/worker/console/static/assets/{cynefinDiagram-MW4NZA55-DvWs_hTY.js → cynefinDiagram-MW4NZA55-rbFo77ID.js} +1 -1
- package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-DxeIxbyO.js → dagre-VZM6K2ZE-asstxBQs.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-7IWD3JNH-DPCG61Of.js → diagram-7IWD3JNH-DzTyBZwI.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-CmuU50-U.js → diagram-B4RE2ZJO-gw8ccH3B.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-LBJQPF4R-B61XLD_v.js → diagram-LBJQPF4R-B8RpZzOf.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-Q27KOJAE-BB7HTRRY.js → diagram-Q27KOJAE-B1zJkCS9.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-UB23O5K3-DvkboAIp.js → diagram-UB23O5K3-B6JLWZmO.js} +1 -1
- package/dist/worker/console/static/assets/{ebnfDiagram-BXEA7PRR-BdJ_y1fL.js → ebnfDiagram-BXEA7PRR-q2iZP-Ps.js} +1 -1
- package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-9bUBZTRi.js → erDiagram-JOGREHBK-B3dbbktQ.js} +1 -1
- package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-Dw4L4RBa.js → flowDiagram-UKHOOZJN-C-zc6-kB.js} +1 -1
- package/dist/worker/console/static/assets/{ganttDiagram-PKOTCBZU-Jr82N_QP.js → ganttDiagram-PKOTCBZU-BSolnot9.js} +1 -1
- package/dist/worker/console/static/assets/{gitGraphDiagram-DS77QQ5N-DAz9wFLr.js → gitGraphDiagram-DS77QQ5N-Bo8jGxTk.js} +1 -1
- package/dist/worker/console/static/assets/index-CAZ2fC_X.css +1 -0
- package/dist/worker/console/static/assets/index-DhfjOafu.js +449 -0
- package/dist/worker/console/static/assets/{infoDiagram-6WML65LV-CBB5Np7y.js → infoDiagram-6WML65LV-DQaZqJOH.js} +1 -1
- package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-D8IOp94y.js → ishikawaDiagram-WSZJBQD7-DsdX1WnE.js} +1 -1
- package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-Dgd3AHGG.js → journeyDiagram-NVQOT4AX-CP5EYDZL.js} +1 -1
- package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-BmYOxLE9.js → kanban-definition-27J2QSJJ-DAm14Dr8.js} +1 -1
- package/dist/worker/console/static/assets/{linear-DfYTEF6J.js → linear-gZECoLc5.js} +1 -1
- package/dist/worker/console/static/assets/{mermaid.core-BjuFPRqa.js → mermaid.core-BRJNIM6p.js} +5 -5
- package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-CLyUViGd.js → mindmap-definition-FAOFIHXS-Cja3kLkR.js} +1 -1
- package/dist/worker/console/static/assets/{pegDiagram-VL7TDLO6-BvX2Di4-.js → pegDiagram-VL7TDLO6-22ZGFisL.js} +1 -1
- package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-BFj0_OLv.js → pieDiagram-7S7Q4E2Y-BXin0Y1o.js} +1 -1
- package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-BIUrD_hx.js → quadrantDiagram-CIZ2JOQS-Cw6T69Yt.js} +1 -1
- package/dist/worker/console/static/assets/{railroadDiagram-AXF67PYL-CHBB48fj.js → railroadDiagram-AXF67PYL-C1-gTieN.js} +1 -1
- package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP-sJrYw2Sf.js → requirementDiagram-LRYGKXZP--H5N2iI1.js} +1 -1
- package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-BzHH6fPR.js → sankeyDiagram-W5VNT64P-CgWAPeRz.js} +1 -1
- package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-7QCnelCt.js → sequenceDiagram-SI44F4Z6-CrKqzGvt.js} +1 -1
- package/dist/worker/console/static/assets/{sizeCapture-X5ZJPWSS-sDYSxn72.js → sizeCapture-X5ZJPWSS-BB3wG06K.js} +1 -1
- package/dist/worker/console/static/assets/{stateDiagram-OKZ733FA-XpiUdwzm.js → stateDiagram-OKZ733FA-DjsGgdgY.js} +1 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-Tp7V0U4q.js +1 -0
- package/dist/worker/console/static/assets/{swimlanes-SLNWSIFB-DvqgNPzD.js → swimlanes-SLNWSIFB-DYKEbvAR.js} +2 -2
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-DUZWZWi8.js +8 -0
- package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-2TyOYNx0.js → timeline-definition-Z64GVDOM-eQOb5k9Y.js} +1 -1
- package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-B-nM6wM2.js → vennDiagram-T6HMQDX7-B2-l9FIu.js} +1 -1
- package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-B86wPdbr.js → wardleyDiagram-T6FBY63Y-BX2Cda3l.js} +1 -1
- package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-Dr1C4AQz.js → xychartDiagram-ELKLHX3M-D9S892ph.js} +1 -1
- package/dist/worker/console/static/index.html +7 -2
- package/dist/worker/console/static-src/active-run-badge.js +17 -0
- package/dist/worker/console/static-src/app/console-types.js +68 -4
- package/dist/worker/console/static-src/app/useConsoleShell.js +30 -12
- package/dist/worker/console/static-src/app/useOperatorActions.js +43 -7
- package/dist/worker/console/static-src/app/useRecoveryActions.js +2 -2
- package/dist/worker/console/static-src/app/useRecoveryConsole.js +45 -10
- package/dist/worker/console/static-src/app/useRunProgress.js +54 -0
- package/dist/worker/console/static-src/app/useTaskWizard.js +74 -2
- package/dist/worker/console/static-src/night/useNightBoard.js +8 -5
- package/dist/worker/console/static-src/operator-chat/cards/failure-category-advice.js +25 -0
- package/dist/worker/console/static-src/operator-chat/chat-sse-events.js +264 -13
- package/dist/worker/console/static-src/operator-chat/compaction-message.js +113 -0
- package/dist/worker/console/static-src/operator-chat/dag-progress-link.js +22 -0
- package/dist/worker/console/static-src/operator-chat/details-dag-actions.js +122 -0
- package/dist/worker/console/static-src/operator-chat/input-history.js +78 -0
- package/dist/worker/console/static-src/operator-chat/mutation-gate.js +1 -1
- package/dist/worker/console/static-src/operator-chat/open-preview-in-browser.js +338 -0
- package/dist/worker/console/static-src/operator-chat/refs.js +3 -0
- package/dist/worker/console/static-src/operator-chat/runtime-selection-labels.js +27 -0
- package/dist/worker/console/static-src/operator-chat/runtime-snapshot-store.js +10 -0
- package/dist/worker/console/static-src/operator-chat/spatial-overlay.js +1 -2
- package/dist/worker/console/static-src/operator-chat/turn-stream-controller.js +33 -1
- package/dist/worker/console/static-src/operator-chat/turn-submission.js +55 -0
- package/dist/worker/console/static-src/operator-chat/useChatSessions.js +448 -109
- package/dist/worker/console/static-src/operator-chat/useChatStream.js +344 -27
- package/dist/worker/console/static-src/operator-chat/useChatThread.js +323 -11
- package/dist/worker/console/static-src/operator-chat/useComposer.js +45 -4
- package/dist/worker/console/static-src/operator-chat/useRepoBrowser.js +97 -13
- package/dist/worker/console/static-src/operator-chat/useRuntimeControls.js +57 -9
- package/dist/worker/console/static-src/operator-chat/useRuntimeSnapshot.js +8 -2
- package/dist/worker/console/static-src/operator-chat/useWorkspaceBrowserGate.js +4 -0
- package/dist/worker/console/static-src/operator-chat/workspace-layout-mode.js +3 -3
- package/dist/worker/console/static-src/operator-chat/workspace-reorder.js +18 -0
- package/dist/worker/console/static-src/pages/tasks/run-id-resolution.js +79 -0
- package/dist/worker/console/static-src/pages/tasks/run-ownership-verify.js +23 -0
- package/dist/worker/console/static-src/pages/tasks/run-panel-progress.js +216 -0
- package/dist/worker/console/static-src/shell/console-update-reload.js +52 -0
- package/dist/worker/console/static-src/shell/useWorkspaces.js +415 -0
- package/dist/worker/console/static-src/shell/workspace-route.js +356 -0
- package/dist/worker/console/workspace-context.js +399 -0
- package/dist/worker/console/workspace-registry.js +487 -0
- package/dist/worker/continuation/worker-continuation.js +278 -0
- package/dist/worker/loop-agent/loop-agent-client.js +7 -3
- package/dist/worker/materialize/frontend-split-task-materializer.js +72 -0
- package/dist/worker/materialize/harness-task-lineage.js +5 -2
- package/dist/worker/observability/init-runtime-activity.js +26 -0
- package/dist/worker/observability/read-model.js +26 -0
- package/dist/worker/observe/health.js +1 -1
- package/dist/worker/observe/node-input.js +160 -3
- package/dist/worker/observe/node-process.js +377 -0
- package/dist/worker/observe/node-transparency.js +572 -0
- package/dist/worker/observe/routes.js +278 -3
- package/dist/worker/observe/server.js +4 -0
- package/dist/worker/observe/shell-handler-keys.js +34 -0
- package/dist/worker/observe/static/api.js +154 -4
- package/dist/worker/observe/static/app.js +18 -70
- package/dist/worker/observe/static/constants.js +26 -19
- package/dist/worker/observe/static/dag-context-reason-labels.d.ts +9 -0
- package/dist/worker/observe/static/dag-context-reason-labels.js +139 -0
- package/dist/worker/observe/static/dag-helpers.js +4 -2
- package/dist/worker/observe/static/dag-history-labels.js +5 -0
- package/dist/worker/observe/static/dag-inspector-humanize.d.ts +16 -0
- package/dist/worker/observe/static/dag-inspector-humanize.js +339 -0
- package/dist/worker/observe/static/dag-node-purpose.d.ts +6 -0
- package/dist/worker/observe/static/dag-node-purpose.js +208 -0
- package/dist/worker/observe/static/format.js +60 -0
- package/dist/worker/observe/static/index.html +10 -5
- package/dist/worker/observe/static/inspect-bootstrap.d.ts +8 -0
- package/dist/worker/observe/static/inspect-bootstrap.js +57 -0
- package/dist/worker/observe/static/inspect-workspace.js +374 -0
- package/dist/worker/observe/static/kpi.js +2 -2
- package/dist/worker/observe/static/markdown-render.js +20 -1
- package/dist/worker/observe/static/operator-chrome.css +168 -24
- package/dist/worker/observe/static/operator-chrome.d.ts +30 -5
- package/dist/worker/observe/static/operator-chrome.js +354 -101
- package/dist/worker/observe/static/prompt-restart-candidates.d.ts +18 -0
- package/dist/worker/observe/static/prompt-restart-candidates.js +38 -0
- package/dist/worker/observe/static/relations.js +7 -7
- package/dist/worker/observe/static/router.d.ts +57 -0
- package/dist/worker/observe/static/router.js +67 -1
- package/dist/worker/observe/static/run-processing.js +4 -2
- package/dist/worker/observe/static/shell-chrome.js +2 -2
- package/dist/worker/observe/static/state.d.ts +50 -0
- package/dist/worker/observe/static/state.js +191 -1
- package/dist/worker/observe/static/styles.css +1720 -86
- package/dist/worker/observe/static/views/dag-graph.js +5 -3
- package/dist/worker/observe/static/views/dag-inspector.js +2601 -188
- package/dist/worker/observe/static/views/dag.d.ts +13 -0
- package/dist/worker/observe/static/views/dag.js +39 -18
- package/dist/worker/observe/static/views/dags.js +10 -6
- package/dist/worker/observe/static/views/dashboard.js +18 -8
- package/dist/worker/observe/static/views/failures.js +5 -2
- package/dist/worker/observe/static/views/night.js +2 -2
- package/dist/worker/observe/static/views/pool.js +8 -2
- package/dist/worker/observe/static/views/run.js +15 -4
- package/dist/worker/observe/static/views/session-timeline.js +386 -25
- package/dist/worker/observe/static/views/task.js +63 -3
- package/dist/worker/outcomes/adapters.js +19 -0
- package/dist/worker/outcomes/types.js +1 -0
- package/dist/worker/pool/attempt-lease.js +97 -66
- package/dist/worker/pool/begin-attempt-with-lease.js +1 -0
- package/dist/worker/pool/reconcile.js +46 -1
- package/dist/worker/pool/run-store.js +2 -0
- package/dist/worker/pool/state-projection.js +2 -0
- package/dist/worker/task-spec/workflow-routing.js +8 -3
- package/dist/workflows/dag/artifact-bindings.js +149 -0
- package/dist/workflows/dag/artifact-revision-schema-registry.js +31 -0
- package/dist/workflows/dag/backend-test-case-coverage-analysis.js +470 -31
- package/dist/workflows/dag/backend-test-markdown-workflow.js +189 -2
- package/dist/workflows/dag/backend-test-plan-protocol.js +210 -0
- package/dist/workflows/dag/backend-test-pytest-collection.js +168 -16
- package/dist/workflows/dag/backend-test-result-contract.js +5 -1
- package/dist/workflows/dag/backend-test-scenario-param.js +506 -73
- package/dist/workflows/dag/backend-test-scenario-partitions.js +135 -2
- package/dist/workflows/dag/backend-test-writer-completeness.js +131 -28
- package/dist/workflows/dag/budget-enforcement.js +10 -0
- package/dist/workflows/dag/context-receipt.js +305 -0
- package/dist/workflows/dag/context-transfer/context-bundle.js +423 -0
- package/dist/workflows/dag/context-transfer/operator-actions.js +61 -0
- package/dist/workflows/dag/context-transfer/renderers.js +93 -0
- package/dist/workflows/dag/contract-output-registry.js +15 -0
- package/dist/workflows/dag/contract-validator-registrations.js +1 -2
- package/dist/workflows/dag/convergence/controller.js +141 -0
- package/dist/workflows/dag/dag-retry-schema.js +138 -0
- package/dist/workflows/dag/dynamic-runtime/loop-until.js +1 -1
- package/dist/workflows/dag/dynamic-runtime/map.js +2 -1
- package/dist/workflows/dag/failure-category.js +7 -116
- package/dist/workflows/dag/frontend-closeout.js +221 -0
- package/dist/workflows/dag/frontend-design-policy.js +400 -0
- package/dist/workflows/dag/frontend-human-decision.js +182 -0
- package/dist/workflows/dag/frontend-implementation-contract.js +1377 -141
- package/dist/workflows/dag/frontend-plan-render.js +26 -1
- package/dist/workflows/dag/frontend-prewrite-gate.js +376 -318
- package/dist/workflows/dag/frontend-provider-capability-matrix.js +159 -0
- package/dist/workflows/dag/frontend-recovery-capsule.js +455 -0
- package/dist/workflows/dag/frontend-recovery-controller.js +226 -0
- package/dist/workflows/dag/frontend-recovery-lineage.js +178 -0
- package/dist/workflows/dag/frontend-recovery-plan.js +21 -10
- package/dist/workflows/dag/frontend-recovery-run.js +166 -34
- package/dist/workflows/dag/frontend-repair.js +7 -424
- package/dist/workflows/dag/frontend-review-context.js +348 -20
- package/dist/workflows/dag/frontend-review-findings.js +270 -0
- package/dist/workflows/dag/frontend-risk.js +15 -2
- package/dist/workflows/dag/frontend-shadow-dual-write.js +941 -0
- package/dist/workflows/dag/frontend-shape-capsule-store.js +191 -0
- package/dist/workflows/dag/frontend-shape-facts.js +419 -0
- package/dist/workflows/dag/frontend-shape.js +435 -0
- package/dist/workflows/dag/frontend-source-fidelity-ledger.js +108 -0
- package/dist/workflows/dag/frontend-split-application-service.js +203 -0
- package/dist/workflows/dag/frontend-split-orchestrator.js +899 -0
- package/dist/workflows/dag/frontend-test-case-checklist.js +53 -5
- package/dist/workflows/dag/frontend-test-case-manifest.js +11 -4
- package/dist/workflows/dag/frontend-test-case-quality.js +11 -16
- package/dist/workflows/dag/frontend-test-environment-probe.js +230 -0
- package/dist/workflows/dag/frontend-test-html-report.js +3 -1
- package/dist/workflows/dag/frontend-test-l5-report.js +3 -1
- package/dist/workflows/dag/frontend-test-layout.js +159 -0
- package/dist/workflows/dag/frontend-test-markdown.js +61 -0
- package/dist/workflows/dag/frontend-test-rerun-candidates.js +103 -0
- package/dist/workflows/dag/frontend-test-result-contract.js +188 -42
- package/dist/workflows/dag/frontend-test-standard-scenarios.js +70 -0
- package/dist/workflows/dag/frontend-typed-event-store.js +452 -0
- package/dist/workflows/dag/frontend-typed-event-transaction.js +180 -0
- package/dist/workflows/dag/frontend-verification-trace.js +281 -29
- package/dist/workflows/dag/frontend-worktree-diff.js +250 -17
- package/dist/workflows/dag/frontend-writer-admission.js +319 -0
- package/dist/workflows/dag/frontend-writer-rollback.js +32 -0
- package/dist/workflows/dag/frontend-writer-status.js +256 -0
- package/dist/workflows/dag/init-hybrid.js +1675 -721
- package/dist/workflows/dag/interrupt-request.js +10 -3
- package/dist/workflows/dag/lifecycle.js +3 -3
- package/dist/workflows/dag/node-execution.js +1141 -32
- package/dist/workflows/dag/path-safety.js +1 -0
- package/dist/workflows/dag/prompt.js +158 -7
- package/dist/workflows/dag/recovery-lease.js +170 -0
- package/dist/workflows/dag/report.js +37 -1
- package/dist/workflows/dag/rerun-feedback.js +526 -0
- package/dist/workflows/dag/rerun-plan.js +790 -28
- package/dist/workflows/dag/rerun-run.js +700 -21
- package/dist/workflows/dag/rerun-task.js +311 -14
- package/dist/workflows/dag/retry-policy.js +336 -101
- package/dist/workflows/dag/runner.js +596 -121
- package/dist/workflows/dag/scheduler.js +133 -20
- package/dist/workflows/dag/skill-snapshot.js +17 -0
- package/dist/workflows/dag/structured-output-repair.js +712 -0
- package/dist/workflows/dag/types.js +585 -31
- package/dist/workflows/dag/validate.js +93 -32
- package/docs/README.md +2 -0
- package/docs/architecture/evolution.md +45 -0
- package/docs/architecture/runtime-boundaries.md +8 -7
- package/docs/architecture/worker-and-feature.md +1 -1
- package/docs/examples/README.md +5 -0
- package/docs/init-surface.manifest.json +36 -12
- package/docs/operations/README.md +1 -1
- package/docs/operations/local-development-environment.md +22 -5
- package/docs/skills/vetted-skill-registry.md +16 -0
- package/docs/templates/README.md +4 -2
- package/docs/templates/agent-dag-report.schema.json +8 -2
- package/docs/templates/agent-dag.schema.json +95 -1
- package/docs/templates/backend-test-dag.json +278 -244
- package/docs/templates/frontend-implementation-contract.schema.json +684 -24
- package/docs/templates/frontend-implementation-dag.json +89 -0
- package/docs/templates/frontend-test-case-checklist.md +2 -2
- package/docs/templates/frontend-test-dag.json +8 -10
- package/docs/templates/frontend-test-dag.retrieve-context.prompt.md +1 -1
- package/docs/templates/init-managed-agents.md +13 -3
- package/docs/templates/product-line/task.yaml +1 -1
- package/docs/templates/spec-registry.schema.json +45 -0
- package/harness.json +2 -2
- package/package.json +19 -5
- package/scripts/next-info.mjs +356 -0
- package/scripts/next-publish-gate.mjs +238 -0
- package/scripts/release-source-binding.mjs +251 -0
- package/skills/analyze-product-requirements/SKILL.md +8 -5
- package/skills/analyze-product-requirements/references/acceptance-criteria.md +1 -1
- package/skills/analyze-product-requirements/references/clarification-and-knowledge.md +10 -6
- package/skills/analyze-product-requirements/references/example.md +50 -0
- package/skills/analyze-product-requirements/references/forward-test-cases.md +11 -7
- package/skills/analyze-product-requirements/references/kb-integration.md +5 -5
- package/skills/analyze-product-requirements/references/product-analysis-schema.md +8 -4
- package/skills/analyze-product-requirements/references/product-requirement-schema.md +2 -2
- package/skills/analyze-product-requirements/references/requirement-clarification-schema.md +1 -1
- package/skills/analyze-product-requirements/scripts/test-validators.mjs +11 -1
- package/skills/analyze-product-requirements/scripts/validate-product-analysis.mjs +20 -1
- package/skills/analyze-product-requirements/scripts/validate-requirement-clarification.mjs +9 -0
- package/skills/codebase-scout/SKILL.md +1 -1
- package/skills/fe-test-ui-scout/SKILL.md +65 -0
- package/skills/fe-test-ui-scout/references/ledger-schema.md +62 -0
- package/skills/fe-test-ui-scout/references/recon-protocol.md +54 -0
- package/skills/frontend-bounded-implement/SKILL.md +15 -14
- package/skills/frontend-bounded-implement/references/code-standards.md +19 -0
- package/skills/frontend-contract/SKILL.md +23 -0
- package/skills/frontend-contract/references/contract-protocol.md +34 -0
- package/skills/frontend-design-review/SKILL.md +22 -41
- package/skills/frontend-plan/SKILL.md +26 -0
- package/skills/frontend-plan/references/decision-contract.md +37 -0
- package/skills/frontend-plan/references/design-decisions.md +17 -0
- package/skills/frontend-review/SKILL.md +20 -15
- package/skills/frontend-review/references/review-findings.md +6 -7
- package/skills/frontend-scout/SKILL.md +25 -0
- package/skills/frontend-scout/references/design-evidence.md +16 -0
- package/skills/frontend-scout/references/scout-evidence.md +23 -0
- package/skills/frontend-verification/SKILL.md +1 -1
- package/skills/improve-codebase-architecture/SKILL.md +81 -0
- package/skills/improve-codebase-architecture/deepening.md +37 -0
- package/skills/improve-codebase-architecture/html-report.md +123 -0
- package/skills/improve-codebase-architecture/interface-design.md +44 -0
- package/skills/improve-codebase-architecture/language.md +53 -0
- package/skills/loop-agent/references/command-reference.md +32 -4
- package/skills/loop-agent/references/hybrid-dag.md +9 -2
- package/skills/playwright-cli/SKILL.md +23 -1
- package/skills/playwright-cli-case-generator/SKILL.md +50 -13
- package/dist/worker/console/operation-store.js +0 -169
- package/dist/worker/console/static/assets/channel-Tl-FkUqr.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-BaehtRk4.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-BaehtRk4.js +0 -1
- package/dist/worker/console/static/assets/index-B7Y-0g3J.css +0 -1
- package/dist/worker/console/static/assets/index-DkCrqaYg.js +0 -325
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-eEhq2A8Y.js +0 -1
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-la8AC7fo.js +0 -8
- package/dist/worker/console/static-src/operator-chat/activity-rail-presentation.js +0 -73
- package/dist/worker/console/static-src/operator-chat/useActivityRailTransition.js +0 -59
- package/skills/frontend-implementation/SKILL.md +0 -52
- package/skills/frontend-implementation/references/code-standards.md +0 -33
- package/skills/frontend-implementation/references/design-spec.md +0 -56
- package/skills/frontend-implementation/references/node-contracts.md +0 -31
- /package/dist/{worker → infrastructure}/console/repo-fingerprint.js +0 -0
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { mkdirSync, readdirSync, rmSync, statSync } from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { parseBoundedNumber, parseEnabledFlag } from "./env.js";
|
|
5
|
+
import { emptyContextPressureCounters, incrementCounter, } from "./telemetry.js";
|
|
6
|
+
export const SIFT_POLICY_VERSION = "sift-v1-query-undefined";
|
|
7
|
+
export const SIFT_RETRIEVE_TOOL_NAME = "sift_retrieve";
|
|
8
|
+
export const SIFT_STASH_KEY_PATTERN = /^[0-9a-f]{24}$/;
|
|
9
|
+
export const SIFT_RETRIEVE_DEFAULT_BYTES = 24 * 1024;
|
|
10
|
+
export const SIFT_RETRIEVE_MAX_BYTES = 48 * 1024;
|
|
11
|
+
export const DEFAULT_MEMO_MAX_ENTRIES = 128;
|
|
12
|
+
export const DEFAULT_MEMO_MAX_BYTES = 32 * 1024 * 1024;
|
|
13
|
+
export const DEFAULT_STASH_RETENTION_DAYS = 14;
|
|
14
|
+
class BoundedMemo {
|
|
15
|
+
maxEntries;
|
|
16
|
+
maxBytes;
|
|
17
|
+
entries = new Map();
|
|
18
|
+
bytes = 0;
|
|
19
|
+
constructor(maxEntries, maxBytes) {
|
|
20
|
+
this.maxEntries = maxEntries;
|
|
21
|
+
this.maxBytes = maxBytes;
|
|
22
|
+
}
|
|
23
|
+
get(key) {
|
|
24
|
+
const hit = this.entries.get(key);
|
|
25
|
+
if (!hit)
|
|
26
|
+
return undefined;
|
|
27
|
+
this.entries.delete(key);
|
|
28
|
+
this.entries.set(key, hit);
|
|
29
|
+
try {
|
|
30
|
+
return JSON.parse(hit.json);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
set(key, value) {
|
|
37
|
+
const json = JSON.stringify(value);
|
|
38
|
+
const size = Buffer.byteLength(json);
|
|
39
|
+
if (size > this.maxBytes)
|
|
40
|
+
return;
|
|
41
|
+
this.delete(key);
|
|
42
|
+
while (this.entries.size >= this.maxEntries ||
|
|
43
|
+
this.bytes + size > this.maxBytes) {
|
|
44
|
+
const oldest = this.entries.keys().next().value;
|
|
45
|
+
if (oldest === undefined)
|
|
46
|
+
break;
|
|
47
|
+
this.delete(oldest);
|
|
48
|
+
}
|
|
49
|
+
this.entries.set(key, { json, bytes: size });
|
|
50
|
+
this.bytes += size;
|
|
51
|
+
}
|
|
52
|
+
delete(key) {
|
|
53
|
+
const current = this.entries.get(key);
|
|
54
|
+
if (!current)
|
|
55
|
+
return;
|
|
56
|
+
this.entries.delete(key);
|
|
57
|
+
this.bytes -= current.bytes;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export function parseSiftBridgeConfig(input) {
|
|
61
|
+
const env = input.env ?? process.env;
|
|
62
|
+
const override = env.HARNESS_CONSOLE_SIFT_STASH_DIR?.trim();
|
|
63
|
+
const root = override || input.defaultStashRoot;
|
|
64
|
+
const stashDir = path.join(root, input.sessionId);
|
|
65
|
+
const entries = parseBoundedNumber(env.HARNESS_CONSOLE_SIFT_MEMO_MAX_ENTRIES, DEFAULT_MEMO_MAX_ENTRIES, 8, 4096);
|
|
66
|
+
const bytes = parseBoundedNumber(env.HARNESS_CONSOLE_SIFT_MEMO_MAX_BYTES, DEFAULT_MEMO_MAX_BYTES, 1024, 256 * 1024 * 1024);
|
|
67
|
+
const retention = parseBoundedNumber(env.HARNESS_CONSOLE_SIFT_STASH_RETENTION_DAYS, DEFAULT_STASH_RETENTION_DAYS, 1, 365);
|
|
68
|
+
return {
|
|
69
|
+
sessionId: input.sessionId,
|
|
70
|
+
stashDir,
|
|
71
|
+
memoMaxEntries: entries.value,
|
|
72
|
+
memoMaxBytes: bytes.value,
|
|
73
|
+
retentionDays: retention.value,
|
|
74
|
+
...(input.siftFactory ? { siftFactory: input.siftFactory } : {}),
|
|
75
|
+
...(input.importSift ? { importSift: input.importSift } : {}),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export function createSiftBridgeState(config) {
|
|
79
|
+
return {
|
|
80
|
+
sessionId: config.sessionId,
|
|
81
|
+
stashDir: config.stashDir,
|
|
82
|
+
config,
|
|
83
|
+
counters: emptyContextPressureCounters(),
|
|
84
|
+
retrieveBypassIds: new Set(),
|
|
85
|
+
diagnostics: new Set(),
|
|
86
|
+
memo: new BoundedMemo(config.memoMaxEntries, config.memoMaxBytes),
|
|
87
|
+
importFailed: false,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function noteOnce(state, code) {
|
|
91
|
+
if (state.diagnostics.has(code))
|
|
92
|
+
return;
|
|
93
|
+
state.diagnostics.add(code);
|
|
94
|
+
incrementCounter(state.counters, "fail-open");
|
|
95
|
+
}
|
|
96
|
+
function memoKey(payload) {
|
|
97
|
+
return createHash("sha256")
|
|
98
|
+
.update(SIFT_POLICY_VERSION)
|
|
99
|
+
.update("\0")
|
|
100
|
+
.update(JSON.stringify(payload))
|
|
101
|
+
.digest("hex");
|
|
102
|
+
}
|
|
103
|
+
function ensureStashDir(stashDir) {
|
|
104
|
+
mkdirSync(stashDir, { recursive: true, mode: 0o700 });
|
|
105
|
+
}
|
|
106
|
+
async function ensureSift(state) {
|
|
107
|
+
if (state.sift)
|
|
108
|
+
return state.sift;
|
|
109
|
+
if (state.importFailed)
|
|
110
|
+
return undefined;
|
|
111
|
+
try {
|
|
112
|
+
ensureStashDir(state.stashDir);
|
|
113
|
+
if (state.config.siftFactory) {
|
|
114
|
+
state.sift = state.config.siftFactory({ stashDir: state.stashDir });
|
|
115
|
+
return state.sift;
|
|
116
|
+
}
|
|
117
|
+
const importer = state.config.importSift ??
|
|
118
|
+
(async () => (await import("@agent-context/sift")));
|
|
119
|
+
const mod = await importer();
|
|
120
|
+
if (typeof mod.createSift !== "function") {
|
|
121
|
+
state.importFailed = true;
|
|
122
|
+
noteOnce(state, "sift-import-invalid");
|
|
123
|
+
return undefined;
|
|
124
|
+
}
|
|
125
|
+
state.sift = mod.createSift({ stashDir: state.stashDir });
|
|
126
|
+
return state.sift;
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
state.importFailed = true;
|
|
130
|
+
noteOnce(state, "sift-import-failed");
|
|
131
|
+
return undefined;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function isRecord(value) {
|
|
135
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
136
|
+
}
|
|
137
|
+
function hasTrailingAnthropicCacheAnchor(payload) {
|
|
138
|
+
if (!isRecord(payload) || !Array.isArray(payload.messages))
|
|
139
|
+
return false;
|
|
140
|
+
const last = payload.messages[payload.messages.length - 1];
|
|
141
|
+
if (!isRecord(last))
|
|
142
|
+
return false;
|
|
143
|
+
const content = last.content;
|
|
144
|
+
if (!Array.isArray(content) || content.length === 0)
|
|
145
|
+
return false;
|
|
146
|
+
const lastBlock = content[content.length - 1];
|
|
147
|
+
return isRecord(lastBlock) && lastBlock.cache_control !== undefined;
|
|
148
|
+
}
|
|
149
|
+
function restoreProtectedToolResults(originalPayload, compressed, protectedIds) {
|
|
150
|
+
if (protectedIds.size === 0)
|
|
151
|
+
return compressed;
|
|
152
|
+
const original = structuredClone(originalPayload);
|
|
153
|
+
const next = structuredClone(compressed);
|
|
154
|
+
restoreInMessages(original, next, protectedIds);
|
|
155
|
+
restoreInResponsesInput(original, next, protectedIds);
|
|
156
|
+
return next;
|
|
157
|
+
}
|
|
158
|
+
function restoreInMessages(original, next, protectedIds) {
|
|
159
|
+
if (!isRecord(original) || !isRecord(next))
|
|
160
|
+
return;
|
|
161
|
+
if (!Array.isArray(original.messages) || !Array.isArray(next.messages))
|
|
162
|
+
return;
|
|
163
|
+
for (let index = 0; index < next.messages.length; index += 1) {
|
|
164
|
+
const origMsg = original.messages[index];
|
|
165
|
+
const nextMsg = next.messages[index];
|
|
166
|
+
if (!isRecord(origMsg) || !isRecord(nextMsg))
|
|
167
|
+
continue;
|
|
168
|
+
const origId = typeof origMsg.tool_call_id === "string"
|
|
169
|
+
? origMsg.tool_call_id
|
|
170
|
+
: undefined;
|
|
171
|
+
if (origId && protectedIds.has(origId)) {
|
|
172
|
+
next.messages[index] = origMsg;
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
if (Array.isArray(origMsg.content) && Array.isArray(nextMsg.content)) {
|
|
176
|
+
for (let blockIndex = 0; blockIndex < nextMsg.content.length; blockIndex += 1) {
|
|
177
|
+
const origBlock = origMsg.content[blockIndex];
|
|
178
|
+
if (!isRecord(origBlock))
|
|
179
|
+
continue;
|
|
180
|
+
const toolUseId = typeof origBlock.tool_use_id === "string"
|
|
181
|
+
? origBlock.tool_use_id
|
|
182
|
+
: undefined;
|
|
183
|
+
if (toolUseId && protectedIds.has(toolUseId)) {
|
|
184
|
+
nextMsg.content[blockIndex] = origBlock;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
function restoreInResponsesInput(original, next, protectedIds) {
|
|
191
|
+
if (!isRecord(original) || !isRecord(next))
|
|
192
|
+
return;
|
|
193
|
+
if (!Array.isArray(original.input) || !Array.isArray(next.input))
|
|
194
|
+
return;
|
|
195
|
+
for (let index = 0; index < next.input.length; index += 1) {
|
|
196
|
+
const origItem = original.input[index];
|
|
197
|
+
if (!isRecord(origItem))
|
|
198
|
+
continue;
|
|
199
|
+
const callId = typeof origItem.call_id === "string" ? origItem.call_id : undefined;
|
|
200
|
+
if (callId && protectedIds.has(callId)) {
|
|
201
|
+
next.input[index] = origItem;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
export async function compressProviderPayload(state, payload) {
|
|
206
|
+
if (payload === undefined)
|
|
207
|
+
return undefined;
|
|
208
|
+
if (!isRecord(payload)) {
|
|
209
|
+
noteOnce(state, "unknown-format");
|
|
210
|
+
return undefined;
|
|
211
|
+
}
|
|
212
|
+
const key = memoKey(payload);
|
|
213
|
+
const cached = state.memo.get(key);
|
|
214
|
+
if (cached !== undefined)
|
|
215
|
+
return cached;
|
|
216
|
+
if (hasTrailingAnthropicCacheAnchor(payload)) {
|
|
217
|
+
const sift = await ensureSift(state);
|
|
218
|
+
if (!sift)
|
|
219
|
+
return undefined;
|
|
220
|
+
try {
|
|
221
|
+
const result = sift.siftRequest(payload, undefined);
|
|
222
|
+
if (result.changed === false &&
|
|
223
|
+
result.blocksExamined === 0 &&
|
|
224
|
+
result.frozenMessages ===
|
|
225
|
+
(Array.isArray(payload.messages)
|
|
226
|
+
? (payload.messages.length)
|
|
227
|
+
: 0)) {
|
|
228
|
+
return undefined;
|
|
229
|
+
}
|
|
230
|
+
if (!result.changed)
|
|
231
|
+
return undefined;
|
|
232
|
+
noteOnce(state, "anthropic-unexpected-change");
|
|
233
|
+
return undefined;
|
|
234
|
+
}
|
|
235
|
+
catch {
|
|
236
|
+
noteOnce(state, "sift-handler-error");
|
|
237
|
+
return undefined;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
const sift = await ensureSift(state);
|
|
241
|
+
if (!sift)
|
|
242
|
+
return undefined;
|
|
243
|
+
try {
|
|
244
|
+
const result = sift.siftRequest(payload, undefined);
|
|
245
|
+
if (!result || result.changed !== true)
|
|
246
|
+
return undefined;
|
|
247
|
+
const restored = restoreProtectedToolResults(payload, result.body, state.retrieveBypassIds);
|
|
248
|
+
state.counters.tokensSavedEstimate += Math.max(0, result.tokensSaved ?? 0);
|
|
249
|
+
state.counters.blocksCompressed += Math.max(0, result.blocksCompressed ?? 0);
|
|
250
|
+
incrementCounter(state.counters, "wire-compression");
|
|
251
|
+
state.memo.set(key, restored);
|
|
252
|
+
return restored;
|
|
253
|
+
}
|
|
254
|
+
catch {
|
|
255
|
+
noteOnce(state, "sift-handler-error");
|
|
256
|
+
return undefined;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
export function clearRetrieveBypass(state) {
|
|
260
|
+
state.retrieveBypassIds.clear();
|
|
261
|
+
}
|
|
262
|
+
export function sliceUtf8Range(text, offset, maxBytes) {
|
|
263
|
+
const totalBytes = Buffer.byteLength(text, "utf8");
|
|
264
|
+
const start = Math.max(0, Math.floor(offset));
|
|
265
|
+
const limit = Math.min(SIFT_RETRIEVE_MAX_BYTES, Math.max(1, Math.floor(maxBytes)));
|
|
266
|
+
if (start >= totalBytes) {
|
|
267
|
+
return { slice: "", nextOffset: null, totalBytes, complete: true };
|
|
268
|
+
}
|
|
269
|
+
const buffer = Buffer.from(text, "utf8");
|
|
270
|
+
let end = Math.min(totalBytes, start + limit);
|
|
271
|
+
while (end > start && (buffer[end] & 0b1100_0000) === 0b1000_0000) {
|
|
272
|
+
end -= 1;
|
|
273
|
+
}
|
|
274
|
+
const slice = buffer.subarray(start, end).toString("utf8");
|
|
275
|
+
const complete = end >= totalBytes;
|
|
276
|
+
return {
|
|
277
|
+
slice,
|
|
278
|
+
nextOffset: complete ? null : end,
|
|
279
|
+
totalBytes,
|
|
280
|
+
complete,
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
export async function executeSiftRetrieve(state, toolCallId, params) {
|
|
284
|
+
const key = typeof params.key === "string" ? params.key.trim() : "";
|
|
285
|
+
if (!SIFT_STASH_KEY_PATTERN.test(key)) {
|
|
286
|
+
return {
|
|
287
|
+
content: [
|
|
288
|
+
{
|
|
289
|
+
type: "text",
|
|
290
|
+
text: JSON.stringify({
|
|
291
|
+
error: "STASH_NOT_FOUND_OR_EXPIRED",
|
|
292
|
+
complete: true,
|
|
293
|
+
}),
|
|
294
|
+
},
|
|
295
|
+
],
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
const sift = await ensureSift(state);
|
|
299
|
+
const original = sift?.retrieve(key) ?? null;
|
|
300
|
+
if (original === null) {
|
|
301
|
+
return {
|
|
302
|
+
content: [
|
|
303
|
+
{
|
|
304
|
+
type: "text",
|
|
305
|
+
text: JSON.stringify({
|
|
306
|
+
error: "STASH_NOT_FOUND_OR_EXPIRED",
|
|
307
|
+
complete: true,
|
|
308
|
+
}),
|
|
309
|
+
},
|
|
310
|
+
],
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
const offset = typeof params.offset === "number" && Number.isFinite(params.offset)
|
|
314
|
+
? Math.max(0, Math.floor(params.offset))
|
|
315
|
+
: 0;
|
|
316
|
+
const maxBytes = typeof params.maxBytes === "number" && Number.isFinite(params.maxBytes)
|
|
317
|
+
? params.maxBytes
|
|
318
|
+
: SIFT_RETRIEVE_DEFAULT_BYTES;
|
|
319
|
+
const page = sliceUtf8Range(original, offset, maxBytes);
|
|
320
|
+
if (toolCallId)
|
|
321
|
+
state.retrieveBypassIds.add(toolCallId);
|
|
322
|
+
return {
|
|
323
|
+
content: [
|
|
324
|
+
{
|
|
325
|
+
type: "text",
|
|
326
|
+
text: JSON.stringify({
|
|
327
|
+
key,
|
|
328
|
+
offset,
|
|
329
|
+
maxBytes: Math.min(SIFT_RETRIEVE_MAX_BYTES, Math.max(1, Math.floor(maxBytes))),
|
|
330
|
+
totalBytes: page.totalBytes,
|
|
331
|
+
nextOffset: page.nextOffset,
|
|
332
|
+
complete: page.complete,
|
|
333
|
+
text: page.slice,
|
|
334
|
+
}),
|
|
335
|
+
},
|
|
336
|
+
],
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
export function housekeepSiftStash(input) {
|
|
340
|
+
let removed = 0;
|
|
341
|
+
try {
|
|
342
|
+
const entries = readdirSync(input.root, { withFileTypes: true });
|
|
343
|
+
const cutoff = (input.now ?? Date.now()) - input.retentionDays * 24 * 60 * 60 * 1000;
|
|
344
|
+
for (const entry of entries) {
|
|
345
|
+
if (!entry.isDirectory())
|
|
346
|
+
continue;
|
|
347
|
+
if (input.activeSessionId && entry.name === input.activeSessionId)
|
|
348
|
+
continue;
|
|
349
|
+
const full = path.join(input.root, entry.name);
|
|
350
|
+
let mtime = 0;
|
|
351
|
+
try {
|
|
352
|
+
mtime = statSync(full).mtimeMs;
|
|
353
|
+
}
|
|
354
|
+
catch {
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
if (mtime <= cutoff) {
|
|
358
|
+
rmSync(full, { recursive: true, force: true });
|
|
359
|
+
removed += 1;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
return { removed, failed: false };
|
|
363
|
+
}
|
|
364
|
+
catch {
|
|
365
|
+
return { removed, failed: true };
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
export function createSiftRetrieveToolDefinition(state) {
|
|
369
|
+
return {
|
|
370
|
+
name: SIFT_RETRIEVE_TOOL_NAME,
|
|
371
|
+
label: "Sift Retrieve",
|
|
372
|
+
description: "Retrieve a previously compressed tool-output page by 24-hex stash key. Use offset/maxBytes to page; default 24KiB, max 48KiB.",
|
|
373
|
+
parameters: {
|
|
374
|
+
type: "object",
|
|
375
|
+
additionalProperties: false,
|
|
376
|
+
properties: {
|
|
377
|
+
key: { type: "string", description: "24-hex stash key" },
|
|
378
|
+
offset: { type: "number", description: "UTF-8 byte offset" },
|
|
379
|
+
maxBytes: { type: "number", description: "Page size in bytes" },
|
|
380
|
+
},
|
|
381
|
+
required: ["key"],
|
|
382
|
+
},
|
|
383
|
+
execute: (toolCallId, params) => executeSiftRetrieve(state, toolCallId, params),
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
export { parseEnabledFlag };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export function emptyContextPressureCounters() {
|
|
2
|
+
return {
|
|
3
|
+
prePromptThreshold: 0,
|
|
4
|
+
overflow: 0,
|
|
5
|
+
manual: 0,
|
|
6
|
+
wireCompression: 0,
|
|
7
|
+
failOpen: 0,
|
|
8
|
+
usageUnavailable: 0,
|
|
9
|
+
l0CompactFailed: 0,
|
|
10
|
+
tokensSavedEstimate: 0,
|
|
11
|
+
blocksCompressed: 0,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export function incrementCounter(counters, reason, amount = 1) {
|
|
15
|
+
switch (reason) {
|
|
16
|
+
case "pre-prompt-threshold":
|
|
17
|
+
counters.prePromptThreshold += amount;
|
|
18
|
+
break;
|
|
19
|
+
case "overflow":
|
|
20
|
+
counters.overflow += amount;
|
|
21
|
+
break;
|
|
22
|
+
case "manual":
|
|
23
|
+
counters.manual += amount;
|
|
24
|
+
break;
|
|
25
|
+
case "wire-compression":
|
|
26
|
+
counters.wireCompression += amount;
|
|
27
|
+
break;
|
|
28
|
+
case "fail-open":
|
|
29
|
+
counters.failOpen += amount;
|
|
30
|
+
break;
|
|
31
|
+
case "usage-unavailable":
|
|
32
|
+
counters.usageUnavailable += amount;
|
|
33
|
+
break;
|
|
34
|
+
case "l0-compact-failed":
|
|
35
|
+
counters.l0CompactFailed += amount;
|
|
36
|
+
break;
|
|
37
|
+
default:
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export function projectSafeTelemetry(counters) {
|
|
42
|
+
return {
|
|
43
|
+
prePromptThreshold: counters.prePromptThreshold,
|
|
44
|
+
overflow: counters.overflow,
|
|
45
|
+
manual: counters.manual,
|
|
46
|
+
wireCompression: counters.wireCompression,
|
|
47
|
+
failOpen: counters.failOpen,
|
|
48
|
+
tokensSavedEstimate: counters.tokensSavedEstimate,
|
|
49
|
+
blocksCompressed: counters.blocksCompressed,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
@@ -9,6 +9,7 @@ export const PLAYWRIGHT_CLI_ALLOWED_COMMANDS = [
|
|
|
9
9
|
"goto",
|
|
10
10
|
"snapshot",
|
|
11
11
|
"find",
|
|
12
|
+
"find-unique",
|
|
12
13
|
"click",
|
|
13
14
|
"dblclick",
|
|
14
15
|
"fill",
|
|
@@ -35,6 +36,20 @@ export const PLAYWRIGHT_CLI_ALLOWED_COMMANDS = [
|
|
|
35
36
|
"requests",
|
|
36
37
|
"request",
|
|
37
38
|
];
|
|
39
|
+
/**
|
|
40
|
+
* Parse the match count from a playwright-cli find output. The CLI prints
|
|
41
|
+
* `Found N match(es) for "...":` on success and `No matches found for "...".`
|
|
42
|
+
* on zero — both with exit code 0, so the count is the only assertion signal.
|
|
43
|
+
* Returns undefined when the output shape is unrecognized (e.g. error pages).
|
|
44
|
+
*/
|
|
45
|
+
export function parsePlaywrightCliFindMatchCount(output) {
|
|
46
|
+
const found = /Found\s+(\d+)\s+match(?:es)?\s+for\b/i.exec(output);
|
|
47
|
+
if (found)
|
|
48
|
+
return Number(found[1]);
|
|
49
|
+
if (/No matches found for\b/i.test(output))
|
|
50
|
+
return 0;
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
38
53
|
const allowedCommandSet = new Set(PLAYWRIGHT_CLI_ALLOWED_COMMANDS);
|
|
39
54
|
export function isPlaywrightCliCommand(value) {
|
|
40
55
|
return allowedCommandSet.has(value);
|
package/dist/shared/preview.js
CHANGED
|
@@ -1,10 +1,34 @@
|
|
|
1
1
|
const ENCODER = new TextEncoder();
|
|
2
2
|
const DECODER = new TextDecoder();
|
|
3
|
+
export function redactSecretsWithFindings(text) {
|
|
4
|
+
let findingCount = 0;
|
|
5
|
+
const replaceChanged = (match, replacement) => {
|
|
6
|
+
if (match !== replacement)
|
|
7
|
+
findingCount += 1;
|
|
8
|
+
return replacement;
|
|
9
|
+
};
|
|
10
|
+
let redacted = text.replace(/(["']?(?:api[_-]?key|token|password|secret|authorization)["']?\s*[:=]\s*["']?)((?:Bearer\s+)?[^"'\s,}]+)/gi, (match, prefix) => replaceChanged(match, `${prefix}***`));
|
|
11
|
+
redacted = redacted.replace(/(\b[A-Z][A-Z0-9_]*=)[^\s]+/g, (match, prefix) => replaceChanged(match, `${prefix}***`));
|
|
12
|
+
redacted = redacted.replace(/\bBearer\s+[^\s"']+/gi, (match) => replaceChanged(match, "Bearer ***"));
|
|
13
|
+
// High-confidence provider-style tokens (OpenAI sk-, GitHub ghp_/gho_,
|
|
14
|
+
// Slack xox*, AWS AKIA) are credential-like even without a key=value
|
|
15
|
+
// prefix (exec-plan 2026-08-25 D4: credential-like 默认阻断).
|
|
16
|
+
redacted = redacted.replace(/\b(?:sk-[A-Za-z0-9_-]{16,}|gh[pos]_[A-Za-z0-9]{20,}|xox[baprs]-[A-Za-z0-9-]{10,}|AKIA[0-9A-Z]{16})\b/g, (match) => replaceChanged(match, "***"));
|
|
17
|
+
return { redacted, findingCount };
|
|
18
|
+
}
|
|
19
|
+
export function redactSensitivePathsWithFindings(text) {
|
|
20
|
+
let findingCount = 0;
|
|
21
|
+
const replaceHome = (match) => {
|
|
22
|
+
if (match !== "<redacted-home>")
|
|
23
|
+
findingCount += 1;
|
|
24
|
+
return "<redacted-home>";
|
|
25
|
+
};
|
|
26
|
+
let redacted = text.replace(/\/(?:Users|home)\/[^/\s"'\\]+/g, replaceHome);
|
|
27
|
+
redacted = redacted.replace(/\b[A-Za-z]:\\Users\\[^\\/\s"']+/gi, replaceHome);
|
|
28
|
+
return { redacted, findingCount };
|
|
29
|
+
}
|
|
3
30
|
export function redactSecrets(text) {
|
|
4
|
-
return text
|
|
5
|
-
.replace(/\bBearer\s+[^\s"']+/gi, "Bearer ***")
|
|
6
|
-
.replace(/(\b[A-Z][A-Z0-9_]*=)[^\s]+/g, "$1***")
|
|
7
|
-
.replace(/(["']?(?:api[_-]?key|token|password|secret|authorization)["']?\s*[:=]\s*["']?)([^"'\s,}]+)/gi, "$1***");
|
|
31
|
+
return redactSecretsWithFindings(text).redacted;
|
|
8
32
|
}
|
|
9
33
|
export function truncateUtf8Preview(text, maxBytes = 4096) {
|
|
10
34
|
if (maxBytes <= 0)
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { createInterface } from "node:readline/promises";
|
|
2
|
+
import semver from "semver";
|
|
3
|
+
import { acquireUpdateLock, readUpdateState, updateLockPath, updateStatePath, writeUpdateState, } from "./state.js";
|
|
4
|
+
export async function runConsoleDailyUpdateCheck(options) {
|
|
5
|
+
void options.writeStdout;
|
|
6
|
+
void options.packageRoot;
|
|
7
|
+
void options.cwd;
|
|
8
|
+
const writeStderr = options.writeStderr ?? ((chunk) => process.stderr.write(chunk));
|
|
9
|
+
const now = options.now ?? (() => new Date());
|
|
10
|
+
try {
|
|
11
|
+
if (!canPromptInteractively(options))
|
|
12
|
+
return;
|
|
13
|
+
const statePath = updateStatePath(options.homeDir);
|
|
14
|
+
const today = formatLocalDate(now());
|
|
15
|
+
const existing = await readUpdateState(statePath);
|
|
16
|
+
if (existing.lastPromptedLocalDate === today)
|
|
17
|
+
return;
|
|
18
|
+
const release = await acquireUpdateLock(updateLockPath(options.homeDir), {
|
|
19
|
+
now,
|
|
20
|
+
});
|
|
21
|
+
if (!release)
|
|
22
|
+
return;
|
|
23
|
+
try {
|
|
24
|
+
const state = await readUpdateState(statePath);
|
|
25
|
+
if (state.lastPromptedLocalDate === today)
|
|
26
|
+
return;
|
|
27
|
+
const check = await options.client.latestVersionCheck();
|
|
28
|
+
if (!check.ok)
|
|
29
|
+
return;
|
|
30
|
+
if (!semver.gt(check.version, options.currentVersion))
|
|
31
|
+
return;
|
|
32
|
+
const parsedLatest = semver.parse(check.version);
|
|
33
|
+
if (!parsedLatest || parsedLatest.prerelease.length > 0)
|
|
34
|
+
return;
|
|
35
|
+
await markPromptedToday(statePath, state, today);
|
|
36
|
+
const answer = await ask(options, `loop-agent 有新版本:${options.currentVersion} → ${check.version}\n现在更新到 ${check.version}?[y/N] `);
|
|
37
|
+
if (!isYes(answer))
|
|
38
|
+
return;
|
|
39
|
+
const proof = await options.client.canAutoInstall();
|
|
40
|
+
if (!proof.ok) {
|
|
41
|
+
writeStderr(`当前 loop-agent 不是由此 npm 的正式全局安装管理,无法自动升级。\n请运行:npm install -g @tea-agent/loop-agent@${check.version}\n`);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const install = await options.client.installExact(check.version);
|
|
45
|
+
if (!install.ok) {
|
|
46
|
+
writeStderr(`loop-agent 更新失败:${install.reason}\n`);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const verified = await options.client.verifyInstalled(check.version);
|
|
50
|
+
if (!verified.ok) {
|
|
51
|
+
writeStderr(`loop-agent 已尝试安装,但验证失败:${verified.reason}\n`);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
writeStderr(`loop-agent 已更新到 ${check.version};新版本将在下一次命令调用时完全生效。\n`);
|
|
55
|
+
}
|
|
56
|
+
finally {
|
|
57
|
+
await release().catch(() => undefined);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
writeStderr(`loop-agent 更新检查已跳过:${error instanceof Error ? error.message : String(error)}\n`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function canPromptInteractively(options) {
|
|
65
|
+
if (!options.stdinIsTTY || !options.stderrIsTTY)
|
|
66
|
+
return false;
|
|
67
|
+
if (options.env.CI)
|
|
68
|
+
return false;
|
|
69
|
+
if (options.env.LOOP_AGENT_DISABLE_UPDATE_CHECK === "1")
|
|
70
|
+
return false;
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
function formatLocalDate(date) {
|
|
74
|
+
const year = date.getFullYear();
|
|
75
|
+
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
76
|
+
const day = String(date.getDate()).padStart(2, "0");
|
|
77
|
+
return `${year}-${month}-${day}`;
|
|
78
|
+
}
|
|
79
|
+
async function markPromptedToday(statePath, state, today) {
|
|
80
|
+
await writeUpdateState(statePath, {
|
|
81
|
+
...state,
|
|
82
|
+
lastPromptedLocalDate: today,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
async function ask(options, prompt) {
|
|
86
|
+
if (options.readLine) {
|
|
87
|
+
options.writeStderr?.(prompt);
|
|
88
|
+
return options.readLine(prompt);
|
|
89
|
+
}
|
|
90
|
+
const rl = createInterface({ input: process.stdin, output: process.stderr });
|
|
91
|
+
try {
|
|
92
|
+
return await rl.question(prompt);
|
|
93
|
+
}
|
|
94
|
+
finally {
|
|
95
|
+
rl.close();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function isYes(answer) {
|
|
99
|
+
return /^(y|yes)$/i.test(answer.trim());
|
|
100
|
+
}
|