@tea-agent/loop-agent 0.52.0-next.1 → 0.52.0-next.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +99 -21
- package/dist/build-stamp.json +3 -3
- package/dist/cli/command-definitions.js +1 -75
- package/dist/cli/help.js +1 -1
- package/dist/cli/program.js +1 -28
- package/dist/commands/init-accepted-merge.js +46 -0
- package/dist/commands/init-upgrade.js +115 -2
- package/dist/commands/init.js +79 -12
- package/dist/executors/pi-sdk-executor.js +3 -3
- package/dist/governance/path-guard.js +2 -0
- package/dist/records/harvest.js +1 -1
- package/dist/shared/git-progress.js +3 -0
- package/dist/shared/operator/capabilities.js +0 -122
- package/dist/shared/pi-context-pressure/checkpoint.js +94 -24
- package/dist/shared/pi-context-pressure/compaction-policy.js +152 -66
- package/dist/shared/pi-context-pressure/extension.js +25 -8
- package/dist/shared/pi-context-pressure/index.js +1 -1
- package/dist/shared/pi-context-pressure/telemetry.js +10 -0
- package/dist/shared/update/npm-client.js +14 -3
- package/dist/task/config-types.js +5 -10
- package/dist/task/delegate.js +1 -1
- package/dist/task/read-model.js +0 -4
- package/dist/task/runtime.js +0 -1
- package/dist/task/worktree.js +1 -1
- package/dist/worker/console/chat/api-workbench-core.js +17 -6
- package/dist/worker/console/chat/api-workbench.js +2 -0
- package/dist/worker/console/chat/assistant-content.js +21 -3
- package/dist/worker/console/chat/chat-event-projection.js +6 -0
- package/dist/worker/console/chat/chat-event-store.js +32 -2
- package/dist/worker/console/chat/chat-references.js +4 -0
- package/dist/worker/console/chat/compaction-errors.js +14 -2
- package/dist/worker/console/chat/context-insights.js +41 -4
- package/dist/worker/console/chat/context-usage.js +4 -1
- package/dist/worker/console/chat/pi-runtime/custom-tools/apiworkbench-tools.js +65 -3
- package/dist/worker/console/chat/pi-runtime/custom-tools/browser-tools.js +2 -2
- package/dist/worker/console/chat/pi-runtime/extension-bindings.js +39 -0
- package/dist/worker/console/chat/pi-runtime/sdk-bindings.js +4 -0
- package/dist/worker/console/chat/pi-runtime.js +389 -191
- package/dist/worker/console/chat/repo-browser.js +5 -2
- package/dist/worker/console/chat/repo-preview-kind.js +16 -6
- package/dist/worker/console/chat/routes.js +299 -25
- package/dist/worker/console/chat/scheduled-goal-request.js +1 -1
- package/dist/worker/console/chat/subagents/jobs.js +115 -4
- package/dist/worker/console/chat/terminal-sessions.js +52 -6
- package/dist/worker/console/chat/tool-exposure-catalog.js +1 -1
- package/dist/worker/console/chat/tool-presentation.js +17 -10
- package/dist/worker/console/chat/tool-preview.js +22 -0
- package/dist/worker/console/chat/turn-process.js +49 -0
- package/dist/worker/console/chat/vcp-prompt.js +14 -9
- package/dist/worker/console/chat/workspace-changes.js +17 -0
- package/dist/worker/console/console-update-runtime.js +5 -1
- package/dist/worker/console/operator-actions.js +7 -6
- package/dist/worker/console/operator-user-error.js +5 -1
- package/dist/worker/console/pi-compaction-settings.js +220 -0
- package/dist/worker/console/routes.js +1 -1
- package/dist/worker/console/server.js +148 -6
- package/dist/worker/console/static/assets/FilePreviewDocx-ybM3ZqSl.js +9 -0
- package/dist/worker/console/static/assets/abnfDiagram-N423BO3Z-CT26sIgH.js +1 -0
- package/dist/worker/console/static/assets/{arc-Bkf_oc0_.js → arc-CPwLqDB0.js} +1 -1
- package/dist/worker/console/static/assets/architectureDiagram-T3A2C74G-CzTSMPU_.js +36 -0
- package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-D62uVvbI.js → blockDiagram-VBNYF7ZC-BfgbtJLH.js} +1 -1
- package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-Iq0Y8Afx.js → c4Diagram-5PPSVZJV-B9pTjB8U.js} +1 -1
- package/dist/worker/console/static/assets/channel-DtYRMDck.js +1 -0
- package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-D1TxRE3k.js → chunk-2GRJ4B5K-xORV8QsC.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-BE-DHkAO.js → chunk-2Q5K7J3B-BzpYWAHK.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5RXB4S5H-t0iYO8Cc.js → chunk-5RXB4S5H-D8zcRP6c.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5VM5RSS4-Clo2nExi.js → chunk-5VM5RSS4-DVEXxzQJ.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-C7bSpo-3.js → chunk-6Q2QTUOP-CKZOJU2z.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-GF5L2VYU-DorZaymh.js → chunk-GF5L2VYU-Cgx34Dj8.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-JWPE2WC7-Ch_4HvyJ.js → chunk-JWPE2WC7-ehcSKOcx.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-KBJHAD2P-yaSoFe-3.js → chunk-KBJHAD2P-CiY9emCG.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-RYQCIY6F-QpjaXecS.js → chunk-RYQCIY6F-Bk9X-ksQ.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-XXDRQBXY-B3t6cycg.js → chunk-XXDRQBXY-DC0xXfHy.js} +1 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-DyesHbs5.js +1 -0
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-DyesHbs5.js +1 -0
- package/dist/worker/console/static/assets/cose-bilkent-JH36ORCC-C_EVg5l9.js +1 -0
- package/dist/worker/console/static/assets/{cynefin-VYW2F7L2-CP8LtrOl.js → cynefin-VYW2F7L2-BIFL8KrA.js} +1 -1
- package/dist/worker/console/static/assets/cynefinDiagram-MW4NZA55-DjtUYOlE.js +62 -0
- package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-BK0ua9V8.js → dagre-VZM6K2ZE-D2aN2V9t.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-7IWD3JNH-t9-HP13j.js → diagram-7IWD3JNH-D_twhmFi.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-L5Sg9jMD.js → diagram-B4RE2ZJO-ChzncqLV.js} +1 -1
- package/dist/worker/console/static/assets/diagram-LBJQPF4R-B6LO-bF2.js +24 -0
- package/dist/worker/console/static/assets/diagram-Q27KOJAE-GrzM7AFc.js +24 -0
- package/dist/worker/console/static/assets/diagram-UB23O5K3-Bv-lntaq.js +41 -0
- package/dist/worker/console/static/assets/docx-preview-CAbT0VNs.js +23 -0
- package/dist/worker/console/static/assets/docxPreview-D_T4B7qe.js +1 -0
- package/dist/worker/console/static/assets/ebnfDiagram-BXEA7PRR-BvD2jkO_.js +1 -0
- package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-CNOuj3BO.js → erDiagram-JOGREHBK-BirPCcmA.js} +1 -1
- package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-h_Cyayai.js → flowDiagram-UKHOOZJN-Chu1YnGQ.js} +1 -1
- package/dist/worker/console/static/assets/ganttDiagram-PKOTCBZU-Djn17xhB.js +292 -0
- package/dist/worker/console/static/assets/gitGraphDiagram-DS77QQ5N-Bx1qbGHx.js +106 -0
- package/dist/worker/console/static/assets/infoDiagram-6WML65LV-D-TLMqmb.js +2 -0
- package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-DAdf5lHp.js → ishikawaDiagram-WSZJBQD7-DbJoh-6T.js} +1 -1
- package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-BQbGtg66.js → journeyDiagram-NVQOT4AX-DsyokZ6e.js} +1 -1
- package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-CetLubYc.js → kanban-definition-27J2QSJJ-DlzXTxic.js} +1 -1
- package/dist/worker/console/static/assets/{linear-DLZOjaVz.js → linear-ClnZn3vw.js} +1 -1
- package/dist/worker/console/static/assets/main-D-ZQ4gLb.css +1 -0
- package/dist/worker/console/static/assets/main-fc3P1HID.js +645 -0
- package/dist/worker/console/static/assets/{mermaid.core-B_xZl_gM.js → mermaid.core-DqSlcvbf.js} +5 -5
- package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-Dzo3dzp0.js → mindmap-definition-FAOFIHXS-CSFbzpiX.js} +1 -1
- package/dist/worker/console/static/assets/pegDiagram-VL7TDLO6-DK80yQqe.js +1 -0
- package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-Cp3YrVzQ.js → pieDiagram-7S7Q4E2Y-DWX7SFGb.js} +1 -1
- package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-4tI5mUgW.js → quadrantDiagram-CIZ2JOQS-BEPPhtXs.js} +1 -1
- package/dist/worker/console/static/assets/railroadDiagram-AXF67PYL-Ck_s6fQn.js +1 -0
- package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP-DY-0JqdT.js → requirementDiagram-LRYGKXZP-CYig27Rj.js} +1 -1
- package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-DuJIzRKC.js → sankeyDiagram-W5VNT64P-u-0aSx5s.js} +1 -1
- package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-BTbVJ85l.js → sequenceDiagram-SI44F4Z6-NsEJI9sM.js} +1 -1
- package/dist/worker/console/static/assets/{sheet-workbook-BPPh1uLw.js → sheet-workbook-kZ_HK4Sg.js} +2 -2
- package/dist/worker/console/static/assets/sizeCapture-X5ZJPWSS-8vneVM5U.js +1 -0
- package/dist/worker/console/static/assets/stateDiagram-OKZ733FA-CMIobUBh.js +1 -0
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-Bd0pHHKP.js +1 -0
- package/dist/worker/console/static/assets/swimlanes-SLNWSIFB-D4Qzt6ug.js +2 -0
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-BzmSZnl_.js +8 -0
- package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-GR6lxokn.js → timeline-definition-Z64GVDOM-DMb1LpED.js} +1 -1
- package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-DEkwyzsF.js → vennDiagram-T6HMQDX7-C_9eFOs3.js} +1 -1
- package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-W5jnvEJ3.js → wardleyDiagram-T6FBY63Y-DJYMe3uT.js} +1 -1
- package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-cqsloioo.js → xychartDiagram-ELKLHX3M-Cv_1Mi3u.js} +1 -1
- package/dist/worker/console/static/docx-preview.html +25 -0
- package/dist/worker/console/static/index.html +3 -2
- package/dist/worker/console/static/vcp/fonts/README.md +28 -0
- package/dist/worker/console/static/vcp/vendor/vcp-engine-v1.js +4 -4
- package/dist/worker/console/static-src/operator-chat/StateDot.js +17 -0
- package/dist/worker/console/static-src/operator-chat/changed-file-diff.js +15 -0
- package/dist/worker/console/static-src/operator-chat/chat-font-size.js +90 -0
- package/dist/worker/console/static-src/operator-chat/chat-session-order.js +96 -0
- package/dist/worker/console/static-src/operator-chat/chat-sse-events.js +8 -1
- package/dist/worker/console/static-src/operator-chat/compaction-message.js +4 -0
- package/dist/worker/console/static-src/operator-chat/details-rail-surfaces.js +2 -0
- package/dist/worker/console/static-src/operator-chat/file-touch.js +107 -0
- package/dist/worker/console/static-src/operator-chat/format-file-size.js +26 -0
- package/dist/worker/console/static-src/operator-chat/open-preview-in-browser.js +44 -0
- package/dist/worker/console/static-src/operator-chat/reference-display.js +7 -1
- package/dist/worker/console/static-src/operator-chat/tasks-auto-open.js +100 -0
- package/dist/worker/console/static-src/operator-chat/tasks-layout-tween.js +103 -0
- package/dist/worker/console/static-src/operator-chat/tasks-model.js +657 -0
- package/dist/worker/console/static-src/operator-chat/tasks-view-glide.js +96 -0
- package/dist/worker/console/static-src/operator-chat/turn-group-equality.js +1 -0
- package/dist/worker/console/static-src/operator-chat/use-auto-animate.js +61 -0
- package/dist/worker/console/static-src/operator-chat/useChatSessions.js +194 -47
- package/dist/worker/console/static-src/operator-chat/useChatStream.js +4 -0
- package/dist/worker/console/static-src/operator-chat/useChatThread.js +18 -0
- package/dist/worker/console/static-src/operator-chat/useRepoBrowser.js +111 -21
- package/dist/worker/console/static-src/operator-chat/useRuntimeControls.js +91 -47
- package/dist/worker/console/static-src/operator-chat/useVcpPreferences.js +1 -1
- package/dist/worker/console/static-src/operator-chat/user-turn-anchors-merge.js +50 -0
- package/dist/worker/console/static-src/operator-chat/vcp-fonts.js +180 -22
- package/dist/worker/console/static-src/operator-chat/vcp-frame.js +3 -3
- package/dist/worker/console/static-src/shell/console-update-progress.js +16 -0
- package/dist/worker/console/static-src/shell/console-update-reload.js +4 -1
- package/dist/worker/console/static-src/shell/workspace-route.js +0 -2
- package/dist/worker/console/vite.config.js +5 -1
- package/dist/worker/console/workspace-registry.js +62 -19
- package/dist/worker/observe/static/operator-chrome.js +0 -1
- package/dist/worker/scheduler/git-base.js +3 -0
- package/dist/worker/scheduler/night-git-finalizer.js +1 -1
- package/dist/worker/scheduler/night-harvest.js +1 -1
- package/dist/worker/scheduler/prepared-attempt-recovery.js +1 -1
- package/dist/worker/scheduler/scheduled-goal-evidence.js +1 -1
- package/dist/workflows/dag/backend-test-scenario-param.js +60 -4
- package/dist/workflows/dag/dynamic-runtime/reduction.js +7 -2
- package/dist/workflows/dag/frontend-test-framework-adapters.js +11 -2
- package/dist/workflows/script/windows/guest.js +13 -2
- package/dist/workflows/script/windows/native.js +21 -3
- package/docs/architecture/dag-execution.md +2 -13
- package/docs/architecture/facts-and-state.md +2 -3
- package/docs/architecture/runtime-boundaries.md +2 -2
- package/package.json +9 -7
- package/resource-catalog.v1.json +6 -6
- package/scripts/patch-pi-sdk-windows-hide.mjs +3 -3
- package/skills/loop-agent/references/command-reference.md +2 -41
- package/skills/loop-agent/references/harness-policy.md +3 -30
- package/skills/loop-agent/references/long-running-loop.md +6 -54
- package/dist/application/loop/run-action.js +0 -19
- package/dist/commands/dag-workflow-compile.js +0 -93
- package/dist/commands/dag-workflow-plan.js +0 -132
- package/dist/commands/dag-workflow-validate.js +0 -68
- package/dist/commands/loop-benchmark.js +0 -74
- package/dist/commands/loop.js +0 -251
- package/dist/commands/workflow.js +0 -259
- package/dist/infrastructure/harness/loop-store.js +0 -41
- package/dist/worker/console/static/assets/abnfDiagram-N423BO3Z-FQePHM07.js +0 -1
- package/dist/worker/console/static/assets/architectureDiagram-T3A2C74G-p_mwm8cd.js +0 -36
- package/dist/worker/console/static/assets/channel-CIBAg8WF.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-B4xQrSmv.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-B4xQrSmv.js +0 -1
- package/dist/worker/console/static/assets/cose-bilkent-JH36ORCC-BPXf8ZYr.js +0 -1
- package/dist/worker/console/static/assets/cynefinDiagram-MW4NZA55-CNsL9N2-.js +0 -62
- package/dist/worker/console/static/assets/diagram-LBJQPF4R-BipWFRgs.js +0 -24
- package/dist/worker/console/static/assets/diagram-Q27KOJAE-T2p4xa38.js +0 -24
- package/dist/worker/console/static/assets/diagram-UB23O5K3-CVwz6LVu.js +0 -41
- package/dist/worker/console/static/assets/ebnfDiagram-BXEA7PRR-CybQrGSA.js +0 -1
- package/dist/worker/console/static/assets/ganttDiagram-PKOTCBZU-D411_55h.js +0 -292
- package/dist/worker/console/static/assets/gitGraphDiagram-DS77QQ5N-DpVtzs9z.js +0 -106
- package/dist/worker/console/static/assets/index-B7cwOTL9.js +0 -649
- package/dist/worker/console/static/assets/index-CATbSkPc.css +0 -1
- package/dist/worker/console/static/assets/infoDiagram-6WML65LV-D74Uvx6K.js +0 -2
- package/dist/worker/console/static/assets/pegDiagram-VL7TDLO6-CSwoBOpM.js +0 -1
- package/dist/worker/console/static/assets/railroadDiagram-AXF67PYL-n0Mt3Yia.js +0 -1
- package/dist/worker/console/static/assets/sizeCapture-X5ZJPWSS-Dmf1pC7B.js +0 -1
- package/dist/worker/console/static/assets/stateDiagram-OKZ733FA-4-jdPUHD.js +0 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-DojWfYnC.js +0 -1
- package/dist/worker/console/static/assets/swimlanes-SLNWSIFB-DNhjjaAU.js +0 -2
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-CJo4AKWH.js +0 -8
- package/dist/worker/console/static/vcp/fonts/Lanxi-/345/217/257/345/256/213.woff2 +0 -0
- package/dist/worker/console/static/vcp/fonts/Lanxi-/346/234/227/345/256/213.woff2 +0 -0
- package/dist/worker/console/static/vcp/fonts/Lanxi-/350/266/205/347/262/227/351/273/221.woff2 +0 -0
- package/dist/workflows/dynamic/compile.js +0 -371
- package/dist/workflows/dynamic/compileTypes.js +0 -1
- package/dist/workflows/dynamic/errors.js +0 -5
- package/dist/workflows/dynamic/profiles.js +0 -156
- package/dist/workflows/dynamic/spec.js +0 -115
- package/dist/workflows/dynamic/validate.js +0 -275
- package/dist/workflows/loop/actions/dag-action.js +0 -129
- package/dist/workflows/loop/actions/pi-review.js +0 -267
- package/dist/workflows/loop/actions/shared.js +0 -157
- package/dist/workflows/loop/actions/shell-verify.js +0 -82
- package/dist/workflows/loop/actions/types.js +0 -1
- package/dist/workflows/loop/actions/workflow-action.js +0 -255
- package/dist/workflows/loop/actions.js +0 -160
- package/dist/workflows/loop/benchmark.js +0 -513
- package/dist/workflows/loop/closeout.js +0 -135
- package/dist/workflows/loop/context.js +0 -47
- package/dist/workflows/loop/events.js +0 -26
- package/dist/workflows/loop/hash.js +0 -32
- package/dist/workflows/loop/index.js +0 -8
- package/dist/workflows/loop/paths.js +0 -17
- package/dist/workflows/loop/policy/auto-policy.js +0 -112
- package/dist/workflows/loop/policy/path-patterns.js +0 -13
- package/dist/workflows/loop/rounds.js +0 -81
- package/dist/workflows/loop/signals.js +0 -52
- package/dist/workflows/loop/state.js +0 -116
- package/dist/workflows/loop/templates.js +0 -54
- package/dist/workflows/loop/types.js +0 -28
- /package/dist/workflows/{dynamic/artifacts.js → dag/dynamic-runtime/reduction-artifacts.js} +0 -0
|
@@ -51,6 +51,11 @@ export function isPdfPreviewLanguage(language) {
|
|
|
51
51
|
export function isSheetPreviewLanguage(language) {
|
|
52
52
|
return ["xlsx", "xls", "csv", "tsv"].includes(normalizedLanguage(language));
|
|
53
53
|
}
|
|
54
|
+
/** Word documents rendered by the in-browser docx renderer. `.doc` is the
|
|
55
|
+
* legacy binary format and has no renderer. */
|
|
56
|
+
export function isDocxPreviewLanguage(language) {
|
|
57
|
+
return normalizedLanguage(language) === "docx";
|
|
58
|
+
}
|
|
54
59
|
export function isBinarySheetLanguage(language) {
|
|
55
60
|
return ["xlsx", "xls"].includes(normalizedLanguage(language));
|
|
56
61
|
}
|
|
@@ -72,6 +77,7 @@ export function isKindBinaryPreview(preview) {
|
|
|
72
77
|
return (preview.kind === "image" ||
|
|
73
78
|
preview.kind === "unsupported" ||
|
|
74
79
|
preview.kind === "pdf" ||
|
|
80
|
+
preview.kind === "docx" ||
|
|
75
81
|
(preview.kind === "sheet" && isBinarySheetLanguage(preview.language)));
|
|
76
82
|
}
|
|
77
83
|
function isSvgLanguage(language) {
|
|
@@ -330,6 +336,11 @@ function previewPane(preview, sheets) {
|
|
|
330
336
|
if (preview.kind === "pdf" && preview.previewUrl) {
|
|
331
337
|
return `<div class="frame"><iframe class="page" title="${escapeHtml(preview.path)}" src="${escapeHtml(preview.previewUrl)}"></iframe></div>`;
|
|
332
338
|
}
|
|
339
|
+
if (preview.kind === "docx") {
|
|
340
|
+
// The detached reader page renders the pages itself; a raw ``.docx`` byte
|
|
341
|
+
// response in an iframe would just download.
|
|
342
|
+
return `<article class="doc"><p class="unsupported">此文件已在独立窗口中打开。</p></article>`;
|
|
343
|
+
}
|
|
333
344
|
if (preview.kind === "sheet")
|
|
334
345
|
return sheetPreviewPane(preview, sheets);
|
|
335
346
|
if (preview.kind === "image" && preview.previewUrl) {
|
|
@@ -434,6 +445,36 @@ ${readingPageScript()}
|
|
|
434
445
|
</body>
|
|
435
446
|
</html>`;
|
|
436
447
|
}
|
|
448
|
+
/** Origin of the running Console. `ChatWorkspace` passes `origin: ""`, so a
|
|
449
|
+
* preview URL can be a bare path; resolving it against a hardcoded host would
|
|
450
|
+
* drop the real port. */
|
|
451
|
+
function consoleOrigin() {
|
|
452
|
+
const location = globalThis.location;
|
|
453
|
+
if (location?.origin && location.origin !== "null")
|
|
454
|
+
return location.origin;
|
|
455
|
+
if (location?.href) {
|
|
456
|
+
try {
|
|
457
|
+
return new URL(location.href).origin;
|
|
458
|
+
}
|
|
459
|
+
catch {
|
|
460
|
+
/* fall through to the test fallback */
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
return "http://localhost";
|
|
464
|
+
}
|
|
465
|
+
/** Detached Word reader page: it fetches the workspace byte route named by
|
|
466
|
+
* `url` and renders the pages in its own document, so the detached window
|
|
467
|
+
* keeps selectable text instead of a raw `.docx` download. */
|
|
468
|
+
export function docxReaderUrl(previewUrl, path) {
|
|
469
|
+
// An absolute preview URL already carries the right host; a bare path is
|
|
470
|
+
// resolved against the live Console origin so the reader page and the byte
|
|
471
|
+
// route stay on the same port.
|
|
472
|
+
const absolute = /^[a-z][a-z0-9+.-]*:\/\//i.test(previewUrl)
|
|
473
|
+
? previewUrl
|
|
474
|
+
: new URL(previewUrl, consoleOrigin()).toString();
|
|
475
|
+
const reader = new URL("/docx-preview.html", absolute).toString();
|
|
476
|
+
return `${reader}?url=${encodeURIComponent(absolute)}&path=${encodeURIComponent(path)}`;
|
|
477
|
+
}
|
|
437
478
|
function screenAvail() {
|
|
438
479
|
const screen = globalThis.screen;
|
|
439
480
|
return {
|
|
@@ -474,6 +515,9 @@ export function openPreviewInBrowser(preview, host = defaultHost(), features = p
|
|
|
474
515
|
preview.previewUrl) {
|
|
475
516
|
targetUrl = preview.previewUrl;
|
|
476
517
|
}
|
|
518
|
+
else if (preview.kind === "docx" && preview.previewUrl) {
|
|
519
|
+
targetUrl = docxReaderUrl(preview.previewUrl, preview.path);
|
|
520
|
+
}
|
|
477
521
|
if (!targetUrl) {
|
|
478
522
|
const documentHtml = buildPreviewBrowserDocument(preview, sheets);
|
|
479
523
|
const blob = new Blob([documentHtml], { type: "text/html;charset=utf-8" });
|
|
@@ -12,6 +12,7 @@ export function referenceTag(source) {
|
|
|
12
12
|
case "file": return source.view === "sheet" ? "表格" : source.view === "html" ? "HTML" : "文件";
|
|
13
13
|
case "diff": return "差异";
|
|
14
14
|
case "message": return "消息";
|
|
15
|
+
case "api": return "API";
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
18
|
export function referenceMeta(source) {
|
|
@@ -31,8 +32,13 @@ export function referenceMeta(source) {
|
|
|
31
32
|
return "对话中的一段文字";
|
|
32
33
|
case "terminal":
|
|
33
34
|
return "终端选文";
|
|
35
|
+
case "api":
|
|
36
|
+
return `${source.method} ${truncateUrlForMeta(source.url)}`;
|
|
34
37
|
}
|
|
35
38
|
}
|
|
39
|
+
function truncateUrlForMeta(url) {
|
|
40
|
+
return url.length > 64 ? `${url.slice(0, 61)}…` : url;
|
|
41
|
+
}
|
|
36
42
|
export function referenceMetaTitle(source) {
|
|
37
|
-
return source.kind === "browser" ? source.url : referenceMeta(source);
|
|
43
|
+
return source.kind === "browser" || source.kind === "api" ? source.url : referenceMeta(source);
|
|
38
44
|
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-open triggers for the Tasks surface — the Loop twin of DSH's
|
|
3
|
+
* "auto-open on subagent / background job" behaviour.
|
|
4
|
+
*
|
|
5
|
+
* DSH turns this on by default (`autoOpenSubagent`, `autoOpenJobs` in
|
|
6
|
+
* `prefs-shared.ts`), decides it from a session-list snapshot, and parks the
|
|
7
|
+
* column instead of taking the viewport over on a narrow screen
|
|
8
|
+
* (`use-host-feeds.ts`). The decisions themselves are pure, so they live here
|
|
9
|
+
* and the component only wires them to state.
|
|
10
|
+
*
|
|
11
|
+
* Two rules are copied verbatim because they are what make the feature
|
|
12
|
+
* bearable rather than nagging:
|
|
13
|
+
*
|
|
14
|
+
* 1. **0 → N only.** A session that ALREADY has subagents, opened for the
|
|
15
|
+
* first time, must not pop the rail — the reader came to read the chat, and
|
|
16
|
+
* the baseline starts at the current count. Same for jobs: the first
|
|
17
|
+
* observation only arms the baseline.
|
|
18
|
+
* 2. **An open rail is never redirected.** If the reader is already looking at
|
|
19
|
+
* some tab, background work must not steal it. Only a rail that was CLOSED
|
|
20
|
+
* gets opened.
|
|
21
|
+
*/
|
|
22
|
+
const PREF_KEY = "loop-console.tasks-auto-open.v1";
|
|
23
|
+
export const DEFAULT_TASKS_AUTO_OPEN_PREFS = {
|
|
24
|
+
// DSH ships both triggers ON.
|
|
25
|
+
subagent: true,
|
|
26
|
+
jobs: true,
|
|
27
|
+
mobileOff: true,
|
|
28
|
+
};
|
|
29
|
+
/** Read the stored prefs, falling back to the DSH defaults. */
|
|
30
|
+
export function readTasksAutoOpenPrefs() {
|
|
31
|
+
if (typeof window === "undefined")
|
|
32
|
+
return DEFAULT_TASKS_AUTO_OPEN_PREFS;
|
|
33
|
+
try {
|
|
34
|
+
const raw = window.localStorage.getItem(PREF_KEY);
|
|
35
|
+
if (!raw)
|
|
36
|
+
return DEFAULT_TASKS_AUTO_OPEN_PREFS;
|
|
37
|
+
const parsed = JSON.parse(raw);
|
|
38
|
+
return {
|
|
39
|
+
subagent: typeof parsed.subagent === "boolean" ? parsed.subagent : DEFAULT_TASKS_AUTO_OPEN_PREFS.subagent,
|
|
40
|
+
jobs: typeof parsed.jobs === "boolean" ? parsed.jobs : DEFAULT_TASKS_AUTO_OPEN_PREFS.jobs,
|
|
41
|
+
mobileOff: typeof parsed.mobileOff === "boolean" ? parsed.mobileOff : DEFAULT_TASKS_AUTO_OPEN_PREFS.mobileOff,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return DEFAULT_TASKS_AUTO_OPEN_PREFS;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export function writeTasksAutoOpenPrefs(prefs) {
|
|
49
|
+
if (typeof window === "undefined")
|
|
50
|
+
return;
|
|
51
|
+
try {
|
|
52
|
+
window.localStorage.setItem(PREF_KEY, JSON.stringify(prefs));
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
/* A blocked storage must not break the chat. */
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/** DSH's narrow breakpoint: below this the right column covers the chat. */
|
|
59
|
+
export const TASKS_AUTO_OPEN_NARROW_WIDTH = 768;
|
|
60
|
+
export function isNarrowViewport(width) {
|
|
61
|
+
return width < TASKS_AUTO_OPEN_NARROW_WIDTH;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Did a NEW subagent appear in this session between two counts?
|
|
65
|
+
*
|
|
66
|
+
* `null` means "no baseline yet" (the first observation of a session), which
|
|
67
|
+
* arms the baseline without opening anything.
|
|
68
|
+
*/
|
|
69
|
+
export function detectNewSubagent(previousCount, nextCount) {
|
|
70
|
+
if (previousCount === null)
|
|
71
|
+
return false;
|
|
72
|
+
return previousCount === 0 && nextCount > 0;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Did a NEW background job appear?
|
|
76
|
+
*
|
|
77
|
+
* Unlike the subagent rule this fires on ANY increase, because an agent may
|
|
78
|
+
* start several jobs in one conversation and each deserves to surface (DSH's
|
|
79
|
+
* `detectNewJob` makes the same distinction). A decrease never fires.
|
|
80
|
+
*/
|
|
81
|
+
export function detectNewJob(previousCount, nextCount) {
|
|
82
|
+
if (previousCount === null)
|
|
83
|
+
return false;
|
|
84
|
+
return nextCount > previousCount;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Whether a background trigger should actually open the rail.
|
|
88
|
+
*
|
|
89
|
+
* Kept separate from the detection helpers so the "never steal an open rail"
|
|
90
|
+
* rule lives in ONE place: a trigger decides WHETHER work appeared, this decides
|
|
91
|
+
* whether acting on it is polite.
|
|
92
|
+
*/
|
|
93
|
+
export function shouldAutoOpen(input) {
|
|
94
|
+
if (!input.prefs[input.kind])
|
|
95
|
+
return false;
|
|
96
|
+
if (input.prefs.mobileOff && isNarrowViewport(input.viewportWidth))
|
|
97
|
+
return false;
|
|
98
|
+
// An open rail belongs to the reader: never redirect it.
|
|
99
|
+
return !input.detailsOpen;
|
|
100
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
import { taskEdgePath } from "./tasks-model.js";
|
|
3
|
+
export const TASKS_LAYOUT_TWEEN_MS = 220;
|
|
4
|
+
function easeOut(progress) {
|
|
5
|
+
const t = Math.min(1, Math.max(0, progress));
|
|
6
|
+
return 1 - (1 - t) ** 3;
|
|
7
|
+
}
|
|
8
|
+
function prefersReducedMotion() {
|
|
9
|
+
return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
10
|
+
}
|
|
11
|
+
function mix(a, b, progress) {
|
|
12
|
+
return a + (b - a) * progress;
|
|
13
|
+
}
|
|
14
|
+
function tweenNode(from, to, progress) {
|
|
15
|
+
if (!from)
|
|
16
|
+
return to;
|
|
17
|
+
return {
|
|
18
|
+
...to,
|
|
19
|
+
x: mix(from.x, to.x, progress),
|
|
20
|
+
y: mix(from.y, to.y, progress),
|
|
21
|
+
width: mix(from.width, to.width, progress),
|
|
22
|
+
height: mix(from.height, to.height, progress),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function tweenEdge(from, to, progress, fromNodes, toNodes) {
|
|
26
|
+
const fromStart = fromNodes.get(to.from) ?? toNodes.get(to.from);
|
|
27
|
+
const fromEnd = fromNodes.get(to.to) ?? toNodes.get(to.to);
|
|
28
|
+
const toStart = toNodes.get(to.from);
|
|
29
|
+
const toEnd = toNodes.get(to.to);
|
|
30
|
+
if (!from || !fromStart || !fromEnd || !toStart || !toEnd)
|
|
31
|
+
return to;
|
|
32
|
+
/*
|
|
33
|
+
* Rebuild the path through the SHARED constructor, not a local formula.
|
|
34
|
+
*
|
|
35
|
+
* This function used to interpolate its own single cubic, which silently
|
|
36
|
+
* replaced whatever `taskEdgePath` produced on every animation frame: the
|
|
37
|
+
* model's routing (the stubs, and the gutter detour for a deep child) never
|
|
38
|
+
* reached the screen, so a fix in the model looked like a no-op in the
|
|
39
|
+
* browser even though its unit test passed.
|
|
40
|
+
*
|
|
41
|
+
* The two endpoints are interpolated and the path is rebuilt from those
|
|
42
|
+
* drawn boxes, so the connector stays glued to the cards while they move.
|
|
43
|
+
*/
|
|
44
|
+
const drawnFrom = {
|
|
45
|
+
...toStart,
|
|
46
|
+
x: mix(fromStart.x, toStart.x, progress),
|
|
47
|
+
y: mix(fromStart.y, toStart.y, progress),
|
|
48
|
+
width: mix(fromStart.width, toStart.width, progress),
|
|
49
|
+
height: mix(fromStart.height, toStart.height, progress),
|
|
50
|
+
};
|
|
51
|
+
const drawnTo = {
|
|
52
|
+
...toEnd,
|
|
53
|
+
x: mix(fromEnd.x, toEnd.x, progress),
|
|
54
|
+
y: mix(fromEnd.y, toEnd.y, progress),
|
|
55
|
+
width: mix(fromEnd.width, toEnd.width, progress),
|
|
56
|
+
height: mix(fromEnd.height, toEnd.height, progress),
|
|
57
|
+
};
|
|
58
|
+
const boxes = [...toNodes.values()].map((node) => node.id === toStart.id ? drawnFrom : node.id === toEnd.id ? drawnTo : node);
|
|
59
|
+
return { ...to, path: taskEdgePath(drawnFrom, drawnTo, boxes) };
|
|
60
|
+
}
|
|
61
|
+
function tweenFrame(from, to, progress) {
|
|
62
|
+
if (!from)
|
|
63
|
+
return to;
|
|
64
|
+
return {
|
|
65
|
+
...to,
|
|
66
|
+
x: mix(from.x, to.x, progress),
|
|
67
|
+
y: mix(from.y, to.y, progress),
|
|
68
|
+
width: mix(from.width, to.width, progress),
|
|
69
|
+
height: mix(from.height, to.height, progress),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export function useTweenedTasksLayout(layout) {
|
|
73
|
+
const drawnRef = useRef(undefined);
|
|
74
|
+
const [drawn, setDrawn] = useState(layout);
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
const previous = drawnRef.current;
|
|
77
|
+
if (!previous || prefersReducedMotion()) {
|
|
78
|
+
drawnRef.current = layout;
|
|
79
|
+
setDrawn(layout);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const previousNodes = new Map(previous.nodes.map((node) => [node.id, node]));
|
|
83
|
+
const currentNodes = new Map(layout.nodes.map((node) => [node.id, node]));
|
|
84
|
+
const previousFrames = new Map(previous.phaseFrames.map((frame) => [frame.id, frame]));
|
|
85
|
+
const previousEdges = new Map(previous.edges.map((edge) => [edge.id, edge]));
|
|
86
|
+
const started = performance.now();
|
|
87
|
+
let raf = 0;
|
|
88
|
+
const frame = () => {
|
|
89
|
+
const progress = easeOut((performance.now() - started) / TASKS_LAYOUT_TWEEN_MS);
|
|
90
|
+
const nodes = layout.nodes.map((node) => tweenNode(previousNodes.get(node.id), node, progress));
|
|
91
|
+
const phaseFrames = layout.phaseFrames.map((item) => tweenFrame(previousFrames.get(item.id), item, progress));
|
|
92
|
+
const edges = layout.edges.map((edge) => tweenEdge(previousEdges.get(edge.id), edge, progress, previousNodes, currentNodes));
|
|
93
|
+
const next = { ...layout, nodes, phaseFrames, edges };
|
|
94
|
+
drawnRef.current = next;
|
|
95
|
+
setDrawn(next);
|
|
96
|
+
if (progress < 1)
|
|
97
|
+
raf = requestAnimationFrame(frame);
|
|
98
|
+
};
|
|
99
|
+
raf = requestAnimationFrame(frame);
|
|
100
|
+
return () => cancelAnimationFrame(raf);
|
|
101
|
+
}, [layout]);
|
|
102
|
+
return drawn;
|
|
103
|
+
}
|