@youweichen/pi-harness 0.0.0-stage → 1.0.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 +3051 -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 +177 -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 +187 -0
- package/dist/server/files-service.js +795 -0
- package/dist/server/index.js +1029 -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-sources.js +142 -0
- package/dist/server/node-workbench.js +668 -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 +113 -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 +280 -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 +177 -0
- package/dist/server/wiki-service.js +511 -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-C4U1PldE.js +3 -0
- package/web/dist/assets/TerminalPanel-CWh6vw_N.js +2 -0
- package/web/dist/assets/abnfDiagram-VCTEODGH-D5Ti0Kpa.js +1 -0
- package/web/dist/assets/arc-DKJilLd6.js +1 -0
- package/web/dist/assets/architectureDiagram-5GKGNRK7-Cf0w38g-.js +36 -0
- package/web/dist/assets/blockDiagram-I7D4REHJ-BOTLWLIL.js +129 -0
- package/web/dist/assets/c4Diagram-7LVT6UL2-CLCCoJs3.js +38 -0
- package/web/dist/assets/channel-D8Hd7T4P.js +1 -0
- package/web/dist/assets/chunk-2Q5K7J3B-BHjga2Ge.js +1 -0
- package/web/dist/assets/chunk-5VM5RSS4-CQJ5VfDZ.js +15 -0
- package/web/dist/assets/chunk-F27PBJKO-C67qoPJH.js +1 -0
- package/web/dist/assets/chunk-IMKFNOWR-CgXXGwI8.js +231 -0
- package/web/dist/assets/chunk-JWPE2WC7-D0RPyByP.js +1 -0
- package/web/dist/assets/chunk-POPQ4Y6H-BeYC9s9x.js +1 -0
- package/web/dist/assets/chunk-SVP7TREG-eQPl4UBQ.js +88 -0
- package/web/dist/assets/chunk-TICWLB2K-DT73arPU.js +206 -0
- package/web/dist/assets/chunk-XXDRQBXY-B4FwQcP-.js +1 -0
- package/web/dist/assets/classDiagram-ZZMXUADV-B_btgYRB.js +1 -0
- package/web/dist/assets/classDiagram-v2-VYDZK3BY-B_btgYRB.js +1 -0
- package/web/dist/assets/cose-bilkent-JH36ORCC-Bnn5nlQN.js +1 -0
- package/web/dist/assets/cynefin-OW5HDTMX-CStWX9kE.js +178 -0
- package/web/dist/assets/cynefinDiagram-5FMLGOSQ-BMVHC03f.js +62 -0
- package/web/dist/assets/cytoscape.esm-Bch-eiPH.js +331 -0
- package/web/dist/assets/dagre-GXQ25YYZ-ClSaO4ml.js +4 -0
- package/web/dist/assets/defaultLocale-DX6XiGOO.js +1 -0
- package/web/dist/assets/diagram-S7CK7UJ4-C43LL08C.js +30 -0
- package/web/dist/assets/diagram-UQ7AKVKN-BPVn_ySW.js +41 -0
- package/web/dist/assets/diagram-VSXAHHWV-C34FFhRi.js +3 -0
- package/web/dist/assets/diagram-VX7I27RA-BRk4bncf.js +24 -0
- package/web/dist/assets/diagram-Z3DM3KII-O5hYPLEd.js +24 -0
- package/web/dist/assets/ebnfDiagram-PWID7BFC-DVGEBm99.js +1 -0
- package/web/dist/assets/erDiagram-RLTQ6QDP-M-BLpTEV.js +99 -0
- package/web/dist/assets/flowDiagram-HODETNUW-BwdLopEx.js +168 -0
- package/web/dist/assets/ganttDiagram-EL5Y4UJY-DYxx2ppA.js +292 -0
- package/web/dist/assets/gitGraphDiagram-WWUBYQGX-DUU0wMYB.js +106 -0
- package/web/dist/assets/index-CI2KfVSr.css +10 -0
- package/web/dist/assets/index-DQcpggFU.js +275 -0
- package/web/dist/assets/infoDiagram-27XIBGKW-CFaW5C0C.js +2 -0
- package/web/dist/assets/init-Gi6I4Gst.js +1 -0
- package/web/dist/assets/ishikawaDiagram-5VMMS53U--ENP1MTB.js +70 -0
- package/web/dist/assets/journeyDiagram-3NMN7TZE-DgnAzSTj.js +139 -0
- package/web/dist/assets/kanban-definition-UXKFOSKX-_STZN1vU.js +89 -0
- package/web/dist/assets/katex-C5jXJg4s.js +257 -0
- package/web/dist/assets/layout-CkUClkXt.js +1 -0
- package/web/dist/assets/linear-sYHiUOxa.js +1 -0
- package/web/dist/assets/markdown-vNTCZJ6d.js +51 -0
- package/web/dist/assets/mermaid.core-B8fKGWsc.js +312 -0
- package/web/dist/assets/mindmap-definition-YA3MSWOX-DP0BYOEx.js +96 -0
- package/web/dist/assets/ordinal-Cboi1Yqb.js +1 -0
- package/web/dist/assets/pegDiagram-XKGWAZYB-DkWTmZre.js +1 -0
- package/web/dist/assets/pieDiagram-E7YTZNPT-DfZgMV4u.js +39 -0
- package/web/dist/assets/quadrantDiagram-AXDQQJYC-Djl4TT7q.js +7 -0
- package/web/dist/assets/railroadDiagram-O6MQD6OU-DbKF6zXn.js +1 -0
- package/web/dist/assets/react-BNj3n7jX.js +24 -0
- package/web/dist/assets/requirementDiagram-BXWQKSXE-idola5qb.js +84 -0
- package/web/dist/assets/sankeyDiagram-P5KCCOFB-KA0hQOle.js +40 -0
- package/web/dist/assets/sequenceDiagram-WJ2MYXX4-BXSKvxzP.js +162 -0
- package/web/dist/assets/sizeCapture-INFHLROL-C_Ewv3S5.js +1 -0
- package/web/dist/assets/stateDiagram-D77RDMKH-DIf5X8oo.js +1 -0
- package/web/dist/assets/stateDiagram-v2-MP3YSRHH-DYwe_2mB.js +1 -0
- package/web/dist/assets/swimlanes-42K2YHIH-Cx_Rc8M2.js +1 -0
- package/web/dist/assets/swimlanesDiagram-VR7AAH4N-52Y8tgRV.js +8 -0
- package/web/dist/assets/timeline-definition-24CTP7MA-BRrDhWVz.js +120 -0
- package/web/dist/assets/vennDiagram-4TSXK5OY-Ad6G0YwD.js +34 -0
- package/web/dist/assets/wardleyDiagram-VM6X3IG4-X6-ENpSi.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-DhegNS6d.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,28 @@
|
|
|
1
|
+
import { chmodSync, mkdirSync, renameSync, statSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname } from "node:path";
|
|
3
|
+
/**
|
|
4
|
+
* Atomic write (tmp + rename) of a file that may hold secrets or personal state:
|
|
5
|
+
* new directories are 0700, the file is 0600 unless told otherwise, and a crash
|
|
6
|
+
* mid-write never leaves a truncated file.
|
|
7
|
+
*/
|
|
8
|
+
export function writeFileAtomic(path, data, options = {}) {
|
|
9
|
+
mkdirSync(dirname(path), { recursive: true, mode: 0o700 });
|
|
10
|
+
let mode = options.mode ?? 0o600;
|
|
11
|
+
if (options.keepExistingMode) {
|
|
12
|
+
try {
|
|
13
|
+
mode = statSync(path).mode & 0o777;
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
/* new file */
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const tmp = `${path}.${process.pid}.tmp`;
|
|
20
|
+
writeFileSync(tmp, data, { mode });
|
|
21
|
+
try {
|
|
22
|
+
chmodSync(tmp, mode); // the create mode is masked by umask; make it exact
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
/* best effort on Windows */
|
|
26
|
+
}
|
|
27
|
+
renameSync(tmp, path);
|
|
28
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* process-utils — 跨平台进程工具:监听端口快照、进程树查杀、进程名查询。
|
|
3
|
+
* 后台任务面板(bgServers)用它们检测/停止 agent 在后台拉起的服务。
|
|
4
|
+
* 从 agent-service.ts 抽出,行为保持不变。全平台 best-effort:失败静默。
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Snapshot currently LISTENING TCP ports → owning pid. Windows: netstat;
|
|
8
|
+
* POSIX: lsof. Used to detect servers the agent started in the background
|
|
9
|
+
* (the bash tool itself exits, leaving e.g. `npm run dev &` listening).
|
|
10
|
+
*/
|
|
11
|
+
export async function snapshotListeningPorts() {
|
|
12
|
+
const m = new Map();
|
|
13
|
+
try {
|
|
14
|
+
const { execFile } = await import("node:child_process");
|
|
15
|
+
if (process.platform === "win32") {
|
|
16
|
+
const out = await new Promise((resolve, reject) => execFile("netstat", ["-ano", "-p", "tcp"], { windowsHide: true, timeout: 8000 }, (err, stdout) => (err ? reject(err) : resolve(stdout))));
|
|
17
|
+
for (const line of out.split(/\r?\n/)) {
|
|
18
|
+
const p = line.trim().split(/\s+/);
|
|
19
|
+
// TCP 0.0.0.0:5173 0.0.0.0:0 LISTENING 12345
|
|
20
|
+
if (p.length >= 5 && p[0] === "TCP" && p[3] === "LISTENING") {
|
|
21
|
+
const port = Number(p[1].split(":").pop());
|
|
22
|
+
const pid = Number(p[4]);
|
|
23
|
+
if (Number.isFinite(port) && Number.isFinite(pid))
|
|
24
|
+
m.set(port, pid);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
const out = await new Promise((resolve, reject) => execFile("lsof", ["-iTCP", "-sTCP:LISTEN", "-P", "-n"], { timeout: 8000 }, (err, stdout) => (err ? reject(err) : resolve(stdout))));
|
|
30
|
+
for (const line of out.split(/\r?\n/).slice(1)) {
|
|
31
|
+
const p = line.trim().split(/\s+/);
|
|
32
|
+
if (p.length >= 9) {
|
|
33
|
+
// NAME column tail: "*:5173 (LISTEN)" or "[::1]:5173 (LISTEN)"
|
|
34
|
+
const mm = (p[p.length - 1] ?? "").match(/(\d+)\)?\s*$/);
|
|
35
|
+
const port = mm ? Number(mm[1]) : NaN;
|
|
36
|
+
const pid = Number(p[1]);
|
|
37
|
+
if (Number.isFinite(port) && Number.isFinite(pid))
|
|
38
|
+
m.set(port, pid);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
// best effort — snapshot failure just means no tracking this round
|
|
45
|
+
}
|
|
46
|
+
return m;
|
|
47
|
+
}
|
|
48
|
+
/** Kill a pid and its whole process tree (cross-platform). */
|
|
49
|
+
export function killPidTree(pid) {
|
|
50
|
+
try {
|
|
51
|
+
if (process.platform === "win32") {
|
|
52
|
+
void import("node:child_process").then(({ spawn }) => {
|
|
53
|
+
spawn("taskkill", ["/F", "/T", "/PID", String(pid)], {
|
|
54
|
+
stdio: "ignore",
|
|
55
|
+
detached: true,
|
|
56
|
+
windowsHide: true,
|
|
57
|
+
}).unref();
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
process.kill(-pid, "SIGKILL");
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
// already dead
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/** Best-effort full command line of a pid (PowerShell CIM on win32 — wmic is
|
|
69
|
+
* gone on recent Win11 builds; ps -o command= on POSIX). Returns undefined
|
|
70
|
+
* when the process is gone or the lookup fails. */
|
|
71
|
+
export async function lookupProcessCommandLine(pid) {
|
|
72
|
+
try {
|
|
73
|
+
const { execFile } = await import("node:child_process");
|
|
74
|
+
if (process.platform === "win32") {
|
|
75
|
+
// CIM query is slower (~1s) than tasklist but this is a one-shot
|
|
76
|
+
// best-effort probe fired once per detected background server.
|
|
77
|
+
const out = await new Promise((resolve, reject) => execFile("powershell.exe", [
|
|
78
|
+
"-NoProfile",
|
|
79
|
+
"-NonInteractive",
|
|
80
|
+
"-Command",
|
|
81
|
+
`(Get-CimInstance Win32_Process -Filter 'ProcessId=${pid}').CommandLine`,
|
|
82
|
+
], { windowsHide: true, timeout: 10000 }, (err, stdout) => (err ? reject(err) : resolve(stdout))));
|
|
83
|
+
const line = out.trim();
|
|
84
|
+
return line || undefined;
|
|
85
|
+
}
|
|
86
|
+
const out = await new Promise((resolve, reject) => execFile("ps", ["-o", "command=", "-p", String(pid)], { timeout: 4000 }, (err, stdout) => (err ? reject(err) : resolve(stdout))));
|
|
87
|
+
const line = out.trim();
|
|
88
|
+
return line || undefined;
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/** Best-effort process name for a pid (tasklist on win32, ps on POSIX).
|
|
95
|
+
* Returns undefined when the process is gone or the lookup fails. */
|
|
96
|
+
export async function lookupProcessName(pid) {
|
|
97
|
+
try {
|
|
98
|
+
const { execFile } = await import("node:child_process");
|
|
99
|
+
if (process.platform === "win32") {
|
|
100
|
+
const out = await new Promise((resolve, reject) => execFile("tasklist", ["/FI", `PID eq ${pid}`, "/FO", "CSV", "/NH"], { windowsHide: true, timeout: 4000 }, (err, stdout) => (err ? reject(err) : resolve(stdout))));
|
|
101
|
+
// CSV: "node.exe","12345",...
|
|
102
|
+
const m = out.match(/"([^"]+)"/);
|
|
103
|
+
return m ? m[1] : undefined;
|
|
104
|
+
}
|
|
105
|
+
const out = await new Promise((resolve, reject) => execFile("ps", ["-o", "comm=", "-p", String(pid)], { timeout: 4000 }, (err, stdout) => (err ? reject(err) : resolve(stdout))));
|
|
106
|
+
const name = out.trim();
|
|
107
|
+
return name || undefined;
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
return undefined;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { expandNativeTemplate } from "./native-prompt-template.js";
|
|
2
|
+
const imagesBySession = new WeakMap();
|
|
3
|
+
/** A question and its attachments occupy ONE native queue item. Never override
|
|
4
|
+
* the user's queue modes or enqueue context that could reach another prompt. */
|
|
5
|
+
export function promptWithAttachments(text, asides) {
|
|
6
|
+
const content = asides.flatMap(({ message }) => typeof message.content === "string" ? [{ type: "text", text: message.content }] : message.content);
|
|
7
|
+
// Native skill parsing separates the command from arguments with a
|
|
8
|
+
// literal space. Keep that separator when attaching context to a bare command.
|
|
9
|
+
const question = content.some(block => block.type === "text") && /^\/\S+$/.test(text) ? `${text} ` : text;
|
|
10
|
+
return {
|
|
11
|
+
text: [question, ...content.flatMap(block => block.type === "text" ? [block.text] : [])].join("\n\n"),
|
|
12
|
+
images: content.filter((block) => block.type === "image"),
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export async function deliverPrompt(session, text, asides, queue, acknowledge) {
|
|
16
|
+
// Extension commands run immediately and own their input/turn. Preserve the
|
|
17
|
+
// original command text instead of turning attachments into command arguments.
|
|
18
|
+
const command = text.startsWith("/") ? session.extensionRunner.getCommand(text.slice(1).split(" ", 1)[0]) : undefined;
|
|
19
|
+
const template = !command && text.startsWith("/") && session.promptTemplates.some(t => t.name === text.slice(1).split(/\s/, 1)[0]) && asides.some(({ message }) => typeof message.content === "string" || message.content.some(b => b.type === "text"));
|
|
20
|
+
if (command) {
|
|
21
|
+
let failed = false;
|
|
22
|
+
const off = session.extensionRunner.onError(error => { if (error.event === "command")
|
|
23
|
+
failed = true; });
|
|
24
|
+
try {
|
|
25
|
+
await session.prompt(text);
|
|
26
|
+
acknowledge(!failed, !failed);
|
|
27
|
+
}
|
|
28
|
+
finally {
|
|
29
|
+
off();
|
|
30
|
+
}
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const input = promptWithAttachments(template ? await expandNativeTemplate(text, session.promptTemplates) : text, command ? [] : asides);
|
|
34
|
+
let pending = imagesBySession.get(session);
|
|
35
|
+
if (!pending) {
|
|
36
|
+
pending = { steering: [], followUp: [] };
|
|
37
|
+
imagesBySession.set(session, pending);
|
|
38
|
+
const records = pending;
|
|
39
|
+
const unsubscribe = session.subscribe(event => {
|
|
40
|
+
if (event.type === "queue_update") {
|
|
41
|
+
// SDK consumes the first matching text. Keep the remaining suffix
|
|
42
|
+
// for duplicate prompts, including prompts without image attachments.
|
|
43
|
+
for (const lane of ["steering", "followUp"]) {
|
|
44
|
+
const counts = new Map();
|
|
45
|
+
for (const text of event[lane])
|
|
46
|
+
counts.set(text, (counts.get(text) ?? 0) + 1);
|
|
47
|
+
records[lane] = records[lane].slice().reverse().filter(record => {
|
|
48
|
+
const count = counts.get(record.text) ?? 0;
|
|
49
|
+
counts.set(record.text, count - 1);
|
|
50
|
+
return count > 0;
|
|
51
|
+
}).reverse();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (event.type === "agent_settled") {
|
|
55
|
+
imagesBySession.delete(session);
|
|
56
|
+
unsubscribe();
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
await session.prompt(input.text, {
|
|
61
|
+
expandPromptTemplates: !template,
|
|
62
|
+
images: input.images, streamingBehavior: queue ? "followUp" : "steer",
|
|
63
|
+
preflightResult: disposition => {
|
|
64
|
+
if (disposition === "queued") {
|
|
65
|
+
const lane = queue ? "followUp" : "steering";
|
|
66
|
+
const native = queue ? session.getFollowUpMessages() : session.getSteeringMessages();
|
|
67
|
+
const accepted = native.at(-1);
|
|
68
|
+
if (accepted !== undefined)
|
|
69
|
+
pending[lane].push({ text: accepted, images: input.images });
|
|
70
|
+
}
|
|
71
|
+
acknowledge(disposition !== "handled");
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/** Snapshot attachments before clearQueue emits the empty native queue. */
|
|
76
|
+
export function recallPending(session) {
|
|
77
|
+
const pending = imagesBySession.get(session);
|
|
78
|
+
const images = pending ? [...pending.steering, ...pending.followUp].flatMap(record => record.images) : [];
|
|
79
|
+
return { ...session.clearQueue(), images };
|
|
80
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire-protocol version. Bump whenever a protocol change would make an old
|
|
3
|
+
* browser tab talk to a newer server (or vice versa) in a broken way — the
|
|
4
|
+
* classic symptom is "UI is new, WS handling is old" after an in-place app
|
|
5
|
+
* update before the auto-restart completes.
|
|
6
|
+
*
|
|
7
|
+
* Lives OUTSIDE protocol.ts (which must stay pure types). The frontend keeps
|
|
8
|
+
* its own copy in web/src/protocol-version.ts; scripts/check-protocol-sync.mjs
|
|
9
|
+
* verifies the two never drift.
|
|
10
|
+
*/
|
|
11
|
+
export const PROTOCOL_VERSION = 41;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
/** Bridge official provider login; credentials remain entirely inside ModelRuntime. */
|
|
3
|
+
export class ProviderAuthService {
|
|
4
|
+
runtime;
|
|
5
|
+
emit;
|
|
6
|
+
changed;
|
|
7
|
+
getDeviceId;
|
|
8
|
+
controller;
|
|
9
|
+
pending;
|
|
10
|
+
state = null;
|
|
11
|
+
constructor(runtime, emit, changed, getDeviceId) {
|
|
12
|
+
this.runtime = runtime;
|
|
13
|
+
this.emit = emit;
|
|
14
|
+
this.changed = changed;
|
|
15
|
+
this.getDeviceId = getDeviceId;
|
|
16
|
+
}
|
|
17
|
+
replay() { if (this.state)
|
|
18
|
+
this.emit({ type: "provider_auth", state: this.state }); }
|
|
19
|
+
respond(requestId, promptId, value) {
|
|
20
|
+
if (this.state?.requestId === requestId && this.pending?.id === promptId)
|
|
21
|
+
this.pending.resolve(value);
|
|
22
|
+
}
|
|
23
|
+
cancel(requestId) {
|
|
24
|
+
if (!requestId || this.state?.requestId === requestId)
|
|
25
|
+
this.controller?.abort();
|
|
26
|
+
}
|
|
27
|
+
async logout(provider) {
|
|
28
|
+
this.cancel();
|
|
29
|
+
try {
|
|
30
|
+
await this.runtime().logout(provider);
|
|
31
|
+
await this.changed();
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
this.emit({ type: "notice", level: "error", text: error instanceof Error ? error.message : "Sign-out failed" });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
publish(state) { this.state = state; this.emit({ type: "provider_auth", state }); }
|
|
38
|
+
async login(provider) {
|
|
39
|
+
this.cancel();
|
|
40
|
+
const requestId = randomUUID(), controller = new AbortController();
|
|
41
|
+
this.controller = controller;
|
|
42
|
+
const signal = controller.signal;
|
|
43
|
+
const current = () => this.state?.requestId === requestId;
|
|
44
|
+
const update = (partial) => { if (current())
|
|
45
|
+
this.publish({ ...this.state, ...partial }); };
|
|
46
|
+
this.publish({ requestId, provider, phase: "pending" });
|
|
47
|
+
const deadline = setTimeout(() => controller.abort(), 10 * 60_000);
|
|
48
|
+
deadline.unref();
|
|
49
|
+
const interaction = {
|
|
50
|
+
signal,
|
|
51
|
+
notify: event => {
|
|
52
|
+
if (event.type === "auth_url")
|
|
53
|
+
update({ url: event.url, message: event.instructions });
|
|
54
|
+
else if (event.type === "device_code")
|
|
55
|
+
update({ url: event.verificationUri, code: event.userCode });
|
|
56
|
+
else
|
|
57
|
+
update({ message: event.message, ...(event.type === "info" && event.links?.length ? { url: event.links[0].url } : {}) });
|
|
58
|
+
},
|
|
59
|
+
prompt: prompt => new Promise((resolve, reject) => {
|
|
60
|
+
const promptId = randomUUID();
|
|
61
|
+
const combined = prompt.signal ? AbortSignal.any([signal, prompt.signal]) : signal;
|
|
62
|
+
const finish = (value) => {
|
|
63
|
+
combined.removeEventListener("abort", abort);
|
|
64
|
+
if (this.pending?.id === promptId)
|
|
65
|
+
this.pending = undefined;
|
|
66
|
+
if (current() && this.state?.prompt?.id === promptId)
|
|
67
|
+
update({ prompt: undefined });
|
|
68
|
+
if (value === undefined)
|
|
69
|
+
reject(new DOMException("Login cancelled", "AbortError"));
|
|
70
|
+
else
|
|
71
|
+
resolve(value);
|
|
72
|
+
};
|
|
73
|
+
const abort = () => finish();
|
|
74
|
+
if (combined.aborted) {
|
|
75
|
+
abort();
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
this.pending = { id: promptId, resolve: value => finish(value) };
|
|
79
|
+
combined.addEventListener("abort", abort, { once: true });
|
|
80
|
+
update({ prompt: { id: promptId, kind: prompt.type, message: prompt.message, ...(prompt.type === "select" ? { options: prompt.options.map(({ id, label }) => ({ id, label })) } : { placeholder: prompt.placeholder }) } });
|
|
81
|
+
}),
|
|
82
|
+
};
|
|
83
|
+
try {
|
|
84
|
+
if (!this.runtime().getProvider(provider)?.auth.oauth)
|
|
85
|
+
throw new Error("Provider does not support OAuth login");
|
|
86
|
+
await this.runtime().login(provider, "oauth", interaction, { getDeviceId: this.getDeviceId });
|
|
87
|
+
await this.changed();
|
|
88
|
+
update({ phase: "success", url: undefined, code: undefined, prompt: undefined, message: undefined });
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
update({ phase: signal.aborted ? "cancelled" : "error", message: signal.aborted ? undefined : error instanceof Error ? error.message : "Login failed", url: undefined, code: undefined, prompt: undefined });
|
|
92
|
+
}
|
|
93
|
+
finally {
|
|
94
|
+
clearTimeout(deadline);
|
|
95
|
+
if (this.controller === controller)
|
|
96
|
+
this.controller = undefined;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** TTL + stale-while-revalidate, with one in-flight scan per key. */
|
|
2
|
+
export class QueryCache {
|
|
3
|
+
ttl;
|
|
4
|
+
maxEntries;
|
|
5
|
+
entries = new Map();
|
|
6
|
+
constructor(ttl, maxEntries = 24) {
|
|
7
|
+
this.ttl = ttl;
|
|
8
|
+
this.maxEntries = maxEntries;
|
|
9
|
+
}
|
|
10
|
+
clear() { this.entries.clear(); }
|
|
11
|
+
async get(key, scan, refreshed) {
|
|
12
|
+
let entry = this.entries.get(key);
|
|
13
|
+
if (!entry) {
|
|
14
|
+
entry = { expires: 0 };
|
|
15
|
+
this.entries.set(key, entry);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
this.entries.delete(key);
|
|
19
|
+
this.entries.set(key, entry);
|
|
20
|
+
}
|
|
21
|
+
while (this.entries.size > this.maxEntries) {
|
|
22
|
+
this.entries.delete(this.entries.keys().next().value);
|
|
23
|
+
}
|
|
24
|
+
if (entry.value !== undefined && entry.expires > Date.now())
|
|
25
|
+
return entry.value;
|
|
26
|
+
if (!entry.pending) {
|
|
27
|
+
const current = entry;
|
|
28
|
+
const hadValue = current.value !== undefined;
|
|
29
|
+
current.pending = scan().then((value) => {
|
|
30
|
+
if (this.entries.get(key) === current) {
|
|
31
|
+
current.value = value;
|
|
32
|
+
current.expires = Date.now() + this.ttl;
|
|
33
|
+
if (hadValue)
|
|
34
|
+
refreshed?.(value);
|
|
35
|
+
}
|
|
36
|
+
return value;
|
|
37
|
+
}).finally(() => { current.pending = undefined; });
|
|
38
|
+
}
|
|
39
|
+
if (entry.value !== undefined) {
|
|
40
|
+
void entry.pending.catch(() => { });
|
|
41
|
+
return entry.value;
|
|
42
|
+
}
|
|
43
|
+
return entry.pending;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
/** Compaction and its summary retry have independent lifetimes. */
|
|
3
|
+
export function recoveryEvent(state, event, now = Date.now(), contextTokens) {
|
|
4
|
+
switch (event.type) {
|
|
5
|
+
case "compaction_start": return { ...state, lastCompaction: undefined, compaction: { id: randomUUID(), reason: event.reason, tokensBefore: contextTokens } };
|
|
6
|
+
case "compaction_end": return { ...state, compaction: undefined, lastCompaction: {
|
|
7
|
+
id: state.compaction?.id ?? randomUUID(), reason: event.reason,
|
|
8
|
+
status: event.aborted ? "aborted" : event.result ? "completed" : "error",
|
|
9
|
+
tokensBefore: event.result?.tokensBefore ?? state.compaction?.tokensBefore,
|
|
10
|
+
tokensAfter: event.result && !event.aborted ? contextTokens : undefined,
|
|
11
|
+
error: event.errorMessage?.slice(0, 500),
|
|
12
|
+
} };
|
|
13
|
+
case "auto_retry_start": return { ...state, retry: { id: randomUUID(), phase: "waiting", attempt: event.attempt, maxAttempts: event.maxAttempts, deadline: now + event.delayMs, error: event.errorMessage.slice(0, 500) } };
|
|
14
|
+
case "agent_start": return state.retry ? { ...state, retry: { ...state.retry, phase: "running" } } : state;
|
|
15
|
+
case "auto_retry_end": return { ...state, retry: undefined };
|
|
16
|
+
case "summarization_retry_scheduled": return { ...state, summary: { id: randomUUID(), source: state.compaction ? "compaction" : "branchSummary", phase: "waiting", attempt: event.attempt, maxAttempts: event.maxAttempts, deadline: now + event.delayMs, error: event.errorMessage.slice(0, 500) } };
|
|
17
|
+
case "summarization_retry_attempt_start": return { ...state, summary: { ...state.summary, id: state.summary?.id ?? randomUUID(), source: event.source, phase: "running", deadline: undefined } };
|
|
18
|
+
case "summarization_retry_finished": return { ...state, summary: undefined };
|
|
19
|
+
case "agent_settled": return { ...(state.branch ? { branch: state.branch } : {}), ...(state.lastCompaction ? { lastCompaction: state.lastCompaction } : {}) };
|
|
20
|
+
default: return state;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export function isRecovering(state) { return !!(state.compaction || state.retry || state.summary || state.branch); }
|
|
24
|
+
/** Send durations, never compare clocks on different machines. Reconnection resamples the duration. */
|
|
25
|
+
export function recoverySnapshot(state, now = Date.now()) {
|
|
26
|
+
const { retry, summary, ...rest } = state;
|
|
27
|
+
const snapshot = { ...rest };
|
|
28
|
+
if (retry) {
|
|
29
|
+
const { deadline, ...operation } = retry;
|
|
30
|
+
snapshot.retry = { ...operation, remainingMs: retry.phase === "waiting" ? Math.max(0, deadline - now) : 0 };
|
|
31
|
+
}
|
|
32
|
+
if (summary) {
|
|
33
|
+
const { deadline, ...operation } = summary;
|
|
34
|
+
snapshot.summary = { ...operation, remainingMs: summary.phase === "waiting" && deadline !== undefined ? Math.max(0, deadline - now) : 0 };
|
|
35
|
+
}
|
|
36
|
+
return snapshot;
|
|
37
|
+
}
|