@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,101 @@
|
|
|
1
|
+
/** Parse the persisted Chat SSE cursor shape `<epoch>:<seq>`. */
|
|
2
|
+
export function parseChatEventCursor(eventId) {
|
|
3
|
+
const raw = eventId?.trim();
|
|
4
|
+
if (!raw)
|
|
5
|
+
return null;
|
|
6
|
+
const separator = raw.lastIndexOf(":");
|
|
7
|
+
if (separator <= 0)
|
|
8
|
+
return null;
|
|
9
|
+
const epoch = raw.slice(0, separator);
|
|
10
|
+
const seqPart = raw.slice(separator + 1);
|
|
11
|
+
if (!/^\d+$/.test(seqPart))
|
|
12
|
+
return null;
|
|
13
|
+
const seq = Number(seqPart);
|
|
14
|
+
if (!Number.isSafeInteger(seq) || seq < 0)
|
|
15
|
+
return null;
|
|
16
|
+
return { epoch, seq };
|
|
17
|
+
}
|
|
18
|
+
/** Keep a cursor monotonic within one epoch; a valid new epoch replaces it. */
|
|
19
|
+
export function selectLaterChatEventId(currentEventId, candidateEventId) {
|
|
20
|
+
const candidate = parseChatEventCursor(candidateEventId);
|
|
21
|
+
if (!candidate)
|
|
22
|
+
return currentEventId ?? null;
|
|
23
|
+
const current = parseChatEventCursor(currentEventId);
|
|
24
|
+
if (!current ||
|
|
25
|
+
current.epoch !== candidate.epoch ||
|
|
26
|
+
candidate.seq > current.seq) {
|
|
27
|
+
return candidateEventId.trim();
|
|
28
|
+
}
|
|
29
|
+
return currentEventId.trim();
|
|
30
|
+
}
|
|
31
|
+
function sseBlockEventId(block) {
|
|
32
|
+
for (const rawLine of block.split("\n")) {
|
|
33
|
+
const line = rawLine.endsWith("\r") ? rawLine.slice(0, -1) : rawLine;
|
|
34
|
+
if (!line.startsWith("id:"))
|
|
35
|
+
continue;
|
|
36
|
+
return line.slice(3).trimStart().trimEnd() || null;
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A repair buffer belongs to the event-log generation that produced it. If the
|
|
42
|
+
* reconnect crossed a Console restart, replay from the replacement epoch is
|
|
43
|
+
* authoritative and old buffered frames must not be applied or restore the old
|
|
44
|
+
* Last-Event-ID. Control/comment frames are not persisted repair facts.
|
|
45
|
+
*/
|
|
46
|
+
export function selectChatSseRepairBlocks(blocks, readyCursor) {
|
|
47
|
+
const ready = parseChatEventCursor(readyCursor);
|
|
48
|
+
if (!ready)
|
|
49
|
+
return [];
|
|
50
|
+
return blocks.filter((block) => {
|
|
51
|
+
const buffered = parseChatEventCursor(sseBlockEventId(block));
|
|
52
|
+
return buffered?.epoch === ready.epoch;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/** Read the dense event-store watermark that starts the live follow phase. */
|
|
56
|
+
export function readChatStreamReadyCursor(block) {
|
|
57
|
+
let eventName = "message";
|
|
58
|
+
let dataText = "";
|
|
59
|
+
for (const rawLine of block.split("\n")) {
|
|
60
|
+
const line = rawLine.endsWith("\r") ? rawLine.slice(0, -1) : rawLine;
|
|
61
|
+
if (line.startsWith("event:"))
|
|
62
|
+
eventName = line.slice(6).trim();
|
|
63
|
+
else if (line.startsWith("data:"))
|
|
64
|
+
dataText += line.slice(5).trimStart();
|
|
65
|
+
}
|
|
66
|
+
if (eventName !== "stream_ready" || !dataText)
|
|
67
|
+
return null;
|
|
68
|
+
try {
|
|
69
|
+
const data = JSON.parse(dataText);
|
|
70
|
+
if (typeof data.epoch !== "string" ||
|
|
71
|
+
!data.epoch ||
|
|
72
|
+
typeof data.lastSeq !== "number" ||
|
|
73
|
+
!Number.isSafeInteger(data.lastSeq) ||
|
|
74
|
+
data.lastSeq < 0)
|
|
75
|
+
return null;
|
|
76
|
+
return `${data.epoch}:${data.lastSeq}`;
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Detect a dropped live persisted frame before it can advance the replay cursor.
|
|
84
|
+
* Epoch changes remain server-owned because an epoch_mismatch reconcile frame
|
|
85
|
+
* is followed by snapshot events from the replacement epoch.
|
|
86
|
+
*/
|
|
87
|
+
export function inspectChatSseContinuity(block, lastEventId) {
|
|
88
|
+
const current = parseChatEventCursor(lastEventId);
|
|
89
|
+
const incoming = parseChatEventCursor(sseBlockEventId(block));
|
|
90
|
+
if (!current || !incoming || current.epoch !== incoming.epoch) {
|
|
91
|
+
return { action: "apply" };
|
|
92
|
+
}
|
|
93
|
+
if (incoming.seq > current.seq + 1) {
|
|
94
|
+
return {
|
|
95
|
+
action: "reconnect",
|
|
96
|
+
expectedSeq: current.seq + 1,
|
|
97
|
+
receivedSeq: incoming.seq,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
return { action: "apply" };
|
|
101
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ensureLinkedSubmissionOrder } from "../../chat/timeline-message-order.js";
|
|
1
2
|
function finiteToken(value) {
|
|
2
3
|
return typeof value === "number" && Number.isFinite(value)
|
|
3
4
|
? Math.max(0, Math.floor(value))
|
|
@@ -60,7 +61,7 @@ export function compactionMessageFromEvent(item) {
|
|
|
60
61
|
}
|
|
61
62
|
/** Stable chronological order: server sequence first, legacy time/id fallback. */
|
|
62
63
|
export function sortChatTimelineMessages(messages) {
|
|
63
|
-
return [...messages].sort((a, b) => {
|
|
64
|
+
return ensureLinkedSubmissionOrder([...messages].sort((a, b) => {
|
|
64
65
|
if (a.eventSeq !== undefined &&
|
|
65
66
|
b.eventSeq !== undefined &&
|
|
66
67
|
a.eventSeq !== b.eventSeq) {
|
|
@@ -75,13 +76,20 @@ export function sortChatTimelineMessages(messages) {
|
|
|
75
76
|
// Modern JS sort is stable; keep insertion order for indistinguishable
|
|
76
77
|
// legacy rows instead of inventing chronology from random ids.
|
|
77
78
|
return 0;
|
|
78
|
-
});
|
|
79
|
+
}));
|
|
79
80
|
}
|
|
80
81
|
export function upsertCompactionMessage(messages, item) {
|
|
81
82
|
const next = compactionMessageFromEvent(item);
|
|
82
83
|
if (!next)
|
|
83
84
|
return messages;
|
|
84
85
|
const existing = messages.find((message) => message.id === next.id);
|
|
86
|
+
const existingUpdatedSeq = existing?.updatedSeq ?? existing?.eventSeq;
|
|
87
|
+
const nextUpdatedSeq = next.updatedSeq ?? next.eventSeq;
|
|
88
|
+
if (existingUpdatedSeq !== undefined &&
|
|
89
|
+
nextUpdatedSeq !== undefined &&
|
|
90
|
+
existingUpdatedSeq > nextUpdatedSeq) {
|
|
91
|
+
return messages;
|
|
92
|
+
}
|
|
85
93
|
const result = existing
|
|
86
94
|
? messages.map((message) => message.id === next.id
|
|
87
95
|
? {
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { createInputHistoryState, navigateInputHistory, recordInputHistoryEntry, resetInputHistoryBrowsing, } from "./input-history.js";
|
|
2
|
+
export const DUPLICATE_SUBMISSION_GESTURE_MS = 350;
|
|
3
|
+
export function composerSessionKey(identity) {
|
|
4
|
+
return `${identity.workspaceId ?? ""}\u0000${identity.sessionId}`;
|
|
5
|
+
}
|
|
6
|
+
function cloneHistory(history) {
|
|
7
|
+
return { ...history, entries: [...history.entries] };
|
|
8
|
+
}
|
|
9
|
+
function cloneImages(images) {
|
|
10
|
+
return [...images];
|
|
11
|
+
}
|
|
12
|
+
function createRecord() {
|
|
13
|
+
return {
|
|
14
|
+
draft: "",
|
|
15
|
+
images: [],
|
|
16
|
+
history: createInputHistoryState(),
|
|
17
|
+
revision: 0,
|
|
18
|
+
sequence: 0,
|
|
19
|
+
initialized: false,
|
|
20
|
+
attempts: new Map(),
|
|
21
|
+
failedSubmissionCount: 0,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function sameImages(left, right) {
|
|
25
|
+
return (left.length === right.length &&
|
|
26
|
+
left.every((image, index) => {
|
|
27
|
+
const other = right[index];
|
|
28
|
+
return (other !== undefined &&
|
|
29
|
+
image.name === other.name &&
|
|
30
|
+
image.type === other.type &&
|
|
31
|
+
image.mimeType === other.mimeType &&
|
|
32
|
+
image.data === other.data);
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Browser-local composer state addressed by durable session identity.
|
|
37
|
+
*
|
|
38
|
+
* Network callbacks settle immutable attempts against their owning record;
|
|
39
|
+
* they never need to mutate whichever composer happens to be visible.
|
|
40
|
+
*/
|
|
41
|
+
export class ComposerSessionLedger {
|
|
42
|
+
now;
|
|
43
|
+
records = new Map();
|
|
44
|
+
constructor(now = Date.now) {
|
|
45
|
+
this.now = now;
|
|
46
|
+
}
|
|
47
|
+
has(identity) {
|
|
48
|
+
return this.records.has(composerSessionKey(identity));
|
|
49
|
+
}
|
|
50
|
+
snapshot(identity) {
|
|
51
|
+
const record = this.record(identity);
|
|
52
|
+
return {
|
|
53
|
+
draft: record.draft,
|
|
54
|
+
images: cloneImages(record.images),
|
|
55
|
+
history: cloneHistory(record.history),
|
|
56
|
+
revision: record.revision,
|
|
57
|
+
failedSubmissionCount: record.failedSubmissionCount,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
seedDraft(identity, draft) {
|
|
61
|
+
const record = this.record(identity);
|
|
62
|
+
if (record.initialized || record.revision !== 0 || record.attempts.size > 0)
|
|
63
|
+
return false;
|
|
64
|
+
record.draft = draft;
|
|
65
|
+
record.initialized = true;
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
setDraft(identity, draft) {
|
|
69
|
+
const record = this.record(identity);
|
|
70
|
+
if (record.draft === draft)
|
|
71
|
+
return false;
|
|
72
|
+
record.draft = draft;
|
|
73
|
+
record.history = resetInputHistoryBrowsing(record.history);
|
|
74
|
+
record.revision += 1;
|
|
75
|
+
record.initialized = true;
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
setImages(identity, images) {
|
|
79
|
+
const record = this.record(identity);
|
|
80
|
+
record.images = cloneImages(images);
|
|
81
|
+
record.revision += 1;
|
|
82
|
+
record.initialized = true;
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
recordHistory(identity, text) {
|
|
86
|
+
const record = this.record(identity);
|
|
87
|
+
record.history = recordInputHistoryEntry(record.history, text);
|
|
88
|
+
}
|
|
89
|
+
navigateHistory(identity, direction, context) {
|
|
90
|
+
const record = this.record(identity);
|
|
91
|
+
const decision = navigateInputHistory(record.history, direction, context);
|
|
92
|
+
if (!decision.handled)
|
|
93
|
+
return decision;
|
|
94
|
+
record.history = decision.state;
|
|
95
|
+
if (record.draft !== decision.text) {
|
|
96
|
+
record.draft = decision.text;
|
|
97
|
+
record.revision += 1;
|
|
98
|
+
record.initialized = true;
|
|
99
|
+
}
|
|
100
|
+
return decision;
|
|
101
|
+
}
|
|
102
|
+
beginSubmission(identity, sessionGeneration, clientRequestId) {
|
|
103
|
+
const record = this.record(identity);
|
|
104
|
+
if (!record.draft.trim() && record.images.length === 0)
|
|
105
|
+
return null;
|
|
106
|
+
const now = this.now();
|
|
107
|
+
const sinceLastClaim = record.lastClaim
|
|
108
|
+
? now - record.lastClaim.at
|
|
109
|
+
: Number.POSITIVE_INFINITY;
|
|
110
|
+
if (record.lastClaim &&
|
|
111
|
+
sinceLastClaim >= 0 &&
|
|
112
|
+
sinceLastClaim <= DUPLICATE_SUBMISSION_GESTURE_MS &&
|
|
113
|
+
record.lastClaim.draft === record.draft &&
|
|
114
|
+
sameImages(record.lastClaim.images, record.images))
|
|
115
|
+
return null;
|
|
116
|
+
record.sequence += 1;
|
|
117
|
+
const sequence = record.sequence;
|
|
118
|
+
const controller = new AbortController();
|
|
119
|
+
const draftSnapshot = record.draft;
|
|
120
|
+
const imageSnapshot = cloneImages(record.images);
|
|
121
|
+
record.lastClaim = {
|
|
122
|
+
draft: draftSnapshot,
|
|
123
|
+
images: cloneImages(imageSnapshot),
|
|
124
|
+
at: now,
|
|
125
|
+
};
|
|
126
|
+
record.history = recordInputHistoryEntry(record.history, draftSnapshot);
|
|
127
|
+
record.draft = "";
|
|
128
|
+
record.images = [];
|
|
129
|
+
record.revision += 1;
|
|
130
|
+
record.initialized = true;
|
|
131
|
+
const attempt = {
|
|
132
|
+
attemptId: `${composerSessionKey(identity)}:${sequence}:${clientRequestId}`,
|
|
133
|
+
identity: { ...identity },
|
|
134
|
+
sessionGeneration,
|
|
135
|
+
sequence,
|
|
136
|
+
clientRequestId,
|
|
137
|
+
draftSnapshot,
|
|
138
|
+
imageSnapshot,
|
|
139
|
+
committedRevision: record.revision,
|
|
140
|
+
signal: controller.signal,
|
|
141
|
+
};
|
|
142
|
+
record.attempts.set(attempt.attemptId, { attempt, controller });
|
|
143
|
+
return attempt;
|
|
144
|
+
}
|
|
145
|
+
settle(attempt, outcome) {
|
|
146
|
+
const key = composerSessionKey(attempt.identity);
|
|
147
|
+
const record = this.records.get(key);
|
|
148
|
+
const owned = record?.attempts.get(attempt.attemptId);
|
|
149
|
+
if (!record || !owned || owned.attempt !== attempt)
|
|
150
|
+
return "stale";
|
|
151
|
+
record.attempts.delete(attempt.attemptId);
|
|
152
|
+
owned.controller.abort();
|
|
153
|
+
if (outcome === "accepted")
|
|
154
|
+
return "accepted";
|
|
155
|
+
if (record.revision === attempt.committedRevision &&
|
|
156
|
+
record.draft === "" &&
|
|
157
|
+
record.images.length === 0) {
|
|
158
|
+
record.draft = attempt.draftSnapshot;
|
|
159
|
+
record.images = cloneImages(attempt.imageSnapshot);
|
|
160
|
+
record.revision += 1;
|
|
161
|
+
return "restored";
|
|
162
|
+
}
|
|
163
|
+
record.failedSubmissionCount = Math.min(Number.MAX_SAFE_INTEGER, record.failedSubmissionCount + 1);
|
|
164
|
+
return "retained";
|
|
165
|
+
}
|
|
166
|
+
settleByRequest(identity, clientRequestId, outcome) {
|
|
167
|
+
const record = this.records.get(composerSessionKey(identity));
|
|
168
|
+
const owned = record
|
|
169
|
+
? [...record.attempts.values()].find((entry) => entry.attempt.clientRequestId === clientRequestId)
|
|
170
|
+
: undefined;
|
|
171
|
+
return owned ? this.settle(owned.attempt, outcome) : "stale";
|
|
172
|
+
}
|
|
173
|
+
release(identity) {
|
|
174
|
+
const key = composerSessionKey(identity);
|
|
175
|
+
const record = this.records.get(key);
|
|
176
|
+
if (!record)
|
|
177
|
+
return;
|
|
178
|
+
for (const owned of record.attempts.values())
|
|
179
|
+
owned.controller.abort();
|
|
180
|
+
record.attempts.clear();
|
|
181
|
+
this.records.delete(key);
|
|
182
|
+
}
|
|
183
|
+
record(identity) {
|
|
184
|
+
const key = composerSessionKey(identity);
|
|
185
|
+
let record = this.records.get(key);
|
|
186
|
+
if (!record) {
|
|
187
|
+
record = createRecord();
|
|
188
|
+
this.records.set(key, record);
|
|
189
|
+
}
|
|
190
|
+
return record;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Operator Chat — context insights store (dsh-context parity).
|
|
3
|
+
*
|
|
4
|
+
* Module-level external store so every surface that needs the dashboard
|
|
5
|
+
* (Details-rail context tab, /context overlay) shares one fetch lifecycle
|
|
6
|
+
* keyed by sessionId. Read-only GET; no mutation gate needed.
|
|
7
|
+
*/
|
|
8
|
+
import { useSyncExternalStore } from "react";
|
|
9
|
+
let state = { sessionId: null, loading: false };
|
|
10
|
+
const listeners = new Set();
|
|
11
|
+
function emit() {
|
|
12
|
+
for (const listener of listeners)
|
|
13
|
+
listener();
|
|
14
|
+
}
|
|
15
|
+
function setState(next) {
|
|
16
|
+
state = next;
|
|
17
|
+
emit();
|
|
18
|
+
}
|
|
19
|
+
/** Attach the store to a session; null detaches and clears. */
|
|
20
|
+
export function attachContextInsights(sessionId) {
|
|
21
|
+
if (state.sessionId === sessionId)
|
|
22
|
+
return;
|
|
23
|
+
setState({ sessionId, loading: Boolean(sessionId) });
|
|
24
|
+
if (!sessionId)
|
|
25
|
+
return;
|
|
26
|
+
void refreshContextInsights();
|
|
27
|
+
}
|
|
28
|
+
/** Force a refetch (spatial overlay open, manual refresh button). */
|
|
29
|
+
export async function refreshContextInsights() {
|
|
30
|
+
const sessionId = state.sessionId;
|
|
31
|
+
if (!sessionId)
|
|
32
|
+
return;
|
|
33
|
+
setState({ ...state, loading: true });
|
|
34
|
+
try {
|
|
35
|
+
const res = await fetch(`/api/operator/v1/chat/sessions/${encodeURIComponent(sessionId)}/context-insights`, { credentials: "include" });
|
|
36
|
+
const body = (await res.json().catch(() => null));
|
|
37
|
+
if (state.sessionId !== sessionId)
|
|
38
|
+
return; // stale reply
|
|
39
|
+
if (!res.ok || !body?.insights) {
|
|
40
|
+
setState({
|
|
41
|
+
sessionId,
|
|
42
|
+
loading: false,
|
|
43
|
+
error: body?.error?.message ?? `加载上下文洞察失败(${res.status})`,
|
|
44
|
+
});
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
setState({ sessionId, loading: false, insights: body.insights });
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
if (state.sessionId !== sessionId)
|
|
51
|
+
return;
|
|
52
|
+
setState({
|
|
53
|
+
sessionId,
|
|
54
|
+
loading: false,
|
|
55
|
+
error: error instanceof Error ? error.message : String(error),
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export function useContextInsights() {
|
|
60
|
+
return useSyncExternalStore((onStoreChange) => {
|
|
61
|
+
listeners.add(onStoreChange);
|
|
62
|
+
return () => listeners.delete(onStoreChange);
|
|
63
|
+
}, () => state, () => state);
|
|
64
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
export const DETAILS_SURFACE_ORDER = [
|
|
2
|
+
"repo",
|
|
3
|
+
"session",
|
|
4
|
+
"bench",
|
|
5
|
+
];
|
|
6
|
+
export const DETAILS_SURFACES = {
|
|
7
|
+
repo: {
|
|
8
|
+
id: "repo",
|
|
9
|
+
label: "仓库",
|
|
10
|
+
description: "当前仓库的文件与 Git",
|
|
11
|
+
pages: ["files", "scm"],
|
|
12
|
+
},
|
|
13
|
+
session: {
|
|
14
|
+
id: "session",
|
|
15
|
+
label: "会话",
|
|
16
|
+
description: "这次对话的注入与检查",
|
|
17
|
+
pages: [
|
|
18
|
+
"context",
|
|
19
|
+
"insights",
|
|
20
|
+
"calls",
|
|
21
|
+
"activity",
|
|
22
|
+
"trajectory",
|
|
23
|
+
"goal",
|
|
24
|
+
"dag",
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
bench: {
|
|
28
|
+
id: "bench",
|
|
29
|
+
label: "工作台",
|
|
30
|
+
description: "终端、预览、数据库",
|
|
31
|
+
pages: ["terminals", "browser", "databases"],
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
const TAB_TO_SURFACE = {
|
|
35
|
+
files: "repo",
|
|
36
|
+
scm: "repo",
|
|
37
|
+
context: "session",
|
|
38
|
+
insights: "session",
|
|
39
|
+
calls: "session",
|
|
40
|
+
activity: "session",
|
|
41
|
+
trajectory: "session",
|
|
42
|
+
goal: "session",
|
|
43
|
+
dag: "session",
|
|
44
|
+
terminals: "bench",
|
|
45
|
+
browser: "bench",
|
|
46
|
+
databases: "bench",
|
|
47
|
+
};
|
|
48
|
+
export const DEFAULT_PAGE_BY_SURFACE = {
|
|
49
|
+
repo: "files",
|
|
50
|
+
session: "context",
|
|
51
|
+
bench: "terminals",
|
|
52
|
+
};
|
|
53
|
+
export function surfaceForTab(tab) {
|
|
54
|
+
return TAB_TO_SURFACE[tab];
|
|
55
|
+
}
|
|
56
|
+
export function pagesOnSurface(surface, available) {
|
|
57
|
+
const allowed = new Set(DETAILS_SURFACES[surface].pages);
|
|
58
|
+
return available.filter((tab) => allowed.has(tab));
|
|
59
|
+
}
|
|
60
|
+
export function surfacesWithPages(available) {
|
|
61
|
+
return DETAILS_SURFACE_ORDER.filter((surface) => pagesOnSurface(surface, available).length > 0);
|
|
62
|
+
}
|
|
63
|
+
export function restorePageOnSurface(surface, available, last) {
|
|
64
|
+
const pages = pagesOnSurface(surface, available);
|
|
65
|
+
if (pages.length === 0)
|
|
66
|
+
return null;
|
|
67
|
+
if (last && pages.includes(last))
|
|
68
|
+
return last;
|
|
69
|
+
return pages[0] ?? null;
|
|
70
|
+
}
|
|
71
|
+
export function adjacentSurface(current, availableSurfaces, delta) {
|
|
72
|
+
if (availableSurfaces.length < 2)
|
|
73
|
+
return null;
|
|
74
|
+
const index = availableSurfaces.indexOf(current);
|
|
75
|
+
if (index < 0)
|
|
76
|
+
return availableSurfaces[0] ?? null;
|
|
77
|
+
return availableSurfaces[(index + delta + availableSurfaces.length) % availableSurfaces.length] ?? null;
|
|
78
|
+
}
|
|
79
|
+
export function adjacentPage(current, pages, delta) {
|
|
80
|
+
if (pages.length < 2)
|
|
81
|
+
return null;
|
|
82
|
+
const index = pages.indexOf(current);
|
|
83
|
+
if (index < 0)
|
|
84
|
+
return pages[0] ?? null;
|
|
85
|
+
return pages[(index + delta + pages.length) % pages.length] ?? null;
|
|
86
|
+
}
|
|
87
|
+
export function temporaryDetailsTab(id) {
|
|
88
|
+
switch (id) {
|
|
89
|
+
/* Context / insights / calls are standing session pages (2026-09-18):
|
|
90
|
+
* they render whenever a session exists, so their tabs carry no close
|
|
91
|
+
* control. Activity and goal remain transient: the panel closes on
|
|
92
|
+
* completion or cancel. */
|
|
93
|
+
case "activity":
|
|
94
|
+
case "goal":
|
|
95
|
+
return id;
|
|
96
|
+
default:
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Composer `@` file palette helpers: 1-column movement, crumbs, row labels,
|
|
3
|
+
* and keyboard decisions. DOM-free so keyboard/AT behavior can be unit-tested.
|
|
4
|
+
*/
|
|
5
|
+
export const FILE_PALETTE_AVAILABLE_HEIGHT_VAR = "--oc-file-palette-available-height";
|
|
6
|
+
export const FILE_PALETTE_MAX_HEIGHT_PX = 400;
|
|
7
|
+
export function fileOptionId(index) {
|
|
8
|
+
return `oc-file-option-${index}`;
|
|
9
|
+
}
|
|
10
|
+
export function filePaletteBasename(path) {
|
|
11
|
+
const trimmed = path.endsWith("/") ? path.slice(0, -1) : path;
|
|
12
|
+
const slash = trimmed.lastIndexOf("/");
|
|
13
|
+
const name = slash < 0 ? trimmed : trimmed.slice(slash + 1);
|
|
14
|
+
return path.endsWith("/") ? `${name}/` : name;
|
|
15
|
+
}
|
|
16
|
+
export function filePaletteParent(path) {
|
|
17
|
+
const trimmed = path.endsWith("/") ? path.slice(0, -1) : path;
|
|
18
|
+
const slash = trimmed.lastIndexOf("/");
|
|
19
|
+
return slash < 0 ? "" : trimmed.slice(0, slash);
|
|
20
|
+
}
|
|
21
|
+
export function moveFilePaletteIndex(current, length, direction) {
|
|
22
|
+
if (!Number.isFinite(length) || length <= 0)
|
|
23
|
+
return 0;
|
|
24
|
+
if (!Number.isFinite(current) || current < 0)
|
|
25
|
+
return 0;
|
|
26
|
+
if (direction === "up")
|
|
27
|
+
return current <= 0 ? 0 : current - 1;
|
|
28
|
+
return current >= length - 1 ? length - 1 : current + 1;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Breadcrumbs exist only after a Tab/chevron drill. A path the user typed
|
|
32
|
+
* already shows its context in the draft, so it gets no header.
|
|
33
|
+
*/
|
|
34
|
+
export function filePaletteCrumbs(query, drilled) {
|
|
35
|
+
if (!drilled)
|
|
36
|
+
return undefined;
|
|
37
|
+
const slash = query.lastIndexOf("/");
|
|
38
|
+
if (slash < 0)
|
|
39
|
+
return undefined;
|
|
40
|
+
const segments = query
|
|
41
|
+
.slice(0, slash)
|
|
42
|
+
.split("/")
|
|
43
|
+
.filter((segment) => segment !== "");
|
|
44
|
+
if (segments.length === 0)
|
|
45
|
+
return undefined;
|
|
46
|
+
const crumbs = [
|
|
47
|
+
{ label: "工作区", value: "", current: false },
|
|
48
|
+
];
|
|
49
|
+
for (const [index, segment] of segments.entries()) {
|
|
50
|
+
crumbs.push({
|
|
51
|
+
label: segment,
|
|
52
|
+
value: `${segments.slice(0, index + 1).join("/")}/`,
|
|
53
|
+
current: index === segments.length - 1,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return crumbs;
|
|
57
|
+
}
|
|
58
|
+
export function decideFilePaletteKey(input) {
|
|
59
|
+
if (input.shortcutOpen || input.composing || input.optionCount <= 0) {
|
|
60
|
+
return { type: "none" };
|
|
61
|
+
}
|
|
62
|
+
if (input.key === "ArrowUp") {
|
|
63
|
+
return {
|
|
64
|
+
type: "move",
|
|
65
|
+
index: moveFilePaletteIndex(input.activeIndex, input.optionCount, "up"),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (input.key === "ArrowDown") {
|
|
69
|
+
return {
|
|
70
|
+
type: "move",
|
|
71
|
+
index: moveFilePaletteIndex(input.activeIndex, input.optionCount, "down"),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
if (input.key === "Escape")
|
|
75
|
+
return { type: "dismiss" };
|
|
76
|
+
if (input.key === "Tab")
|
|
77
|
+
return input.activeIsDir ? { type: "drill" } : { type: "pick" };
|
|
78
|
+
if (input.key === "Enter" && !input.shiftKey)
|
|
79
|
+
return { type: "pick" };
|
|
80
|
+
return { type: "none" };
|
|
81
|
+
}
|
|
@@ -42,6 +42,28 @@ export function isMarkdownPreviewLanguage(language) {
|
|
|
42
42
|
const lang = normalizedLanguage(language);
|
|
43
43
|
return lang === "md" || lang === "markdown";
|
|
44
44
|
}
|
|
45
|
+
/** Image languages whose preview is an <img> fed by the workspace byte
|
|
46
|
+
* route (DSH IMAGE_EXTENSIONS). Shared with the inline preview drawer. */
|
|
47
|
+
export function isImagePreviewLanguage(language) {
|
|
48
|
+
return [
|
|
49
|
+
"png",
|
|
50
|
+
"jpg",
|
|
51
|
+
"jpeg",
|
|
52
|
+
"gif",
|
|
53
|
+
"webp",
|
|
54
|
+
"bmp",
|
|
55
|
+
"ico",
|
|
56
|
+
"svg",
|
|
57
|
+
].includes(normalizedLanguage(language));
|
|
58
|
+
}
|
|
59
|
+
/** Kind-tagged binary previews (image/unsupported) never fall back to a
|
|
60
|
+
* text <pre>: their snapshot content is empty by design. */
|
|
61
|
+
export function isKindBinaryPreview(preview) {
|
|
62
|
+
return preview.kind === "image" || preview.kind === "unsupported";
|
|
63
|
+
}
|
|
64
|
+
function isSvgLanguage(language) {
|
|
65
|
+
return normalizedLanguage(language) === "svg";
|
|
66
|
+
}
|
|
45
67
|
function formatTextBody(preview) {
|
|
46
68
|
if (normalizedLanguage(preview.language) !== "json")
|
|
47
69
|
return preview.content;
|
|
@@ -201,12 +223,20 @@ body { font: 16px/1.65 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans
|
|
|
201
223
|
.md-code, .source { margin: 1em 0; padding: 14px 16px; overflow: auto; white-space: pre-wrap; background: #fff; border: 1px solid #e4ddd2; border-radius: 8px; }
|
|
202
224
|
.frame { margin: 0; padding: 0; }
|
|
203
225
|
iframe.page { display: block; width: 100%; height: calc(100vh - 53px); border: 0; background: #fff; }
|
|
226
|
+
.frame .page-image { display: block; max-width: calc(100vw - 32px); max-height: calc(100vh - 85px); margin: 16px auto; border-radius: 8px; }
|
|
227
|
+
p.unsupported { margin: 0; padding: 48px 24px; color: #6b6258; font-size: 14px; text-align: center; }
|
|
204
228
|
`.trim();
|
|
205
229
|
}
|
|
206
230
|
function formattedSource(preview) {
|
|
207
231
|
return escapeHtml(formatTextBody(preview));
|
|
208
232
|
}
|
|
209
233
|
function previewPane(preview) {
|
|
234
|
+
if (preview.kind === "unsupported") {
|
|
235
|
+
return `<article class="doc"><p class="unsupported">${preview.language === "pdf" ? "暂不支持 PDF 预览" : "此文件类型无法预览"}</p></article>`;
|
|
236
|
+
}
|
|
237
|
+
if (preview.kind === "image" && preview.previewUrl) {
|
|
238
|
+
return `<div class="frame"><img class="page-image" src="${escapeHtml(preview.previewUrl)}" alt="${escapeHtml(preview.path)}" decoding="async" referrerpolicy="no-referrer"></div>`;
|
|
239
|
+
}
|
|
210
240
|
if (isHtmlPreviewLanguage(preview.language)) {
|
|
211
241
|
return preview.htmlPreviewUrl
|
|
212
242
|
? `<div class="frame"><iframe class="page" sandbox="${HTML_PREVIEW_SANDBOX}" referrerpolicy="no-referrer" src="${escapeHtml(preview.htmlPreviewUrl)}"></iframe></div>`
|
|
@@ -218,6 +248,10 @@ function previewPane(preview) {
|
|
|
218
248
|
return `<article class="doc"><pre class="source">${formattedSource(preview)}</pre></article>`;
|
|
219
249
|
}
|
|
220
250
|
function sourcePane(preview) {
|
|
251
|
+
if (isKindBinaryPreview(preview) && !isSvgLanguage(preview.language)) {
|
|
252
|
+
// Bitmap/unsupported bytes never enter a text pane; SVG keeps its XML.
|
|
253
|
+
return `<article class="doc"><p class="unsupported">此文件无文本源码。</p></article>`;
|
|
254
|
+
}
|
|
221
255
|
return `<article class="doc"><pre class="source">${formattedSource(preview)}</pre></article>`;
|
|
222
256
|
}
|
|
223
257
|
function readingPageScript() {
|
|
@@ -249,6 +283,18 @@ export function buildPreviewBrowserDocument(preview) {
|
|
|
249
283
|
? `<p class="notice">${escapeHtml(PREVIEW_TRUNCATION_NOTICE)}</p>`
|
|
250
284
|
: "";
|
|
251
285
|
const lang = normalizedLanguage(preview.language);
|
|
286
|
+
// Bitmap images and unrenderable binaries have no readable source pane:
|
|
287
|
+
// hide the mode toggle instead of offering an empty <pre>.
|
|
288
|
+
const hasSourcePane = !(isKindBinaryPreview(preview) && !isSvgLanguage(lang));
|
|
289
|
+
const modes = hasSourcePane
|
|
290
|
+
? ` <div class="modes" role="group" aria-label="查看模式">
|
|
291
|
+
<button type="button" id="view-preview" class="is-active" aria-pressed="true">预览</button>
|
|
292
|
+
<button type="button" id="view-source" aria-pressed="false">查看原文</button>
|
|
293
|
+
</div>`
|
|
294
|
+
: "";
|
|
295
|
+
const sourcePaneHtml = hasSourcePane
|
|
296
|
+
? `\n<div id="pane-source" class="pane">${sourcePane(preview)}</div>`
|
|
297
|
+
: "";
|
|
252
298
|
return `<!doctype html>
|
|
253
299
|
<html lang="zh-CN">
|
|
254
300
|
<head>
|
|
@@ -265,14 +311,10 @@ ${readingPageCss()}
|
|
|
265
311
|
<strong>${title}</strong>
|
|
266
312
|
<span class="kind">${escapeHtml(lang || "text")}${preview.truncated ? " · 已截断" : ""}</span>
|
|
267
313
|
</div>
|
|
268
|
-
|
|
269
|
-
<button type="button" id="view-preview" class="is-active" aria-pressed="true">预览</button>
|
|
270
|
-
<button type="button" id="view-source" aria-pressed="false">查看原文</button>
|
|
271
|
-
</div>
|
|
314
|
+
${modes}
|
|
272
315
|
</header>
|
|
273
316
|
${notice}
|
|
274
|
-
<div id="pane-preview" class="pane is-active">${previewPane(preview)}</div
|
|
275
|
-
<div id="pane-source" class="pane">${sourcePane(preview)}</div>
|
|
317
|
+
<div id="pane-preview" class="pane is-active">${previewPane(preview)}</div>${sourcePaneHtml}
|
|
276
318
|
${readingPageScript()}
|
|
277
319
|
</body>
|
|
278
320
|
</html>`;
|
|
@@ -307,9 +349,15 @@ function defaultHost() {
|
|
|
307
349
|
export function openPreviewInBrowser(preview, host = defaultHost(), features = previewOpenWindowFeatures(screenAvail())) {
|
|
308
350
|
let objectUrl;
|
|
309
351
|
try {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
352
|
+
// Bitmap images open the workspace byte route directly; their bytes
|
|
353
|
+
// must never be escaped into a text <pre> reading page.
|
|
354
|
+
let targetUrl;
|
|
355
|
+
if (isHtmlPreviewLanguage(preview.language) && preview.htmlPreviewUrl) {
|
|
356
|
+
targetUrl = preview.htmlPreviewUrl;
|
|
357
|
+
}
|
|
358
|
+
else if (preview.kind === "image" && preview.previewUrl) {
|
|
359
|
+
targetUrl = preview.previewUrl;
|
|
360
|
+
}
|
|
313
361
|
if (!targetUrl) {
|
|
314
362
|
const documentHtml = buildPreviewBrowserDocument(preview);
|
|
315
363
|
const blob = new Blob([documentHtml], { type: "text/html;charset=utf-8" });
|