@tea-agent/loop-agent 0.51.0 → 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 +123 -5
- 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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{s as xi,g as di,o as Yt,n as fi,a as pi,b as mi,_ as n,l as Nt,D as yi,e as bi,p as Ai,y as kt,i as wi,A as Ht,B as Ci,E as Si,az as Ri,P as Ot}from"./mermaid.core-
|
|
1
|
+
import{s as xi,g as di,o as Yt,n as fi,a as pi,b as mi,_ as n,l as Nt,D as yi,e as bi,p as Ai,y as kt,i as wi,A as Ht,B as Ci,E as Si,az as Ri,P as Ot}from"./mermaid.core-DqSlcvbf.js";import{i as _i}from"./init-Gi6I4Gst.js";import{o as ki}from"./ordinal-Cboi1Yqb.js";import{l as Wt}from"./linear-ClnZn3vw.js";import"./FilePreviewDocx-ybM3ZqSl.js";import"./defaultLocale-DX6XiGOO.js";function Ti(e,t,i){e=+e,t=+t,i=(a=arguments.length)<2?(t=e,e=0,1):a<3?1:+i;for(var s=-1,a=Math.max(0,Math.ceil((t-e)/i))|0,o=new Array(a);++s<a;)o[s]=e+s*i;return o}function wt(){var e=ki().unknown(void 0),t=e.domain,i=e.range,s=0,a=1,o,l,p=!1,d=0,k=0,T=.5;delete e.unknown;function _(){var b=t().length,E=a<s,L=E?a:s,P=E?s:a;o=(P-L)/Math.max(1,b-d+k*2),p&&(o=Math.floor(o)),L+=(P-L-o*(b-d))*T,l=o*(1-d),p&&(L=Math.round(L),l=Math.round(l));var I=Ti(b).map(function(m){return L+o*m});return i(E?I.reverse():I)}return e.domain=function(b){return arguments.length?(t(b),_()):t()},e.range=function(b){return arguments.length?([s,a]=b,s=+s,a=+a,_()):[s,a]},e.rangeRound=function(b){return[s,a]=b,s=+s,a=+a,p=!0,_()},e.bandwidth=function(){return l},e.step=function(){return o},e.round=function(b){return arguments.length?(p=!!b,_()):p},e.padding=function(b){return arguments.length?(d=Math.min(1,k=+b),_()):d},e.paddingInner=function(b){return arguments.length?(d=Math.min(1,b),_()):d},e.paddingOuter=function(b){return arguments.length?(k=+b,_()):k},e.align=function(b){return arguments.length?(T=Math.max(0,Math.min(1,b)),_()):T},e.copy=function(){return wt(t(),[s,a]).round(p).paddingInner(d).paddingOuter(k).align(T)},_i.apply(_(),arguments)}var Ct=(function(){var e=n(function(F,h,u,g){for(u=u||{},g=F.length;g--;u[F[g]]=h);return u},"o"),t=[1,10,12,14,16,18,19,21,23],i=[2,6],s=[1,3],a=[1,5],o=[1,6],l=[1,7],p=[1,5,10,12,14,16,18,19,21,23,36,37,38],d=[1,25],k=[1,26],T=[1,28],_=[1,29],b=[1,30],E=[1,31],L=[1,32],P=[1,33],I=[1,34],m=[1,35],D=[1,36],c=[1,37],B=[1,43],W=[1,42],X=[1,47],Y=[1,50],S=[1,10,12,14,16,18,19,21,23,36,37,38],H=[1,10,12,14,16,18,19,21,23,24,26,28,29,36,37,38],A=[1,10,12,14,16,18,19,21,23,24,26,28,29,36,37,38,42,43,44,45,46,47,48,49,50,51],w=[1,65],V=[26,28],R={trace:n(function(){},"trace"),yy:{},symbols_:{error:2,start:3,eol:4,XYCHART:5,chartConfig:6,document:7,CHART_ORIENTATION:8,statement:9,title:10,text:11,X_AXIS:12,parseXAxis:13,Y_AXIS:14,parseYAxis:15,LINE:16,plotData:17,BAR:18,acc_title:19,acc_title_value:20,acc_descr:21,acc_descr_value:22,acc_descr_multiline_value:23,SQUARE_BRACES_START:24,dataPoints:25,SQUARE_BRACES_END:26,dataPoint:27,COMMA:28,NUMBER_WITH_DECIMAL:29,STR:30,xAxisData:31,bandData:32,ARROW_DELIMITER:33,commaSeparatedTexts:34,yAxisData:35,NEWLINE:36,SEMI:37,EOF:38,alphaNum:39,MD_STR:40,alphaNumToken:41,AMP:42,NUM:43,ALPHA:44,PLUS:45,EQUALS:46,MULT:47,DOT:48,BRKT:49,MINUS:50,UNDERSCORE:51,$accept:0,$end:1},terminals_:{2:"error",5:"XYCHART",8:"CHART_ORIENTATION",10:"title",12:"X_AXIS",14:"Y_AXIS",16:"LINE",18:"BAR",19:"acc_title",20:"acc_title_value",21:"acc_descr",22:"acc_descr_value",23:"acc_descr_multiline_value",24:"SQUARE_BRACES_START",26:"SQUARE_BRACES_END",28:"COMMA",29:"NUMBER_WITH_DECIMAL",30:"STR",33:"ARROW_DELIMITER",36:"NEWLINE",37:"SEMI",38:"EOF",40:"MD_STR",42:"AMP",43:"NUM",44:"ALPHA",45:"PLUS",46:"EQUALS",47:"MULT",48:"DOT",49:"BRKT",50:"MINUS",51:"UNDERSCORE"},productions_:[0,[3,2],[3,3],[3,2],[3,1],[6,1],[7,0],[7,2],[9,2],[9,2],[9,2],[9,2],[9,2],[9,3],[9,2],[9,3],[9,2],[9,2],[9,1],[17,3],[25,3],[25,1],[27,2],[27,1],[13,1],[13,2],[13,1],[31,1],[31,3],[32,3],[34,3],[34,1],[15,1],[15,2],[15,1],[35,3],[4,1],[4,1],[4,1],[11,1],[11,1],[11,1],[39,1],[39,2],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1]],performAction:n(function(h,u,g,x,C,r,rt){var f=r.length-1;switch(C){case 5:x.setOrientation(r[f]);break;case 9:x.setDiagramTitle(r[f].text.trim());break;case 12:x.setLineData({text:"",type:"text"},r[f]);break;case 13:x.setLineData(r[f-1],r[f]);break;case 14:x.setBarData({text:"",type:"text"},r[f]);break;case 15:x.setBarData(r[f-1],r[f]);break;case 16:this.$=r[f].trim(),x.setAccTitle(this.$);break;case 17:case 18:this.$=r[f].trim(),x.setAccDescription(this.$);break;case 19:this.$=r[f-1];break;case 20:case 30:this.$=[r[f-2],...r[f]];break;case 21:case 31:this.$=[r[f]];break;case 22:this.$={value:Number(r[f-1]),label:r[f]};break;case 23:this.$={value:Number(r[f]),label:""};break;case 24:x.setXAxisTitle(r[f]);break;case 25:x.setXAxisTitle(r[f-1]);break;case 26:x.setXAxisTitle({type:"text",text:""});break;case 27:x.setXAxisBand(r[f]);break;case 28:x.setXAxisRangeData(Number(r[f-2]),Number(r[f]));break;case 29:this.$=r[f-1];break;case 32:x.setYAxisTitle(r[f]);break;case 33:x.setYAxisTitle(r[f-1]);break;case 34:x.setYAxisTitle({type:"text",text:""});break;case 35:x.setYAxisRangeData(Number(r[f-2]),Number(r[f]));break;case 39:this.$={text:r[f],type:"text"};break;case 40:this.$={text:r[f],type:"text"};break;case 41:this.$={text:r[f],type:"markdown"};break;case 42:this.$=r[f];break;case 43:this.$=r[f-1]+""+r[f];break}},"anonymous"),table:[e(t,i,{3:1,4:2,7:4,5:s,36:a,37:o,38:l}),{1:[3]},e(t,i,{4:2,7:4,3:8,5:s,36:a,37:o,38:l}),e(t,i,{4:2,7:4,6:9,3:10,5:s,8:[1,11],36:a,37:o,38:l}),{1:[2,4],9:12,10:[1,13],12:[1,14],14:[1,15],16:[1,16],18:[1,17],19:[1,18],21:[1,19],23:[1,20]},e(p,[2,36]),e(p,[2,37]),e(p,[2,38]),{1:[2,1]},e(t,i,{4:2,7:4,3:21,5:s,36:a,37:o,38:l}),{1:[2,3]},e(p,[2,5]),e(t,[2,7],{4:22,36:a,37:o,38:l}),{11:23,30:d,39:24,40:k,41:27,42:T,43:_,44:b,45:E,46:L,47:P,48:I,49:m,50:D,51:c},{11:39,13:38,24:B,29:W,30:d,31:40,32:41,39:24,40:k,41:27,42:T,43:_,44:b,45:E,46:L,47:P,48:I,49:m,50:D,51:c},{11:45,15:44,29:X,30:d,35:46,39:24,40:k,41:27,42:T,43:_,44:b,45:E,46:L,47:P,48:I,49:m,50:D,51:c},{11:49,17:48,24:Y,30:d,39:24,40:k,41:27,42:T,43:_,44:b,45:E,46:L,47:P,48:I,49:m,50:D,51:c},{11:52,17:51,24:Y,30:d,39:24,40:k,41:27,42:T,43:_,44:b,45:E,46:L,47:P,48:I,49:m,50:D,51:c},{20:[1,53]},{22:[1,54]},e(S,[2,18]),{1:[2,2]},e(S,[2,8]),e(S,[2,9]),e(H,[2,39],{41:55,42:T,43:_,44:b,45:E,46:L,47:P,48:I,49:m,50:D,51:c}),e(H,[2,40]),e(H,[2,41]),e(A,[2,42]),e(A,[2,44]),e(A,[2,45]),e(A,[2,46]),e(A,[2,47]),e(A,[2,48]),e(A,[2,49]),e(A,[2,50]),e(A,[2,51]),e(A,[2,52]),e(A,[2,53]),e(S,[2,10]),e(S,[2,24],{32:41,31:56,24:B,29:W}),e(S,[2,26]),e(S,[2,27]),{33:[1,57]},{11:59,30:d,34:58,39:24,40:k,41:27,42:T,43:_,44:b,45:E,46:L,47:P,48:I,49:m,50:D,51:c},e(S,[2,11]),e(S,[2,32],{35:60,29:X}),e(S,[2,34]),{33:[1,61]},e(S,[2,12]),{17:62,24:Y},{25:63,27:64,29:w},e(S,[2,14]),{17:66,24:Y},e(S,[2,16]),e(S,[2,17]),e(A,[2,43]),e(S,[2,25]),{29:[1,67]},{26:[1,68]},{26:[2,31],28:[1,69]},e(S,[2,33]),{29:[1,70]},e(S,[2,13]),{26:[1,71]},{26:[2,21],28:[1,72]},e(V,[2,23],{30:[1,73]}),e(S,[2,15]),e(S,[2,28]),e(S,[2,29]),{11:59,30:d,34:74,39:24,40:k,41:27,42:T,43:_,44:b,45:E,46:L,47:P,48:I,49:m,50:D,51:c},e(S,[2,35]),e(S,[2,19]),{25:75,27:64,29:w},e(V,[2,22]),{26:[2,30]},{26:[2,20]}],defaultActions:{8:[2,1],10:[2,3],21:[2,2],74:[2,30],75:[2,20]},parseError:n(function(h,u){if(u.recoverable)this.trace(h);else{var g=new Error(h);throw g.hash=u,g}},"parseError"),parse:n(function(h){var u=this,g=[0],x=[],C=[null],r=[],rt=this.table,f="",gt=0,Mt=0,li=2,zt=1,ci=r.slice.call(arguments,1),v=Object.create(this.lexer),$={yy:{}};for(var mt in this.yy)Object.prototype.hasOwnProperty.call(this.yy,mt)&&($.yy[mt]=this.yy[mt]);v.setInput(h,$.yy),$.yy.lexer=v,$.yy.parser=this,typeof v.yylloc>"u"&&(v.yylloc={});var yt=v.yylloc;r.push(yt);var ui=v.options&&v.options.ranges;typeof $.yy.parseError=="function"?this.parseError=$.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function gi(z){g.length=g.length-2*z,C.length=C.length-z,r.length=r.length-z}n(gi,"popStack");function Bt(){var z;return z=x.pop()||v.lex()||zt,typeof z!="number"&&(z instanceof Array&&(x=z,z=x.pop()),z=u.symbols_[z]||z),z}n(Bt,"lex");for(var M,U,O,bt,G={},xt,N,Vt,dt;;){if(U=g[g.length-1],this.defaultActions[U]?O=this.defaultActions[U]:((M===null||typeof M>"u")&&(M=Bt()),O=rt[U]&&rt[U][M]),typeof O>"u"||!O.length||!O[0]){var At="";dt=[];for(xt in rt[U])this.terminals_[xt]&&xt>li&&dt.push("'"+this.terminals_[xt]+"'");v.showPosition?At="Parse error on line "+(gt+1)+`:
|
|
2
2
|
`+v.showPosition()+`
|
|
3
3
|
Expecting `+dt.join(", ")+", got '"+(this.terminals_[M]||M)+"'":At="Parse error on line "+(gt+1)+": Unexpected "+(M==zt?"end of input":"'"+(this.terminals_[M]||M)+"'"),this.parseError(At,{text:v.match,token:this.terminals_[M]||M,line:v.yylineno,loc:yt,expected:dt})}if(O[0]instanceof Array&&O.length>1)throw new Error("Parse Error: multiple actions possible at state: "+U+", token: "+M);switch(O[0]){case 1:g.push(M),C.push(v.yytext),r.push(v.yylloc),g.push(O[1]),M=null,Mt=v.yyleng,f=v.yytext,gt=v.yylineno,yt=v.yylloc;break;case 2:if(N=this.productions_[O[1]][1],G.$=C[C.length-N],G._$={first_line:r[r.length-(N||1)].first_line,last_line:r[r.length-1].last_line,first_column:r[r.length-(N||1)].first_column,last_column:r[r.length-1].last_column},ui&&(G._$.range=[r[r.length-(N||1)].range[0],r[r.length-1].range[1]]),bt=this.performAction.apply(G,[f,Mt,gt,$.yy,O[1],C,r].concat(ci)),typeof bt<"u")return bt;N&&(g=g.slice(0,-1*N*2),C=C.slice(0,-1*N),r=r.slice(0,-1*N)),g.push(this.productions_[O[1]][0]),C.push(G.$),r.push(G._$),Vt=rt[g[g.length-2]][g[g.length-1]],g.push(Vt);break;case 3:return!0}}return!0},"parse")},ot=(function(){var F={EOF:1,parseError:n(function(u,g){if(this.yy.parser)this.yy.parser.parseError(u,g);else throw new Error(u)},"parseError"),setInput:n(function(h,u){return this.yy=u||this.yy||{},this._input=h,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:n(function(){var h=this._input[0];this.yytext+=h,this.yyleng++,this.offset++,this.match+=h,this.matched+=h;var u=h.match(/(?:\r\n?|\n).*/g);return u?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),h},"input"),unput:n(function(h){var u=h.length,g=h.split(/(?:\r\n?|\n)/g);this._input=h+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-u),this.offset-=u;var x=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),g.length-1&&(this.yylineno-=g.length-1);var C=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:g?(g.length===x.length?this.yylloc.first_column:0)+x[x.length-g.length].length-g[0].length:this.yylloc.first_column-u},this.options.ranges&&(this.yylloc.range=[C[0],C[0]+this.yyleng-u]),this.yyleng=this.yytext.length,this},"unput"),more:n(function(){return this._more=!0,this},"more"),reject:n(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
|
|
4
4
|
`+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:n(function(h){this.unput(this.match.slice(h))},"less"),pastInput:n(function(){var h=this.matched.substr(0,this.matched.length-this.match.length);return(h.length>20?"...":"")+h.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:n(function(){var h=this.match;return h.length<20&&(h+=this._input.substr(0,20-h.length)),(h.substr(0,20)+(h.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:n(function(){var h=this.pastInput(),u=new Array(h.length+1).join("-");return h+this.upcomingInput()+`
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
|
|
6
|
+
<title>Word 文档预览 · Loop 操作台</title>
|
|
7
|
+
<style>
|
|
8
|
+
html, body { margin: 0; height: 100%; background: #eef1f5; }
|
|
9
|
+
#root { height: 100%; }
|
|
10
|
+
#root[role="alert"] {
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
padding: 24px;
|
|
15
|
+
color: #b91c1c;
|
|
16
|
+
font: 14px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
17
|
+
}
|
|
18
|
+
</style>
|
|
19
|
+
<script type="module" crossorigin src="/assets/docxPreview-D_T4B7qe.js"></script>
|
|
20
|
+
<link rel="modulepreload" crossorigin href="/assets/FilePreviewDocx-ybM3ZqSl.js">
|
|
21
|
+
</head>
|
|
22
|
+
<body>
|
|
23
|
+
<div id="root"></div>
|
|
24
|
+
</body>
|
|
25
|
+
</html>
|
|
@@ -10,8 +10,9 @@
|
|
|
10
10
|
<link rel="stylesheet" href="/inspect/vendor/remixicon/remixicon.css" />
|
|
11
11
|
<link rel="stylesheet" href="/inspect/operator-chrome.css" />
|
|
12
12
|
<title>Loop 操作台 · Operator Console</title>
|
|
13
|
-
<script type="module" crossorigin src="/assets/
|
|
14
|
-
<link rel="
|
|
13
|
+
<script type="module" crossorigin src="/assets/main-fc3P1HID.js"></script>
|
|
14
|
+
<link rel="modulepreload" crossorigin href="/assets/FilePreviewDocx-ybM3ZqSl.js">
|
|
15
|
+
<link rel="stylesheet" crossorigin href="/assets/main-D-ZQ4gLb.css">
|
|
15
16
|
</head>
|
|
16
17
|
<body>
|
|
17
18
|
<div id="root"></div>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# VCP 内置字体
|
|
2
|
+
|
|
3
|
+
卡片默认使用系统字体别名(`Vcp-Sans` / `Vcp-Serif` / `Vcp-Kai` / `Vcp-Mono`,见
|
|
4
|
+
`src/worker/console/static-src/operator-chat/vcp-fonts.ts`)。这里的 woff2 只作为
|
|
5
|
+
离线兜底与单文件导出的一致性保证。
|
|
6
|
+
|
|
7
|
+
只允许放 **SIL OFL 1.1** 字族——本目录会随 npm 包分发,非商业授权字体不得入库。
|
|
8
|
+
|
|
9
|
+
| 文件 | 上游字族 | 字重 | 授权 |
|
|
10
|
+
| --- | --- | --- | --- |
|
|
11
|
+
| `Lanxi-HeiTi.woff2` | [Noto Sans CJK SC](https://github.com/notofonts/noto-cjk) | 400 | SIL OFL 1.1 |
|
|
12
|
+
| `Lanxi-HeiTiBold.woff2` | Noto Sans CJK SC Bold | 700 | SIL OFL 1.1 |
|
|
13
|
+
| `Lanxi-WenKai.woff2` | [LXGW WenKai GB Lite](https://github.com/lxgw/LxgwWenKaiGB-Lite) | 400 | SIL OFL 1.1 |
|
|
14
|
+
|
|
15
|
+
文件名保留 `Lanxi-*` 前缀是兼容既有卡片与测试的稳定标识,不代表另有来源。
|
|
16
|
+
|
|
17
|
+
## 已移除
|
|
18
|
+
|
|
19
|
+
| 文件 | 移除原因 |
|
|
20
|
+
| --- | --- |
|
|
21
|
+
| `Lanxi-超粗黑.woff2` | 笔画在标题字号下糊成一坨,不可读 |
|
|
22
|
+
| `Lanxi-可宋.woff2` | *Noncommercial* 授权,不能随包分发;已被 `Vcp-Serif` 系统衬线链覆盖 |
|
|
23
|
+
| `Lanxi-朗宋.woff2` | 同上 |
|
|
24
|
+
|
|
25
|
+
## 授权全文
|
|
26
|
+
|
|
27
|
+
OFL 1.1 全文见 <https://openfontlicense.org>。分发这些 woff2 时不得单独售卖字体,
|
|
28
|
+
修改后的衍生字体必须沿用 OFL。
|
|
@@ -305,7 +305,7 @@
|
|
|
305
305
|
// 仅对「有 <style> 的卡」注入:注入在第一个 <style> 标签开头作为底护兜底,
|
|
306
306
|
// 保持卡片自身声明的字体规则在后、优先级更高,同时排除 pre/code 免伤等宽代码。
|
|
307
307
|
var FONT_INHERIT_TAGS = 'div,p,span,h1,h2,h3,h4,h5,h6,li,td,th,a,strong,b,em,i,blockquote,small,label,figcaption,summary,button'
|
|
308
|
-
var FONT_SYSTEM_CHAIN = "
|
|
308
|
+
var FONT_SYSTEM_CHAIN = "var(--vcp-font-sans,-apple-system,BlinkMacSystemFont,'PingFang SC','Hiragino Sans GB','Microsoft YaHei UI','Microsoft YaHei','Segoe UI',system-ui,sans-serif)"
|
|
309
309
|
var FONT_INHERIT_RULE = function (uid) {
|
|
310
310
|
var out = '\n /* v6.33 渲染器注入:字体链兜底(根容器锁定 + 未声明字体元素继承)*/\n #' + uid + '{font-family:' + FONT_SYSTEM_CHAIN + ' !important}\n '
|
|
311
311
|
var tags = FONT_INHERIT_TAGS.split(',')
|
|
@@ -980,7 +980,7 @@
|
|
|
980
980
|
}
|
|
981
981
|
// ① 根容器:font-family 兜底链或无字体 → 锁定系统链(AI 显式内联/选择器尊重)
|
|
982
982
|
var rootFont = el.style.fontFamily
|
|
983
|
-
if (!(rootFont && rootFont.indexOf('
|
|
983
|
+
if (!(rootFont && rootFont.indexOf('var(--vcp-font-sans') !== 0 && !matched(el, 'font-family'))) {
|
|
984
984
|
if (!matched(el, 'font-family')) {
|
|
985
985
|
el.style.setProperty('font-family', FONT_SYSTEM_CHAIN, 'important')
|
|
986
986
|
}
|
|
@@ -1718,7 +1718,7 @@
|
|
|
1718
1718
|
if (!has('borderRadius')) base.borderRadius = '16px'
|
|
1719
1719
|
if (!has('border') && !has('borderColor')) base.border = '1px solid var(--vcp-border)'
|
|
1720
1720
|
if (!has('boxSizing')) base.boxSizing = 'border-box'
|
|
1721
|
-
if (!has('fontFamily')) base.fontFamily = "
|
|
1721
|
+
if (!has('fontFamily')) base.fontFamily = "var(--vcp-font-sans,-apple-system,'PingFang SC','Microsoft YaHei',system-ui,sans-serif)"
|
|
1722
1722
|
if (!has('lineHeight')) base.lineHeight = '1.6'
|
|
1723
1723
|
if (!has('display')) base.display = 'block'
|
|
1724
1724
|
if (!has('width')) base.width = '100%'
|
|
@@ -1772,7 +1772,7 @@
|
|
|
1772
1772
|
if (!has2('border-radius')) bs.setProperty('border-radius', '16px')
|
|
1773
1773
|
if (!has2('border') && !has2('border-color')) bs.setProperty('border', '1px solid var(--vcp-border)')
|
|
1774
1774
|
if (!has2('box-sizing')) bs.setProperty('box-sizing', 'border-box')
|
|
1775
|
-
if (!has2('font-family')) bs.setProperty('font-family', "
|
|
1775
|
+
if (!has2('font-family')) bs.setProperty('font-family', "var(--vcp-font-sans,-apple-system,'PingFang SC','Microsoft YaHei',system-ui,sans-serif)")
|
|
1776
1776
|
if (!has2('line-height')) bs.setProperty('line-height', '1.6')
|
|
1777
1777
|
if (!has2('display')) bs.setProperty('display', 'block')
|
|
1778
1778
|
if (!has2('width')) bs.setProperty('width', '100%')
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
function syncSpinner(element) {
|
|
3
|
+
if (!element)
|
|
4
|
+
return;
|
|
5
|
+
const svg = element;
|
|
6
|
+
for (const animation of svg.getAnimations?.({ subtree: true }) ?? []) {
|
|
7
|
+
animation.startTime = 0;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/** Small shared status marker; ongoing is the only animated state. */
|
|
11
|
+
export function StateDot(props) {
|
|
12
|
+
const edge = props.size ?? (props.state === "ongoing" ? 14 : 10);
|
|
13
|
+
if (props.state === "ongoing") {
|
|
14
|
+
return (_jsx("svg", { ref: syncSpinner, className: `oc-state-dot${props.className ? ` ${props.className}` : ""}`, "data-state": "ongoing", width: edge, height: edge, viewBox: "0 0 24 24", "aria-hidden": "true", children: _jsxs("g", { className: "oc-state-dot-motion", children: [_jsx("circle", { className: "oc-state-dot-track", cx: "12", cy: "12", r: "9.5" }), _jsx("circle", { className: "oc-state-dot-arc", cx: "12", cy: "12", r: "9.5" })] }) }));
|
|
15
|
+
}
|
|
16
|
+
return _jsx("span", { className: `oc-state-dot${props.className ? ` ${props.className}` : ""}`, "data-state": props.state, style: { width: edge, height: edge }, "aria-hidden": "true" });
|
|
17
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { fileToolPreview, toolRecord } from "../../chat/tool-presentation.js";
|
|
2
|
+
/** Only recorded successful edits from the selected turn may supply historical content. */
|
|
3
|
+
export function changedFileEdits(file, tools) {
|
|
4
|
+
const normalize = (path) => path.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
5
|
+
const paths = new Set([normalize(file.path), normalize(file.display)]);
|
|
6
|
+
return tools.flatMap(tool => {
|
|
7
|
+
if (!["edit", "write"].includes(tool.toolName) || tool.status !== "ok" || tool.interrupted)
|
|
8
|
+
return [];
|
|
9
|
+
const args = toolRecord(tool.args);
|
|
10
|
+
const path = typeof args?.path === "string" ? args.path : typeof args?.file_path === "string" ? args.file_path : undefined;
|
|
11
|
+
if (!path || args?.pathTruncated || !paths.has(normalize(path)))
|
|
12
|
+
return [];
|
|
13
|
+
return [{ id: tool.id, preview: fileToolPreview(tool.resultText ?? tool.result) }];
|
|
14
|
+
});
|
|
15
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The reader's chat type sizes, modelled on DSH's `ui-theme` font-size rows.
|
|
3
|
+
*
|
|
4
|
+
* DSH exposes THREE independent roles (`FONT_SIZE_SPECS` in
|
|
5
|
+
* `@deepseek-ai/dsh-client-ui-theme`), each a bounded integer rather than a set
|
|
6
|
+
* of presets, and each backed by its own CSS variable:
|
|
7
|
+
*
|
|
8
|
+
* text `--dsh-content-font-size` 10–22 default 14
|
|
9
|
+
* code `--dsh-code-font-size` 10–16 default 11
|
|
10
|
+
* terminal `--dsh-terminal-font-size` 10–20 default 13
|
|
11
|
+
*
|
|
12
|
+
* This module mirrors `text` and `code`; Console has no embedded terminal of its
|
|
13
|
+
* own to size (the terminal panel is a separate surface with its own setting).
|
|
14
|
+
* The bounds follow DSH. Each role is an independent integer so a reader can keep
|
|
15
|
+
* code dense next to comfortable prose — one shared ladder cannot express that,
|
|
16
|
+
* which is why the earlier fixed 13/14/15/16 list was replaced.
|
|
17
|
+
*/
|
|
18
|
+
const PREF_KEY = "loop-console.chat-font-size.v2";
|
|
19
|
+
/** Bounds and defaults per role, taken from DSH's `FONT_SIZE_SPECS`. DSH sets
|
|
20
|
+
* `code` to 11 and `text` to 14; Loop's code blocks already render at 12.5px, so
|
|
21
|
+
* the code default sits at 12 to avoid shrinking them on first load. */
|
|
22
|
+
export const CHAT_FONT_SPECS = {
|
|
23
|
+
text: { variable: "--oc-chat-font-body", min: 10, max: 22, default: 14 },
|
|
24
|
+
code: { variable: "--oc-chat-font-mono", min: 10, max: 16, default: 12 },
|
|
25
|
+
};
|
|
26
|
+
export const DEFAULT_CHAT_FONT_SIZES = {
|
|
27
|
+
text: CHAT_FONT_SPECS.text.default,
|
|
28
|
+
code: CHAT_FONT_SPECS.code.default,
|
|
29
|
+
};
|
|
30
|
+
/** Line height tracks the body at the scale's own ratio (22 / 14). */
|
|
31
|
+
const LINE_RATIO = 22 / 14;
|
|
32
|
+
export function clampFontSize(role, value) {
|
|
33
|
+
const spec = CHAT_FONT_SPECS[role];
|
|
34
|
+
if (!Number.isFinite(value))
|
|
35
|
+
return spec.default;
|
|
36
|
+
return Math.min(spec.max, Math.max(spec.min, Math.round(value)));
|
|
37
|
+
}
|
|
38
|
+
export function readChatFontSizes() {
|
|
39
|
+
if (typeof window === "undefined")
|
|
40
|
+
return DEFAULT_CHAT_FONT_SIZES;
|
|
41
|
+
try {
|
|
42
|
+
const raw = window.localStorage.getItem(PREF_KEY);
|
|
43
|
+
if (!raw)
|
|
44
|
+
return DEFAULT_CHAT_FONT_SIZES;
|
|
45
|
+
const parsed = JSON.parse(raw);
|
|
46
|
+
return {
|
|
47
|
+
text: clampFontSize("text", typeof parsed.text === "number" ? parsed.text : CHAT_FONT_SPECS.text.default),
|
|
48
|
+
code: clampFontSize("code", typeof parsed.code === "number" ? parsed.code : CHAT_FONT_SPECS.code.default),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return DEFAULT_CHAT_FONT_SIZES;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export function writeChatFontSizes(sizes) {
|
|
56
|
+
if (typeof window === "undefined")
|
|
57
|
+
return;
|
|
58
|
+
try {
|
|
59
|
+
window.localStorage.setItem(PREF_KEY, JSON.stringify(sizes));
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
/* A blocked storage must not break the chat; the choice still applies for
|
|
63
|
+
this session because the caller holds it in state. */
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The custom properties that carry one pair of choices.
|
|
68
|
+
*
|
|
69
|
+
* The prose line height is derived from the text size so a larger body keeps its
|
|
70
|
+
* leading; the code rung is independent (that is the point of the second role).
|
|
71
|
+
*/
|
|
72
|
+
export function chatFontVars(sizes) {
|
|
73
|
+
const text = clampFontSize("text", sizes.text);
|
|
74
|
+
const code = clampFontSize("code", sizes.code);
|
|
75
|
+
return {
|
|
76
|
+
"--oc-chat-font-body": `${text}px`,
|
|
77
|
+
"--oc-chat-line-body": `${Math.round(text * LINE_RATIO)}px`,
|
|
78
|
+
"--oc-chat-font-mono": `${code}px`,
|
|
79
|
+
// Inline code needs its own line box or it clips against a larger body.
|
|
80
|
+
"--oc-chat-line-mono": `${Math.round(code * 1.55)}px`,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/** Apply both roles to the document root so every transcript surface picks them up. */
|
|
84
|
+
export function applyChatFontSizes(sizes, root) {
|
|
85
|
+
if (!root)
|
|
86
|
+
return;
|
|
87
|
+
for (const [name, value] of Object.entries(chatFontVars(sizes))) {
|
|
88
|
+
root.style.setProperty(name, value);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session-list ordering.
|
|
3
|
+
*
|
|
4
|
+
* Two modes, following DSH's `ui-workspace` (`orderBy.updated` / `orderBy.manual`):
|
|
5
|
+
*
|
|
6
|
+
* · `updated` — strict recency. This is the historical behaviour, and it is why a
|
|
7
|
+
* list "keeps moving": every session's `updatedAt` advances whenever it does
|
|
8
|
+
* anything, so two sessions streaming at once flip the order continuously.
|
|
9
|
+
* · `manual` — frozen. Existing rows never move again; only a session that is
|
|
10
|
+
* NEW since the order was last saved gets inserted, positioned by recency among
|
|
11
|
+
* its own new peers.
|
|
12
|
+
*
|
|
13
|
+
* DSH's rule, which this reproduces: entering `manual` freezes the order as it
|
|
14
|
+
* stands, and returning to `updated` discards the frozen layout.
|
|
15
|
+
*/
|
|
16
|
+
const ORDER_MODE_KEY = "loop-console.session-order-mode.v1";
|
|
17
|
+
const SAVED_ORDER_KEY = "loop-console.session-order.v1";
|
|
18
|
+
export const SESSION_ORDER_OPTIONS = [
|
|
19
|
+
{ id: "updated", label: "最近更新" },
|
|
20
|
+
{ id: "manual", label: "保持顺序" },
|
|
21
|
+
];
|
|
1
22
|
function timestamp(value) {
|
|
2
23
|
if (value === null || value === undefined || value === "")
|
|
3
24
|
return null;
|
|
@@ -21,3 +42,78 @@ export function sortSessionsByRecency(sessions) {
|
|
|
21
42
|
return a.sessionId < b.sessionId ? -1 : a.sessionId > b.sessionId ? 1 : 0;
|
|
22
43
|
});
|
|
23
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Apply a saved order to the current membership, then insert anything new.
|
|
47
|
+
*
|
|
48
|
+
* The saved positions are emitted EXACTLY as stored — that is the whole point:
|
|
49
|
+
* a row the reader has already seen must not move because some other session
|
|
50
|
+
* produced a token. Sessions absent from the saved order (a brand-new
|
|
51
|
+
* conversation, or one created in another tab) are ranked by recency and placed
|
|
52
|
+
* after the known rows, which is where a reader expects new arrivals.
|
|
53
|
+
*
|
|
54
|
+
* @param sessions - current membership of one workspace.
|
|
55
|
+
* @param savedOrder - previously saved session ids, newest policy first.
|
|
56
|
+
* @returns the reordered array; unknown ids in `savedOrder` are dropped.
|
|
57
|
+
*/
|
|
58
|
+
export function orderSessionsManually(sessions, savedOrder) {
|
|
59
|
+
if (!savedOrder || savedOrder.length === 0)
|
|
60
|
+
return sortSessionsByRecency(sessions);
|
|
61
|
+
const remaining = new Map(sessions.map((session) => [session.sessionId, session]));
|
|
62
|
+
const ordered = [];
|
|
63
|
+
for (const sessionId of savedOrder) {
|
|
64
|
+
const session = remaining.get(sessionId);
|
|
65
|
+
if (session === undefined)
|
|
66
|
+
continue;
|
|
67
|
+
ordered.push(session);
|
|
68
|
+
remaining.delete(sessionId);
|
|
69
|
+
}
|
|
70
|
+
// Anything not in the saved order is new since the freeze; rank only those.
|
|
71
|
+
return [...ordered, ...sortSessionsByRecency([...remaining.values()])];
|
|
72
|
+
}
|
|
73
|
+
export function orderSessions(sessions, mode, savedOrder) {
|
|
74
|
+
return mode === "manual" ? orderSessionsManually(sessions, savedOrder) : sortSessionsByRecency(sessions);
|
|
75
|
+
}
|
|
76
|
+
export function readSessionOrderMode() {
|
|
77
|
+
if (typeof window === "undefined")
|
|
78
|
+
return "updated";
|
|
79
|
+
try {
|
|
80
|
+
return window.localStorage.getItem(ORDER_MODE_KEY) === "manual" ? "manual" : "updated";
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
return "updated";
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
export function writeSessionOrderMode(mode) {
|
|
87
|
+
if (typeof window === "undefined")
|
|
88
|
+
return;
|
|
89
|
+
try {
|
|
90
|
+
window.localStorage.setItem(ORDER_MODE_KEY, mode);
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
/* A blocked storage must not break the list. */
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
export function readSavedSessionOrder() {
|
|
97
|
+
if (typeof window === "undefined")
|
|
98
|
+
return [];
|
|
99
|
+
try {
|
|
100
|
+
const raw = window.localStorage.getItem(SAVED_ORDER_KEY);
|
|
101
|
+
if (!raw)
|
|
102
|
+
return [];
|
|
103
|
+
const parsed = JSON.parse(raw);
|
|
104
|
+
return Array.isArray(parsed) ? parsed.filter((id) => typeof id === "string") : [];
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
return [];
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
export function writeSavedSessionOrder(sessionIds) {
|
|
111
|
+
if (typeof window === "undefined")
|
|
112
|
+
return;
|
|
113
|
+
try {
|
|
114
|
+
window.localStorage.setItem(SAVED_ORDER_KEY, JSON.stringify(sessionIds));
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
/* Best effort. */
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -17,7 +17,7 @@ import { createAnimationFrameBatcher } from "./animation-frame-batcher.js";
|
|
|
17
17
|
* original request would have. `assistantId` is the in-flight assistant
|
|
18
18
|
* message id to patch for streaming text; reconnect creates one if none. */
|
|
19
19
|
export function createChatSseEventApplier(deps) {
|
|
20
|
-
const { refs, onReconcile, setError, setInterview, setHumanGateCards, setArtifactCards, setStreaming, setTurnPhase = () => undefined, setDeferredTurn = () => undefined, setDeferredTurns = () => undefined, setStreamingAssistantId, setUnread, setOperationCards, setUsage, onTelemetryRefresh, setMessages, setToolCalls, setPendingQuestion = () => undefined, setTodos = () => undefined, setWorkflowRuns = () => undefined, setGoal = () => undefined, setGoalStatus = () => undefined, setOperatorActions = () => undefined, setSddSessionIdentity = () => undefined, setConversationNodes = () => undefined, setTurnState = () => undefined, getMessages, } = deps;
|
|
20
|
+
const { refs, onReconcile, setError, setInterview, setHumanGateCards, setArtifactCards, setStreaming, setTurnPhase = () => undefined, setDeferredTurn = () => undefined, setDeferredTurns = () => undefined, setStreamingAssistantId, setUnread, setOperationCards, setUsage, onTelemetryRefresh, setMessages, setToolCalls, setPendingQuestion = () => undefined, setTodos = () => undefined, setWorkspaceChanges = () => undefined, setWorkflowRuns = () => undefined, setGoal = () => undefined, setGoalStatus = () => undefined, setOperatorActions = () => undefined, setSddSessionIdentity = () => undefined, setConversationNodes = () => undefined, setTurnState = () => undefined, getMessages, } = deps;
|
|
21
21
|
let queueOwner;
|
|
22
22
|
let queueRevision = -1;
|
|
23
23
|
// Keep the fence after terminal evidence clears the ownership refs. Session
|
|
@@ -209,6 +209,13 @@ export function createChatSseEventApplier(deps) {
|
|
|
209
209
|
}
|
|
210
210
|
return;
|
|
211
211
|
}
|
|
212
|
+
if (eventName === "workspace_changes") {
|
|
213
|
+
const summary = payload;
|
|
214
|
+
if (typeof summary.turnId === "string" && Array.isArray(summary.files)) {
|
|
215
|
+
setWorkspaceChanges(current => [...current.filter(item => item.turnId !== summary.turnId), summary].sort((a, b) => (a.turnNumber ?? 0) - (b.turnNumber ?? 0)));
|
|
216
|
+
}
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
212
219
|
if (eventName === "todo_updated" || eventName === "todo_cleared") {
|
|
213
220
|
const todos = Array.isArray(payload.todos) ? payload.todos : [];
|
|
214
221
|
setTodos(todos.filter((item) => Boolean(item) && typeof item === "object" && typeof item.content === "string" && (item.status === "pending" || item.status === "in_progress" || item.status === "completed")));
|
|
@@ -55,6 +55,10 @@ export function compactionMessageFromEvent(item) {
|
|
|
55
55
|
? { firstKeptEntryId: data.firstKeptEntryId }
|
|
56
56
|
: {}),
|
|
57
57
|
...(errorMessage ? { errorMessage } : {}),
|
|
58
|
+
...(data.localFallback === true ? { localFallback: true } : {}),
|
|
59
|
+
...(typeof data.localFallbackReason === "string" && data.localFallbackReason
|
|
60
|
+
? { localFallbackReason: data.localFallbackReason }
|
|
61
|
+
: {}),
|
|
58
62
|
...(eventId ? { eventId } : {}),
|
|
59
63
|
},
|
|
60
64
|
};
|
|
@@ -21,6 +21,7 @@ export const DETAILS_SURFACES = {
|
|
|
21
21
|
"activity",
|
|
22
22
|
"trajectory",
|
|
23
23
|
"goal",
|
|
24
|
+
"tasks",
|
|
24
25
|
"subagents",
|
|
25
26
|
"workflows",
|
|
26
27
|
"dag",
|
|
@@ -42,6 +43,7 @@ const TAB_TO_SURFACE = {
|
|
|
42
43
|
activity: "session",
|
|
43
44
|
trajectory: "session",
|
|
44
45
|
goal: "session",
|
|
46
|
+
tasks: "session",
|
|
45
47
|
subagents: "session",
|
|
46
48
|
workflows: "session",
|
|
47
49
|
dag: "session",
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which files did the model just write or edit?
|
|
3
|
+
*
|
|
4
|
+
* The repo browser's file preview is a SNAPSHOT: once open, its content never
|
|
5
|
+
* changed, so a reply that edited that very file left the reader looking at the
|
|
6
|
+
* old bytes with no way to refresh short of closing and reopening the tab.
|
|
7
|
+
*
|
|
8
|
+
* DSH answers the same question and its reasoning is worth copying exactly
|
|
9
|
+
* (`src/client/ops-stream.ts`, `src/client/changes/ops.ts`): it does NOT watch
|
|
10
|
+
* the filesystem. `fs.watch` reports a DIRECTORY's entry list changing, so it
|
|
11
|
+
* can see a file appear or vanish but never a file's CONTENTS changing — the
|
|
12
|
+
* one thing an open preview has to notice. DSH instead folds the session's own
|
|
13
|
+
* tool-call log into "which file was just touched", which also means the
|
|
14
|
+
* plugin's own saves cannot re-trigger a reload, and a write that failed never
|
|
15
|
+
* fires.
|
|
16
|
+
*
|
|
17
|
+
* This module is the same fold over Loop's `ToolCallEntry[]`, with DSH's three
|
|
18
|
+
* rules:
|
|
19
|
+
*
|
|
20
|
+
* 1. **Settled successes only.** A `write` fires once its result landed without
|
|
21
|
+
* an error, so a half-written file never reaches the preview.
|
|
22
|
+
* 2. **Nothing historical fires.** The first read of a session is the baseline:
|
|
23
|
+
* every op it already contains is recorded as seen and refreshes nothing.
|
|
24
|
+
* 3. **Session-scoped.** A touch found in one session is invisible to another.
|
|
25
|
+
*/
|
|
26
|
+
/** A tool whose SUCCESSFUL result changed a file's content. */
|
|
27
|
+
const WRITE_TOOL_NAMES = new Set([
|
|
28
|
+
"write",
|
|
29
|
+
"edit",
|
|
30
|
+
"multi-edit",
|
|
31
|
+
"multi_edit",
|
|
32
|
+
"create",
|
|
33
|
+
"str_replace",
|
|
34
|
+
"str-replace-editor",
|
|
35
|
+
]);
|
|
36
|
+
/**
|
|
37
|
+
* Classify one tool name. Unknown names are ignored rather than guessed at: a
|
|
38
|
+
* false positive would reload an unrelated preview, while a miss only costs the
|
|
39
|
+
* reader one manual reopen.
|
|
40
|
+
*/
|
|
41
|
+
export function isFileWriteTool(toolName) {
|
|
42
|
+
const name = toolName.trim();
|
|
43
|
+
if (WRITE_TOOL_NAMES.has(name))
|
|
44
|
+
return true;
|
|
45
|
+
// Namespaced forms (`fs.write`, `filesystem__edit`, `mcp__x__write_file`).
|
|
46
|
+
const tail = name.includes("__") ? name.slice(name.lastIndexOf("__") + 2) : name.slice(name.lastIndexOf(".") + 1);
|
|
47
|
+
if (WRITE_TOOL_NAMES.has(tail))
|
|
48
|
+
return true;
|
|
49
|
+
// `apply_patch` edits many files with no single path; it is deliberately NOT
|
|
50
|
+
// in the set above, and is handled by the caller as "reload everything open".
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Fold a session's tool calls into the file touches that happened AFTER
|
|
55
|
+
* `sinceSeq`.
|
|
56
|
+
*
|
|
57
|
+
* `sinceSeq` starts at `null` for a session's first read — that call returns no
|
|
58
|
+
* touches at all and only establishes the baseline, which is what keeps opening
|
|
59
|
+
* an old conversation from reloading everything.
|
|
60
|
+
*/
|
|
61
|
+
export function collectFileTouches(calls, sinceSeq) {
|
|
62
|
+
let high = sinceSeq ?? 0;
|
|
63
|
+
// Baseline read: record how far the log goes, refresh nothing.
|
|
64
|
+
if (sinceSeq === null) {
|
|
65
|
+
for (const call of calls) {
|
|
66
|
+
high = Math.max(high, call.finishedSeq ?? call.eventSeq ?? 0);
|
|
67
|
+
}
|
|
68
|
+
return { paths: [], reloadAll: false, cursor: high };
|
|
69
|
+
}
|
|
70
|
+
const seen = new Set();
|
|
71
|
+
const paths = [];
|
|
72
|
+
let reloadAll = false;
|
|
73
|
+
for (const call of calls) {
|
|
74
|
+
const seq = call.finishedSeq ?? call.eventSeq ?? 0;
|
|
75
|
+
if (seq <= high)
|
|
76
|
+
continue;
|
|
77
|
+
high = Math.max(high, seq);
|
|
78
|
+
// Rule 1: only a call that settled successfully changed a file.
|
|
79
|
+
if (call.status !== "ok")
|
|
80
|
+
continue;
|
|
81
|
+
const name = call.toolName.trim();
|
|
82
|
+
if (name === "apply_patch" || name.endsWith("__apply_patch")) {
|
|
83
|
+
reloadAll = true;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (!isFileWriteTool(name))
|
|
87
|
+
continue;
|
|
88
|
+
const path = pathOf(call.args);
|
|
89
|
+
if (!path || seen.has(path))
|
|
90
|
+
continue;
|
|
91
|
+
seen.add(path);
|
|
92
|
+
paths.push(path);
|
|
93
|
+
}
|
|
94
|
+
return { paths, reloadAll, cursor: high };
|
|
95
|
+
}
|
|
96
|
+
/** Every path-shaped key the file tools use, checked before use. */
|
|
97
|
+
function pathOf(args) {
|
|
98
|
+
if (args === null || typeof args !== "object" || Array.isArray(args))
|
|
99
|
+
return undefined;
|
|
100
|
+
const record = args;
|
|
101
|
+
for (const key of ["file_path", "path", "filePath", "filename", "file"]) {
|
|
102
|
+
const value = record[key];
|
|
103
|
+
if (typeof value === "string" && value.trim().length > 0)
|
|
104
|
+
return value;
|
|
105
|
+
}
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Human-readable byte size for attachment cards.
|
|
3
|
+
*
|
|
4
|
+
* Attachment metadata already carries `byteLength`; this is only a display
|
|
5
|
+
* concern, so it stays a tiny pure function rather than a formatting package.
|
|
6
|
+
*/
|
|
7
|
+
export function formatFileSize(bytes) {
|
|
8
|
+
if (!Number.isFinite(bytes) || bytes < 0)
|
|
9
|
+
return "";
|
|
10
|
+
if (bytes < 1024)
|
|
11
|
+
return `${Math.round(bytes)} B`;
|
|
12
|
+
const units = ["KB", "MB", "GB", "TB"];
|
|
13
|
+
let value = bytes / 1024;
|
|
14
|
+
let unitIndex = 0;
|
|
15
|
+
while (value >= 1024 && unitIndex < units.length - 1) {
|
|
16
|
+
value /= 1024;
|
|
17
|
+
unitIndex += 1;
|
|
18
|
+
}
|
|
19
|
+
// One decimal only when it adds information (1.0 MB reads as 1 MB).
|
|
20
|
+
const rounded = Math.round(value * 10) / 10;
|
|
21
|
+
return `${Number.isInteger(rounded) ? rounded : rounded.toFixed(1)} ${units[unitIndex]}`;
|
|
22
|
+
}
|
|
23
|
+
/** Whether an attachment should render as an image preview or a file card. */
|
|
24
|
+
export function isImageAttachment(mimeType) {
|
|
25
|
+
return typeof mimeType === "string" && mimeType.toLowerCase().startsWith("image/");
|
|
26
|
+
}
|