@cortex-agent/server 2026.10.28 → 2026.12.5
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 +255 -21
- package/README.md +36 -7
- package/THIRD_PARTY_NOTICES.txt +1990 -593
- package/defaults/hooks/cortex-hook-api.mjs +2 -1
- package/defaults/hooks/quota-stop.mjs +37 -0
- package/defaults/plugins/cortex-system/skills/client-manage/SKILL.md +23 -15
- package/defaults/prompts/clean-workspace.md +5 -0
- package/dist/agent-adapter/claude/remote-mcp-proxy.js +1 -1
- package/dist/chunks/agent-runner-LVZVKBZX.js +4 -0
- package/dist/chunks/anthropic-messages-TT6454AA.js +8 -0
- package/dist/chunks/azure-openai-responses-52LR2XZD.js +4 -0
- package/dist/chunks/bedrock-converse-stream-EOZGYUNY.js +60 -0
- package/dist/chunks/bowser-MLGGLXTZ.js +20 -0
- package/dist/chunks/child-runner-SMG2VOU5.js +4 -0
- package/dist/chunks/chunk-24DH4IR5.js +4 -0
- package/dist/chunks/chunk-25XKBRDT.js +70 -0
- package/dist/chunks/chunk-2ABET62E.js +23 -0
- package/dist/chunks/chunk-2BVUA256.js +4 -0
- package/dist/chunks/{chunk-LEUENXI2.js → chunk-2WFL62UO.js} +1 -1
- package/dist/chunks/{chunk-OZGBWAT2.js → chunk-2YTYYG4K.js} +1 -1
- package/dist/chunks/chunk-335SSANX.js +4 -0
- package/dist/chunks/chunk-377OPTXX.js +17 -0
- package/dist/chunks/chunk-3EZNVLBF.js +129 -0
- package/dist/chunks/chunk-3O6ZG5HA.js +7 -0
- package/dist/chunks/{chunk-6AKUD3CF.js → chunk-3XLHL5YT.js} +1 -1
- package/dist/chunks/chunk-4HRI75GU.js +4 -0
- package/dist/chunks/chunk-4JBYLRPM.js +57 -0
- package/dist/chunks/chunk-4KKV7VKE.js +4 -0
- package/dist/chunks/chunk-4KQHDDC5.js +4 -0
- package/dist/chunks/chunk-4SWD4JMP.js +33 -0
- package/dist/chunks/chunk-52VCLZS5.js +4 -0
- package/dist/chunks/chunk-54P7TSY3.js +10 -0
- package/dist/chunks/chunk-5DVSAXOI.js +7 -0
- package/dist/chunks/chunk-5F3A62YS.js +4 -0
- package/dist/chunks/{chunk-XNSSUVT6.js → chunk-5FHETFZM.js} +1 -1
- package/dist/chunks/{chunk-A34TDMIC.js → chunk-5LBLRAHS.js} +1 -1
- package/dist/chunks/chunk-5UYVNA3W.js +4 -0
- package/dist/chunks/chunk-6G3OYMCV.js +21 -0
- package/dist/chunks/chunk-7GGPYU5E.js +30 -0
- package/dist/chunks/chunk-7TYSMLUV.js +4 -0
- package/dist/chunks/chunk-7W7VYUTK.js +5 -0
- package/dist/chunks/chunk-AXYAZTTN.js +6 -0
- package/dist/chunks/{chunk-BGVHA2D4.js → chunk-B3NB243Z.js} +1 -1
- package/dist/chunks/chunk-BKYP6AGM.js +8 -0
- package/dist/chunks/chunk-BVEDNESB.js +4 -0
- package/dist/chunks/chunk-BWDJS6A4.js +12 -0
- package/dist/chunks/chunk-C6YVF7EI.js +4 -0
- package/dist/chunks/chunk-CEJIYYVE.js +15 -0
- package/dist/chunks/chunk-CI2RHH74.js +50 -0
- package/dist/chunks/chunk-CMSOOLJB.js +4 -0
- package/dist/chunks/chunk-CSVTYYLP.js +4 -0
- package/dist/chunks/chunk-DE5EGVKG.js +6 -0
- package/dist/chunks/{chunk-E6BYRULL.js → chunk-DK3RPZOQ.js} +1 -1
- package/dist/chunks/{chunk-YPK2CAIZ.js → chunk-DK4UCK7L.js} +1 -1
- package/dist/chunks/chunk-DYLBVUAU.js +4 -0
- package/dist/chunks/chunk-FDC2GRBK.js +27 -0
- package/dist/chunks/chunk-FE7HH5JS.js +18 -0
- package/dist/chunks/chunk-FYD57YRO.js +436 -0
- package/dist/chunks/chunk-G264APQN.js +5 -0
- package/dist/chunks/chunk-G4JYZFEO.js +11 -0
- package/dist/chunks/chunk-GFFM56U2.js +4 -0
- package/dist/chunks/chunk-GOS3P7KS.js +132 -0
- package/dist/chunks/chunk-HVN37UXD.js +4 -0
- package/dist/chunks/chunk-IA6IODY3.js +4 -0
- package/dist/chunks/{chunk-HU6UIDEJ.js → chunk-IGZWZP7Z.js} +1 -1
- package/dist/chunks/{chunk-NR6U3WIZ.js → chunk-IJ7XFQMI.js} +1 -1
- package/dist/chunks/chunk-IMMGYDAB.js +6 -0
- package/dist/chunks/chunk-IOWBF7UK.js +10 -0
- package/dist/chunks/{chunk-HALUQ7ZF.js → chunk-ITGCWQFK.js} +1 -1
- package/dist/chunks/chunk-IVZ7QUEG.js +4 -0
- package/dist/chunks/{chunk-YAEVYJAR.js → chunk-IWY2HIFK.js} +1 -1
- package/dist/chunks/{chunk-KGJZAYQD.js → chunk-J7OBATRN.js} +1 -1
- package/dist/chunks/{chunk-QWAQHHRS.js → chunk-JGUEIW2W.js} +1 -1
- package/dist/chunks/chunk-JKL3AK5D.js +106 -0
- package/dist/chunks/chunk-JZ7U7RUK.js +351 -0
- package/dist/chunks/chunk-KJUQCCB5.js +4 -0
- package/dist/chunks/chunk-KST6OY76.js +10 -0
- package/dist/chunks/chunk-KZSAFVSY.js +129 -0
- package/dist/chunks/chunk-LD2ZSH3M.js +903 -0
- package/dist/chunks/chunk-LE6QPXN6.js +7 -0
- package/dist/chunks/chunk-LEAV3FFG.js +4 -0
- package/dist/chunks/chunk-LIIZI3HY.js +5 -0
- package/dist/chunks/chunk-LP72AF56.js +45 -0
- package/dist/chunks/{chunk-FXDIR3SQ.js → chunk-MJQ2D2OP.js} +1 -1
- package/dist/chunks/{chunk-6LZK4DDH.js → chunk-NHHR4DCF.js} +1 -1
- package/dist/chunks/chunk-NW4GW47L.js +4 -0
- package/dist/chunks/chunk-OALEJ6FG.js +60 -0
- package/dist/chunks/chunk-OIV4DIMB.js +4 -0
- package/dist/chunks/chunk-OJ37ZWBG.js +4 -0
- package/dist/chunks/chunk-OZXMPBUX.js +4 -0
- package/dist/chunks/{chunk-3THJYAEF.js → chunk-PG7452XE.js} +1 -1
- package/dist/chunks/chunk-PJCUB7YJ.js +4 -0
- package/dist/chunks/chunk-PTS3J4DQ.js +6 -0
- package/dist/chunks/{chunk-PXS5SHOV.js → chunk-PVVEEBUU.js} +1 -1
- package/dist/chunks/chunk-Q7BZLPBU.js +8 -0
- package/dist/chunks/{chunk-FOJQXLL2.js → chunk-QC66ZXPP.js} +1 -1
- package/dist/chunks/chunk-QXFWIL4C.js +4 -0
- package/dist/chunks/{chunk-PFMEUFJ7.js → chunk-R2CCD4OF.js} +1 -1
- package/dist/chunks/chunk-R6CGBSTC.js +22 -0
- package/dist/chunks/chunk-RG5GP4RB.js +5 -0
- package/dist/chunks/{chunk-D3NXKK2L.js → chunk-RW2F2QNP.js} +1 -1
- package/dist/chunks/{models-L5VF4I5O-XXNJYQMQ.js → chunk-RWPO3NZ3.js} +1 -1
- package/dist/chunks/chunk-SAJD4EKE.js +10 -0
- package/dist/chunks/chunk-SDUS2H3E.js +4 -0
- package/dist/chunks/chunk-SIHGKM4E.js +4 -0
- package/dist/chunks/chunk-SKHFU5DI.js +4 -0
- package/dist/chunks/{chunk-STUHNKQS.js → chunk-SM45TH22.js} +1 -1
- package/dist/chunks/chunk-T54CZKNJ.js +6 -0
- package/dist/chunks/chunk-TKFFQNAP.js +19 -0
- package/dist/chunks/chunk-TMV2ZDOI.js +18 -0
- package/dist/chunks/chunk-TRXLIL7V.js +4 -0
- package/dist/chunks/{chunk-SUFW24P4.js → chunk-UEEW2R4E.js} +1 -1
- package/dist/chunks/chunk-UHXPRU6G.js +10 -0
- package/dist/chunks/chunk-UPQVWHZ3.js +4 -0
- package/dist/chunks/{chunk-JERCOLY3.js → chunk-V35MFAUQ.js} +4 -6
- package/dist/chunks/chunk-V7K3KNDM.js +4 -0
- package/dist/chunks/chunk-VHX2GHBF.js +4 -0
- package/dist/chunks/chunk-VOAKRJ4R.js +4 -0
- package/dist/chunks/{chunk-X2GYYRVM.js → chunk-VW7TLY3P.js} +1 -1
- package/dist/chunks/chunk-W34AK4SK.js +65 -0
- package/dist/chunks/{chunk-REBNWCKI.js → chunk-WU7RNAZD.js} +1 -1
- package/dist/chunks/chunk-WZC4TDDM.js +6 -0
- package/dist/chunks/chunk-WZYS2HAK.js +4 -0
- package/dist/chunks/chunk-X2TKJ7KR.js +11 -0
- package/dist/chunks/{chunk-H2FP6DG4.js → chunk-X5ND4H4P.js} +1 -1
- package/dist/chunks/{chunk-4U7XXM4W.js → chunk-Y3AOGNDT.js} +1 -1
- package/dist/chunks/chunk-Y6DGVTKM.js +6 -0
- package/dist/chunks/{chunk-KENCMLRE.js → chunk-YAEHSSR4.js} +1 -1
- package/dist/chunks/chunk-YWPBE5LP.js +4 -0
- package/dist/chunks/chunk-ZAVX7G2M.js +15 -0
- package/dist/chunks/chunk-ZD2M73XA.js +19 -0
- package/dist/chunks/chunk-ZD4O6NPV.js +4 -0
- package/dist/chunks/chunk-ZNAMETPQ.js +4 -0
- package/dist/chunks/chunk-ZY6N5LVQ.js +4 -0
- package/dist/chunks/chunk-ZYQ4TDTT.js +81 -0
- package/dist/chunks/cli-VB2N7HEK.js +55 -0
- package/dist/chunks/cloudflare-workers-ai-system-one-YKU742EC.js +4 -0
- package/dist/chunks/context-CI2FKEQE.js +4 -0
- package/dist/chunks/cost-CZRRSIUF.js +5 -0
- package/dist/chunks/dist-QCNQN6DY.js +4 -0
- package/dist/chunks/easter-egg-3d-XR5S2O3T.js +4 -0
- package/dist/chunks/{event-streams-3JSFPOTZ.js → event-streams-AVE4MSS6.js} +1 -1
- package/dist/chunks/{execution-repo-ZLJTBWFC.js → execution-repo-5TLV2NM4.js} +1 -1
- package/dist/chunks/{executions-6ARGR3IO.js → executions-I3UUIGSL.js} +1 -1
- package/dist/chunks/file-Y5G56IUT.js +4 -0
- package/dist/chunks/github-copilot-BRU2SRRZ.js +4 -0
- package/dist/chunks/google-generative-ai-ZF5QEUZV.js +4 -0
- package/dist/chunks/google-vertex-4PJZZI3Y.js +4 -0
- package/dist/chunks/init-A6GY656J.js +4 -0
- package/dist/chunks/{install-cli-4IZCSDFZ.js → install-cli-FALWKQYO.js} +1 -1
- package/dist/chunks/{interaction-ask-G5T3H3CG.js → interaction-ask-O5HGF6CH.js} +1 -1
- package/dist/chunks/{interaction-plan-E5V42MUP.js → interaction-plan-JTVDN3BC.js} +1 -1
- package/dist/chunks/kimi-coding-ZCIBMDZ6.js +4 -0
- package/dist/chunks/{llama-cpp-classify-OTXZWCMW.js → llama-cpp-classify-NRUXAIGQ.js} +3 -3
- package/dist/chunks/local-client-stop-RS4AHNF4.js +4 -0
- package/dist/chunks/{memory-cli-PYOILNN5.js → memory-cli-DIT4DQF3.js} +1 -1
- package/dist/chunks/meta-JQH66YU7.js +4 -0
- package/dist/chunks/mistral-conversations-CXHOECUV.js +7 -0
- package/dist/chunks/model-resolver-GIBPYRKP.js +4 -0
- package/dist/chunks/monitor-Z2HKNY5E.js +4 -0
- package/dist/chunks/{node-PTK2HCDV.js → node-DAO3SX7O.js} +1 -1
- package/dist/chunks/{openai-codex-2REL6UQU.js → openai-codex-JULCKICT.js} +1 -1
- package/dist/chunks/openai-codex-responses-U6DGMGDK.js +12 -0
- package/dist/chunks/openai-completions-PP4XLLOM.js +9 -0
- package/dist/chunks/{openai-decisions-2N6ZRPZC.js → openai-decisions-JU6QQKEM.js} +1 -1
- package/dist/chunks/openai-responses-2SG757TL.js +6 -0
- package/dist/chunks/openrouter-images-32M7YZWC.js +4 -0
- package/dist/chunks/pi-messages-VSINMXN4.js +10 -0
- package/dist/chunks/radius-THYKWV4E.js +4 -0
- package/dist/chunks/remote-ops-2WBEFQ3E.js +14 -0
- package/dist/chunks/runner-5MKMRTIN.js +4 -0
- package/dist/chunks/runtime-DST3H5JP.js +4 -0
- package/dist/chunks/schedule-cli-V7Y2BBVY.js +4 -0
- package/dist/chunks/slack-R7SEJYMY.js +4 -0
- package/dist/chunks/start-ui-http-7K5JOLPU.js +43 -0
- package/dist/chunks/subagent-Z5IQ4L54.js +4 -0
- package/dist/chunks/{time-KEHDQT6K.js → time-P6PE52WL.js} +1 -1
- package/dist/chunks/tool-shims-YCXZWTST.js +4 -0
- package/dist/chunks/typesafe-system-one-M2DABJSZ.js +4 -0
- package/dist/chunks/ui-board-HQIE4RZG.js +5 -0
- package/dist/chunks/ui-decision-YBZDS4YW.js +4 -0
- package/dist/chunks/{ui-file-GVH53O3X.js → ui-file-SRD4ILBS.js} +1 -1
- package/dist/chunks/ui-view-Z25MTZT7.js +4 -0
- package/dist/chunks/virtual-modules-H4DXPJZB.js +4 -0
- package/dist/chunks/waitpoint-M6JZBSLT.js +5 -0
- package/dist/chunks/workers-SQ2R32TK.js +4 -0
- package/dist/client-bundle/client.mjs +273 -93
- package/dist/client-bundle/manifest.json +2 -2
- package/dist/core/pi-sdk.js +1 -1
- package/dist/domain/auth/cc-auth-cli.js +1 -1
- package/dist/domain/mcp/bundled-server.js +1 -1
- package/dist/domain/mcp/feishu/client.js +4 -0
- package/dist/entry/app.js +151 -559
- package/dist/entry/browser-cli.js +10 -10
- package/dist/entry/cli.js +1 -1
- package/dist/entry/cortex-cli.js +1 -1
- package/dist/entry/daemon.js +4 -4
- package/dist/entry/hook-cli.js +2 -2
- package/dist/entry/production-app-bootstrap.js +1 -1
- package/dist/entry/production-evidence-export-cli.js +1 -1
- package/dist/entry/signal-cli.js +2 -2
- package/dist/tui/index.js +41 -41
- package/package.json +3 -3
- package/vendor/pi/CHANGELOG.md +330 -0
- package/vendor/pi/dist/codemode-worker.js +2 -0
- package/vendor/pi/dist/core/export-html/ansi-to-html.js +57 -20
- package/vendor/pi/dist/core/export-html/template.css +9 -0
- package/vendor/pi/dist/core/export-html/template.js +166 -46
- package/vendor/pi/dist/core/export-html/tool-renderer.js +5 -3
- package/vendor/pi/dist/core/extensions/loader.js +1 -1
- package/vendor/pi/dist/extensions/codemode/execute.js +15 -13
- package/vendor/pi/dist/modes/interactive/theme/theme.js +36 -23
- package/vendor/pi/dist/utils/image-resize-worker.js +1 -1
- package/vendor/pi/dist/utils/image-resize.js +1 -1
- package/vendor/pi/docs/cli.md +35 -12
- package/vendor/pi/docs/custom-provider.md +2 -0
- package/vendor/pi/docs/environment-variables.md +2 -0
- package/vendor/pi/docs/extensions.md +3192 -225
- package/vendor/pi/docs/keybindings.md +2 -2
- package/vendor/pi/docs/llama-cpp.md +27 -19
- package/vendor/pi/docs/mcp.md +6 -4
- package/vendor/pi/docs/message-types.md +1 -1
- package/vendor/pi/docs/models-configuration.md +9 -3
- package/vendor/pi/docs/models.md +2 -1
- package/vendor/pi/docs/nvidia-rtx-llama-cpp.md +5 -5
- package/vendor/pi/docs/packages.md +24 -0
- package/vendor/pi/docs/prompt-templates.md +1 -1
- package/vendor/pi/docs/providers.md +4 -2
- package/vendor/pi/docs/quickstart.md +7 -3
- package/vendor/pi/docs/rpc-commands.md +1 -1
- package/vendor/pi/docs/rpc.md +4 -2
- package/vendor/pi/docs/sessions.md +17 -3
- package/vendor/pi/docs/settings.md +6 -5
- package/vendor/pi/docs/slash-commands.md +3 -2
- package/vendor/pi/docs/terminal-setup.md +3 -1
- package/vendor/pi/docs/tmux.md +6 -0
- package/vendor/pi/docs/tui.md +4 -0
- package/vendor/pi/docs/windows.md +27 -0
- package/vendor/pi/examples/extensions/README.md +2 -1
- package/vendor/pi/examples/extensions/custom-provider-anthropic/index.ts +27 -31
- package/vendor/pi/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/vendor/pi/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/vendor/pi/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/vendor/pi/examples/extensions/debug-provider.ts +2 -2
- package/vendor/pi/examples/extensions/gondolin/index.ts +4 -7
- package/vendor/pi/examples/extensions/gondolin/package-lock.json +19 -29
- package/vendor/pi/examples/extensions/gondolin/package.json +2 -2
- package/vendor/pi/examples/extensions/plan-mode/index.ts +23 -13
- package/vendor/pi/examples/extensions/plan-mode/utils.ts +42 -16
- package/vendor/pi/examples/extensions/preset.ts +2 -0
- package/vendor/pi/examples/extensions/reload-runtime.ts +17 -5
- package/vendor/pi/examples/extensions/subagent/README.md +14 -11
- package/vendor/pi/examples/extensions/subagent/index.ts +392 -171
- package/vendor/pi/examples/extensions/todo.ts +7 -0
- package/vendor/pi/examples/extensions/tools.ts +2 -0
- package/vendor/pi/examples/extensions/with-deps/package-lock.json +2 -2
- package/vendor/pi/examples/extensions/with-deps/package.json +1 -1
- package/vendor/pi/examples/tsconfig.json +208 -0
- package/vendor/pi/package.json +15 -16
- package/vendor/pi/schemas/models.schema.json +66 -37
- package/vendor/pi/schemas/settings.schema.json +18 -1
- package/vendor/pi-ai/bedrock.js +1 -1
- package/vendor/pi-ai/oauth-load.js +1 -1
- package/web/dist/assets/{board-math-css-BPXakv_3.js → board-math-css-DKX6FcUS.js} +1 -1
- package/web/dist/assets/index-D11wi0uG.js +540 -0
- package/web/dist/assets/index-JedYumhY.css +1 -0
- package/web/dist/assets/{index-WCm6wwmM.js → index-jl30Gy8P.js} +1 -1
- package/web/dist/assets/pdf-worker-DdZgk2mV.js +57 -0
- package/web/dist/assets/pdf.worker.min-Bz_KHX45.js +55 -0
- package/web/dist/index.html +2 -2
- package/web/dist/theme.css +22 -0
- package/dist/chunks/anthropic-messages-M3SMXACA.js +0 -8
- package/dist/chunks/api-GM53PHIL-GFHEXXE6.js +0 -4
- package/dist/chunks/azure-openai-responses-76YWXHSB.js +0 -4
- package/dist/chunks/bedrock-converse-stream-5UPX4NTQ.js +0 -58
- package/dist/chunks/child-runner-3GHOWGZP.js +0 -4
- package/dist/chunks/chunk-2ZNLUY2U.js +0 -128
- package/dist/chunks/chunk-3F6WW7HR.js +0 -13
- package/dist/chunks/chunk-3OKHUVEM.js +0 -7
- package/dist/chunks/chunk-3YHOCPQU.js +0 -10
- package/dist/chunks/chunk-4EX2JJWB.js +0 -4
- package/dist/chunks/chunk-4LLH5OWM.js +0 -10
- package/dist/chunks/chunk-52T37Y47.js +0 -8
- package/dist/chunks/chunk-7MU2AKNM.js +0 -4
- package/dist/chunks/chunk-AAA3UBIS.js +0 -4
- package/dist/chunks/chunk-ASYQHJVQ.js +0 -9
- package/dist/chunks/chunk-BKHDWCRT.js +0 -79
- package/dist/chunks/chunk-CQLH4UVX.js +0 -4
- package/dist/chunks/chunk-CVC66CFV.js +0 -33
- package/dist/chunks/chunk-D6UA4BZC.js +0 -19
- package/dist/chunks/chunk-DGMNI4AO.js +0 -4
- package/dist/chunks/chunk-DHSA5ACV.js +0 -125
- package/dist/chunks/chunk-DPQPXBTP.js +0 -68
- package/dist/chunks/chunk-DXBSQXJL.js +0 -18
- package/dist/chunks/chunk-E7ZMYIY6.js +0 -30
- package/dist/chunks/chunk-EQITBTJC.js +0 -10
- package/dist/chunks/chunk-EXJA5RIX.js +0 -357
- package/dist/chunks/chunk-FF7UELTU.js +0 -4
- package/dist/chunks/chunk-FH74NME3.js +0 -115
- package/dist/chunks/chunk-FOQ7VLIL.js +0 -17
- package/dist/chunks/chunk-FX6MOGLR.js +0 -11
- package/dist/chunks/chunk-G2V65UBA.js +0 -4
- package/dist/chunks/chunk-HGPBHTVD.js +0 -6
- package/dist/chunks/chunk-J5DVLUKY.js +0 -6
- package/dist/chunks/chunk-JW2HFMTF.js +0 -4
- package/dist/chunks/chunk-KDYEGGMW.js +0 -4
- package/dist/chunks/chunk-KIGMAATV.js +0 -23
- package/dist/chunks/chunk-KIU5FAPY.js +0 -5
- package/dist/chunks/chunk-KIWMQPH7.js +0 -739
- package/dist/chunks/chunk-L6VCIGWS.js +0 -11
- package/dist/chunks/chunk-LACGULCN.js +0 -10
- package/dist/chunks/chunk-LMSQZ6TQ.js +0 -4
- package/dist/chunks/chunk-MEPASGPP.js +0 -6
- package/dist/chunks/chunk-MFAEUHMV.js +0 -28
- package/dist/chunks/chunk-NAA7GF6Q.js +0 -5
- package/dist/chunks/chunk-NKDMKRSB.js +0 -68
- package/dist/chunks/chunk-NKXV32S6.js +0 -4
- package/dist/chunks/chunk-NVX5IPRN.js +0 -4
- package/dist/chunks/chunk-O3JW2F7D.js +0 -8
- package/dist/chunks/chunk-OE4KH3NJ.js +0 -4
- package/dist/chunks/chunk-OISO5JXB.js +0 -4
- package/dist/chunks/chunk-OPYXNSMY.js +0 -4
- package/dist/chunks/chunk-OSEIQ7SS.js +0 -4
- package/dist/chunks/chunk-P52RMIYX.js +0 -6
- package/dist/chunks/chunk-PBJ5MPPX.js +0 -60
- package/dist/chunks/chunk-PZMGBKUR.js +0 -13
- package/dist/chunks/chunk-PZMXHA6X.js +0 -9
- package/dist/chunks/chunk-Q7CE3UIE.js +0 -133
- package/dist/chunks/chunk-QBKCAIJG.js +0 -4
- package/dist/chunks/chunk-QEOFEETJ.js +0 -4
- package/dist/chunks/chunk-QUUEQRIT.js +0 -4
- package/dist/chunks/chunk-RA6HKFBV.js +0 -4
- package/dist/chunks/chunk-REPYBMQS.js +0 -4
- package/dist/chunks/chunk-SKHLZ6XY.js +0 -9
- package/dist/chunks/chunk-TAWLERZA.js +0 -4
- package/dist/chunks/chunk-TWAEABGG.js +0 -52
- package/dist/chunks/chunk-TZFLHVOQ.js +0 -7
- package/dist/chunks/chunk-UD3NMUHR.js +0 -12
- package/dist/chunks/chunk-UNVEZI57.js +0 -4
- package/dist/chunks/chunk-VQUPKMDR.js +0 -4
- package/dist/chunks/chunk-W25TB3PU.js +0 -4
- package/dist/chunks/chunk-W5LGYSPZ.js +0 -4
- package/dist/chunks/chunk-WEZWKMYU.js +0 -4
- package/dist/chunks/chunk-XAJLZR7C.js +0 -28
- package/dist/chunks/chunk-XH6FMP3N.js +0 -71
- package/dist/chunks/chunk-XSRZHN63.js +0 -4
- package/dist/chunks/chunk-Y3GFB5XM.js +0 -8
- package/dist/chunks/chunk-YG7OEPR2.js +0 -6
- package/dist/chunks/chunk-YHIWOGVL.js +0 -4
- package/dist/chunks/chunk-YKKEI5GI.js +0 -4
- package/dist/chunks/chunk-YZSHTWNM.js +0 -92
- package/dist/chunks/chunk-Z4H3VDHI.js +0 -4
- package/dist/chunks/cli-5DBTRMHU.js +0 -53
- package/dist/chunks/client-XOGYH5UR.js +0 -4
- package/dist/chunks/cloudflare-workers-ai-system-one-32JCFHI3.js +0 -4
- package/dist/chunks/config-DJSQI77S-335IXHSM.js +0 -4
- package/dist/chunks/context-VCQH5OB6.js +0 -4
- package/dist/chunks/cost-PGGFI7QJ.js +0 -5
- package/dist/chunks/dist-PUKMZ7GW.js +0 -4
- package/dist/chunks/easter-egg-3d-MO4MOEVF.js +0 -4
- package/dist/chunks/es5-VNTQPCKX.js +0 -4
- package/dist/chunks/file-7BN7RCAY.js +0 -4
- package/dist/chunks/gateway-UCRPMR75.js +0 -36
- package/dist/chunks/github-copilot-HAI2DA62.js +0 -4
- package/dist/chunks/google-generative-ai-2VXWLHWI.js +0 -4
- package/dist/chunks/google-vertex-UA36QP2U.js +0 -4
- package/dist/chunks/init-HA7FAQ73.js +0 -4
- package/dist/chunks/kimi-coding-HMJRKCPA.js +0 -4
- package/dist/chunks/local-client-stop-SQRU7ZZM.js +0 -4
- package/dist/chunks/meta-KY3LNFV2.js +0 -4
- package/dist/chunks/mistral-conversations-34F66L3O.js +0 -7
- package/dist/chunks/model-resolver-N3DTAQ2S.js +0 -4
- package/dist/chunks/openai-codex-responses-ZBVHREB3.js +0 -12
- package/dist/chunks/openai-completions-VVIB26SH.js +0 -9
- package/dist/chunks/openai-responses-735XA2ZX.js +0 -6
- package/dist/chunks/openrouter-images-3IKETHAC.js +0 -4
- package/dist/chunks/pi-messages-I3E4ZFHA.js +0 -10
- package/dist/chunks/radius-HXRZVBDB.js +0 -4
- package/dist/chunks/remote-ops-BALZYKH6.js +0 -14
- package/dist/chunks/runner-PLVZDGHB.js +0 -4
- package/dist/chunks/runtime-6YLTA2ZD.js +0 -4
- package/dist/chunks/schedule-cli-OLASBBYJ.js +0 -4
- package/dist/chunks/slack-WAGSPZUX.js +0 -4
- package/dist/chunks/start-ui-http-QALT7C3P.js +0 -43
- package/dist/chunks/subagent-E3UC7ZHC.js +0 -4
- package/dist/chunks/tool-shims-Q6P6UXVC.js +0 -4
- package/dist/chunks/typesafe-system-one-6ULACYD4.js +0 -4
- package/dist/chunks/ui-board-4GYW6KKW.js +0 -5
- package/dist/chunks/ui-decision-U2FXSEC2.js +0 -4
- package/dist/chunks/ui-view-O7PLANT7.js +0 -4
- package/dist/chunks/virtual-modules-IDC5YKZJ.js +0 -4
- package/dist/chunks/waitpoint-2FGQBIAC.js +0 -5
- package/dist/chunks/workers-XN4PSTH6.js +0 -4
- package/vendor/aistatus/gateway-cli.js +0 -21
- package/vendor/pi/examples/extensions/sandbox/index.ts +0 -321
- package/vendor/pi/examples/extensions/sandbox/package-lock.json +0 -92
- package/vendor/pi/examples/extensions/sandbox/package.json +0 -19
- package/web/dist/assets/index-BHZpFXhc.js +0 -525
- package/web/dist/assets/index-DqWMdMkh.css +0 -1
- package/web/dist/assets/pdf-worker-Hp15W1QJ.js +0 -57
- package/web/dist/assets/pdf.worker.min-DnhTvCwe.js +0 -55
|
@@ -37,9 +37,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
37
37
|
mod
|
|
38
38
|
));
|
|
39
39
|
|
|
40
|
-
// node_modules/ws/lib/constants.js
|
|
40
|
+
// ../node_modules/ws/lib/constants.js
|
|
41
41
|
var require_constants = __commonJS({
|
|
42
|
-
"node_modules/ws/lib/constants.js"(exports, module) {
|
|
42
|
+
"../node_modules/ws/lib/constants.js"(exports, module) {
|
|
43
43
|
"use strict";
|
|
44
44
|
var BINARY_TYPES = ["nodebuffer", "arraybuffer", "fragments"];
|
|
45
45
|
var hasBlob = typeof Blob !== "undefined";
|
|
@@ -60,9 +60,9 @@ var require_constants = __commonJS({
|
|
|
60
60
|
}
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
-
// node_modules/ws/lib/buffer-util.js
|
|
63
|
+
// ../node_modules/ws/lib/buffer-util.js
|
|
64
64
|
var require_buffer_util = __commonJS({
|
|
65
|
-
"node_modules/ws/lib/buffer-util.js"(exports, module) {
|
|
65
|
+
"../node_modules/ws/lib/buffer-util.js"(exports, module) {
|
|
66
66
|
"use strict";
|
|
67
67
|
var { EMPTY_BUFFER } = require_constants();
|
|
68
68
|
var FastBuffer = Buffer[Symbol.species];
|
|
@@ -135,9 +135,9 @@ var require_buffer_util = __commonJS({
|
|
|
135
135
|
}
|
|
136
136
|
});
|
|
137
137
|
|
|
138
|
-
// node_modules/ws/lib/limiter.js
|
|
138
|
+
// ../node_modules/ws/lib/limiter.js
|
|
139
139
|
var require_limiter = __commonJS({
|
|
140
|
-
"node_modules/ws/lib/limiter.js"(exports, module) {
|
|
140
|
+
"../node_modules/ws/lib/limiter.js"(exports, module) {
|
|
141
141
|
"use strict";
|
|
142
142
|
var kDone = /* @__PURE__ */ Symbol("kDone");
|
|
143
143
|
var kRun = /* @__PURE__ */ Symbol("kRun");
|
|
@@ -185,9 +185,9 @@ var require_limiter = __commonJS({
|
|
|
185
185
|
}
|
|
186
186
|
});
|
|
187
187
|
|
|
188
|
-
// node_modules/ws/lib/permessage-deflate.js
|
|
188
|
+
// ../node_modules/ws/lib/permessage-deflate.js
|
|
189
189
|
var require_permessage_deflate = __commonJS({
|
|
190
|
-
"node_modules/ws/lib/permessage-deflate.js"(exports, module) {
|
|
190
|
+
"../node_modules/ws/lib/permessage-deflate.js"(exports, module) {
|
|
191
191
|
"use strict";
|
|
192
192
|
var zlib = __require("zlib");
|
|
193
193
|
var bufferUtil = require_buffer_util();
|
|
@@ -314,7 +314,7 @@ var require_permessage_deflate = __commonJS({
|
|
|
314
314
|
acceptAsServer(offers) {
|
|
315
315
|
const opts = this._options;
|
|
316
316
|
const accepted = offers.find((params) => {
|
|
317
|
-
if (opts.serverNoContextTakeover === false && params.server_no_context_takeover || params.server_max_window_bits && (opts.serverMaxWindowBits === false || typeof opts.serverMaxWindowBits === "number" && opts.serverMaxWindowBits > params.server_max_window_bits) || typeof opts.clientMaxWindowBits === "number" && !params.client_max_window_bits) {
|
|
317
|
+
if (opts.serverNoContextTakeover === false && params.server_no_context_takeover || params.server_max_window_bits && (opts.serverMaxWindowBits === false || typeof opts.serverMaxWindowBits === "number" && opts.serverMaxWindowBits > params.server_max_window_bits) || typeof opts.clientMaxWindowBits === "number" && (typeof params.client_max_window_bits === "number" ? opts.clientMaxWindowBits > params.client_max_window_bits : !params.client_max_window_bits)) {
|
|
318
318
|
return false;
|
|
319
319
|
}
|
|
320
320
|
return true;
|
|
@@ -568,9 +568,9 @@ var require_permessage_deflate = __commonJS({
|
|
|
568
568
|
}
|
|
569
569
|
});
|
|
570
570
|
|
|
571
|
-
// node_modules/ws/lib/validation.js
|
|
571
|
+
// ../node_modules/ws/lib/validation.js
|
|
572
572
|
var require_validation = __commonJS({
|
|
573
|
-
"node_modules/ws/lib/validation.js"(exports, module) {
|
|
573
|
+
"../node_modules/ws/lib/validation.js"(exports, module) {
|
|
574
574
|
"use strict";
|
|
575
575
|
var { isUtf8 } = __require("buffer");
|
|
576
576
|
var { hasBlob } = require_constants();
|
|
@@ -769,9 +769,9 @@ var require_validation = __commonJS({
|
|
|
769
769
|
}
|
|
770
770
|
});
|
|
771
771
|
|
|
772
|
-
// node_modules/ws/lib/receiver.js
|
|
772
|
+
// ../node_modules/ws/lib/receiver.js
|
|
773
773
|
var require_receiver = __commonJS({
|
|
774
|
-
"node_modules/ws/lib/receiver.js"(exports, module) {
|
|
774
|
+
"../node_modules/ws/lib/receiver.js"(exports, module) {
|
|
775
775
|
"use strict";
|
|
776
776
|
var { Writable } = __require("stream");
|
|
777
777
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
@@ -1392,9 +1392,9 @@ var require_receiver = __commonJS({
|
|
|
1392
1392
|
}
|
|
1393
1393
|
});
|
|
1394
1394
|
|
|
1395
|
-
// node_modules/ws/lib/sender.js
|
|
1395
|
+
// ../node_modules/ws/lib/sender.js
|
|
1396
1396
|
var require_sender = __commonJS({
|
|
1397
|
-
"node_modules/ws/lib/sender.js"(exports, module) {
|
|
1397
|
+
"../node_modules/ws/lib/sender.js"(exports, module) {
|
|
1398
1398
|
"use strict";
|
|
1399
1399
|
var { Duplex } = __require("stream");
|
|
1400
1400
|
var { randomFillSync } = __require("crypto");
|
|
@@ -1885,9 +1885,9 @@ var require_sender = __commonJS({
|
|
|
1885
1885
|
}
|
|
1886
1886
|
});
|
|
1887
1887
|
|
|
1888
|
-
// node_modules/ws/lib/event-target.js
|
|
1888
|
+
// ../node_modules/ws/lib/event-target.js
|
|
1889
1889
|
var require_event_target = __commonJS({
|
|
1890
|
-
"node_modules/ws/lib/event-target.js"(exports, module) {
|
|
1890
|
+
"../node_modules/ws/lib/event-target.js"(exports, module) {
|
|
1891
1891
|
"use strict";
|
|
1892
1892
|
var { kForOnEventAttribute, kListener } = require_constants();
|
|
1893
1893
|
var kCode = /* @__PURE__ */ Symbol("kCode");
|
|
@@ -2114,9 +2114,9 @@ var require_event_target = __commonJS({
|
|
|
2114
2114
|
}
|
|
2115
2115
|
});
|
|
2116
2116
|
|
|
2117
|
-
// node_modules/ws/lib/extension.js
|
|
2117
|
+
// ../node_modules/ws/lib/extension.js
|
|
2118
2118
|
var require_extension = __commonJS({
|
|
2119
|
-
"node_modules/ws/lib/extension.js"(exports, module) {
|
|
2119
|
+
"../node_modules/ws/lib/extension.js"(exports, module) {
|
|
2120
2120
|
"use strict";
|
|
2121
2121
|
var { tokenChars } = require_validation();
|
|
2122
2122
|
function push(dest, name, elem) {
|
|
@@ -2267,9 +2267,9 @@ var require_extension = __commonJS({
|
|
|
2267
2267
|
}
|
|
2268
2268
|
});
|
|
2269
2269
|
|
|
2270
|
-
// node_modules/ws/lib/websocket.js
|
|
2270
|
+
// ../node_modules/ws/lib/websocket.js
|
|
2271
2271
|
var require_websocket = __commonJS({
|
|
2272
|
-
"node_modules/ws/lib/websocket.js"(exports, module) {
|
|
2272
|
+
"../node_modules/ws/lib/websocket.js"(exports, module) {
|
|
2273
2273
|
"use strict";
|
|
2274
2274
|
var EventEmitter = __require("events");
|
|
2275
2275
|
var https = __require("https");
|
|
@@ -2332,11 +2332,23 @@ var require_websocket = __commonJS({
|
|
|
2332
2332
|
this._isServer = false;
|
|
2333
2333
|
this._redirects = 0;
|
|
2334
2334
|
if (protocols === void 0) {
|
|
2335
|
-
protocols
|
|
2335
|
+
if (!options || options.protocols === void 0) {
|
|
2336
|
+
protocols = [];
|
|
2337
|
+
} else if (Array.isArray(options.protocols)) {
|
|
2338
|
+
protocols = options.protocols;
|
|
2339
|
+
} else {
|
|
2340
|
+
protocols = [options.protocols];
|
|
2341
|
+
}
|
|
2336
2342
|
} else if (!Array.isArray(protocols)) {
|
|
2337
2343
|
if (typeof protocols === "object" && protocols !== null) {
|
|
2338
2344
|
options = protocols;
|
|
2339
|
-
protocols
|
|
2345
|
+
if (options.protocols === void 0) {
|
|
2346
|
+
protocols = [];
|
|
2347
|
+
} else if (Array.isArray(options.protocols)) {
|
|
2348
|
+
protocols = options.protocols;
|
|
2349
|
+
} else {
|
|
2350
|
+
protocols = [options.protocols];
|
|
2351
|
+
}
|
|
2340
2352
|
} else {
|
|
2341
2353
|
protocols = [protocols];
|
|
2342
2354
|
}
|
|
@@ -2533,7 +2545,6 @@ var require_websocket = __commonJS({
|
|
|
2533
2545
|
}
|
|
2534
2546
|
return;
|
|
2535
2547
|
}
|
|
2536
|
-
this._readyState = _WebSocket.CLOSING;
|
|
2537
2548
|
this._sender.close(code, data, !this._isServer, (err) => {
|
|
2538
2549
|
if (err) return;
|
|
2539
2550
|
this._closeFrameSent = true;
|
|
@@ -2541,6 +2552,7 @@ var require_websocket = __commonJS({
|
|
|
2541
2552
|
this._socket.end();
|
|
2542
2553
|
}
|
|
2543
2554
|
});
|
|
2555
|
+
this._readyState = _WebSocket.CLOSING;
|
|
2544
2556
|
setCloseTimer(this);
|
|
2545
2557
|
}
|
|
2546
2558
|
/**
|
|
@@ -2765,6 +2777,7 @@ var require_websocket = __commonJS({
|
|
|
2765
2777
|
socketPath: void 0,
|
|
2766
2778
|
hostname: void 0,
|
|
2767
2779
|
protocol: void 0,
|
|
2780
|
+
protocols: void 0,
|
|
2768
2781
|
timeout: void 0,
|
|
2769
2782
|
method: "GET",
|
|
2770
2783
|
host: void 0,
|
|
@@ -3163,9 +3176,9 @@ var require_websocket = __commonJS({
|
|
|
3163
3176
|
}
|
|
3164
3177
|
});
|
|
3165
3178
|
|
|
3166
|
-
// node_modules/ws/lib/stream.js
|
|
3179
|
+
// ../node_modules/ws/lib/stream.js
|
|
3167
3180
|
var require_stream = __commonJS({
|
|
3168
|
-
"node_modules/ws/lib/stream.js"(exports, module) {
|
|
3181
|
+
"../node_modules/ws/lib/stream.js"(exports, module) {
|
|
3169
3182
|
"use strict";
|
|
3170
3183
|
var WebSocket2 = require_websocket();
|
|
3171
3184
|
var { Duplex } = __require("stream");
|
|
@@ -3261,9 +3274,9 @@ var require_stream = __commonJS({
|
|
|
3261
3274
|
}
|
|
3262
3275
|
});
|
|
3263
3276
|
|
|
3264
|
-
// node_modules/ws/lib/subprotocol.js
|
|
3277
|
+
// ../node_modules/ws/lib/subprotocol.js
|
|
3265
3278
|
var require_subprotocol = __commonJS({
|
|
3266
|
-
"node_modules/ws/lib/subprotocol.js"(exports, module) {
|
|
3279
|
+
"../node_modules/ws/lib/subprotocol.js"(exports, module) {
|
|
3267
3280
|
"use strict";
|
|
3268
3281
|
var { tokenChars } = require_validation();
|
|
3269
3282
|
function parse(header) {
|
|
@@ -3306,9 +3319,9 @@ var require_subprotocol = __commonJS({
|
|
|
3306
3319
|
}
|
|
3307
3320
|
});
|
|
3308
3321
|
|
|
3309
|
-
// node_modules/ws/lib/websocket-server.js
|
|
3322
|
+
// ../node_modules/ws/lib/websocket-server.js
|
|
3310
3323
|
var require_websocket_server = __commonJS({
|
|
3311
|
-
"node_modules/ws/lib/websocket-server.js"(exports, module) {
|
|
3324
|
+
"../node_modules/ws/lib/websocket-server.js"(exports, module) {
|
|
3312
3325
|
"use strict";
|
|
3313
3326
|
var EventEmitter = __require("events");
|
|
3314
3327
|
var http = __require("http");
|
|
@@ -3707,7 +3720,7 @@ var require_websocket_server = __commonJS({
|
|
|
3707
3720
|
}
|
|
3708
3721
|
});
|
|
3709
3722
|
|
|
3710
|
-
// node_modules/ws/wrapper.mjs
|
|
3723
|
+
// ../node_modules/ws/wrapper.mjs
|
|
3711
3724
|
var import_stream = __toESM(require_stream(), 1);
|
|
3712
3725
|
var import_extension = __toESM(require_extension(), 1);
|
|
3713
3726
|
var import_permessage_deflate = __toESM(require_permessage_deflate(), 1);
|
|
@@ -3719,9 +3732,9 @@ var import_websocket_server = __toESM(require_websocket_server(), 1);
|
|
|
3719
3732
|
var wrapper_default = import_websocket.default;
|
|
3720
3733
|
|
|
3721
3734
|
// src/client.ts
|
|
3722
|
-
import * as
|
|
3723
|
-
import * as
|
|
3724
|
-
import * as
|
|
3735
|
+
import * as fs7 from "fs";
|
|
3736
|
+
import * as path6 from "path";
|
|
3737
|
+
import * as os4 from "os";
|
|
3725
3738
|
import { execFileSync as execFileSync3 } from "child_process";
|
|
3726
3739
|
|
|
3727
3740
|
// src/agents-md-scanner.ts
|
|
@@ -3876,22 +3889,33 @@ function execBashBackground(command) {
|
|
|
3876
3889
|
proc.unref();
|
|
3877
3890
|
return { pid: proc.pid };
|
|
3878
3891
|
}
|
|
3892
|
+
var EXIT_DRAIN_MS = 500;
|
|
3879
3893
|
function monitorCommand(proc, stdout, stderr, timeoutMs) {
|
|
3894
|
+
const snapshot = (exitCode, note) => ({
|
|
3895
|
+
stdout: stdout.toString(),
|
|
3896
|
+
stderr: note ? joinStderr(stderr.toString(), note) : stderr.toString(),
|
|
3897
|
+
exitCode
|
|
3898
|
+
});
|
|
3880
3899
|
return new Promise((resolve5) => {
|
|
3881
3900
|
let settled = false;
|
|
3901
|
+
let drainTimer;
|
|
3882
3902
|
const finish = (result) => {
|
|
3883
3903
|
if (settled) return;
|
|
3884
3904
|
settled = true;
|
|
3885
3905
|
clearTimeout(timer);
|
|
3906
|
+
clearTimeout(drainTimer);
|
|
3886
3907
|
resolve5(result);
|
|
3887
3908
|
};
|
|
3888
3909
|
const timer = setTimeout(() => {
|
|
3910
|
+
if (proc.exitCode !== null || proc.signalCode !== null) return finish(snapshot(proc.exitCode ?? 1));
|
|
3889
3911
|
if (proc.pid) killCommandTree(proc.pid);
|
|
3890
|
-
|
|
3891
|
-
finish({ stdout: stdout.toString(), stderr: joinStderr(stderr.toString(), message), exitCode: 124 });
|
|
3912
|
+
finish(snapshot(124, `Command timed out after ${timeoutMs / 1e3}s`));
|
|
3892
3913
|
}, timeoutMs);
|
|
3893
|
-
proc.on("
|
|
3894
|
-
|
|
3914
|
+
proc.on("exit", (code) => {
|
|
3915
|
+
if (!settled) drainTimer = setTimeout(() => finish(snapshot(code ?? 1)), EXIT_DRAIN_MS);
|
|
3916
|
+
});
|
|
3917
|
+
proc.on("close", (code) => finish(snapshot(code ?? 1)));
|
|
3918
|
+
proc.on("error", (error) => finish(snapshot(127, error.message)));
|
|
3895
3919
|
});
|
|
3896
3920
|
}
|
|
3897
3921
|
function resolveBash(posixShell = "/bin/bash") {
|
|
@@ -4177,30 +4201,101 @@ function detectGpuCount(run = runNvidiaSmi) {
|
|
|
4177
4201
|
return count;
|
|
4178
4202
|
}
|
|
4179
4203
|
|
|
4204
|
+
// src/dir-list.ts
|
|
4205
|
+
import * as fs5 from "node:fs";
|
|
4206
|
+
import * as os3 from "node:os";
|
|
4207
|
+
import * as path4 from "node:path";
|
|
4208
|
+
var LIST_ENTRY_CAP = 500;
|
|
4209
|
+
var LOCAL_HOST = { platform: process.platform, homedir: os3.homedir() };
|
|
4210
|
+
var ERROR_TEXT = {
|
|
4211
|
+
ENOENT: "Directory not found",
|
|
4212
|
+
ENOTDIR: "Not a directory",
|
|
4213
|
+
EACCES: "Permission denied",
|
|
4214
|
+
EPERM: "Permission denied"
|
|
4215
|
+
};
|
|
4216
|
+
function flavor(host) {
|
|
4217
|
+
return host.platform === "win32" ? path4.win32 : path4.posix;
|
|
4218
|
+
}
|
|
4219
|
+
function windowsSpelling(raw) {
|
|
4220
|
+
const gitBash = raw.match(/^\/([A-Za-z])(?:\/(.*))?$/);
|
|
4221
|
+
if (gitBash) return `${gitBash[1].toUpperCase()}:\\${(gitBash[2] ?? "").replace(/\//g, "\\")}`;
|
|
4222
|
+
return /^[A-Za-z]:$/.test(raw) ? `${raw}\\` : raw;
|
|
4223
|
+
}
|
|
4224
|
+
function resolveListPath(input, host = LOCAL_HOST) {
|
|
4225
|
+
const p = flavor(host);
|
|
4226
|
+
const raw = input.trim();
|
|
4227
|
+
if (raw === "~") return p.resolve(host.homedir);
|
|
4228
|
+
if (/^~[\\/]/.test(raw)) return p.resolve(host.homedir, raw.slice(2));
|
|
4229
|
+
const spelled = host.platform === "win32" ? windowsSpelling(raw) : raw;
|
|
4230
|
+
if (!p.isAbsolute(spelled)) throw new Error(`Path must be absolute or start with ~: ${input}`);
|
|
4231
|
+
return p.resolve(spelled);
|
|
4232
|
+
}
|
|
4233
|
+
function parentOf(dir, host = LOCAL_HOST) {
|
|
4234
|
+
const parent = flavor(host).dirname(dir);
|
|
4235
|
+
return parent === dir ? null : parent;
|
|
4236
|
+
}
|
|
4237
|
+
async function kindOf(dir, dirent) {
|
|
4238
|
+
if (!dirent.isSymbolicLink()) return dirent.isDirectory() ? "dir" : "file";
|
|
4239
|
+
try {
|
|
4240
|
+
return (await fs5.promises.stat(path4.join(dir, dirent.name))).isDirectory() ? "dir" : "file";
|
|
4241
|
+
} catch {
|
|
4242
|
+
return "file";
|
|
4243
|
+
}
|
|
4244
|
+
}
|
|
4245
|
+
function compareEntries(a, b) {
|
|
4246
|
+
if (a.kind !== b.kind) return a.kind === "dir" ? -1 : 1;
|
|
4247
|
+
const hidden = Number(a.name.startsWith(".")) - Number(b.name.startsWith("."));
|
|
4248
|
+
return hidden || a.name.localeCompare(b.name);
|
|
4249
|
+
}
|
|
4250
|
+
async function readDirectory(dir) {
|
|
4251
|
+
try {
|
|
4252
|
+
return await fs5.promises.readdir(dir, { withFileTypes: true });
|
|
4253
|
+
} catch (error) {
|
|
4254
|
+
const text = ERROR_TEXT[error.code ?? ""];
|
|
4255
|
+
throw text ? new Error(`${text}: ${dir}`) : error;
|
|
4256
|
+
}
|
|
4257
|
+
}
|
|
4258
|
+
async function listDirectory(params, host = LOCAL_HOST) {
|
|
4259
|
+
const dir = resolveListPath(params.path, host);
|
|
4260
|
+
const dirents = await readDirectory(dir);
|
|
4261
|
+
const visible = params.showHidden ? dirents : dirents.filter((dirent) => !dirent.name.startsWith("."));
|
|
4262
|
+
const entries = await Promise.all(visible.map(async (dirent) => ({
|
|
4263
|
+
name: dirent.name,
|
|
4264
|
+
kind: await kindOf(dir, dirent)
|
|
4265
|
+
})));
|
|
4266
|
+
entries.sort(compareEntries);
|
|
4267
|
+
return {
|
|
4268
|
+
path: dir,
|
|
4269
|
+
parent: parentOf(dir, host),
|
|
4270
|
+
entries: entries.slice(0, LIST_ENTRY_CAP),
|
|
4271
|
+
truncated: entries.length > LIST_ENTRY_CAP
|
|
4272
|
+
};
|
|
4273
|
+
}
|
|
4274
|
+
|
|
4180
4275
|
// src/self-update.ts
|
|
4181
|
-
import * as
|
|
4182
|
-
import * as
|
|
4276
|
+
import * as fs6 from "fs";
|
|
4277
|
+
import * as path5 from "path";
|
|
4183
4278
|
import * as crypto from "crypto";
|
|
4184
4279
|
import { spawn as spawn2 } from "child_process";
|
|
4185
4280
|
var log3 = createLogger("self-update");
|
|
4186
|
-
var CLIENT_INSTALL_DIR =
|
|
4281
|
+
var CLIENT_INSTALL_DIR = path5.join(DATA_DIR, "client");
|
|
4187
4282
|
var BUNDLE_FILES = ["client.mjs", "cortex-run-watcher.mjs"];
|
|
4188
4283
|
function hashBundleFiles(dir) {
|
|
4189
4284
|
const h = crypto.createHash("sha256");
|
|
4190
4285
|
for (const name of BUNDLE_FILES) {
|
|
4191
|
-
const p =
|
|
4192
|
-
if (!
|
|
4193
|
-
h.update(
|
|
4286
|
+
const p = path5.join(dir, name);
|
|
4287
|
+
if (!fs6.existsSync(p)) return null;
|
|
4288
|
+
h.update(fs6.readFileSync(p));
|
|
4194
4289
|
}
|
|
4195
4290
|
return h.digest("hex");
|
|
4196
4291
|
}
|
|
4197
4292
|
function computeSelfBundleHash(entryPath = process.argv[1]) {
|
|
4198
4293
|
if (!entryPath) return "unknown";
|
|
4199
|
-
const entry =
|
|
4200
|
-
const setHash = hashBundleFiles(
|
|
4294
|
+
const entry = path5.resolve(entryPath);
|
|
4295
|
+
const setHash = hashBundleFiles(path5.dirname(entry));
|
|
4201
4296
|
if (setHash) return setHash;
|
|
4202
4297
|
try {
|
|
4203
|
-
return `entry-${crypto.createHash("sha256").update(
|
|
4298
|
+
return `entry-${crypto.createHash("sha256").update(fs6.readFileSync(entry)).digest("hex")}`;
|
|
4204
4299
|
} catch {
|
|
4205
4300
|
return "unknown";
|
|
4206
4301
|
}
|
|
@@ -4216,18 +4311,18 @@ function validateUpdateMessage(msg) {
|
|
|
4216
4311
|
return null;
|
|
4217
4312
|
}
|
|
4218
4313
|
function swapDirs(root) {
|
|
4219
|
-
const next =
|
|
4220
|
-
const current =
|
|
4221
|
-
const previous =
|
|
4222
|
-
|
|
4223
|
-
const hadCurrent =
|
|
4224
|
-
if (hadCurrent)
|
|
4314
|
+
const next = path5.join(root, "next");
|
|
4315
|
+
const current = path5.join(root, "current");
|
|
4316
|
+
const previous = path5.join(root, "previous");
|
|
4317
|
+
fs6.rmSync(previous, { recursive: true, force: true });
|
|
4318
|
+
const hadCurrent = fs6.existsSync(current);
|
|
4319
|
+
if (hadCurrent) fs6.renameSync(current, previous);
|
|
4225
4320
|
try {
|
|
4226
|
-
|
|
4321
|
+
fs6.renameSync(next, current);
|
|
4227
4322
|
} catch (err) {
|
|
4228
4323
|
if (hadCurrent) {
|
|
4229
4324
|
try {
|
|
4230
|
-
|
|
4325
|
+
fs6.renameSync(previous, current);
|
|
4231
4326
|
} catch {
|
|
4232
4327
|
}
|
|
4233
4328
|
}
|
|
@@ -4250,16 +4345,16 @@ function handleUpdateMessage(msg, io) {
|
|
|
4250
4345
|
return;
|
|
4251
4346
|
}
|
|
4252
4347
|
try {
|
|
4253
|
-
const next =
|
|
4254
|
-
|
|
4255
|
-
|
|
4348
|
+
const next = path5.join(CLIENT_INSTALL_DIR, "next");
|
|
4349
|
+
fs6.rmSync(next, { recursive: true, force: true });
|
|
4350
|
+
fs6.mkdirSync(next, { recursive: true });
|
|
4256
4351
|
for (const name of BUNDLE_FILES) {
|
|
4257
4352
|
const file = msg.files.find((f) => f.name === name);
|
|
4258
|
-
|
|
4353
|
+
fs6.writeFileSync(path5.join(next, name), Buffer.from(file.data, "base64"), { mode: 493 });
|
|
4259
4354
|
}
|
|
4260
4355
|
const got = hashBundleFiles(next);
|
|
4261
4356
|
if (got !== msg.hash) {
|
|
4262
|
-
|
|
4357
|
+
fs6.rmSync(next, { recursive: true, force: true });
|
|
4263
4358
|
io.sendResult(false, `hash mismatch: expected ${msg.hash}, got ${got}`);
|
|
4264
4359
|
return;
|
|
4265
4360
|
}
|
|
@@ -4277,7 +4372,7 @@ function handleUpdateMessage(msg, io) {
|
|
|
4277
4372
|
}
|
|
4278
4373
|
setTimeout(() => {
|
|
4279
4374
|
try {
|
|
4280
|
-
io.respawn(
|
|
4375
|
+
io.respawn(path5.join(CLIENT_INSTALL_DIR, "current", "client.mjs"));
|
|
4281
4376
|
} catch (err) {
|
|
4282
4377
|
log3.error(`Respawn failed: ${err.message}`);
|
|
4283
4378
|
}
|
|
@@ -4286,6 +4381,83 @@ function handleUpdateMessage(msg, io) {
|
|
|
4286
4381
|
}, 400);
|
|
4287
4382
|
}
|
|
4288
4383
|
|
|
4384
|
+
// src/result-outbox.ts
|
|
4385
|
+
var OPEN = 1;
|
|
4386
|
+
var RESEND_WINDOW_MS = 9e4;
|
|
4387
|
+
var UNDELIVERED_TTL_MS = 5 * 6e4;
|
|
4388
|
+
var MAX_UNDELIVERED = 64;
|
|
4389
|
+
var ResultOutbox = class {
|
|
4390
|
+
constructor(now = Date.now) {
|
|
4391
|
+
this.now = now;
|
|
4392
|
+
}
|
|
4393
|
+
now;
|
|
4394
|
+
running = /* @__PURE__ */ new Set();
|
|
4395
|
+
undelivered = /* @__PURE__ */ new Map();
|
|
4396
|
+
sent = /* @__PURE__ */ new Map();
|
|
4397
|
+
begin(commandId) {
|
|
4398
|
+
this.running.add(commandId);
|
|
4399
|
+
}
|
|
4400
|
+
/** Deliver a finished command's result on `socket`, or keep it for the next connection. */
|
|
4401
|
+
deliver(frame, socket) {
|
|
4402
|
+
this.running.delete(frame.commandId);
|
|
4403
|
+
this.send({ frame, at: this.now() }, socket);
|
|
4404
|
+
}
|
|
4405
|
+
/** Commands the server should keep pending: still running, or finished but not delivered. */
|
|
4406
|
+
pendingIds() {
|
|
4407
|
+
this.expire();
|
|
4408
|
+
return [...this.running, ...this.undelivered.keys()];
|
|
4409
|
+
}
|
|
4410
|
+
/** Send everything kept, on a socket that has just said hello. */
|
|
4411
|
+
flush(socket) {
|
|
4412
|
+
this.expire();
|
|
4413
|
+
const entries = [...this.undelivered.values()];
|
|
4414
|
+
this.undelivered.clear();
|
|
4415
|
+
for (const entry of entries) this.send(entry, socket);
|
|
4416
|
+
}
|
|
4417
|
+
/** `socket` closed: what it sent moments ago may never have arrived. */
|
|
4418
|
+
socketClosed(socket) {
|
|
4419
|
+
const cutoff = this.now() - RESEND_WINDOW_MS;
|
|
4420
|
+
for (const entry of this.sent.get(socket) ?? []) {
|
|
4421
|
+
if (entry.sentAt >= cutoff) this.keep({ frame: entry.frame, at: entry.at });
|
|
4422
|
+
}
|
|
4423
|
+
this.sent.delete(socket);
|
|
4424
|
+
}
|
|
4425
|
+
send(entry, socket) {
|
|
4426
|
+
if (!socket || socket.readyState !== OPEN) {
|
|
4427
|
+
this.keep(entry);
|
|
4428
|
+
return;
|
|
4429
|
+
}
|
|
4430
|
+
try {
|
|
4431
|
+
socket.send(JSON.stringify(entry.frame), (err) => {
|
|
4432
|
+
if (err) this.keep(entry);
|
|
4433
|
+
});
|
|
4434
|
+
} catch {
|
|
4435
|
+
this.keep(entry);
|
|
4436
|
+
return;
|
|
4437
|
+
}
|
|
4438
|
+
this.recordSent(socket, entry);
|
|
4439
|
+
}
|
|
4440
|
+
recordSent(socket, entry) {
|
|
4441
|
+
const now = this.now();
|
|
4442
|
+
const recent = (this.sent.get(socket) ?? []).filter((e) => e.sentAt >= now - RESEND_WINDOW_MS);
|
|
4443
|
+
recent.push({ ...entry, sentAt: now });
|
|
4444
|
+
this.sent.set(socket, recent);
|
|
4445
|
+
}
|
|
4446
|
+
keep(entry) {
|
|
4447
|
+
this.undelivered.delete(entry.frame.commandId);
|
|
4448
|
+
this.undelivered.set(entry.frame.commandId, entry);
|
|
4449
|
+
while (this.undelivered.size > MAX_UNDELIVERED) {
|
|
4450
|
+
this.undelivered.delete(this.undelivered.keys().next().value);
|
|
4451
|
+
}
|
|
4452
|
+
}
|
|
4453
|
+
expire() {
|
|
4454
|
+
const cutoff = this.now() - UNDELIVERED_TTL_MS;
|
|
4455
|
+
for (const [id, entry] of this.undelivered) {
|
|
4456
|
+
if (entry.at < cutoff) this.undelivered.delete(id);
|
|
4457
|
+
}
|
|
4458
|
+
}
|
|
4459
|
+
};
|
|
4460
|
+
|
|
4289
4461
|
// src/client.ts
|
|
4290
4462
|
var log4 = createLogger("cortex-client");
|
|
4291
4463
|
function getClientHelp() {
|
|
@@ -4296,7 +4468,7 @@ function getClientHelp() {
|
|
|
4296
4468
|
"",
|
|
4297
4469
|
"cortex-client is a daemon-style worker that the agent-server starts.",
|
|
4298
4470
|
"Configuration is read from",
|
|
4299
|
-
` ${
|
|
4471
|
+
` ${path6.join(CONFIG_DIR, "cortex-client.json")}`,
|
|
4300
4472
|
"which is written by the server's bootstrap script (from agent-server/ in a",
|
|
4301
4473
|
"source checkout: node --import tsx src/domain/remote/client-bootstrap.ts),",
|
|
4302
4474
|
"by `cortex init` for a local desktop install, or by hand. There are no",
|
|
@@ -4313,7 +4485,7 @@ function getClientHelp() {
|
|
|
4313
4485
|
"",
|
|
4314
4486
|
"Behavior:",
|
|
4315
4487
|
" \u2022 Opens a WebSocket to CORTEX_SERVER_URL, else serverUrl, else ws://<serverHost>:<serverPort>.",
|
|
4316
|
-
" \u2022 Receives bash/read/write/edit/glob/grep commands.",
|
|
4488
|
+
" \u2022 Receives bash/read/write/edit/glob/grep/list commands.",
|
|
4317
4489
|
" \u2022 Exits if the server rejects the handshake (e.g. device already connected).",
|
|
4318
4490
|
" \u2022 Reconnects automatically on transient disconnects.",
|
|
4319
4491
|
"",
|
|
@@ -4327,9 +4499,9 @@ if (process.argv.slice(2).some((a) => a === "--help" || a === "-h")) {
|
|
|
4327
4499
|
process.exit(0);
|
|
4328
4500
|
}
|
|
4329
4501
|
function loadConfig() {
|
|
4330
|
-
const configPath =
|
|
4502
|
+
const configPath = path6.join(CONFIG_DIR, "cortex-client.json");
|
|
4331
4503
|
try {
|
|
4332
|
-
const raw =
|
|
4504
|
+
const raw = fs7.readFileSync(configPath, "utf8");
|
|
4333
4505
|
const cfg = JSON.parse(raw);
|
|
4334
4506
|
if (!cfg.serverHost && !cfg.serverUrl && !process.env.CORTEX_SERVER_URL) {
|
|
4335
4507
|
throw new Error("Missing serverHost (or provide serverUrl / CORTEX_SERVER_URL)");
|
|
@@ -4337,7 +4509,7 @@ function loadConfig() {
|
|
|
4337
4509
|
return {
|
|
4338
4510
|
// Full WS URL (tunnel route). env CORTEX_SERVER_URL > config serverUrl > ws://host:port.
|
|
4339
4511
|
serverUrl: resolveServerUrl(cfg, process.env),
|
|
4340
|
-
deviceName: cfg.deviceName ||
|
|
4512
|
+
deviceName: cfg.deviceName || os4.hostname(),
|
|
4341
4513
|
// WS bearer token required by the agent-server gate; env overrides config (see auth-headers.ts).
|
|
4342
4514
|
clientToken: resolveClientToken(cfg, process.env)
|
|
4343
4515
|
};
|
|
@@ -4430,7 +4602,7 @@ function extractImageDimensions(buf, mime) {
|
|
|
4430
4602
|
return null;
|
|
4431
4603
|
}
|
|
4432
4604
|
function detectCapabilities() {
|
|
4433
|
-
const caps = ["file-stream"];
|
|
4605
|
+
const caps = ["file-stream", "fs-list"];
|
|
4434
4606
|
try {
|
|
4435
4607
|
execFileSync3("rg", ["--version"], { timeout: 5e3, stdio: "pipe", windowsHide: true });
|
|
4436
4608
|
caps.push("rg");
|
|
@@ -4457,20 +4629,20 @@ function safeScanAgentsMDs(filePath) {
|
|
|
4457
4629
|
function handleRead(params) {
|
|
4458
4630
|
try {
|
|
4459
4631
|
const filePath = normalizePath(params.file_path);
|
|
4460
|
-
if (!
|
|
4632
|
+
if (!path6.isAbsolute(filePath)) {
|
|
4461
4633
|
return { error: "file_path must be absolute" };
|
|
4462
4634
|
}
|
|
4463
|
-
if (!
|
|
4635
|
+
if (!fs7.existsSync(filePath)) {
|
|
4464
4636
|
return { error: `File not found: ${filePath}` };
|
|
4465
4637
|
}
|
|
4466
|
-
const stat =
|
|
4638
|
+
const stat = fs7.statSync(filePath);
|
|
4467
4639
|
if (!stat.isFile()) {
|
|
4468
4640
|
return { error: `Not a file: ${filePath}` };
|
|
4469
4641
|
}
|
|
4470
4642
|
if (stat.size > MAX_READ_FILE_SIZE) {
|
|
4471
4643
|
return { error: `File too large (${(stat.size / 1024 / 1024).toFixed(1)}MB, max 10MB). Use offset and limit for range reading.` };
|
|
4472
4644
|
}
|
|
4473
|
-
const rawBuf =
|
|
4645
|
+
const rawBuf = fs7.readFileSync(filePath);
|
|
4474
4646
|
const cortexMDs = safeScanAgentsMDs(filePath);
|
|
4475
4647
|
const imageType = detectImageType(rawBuf);
|
|
4476
4648
|
if (imageType) {
|
|
@@ -4510,14 +4682,14 @@ function handleRead(params) {
|
|
|
4510
4682
|
function handleFileStat(params) {
|
|
4511
4683
|
try {
|
|
4512
4684
|
const filePath = normalizePath(params.file_path);
|
|
4513
|
-
if (!
|
|
4685
|
+
if (!path6.isAbsolute(filePath)) {
|
|
4514
4686
|
return { error: "file_path must be absolute" };
|
|
4515
4687
|
}
|
|
4516
|
-
const stat =
|
|
4688
|
+
const stat = fs7.statSync(filePath);
|
|
4517
4689
|
if (!stat.isFile()) {
|
|
4518
4690
|
return { error: `Not a file: ${filePath}` };
|
|
4519
4691
|
}
|
|
4520
|
-
return { size: stat.size, name:
|
|
4692
|
+
return { size: stat.size, name: path6.basename(filePath), mtimeMs: stat.mtimeMs };
|
|
4521
4693
|
} catch (err) {
|
|
4522
4694
|
const e = err;
|
|
4523
4695
|
if (e.code === "ENOENT") return { error: `File not found: ${params.file_path}` };
|
|
@@ -4527,15 +4699,15 @@ function handleFileStat(params) {
|
|
|
4527
4699
|
function handleWrite(params) {
|
|
4528
4700
|
try {
|
|
4529
4701
|
const filePath = normalizePath(params.file_path);
|
|
4530
|
-
if (!
|
|
4702
|
+
if (!path6.isAbsolute(filePath)) {
|
|
4531
4703
|
return { error: "file_path must be absolute" };
|
|
4532
4704
|
}
|
|
4533
|
-
const dir =
|
|
4534
|
-
|
|
4705
|
+
const dir = path6.dirname(filePath);
|
|
4706
|
+
fs7.mkdirSync(dir, { recursive: true });
|
|
4535
4707
|
let content = params.content;
|
|
4536
|
-
if (
|
|
4708
|
+
if (fs7.existsSync(filePath)) {
|
|
4537
4709
|
try {
|
|
4538
|
-
const existing =
|
|
4710
|
+
const existing = fs7.readFileSync(filePath, "utf8");
|
|
4539
4711
|
const lineEnding = detectLineEnding(existing);
|
|
4540
4712
|
if (lineEnding === "\r\n") {
|
|
4541
4713
|
content = content.replace(/\r\n/g, "\n").replace(/\n/g, "\r\n");
|
|
@@ -4543,7 +4715,7 @@ function handleWrite(params) {
|
|
|
4543
4715
|
} catch {
|
|
4544
4716
|
}
|
|
4545
4717
|
}
|
|
4546
|
-
|
|
4718
|
+
fs7.writeFileSync(filePath, content, "utf8");
|
|
4547
4719
|
return {
|
|
4548
4720
|
success: true,
|
|
4549
4721
|
cortexMDs: safeScanAgentsMDs(filePath)
|
|
@@ -4555,10 +4727,10 @@ function handleWrite(params) {
|
|
|
4555
4727
|
function handleEdit(params) {
|
|
4556
4728
|
try {
|
|
4557
4729
|
const filePath = normalizePath(params.file_path);
|
|
4558
|
-
if (!
|
|
4730
|
+
if (!path6.isAbsolute(filePath)) {
|
|
4559
4731
|
return { error: "file_path must be absolute" };
|
|
4560
4732
|
}
|
|
4561
|
-
const rawBuf =
|
|
4733
|
+
const rawBuf = fs7.readFileSync(filePath);
|
|
4562
4734
|
const encoding = detectEncoding(rawBuf);
|
|
4563
4735
|
const rawContent = rawBuf.toString(encoding);
|
|
4564
4736
|
const originalLineEnding = detectLineEnding(rawContent);
|
|
@@ -4578,7 +4750,7 @@ function handleEdit(params) {
|
|
|
4578
4750
|
}
|
|
4579
4751
|
const result2 = content.split(oldStr).join(newStr);
|
|
4580
4752
|
const final2 = originalLineEnding === "\r\n" ? result2.replace(/\n/g, "\r\n") : result2;
|
|
4581
|
-
|
|
4753
|
+
fs7.writeFileSync(filePath, final2, encoding);
|
|
4582
4754
|
return buildResult();
|
|
4583
4755
|
}
|
|
4584
4756
|
const firstIdx = content.indexOf(oldStr);
|
|
@@ -4591,7 +4763,7 @@ function handleEdit(params) {
|
|
|
4591
4763
|
}
|
|
4592
4764
|
const result = content.replace(oldStr, () => newStr);
|
|
4593
4765
|
const final = originalLineEnding === "\r\n" ? result.replace(/\n/g, "\r\n") : result;
|
|
4594
|
-
|
|
4766
|
+
fs7.writeFileSync(filePath, final, encoding);
|
|
4595
4767
|
return buildResult();
|
|
4596
4768
|
} catch (err) {
|
|
4597
4769
|
return { error: err.message };
|
|
@@ -4603,7 +4775,7 @@ async function handleGlob(params) {
|
|
|
4603
4775
|
try {
|
|
4604
4776
|
const pattern = params.pattern;
|
|
4605
4777
|
const cwd = normalizePath(params.path || (PLATFORM === "win32" ? "C:\\" : process.cwd()));
|
|
4606
|
-
if (!
|
|
4778
|
+
if (!fs7.existsSync(cwd)) {
|
|
4607
4779
|
return { error: `Directory not found: ${cwd}` };
|
|
4608
4780
|
}
|
|
4609
4781
|
const shell = resolveBash("bash");
|
|
@@ -4628,9 +4800,9 @@ function formatGlobResult(result, cwd) {
|
|
|
4628
4800
|
let files = result.stdout.trim().split("\n").filter(Boolean);
|
|
4629
4801
|
const truncated = files.length > GLOB_MAX_RESULTS;
|
|
4630
4802
|
if (truncated) files = files.slice(0, GLOB_MAX_RESULTS);
|
|
4631
|
-
files = files.map((f) =>
|
|
4803
|
+
files = files.map((f) => path6.isAbsolute(f) ? f : path6.resolve(cwd, f));
|
|
4632
4804
|
files = files.filter((f) => {
|
|
4633
|
-
const parts =
|
|
4805
|
+
const parts = path6.relative(cwd, f).split(path6.sep);
|
|
4634
4806
|
return !parts.some((p) => VCS_DIRS.has(p));
|
|
4635
4807
|
});
|
|
4636
4808
|
return { files, truncated };
|
|
@@ -4704,6 +4876,7 @@ async function handleGrep(params) {
|
|
|
4704
4876
|
function settle(result) {
|
|
4705
4877
|
return result.error ? { success: false, error: result.error } : { success: true, data: result };
|
|
4706
4878
|
}
|
|
4879
|
+
var MAX_BASH_TIMEOUT_MS = 30 * 6e4;
|
|
4707
4880
|
async function handleBashCommand(params) {
|
|
4708
4881
|
if (params.run_in_background) {
|
|
4709
4882
|
const { pid } = execBashBackground(params.command);
|
|
@@ -4712,7 +4885,7 @@ async function handleBashCommand(params) {
|
|
|
4712
4885
|
data: { stdout: `Background process started with PID ${pid}`, stderr: "", exitCode: 0 }
|
|
4713
4886
|
};
|
|
4714
4887
|
}
|
|
4715
|
-
const timeout = Math.min(params.timeout || 12e4,
|
|
4888
|
+
const timeout = Math.min(params.timeout || 12e4, MAX_BASH_TIMEOUT_MS);
|
|
4716
4889
|
return { success: true, data: await execBash(params.command, timeout) };
|
|
4717
4890
|
}
|
|
4718
4891
|
var COMMAND_HANDLERS = {
|
|
@@ -4722,7 +4895,8 @@ var COMMAND_HANDLERS = {
|
|
|
4722
4895
|
write: async (params) => settle(handleWrite(params)),
|
|
4723
4896
|
edit: async (params) => settle(handleEdit(params)),
|
|
4724
4897
|
glob: async (params) => settle(await handleGlob(params)),
|
|
4725
|
-
grep: async (params) => settle(await handleGrep(params))
|
|
4898
|
+
grep: async (params) => settle(await handleGrep(params)),
|
|
4899
|
+
list: async (params) => ({ success: true, data: await listDirectory(params) })
|
|
4726
4900
|
};
|
|
4727
4901
|
async function handleCommand(action, params) {
|
|
4728
4902
|
if (!Object.hasOwn(COMMAND_HANDLERS, action)) return { success: false, error: `Unknown action: ${action}` };
|
|
@@ -4732,19 +4906,21 @@ var ws = null;
|
|
|
4732
4906
|
var heartbeatTimer = null;
|
|
4733
4907
|
var reconnectDelay = 1e3;
|
|
4734
4908
|
var MAX_RECONNECT_DELAY = 3e4;
|
|
4909
|
+
var HANDSHAKE_TIMEOUT_MS = 15e3;
|
|
4910
|
+
var outbox = new ResultOutbox();
|
|
4735
4911
|
function sendFrame(socket, frame) {
|
|
4736
4912
|
if (socket && socket.readyState === wrapper_default.OPEN) socket.send(JSON.stringify(frame));
|
|
4737
4913
|
}
|
|
4738
4914
|
async function runCommand(frame) {
|
|
4739
|
-
const currentWs = ws;
|
|
4740
4915
|
log4.info(`Executing ${frame.action}: ${JSON.stringify(frame.params).substring(0, 100)}`);
|
|
4916
|
+
outbox.begin(frame.commandId);
|
|
4741
4917
|
let outcome;
|
|
4742
4918
|
try {
|
|
4743
4919
|
outcome = await handleCommand(frame.action, frame.params || {});
|
|
4744
4920
|
} catch (err) {
|
|
4745
4921
|
outcome = { success: false, error: err.message };
|
|
4746
4922
|
}
|
|
4747
|
-
|
|
4923
|
+
outbox.deliver({ type: "result", commandId: frame.commandId, ...outcome }, ws);
|
|
4748
4924
|
}
|
|
4749
4925
|
function applyUpdate(frame) {
|
|
4750
4926
|
const currentWs = ws;
|
|
@@ -4771,7 +4947,8 @@ function connect2() {
|
|
|
4771
4947
|
const url = SERVER_URL;
|
|
4772
4948
|
const headers = buildClientHeaders(CLIENT_TOKEN);
|
|
4773
4949
|
log4.info(`Connecting to ${url} as "${DEVICE_NAME}" (${PLATFORM})${headers ? " [token]" : " [no-token]"}...`);
|
|
4774
|
-
|
|
4950
|
+
const socket = new wrapper_default(url, { ...headers ? { headers } : {}, handshakeTimeout: HANDSHAKE_TIMEOUT_MS });
|
|
4951
|
+
ws = socket;
|
|
4775
4952
|
ws.on("open", () => {
|
|
4776
4953
|
log4.info(`Connected to server`);
|
|
4777
4954
|
reconnectDelay = 1e3;
|
|
@@ -4784,8 +4961,10 @@ function connect2() {
|
|
|
4784
4961
|
capabilities,
|
|
4785
4962
|
gpuCount,
|
|
4786
4963
|
bundleHash: BUNDLE_HASH,
|
|
4787
|
-
pid: process.pid
|
|
4964
|
+
pid: process.pid,
|
|
4965
|
+
inflight: outbox.pendingIds()
|
|
4788
4966
|
});
|
|
4967
|
+
outbox.flush(socket);
|
|
4789
4968
|
if (heartbeatTimer) clearInterval(heartbeatTimer);
|
|
4790
4969
|
heartbeatTimer = setInterval(() => {
|
|
4791
4970
|
sendFrame(ws, { type: "heartbeat", device: DEVICE_NAME, timestamp: Date.now() });
|
|
@@ -4821,6 +5000,7 @@ function connect2() {
|
|
|
4821
5000
|
});
|
|
4822
5001
|
ws.on("close", (code, reason) => {
|
|
4823
5002
|
log4.info(`Disconnected (code=${code}, reason=${reason?.toString() || "none"})`);
|
|
5003
|
+
outbox.socketClosed(socket);
|
|
4824
5004
|
cleanup();
|
|
4825
5005
|
if (code === 4002 || code === 4005) {
|
|
4826
5006
|
const rejection = code === 4005 ? "unknown device" : "device already connected";
|