@youweichen/pi-harness 0.0.0-stage → 1.1.0
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/LICENSE +21 -0
- package/README.md +74 -2
- package/bin/pi-harness.mjs +1819 -0
- package/deploy/com.youweichen.pi-harness.plist +48 -0
- package/deploy/nginx-subpath.conf +88 -0
- package/deploy/pi-harness-task.xml +71 -0
- package/deploy/pi-harness.service +31 -0
- package/dist/server/agent-service.js +3131 -0
- package/dist/server/app-version.js +19 -0
- package/dist/server/attachments.js +526 -0
- package/dist/server/auth-file.js +61 -0
- package/dist/server/bg-servers.js +154 -0
- package/dist/server/client-eviction.js +19 -0
- package/dist/server/client-id.js +9 -0
- package/dist/server/client-state.js +202 -0
- package/dist/server/codemode-image-routes.js +36 -0
- package/dist/server/codemode-presentation.js +19 -0
- package/dist/server/component-updates.js +135 -0
- package/dist/server/context-breakdown.js +56 -0
- package/dist/server/control-socket.js +178 -0
- package/dist/server/conversation.js +65 -0
- package/dist/server/dir-browser.js +77 -0
- package/dist/server/editor-snapshot.js +38 -0
- package/dist/server/ensure-bash.js +80 -0
- package/dist/server/extension-display.js +23 -0
- package/dist/server/extensions-catalog.js +64 -0
- package/dist/server/extensions-model.js +46 -0
- package/dist/server/extensions-routes.js +255 -0
- package/dist/server/extensions-worker.js +188 -0
- package/dist/server/files-service.js +787 -0
- package/dist/server/index.js +1033 -0
- package/dist/server/markdown-images.js +42 -0
- package/dist/server/model-admin.js +801 -0
- package/dist/server/model-config-merge.js +32 -0
- package/dist/server/native-mcp-config.js +103 -0
- package/dist/server/native-mcp-presentation.js +12 -0
- package/dist/server/native-prompt-template.js +12 -0
- package/dist/server/native-tools.js +32 -0
- package/dist/server/node-agent.js +262 -0
- package/dist/server/node-sources.js +142 -0
- package/dist/server/node-workbench.js +729 -0
- package/dist/server/origin-policy.js +50 -0
- package/dist/server/patch-node-pty.js +96 -0
- package/dist/server/pi-environment.js +203 -0
- package/dist/server/plan/extension.js +74 -0
- package/dist/server/plan/progress.js +90 -0
- package/dist/server/plan/settings.js +41 -0
- package/dist/server/plan/state.js +123 -0
- package/dist/server/plugin-facilities.js +304 -0
- package/dist/server/plugin-updater.js +245 -0
- package/dist/server/plugins.js +712 -0
- package/dist/server/private-file.js +28 -0
- package/dist/server/process-utils.js +112 -0
- package/dist/server/prompt-delivery.js +80 -0
- package/dist/server/protocol-version.js +11 -0
- package/dist/server/protocol.js +6 -0
- package/dist/server/provider-auth.js +99 -0
- package/dist/server/query-cache.js +45 -0
- package/dist/server/recovery-state.js +37 -0
- package/dist/server/scm.js +459 -0
- package/dist/server/security-headers.js +24 -0
- package/dist/server/serialize.js +254 -0
- package/dist/server/session-file-read.js +225 -0
- package/dist/server/session-record-worker.js +21 -0
- package/dist/server/session-reload.js +13 -0
- package/dist/server/session-tree-controller.js +250 -0
- package/dist/server/session-tree.js +191 -0
- package/dist/server/settings-service.js +53 -0
- package/dist/server/skills-service.js +87 -0
- package/dist/server/slash-commands.js +286 -0
- package/dist/server/sqlite-preview.js +58 -0
- package/dist/server/sqlite-query.js +67 -0
- package/dist/server/sqlite-worker.js +12 -0
- package/dist/server/system-prompt-files.js +158 -0
- package/dist/server/system-prompt-routes.js +40 -0
- package/dist/server/system-prompt-view.js +49 -0
- package/dist/server/task-progress.js +233 -0
- package/dist/server/terminals.js +833 -0
- package/dist/server/text-sniff.js +269 -0
- package/dist/server/thinking-timing.js +91 -0
- package/dist/server/token-auth.js +37 -0
- package/dist/server/tool-output.js +97 -0
- package/dist/server/tool-text-incidents.js +82 -0
- package/dist/server/tool-text.js +67 -0
- package/dist/server/uploads.js +112 -0
- package/dist/server/user-attachments.js +96 -0
- package/dist/server/webui-context.js +257 -0
- package/dist/server/wiki-links.js +136 -0
- package/dist/server/wiki-pdf-worker.js +23 -0
- package/dist/server/wiki-pdf.js +36 -0
- package/dist/server/wiki-routes.js +184 -0
- package/dist/server/wiki-service.js +524 -0
- package/electron/main.mjs +607 -0
- package/extensions/webui.ts +192 -0
- package/package.json +122 -4
- package/web/dist/apple-touch-icon.png +0 -0
- package/web/dist/assets/NodeWorkbench-BiP2ktQP.js +3 -0
- package/web/dist/assets/TerminalPanel-CKaSUsN-.js +2 -0
- package/web/dist/assets/abnfDiagram-VCTEODGH-CnwRJDRL.js +1 -0
- package/web/dist/assets/arc-CG4Q7-W_.js +1 -0
- package/web/dist/assets/architectureDiagram-5GKGNRK7-BrGqX_Rg.js +36 -0
- package/web/dist/assets/blockDiagram-I7D4REHJ-C2t0PjZT.js +129 -0
- package/web/dist/assets/c4Diagram-7LVT6UL2-CadrcgGL.js +38 -0
- package/web/dist/assets/channel-C27Jizb6.js +1 -0
- package/web/dist/assets/chunk-2Q5K7J3B-CC3V2ITZ.js +1 -0
- package/web/dist/assets/chunk-5VM5RSS4-DqKSbGmE.js +15 -0
- package/web/dist/assets/chunk-F27PBJKO-_CDr3JbY.js +1 -0
- package/web/dist/assets/chunk-IMKFNOWR-BIR4H4fX.js +231 -0
- package/web/dist/assets/chunk-JWPE2WC7-CrsdBGXT.js +1 -0
- package/web/dist/assets/chunk-POPQ4Y6H-C6q9kQmf.js +1 -0
- package/web/dist/assets/chunk-SVP7TREG-l2XXTr2v.js +88 -0
- package/web/dist/assets/chunk-TICWLB2K-29I_mZgB.js +206 -0
- package/web/dist/assets/chunk-XXDRQBXY-htV9FBqi.js +1 -0
- package/web/dist/assets/classDiagram-ZZMXUADV-DYTBrAEP.js +1 -0
- package/web/dist/assets/classDiagram-v2-VYDZK3BY-DYTBrAEP.js +1 -0
- package/web/dist/assets/cose-bilkent-JH36ORCC-Cop-ihyx.js +1 -0
- package/web/dist/assets/cynefin-OW5HDTMX-IEk8qBRq.js +178 -0
- package/web/dist/assets/cynefinDiagram-5FMLGOSQ-Bmzt6Qb5.js +62 -0
- package/web/dist/assets/cytoscape.esm-Bch-eiPH.js +331 -0
- package/web/dist/assets/dagre-GXQ25YYZ-DiXTJYYU.js +4 -0
- package/web/dist/assets/defaultLocale-DX6XiGOO.js +1 -0
- package/web/dist/assets/diagram-S7CK7UJ4-BT7CLuNk.js +30 -0
- package/web/dist/assets/diagram-UQ7AKVKN-BZZ3nTCO.js +41 -0
- package/web/dist/assets/diagram-VSXAHHWV-Dal8LeZh.js +3 -0
- package/web/dist/assets/diagram-VX7I27RA-D6V9FfNA.js +24 -0
- package/web/dist/assets/diagram-Z3DM3KII-KUAIcFiD.js +24 -0
- package/web/dist/assets/ebnfDiagram-PWID7BFC-s0FEPZrV.js +1 -0
- package/web/dist/assets/erDiagram-RLTQ6QDP-CiIQPFCD.js +99 -0
- package/web/dist/assets/flowDiagram-HODETNUW-CvG4MYWn.js +168 -0
- package/web/dist/assets/ganttDiagram-EL5Y4UJY-CUf115ii.js +292 -0
- package/web/dist/assets/gitGraphDiagram-WWUBYQGX-o3K1r6fL.js +106 -0
- package/web/dist/assets/index-C3vDFSEV.css +10 -0
- package/web/dist/assets/index-C5or_GAq.js +276 -0
- package/web/dist/assets/infoDiagram-27XIBGKW-BxiBeQ8E.js +2 -0
- package/web/dist/assets/init-Gi6I4Gst.js +1 -0
- package/web/dist/assets/ishikawaDiagram-5VMMS53U-B1ONuCkH.js +70 -0
- package/web/dist/assets/journeyDiagram-3NMN7TZE-DwmuoXcX.js +139 -0
- package/web/dist/assets/kanban-definition-UXKFOSKX-pMKHubxH.js +89 -0
- package/web/dist/assets/katex-C5jXJg4s.js +257 -0
- package/web/dist/assets/layout-CEwfjQR0.js +1 -0
- package/web/dist/assets/linear-D22Gdbt1.js +1 -0
- package/web/dist/assets/markdown-BhJ_LInD.js +51 -0
- package/web/dist/assets/mermaid.core-CO2nrD04.js +312 -0
- package/web/dist/assets/mindmap-definition-YA3MSWOX-9MQn9ZAp.js +96 -0
- package/web/dist/assets/ordinal-Cboi1Yqb.js +1 -0
- package/web/dist/assets/pegDiagram-XKGWAZYB-Dy6fLjM-.js +1 -0
- package/web/dist/assets/pieDiagram-E7YTZNPT-EDLez6nA.js +39 -0
- package/web/dist/assets/quadrantDiagram-AXDQQJYC-Cgcd9mvy.js +7 -0
- package/web/dist/assets/railroadDiagram-O6MQD6OU-B4Td0tjj.js +1 -0
- package/web/dist/assets/react-BddUxV-9.js +24 -0
- package/web/dist/assets/requirementDiagram-BXWQKSXE-aF2QNZ78.js +84 -0
- package/web/dist/assets/sankeyDiagram-P5KCCOFB-DgTYwYMa.js +40 -0
- package/web/dist/assets/sequenceDiagram-WJ2MYXX4-EUcddWUc.js +162 -0
- package/web/dist/assets/sizeCapture-INFHLROL-CXHOv9Sx.js +1 -0
- package/web/dist/assets/stateDiagram-D77RDMKH-B-xlgfaK.js +1 -0
- package/web/dist/assets/stateDiagram-v2-MP3YSRHH-kwAwAlWX.js +1 -0
- package/web/dist/assets/swimlanes-42K2YHIH-BtFBOCDh.js +1 -0
- package/web/dist/assets/swimlanesDiagram-VR7AAH4N-D5j5Cj3S.js +8 -0
- package/web/dist/assets/timeline-definition-24CTP7MA-CZlQY6pb.js +120 -0
- package/web/dist/assets/vennDiagram-4TSXK5OY-Cn61dJvL.js +34 -0
- package/web/dist/assets/wardleyDiagram-VM6X3IG4-fiMNrWpr.js +78 -0
- package/web/dist/assets/xterm-6GBZ9nXN.css +32 -0
- package/web/dist/assets/xterm-D1D2FVe3.js +38 -0
- package/web/dist/assets/xychartDiagram-S5SC5T6Z-CuzM_sof.js +7 -0
- package/web/dist/brand-mark.svg +5 -0
- package/web/dist/favicon-32.png +0 -0
- package/web/dist/favicon.svg +5 -0
- package/web/dist/fonts/WIKI-FONTS.md +5 -0
- package/web/dist/fonts/ibm-plex-mono/ibm-plex-mono-latin-400-normal.woff2 +0 -0
- package/web/dist/fonts/ibm-plex-mono/ibm-plex-mono-latin-500-normal.woff2 +0 -0
- package/web/dist/fonts/ibm-plex-mono/ibm-plex-mono-latin-600-normal.woff2 +0 -0
- package/web/dist/fonts/ibm-plex-mono/ibm-plex-mono-latin-ext-400-normal.woff2 +0 -0
- package/web/dist/fonts/ibm-plex-mono/ibm-plex-mono-latin-ext-500-normal.woff2 +0 -0
- package/web/dist/fonts/ibm-plex-mono/ibm-plex-mono-latin-ext-600-normal.woff2 +0 -0
- package/web/dist/fonts/ibm-plex-sans/LICENSE +93 -0
- package/web/dist/fonts/ibm-plex-sans/ibm-plex-sans-latin-400-normal.woff2 +0 -0
- package/web/dist/fonts/ibm-plex-sans/ibm-plex-sans-latin-500-normal.woff2 +0 -0
- package/web/dist/fonts/ibm-plex-sans/ibm-plex-sans-latin-600-normal.woff2 +0 -0
- package/web/dist/fonts/ibm-plex-sans/ibm-plex-sans-latin-ext-400-normal.woff2 +0 -0
- package/web/dist/fonts/ibm-plex-sans/ibm-plex-sans-latin-ext-500-normal.woff2 +0 -0
- package/web/dist/fonts/ibm-plex-sans/ibm-plex-sans-latin-ext-600-normal.woff2 +0 -0
- package/web/dist/fonts/inter/inter-latin-400-normal.woff2 +0 -0
- package/web/dist/fonts/inter/inter-latin-500-normal.woff2 +0 -0
- package/web/dist/fonts/inter/inter-latin-600-normal.woff2 +0 -0
- package/web/dist/fonts/inter/inter-latin-700-normal.woff2 +0 -0
- package/web/dist/fonts/inter/inter-latin-800-normal.woff2 +0 -0
- package/web/dist/fonts/inter/inter-latin-ext-400-normal.woff2 +0 -0
- package/web/dist/fonts/inter/inter-latin-ext-500-normal.woff2 +0 -0
- package/web/dist/fonts/inter/inter-latin-ext-600-normal.woff2 +0 -0
- package/web/dist/fonts/inter/inter-latin-ext-700-normal.woff2 +0 -0
- package/web/dist/fonts/inter/inter-latin-ext-800-normal.woff2 +0 -0
- package/web/dist/fonts/jetbrains-mono/LICENSE +93 -0
- package/web/dist/fonts/jetbrains-mono/jetbrains-mono-latin-400-normal.woff2 +0 -0
- package/web/dist/fonts/jetbrains-mono/jetbrains-mono-latin-500-normal.woff2 +0 -0
- package/web/dist/fonts/jetbrains-mono/jetbrains-mono-latin-600-normal.woff2 +0 -0
- package/web/dist/fonts/jetbrains-mono/jetbrains-mono-latin-ext-400-normal.woff2 +0 -0
- package/web/dist/fonts/jetbrains-mono/jetbrains-mono-latin-ext-500-normal.woff2 +0 -0
- package/web/dist/fonts/jetbrains-mono/jetbrains-mono-latin-ext-600-normal.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/LICENSE +94 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-0.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-1.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-10.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-100.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-11.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-12.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-13.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-14.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-15.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-16.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-17.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-18.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-19.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-2.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-20.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-21.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-22.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-23.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-24.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-25.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-26.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-27.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-28.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-29.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-3.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-30.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-31.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-32.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-33.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-34.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-35.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-36.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-37.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-38.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-39.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-4.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-40.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-41.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-42.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-43.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-44.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-45.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-46.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-47.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-48.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-49.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-5.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-50.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-51.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-52.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-53.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-54.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-55.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-56.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-57.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-58.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-59.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-6.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-60.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-61.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-62.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-63.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-64.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-65.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-66.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-67.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-68.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-69.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-7.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-70.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-71.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-72.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-73.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-74.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-75.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-76.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-77.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-78.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-79.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-8.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-80.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-81.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-82.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-83.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-84.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-85.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-86.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-87.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-88.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-89.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-9.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-90.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-91.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-92.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-93.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-94.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-95.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-96.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-97.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-98.woff2 +0 -0
- package/web/dist/fonts/noto-serif-sc/noto-serif-sc-500-99.woff2 +0 -0
- package/web/dist/fonts/source-serif-4/LICENSE +93 -0
- package/web/dist/fonts/source-serif-4/source-serif-4-500-0.woff2 +0 -0
- package/web/dist/fonts/source-serif-4/source-serif-4-500-1.woff2 +0 -0
- package/web/dist/fonts/source-serif-4/source-serif-4-500-2.woff2 +0 -0
- package/web/dist/fonts/source-serif-4/source-serif-4-500-3.woff2 +0 -0
- package/web/dist/fonts/source-serif-4/source-serif-4-500-4.woff2 +0 -0
- package/web/dist/fonts/source-serif-4/source-serif-4-500-5.woff2 +0 -0
- package/web/dist/icon/1a-mark.svg +1 -0
- package/web/dist/icon.ico +0 -0
- package/web/dist/index.html +18 -0
- package/web/public/apple-touch-icon.png +0 -0
- package/web/public/brand-mark.svg +5 -0
- package/web/public/favicon-32.png +0 -0
- package/web/public/favicon.svg +5 -0
- package/web/public/fonts/WIKI-FONTS.md +5 -0
- package/web/public/fonts/ibm-plex-mono/ibm-plex-mono-latin-400-normal.woff2 +0 -0
- package/web/public/fonts/ibm-plex-mono/ibm-plex-mono-latin-500-normal.woff2 +0 -0
- package/web/public/fonts/ibm-plex-mono/ibm-plex-mono-latin-600-normal.woff2 +0 -0
- package/web/public/fonts/ibm-plex-mono/ibm-plex-mono-latin-ext-400-normal.woff2 +0 -0
- package/web/public/fonts/ibm-plex-mono/ibm-plex-mono-latin-ext-500-normal.woff2 +0 -0
- package/web/public/fonts/ibm-plex-mono/ibm-plex-mono-latin-ext-600-normal.woff2 +0 -0
- package/web/public/fonts/ibm-plex-sans/LICENSE +93 -0
- package/web/public/fonts/ibm-plex-sans/ibm-plex-sans-latin-400-normal.woff2 +0 -0
- package/web/public/fonts/ibm-plex-sans/ibm-plex-sans-latin-500-normal.woff2 +0 -0
- package/web/public/fonts/ibm-plex-sans/ibm-plex-sans-latin-600-normal.woff2 +0 -0
- package/web/public/fonts/ibm-plex-sans/ibm-plex-sans-latin-ext-400-normal.woff2 +0 -0
- package/web/public/fonts/ibm-plex-sans/ibm-plex-sans-latin-ext-500-normal.woff2 +0 -0
- package/web/public/fonts/ibm-plex-sans/ibm-plex-sans-latin-ext-600-normal.woff2 +0 -0
- package/web/public/fonts/inter/inter-latin-400-normal.woff2 +0 -0
- package/web/public/fonts/inter/inter-latin-500-normal.woff2 +0 -0
- package/web/public/fonts/inter/inter-latin-600-normal.woff2 +0 -0
- package/web/public/fonts/inter/inter-latin-700-normal.woff2 +0 -0
- package/web/public/fonts/inter/inter-latin-800-normal.woff2 +0 -0
- package/web/public/fonts/inter/inter-latin-ext-400-normal.woff2 +0 -0
- package/web/public/fonts/inter/inter-latin-ext-500-normal.woff2 +0 -0
- package/web/public/fonts/inter/inter-latin-ext-600-normal.woff2 +0 -0
- package/web/public/fonts/inter/inter-latin-ext-700-normal.woff2 +0 -0
- package/web/public/fonts/inter/inter-latin-ext-800-normal.woff2 +0 -0
- package/web/public/fonts/jetbrains-mono/LICENSE +93 -0
- package/web/public/fonts/jetbrains-mono/jetbrains-mono-latin-400-normal.woff2 +0 -0
- package/web/public/fonts/jetbrains-mono/jetbrains-mono-latin-500-normal.woff2 +0 -0
- package/web/public/fonts/jetbrains-mono/jetbrains-mono-latin-600-normal.woff2 +0 -0
- package/web/public/fonts/jetbrains-mono/jetbrains-mono-latin-ext-400-normal.woff2 +0 -0
- package/web/public/fonts/jetbrains-mono/jetbrains-mono-latin-ext-500-normal.woff2 +0 -0
- package/web/public/fonts/jetbrains-mono/jetbrains-mono-latin-ext-600-normal.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/LICENSE +94 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-0.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-1.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-10.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-100.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-11.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-12.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-13.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-14.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-15.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-16.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-17.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-18.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-19.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-2.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-20.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-21.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-22.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-23.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-24.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-25.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-26.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-27.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-28.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-29.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-3.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-30.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-31.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-32.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-33.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-34.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-35.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-36.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-37.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-38.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-39.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-4.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-40.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-41.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-42.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-43.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-44.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-45.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-46.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-47.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-48.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-49.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-5.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-50.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-51.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-52.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-53.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-54.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-55.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-56.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-57.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-58.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-59.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-6.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-60.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-61.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-62.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-63.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-64.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-65.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-66.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-67.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-68.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-69.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-7.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-70.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-71.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-72.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-73.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-74.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-75.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-76.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-77.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-78.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-79.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-8.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-80.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-81.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-82.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-83.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-84.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-85.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-86.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-87.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-88.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-89.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-9.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-90.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-91.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-92.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-93.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-94.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-95.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-96.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-97.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-98.woff2 +0 -0
- package/web/public/fonts/noto-serif-sc/noto-serif-sc-500-99.woff2 +0 -0
- package/web/public/fonts/source-serif-4/LICENSE +93 -0
- package/web/public/fonts/source-serif-4/source-serif-4-500-0.woff2 +0 -0
- package/web/public/fonts/source-serif-4/source-serif-4-500-1.woff2 +0 -0
- package/web/public/fonts/source-serif-4/source-serif-4-500-2.woff2 +0 -0
- package/web/public/fonts/source-serif-4/source-serif-4-500-3.woff2 +0 -0
- package/web/public/fonts/source-serif-4/source-serif-4-500-4.woff2 +0 -0
- package/web/public/fonts/source-serif-4/source-serif-4-500-5.woff2 +0 -0
- package/web/public/icon/1a-mark.svg +1 -0
- package/web/public/icon.ico +0 -0
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { codemodeDetails } from "./codemode-presentation.js";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { snapshotFromDetails } from "./plan/state.js";
|
|
4
|
+
const TEXT_CAP = 200_000;
|
|
5
|
+
const TOOL_OUTPUT_CAP = 100_000;
|
|
6
|
+
const ARGS_CAP = 20_000;
|
|
7
|
+
function truncate(s, cap) {
|
|
8
|
+
if (s.length <= cap)
|
|
9
|
+
return { text: s, truncated: false };
|
|
10
|
+
return { text: `${s.slice(0, cap)}\n\n… [truncated]`, truncated: true };
|
|
11
|
+
}
|
|
12
|
+
/** Only documented native result fields cross the wire. */
|
|
13
|
+
export function toolExitCode(result, isError = false) {
|
|
14
|
+
if (!result || typeof result !== "object")
|
|
15
|
+
return undefined;
|
|
16
|
+
const r = result;
|
|
17
|
+
for (const value of [r.structuredContent?.exit_code, r.details?.exitCode]) {
|
|
18
|
+
if (typeof value === "number" && Number.isSafeInteger(value))
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
if (!isError)
|
|
22
|
+
return undefined;
|
|
23
|
+
const text = Array.isArray(r.content) ? r.content.filter(c => c?.type === "text" && typeof c.text === "string").map(c => c.text).join("\n") : "";
|
|
24
|
+
const match = text.match(/exited with code (-?\d+)/);
|
|
25
|
+
return match && Number.isSafeInteger(Number(match[1])) ? Number(match[1]) : undefined;
|
|
26
|
+
}
|
|
27
|
+
export function nativeToolDetails(name, result) {
|
|
28
|
+
if (!result || typeof result !== "object")
|
|
29
|
+
return undefined;
|
|
30
|
+
const r = result;
|
|
31
|
+
const d = r.details;
|
|
32
|
+
const out = {};
|
|
33
|
+
if (name === "edit") {
|
|
34
|
+
if (typeof d?.diff === "string") {
|
|
35
|
+
const bounded = truncate(d.diff, TOOL_OUTPUT_CAP);
|
|
36
|
+
out.diff = bounded.text;
|
|
37
|
+
out.diffTruncated = bounded.truncated;
|
|
38
|
+
}
|
|
39
|
+
if (typeof d?.firstChangedLine === "number" && Number.isSafeInteger(d.firstChangedLine) && d.firstChangedLine > 0)
|
|
40
|
+
out.firstChangedLine = d.firstChangedLine;
|
|
41
|
+
}
|
|
42
|
+
const path = d?.fullOutputPath ?? (["bash", "powershell"].includes(name) ? r.structuredContent?.full_output_path : undefined);
|
|
43
|
+
if (typeof path === "string" && path.length <= 4096)
|
|
44
|
+
out.fullOutputPath = path;
|
|
45
|
+
if (name === "bash") {
|
|
46
|
+
out.exitCode = toolExitCode(result, r.isError);
|
|
47
|
+
if (d?.truncation && typeof d.truncation === "object") {
|
|
48
|
+
const source = d.truncation;
|
|
49
|
+
const truncation = {};
|
|
50
|
+
for (const key of ["truncated", "lastLinePartial"])
|
|
51
|
+
if (typeof source[key] === "boolean")
|
|
52
|
+
truncation[key] = source[key];
|
|
53
|
+
for (const key of ["totalLines", "totalBytes", "outputLines", "outputBytes"])
|
|
54
|
+
if (typeof source[key] === "number" && Number.isSafeInteger(source[key]) && source[key] >= 0)
|
|
55
|
+
truncation[key] = source[key];
|
|
56
|
+
if (source.truncatedBy === "lines" || source.truncatedBy === "bytes")
|
|
57
|
+
truncation.truncatedBy = source.truncatedBy;
|
|
58
|
+
out.truncation = truncation;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return Object.keys(out).length ? out : undefined;
|
|
62
|
+
}
|
|
63
|
+
function serializeUserContent(content) {
|
|
64
|
+
if (typeof content === "string")
|
|
65
|
+
return [{ type: "text", text: content }];
|
|
66
|
+
return content.map((b) => {
|
|
67
|
+
if (b.type === "image") {
|
|
68
|
+
const img = b;
|
|
69
|
+
// Canonical ImageContent shape is { type, data, mimeType }; tolerate the
|
|
70
|
+
// legacy { source } wrapper too.
|
|
71
|
+
if (typeof img.data === "string" && img.data.length > 0) {
|
|
72
|
+
return {
|
|
73
|
+
type: "image",
|
|
74
|
+
dataUrl: `data:${img.mimeType ?? "image/png"};base64,${img.data}`,
|
|
75
|
+
mimeType: img.mimeType,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
const src = img.source;
|
|
79
|
+
if (src?.type === "base64" && src.data) {
|
|
80
|
+
return {
|
|
81
|
+
type: "image",
|
|
82
|
+
dataUrl: `data:${src.mediaType ?? "image/png"};base64,${src.data}`,
|
|
83
|
+
mimeType: src.mediaType,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
return { type: "image", dataUrl: src?.url };
|
|
87
|
+
}
|
|
88
|
+
return { type: "text", text: String(b.text ?? "") };
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function serializeAssistantContent(content) {
|
|
92
|
+
return content.map((b) => {
|
|
93
|
+
if (b.type === "text") {
|
|
94
|
+
const { text, truncated } = truncate(b.text, TEXT_CAP);
|
|
95
|
+
return { type: "text", text, truncated };
|
|
96
|
+
}
|
|
97
|
+
if (b.type === "thinking") {
|
|
98
|
+
return { type: "thinking", thinking: b.thinking };
|
|
99
|
+
}
|
|
100
|
+
if (b.type === "toolCall") {
|
|
101
|
+
if (b.arguments === undefined) {
|
|
102
|
+
return { type: "toolCall", id: b.id, name: b.name };
|
|
103
|
+
}
|
|
104
|
+
const { text, truncated } = truncate(JSON.stringify(b.arguments), ARGS_CAP);
|
|
105
|
+
return {
|
|
106
|
+
type: "toolCall",
|
|
107
|
+
id: b.id,
|
|
108
|
+
name: b.name,
|
|
109
|
+
argumentsText: text,
|
|
110
|
+
argumentsTruncated: truncated,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
return { type: "unknown", ...b };
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
export function serializeMessage(m, seq) {
|
|
117
|
+
switch (m.role) {
|
|
118
|
+
case "user":
|
|
119
|
+
return {
|
|
120
|
+
id: `u-${m.timestamp}-${seq}`,
|
|
121
|
+
role: "user",
|
|
122
|
+
content: serializeUserContent(m.content),
|
|
123
|
+
timestamp: m.timestamp,
|
|
124
|
+
};
|
|
125
|
+
case "assistant":
|
|
126
|
+
return {
|
|
127
|
+
id: `a-${m.timestamp}-${seq}`,
|
|
128
|
+
role: "assistant",
|
|
129
|
+
content: serializeAssistantContent(m.content),
|
|
130
|
+
timestamp: m.timestamp,
|
|
131
|
+
model: m.model,
|
|
132
|
+
provider: m.provider,
|
|
133
|
+
stopReason: m.stopReason,
|
|
134
|
+
usage: m.usage ? { input: m.usage.input, output: m.usage.output, cacheRead: m.usage.cacheRead, cacheWrite: m.usage.cacheWrite } : undefined,
|
|
135
|
+
errorMessage: m.errorMessage,
|
|
136
|
+
};
|
|
137
|
+
case "toolResult": {
|
|
138
|
+
const raw = m.content
|
|
139
|
+
.map((c) => (c.type === "text" ? c.text : ""))
|
|
140
|
+
.join("\n");
|
|
141
|
+
const { text, truncated } = truncate(raw, TOOL_OUTPUT_CAP);
|
|
142
|
+
const plan = m.toolName === "plan" && !m.isError ? snapshotFromDetails(m.details) : undefined;
|
|
143
|
+
let nestedComplete = m.nestedCalls?.complete === true && m.nestedCalls.calls.length <= 256;
|
|
144
|
+
const nestedCalls = m.nestedCalls?.calls.slice(0, 256).map(call => {
|
|
145
|
+
const args = call.arguments ? truncate(JSON.stringify(call.arguments), ARGS_CAP) : undefined;
|
|
146
|
+
if (args?.truncated)
|
|
147
|
+
nestedComplete = false;
|
|
148
|
+
return { id: call.id, name: call.name, status: call.status, durationMs: call.durationMs,
|
|
149
|
+
error: call.error?.slice(0, 500), argumentsBytes: call.argumentsBytes,
|
|
150
|
+
argumentsText: args?.text };
|
|
151
|
+
});
|
|
152
|
+
return {
|
|
153
|
+
id: `t-${m.toolCallId}`,
|
|
154
|
+
role: "toolResult",
|
|
155
|
+
content: [{ type: "text", text, truncated }, ...serializeUserContent(m.content.filter(block => block.type === "image"))],
|
|
156
|
+
...(nestedCalls ? { nestedCalls: { complete: nestedComplete, calls: nestedCalls } } : {}),
|
|
157
|
+
toolCallId: m.toolCallId,
|
|
158
|
+
toolName: m.toolName,
|
|
159
|
+
details: nativeToolDetails(m.toolName, m),
|
|
160
|
+
...(m.toolName === "codemode" ? { codemode: codemodeDetails(m.details) } : {}),
|
|
161
|
+
isError: m.isError,
|
|
162
|
+
...(plan ? { planSnapshot: plan } : {}),
|
|
163
|
+
timestamp: m.timestamp,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
case "bashExecution": {
|
|
167
|
+
const { text, truncated } = truncate(m.output, TOOL_OUTPUT_CAP);
|
|
168
|
+
return {
|
|
169
|
+
id: `b-${m.timestamp}-${seq}`,
|
|
170
|
+
role: "bashExecution",
|
|
171
|
+
content: [
|
|
172
|
+
{
|
|
173
|
+
type: "bash",
|
|
174
|
+
command: m.command,
|
|
175
|
+
output: text,
|
|
176
|
+
exitCode: m.exitCode,
|
|
177
|
+
cancelled: m.cancelled,
|
|
178
|
+
truncated,
|
|
179
|
+
},
|
|
180
|
+
],
|
|
181
|
+
timestamp: m.timestamp,
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
case "custom": {
|
|
185
|
+
// Third-party extension messages with display:false are UI-hidden
|
|
186
|
+
// (they still go into LLM context — the SDK handles that).
|
|
187
|
+
if (m.display === false) {
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
const content = serializeUserContent(m.content);
|
|
191
|
+
return {
|
|
192
|
+
id: `c-${m.timestamp}-${seq}`,
|
|
193
|
+
role: "custom",
|
|
194
|
+
content,
|
|
195
|
+
customType: m.customType,
|
|
196
|
+
details: m.details,
|
|
197
|
+
timestamp: m.timestamp,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
case "branchSummary": {
|
|
201
|
+
const { text, truncated } = truncate(m.summary, TEXT_CAP);
|
|
202
|
+
return {
|
|
203
|
+
id: `bs-${m.timestamp}-${seq}`,
|
|
204
|
+
role: "branchSummary",
|
|
205
|
+
content: [{ type: "text", text, truncated }],
|
|
206
|
+
timestamp: m.timestamp,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
case "compactionSummary": {
|
|
210
|
+
const { text, truncated } = truncate(m.summary, TEXT_CAP);
|
|
211
|
+
return {
|
|
212
|
+
id: `cs-${m.timestamp}-${seq}`,
|
|
213
|
+
role: "compactionSummary",
|
|
214
|
+
content: [{ type: "text", text, truncated }],
|
|
215
|
+
timestamp: m.timestamp,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
default:
|
|
219
|
+
return {
|
|
220
|
+
id: `x-${seq}`,
|
|
221
|
+
role: String(m.role ?? "unknown"),
|
|
222
|
+
content: [],
|
|
223
|
+
timestamp: m.timestamp,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Serialize the in-progress assistant message (agent.state.streamingMessage).
|
|
229
|
+
*
|
|
230
|
+
* Unlike persisted messages, the id must be STABLE across snapshots: the SDK
|
|
231
|
+
* replaces the partial object on every stream event, so a seq-based id would
|
|
232
|
+
* remount the React component (and collapse open thinking/tool blocks) every
|
|
233
|
+
* 60ms. The timestamp is fixed at message creation, so `stream-<ts>` stays
|
|
234
|
+
* constant for the whole stream.
|
|
235
|
+
*/
|
|
236
|
+
export function serializeStreamingMessage(m) {
|
|
237
|
+
const msg = serializeMessage(m, 0);
|
|
238
|
+
if (!msg)
|
|
239
|
+
return null;
|
|
240
|
+
return { ...msg, id: `stream-${m.timestamp ?? 0}` };
|
|
241
|
+
}
|
|
242
|
+
/** Stable discriminator for messages sharing a role and millisecond timestamp. */
|
|
243
|
+
const fingerprints = new WeakMap();
|
|
244
|
+
export function contentFingerprint(message) {
|
|
245
|
+
const cached = fingerprints.get(message);
|
|
246
|
+
if (cached)
|
|
247
|
+
return cached;
|
|
248
|
+
// Persisted messages are immutable. Hash all blocks once, including image
|
|
249
|
+
// bytes, thinking, tool arguments and custom metadata; a prefix/length is
|
|
250
|
+
// not an identity. Streaming messages never use this cache.
|
|
251
|
+
const fingerprint = createHash("sha256").update(JSON.stringify(message)).digest("hex");
|
|
252
|
+
fingerprints.set(message, fingerprint);
|
|
253
|
+
return fingerprint;
|
|
254
|
+
}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { statSync } from "node:fs";
|
|
2
|
+
import { open, readFile, stat } from "node:fs/promises";
|
|
3
|
+
import { setImmediate as yieldLoop } from "node:timers/promises";
|
|
4
|
+
import { Worker } from "node:worker_threads";
|
|
5
|
+
import { StringDecoder } from "node:string_decoder";
|
|
6
|
+
import { isDeepStrictEqual } from "node:util";
|
|
7
|
+
import { parseSessionEntries } from "@earendil-works/pi-coding-agent";
|
|
8
|
+
const stamp = (s) => `${s.dev}:${s.ino}:${s.size}:${s.mtimeMs}:${s.ctimeMs}`;
|
|
9
|
+
const matches = (native, disk) => native !== undefined && isDeepStrictEqual(JSON.parse(JSON.stringify(native)), disk);
|
|
10
|
+
/** Verify the baseline once, then read only appended bytes except for equal-size stamp changes. */
|
|
11
|
+
export class SessionTailValidator {
|
|
12
|
+
path;
|
|
13
|
+
changed;
|
|
14
|
+
previous;
|
|
15
|
+
verified = new Set();
|
|
16
|
+
invalid = false;
|
|
17
|
+
missing = false;
|
|
18
|
+
disposed = false;
|
|
19
|
+
pending;
|
|
20
|
+
worker;
|
|
21
|
+
get checking() { return !!this.pending; }
|
|
22
|
+
blockingCheck = false;
|
|
23
|
+
get blocking() { return this.checking && this.blockingCheck; }
|
|
24
|
+
dispose() { this.disposed = true; void this.worker?.terminate(); }
|
|
25
|
+
async ready() { return this.pending ?? !this.invalid; }
|
|
26
|
+
async verify(source) { return this.check(source) ?? this.ready(); }
|
|
27
|
+
/** Includes baseline I/O; callers can measure subsequent reads by subtracting the initial value. */
|
|
28
|
+
bytesRead = 0;
|
|
29
|
+
constructor(path, source, changed = () => { }) {
|
|
30
|
+
this.path = path;
|
|
31
|
+
this.changed = changed;
|
|
32
|
+
this.check(source);
|
|
33
|
+
}
|
|
34
|
+
check(source) {
|
|
35
|
+
if (this.invalid || this.disposed)
|
|
36
|
+
return false;
|
|
37
|
+
if (this.pending)
|
|
38
|
+
return undefined;
|
|
39
|
+
this.blockingCheck = true;
|
|
40
|
+
try {
|
|
41
|
+
const current = statSync(this.path);
|
|
42
|
+
this.blockingCheck = !this.previous || current.size <= this.previous.size || current.ino !== this.previous.ino || current.dev !== this.previous.dev;
|
|
43
|
+
if (this.previous && stamp(this.previous) === stamp(current))
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
if (this.missing && error.code === "ENOENT")
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
const finish = (valid) => {
|
|
51
|
+
this.pending = undefined;
|
|
52
|
+
if (this.disposed)
|
|
53
|
+
return false;
|
|
54
|
+
this.invalid = !valid;
|
|
55
|
+
if (this.blockingCheck || !valid)
|
|
56
|
+
this.changed();
|
|
57
|
+
return valid;
|
|
58
|
+
};
|
|
59
|
+
this.pending = this.validate(source).then(finish, () => finish(false));
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
compareInWorker(request) {
|
|
63
|
+
const worker = this.worker ??= new Worker(new URL(import.meta.url.endsWith(".ts") ? "./session-record-worker.ts" : "./session-record-worker.js", import.meta.url), { execArgv: process.execArgv.filter(arg => !arg.startsWith("--watch")) });
|
|
64
|
+
return new Promise((resolve, reject) => {
|
|
65
|
+
const cleanup = () => { worker.off("message", message); worker.off("error", failed); worker.off("exit", exited); };
|
|
66
|
+
const failed = (error) => { cleanup(); reject(error); };
|
|
67
|
+
const exited = () => failed(new Error("Record validation cancelled"));
|
|
68
|
+
const message = (result) => { cleanup(); if (result.error)
|
|
69
|
+
reject(new Error("Invalid session record"));
|
|
70
|
+
else
|
|
71
|
+
resolve(result); };
|
|
72
|
+
worker.once("message", message);
|
|
73
|
+
worker.once("error", failed);
|
|
74
|
+
worker.once("exit", exited);
|
|
75
|
+
worker.postMessage(request);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
async validate(source) {
|
|
79
|
+
let handle;
|
|
80
|
+
let observed = false;
|
|
81
|
+
try {
|
|
82
|
+
const current = await stat(this.path);
|
|
83
|
+
observed = true;
|
|
84
|
+
const previous = this.previous;
|
|
85
|
+
if (previous && stamp(previous) === stamp(current))
|
|
86
|
+
return true;
|
|
87
|
+
if (previous && (previous.ino !== current.ino || previous.dev !== current.dev || current.size < previous.size))
|
|
88
|
+
return false;
|
|
89
|
+
const full = !previous || current.size === previous.size;
|
|
90
|
+
const offset = full ? 0 : previous.size;
|
|
91
|
+
const expected = full ? [source.getHeader(), ...source.getEntries()] : undefined;
|
|
92
|
+
const added = new Set();
|
|
93
|
+
let index = 0;
|
|
94
|
+
const accept = async (line) => {
|
|
95
|
+
if (!line.trim())
|
|
96
|
+
return true;
|
|
97
|
+
let id, equal;
|
|
98
|
+
if (line.length > 256 * 1024) {
|
|
99
|
+
({ id } = await this.compareInWorker({ text: line }));
|
|
100
|
+
const native = full ? expected[index] : typeof id === "string" ? source.getEntry(id) : undefined;
|
|
101
|
+
equal = (await this.compareInWorker({ native })).equal === true;
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
const entry = JSON.parse(line);
|
|
105
|
+
id = entry?.id;
|
|
106
|
+
equal = matches(full ? expected[index] : typeof id === "string" ? source.getEntry(id) : undefined, entry);
|
|
107
|
+
}
|
|
108
|
+
if (!equal || (!full && typeof id === "string" && this.verified.has(id)))
|
|
109
|
+
return false;
|
|
110
|
+
if (!(full && index === 0)) {
|
|
111
|
+
if (typeof id !== "string" || added.has(id))
|
|
112
|
+
return false;
|
|
113
|
+
added.add(id);
|
|
114
|
+
}
|
|
115
|
+
index++;
|
|
116
|
+
return true;
|
|
117
|
+
};
|
|
118
|
+
handle = await open(this.path, "r");
|
|
119
|
+
const opened = await handle.stat();
|
|
120
|
+
if (stamp(opened) !== stamp(current)) {
|
|
121
|
+
if (opened.ino !== current.ino || opened.dev !== current.dev || opened.size < current.size)
|
|
122
|
+
return false;
|
|
123
|
+
await handle.close();
|
|
124
|
+
handle = undefined;
|
|
125
|
+
return this.disposed ? false : this.validate(source);
|
|
126
|
+
}
|
|
127
|
+
const buffer = Buffer.alloc(64 * 1024), decoder = new StringDecoder("utf8");
|
|
128
|
+
let position = offset;
|
|
129
|
+
let fragments = [];
|
|
130
|
+
while (position < current.size) {
|
|
131
|
+
if (this.disposed)
|
|
132
|
+
return false;
|
|
133
|
+
const { bytesRead: n } = await handle.read(buffer, 0, Math.min(buffer.length, current.size - position), position);
|
|
134
|
+
if (!n)
|
|
135
|
+
return false;
|
|
136
|
+
position += n;
|
|
137
|
+
this.bytesRead += n;
|
|
138
|
+
const text = decoder.write(buffer.subarray(0, n));
|
|
139
|
+
let start = 0, newline;
|
|
140
|
+
while ((newline = text.indexOf("\n", start)) !== -1) {
|
|
141
|
+
fragments.push(text.slice(start, newline));
|
|
142
|
+
if (!await accept(fragments.join("")))
|
|
143
|
+
return false;
|
|
144
|
+
fragments = [];
|
|
145
|
+
start = newline + 1;
|
|
146
|
+
}
|
|
147
|
+
if (start < text.length)
|
|
148
|
+
fragments.push(text.slice(start));
|
|
149
|
+
await yieldLoop();
|
|
150
|
+
}
|
|
151
|
+
const after = await stat(this.path);
|
|
152
|
+
if (stamp(await handle.stat()) !== stamp(current) || stamp(after) !== stamp(current)) {
|
|
153
|
+
if (after.ino !== current.ino || after.dev !== current.dev || after.size < current.size)
|
|
154
|
+
return false;
|
|
155
|
+
await handle.close();
|
|
156
|
+
handle = undefined;
|
|
157
|
+
// Native writes may continue during metadata verification. Retry against
|
|
158
|
+
// the new snapshot instead of treating our own append as a conflict.
|
|
159
|
+
return this.disposed ? false : this.validate(source);
|
|
160
|
+
}
|
|
161
|
+
if (decoder.end() || fragments.length || !index || (expected && index !== expected.length))
|
|
162
|
+
return false;
|
|
163
|
+
if (full)
|
|
164
|
+
this.verified = added;
|
|
165
|
+
else
|
|
166
|
+
for (const id of added)
|
|
167
|
+
this.verified.add(id);
|
|
168
|
+
this.previous = current;
|
|
169
|
+
this.missing = false;
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
this.missing = !observed && !this.previous && error.code === "ENOENT";
|
|
174
|
+
return this.missing;
|
|
175
|
+
}
|
|
176
|
+
finally {
|
|
177
|
+
await handle?.close();
|
|
178
|
+
if (this.worker) {
|
|
179
|
+
const worker = this.worker;
|
|
180
|
+
this.worker = undefined;
|
|
181
|
+
await worker.terminate();
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
/** Listing must never instantiate a SessionManager: open() can migrate and rewrite files. */
|
|
187
|
+
export class SessionBranchCounts {
|
|
188
|
+
cache = new Map();
|
|
189
|
+
async getMany(paths) {
|
|
190
|
+
const results = new Array(paths.length);
|
|
191
|
+
let next = 0;
|
|
192
|
+
await Promise.all(Array.from({ length: Math.min(8, paths.length) }, async () => {
|
|
193
|
+
while (next < paths.length) {
|
|
194
|
+
const index = next++;
|
|
195
|
+
results[index] = await this.get(paths[index]);
|
|
196
|
+
}
|
|
197
|
+
}));
|
|
198
|
+
return results;
|
|
199
|
+
}
|
|
200
|
+
async get(path) {
|
|
201
|
+
try {
|
|
202
|
+
const before = await stat(path), key = stamp(before);
|
|
203
|
+
const cached = this.cache.get(path);
|
|
204
|
+
if (cached?.stamp === key)
|
|
205
|
+
return cached.count;
|
|
206
|
+
const entries = parseSessionEntries(await readFile(path, "utf8"));
|
|
207
|
+
if (stamp(await stat(path)) !== key)
|
|
208
|
+
return undefined;
|
|
209
|
+
const parents = new Map();
|
|
210
|
+
for (const entry of entries)
|
|
211
|
+
if ("parentId" in entry && entry.parentId)
|
|
212
|
+
parents.set(entry.parentId, (parents.get(entry.parentId) ?? 0) + 1);
|
|
213
|
+
const count = [...parents.values()].filter(n => n > 1).length;
|
|
214
|
+
this.cache.delete(path);
|
|
215
|
+
this.cache.set(path, { stamp: key, count });
|
|
216
|
+
if (this.cache.size > 1000)
|
|
217
|
+
this.cache.delete(this.cache.keys().next().value);
|
|
218
|
+
return count;
|
|
219
|
+
}
|
|
220
|
+
catch {
|
|
221
|
+
this.cache.delete(path);
|
|
222
|
+
return undefined;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { parentPort } from "node:worker_threads";
|
|
2
|
+
import { isDeepStrictEqual } from "node:util";
|
|
3
|
+
// Large JSON records are parsed and compared away from the server event loop.
|
|
4
|
+
let record;
|
|
5
|
+
parentPort.on("message", (request) => {
|
|
6
|
+
try {
|
|
7
|
+
if ("text" in request) {
|
|
8
|
+
record = JSON.parse(request.text);
|
|
9
|
+
parentPort.postMessage({ id: record?.id });
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
const equal = request.native !== undefined && isDeepStrictEqual(JSON.parse(JSON.stringify(request.native)), record);
|
|
13
|
+
record = undefined;
|
|
14
|
+
parentPort.postMessage({ equal });
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
record = undefined;
|
|
19
|
+
parentPort.postMessage({ error: true });
|
|
20
|
+
}
|
|
21
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const pending = new WeakMap();
|
|
2
|
+
/** Host reload entry points share one queue per native session. A failed
|
|
3
|
+
* reload is reported to its caller without poisoning later retries. */
|
|
4
|
+
export function reloadSession(session) {
|
|
5
|
+
const previous = pending.get(session) ?? Promise.resolve();
|
|
6
|
+
const operation = previous.catch(() => { }).then(() => session.reload());
|
|
7
|
+
pending.set(session, operation);
|
|
8
|
+
void operation.finally(() => {
|
|
9
|
+
if (pending.get(session) === operation)
|
|
10
|
+
pending.delete(session);
|
|
11
|
+
}).catch(() => { });
|
|
12
|
+
return operation;
|
|
13
|
+
}
|