upfynai-code 0.1.0 → 2.2.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/client/dist/api-docs.html +879 -0
- package/client/dist/assets/AppContent-CTSHQdyq.js +513 -0
- package/client/dist/assets/CanvasPanel-Cig0Mo9s.js +6 -0
- package/client/dist/assets/CanvasPanel-q4HEqNtV.css +1 -0
- package/client/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/client/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/client/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/client/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/client/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/client/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/client/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/client/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/client/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/client/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/client/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/client/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/client/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/client/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/client/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/client/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/client/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/client/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/client/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/client/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/client/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/client/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/client/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/client/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/client/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/client/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/client/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/client/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/client/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/client/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/client/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/client/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/client/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/client/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/client/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/client/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/client/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/client/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/client/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/client/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/client/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/client/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/client/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/client/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/client/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/client/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/client/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/client/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/client/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/client/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/client/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/client/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/client/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/client/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/client/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/client/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/client/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/client/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/client/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/client/dist/assets/LoginModal-silya-zP.js +11 -0
- package/client/dist/assets/MarkdownPreview-B3c7OEj6.js +1 -0
- package/client/dist/assets/Onboarding-Coxo6mFA.js +1 -0
- package/client/dist/assets/SetupForm-BzYOsbji.js +1 -0
- package/client/dist/assets/Tableau10-B-NsZVaP.js +1 -0
- package/client/dist/assets/_commonjs-dynamic-modules-TDtrdbi3.js +1 -0
- package/client/dist/assets/ar-SA-G6X2FPQ2-Bmw2-hDt.js +10 -0
- package/client/dist/assets/arc-BMqY7_Ci.js +1 -0
- package/client/dist/assets/array-BKyUJesY.js +1 -0
- package/client/dist/assets/az-AZ-76LH7QW2-Dh1le_qs.js +1 -0
- package/client/dist/assets/bg-BG-XCXSNQG7-Cbav8Z9z.js +5 -0
- package/client/dist/assets/blockDiagram-38ab4fdb-ChHJxsXw.js +118 -0
- package/client/dist/assets/bn-BD-2XOGV67Q-DCNjOaWz.js +5 -0
- package/client/dist/assets/c4Diagram-3d4e48cf-b8Xue4Z6.js +10 -0
- package/client/dist/assets/ca-ES-6MX7JW3Y-Dl_vM7NS.js +8 -0
- package/client/dist/assets/channel-CSnvHe_M.js +1 -0
- package/client/dist/assets/classDiagram-70f12bd4-BheP7Ggo.js +2 -0
- package/client/dist/assets/classDiagram-v2-f2320105-xtym7GEZ.js +2 -0
- package/client/dist/assets/clone-B75abXxS.js +1 -0
- package/client/dist/assets/createText-2e5e7dd3-_n4jI_fO.js +5 -0
- package/client/dist/assets/cs-CZ-2BRQDIVT-ftsKDdz4.js +11 -0
- package/client/dist/assets/da-DK-5WZEPLOC-DAjdwGRO.js +5 -0
- package/client/dist/assets/de-DE-XR44H4JA-BJXczHGT.js +8 -0
- package/client/dist/assets/directory-open-01563666-DWU9wJ6I.js +1 -0
- package/client/dist/assets/directory-open-4ed118d0-CunoC1EB.js +1 -0
- package/client/dist/assets/edges-e0da2a9e-CfPZr4YM.js +4 -0
- package/client/dist/assets/el-GR-BZB4AONW-DW2p_uy7.js +10 -0
- package/client/dist/assets/erDiagram-9861fffd-CF33V-Of.js +51 -0
- package/client/dist/assets/es-ES-U4NZUMDT-DLOIGnrl.js +9 -0
- package/client/dist/assets/eu-ES-A7QVB2H4-LJXbf89m.js +11 -0
- package/client/dist/assets/fa-IR-HGAKTJCU-Dvx65fgW.js +8 -0
- package/client/dist/assets/fi-FI-Z5N7JZ37-EoL65BQh.js +6 -0
- package/client/dist/assets/file-open-002ab408-DIuFHtCF.js +1 -0
- package/client/dist/assets/file-open-7c801643-684qeFg4.js +1 -0
- package/client/dist/assets/file-save-3189631c-C1wFhQhH.js +1 -0
- package/client/dist/assets/file-save-745eba88-Bb9F9Kg7.js +1 -0
- package/client/dist/assets/flowDb-956e92f1-HgoXVy2H.js +10 -0
- package/client/dist/assets/flowDiagram-66a62f08-tffoET0H.js +4 -0
- package/client/dist/assets/flowDiagram-v2-96b9c2cf-Byc3JCHh.js +1 -0
- package/client/dist/assets/flowchart-elk-definition-4a651766-DJbI2dpv.js +139 -0
- package/client/dist/assets/fr-FR-RHASNOE6-DNk_jdDs.js +9 -0
- package/client/dist/assets/ganttDiagram-c361ad54-2XX670FU.js +257 -0
- package/client/dist/assets/gitGraphDiagram-72cf32ee-CcUfruAo.js +70 -0
- package/client/dist/assets/gl-ES-HMX3MZ6V-dxzFjZlG.js +10 -0
- package/client/dist/assets/graph-BSbiMSBC.js +1 -0
- package/client/dist/assets/he-IL-6SHJWFNN-Cogsfdt1.js +10 -0
- package/client/dist/assets/hi-IN-IWLTKZ5I-L6wbgi4F.js +4 -0
- package/client/dist/assets/hu-HU-A5ZG7DT2-DSA6ZDsH.js +7 -0
- package/client/dist/assets/id-ID-SAP4L64H-BK_vGGS6.js +10 -0
- package/client/dist/assets/image-blob-reduce.esm-BLtmMM_J.js +2 -0
- package/client/dist/assets/index-3862675e-Bv32HUgT.js +1 -0
- package/client/dist/assets/index-B8wwD_Xo.css +1 -0
- package/client/dist/assets/index-BPwf8Fw3.js +27 -0
- package/client/dist/assets/index-D1urGMYu.js +95 -0
- package/client/dist/assets/infoDiagram-f8f76790-w4mR4pxn.js +7 -0
- package/client/dist/assets/init-Gi6I4Gst.js +1 -0
- package/client/dist/assets/it-IT-JPQ66NNP-BLdHYMhn.js +11 -0
- package/client/dist/assets/ja-JP-DBVTYXUO-B_vmexl_.js +8 -0
- package/client/dist/assets/journeyDiagram-49397b02-D9nmO17e.js +139 -0
- package/client/dist/assets/kaa-6HZHGXH3-5s-3jl6F.js +1 -0
- package/client/dist/assets/kab-KAB-ZGHBKWFO-2QaVDuSf.js +8 -0
- package/client/dist/assets/kk-KZ-P5N5QNE5-CTC52Vbi.js +1 -0
- package/client/dist/assets/km-KH-HSX4SM5Z-DxawH8UZ.js +11 -0
- package/client/dist/assets/ko-KR-MTYHY66A-CmosEM8_.js +9 -0
- package/client/dist/assets/ku-TR-6OUDTVRD-DbiLen4y.js +9 -0
- package/client/dist/assets/layout-jmt3H9tA.js +1 -0
- package/client/dist/assets/line-JTlRayUJ.js +1 -0
- package/client/dist/assets/linear-DJeB5p7x.js +1 -0
- package/client/dist/assets/lt-LT-XHIRWOB4-CH15wrjA.js +3 -0
- package/client/dist/assets/lv-LV-5QDEKY6T-dhgfPuCQ.js +7 -0
- package/client/dist/assets/mindmap-definition-fc14e90a-BOOrexmz.js +415 -0
- package/client/dist/assets/mr-IN-CRQNXWMA-3Gi6iq7A.js +13 -0
- package/client/dist/assets/my-MM-5M5IBNSE-CpH4rdJj.js +1 -0
- package/client/dist/assets/nb-NO-T6EIAALU-Du6iiGql.js +10 -0
- package/client/dist/assets/nl-NL-IS3SIHDZ-BGvsd1MT.js +8 -0
- package/client/dist/assets/nn-NO-6E72VCQL-B-odvJZW.js +8 -0
- package/client/dist/assets/oc-FR-POXYY2M6-COC8xNjo.js +8 -0
- package/client/dist/assets/ordinal-Cboi1Yqb.js +1 -0
- package/client/dist/assets/pa-IN-N4M65BXN-CE21PUQH.js +4 -0
- package/client/dist/assets/path-CbwjOpE9.js +1 -0
- package/client/dist/assets/pdf-TYrZqVzP.js +12 -0
- package/client/dist/assets/pdf.worker-BA9kU3Pw.mjs +61080 -0
- package/client/dist/assets/percentages-BXMCSKIN-C9GT0OD3.js +199 -0
- package/client/dist/assets/pica-VkdyTzi8.js +2 -0
- package/client/dist/assets/pieDiagram-8a3498a8-Cvfh7Qr5.js +35 -0
- package/client/dist/assets/pl-PL-T2D74RX3-D4xFVSoT.js +9 -0
- package/client/dist/assets/pt-BR-5N22H2LF-CCq257gA.js +9 -0
- package/client/dist/assets/pt-PT-UZXXM6DQ-1l8gt5vA.js +9 -0
- package/client/dist/assets/quadrantDiagram-120e2f19-BA0js1aD.js +7 -0
- package/client/dist/assets/requirementDiagram-deff3bca-B0QNFfIn.js +52 -0
- package/client/dist/assets/ro-RO-JPDTUUEW-yosBW01E.js +11 -0
- package/client/dist/assets/roundRect-mAH3dD0p.js +1 -0
- package/client/dist/assets/ru-RU-B4JR7IUQ-8LkEJUix.js +9 -0
- package/client/dist/assets/sankeyDiagram-04a897e0-D4T9eCXn.js +8 -0
- package/client/dist/assets/sequenceDiagram-704730f1-CfBUTCrO.js +122 -0
- package/client/dist/assets/si-LK-N5RQ5JYF-D8rjbqtd.js +1 -0
- package/client/dist/assets/sk-SK-C5VTKIMK-Bg14sAzN.js +6 -0
- package/client/dist/assets/sl-SI-NN7IZMDC-CMTib6Zs.js +6 -0
- package/client/dist/assets/stateDiagram-587899a1-BGgvmVSZ.js +1 -0
- package/client/dist/assets/stateDiagram-v2-d93cdb3a-Qn3DpYuO.js +1 -0
- package/client/dist/assets/styles-6aaf32cf-IdVZLPrD.js +207 -0
- package/client/dist/assets/styles-9a916d00-BAC3L45X.js +160 -0
- package/client/dist/assets/styles-c10674c1-COhXxX8c.js +116 -0
- package/client/dist/assets/subset-shared.chunk-BWHnFai4.js +22 -0
- package/client/dist/assets/subset-worker.chunk-C8QUSruZ.js +1 -0
- package/client/dist/assets/sv-SE-XGPEYMSR-C1425rOF.js +10 -0
- package/client/dist/assets/svgDrawCommon-08f97a94-Cfk-fgnN.js +1 -0
- package/client/dist/assets/ta-IN-2NMHFXQM-BHHo1zpF.js +9 -0
- package/client/dist/assets/th-TH-HPSO5L25-CZVzm_WT.js +2 -0
- package/client/dist/assets/timeline-definition-85554ec2-VAvuJith.js +61 -0
- package/client/dist/assets/tr-TR-DEFEU3FU-DE1lclCq.js +7 -0
- package/client/dist/assets/uk-UA-QMV73CPH-D4lJZ85O.js +6 -0
- package/client/dist/assets/vendor-codemirror-BARtJV1V.js +16 -0
- package/client/dist/assets/vendor-codemirror-langs-52_y1wip.js +20 -0
- package/client/dist/assets/vendor-i18n-ByAl-gdx.js +1 -0
- package/client/dist/assets/vendor-icons-D33IkSIf.js +1 -0
- package/client/dist/assets/vendor-markdown-CIVH08vJ.js +298 -0
- package/client/dist/assets/vendor-react-CHoMc7ka.js +8 -0
- package/client/dist/assets/vendor-syntax-Djb62v3a.js +9 -0
- package/client/dist/assets/vendor-xterm-DBb3RXlu.js +66 -0
- package/client/dist/assets/vendor-xterm-DrlLKa8f.css +1 -0
- package/client/dist/assets/vi-VN-M7AON7JQ-Dgc_SShk.js +5 -0
- package/client/dist/assets/xychartDiagram-e933f94c-BeyVBJhb.js +7 -0
- package/client/dist/assets/zh-CN-LNUGB5OW-MH4Yh8in.js +10 -0
- package/client/dist/assets/zh-HK-E62DVLB3-D4XHehjx.js +1 -0
- package/client/dist/assets/zh-TW-RAJ6MFWO--efj3evj.js +9 -0
- package/client/dist/clear-cache.html +85 -0
- package/client/dist/convert-icons.md +53 -0
- package/client/dist/favicon.png +0 -0
- package/client/dist/favicon.svg +9 -0
- package/client/dist/generate-icons.js +49 -0
- package/client/dist/icons/claude-ai-icon.svg +1 -0
- package/client/dist/icons/codex-white.svg +3 -0
- package/client/dist/icons/codex.svg +3 -0
- package/client/dist/icons/cursor-white.svg +12 -0
- package/client/dist/icons/cursor.svg +1 -0
- package/client/dist/icons/icon-128x128.png +0 -0
- package/client/dist/icons/icon-128x128.svg +12 -0
- package/client/dist/icons/icon-144x144.png +0 -0
- package/client/dist/icons/icon-144x144.svg +12 -0
- package/client/dist/icons/icon-152x152.png +0 -0
- package/client/dist/icons/icon-152x152.svg +12 -0
- package/client/dist/icons/icon-192x192.png +0 -0
- package/client/dist/icons/icon-192x192.svg +12 -0
- package/client/dist/icons/icon-384x384.png +0 -0
- package/client/dist/icons/icon-384x384.svg +12 -0
- package/client/dist/icons/icon-512x512.png +0 -0
- package/client/dist/icons/icon-512x512.svg +12 -0
- package/client/dist/icons/icon-72x72.png +0 -0
- package/client/dist/icons/icon-72x72.svg +12 -0
- package/client/dist/icons/icon-96x96.png +0 -0
- package/client/dist/icons/icon-96x96.svg +12 -0
- package/client/dist/icons/icon-template.svg +12 -0
- package/client/dist/index.html +128 -0
- package/client/dist/logo-128.png +0 -0
- package/client/dist/logo-256.png +0 -0
- package/client/dist/logo-32.png +0 -0
- package/client/dist/logo-512.png +0 -0
- package/client/dist/logo-64.png +0 -0
- package/client/dist/logo.svg +17 -0
- package/client/dist/manifest.json +61 -0
- package/client/dist/mcp-docs.html +119 -0
- package/client/dist/screenshots/cli-selection.png +0 -0
- package/client/dist/screenshots/desktop-main.png +0 -0
- package/client/dist/screenshots/mobile-chat.png +0 -0
- package/client/dist/screenshots/tools-modal.png +0 -0
- package/client/dist/sw.js +19 -0
- package/commands/upfynai-connect.md +46 -0
- package/commands/upfynai-disconnect.md +31 -0
- package/commands/upfynai-doctor.md +99 -0
- package/commands/upfynai-export.md +49 -0
- package/commands/upfynai-local.md +82 -0
- package/commands/upfynai-status.md +75 -0
- package/commands/upfynai-stop.md +49 -0
- package/commands/upfynai-uninstall.md +58 -0
- package/commands/upfynai.md +50 -0
- package/package.json +106 -47
- package/scripts/build-client.js +17 -0
- package/scripts/fix-node-pty.js +67 -0
- package/scripts/install-commands.js +78 -0
- package/server/claude-sdk.js +714 -0
- package/server/cli.js +419 -0
- package/server/constants/config.js +5 -0
- package/server/cursor-cli.js +270 -0
- package/server/database/auth.db +0 -0
- package/server/database/db.js +606 -0
- package/server/database/init.sql +70 -0
- package/server/index.js +2269 -0
- package/server/load-env.js +26 -0
- package/server/mcp-server.js +620 -0
- package/server/middleware/auth.js +158 -0
- package/server/openai-codex.js +403 -0
- package/server/projects.js +1849 -0
- package/server/relay-client.js +314 -0
- package/server/routes/agent.js +1231 -0
- package/server/routes/auth.js +220 -0
- package/server/routes/cli-auth.js +263 -0
- package/server/routes/codex.js +344 -0
- package/server/routes/commands.js +601 -0
- package/server/routes/cursor.js +808 -0
- package/server/routes/git.js +1165 -0
- package/server/routes/mcp-utils.js +48 -0
- package/server/routes/mcp.js +552 -0
- package/server/routes/payments.js +172 -0
- package/server/routes/projects.js +549 -0
- package/server/routes/settings.js +178 -0
- package/server/routes/taskmaster.js +1964 -0
- package/server/routes/user.js +106 -0
- package/server/utils/commandParser.js +303 -0
- package/server/utils/gitConfig.js +24 -0
- package/server/utils/mcp-detector.js +198 -0
- package/server/utils/taskmaster-websocket.js +129 -0
- package/shared/modelConstants.js +67 -0
- package/LICENSE +0 -22
- package/bin/cli.js +0 -86
- package/dist/assets/CanvasPanel-B48gAKVY.js +0 -538
- package/dist/assets/CanvasPanel-B48gAKVY.js.map +0 -1
- package/dist/assets/CanvasPanel-BsOG3EVs.css +0 -1
- package/dist/assets/index-CEhTwG68.css +0 -1
- package/dist/assets/index-GqAGWpJI.js +0 -70
- package/dist/assets/index-GqAGWpJI.js.map +0 -1
- package/dist/index.html +0 -18
- package/index.html +0 -17
- package/src/App.tsx +0 -226
- package/src/components/canvas/CanvasPanel.tsx +0 -62
- package/src/components/canvas/layout/graph-builder.ts +0 -136
- package/src/components/canvas/shapes/CompactionNodeShape.tsx +0 -76
- package/src/components/canvas/shapes/SessionNodeShape.tsx +0 -93
- package/src/components/canvas/shapes/StatuslineWidgetShape.tsx +0 -125
- package/src/components/canvas/shapes/TextResponseNodeShape.tsx +0 -86
- package/src/components/canvas/shapes/ToolCallNodeShape.tsx +0 -107
- package/src/components/canvas/shapes/ToolResultNodeShape.tsx +0 -87
- package/src/components/canvas/shapes/shared-styles.ts +0 -35
- package/src/components/chat/ChatPanel.tsx +0 -96
- package/src/components/chat/InputBar.tsx +0 -81
- package/src/components/chat/MessageList.tsx +0 -130
- package/src/components/chat/PermissionDialog.tsx +0 -70
- package/src/components/layout/FolderSelector.tsx +0 -152
- package/src/components/layout/ModelSelector.tsx +0 -65
- package/src/components/layout/SessionManager.tsx +0 -115
- package/src/components/statusline/StatuslineBar.tsx +0 -114
- package/src/main.tsx +0 -10
- package/src/server/claude-session.ts +0 -156
- package/src/server/index.ts +0 -149
- package/src/services/stream-consumer.ts +0 -330
- package/src/statusline-core/bin/statusline.sh +0 -121
- package/src/statusline-core/commands/sls-config.md +0 -42
- package/src/statusline-core/commands/sls-doctor.md +0 -35
- package/src/statusline-core/commands/sls-help.md +0 -48
- package/src/statusline-core/commands/sls-layout.md +0 -38
- package/src/statusline-core/commands/sls-preview.md +0 -34
- package/src/statusline-core/commands/sls-theme.md +0 -40
- package/src/statusline-core/installer.js +0 -228
- package/src/statusline-core/layouts/compact.sh +0 -21
- package/src/statusline-core/layouts/full.sh +0 -62
- package/src/statusline-core/layouts/standard.sh +0 -39
- package/src/statusline-core/lib/core.sh +0 -389
- package/src/statusline-core/lib/helpers.sh +0 -81
- package/src/statusline-core/lib/json-parser.sh +0 -71
- package/src/statusline-core/themes/catppuccin.sh +0 -32
- package/src/statusline-core/themes/default.sh +0 -37
- package/src/statusline-core/themes/gruvbox.sh +0 -32
- package/src/statusline-core/themes/nord.sh +0 -32
- package/src/statusline-core/themes/tokyo-night.sh +0 -32
- package/src/store/canvas-store.ts +0 -50
- package/src/store/chat-store.ts +0 -60
- package/src/store/permission-store.ts +0 -29
- package/src/store/session-store.ts +0 -52
- package/src/store/statusline-store.ts +0 -160
- package/src/styles/global.css +0 -117
- package/src/themes/index.ts +0 -149
- package/src/types/canvas-graph.ts +0 -24
- package/src/types/sdk-messages.ts +0 -156
- package/src/types/statusline-fields.ts +0 -67
- package/src/vite-env.d.ts +0 -1
- package/tsconfig.json +0 -26
- package/vite.config.ts +0 -24
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import { spawn, type ChildProcess } from 'node:child_process';
|
|
2
|
-
import { createInterface } from 'node:readline';
|
|
3
|
-
import type { SDKMessage } from '../types/sdk-messages.js';
|
|
4
|
-
|
|
5
|
-
interface SessionOptions {
|
|
6
|
-
cwd: string;
|
|
7
|
-
model?: string;
|
|
8
|
-
permissionMode?: string;
|
|
9
|
-
onMessage: (msg: SDKMessage) => void;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface PendingPermission {
|
|
13
|
-
resolve: (approved: boolean) => void;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export class ClaudeSession {
|
|
17
|
-
private process: ChildProcess | null = null;
|
|
18
|
-
private options: SessionOptions;
|
|
19
|
-
private pendingPermissions = new Map<string, PendingPermission>();
|
|
20
|
-
private sessionId: string | null = null;
|
|
21
|
-
private isRunning = false;
|
|
22
|
-
|
|
23
|
-
constructor(options: SessionOptions) {
|
|
24
|
-
this.options = options;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
async sendPrompt(prompt: string, resumeSessionId?: string): Promise<void> {
|
|
28
|
-
if (this.isRunning) {
|
|
29
|
-
// If already running with stream-json input, send as user message
|
|
30
|
-
if (this.process?.stdin?.writable) {
|
|
31
|
-
const msg = JSON.stringify({
|
|
32
|
-
type: 'user',
|
|
33
|
-
message: { role: 'user', content: prompt },
|
|
34
|
-
});
|
|
35
|
-
this.process.stdin.write(msg + '\n');
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
throw new Error('Session is busy');
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
this.isRunning = true;
|
|
42
|
-
|
|
43
|
-
const args = [
|
|
44
|
-
'--print',
|
|
45
|
-
'--verbose',
|
|
46
|
-
'--output-format', 'stream-json',
|
|
47
|
-
'--input-format', 'stream-json',
|
|
48
|
-
];
|
|
49
|
-
|
|
50
|
-
if (this.options.model) {
|
|
51
|
-
args.push('--model', this.options.model);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (this.options.permissionMode && this.options.permissionMode !== 'default') {
|
|
55
|
-
args.push('--permission-mode', this.options.permissionMode);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (resumeSessionId) {
|
|
59
|
-
args.push('--resume', resumeSessionId);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
this.process = spawn('claude', args, {
|
|
63
|
-
stdio: ['pipe', 'pipe', 'pipe'],
|
|
64
|
-
cwd: this.options.cwd,
|
|
65
|
-
shell: true,
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
// Send the initial prompt
|
|
69
|
-
if (this.process.stdin) {
|
|
70
|
-
const msg = JSON.stringify({
|
|
71
|
-
type: 'user',
|
|
72
|
-
message: { role: 'user', content: prompt },
|
|
73
|
-
});
|
|
74
|
-
this.process.stdin.write(msg + '\n');
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Read NDJSON from stdout
|
|
78
|
-
if (this.process.stdout) {
|
|
79
|
-
const rl = createInterface({ input: this.process.stdout });
|
|
80
|
-
rl.on('line', (line: string) => {
|
|
81
|
-
if (!line.trim()) return;
|
|
82
|
-
try {
|
|
83
|
-
const event = JSON.parse(line) as SDKMessage;
|
|
84
|
-
|
|
85
|
-
// Track session ID
|
|
86
|
-
if (event.type === 'system' && 'subtype' in event && event.subtype === 'init') {
|
|
87
|
-
this.sessionId = event.session_id;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// Handle result — mark as not running
|
|
91
|
-
if (event.type === 'result') {
|
|
92
|
-
this.isRunning = false;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
this.options.onMessage(event);
|
|
96
|
-
} catch {
|
|
97
|
-
// Non-JSON line (debug output)
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// Log stderr
|
|
103
|
-
if (this.process.stderr) {
|
|
104
|
-
const rl = createInterface({ input: this.process.stderr });
|
|
105
|
-
rl.on('line', (line: string) => {
|
|
106
|
-
if (line.trim()) {
|
|
107
|
-
console.error(` [claude stderr] ${line}`);
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
this.process.on('exit', (code) => {
|
|
113
|
-
this.isRunning = false;
|
|
114
|
-
this.process = null;
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
this.process.on('error', (err) => {
|
|
118
|
-
this.isRunning = false;
|
|
119
|
-
console.error(' Claude process error:', err.message);
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
resolvePermission(requestId: string, approved: boolean): void {
|
|
124
|
-
const pending = this.pendingPermissions.get(requestId);
|
|
125
|
-
if (pending) {
|
|
126
|
-
pending.resolve(approved);
|
|
127
|
-
this.pendingPermissions.delete(requestId);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// Also send permission response through stdin if process is running
|
|
131
|
-
if (this.process?.stdin?.writable) {
|
|
132
|
-
const response = JSON.stringify({
|
|
133
|
-
type: 'permission_response',
|
|
134
|
-
tool_use_id: requestId,
|
|
135
|
-
allowed: approved,
|
|
136
|
-
});
|
|
137
|
-
this.process.stdin.write(response + '\n');
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
getSessionId(): string | null {
|
|
142
|
-
return this.sessionId;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
isActive(): boolean {
|
|
146
|
-
return this.isRunning;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
kill(): void {
|
|
150
|
-
if (this.process) {
|
|
151
|
-
this.process.kill('SIGTERM');
|
|
152
|
-
this.process = null;
|
|
153
|
-
this.isRunning = false;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
package/src/server/index.ts
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import { Hono } from 'hono';
|
|
2
|
-
import { serve } from '@hono/node-server';
|
|
3
|
-
import { streamSSE } from 'hono/streaming';
|
|
4
|
-
import { cors } from 'hono/cors';
|
|
5
|
-
import { ClaudeSession } from './claude-session.js';
|
|
6
|
-
import type { SDKMessage } from '../types/sdk-messages.js';
|
|
7
|
-
|
|
8
|
-
const app = new Hono();
|
|
9
|
-
app.use('*', cors());
|
|
10
|
-
|
|
11
|
-
let session: ClaudeSession | null = null;
|
|
12
|
-
const sseClients: Set<(msg: SDKMessage) => void> = new Set();
|
|
13
|
-
|
|
14
|
-
const PROJECT_CWD = process.env.UPFYN_CWD || process.cwd();
|
|
15
|
-
|
|
16
|
-
// Broadcast to all SSE clients
|
|
17
|
-
function broadcast(msg: SDKMessage) {
|
|
18
|
-
for (const send of sseClients) {
|
|
19
|
-
send(msg);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// SSE stream endpoint
|
|
24
|
-
app.get('/api/stream', (c) => {
|
|
25
|
-
return streamSSE(c, async (stream) => {
|
|
26
|
-
const send = (msg: SDKMessage) => {
|
|
27
|
-
stream.writeSSE({ data: JSON.stringify(msg), event: 'message' });
|
|
28
|
-
};
|
|
29
|
-
sseClients.add(send);
|
|
30
|
-
|
|
31
|
-
// Keep alive
|
|
32
|
-
const keepAlive = setInterval(() => {
|
|
33
|
-
stream.writeSSE({ data: '', event: 'ping' });
|
|
34
|
-
}, 15000);
|
|
35
|
-
|
|
36
|
-
stream.onAbort(() => {
|
|
37
|
-
sseClients.delete(send);
|
|
38
|
-
clearInterval(keepAlive);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
// Block until aborted
|
|
42
|
-
await new Promise(() => {});
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
// Send a prompt
|
|
47
|
-
app.post('/api/prompt', async (c) => {
|
|
48
|
-
const body = await c.req.json<{ prompt: string; sessionId?: string; cwd?: string }>();
|
|
49
|
-
|
|
50
|
-
if (!session) {
|
|
51
|
-
session = new ClaudeSession({
|
|
52
|
-
cwd: body.cwd || PROJECT_CWD,
|
|
53
|
-
onMessage: broadcast,
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
try {
|
|
58
|
-
await session.sendPrompt(body.prompt, body.sessionId);
|
|
59
|
-
return c.json({ ok: true });
|
|
60
|
-
} catch (err: any) {
|
|
61
|
-
return c.json({ ok: false, error: err.message }, 500);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
// Respond to permission request
|
|
66
|
-
app.post('/api/permission/respond', async (c) => {
|
|
67
|
-
const body = await c.req.json<{ requestId: string; approved: boolean }>();
|
|
68
|
-
|
|
69
|
-
if (session) {
|
|
70
|
-
session.resolvePermission(body.requestId, body.approved);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return c.json({ ok: true });
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
// Get session info
|
|
77
|
-
app.get('/api/session', (c) => {
|
|
78
|
-
return c.json({
|
|
79
|
-
active: session !== null,
|
|
80
|
-
cwd: PROJECT_CWD,
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
// Git status endpoint (for statusline)
|
|
85
|
-
app.get('/api/git-status', async (c) => {
|
|
86
|
-
const cwd = c.req.query('cwd') || PROJECT_CWD;
|
|
87
|
-
const { execSync } = await import('child_process');
|
|
88
|
-
|
|
89
|
-
try {
|
|
90
|
-
const branch = execSync('git symbolic-ref --short HEAD 2>/dev/null || git rev-parse --short HEAD', { cwd, encoding: 'utf-8' }).trim();
|
|
91
|
-
let remoteUrl = '';
|
|
92
|
-
try { remoteUrl = execSync('git remote get-url origin', { cwd, encoding: 'utf-8' }).trim(); } catch {}
|
|
93
|
-
|
|
94
|
-
let ghUser = '', ghRepo = '';
|
|
95
|
-
const ghMatch = remoteUrl.match(/github\.com[:/]([^/]+)\/([^/.]+)/);
|
|
96
|
-
if (ghMatch) { ghUser = ghMatch[1]; ghRepo = ghMatch[2]; }
|
|
97
|
-
|
|
98
|
-
let staged = false, unstaged = false;
|
|
99
|
-
try { execSync('git diff --cached --quiet', { cwd }); } catch { staged = true; }
|
|
100
|
-
try { execSync('git diff --quiet', { cwd }); } catch { unstaged = true; }
|
|
101
|
-
|
|
102
|
-
return c.json({ branch, ghUser, ghRepo, staged, unstaged });
|
|
103
|
-
} catch {
|
|
104
|
-
return c.json({ branch: 'no-git', ghUser: '', ghRepo: '', staged: false, unstaged: false });
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
// Discover Claude Code projects from ~/.claude/projects/
|
|
109
|
-
app.get('/api/projects', async (c) => {
|
|
110
|
-
const { readdirSync, statSync } = await import('fs');
|
|
111
|
-
const { join } = await import('path');
|
|
112
|
-
const home = process.env.HOME || process.env.USERPROFILE || '';
|
|
113
|
-
const projectsDir = join(home, '.claude', 'projects');
|
|
114
|
-
|
|
115
|
-
try {
|
|
116
|
-
const entries = readdirSync(projectsDir);
|
|
117
|
-
const projects = entries
|
|
118
|
-
.map((name) => {
|
|
119
|
-
const fullPath = join(projectsDir, name);
|
|
120
|
-
try {
|
|
121
|
-
const stat = statSync(fullPath);
|
|
122
|
-
if (!stat.isDirectory()) return null;
|
|
123
|
-
// Decode the project hash back to a path
|
|
124
|
-
let decoded = name
|
|
125
|
-
.replace(/^([A-Z])--/, '$1:/')
|
|
126
|
-
.replace(/-/g, '/');
|
|
127
|
-
return {
|
|
128
|
-
path: decoded,
|
|
129
|
-
name: decoded.split('/').pop() || name,
|
|
130
|
-
lastUsed: stat.mtimeMs,
|
|
131
|
-
};
|
|
132
|
-
} catch { return null; }
|
|
133
|
-
})
|
|
134
|
-
.filter(Boolean)
|
|
135
|
-
.sort((a: any, b: any) => b.lastUsed - a.lastUsed)
|
|
136
|
-
.slice(0, 20);
|
|
137
|
-
|
|
138
|
-
return c.json({ projects });
|
|
139
|
-
} catch {
|
|
140
|
-
return c.json({ projects: [] });
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
// Health check
|
|
145
|
-
app.get('/api/health', (c) => c.json({ status: 'ok', version: '0.1.0' }));
|
|
146
|
-
|
|
147
|
-
const port = parseInt(process.env.UPFYN_PORT || '3210');
|
|
148
|
-
console.log(` \x1b[38;2;34;197;94m✓\x1b[0m API server running on http://localhost:${port}`);
|
|
149
|
-
serve({ fetch: app.fetch, port });
|
|
@@ -1,330 +0,0 @@
|
|
|
1
|
-
import type { SDKMessage, ContentBlockToolUse, ToolResultContent } from '../types/sdk-messages';
|
|
2
|
-
import { useSessionStore } from '../store/session-store';
|
|
3
|
-
import { useChatStore } from '../store/chat-store';
|
|
4
|
-
import { useStatuslineStore } from '../store/statusline-store';
|
|
5
|
-
import { usePermissionStore } from '../store/permission-store';
|
|
6
|
-
import { useCanvasStore } from '../store/canvas-store';
|
|
7
|
-
|
|
8
|
-
let eventSource: EventSource | null = null;
|
|
9
|
-
let messageCounter = 0;
|
|
10
|
-
|
|
11
|
-
function nextId(): string {
|
|
12
|
-
return `msg-${++messageCounter}-${Date.now()}`;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function connectSSE(baseUrl = '') {
|
|
16
|
-
if (eventSource) {
|
|
17
|
-
eventSource.close();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
eventSource = new EventSource(`${baseUrl}/api/stream`);
|
|
21
|
-
|
|
22
|
-
eventSource.addEventListener('message', (event) => {
|
|
23
|
-
if (!event.data) return;
|
|
24
|
-
|
|
25
|
-
try {
|
|
26
|
-
const msg: SDKMessage = JSON.parse(event.data);
|
|
27
|
-
handleMessage(msg);
|
|
28
|
-
} catch {
|
|
29
|
-
// Ignore parse errors
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
eventSource.addEventListener('open', () => {
|
|
34
|
-
useSessionStore.getState().setConnected(true);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
eventSource.addEventListener('error', () => {
|
|
38
|
-
useSessionStore.getState().setConnected(false);
|
|
39
|
-
// Auto-reconnect is handled by EventSource
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
return eventSource;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export function disconnectSSE() {
|
|
46
|
-
if (eventSource) {
|
|
47
|
-
eventSource.close();
|
|
48
|
-
eventSource = null;
|
|
49
|
-
}
|
|
50
|
-
useSessionStore.getState().setConnected(false);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function handleMessage(msg: SDKMessage) {
|
|
54
|
-
const chat = useChatStore.getState();
|
|
55
|
-
const session = useSessionStore.getState();
|
|
56
|
-
const statusline = useStatuslineStore.getState();
|
|
57
|
-
const permissions = usePermissionStore.getState();
|
|
58
|
-
const canvas = useCanvasStore.getState();
|
|
59
|
-
|
|
60
|
-
switch (msg.type) {
|
|
61
|
-
case 'system': {
|
|
62
|
-
if ('subtype' in msg && msg.subtype === 'init') {
|
|
63
|
-
session.setInit({
|
|
64
|
-
sessionId: msg.session_id,
|
|
65
|
-
model: msg.model,
|
|
66
|
-
cwd: msg.cwd,
|
|
67
|
-
tools: msg.tools,
|
|
68
|
-
permissionMode: msg.permissionMode,
|
|
69
|
-
});
|
|
70
|
-
statusline.updateFromInit(msg.model, msg.cwd, msg.session_id, msg.permissionMode);
|
|
71
|
-
|
|
72
|
-
// Fetch git status
|
|
73
|
-
fetchGitStatus(msg.cwd);
|
|
74
|
-
|
|
75
|
-
// Canvas: session node
|
|
76
|
-
canvas.addNode({
|
|
77
|
-
id: `session-${msg.session_id}`,
|
|
78
|
-
type: 'session',
|
|
79
|
-
label: msg.model,
|
|
80
|
-
data: { model: msg.model, cwd: msg.cwd, session_id: msg.session_id, tools: msg.tools },
|
|
81
|
-
timestamp: Date.now(),
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
chat.addMessage({
|
|
85
|
-
id: nextId(),
|
|
86
|
-
role: 'system',
|
|
87
|
-
content: `Connected to Claude Code (${msg.model})`,
|
|
88
|
-
timestamp: Date.now(),
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
if ('subtype' in msg && msg.subtype === 'compact_boundary') {
|
|
92
|
-
statusline.markCompaction(msg.compact_metadata.pre_tokens);
|
|
93
|
-
|
|
94
|
-
// Canvas: compaction node
|
|
95
|
-
canvas.addNode({
|
|
96
|
-
id: `compact-${Date.now()}`,
|
|
97
|
-
type: 'compaction',
|
|
98
|
-
label: 'Compaction',
|
|
99
|
-
data: { pre_tokens: msg.compact_metadata.pre_tokens, trigger: msg.compact_metadata.trigger },
|
|
100
|
-
timestamp: Date.now(),
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
chat.addMessage({
|
|
104
|
-
id: nextId(),
|
|
105
|
-
role: 'system',
|
|
106
|
-
content: `Context compacted (was ${Math.round(msg.compact_metadata.pre_tokens / 1000)}k tokens)`,
|
|
107
|
-
timestamp: Date.now(),
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
case 'stream_event': {
|
|
114
|
-
session.setStreaming(true);
|
|
115
|
-
const evt = msg.event;
|
|
116
|
-
|
|
117
|
-
if (evt.type === 'content_block_delta' && evt.delta) {
|
|
118
|
-
if (evt.delta.type === 'text_delta' && evt.delta.text) {
|
|
119
|
-
chat.appendStreamDelta(evt.delta.text);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if (evt.type === 'content_block_start' && evt.content_block) {
|
|
124
|
-
if (evt.content_block.type === 'tool_use' && evt.content_block.name) {
|
|
125
|
-
chat.setStreamingToolName(evt.content_block.name);
|
|
126
|
-
statusline.updateSkill(evt.content_block.name);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (evt.type === 'message_stop') {
|
|
131
|
-
session.setStreaming(false);
|
|
132
|
-
}
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
case 'assistant': {
|
|
137
|
-
// Finalize any streaming text
|
|
138
|
-
chat.finalizeStreaming(msg.message.usage);
|
|
139
|
-
|
|
140
|
-
// Process content blocks
|
|
141
|
-
for (const block of msg.message.content) {
|
|
142
|
-
if (block.type === 'tool_use') {
|
|
143
|
-
const toolBlock = block as ContentBlockToolUse;
|
|
144
|
-
chat.addMessage({
|
|
145
|
-
id: nextId(),
|
|
146
|
-
role: 'tool_call',
|
|
147
|
-
content: JSON.stringify(toolBlock.input, null, 2),
|
|
148
|
-
toolName: toolBlock.name,
|
|
149
|
-
toolUseId: toolBlock.id,
|
|
150
|
-
timestamp: Date.now(),
|
|
151
|
-
});
|
|
152
|
-
statusline.updateSkill(toolBlock.name);
|
|
153
|
-
|
|
154
|
-
// Canvas: tool call node
|
|
155
|
-
canvas.addNode({
|
|
156
|
-
id: `tool-${toolBlock.id}`,
|
|
157
|
-
type: 'toolCall',
|
|
158
|
-
label: toolBlock.name,
|
|
159
|
-
data: { name: toolBlock.name, input: toolBlock.input, id: toolBlock.id },
|
|
160
|
-
timestamp: Date.now(),
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// Canvas: text response for non-tool text blocks
|
|
165
|
-
const textBlocks = msg.message.content.filter(b => b.type === 'text');
|
|
166
|
-
if (textBlocks.length > 0) {
|
|
167
|
-
const fullText = textBlocks.map(b => (b as { text: string }).text).join('');
|
|
168
|
-
if (fullText.trim()) {
|
|
169
|
-
canvas.addNode({
|
|
170
|
-
id: `text-${msg.uuid}`,
|
|
171
|
-
type: 'textResponse',
|
|
172
|
-
label: 'Response',
|
|
173
|
-
data: { text: fullText },
|
|
174
|
-
timestamp: Date.now(),
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// Update statusline with usage
|
|
181
|
-
if (msg.message.usage) {
|
|
182
|
-
statusline.updateFromUsage(msg.message.usage);
|
|
183
|
-
}
|
|
184
|
-
break;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
case 'user': {
|
|
188
|
-
if (Array.isArray(msg.message.content)) {
|
|
189
|
-
for (const block of msg.message.content) {
|
|
190
|
-
if ((block as ToolResultContent).type === 'tool_result') {
|
|
191
|
-
const result = block as ToolResultContent;
|
|
192
|
-
chat.addMessage({
|
|
193
|
-
id: nextId(),
|
|
194
|
-
role: 'tool_result',
|
|
195
|
-
content: typeof result.content === 'string'
|
|
196
|
-
? result.content.slice(0, 2000)
|
|
197
|
-
: JSON.stringify(result.content).slice(0, 2000),
|
|
198
|
-
toolUseId: result.tool_use_id,
|
|
199
|
-
isError: result.is_error,
|
|
200
|
-
timestamp: Date.now(),
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
// Canvas: tool result node
|
|
204
|
-
canvas.addNode({
|
|
205
|
-
id: `result-${result.tool_use_id}`,
|
|
206
|
-
type: 'toolResult',
|
|
207
|
-
label: 'Result',
|
|
208
|
-
data: {
|
|
209
|
-
toolName: result.tool_use_id,
|
|
210
|
-
content: typeof result.content === 'string' ? result.content.slice(0, 200) : '',
|
|
211
|
-
is_error: result.is_error,
|
|
212
|
-
},
|
|
213
|
-
timestamp: Date.now(),
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
break;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
case 'result': {
|
|
222
|
-
session.setStreaming(false);
|
|
223
|
-
chat.finalizeStreaming();
|
|
224
|
-
chat.setWaiting(false);
|
|
225
|
-
|
|
226
|
-
statusline.updateFromResult({
|
|
227
|
-
cost: msg.total_cost_usd,
|
|
228
|
-
duration: msg.duration_ms,
|
|
229
|
-
numTurns: msg.num_turns,
|
|
230
|
-
usage: msg.usage,
|
|
231
|
-
modelUsage: msg.modelUsage,
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
if (msg.is_error && msg.errors) {
|
|
235
|
-
chat.addMessage({
|
|
236
|
-
id: nextId(),
|
|
237
|
-
role: 'system',
|
|
238
|
-
content: `Error: ${msg.errors.join(', ')}`,
|
|
239
|
-
isError: true,
|
|
240
|
-
timestamp: Date.now(),
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
break;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
case 'permission_request': {
|
|
247
|
-
permissions.addRequest({
|
|
248
|
-
requestId: msg.requestId,
|
|
249
|
-
toolName: msg.toolName,
|
|
250
|
-
toolInput: msg.toolInput,
|
|
251
|
-
timestamp: Date.now(),
|
|
252
|
-
});
|
|
253
|
-
break;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
async function fetchGitStatus(cwd: string) {
|
|
259
|
-
try {
|
|
260
|
-
const res = await fetch(`/api/git-status?cwd=${encodeURIComponent(cwd)}`);
|
|
261
|
-
if (res.ok) {
|
|
262
|
-
const data = await res.json();
|
|
263
|
-
useStatuslineStore.getState().updateGit(data);
|
|
264
|
-
}
|
|
265
|
-
} catch {
|
|
266
|
-
// Git status not available
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
export async function sendPrompt(prompt: string) {
|
|
271
|
-
const chat = useChatStore.getState();
|
|
272
|
-
const session = useSessionStore.getState();
|
|
273
|
-
|
|
274
|
-
// Add user message to chat
|
|
275
|
-
chat.addMessage({
|
|
276
|
-
id: nextId(),
|
|
277
|
-
role: 'user',
|
|
278
|
-
content: prompt,
|
|
279
|
-
timestamp: Date.now(),
|
|
280
|
-
});
|
|
281
|
-
chat.setInput('');
|
|
282
|
-
chat.setWaiting(true);
|
|
283
|
-
|
|
284
|
-
try {
|
|
285
|
-
const res = await fetch('/api/prompt', {
|
|
286
|
-
method: 'POST',
|
|
287
|
-
headers: { 'Content-Type': 'application/json' },
|
|
288
|
-
body: JSON.stringify({
|
|
289
|
-
prompt,
|
|
290
|
-
sessionId: session.sessionId,
|
|
291
|
-
cwd: session.cwd,
|
|
292
|
-
}),
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
if (!res.ok) {
|
|
296
|
-
const err = await res.json();
|
|
297
|
-
chat.addMessage({
|
|
298
|
-
id: nextId(),
|
|
299
|
-
role: 'system',
|
|
300
|
-
content: `Failed to send: ${err.error || 'Unknown error'}`,
|
|
301
|
-
isError: true,
|
|
302
|
-
timestamp: Date.now(),
|
|
303
|
-
});
|
|
304
|
-
chat.setWaiting(false);
|
|
305
|
-
}
|
|
306
|
-
} catch (err: any) {
|
|
307
|
-
chat.addMessage({
|
|
308
|
-
id: nextId(),
|
|
309
|
-
role: 'system',
|
|
310
|
-
content: `Connection error: ${err.message}`,
|
|
311
|
-
isError: true,
|
|
312
|
-
timestamp: Date.now(),
|
|
313
|
-
});
|
|
314
|
-
chat.setWaiting(false);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
export async function respondPermission(requestId: string, approved: boolean) {
|
|
319
|
-
usePermissionStore.getState().removeRequest(requestId);
|
|
320
|
-
|
|
321
|
-
try {
|
|
322
|
-
await fetch('/api/permission/respond', {
|
|
323
|
-
method: 'POST',
|
|
324
|
-
headers: { 'Content-Type': 'application/json' },
|
|
325
|
-
body: JSON.stringify({ requestId, approved }),
|
|
326
|
-
});
|
|
327
|
-
} catch {
|
|
328
|
-
// Best effort
|
|
329
|
-
}
|
|
330
|
-
}
|