@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,255 @@
|
|
|
1
|
+
import { nativeSkills } from "./skills-service.js";
|
|
2
|
+
import { mkdirSync, readFileSync, writeFileSync, renameSync, statSync, realpathSync, existsSync } from "node:fs";
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
4
|
+
import { killPidTree } from "./process-utils.js";
|
|
5
|
+
import { fork } from "node:child_process";
|
|
6
|
+
import { randomUUID } from "node:crypto";
|
|
7
|
+
import { join } from "node:path";
|
|
8
|
+
import { getAgentDir } from "@earendil-works/pi-coding-agent";
|
|
9
|
+
import { readJson, textField, resourceTypes, sourceInfo, validateSource } from "./extensions-model.js";
|
|
10
|
+
import { browseCatalog, cachedFetch, safeUrl, packageReleaseNotes } from "./extensions-catalog.js";
|
|
11
|
+
const jobs = new Map();
|
|
12
|
+
const tickets = new Map();
|
|
13
|
+
const states = new Map();
|
|
14
|
+
let mutation;
|
|
15
|
+
let readers = 0;
|
|
16
|
+
let canBackgroundRun = () => false;
|
|
17
|
+
const background = new Map();
|
|
18
|
+
function autoCheckEnabled(agentDir) { try {
|
|
19
|
+
return readJson(join(agentDir, "webui-extensions.json")).autoCheck !== false;
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return false;
|
|
23
|
+
} }
|
|
24
|
+
const backgroundTimer = setInterval(() => {
|
|
25
|
+
if (mutation || readers || !canBackgroundRun())
|
|
26
|
+
return;
|
|
27
|
+
const entry = [...background].find(([, v]) => v.next <= Date.now());
|
|
28
|
+
if (!entry)
|
|
29
|
+
return;
|
|
30
|
+
const [cwd, target] = entry;
|
|
31
|
+
target.next = Date.now() + 6 * 60 * 60 * 1000;
|
|
32
|
+
if (!autoCheckEnabled(target.agentDir))
|
|
33
|
+
return;
|
|
34
|
+
readers++;
|
|
35
|
+
void runWorker({ cwd, agentDir: target.agentDir, action: "check" }).then(state => states.set(cwd, state)).catch(() => { }).finally(() => { readers--; });
|
|
36
|
+
}, 60000);
|
|
37
|
+
backgroundTimer.unref();
|
|
38
|
+
function runWorker(input, log = () => { }) {
|
|
39
|
+
return new Promise((resolve, reject) => {
|
|
40
|
+
const child = fork(new URL(import.meta.url.endsWith(".ts") ? "./extensions-worker.ts" : "./extensions-worker.js", import.meta.url), ["--extensions-worker"], { detached: process.platform !== "win32", stdio: ["ignore", "pipe", "pipe", "ipc"], execArgv: process.execArgv.filter(a => !a.startsWith("--watch")), env: { ...process.env, ELECTRON_RUN_AS_NODE: "1", GIT_TERMINAL_PROMPT: "0" } });
|
|
41
|
+
let result, failure;
|
|
42
|
+
child.stdout?.on("data", chunk => log(String(chunk)));
|
|
43
|
+
child.stderr?.on("data", chunk => log(String(chunk)));
|
|
44
|
+
child.on("message", (message) => { if (message.progress)
|
|
45
|
+
log(message.progress); if (message.state)
|
|
46
|
+
result = message.state; if (message.error)
|
|
47
|
+
failure = Error(message.error); });
|
|
48
|
+
const stop = () => { if (child.pid)
|
|
49
|
+
killPidTree(child.pid); };
|
|
50
|
+
process.once("exit", stop);
|
|
51
|
+
const timer = setTimeout(() => { failure = Error("Package operation timed out"); stop(); }, input.action === "mutate" ? 20 * 60 * 1000 : 120000);
|
|
52
|
+
child.once("error", error => { clearTimeout(timer); process.removeListener("exit", stop); reject(error); });
|
|
53
|
+
child.once("exit", () => { clearTimeout(timer); process.removeListener("exit", stop); result && !failure ? resolve(result) : reject(failure ?? Error("Package worker stopped")); });
|
|
54
|
+
child.send(input);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
async function previewSource(source) {
|
|
58
|
+
const info = sourceInfo(source);
|
|
59
|
+
let meta = {};
|
|
60
|
+
if (info.kind === "npm")
|
|
61
|
+
meta = await cachedFetch(`https://registry.npmjs.org/${encodeURIComponent(info.name)}/${encodeURIComponent(info.ref ?? "latest")}`);
|
|
62
|
+
if (info.kind === "local") {
|
|
63
|
+
try {
|
|
64
|
+
meta = readJson(join(source, "package.json"));
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
if (e.code !== "ENOTDIR")
|
|
68
|
+
throw e;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const resources = {};
|
|
72
|
+
for (const type of resourceTypes)
|
|
73
|
+
if (Array.isArray(meta.pi?.[type]))
|
|
74
|
+
resources[type] = meta.pi[type].filter((v) => typeof v === "string").slice(0, 100);
|
|
75
|
+
return { source, name: textField(meta.name) ?? info.name, version: textField(meta.version), description: textField(meta.description), license: textField(meta.license), author: textField(typeof meta.author === "string" ? meta.author : meta.author?.name), repository: safeUrl(typeof meta.repository === "string" ? meta.repository : meta.repository?.url), resources, canPin: info.kind === "npm" && typeof meta.version === "string" };
|
|
76
|
+
}
|
|
77
|
+
export function installExtensionsRoutes(app, service, originAllowed) {
|
|
78
|
+
canBackgroundRun = () => !service().quiesceInfo().quiesced;
|
|
79
|
+
app.post("/api/extensions", async (req, res) => {
|
|
80
|
+
res.setHeader("Cache-Control", "no-store");
|
|
81
|
+
if (!originAllowed(req) || !req.is("application/json")) {
|
|
82
|
+
res.sendStatus(403);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const { clientId, cwd, action } = req.body ?? {};
|
|
86
|
+
const cs = typeof clientId === "string" ? service().get(clientId) : undefined;
|
|
87
|
+
if (!cs || cs.cwd !== cwd || cs.switchingWorkspace || service().quiesceInfo().quiesced) {
|
|
88
|
+
res.status(409).json({ error: "Workspace unavailable" });
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const agentDir = getAgentDir();
|
|
92
|
+
try {
|
|
93
|
+
if (action === "open-info" && req.body.id === "skills:user") {
|
|
94
|
+
const path = join(agentDir, "skills");
|
|
95
|
+
res.json({ absolute: existsSync(path) ? path : agentDir });
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (action === "skills-list" || action === "skills-toggle") {
|
|
99
|
+
if (mutation || readers >= 4)
|
|
100
|
+
throw Error("Package manager busy");
|
|
101
|
+
const change = action === "skills-toggle" ? req.body : undefined;
|
|
102
|
+
if (change && (typeof change.id !== "string" || typeof change.enabled !== "boolean" || typeof change.version !== "string"))
|
|
103
|
+
throw Error("Invalid skill change");
|
|
104
|
+
if (change)
|
|
105
|
+
mutation = randomUUID();
|
|
106
|
+
readers++;
|
|
107
|
+
try {
|
|
108
|
+
const valid = () => cs.cwd === cwd && !cs.switchingWorkspace && !service().quiesceInfo().quiesced;
|
|
109
|
+
const state = await nativeSkills(cwd, agentDir, change, valid);
|
|
110
|
+
if (!valid())
|
|
111
|
+
throw Error("Workspace changed");
|
|
112
|
+
res.json(state);
|
|
113
|
+
}
|
|
114
|
+
finally {
|
|
115
|
+
readers--;
|
|
116
|
+
if (change)
|
|
117
|
+
mutation = undefined;
|
|
118
|
+
}
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (action === "preferences") {
|
|
122
|
+
if (typeof req.body.enabled !== "boolean")
|
|
123
|
+
throw Error("Invalid preference");
|
|
124
|
+
const path = join(agentDir, "webui-extensions.json"), previous = readJson(path);
|
|
125
|
+
mkdirSync(agentDir, { recursive: true });
|
|
126
|
+
writeFileSync(`${path}.tmp`, JSON.stringify({ ...previous, autoCheck: req.body.enabled }), { mode: 0o600 });
|
|
127
|
+
renameSync(`${path}.tmp`, path);
|
|
128
|
+
res.json({ autoCheck: req.body.enabled });
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (action === "search") {
|
|
132
|
+
res.json(await browseCatalog(String(req.body.query ?? ""), String(req.body.type ?? ""), String(req.body.sort ?? ""), Number(req.body.page) || 1));
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (action === "details") {
|
|
136
|
+
res.json(await previewSource(validateSource(req.body.source, cwd)));
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
if (action === "preview") {
|
|
140
|
+
const preview = { ...await previewSource(validateSource(req.body.source, cwd)), ticket: randomUUID() };
|
|
141
|
+
if (tickets.size >= 64)
|
|
142
|
+
tickets.delete(tickets.keys().next().value);
|
|
143
|
+
tickets.set(preview.ticket, { cwd, clientId, until: Date.now() + 1200000, preview });
|
|
144
|
+
res.json(preview);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (action === "job") {
|
|
148
|
+
const job = jobs.get(req.body.id);
|
|
149
|
+
if (!job || job.clientId !== clientId || job.cwd !== cwd)
|
|
150
|
+
throw Error("Operation not found");
|
|
151
|
+
res.json(job);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (action === "start") {
|
|
155
|
+
if (mutation)
|
|
156
|
+
throw Error("Package manager is busy; retry shortly");
|
|
157
|
+
const op = req.body.operation;
|
|
158
|
+
if (!op || !["install", "remove", "toggle", "update", "update-all", "unpin", "move"].includes(op.action) || op.scope && !["user", "project"].includes(op.scope) || op.action === "toggle" && typeof op.enabled !== "boolean")
|
|
159
|
+
throw Error("Invalid operation");
|
|
160
|
+
let source;
|
|
161
|
+
if (op.action === "install") {
|
|
162
|
+
const ticket = tickets.get(op.ticket ?? "");
|
|
163
|
+
if (!ticket || ticket.cwd !== cwd || ticket.clientId !== clientId || ticket.until < Date.now())
|
|
164
|
+
throw Error("Install preview expired; review the source again");
|
|
165
|
+
source = ticket.preview.source;
|
|
166
|
+
if (op.pin && ticket.preview.canPin)
|
|
167
|
+
source = `${sourceInfo(source).unpinned}@${ticket.preview.version}`;
|
|
168
|
+
tickets.delete(op.ticket);
|
|
169
|
+
}
|
|
170
|
+
const id = randomUUID(), job = { id, phase: "running", log: "", cwd, clientId };
|
|
171
|
+
if (jobs.size >= 32)
|
|
172
|
+
jobs.delete(jobs.keys().next().value);
|
|
173
|
+
jobs.set(id, job);
|
|
174
|
+
mutation = id;
|
|
175
|
+
void runWorker({ cwd, agentDir, action: "mutate", operation: op, source, version: req.body.version }, line => { job.log = (job.log + line + "\n").slice(-128000); }).then(() => { states.delete(cwd); job.phase = "done"; }, error => { job.phase = "error"; job.error = error.message; job.log += `\n${error.message}`; }).finally(() => { mutation = undefined; });
|
|
176
|
+
res.json(job);
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
if (action !== "list" && action !== "check" && !["open-info", "file", "save-file", "notes"].includes(action))
|
|
180
|
+
throw Error("Unknown action");
|
|
181
|
+
if (mutation)
|
|
182
|
+
throw Error("Package operation running");
|
|
183
|
+
if (readers >= 4)
|
|
184
|
+
throw Error("Package manager busy");
|
|
185
|
+
readers++;
|
|
186
|
+
try {
|
|
187
|
+
const cached = states.get(cwd);
|
|
188
|
+
const state = await runWorker({ cwd, agentDir, action: action === "check" ? "check" : "list" });
|
|
189
|
+
if (cs.cwd !== cwd || cs.switchingWorkspace)
|
|
190
|
+
throw Error("Workspace changed");
|
|
191
|
+
if (["file", "save-file", "notes"].includes(action)) {
|
|
192
|
+
const item = state.packages.find(p => p.id === req.body.id);
|
|
193
|
+
if (!item)
|
|
194
|
+
throw Error("Package unavailable");
|
|
195
|
+
if (action === "notes") {
|
|
196
|
+
res.json(item.kind === "npm" ? await packageReleaseNotes(sourceInfo(item.source).name) : { title: item.version ?? "", notes: [] });
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
if (item.kind !== "file" || !item.trusted || !item.path || !/\.[cm]?[jt]s$/.test(item.path))
|
|
200
|
+
throw Error("Only trusted standalone extension files can be edited here");
|
|
201
|
+
const path = realpathSync(item.path), info = statSync(path);
|
|
202
|
+
if (!info.isFile() || info.size > 512 * 1024)
|
|
203
|
+
throw Error("Extension file exceeds editor limit (512 KB)");
|
|
204
|
+
const raw = readFileSync(path), version = createHash("sha256").update(raw).digest("hex");
|
|
205
|
+
if (action === "save-file") {
|
|
206
|
+
if (mutation)
|
|
207
|
+
throw Error("Package operation running");
|
|
208
|
+
if (version !== req.body.version)
|
|
209
|
+
throw Error("File changed externally; reopen before saving");
|
|
210
|
+
if (typeof req.body.content !== "string" || Buffer.byteLength(req.body.content) > 512 * 1024)
|
|
211
|
+
throw Error("Invalid extension content");
|
|
212
|
+
const temp = `${path}.${randomUUID()}.tmp`;
|
|
213
|
+
writeFileSync(temp, req.body.content, { mode: info.mode });
|
|
214
|
+
renameSync(temp, path);
|
|
215
|
+
res.json({ saved: true });
|
|
216
|
+
}
|
|
217
|
+
else
|
|
218
|
+
res.json({ content: new TextDecoder("utf-8", { fatal: true }).decode(raw), version });
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
if (action === "open-info") {
|
|
222
|
+
const item = state.packages.find(p => p.id === req.body.id);
|
|
223
|
+
if (!item?.path)
|
|
224
|
+
throw Error("Installed path unavailable");
|
|
225
|
+
res.json({ absolute: item.path });
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
if (action === "check") {
|
|
229
|
+
if (states.size > 32)
|
|
230
|
+
states.delete(states.keys().next().value);
|
|
231
|
+
states.set(cwd, state);
|
|
232
|
+
}
|
|
233
|
+
else if (cached?.version === state.version) {
|
|
234
|
+
state.checkedAt = cached.checkedAt;
|
|
235
|
+
for (const item of state.packages) {
|
|
236
|
+
const old = cached.packages.find(p => p.id === item.id);
|
|
237
|
+
if (old?.version === item.version)
|
|
238
|
+
Object.assign(item, { update: old?.update, latest: old?.latest, checkError: old?.checkError });
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
state.autoCheck = autoCheckEnabled(agentDir);
|
|
242
|
+
if (background.size > 32)
|
|
243
|
+
background.delete(background.keys().next().value);
|
|
244
|
+
background.set(cwd, { agentDir, next: Math.max(Date.now() + 60000, (state.checkedAt ?? 0) + 6 * 60 * 60 * 1000) });
|
|
245
|
+
res.json(state);
|
|
246
|
+
}
|
|
247
|
+
finally {
|
|
248
|
+
readers--;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
catch (error) {
|
|
252
|
+
res.status(400).json({ error: error instanceof Error ? error.message : String(error) });
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { DefaultPackageManager, SettingsManager, ProjectTrustStore } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { writeFileSync, mkdirSync, renameSync } from "node:fs";
|
|
3
|
+
import { join, relative } from "node:path";
|
|
4
|
+
import { createHash } from "node:crypto";
|
|
5
|
+
import { readJson, textField, resourceTypes, sourceOf, sourceInfo, packageDisabled, settingsVersion } from "./extensions-model.js";
|
|
6
|
+
import { extensionDisplay } from "./extension-display.js";
|
|
7
|
+
import { gitOutput, latestNpmVersion } from "./component-updates.js";
|
|
8
|
+
const blankResources = () => ({ extensions: [], skills: [], prompts: [], themes: [] });
|
|
9
|
+
export async function extensionWork(input, progress = () => { }) {
|
|
10
|
+
const { cwd, agentDir } = input;
|
|
11
|
+
const trusted = new ProjectTrustStore(agentDir).get(cwd) === true;
|
|
12
|
+
const settings = SettingsManager.create(cwd, agentDir, { projectTrusted: trusted });
|
|
13
|
+
const errors = settings.drainErrors();
|
|
14
|
+
if (errors.length)
|
|
15
|
+
throw Error(errors.map(e => e.error.message).join("\n"));
|
|
16
|
+
const manager = new DefaultPackageManager({ cwd, agentDir, settingsManager: settings });
|
|
17
|
+
manager.setProgressCallback(event => progress(`${event.type}: ${event.message ?? event.source}`));
|
|
18
|
+
const config = (scope) => scope === "user" ? settings.getGlobalSettings() : settings.getProjectSettings();
|
|
19
|
+
const packages = (scope) => config(scope).packages ?? [];
|
|
20
|
+
const setPackages = (scope, entries) => scope === "user" ? settings.setPackages(entries) : settings.setProjectPackages(entries);
|
|
21
|
+
const flush = async () => { await settings.flush(); const errors = settings.drainErrors(); if (errors.length)
|
|
22
|
+
throw Error(errors.map(e => e.error.message).join("\n")); };
|
|
23
|
+
const scopedManager = (scope, entries) => {
|
|
24
|
+
const isolated = SettingsManager.inMemory({ ...settings.getSettings(), packages: [] }, { projectTrusted: true });
|
|
25
|
+
if (scope === "project")
|
|
26
|
+
isolated.setProjectPackages(entries);
|
|
27
|
+
else
|
|
28
|
+
isolated.setPackages(entries);
|
|
29
|
+
return new DefaultPackageManager({ cwd, agentDir, settingsManager: isolated });
|
|
30
|
+
};
|
|
31
|
+
const checkUpdates = async () => (await Promise.all(["user", "project"].filter(scope => scope === "user" || trusted).map(scope => scopedManager(scope, packages(scope)).checkForAvailableUpdates()))).flat();
|
|
32
|
+
const backupPath = join(agentDir, "webui-extension-filters.json");
|
|
33
|
+
const backup = readJson(backupPath);
|
|
34
|
+
const backupKey = (id) => createHash("sha256").update(`${id.startsWith("user:") ? "global" : cwd}:${id}`).digest("hex");
|
|
35
|
+
const saveBackup = () => { mkdirSync(agentDir, { recursive: true }); writeFileSync(`${backupPath}.tmp`, JSON.stringify(backup), { mode: 0o600 }); renameSync(`${backupPath}.tmp`, backupPath); };
|
|
36
|
+
async function list() {
|
|
37
|
+
const resources = await manager.resolve(async () => "skip");
|
|
38
|
+
const result = [];
|
|
39
|
+
const projectDeclarations = readJson(join(cwd, ".pi/settings.json")).packages ?? [];
|
|
40
|
+
for (const scope of ["user", "project"]) {
|
|
41
|
+
const declarations = scope === "project" && !trusted ? projectDeclarations : packages(scope);
|
|
42
|
+
for (const entry of declarations) {
|
|
43
|
+
const source = sourceOf(entry), info = sourceInfo(source), path = scope === "project" && !trusted ? undefined : manager.getInstalledPath(source, scope);
|
|
44
|
+
let metadata = {};
|
|
45
|
+
if (path)
|
|
46
|
+
try {
|
|
47
|
+
metadata = readJson(join(path, "package.json"));
|
|
48
|
+
}
|
|
49
|
+
catch { }
|
|
50
|
+
const counts = blankResources();
|
|
51
|
+
for (const type of resourceTypes)
|
|
52
|
+
counts[type] = resources[type].filter(r => r.metadata.source === source && r.metadata.scope === scope).map(r => relative(path ?? cwd, r.path));
|
|
53
|
+
result.push({ id: `${scope}:${source}`, source, scope, kind: info.kind, name: textField(metadata.name) ?? info.name, path, version: textField(metadata.version), description: textField(metadata.description), enabled: !packageDisabled(entry), pinned: info.pinned, trusted: scope === "user" || trusted, resources: counts, protected: ["@youweichen/pi-harness", "pi-harness", "@earendil-works/pi-coding-agent"].includes(info.name) });
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
for (const resource of resources.extensions) {
|
|
57
|
+
if (resource.metadata.origin !== "top-level" || resource.path.startsWith("builtin:") || resource.metadata.scope === "temporary")
|
|
58
|
+
continue;
|
|
59
|
+
result.push({ id: `file:${resource.metadata.scope}:${resource.path}`, source: resource.path, ...extensionDisplay(resource.path), scope: resource.metadata.scope, kind: "file", path: resource.path, enabled: resource.enabled, pinned: false, trusted: resource.metadata.scope === "user" || trusted, resources: blankResources() });
|
|
60
|
+
}
|
|
61
|
+
return { packages: result, version: settingsVersion(cwd, agentDir), trusted };
|
|
62
|
+
}
|
|
63
|
+
if (input.action === "mutate") {
|
|
64
|
+
if (input.version !== settingsVersion(cwd, agentDir))
|
|
65
|
+
throw Error("Pi settings changed; refresh before applying changes");
|
|
66
|
+
const op = input.operation;
|
|
67
|
+
const state = await list(), target = state.packages.find(p => p.id === op.id);
|
|
68
|
+
if (!["install", "update-all"].includes(op.action) && !target)
|
|
69
|
+
throw Error("Package no longer configured");
|
|
70
|
+
if (target?.kind === "file" && op.action !== "toggle")
|
|
71
|
+
throw Error("Standalone files only support toggling and editing");
|
|
72
|
+
if (target?.protected)
|
|
73
|
+
throw Error("This package must be managed with the application");
|
|
74
|
+
if (target && !target.trusted || op.scope === "project" && !trusted)
|
|
75
|
+
throw Error("Project is not trusted; review it in MCP settings or Pi first");
|
|
76
|
+
if (input.version !== settingsVersion(cwd, agentDir))
|
|
77
|
+
throw Error("Pi settings changed; refresh before applying changes");
|
|
78
|
+
const scope = target?.scope ?? op.scope ?? "user", local = scope === "project";
|
|
79
|
+
const source = target?.source ?? input.source;
|
|
80
|
+
const entries = packages(scope), index = entries.findIndex(p => sourceOf(p) === source);
|
|
81
|
+
if (op.action === "install") {
|
|
82
|
+
if (!input.source)
|
|
83
|
+
throw Error("Install preview expired");
|
|
84
|
+
if (["@youweichen/pi-harness", "pi-harness", "@earendil-works/pi-coding-agent"].includes(sourceInfo(input.source).name))
|
|
85
|
+
throw Error("Manage this package with the application updater");
|
|
86
|
+
await manager.install(input.source, { local });
|
|
87
|
+
if (input.version !== settingsVersion(cwd, agentDir))
|
|
88
|
+
throw Error("Pi settings changed during install; files were installed but configuration was not overwritten");
|
|
89
|
+
manager.addSourceToSettings(input.source, { local });
|
|
90
|
+
}
|
|
91
|
+
else if (op.action === "remove") {
|
|
92
|
+
await manager.remove(source, { local });
|
|
93
|
+
await settings.reload();
|
|
94
|
+
manager.removeSourceFromSettings(source, { local });
|
|
95
|
+
delete backup[backupKey(target.id)];
|
|
96
|
+
saveBackup();
|
|
97
|
+
}
|
|
98
|
+
else if (op.action === "toggle" && target?.kind === "file") {
|
|
99
|
+
const paths = [...(config(scope).extensions ?? [])].filter(p => p !== `-${source}` && p !== `+${source}`);
|
|
100
|
+
paths.push(`${op.enabled ? "+" : "-"}${source}`);
|
|
101
|
+
if (local)
|
|
102
|
+
settings.setProjectExtensionPaths(paths);
|
|
103
|
+
else
|
|
104
|
+
settings.setExtensionPaths(paths);
|
|
105
|
+
}
|
|
106
|
+
else if (op.action === "toggle") {
|
|
107
|
+
const key = backupKey(target.id);
|
|
108
|
+
if (!op.enabled && !packageDisabled(entries[index])) {
|
|
109
|
+
backup[key] = entries[index];
|
|
110
|
+
saveBackup();
|
|
111
|
+
entries[index] = { ...(typeof entries[index] === "object" ? entries[index] : { source }), autoload: true, extensions: [], skills: [], prompts: [], themes: [] };
|
|
112
|
+
}
|
|
113
|
+
if (op.enabled && packageDisabled(entries[index]))
|
|
114
|
+
entries[index] = backup[key] ?? { source };
|
|
115
|
+
setPackages(scope, entries);
|
|
116
|
+
}
|
|
117
|
+
else if (op.action === "unpin") {
|
|
118
|
+
const unpinned = sourceInfo(source).unpinned;
|
|
119
|
+
entries[index] = typeof entries[index] === "string" ? unpinned : { ...entries[index], source: unpinned };
|
|
120
|
+
const saved = backup[backupKey(target.id)];
|
|
121
|
+
if (saved) {
|
|
122
|
+
backup[backupKey(`${scope}:${unpinned}`)] = typeof saved === "string" ? unpinned : { ...saved, source: unpinned };
|
|
123
|
+
saveBackup();
|
|
124
|
+
}
|
|
125
|
+
setPackages(scope, entries);
|
|
126
|
+
}
|
|
127
|
+
else if (op.action === "move") {
|
|
128
|
+
const destination = scope === "user" ? "project" : "user";
|
|
129
|
+
if (!trusted)
|
|
130
|
+
throw Error("Project is not trusted");
|
|
131
|
+
if (packages(destination).some(p => sourceInfo(sourceOf(p)).unpinned === sourceInfo(source).unpinned))
|
|
132
|
+
throw Error("Package already declared in destination scope");
|
|
133
|
+
const movedSource = target.kind === "local" ? target.path ?? source : source;
|
|
134
|
+
await manager.install(movedSource, { local: destination === "project" });
|
|
135
|
+
if (input.version !== settingsVersion(cwd, agentDir))
|
|
136
|
+
throw Error("Pi settings changed during move; destination files installed but configuration retained");
|
|
137
|
+
const old = entries[index], moved = typeof old === "string" ? movedSource : { ...old, source: movedSource };
|
|
138
|
+
setPackages(destination, [...packages(destination), moved]);
|
|
139
|
+
await flush();
|
|
140
|
+
setPackages(scope, entries.filter((_, i) => i !== index));
|
|
141
|
+
const oldBackup = backup[backupKey(target.id)];
|
|
142
|
+
if (oldBackup) {
|
|
143
|
+
backup[backupKey(`${destination}:${movedSource}`)] = typeof oldBackup === "string" ? movedSource : { ...oldBackup, source: movedSource };
|
|
144
|
+
saveBackup();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else if (op.action === "update" || op.action === "update-all") {
|
|
148
|
+
const updates = await checkUpdates();
|
|
149
|
+
const eligible = state.packages.filter(p => !p.protected && p.trusted && !p.pinned && updates.some(u => u.source === p.source && u.scope === p.scope) && (op.action === "update-all" || p.id === target.id));
|
|
150
|
+
if (!eligible.length)
|
|
151
|
+
throw Error("No updates available");
|
|
152
|
+
for (const [i, p] of eligible.entries()) {
|
|
153
|
+
if (p.kind === "git" && p.path && await gitOutput(p.path, ["status", "--porcelain"]))
|
|
154
|
+
throw Error(`Local changes in ${p.name}; commit or save them before updating`);
|
|
155
|
+
progress(`${i + 1}/${eligible.length} ${p.name}`);
|
|
156
|
+
// A scope-isolated native manager prevents update(source) from also updating another declaration.
|
|
157
|
+
const updater = scopedManager(p.scope, [p.source]);
|
|
158
|
+
updater.setProgressCallback(event => progress(`${event.type}: ${event.message ?? event.source}`));
|
|
159
|
+
await updater.update(p.source);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
else
|
|
163
|
+
throw Error("Unsupported operation");
|
|
164
|
+
await flush();
|
|
165
|
+
}
|
|
166
|
+
const state = await list();
|
|
167
|
+
if (input.action === "check") {
|
|
168
|
+
const updates = await checkUpdates();
|
|
169
|
+
for (const item of state.packages) {
|
|
170
|
+
item.update = !item.protected && updates.some(u => u.scope === item.scope && u.source === item.source);
|
|
171
|
+
if (item.update && item.kind === "npm" && !sourceInfo(item.source).ref)
|
|
172
|
+
try {
|
|
173
|
+
item.latest = await latestNpmVersion(sourceInfo(item.source).name);
|
|
174
|
+
}
|
|
175
|
+
catch (e) {
|
|
176
|
+
item.checkError = String(e);
|
|
177
|
+
}
|
|
178
|
+
if (item.update && item.kind === "git")
|
|
179
|
+
item.latest = "HEAD";
|
|
180
|
+
}
|
|
181
|
+
state.checkedAt = Date.now();
|
|
182
|
+
}
|
|
183
|
+
return state;
|
|
184
|
+
}
|
|
185
|
+
if (process.send && process.argv.includes("--extensions-worker"))
|
|
186
|
+
process.once("message", (input) => {
|
|
187
|
+
void extensionWork(input, message => process.send?.({ progress: message })).then(state => process.send?.({ state }, () => process.disconnect()), error => process.send?.({ error: error instanceof Error ? error.message : String(error) }, () => process.disconnect()));
|
|
188
|
+
});
|