@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
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as __cortexCreateRequire } from 'node:module';
|
|
2
2
|
const require = __cortexCreateRequire(import.meta.url);
|
|
3
3
|
const __cortexPackageRoot = new URL("../../", import.meta.url);
|
|
4
|
-
import{
|
|
4
|
+
import{ta as o}from"./chunk-GOS3P7KS.js";var m=31,G=36,c=m,u=G,g=[255,255,255,127,255,240,255,127,255,237,255,127,255,219,255,127,255,183,255,127,255,119,254,127,63,248,254,127,223,255,254,127,223,63,252,127,159,195,251,127,111,252,244,127,247,15,247,127,247,255,247,127,247,255,227,127,247,7,232,127,239,248,103,112,15,255,187,111,241,0,208,91,253,63,236,83,193,255,239,87,159,253,238,95,159,252,174,95,31,120,172,95,63,0,80,108,127,0,220,119,255,192,63,120,255,1,248,127,255,3,156,120,255,7,140,124,255,15,206,120,255,255,207,127,255,255,207,120,255,255,223,120,255,255,223,125,255,255,63,126,255,255,255,127],M=Math.ceil(c/8),s=Math.ceil(u/2),h=["typewriter","scanline","rain","fade","crt","glitch","dissolve"];function l(a,t){if(t>=u)return!1;let e=t*M+Math.floor(a/8),i=a%8;return(g[e]>>i&1)===0}function k(a,t){let e=l(a,t*2),i=l(a,t*2+1);return e&&i?"\u2588":e?"\u2580":i?"\u2584":" "}function S(){let a=[];for(let t=0;t<s;t++){let e=[];for(let i=0;i<c;i++)e.push(k(i,t));a.push(e)}return a}var d=class{ui;interval=null;effect;finalGrid;currentGrid;effectState={};cachedLines=[];cachedWidth=0;gridVersion=0;cachedVersion=-1;constructor(t){this.ui=t,this.effect=h[Math.floor(Math.random()*h.length)],this.finalGrid=S(),this.currentGrid=this.createEmptyGrid(),this.initEffect(),this.startAnimation()}invalidate(){this.cachedWidth=0}render(t){if(t===this.cachedWidth&&this.cachedVersion===this.gridVersion)return this.cachedLines;let e=1,i=t-e;this.cachedLines=this.currentGrid.map(n=>{let x=n.slice(0,i).join(""),p=Math.max(0,t-e-x.length);return` ${o.fg("accent",x)}${" ".repeat(p)}`});let r="ARMIN SAYS HI",f=Math.max(0,t-e-r.length);return this.cachedLines.push(` ${o.fg("accent",r)}${" ".repeat(f)}`),this.cachedWidth=t,this.cachedVersion=this.gridVersion,this.cachedLines}createEmptyGrid(){return Array.from({length:s},()=>Array(c).fill(" "))}initEffect(){switch(this.effect){case"typewriter":this.effectState={pos:0};break;case"scanline":this.effectState={row:0};break;case"rain":this.effectState={drops:Array.from({length:c},()=>({y:-Math.floor(Math.random()*s*2),settled:0}))};break;case"fade":{let t=[];for(let e=0;e<s;e++)for(let i=0;i<c;i++)t.push([e,i]);for(let e=t.length-1;e>0;e--){let i=Math.floor(Math.random()*(e+1));[t[e],t[i]]=[t[i],t[e]]}this.effectState={positions:t,idx:0};break}case"crt":this.effectState={expansion:0};break;case"glitch":this.effectState={phase:0,glitchFrames:8};break;case"dissolve":{this.currentGrid=Array.from({length:s},()=>Array.from({length:c},()=>{let e=[" ","\u2591","\u2592","\u2593","\u2588","\u2580","\u2584"];return e[Math.floor(Math.random()*e.length)]}));let t=[];for(let e=0;e<s;e++)for(let i=0;i<c;i++)t.push([e,i]);for(let e=t.length-1;e>0;e--){let i=Math.floor(Math.random()*(e+1));[t[e],t[i]]=[t[i],t[e]]}this.effectState={positions:t,idx:0};break}}}startAnimation(){let t=this.effect==="glitch"?60:30;this.interval=setInterval(()=>{let e=this.tickEffect();this.updateDisplay(),this.ui.requestRender(),e&&this.stopAnimation()},1e3/t)}stopAnimation(){this.interval&&(clearInterval(this.interval),this.interval=null)}tickEffect(){switch(this.effect){case"typewriter":return this.tickTypewriter();case"scanline":return this.tickScanline();case"rain":return this.tickRain();case"fade":return this.tickFade();case"crt":return this.tickCrt();case"glitch":return this.tickGlitch();case"dissolve":return this.tickDissolve();default:return!0}}tickTypewriter(){let t=this.effectState,e=3;for(let i=0;i<e;i++){let r=Math.floor(t.pos/c),f=t.pos%c;if(r>=s)return!0;this.currentGrid[r][f]=this.finalGrid[r][f],t.pos++}return!1}tickScanline(){let t=this.effectState;if(t.row>=s)return!0;for(let e=0;e<c;e++)this.currentGrid[t.row][e]=this.finalGrid[t.row][e];return t.row++,!1}tickRain(){let t=this.effectState,e=!0;this.currentGrid=this.createEmptyGrid();for(let i=0;i<c;i++){let r=t.drops[i];for(let n=s-1;n>=s-r.settled;n--)n>=0&&(this.currentGrid[n][i]=this.finalGrid[n][i]);if(r.settled>=s)continue;e=!1;let f=-1;for(let n=s-1-r.settled;n>=0;n--)if(this.finalGrid[n][i]!==" "){f=n;break}r.y++,r.y>=0&&r.y<s&&(f>=0&&r.y>=f?(r.settled=s-f,r.y=-Math.floor(Math.random()*5)-1):this.currentGrid[r.y][i]="\u2593")}return e}tickFade(){let t=this.effectState,e=15;for(let i=0;i<e;i++){if(t.idx>=t.positions.length)return!0;let[r,f]=t.positions[t.idx];this.currentGrid[r][f]=this.finalGrid[r][f],t.idx++}return!1}tickCrt(){let t=this.effectState,e=Math.floor(s/2);this.currentGrid=this.createEmptyGrid();let i=e-t.expansion,r=e+t.expansion;for(let f=Math.max(0,i);f<=Math.min(s-1,r);f++)for(let n=0;n<c;n++)this.currentGrid[f][n]=this.finalGrid[f][n];return t.expansion++,t.expansion>s}tickGlitch(){let t=this.effectState;return t.phase<t.glitchFrames?(this.currentGrid=this.finalGrid.map(e=>{let i=Math.floor(Math.random()*7)-3,r=[...e];if(Math.random()<.3)return r.slice(i).concat(r.slice(0,i)).slice(0,c);if(Math.random()<.2){let f=Math.floor(Math.random()*s);return[...this.finalGrid[f]]}return r}),t.phase++,!1):(this.currentGrid=this.finalGrid.map(e=>[...e]),!0)}tickDissolve(){let t=this.effectState,e=20;for(let i=0;i<e;i++){if(t.idx>=t.positions.length)return!0;let[r,f]=t.positions[t.idx];this.currentGrid[r][f]=this.finalGrid[r][f],t.idx++}return!1}updateDisplay(){this.gridVersion++}dispose(){this.stopAnimation()}};export{m as a,G as b,l as c,d};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as __cortexCreateRequire } from 'node:module';
|
|
2
2
|
const require = __cortexCreateRequire(import.meta.url);
|
|
3
3
|
const __cortexPackageRoot = new URL("../../", import.meta.url);
|
|
4
|
-
import{
|
|
4
|
+
import{j as m}from"./chunk-T54CZKNJ.js";import*as d from"path";import{readFileSync as y,writeFileSync as S,mkdirSync as v,existsSync as w,unlinkSync as b}from"fs";var h=class extends Error{constructor(t){super(t),this.name="FeishuUserTokenError"}};function u(e){return e==="lark"?{authorizeBase:"https://accounts.larksuite.com",tokenBase:"https://open.larksuite.com"}:{authorizeBase:"https://accounts.feishu.cn",tokenBase:"https://open.feishu.cn"}}var k="/open-apis/authen/v2/oauth/token",P="/open-apis/authen/v1/authorize",U="/oauth/v1/device_authorization",E="urn:ietf:params:oauth:grant-type:device_code",z="offline_access",N="docx:document sheets:spreadsheet bitable:app wiki:wiki space:document:delete im:resource";function f(){return d.join(m,"feishu-user-token.json")}function T(e){let t=new Set((e??"").split(/\s+/).filter(Boolean));return t.add(z),[...t].join(" ")}function B(e){let{authorizeBase:t}=u(e.domain),n=new URL(t+P);return n.searchParams.set("client_id",e.appId),n.searchParams.set("redirect_uri",e.redirectUri),n.searchParams.set("response_type","code"),n.searchParams.set("scope",T(e.scope)),e.state&&n.searchParams.set("state",e.state),n.toString()}function R(e){let t=(e??"").trim();if(!t)return null;if(/^https?:\/\//i.test(t))try{return new URL(t).searchParams.get("code")}catch{return null}return t}function p(e,t,n){let o=Number(e.expires_in??0)*1e3,r=Number(e.refresh_token_expires_in??0)*1e3;return{access_token:String(e.access_token??""),refresh_token:String(e.refresh_token??n??""),access_expires_at:t+o,refresh_expires_at:t+r,scope:e.scope,obtained_at:t}}async function x(e,t,n){let o=await n(e.tokenBase+k,{method:"POST",headers:{"Content-Type":"application/json; charset=utf-8"},body:JSON.stringify(t)}),r=await o.json().catch(()=>({}));if(!o.ok||typeof r.code=="number"&&r.code!==0||r.error){let i=r.error_description||r.error||r.msg||`HTTP ${o.status}`,c=r.code??r.error??o.status;throw new Error(`Feishu OAuth error ${c}: ${i}`)}return r}async function j(e){let t=e.fetchImpl??globalThis.fetch,n=(e.now??Date.now)(),o={grant_type:"authorization_code",client_id:e.appId,client_secret:e.appSecret,code:e.code};e.redirectUri&&(o.redirect_uri=e.redirectUri);let r=await x(u(e.domain),o,t);return p(r,n)}function O(e,t){return Buffer.from(`${e}:${t}`,"utf8").toString("base64")}function g(e){return Object.entries(e).map(([t,n])=>`${encodeURIComponent(t)}=${encodeURIComponent(n)}`).join("&")}async function H(e){let t=e.fetchImpl??globalThis.fetch,n=u(e.domain),o=await t(n.authorizeBase+U,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Authorization:`Basic ${O(e.appId,e.appSecret)}`},body:g({client_id:e.appId,scope:T(e.scope)})}),r=await o.json().catch(()=>({}));if(!o.ok||r.error||!r.device_code){let c=r.error_description||r.error||r.msg||`HTTP ${o.status}`;throw new Error(`Feishu device authorization failed: ${c}`)}let i=String(r.verification_uri??"");return{device_code:String(r.device_code),user_code:String(r.user_code??""),verification_uri:i,verification_uri_complete:String(r.verification_uri_complete||i),expires_in:Number(r.expires_in??300),interval:Number(r.interval??5)}}async function L(e){let t=e.fetchImpl??globalThis.fetch,n=e.sleep??(l=>new Promise(s=>setTimeout(s,l))),o=e.now??Date.now,r=u(e.domain),i=60,c=Math.max(1,e.interval??5),I=o()+(e.expiresIn??300)*1e3;for(;;){await n(c*1e3);let s=await(await t(r.tokenBase+k,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:g({grant_type:E,device_code:e.deviceCode,client_id:e.appId,client_secret:e.appSecret})})).json().catch(()=>({})),a=s.error;if(!a&&s.access_token)return p(s,o());if(a==="authorization_pending")e.onPending?.();else if(a==="slow_down")c=Math.min(i,c+5),e.onPending?.();else if(a)throw new Error(`Feishu device login failed: ${s.error_description||a}`);if(o()>=I)throw new Error("Feishu device login timed out before authorization completed.")}}async function C(e){let t=e.fetchImpl??globalThis.fetch,n=(e.now??Date.now)(),o=await x(u(e.domain),{grant_type:"refresh_token",client_id:e.appId,client_secret:e.appSecret,refresh_token:e.refreshToken},t);return p(o,n,e.refreshToken)}function A(e,t=f()){v(d.dirname(t),{recursive:!0}),S(t,JSON.stringify(e,null,2),{mode:384})}function F(e=f()){if(!w(e))return null;try{return JSON.parse(y(e,"utf8"))}catch{return null}}function G(e=f()){if(!w(e))return!1;try{return b(e),!0}catch{return!1}}var _="Run `cortex feishu login` to authorize a Feishu user account.";async function J(e){let t=e.file??f(),n=(e.now??Date.now)(),o=e.bufferMs??12e4,r=F(t);if(!r||!r.access_token)throw new h(`No Feishu user token found. ${_}`);if(n<r.access_expires_at-o)return r.access_token;if(!r.refresh_token||n>=r.refresh_expires_at)throw new h(`Feishu user token expired and cannot be refreshed. ${_}`);let i=await C({appId:e.appId,appSecret:e.appSecret,refreshToken:r.refresh_token,domain:e.domain,fetchImpl:e.fetchImpl,now:()=>n});return A(i,t),i.access_token}export{N as a,f as b,B as c,R as d,j as e,H as f,L as g,A as h,F as i,G as j,J as k};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire as __cortexCreateRequire } from 'node:module';
|
|
2
|
+
const require = __cortexCreateRequire(import.meta.url);
|
|
3
|
+
const __cortexPackageRoot = new URL("../../", import.meta.url);
|
|
4
|
+
import{b as l}from"./chunk-CXT5IR5T.js";function h(r,a,s,t){return{role:"assistant",content:[],api:r.api,provider:r.provider,model:r.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:t,errorMessage:a instanceof Error?a.message:String(a),timestamp:s}}function m(r){return typeof r.result=="function"}async function w(r,a,s,t){let n;for await(let e of a)r.push(e),s?.onEvent?.(e),e.type==="done"?n=e.message:e.type==="error"&&(n=e.error);m(a)&&(n=await a.result()),r.end(n),t(n)}function f(r,a,s,t){let n=Date.now(),e=new l,c=!1,u=o=>{c||(c=!0,s?.onResult?.(o))};return a().then(o=>w(e,o,s,u)).catch(o=>{let d=t?.aborted?"aborted":"error",i=h(r,o,n,d),p={type:"error",reason:d,error:i};e.push(p),s?.onEvent?.(p),e.end(i),u(i)}),e}function g(r,a){let s={stream:(t,n,e)=>f(t,async()=>(await r()).stream(t,n,e),void 0,e?.signal),streamSimple:(t,n,e)=>f(t,async()=>(await r()).streamSimple(t,n,e),void 0,e?.signal)};return a?.fetchDeferred&&(s.fetchDeferred=(t,n,e)=>f(t,async()=>{let c=await r();if(!c.fetchDeferred)throw new Error("API does not support deferred responses");return c.fetchDeferred(t,n,e)},void 0,e?.signal)),a?.cancelDeferred&&(s.cancelDeferred=async(t,n,e)=>{let c=await r();if(!c.cancelDeferred)throw new Error("API cannot cancel deferred responses");await c.cancelDeferred(t,n,e)}),s}export{f as a,g as b};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { createRequire as __cortexCreateRequire } from 'node:module';
|
|
2
|
+
const require = __cortexCreateRequire(import.meta.url);
|
|
3
|
+
const __cortexPackageRoot = new URL("../../", import.meta.url);
|
|
4
|
+
import{G as pe,H as It,K as wt,L as xt,a as le,b as ue,c as Ee,i as ht,m as bt}from"./chunk-ZAVX7G2M.js";import{a as it}from"./chunk-TCAEECDI.js";import{a as lt,b as ut,c as pt,d as W,e as dt,f as mt,g as ft,i as gt}from"./chunk-ZFPMIQA3.js";import{a as rt,b as ce}from"./chunk-LEAV3FFG.js";import{a as yt}from"./chunk-4HRI75GU.js";import{a as J}from"./chunk-BKYP6AGM.js";import{k as st,w as ct,x as $e,z as Q}from"./chunk-KST6OY76.js";import{a as nt,b as ot,f as Z}from"./chunk-AXYAZTTN.js";import{a as P}from"./chunk-R2CCD4OF.js";import{K as e}from"./chunk-W34AK4SK.js";import{e as _}from"./chunk-7GGPYU5E.js";import{e as $}from"./chunk-7W7VYUTK.js";import{f as at,g as ve}from"./chunk-JGUEIW2W.js";import{e as et,k as tt}from"./chunk-T54CZKNJ.js";var kn=[["permission",/\b(EACCES|EPERM)\b|permission denied/i],["disk",/\bENOSPC\b|no space left/i],["timeout",/\bETIMEDOUT\b|timed? ?out|killed by SIG/i],["network",/\b(ENOTFOUND|ECONNRESET|ECONNREFUSED|EAI_AGAIN|ENETUNREACH)\b|network|fetch failed/i],["npm",/npm (ERR|error)|exited with code|could not start/i]];function Tn(t){return kn.find(([,n])=>n.test(t))?.[0]??"other"}function St(t,n){return Math.max(0,Math.round((n-t)/1e3))}function de(t,n=new Date){return{type:"upgrade",at:n.toISOString(),...t}}function Rn(t,n){let o=St(Date.parse(t.startedAt),Date.now()),{from:r,to:i,method:a}=t;if(n===null){$e(u=>({...u,pendingUpgrade:t})),Q(de({from:r,to:i,method:a,stage:"installed",durationS:o,failure:null}));return}let c={class:Tn(n),message:J(n)};Q(de({from:r,to:i,method:a,stage:"failed",durationS:o,failure:c}),{urgent:!0})}function vt(t){return(n,o)=>{let r={from:P,to:n,startedAt:new Date().toISOString(),method:Z().serverAutoUpdate?"auto":"prompt"};t(n,i=>{try{Rn(r,i)}catch{}o(i)})}}function jn(t,n,o){if(t){let r=t.to===P?"confirmed":"unconfirmed",i=St(Date.parse(t.startedAt),o);return de({...t,stage:r,durationS:i,failure:null},new Date(o))}return!n||n===P?null:de({from:n,to:P,method:"manual",stage:"version-changed",durationS:null,failure:null},new Date(o))}function Ns(t=Date.now()){let n=ct(),o=jn(n.pendingUpgrade,n.lastVersion,t);$e(r=>({...r,pendingUpgrade:null,lastVersion:P})),o&&Q(o)}function Cn(t){let n=t?.code;return n==="EACCES"||n==="EPERM"?"permission":t instanceof SyntaxError?"parse":typeof n=="string"&&n.startsWith("E")?"io":"other"}function Us(t){let n=t.error instanceof Error?t.error.message:String(t.error);Q({type:"migration_failure",at:new Date().toISOString(),migration:t.migration.replace(/[^A-Za-z0-9._:/@[\]-]/g,"_").slice(0,80),errorClass:Cn(t.error),message:J(n)})}import*as he from"node:fs";import*as je from"node:os";import{spawn as Mn}from"node:child_process";var U=class extends Error{failure;detail;constructor(n,o){super(o?`${n}: ${o}`:n),this.failure=n,this.detail=o,this.name="UpdateLookupError"}};function G(t,n){let o=n?.trim();return{status:"error",reason:"check_failed",failure:t,...o?{detail:J(o)}:{}}}function me(t){return t instanceof U?G(t.failure,t.detail):t instanceof Error?G(`exception:${t.name}`,t.message):G(`exception:${typeof t}`,String(t))}var Et={available:null,state:"idle"},x=Et,A=null;function $t(){return x}function Hs(t,n){let o=A;A=null,o?.(null),A=n,x={available:t,state:"prompting"}}function kt(t){let n=A;return n?(A=null,n(t),!0):!1}function qs(t){A=null,x=t==="apply"?{available:x.available,state:"waiting"}:Et}function Tt(t){let n=A;A=null,n?.(null),x={available:t,state:"waiting",auto:!0}}function Rt(){return x.auto?{auto:!0}:{}}function jt(){x={available:x.available,state:"installing",...Rt()}}function Ct(){x={available:x.available,state:"restarting",...Rt()}}function ee(t){x={available:x.available,state:"failed",error:t}}var _n=2e4,_t=Symbol("timed out"),Pn=/^\d+\.\d+\.\d+(?:-\d+)?$/;function ke(t){return{status:"available",update:{version:t}}}async function An(t){let n,o=new Promise(r=>{n=setTimeout(()=>r(_t),_n),n.unref?.()});try{return await Promise.race([Promise.resolve().then(t),o])}finally{clearTimeout(n)}}var fe=class{deps;inFlight=null;pending=null;latestVersion=null;promptFailure=null;decision=Promise.resolve(null);constructor(n){this.deps=n}check(){return this.inFlight?this.inFlight:(this.inFlight=this.discover().catch(me).finally(()=>{this.inFlight=null}),this.inFlight)}async checkAndWait(){return await this.check(),{action:await this.decision,latestVersion:this.latestVersion}}skipReason(){if(Z().serverUpdateDisable)return"disabled";if(this.deps.isDevMode())return"dev_mode";let{state:n}=$t();return n==="waiting"||n==="installing"||n==="restarting"?"update_in_progress":null}async discover(){let n=this.skipReason();return n?{status:"skipped",reason:n}:this.lookup()}async lookup(){let n=await An(this.deps.getLatest);if(n===_t)return G("timeout");if(!n||!Pn.test(n))return G("bad_version",n??void 0);let o=this.skipReason();return o?{status:"skipped",reason:o}:(this.latestVersion=n,this.resolveVersion(n))}resolveVersion(n){if(it(n,P)<=0)return this.current();let o=this.deps.loadState()??{};return o.skippedVersion===n?{status:"skipped",reason:"version_skipped"}:Z().serverAutoUpdate?this.autoInstall(n,o):this.pending?.version===n?ke(n):this.openPrompt(n,o)}autoInstall(n,o){this.deps.saveState({...o,lastCheckedAt:this.deps.now()}),this.pending=null,Tt(n);try{this.deps.installWhenIdle(n)}catch(r){return ee(r instanceof Error?r.message:String(r)),this.decision=Promise.resolve(null),me(r)}return this.decision=Promise.resolve("apply"),{...ke(n),reason:"auto_install"}}current(){return this.pending&&(this.pending=null,kt("cancel"),this.decision=Promise.resolve(null)),{status:"current"}}async openPrompt(n,o){let r={...o,lastCheckedAt:this.deps.now(),lastPromptedVersion:n};this.deps.saveState(r);let i=this.deps.prompt.ask({latestVersion:n});return this.pending={version:n,answer:i},this.promptFailure=null,this.decision=this.handleDecision(this.pending,r),await Promise.resolve(),this.promptFailure??ke(n)}async handleDecision(n,o){try{let r=await n.answer;return this.pending!==n?null:this.acceptChoice(r,n.version,o)}catch(r){return this.failDecision(n,r)}finally{this.pending===n&&(this.pending=null)}}failDecision(n,o){return this.pending!==n||(this.promptFailure=me(o),ee(o instanceof Error?o.message:String(o))),null}acceptChoice(n,o,r){return n==="apply"&&(this.deps.saveState({...r,skippedVersion:void 0}),this.deps.installWhenIdle(o)),n==="skip"&&this.deps.saveState({...r,skippedVersion:o}),n}};import{execFile as On}from"node:child_process";var Dn=1024*1024;function Ln(t,n,o,r,i){let a=n&&typeof n.code=="number"?n.code:n?null:0,c=n?.signal??null,u=!!n&&(n?.killed===!0||c==="SIGTERM")&&i!==void 0;t({ok:a===0,code:a,signal:c,timedOut:u,stdout:o,stderr:r,...n&&typeof n.code=="string"?{error:n.message}:{}})}function H(t,n=[],o={}){return new Promise(r=>{let i=On(t,[...n],{cwd:o.cwd,shell:o.shell,env:o.env??process.env,timeout:o.timeoutMs,killSignal:"SIGTERM",maxBuffer:o.maxBuffer??Dn,encoding:"utf8",windowsHide:!0},(a,c,u)=>Ln(r,a,c,u,o.timeoutMs));o.stdin!==void 0?i.stdin?.end(o.stdin):i.stdin?.end()})}function er(t,n={}){let o=process.platform==="win32"?process.env.ComSpec??"cmd.exe":"/bin/sh",r=process.platform==="win32"?"/c":"-c";return H(o,[r,t],n)}import*as q from"fs";import*as ge from"path";var Te=ge.join(tt,"update-state.json");function Pt(){try{return JSON.parse(q.readFileSync(Te,"utf8"))}catch{return null}}function At(t){let n=ge.dirname(Te);q.mkdirSync(n,{recursive:!0}),q.writeFileSync(Te,JSON.stringify(t,null,2))}var Fn=6e4,Ot={isIdle:()=>!0,onIdle:()=>()=>{}};function Dt(t,n,o={}){let r=o.supervised??(()=>!!process.send),i=o.renewMs??Fn,a=null,c=!1,u=null,f=(b,g)=>{if(clearInterval(b),c=!1,g!==null){Ee(),ee(g);return}Ct(),r()?ue({phase:le}):Ee()},m=()=>{if(c||a===null||!t.isIdle())return;let b=a;a=null,u?.(),u=null,c=!0,ue({phase:le});let g=setInterval(()=>ue({phase:le}),i);g.unref?.(),jt();let N=!1,K=C=>{N||(N=!0,f(g,C))};try{n(b,K)}catch(C){K(C instanceof Error?C.message:String(C))}};return b=>{if(a=b,t.isIdle()){m();return}u??=t.onIdle(m)}}function Nn(){let t=process.env.CORTEX_REPO;if(!t)return!1;try{return he.existsSync(t)&&he.statSync(t).isDirectory()}catch{return!1}}async function Un(){let t=ve(["view","@cortex-agent/server","version"]),n=await H(t.command,t.args,{shell:t.shell,timeoutMs:15e3,cwd:je.tmpdir()});if(!n.ok)throw Bn(n);return n.stdout.trim()||null}function Bn(t){return t.timedOut?new U("timeout",Re(t.stderr)):t.error?new U("npm_spawn",t.error):new U(`npm_exit:${t.code??t.signal}`,Re(t.stderr))}var Wn=2e3;function Re(t){return t.trim().split(`
|
|
5
|
+
`).slice(-6).join(`
|
|
6
|
+
`).trim()}function Gn(t,n,o){let r=n!==null?`killed by ${n}`:`exited with code ${t}`,i=Re(o);return i?`npm install -g ${r}
|
|
7
|
+
${i}`:`npm install -g ${r}`}function Hn(t,n){let o=ve(at(["install","-g",`@cortex-agent/server@${t}`])),r=Mn(o.command,o.args,{shell:o.shell,detached:!0,stdio:["ignore","ignore","pipe"],cwd:je.tmpdir()}),i="";r.stderr?.on("data",a=>{i.length<Wn&&(i+=String(a))}),r.stderr?.unref?.(),r.on("error",a=>n(`npm install -g could not start: ${a.message}`)),r.on("exit",(a,c)=>n(a===0?null:Gn(a,c,i))),r.unref()}function qn(){return new Date().toISOString()}function gr(t){return new fe({prompt:t.prompt,getLatest:t.getLatest??Un,installWhenIdle:t.installWhenIdle??Dt(t.idle??Ot,vt(Hn)),loadState:t.loadState??Pt,saveState:t.saveState??At,now:t.now??qn,isDevMode:Nn})}import*as Ft from"net";var O=$("device-port"),Lt="127.0.0.1",Mt="127.0.0.1",Vn=32,Xn=64,D=new Map;function Nt(t,n,o){return`${t}|${n}|${o}`}function zn(t,n,o){let r=!1,i=a=>{if(!r){r=!0,O.debug(`${o} closed: ${a}`);try{n.close()}catch{}try{t.destroy()}catch{}}};n.on("message",a=>{let c=Array.isArray(a)?Buffer.concat(a):Buffer.from(a);t.write(c)||(n.pause?.(),t.once("drain",()=>n.resume?.()))}),n.on("error",a=>i(`ws error: ${a.message}`)),n.on("close",()=>i("ws closed")),t.on("data",a=>{t.pause(),n.send(a,c=>{c?i(`send failed: ${c.message}`):t.resume()})}),t.on("error",a=>i(`tcp error: ${a.message}`)),t.on("close",()=>i("tcp closed")),t.resume()}var Yn=wt;async function Kn(t,n){let{device:o,remoteHost:r,remotePort:i}=t.info;if(n.pause(),n.setNoDelay(!0),t.connections.add(n),n.once("close",()=>t.connections.delete(n)),t.connections.size>Xn){O.warn(`${o}:${i} \u2014 connection cap reached, refusing`),n.destroy();return}let a;try{a=bt(o,r,i)}catch(u){O.warn(`${o}:${i} \u2014 ${u.message}`),n.destroy();return}a.socket.catch(()=>{});try{Yn(o,a.message)}catch(u){O.warn(`${o}:${i} \u2014 cannot ask device to open a stream: ${u.message}`),n.destroy();return}let c;try{c=await a.socket}catch(u){O.warn(`${o}:${i} \u2014 ${u.message}`),n.destroy();return}if(n.destroyed){try{c.close()}catch{}return}zn(n,c,`${o}:${i} stream ${a.id.slice(0,8)}`)}async function Ut(t,n){let o=Mt,r=Nt(t,o,n),i=D.get(r);if(i)return i.info;if(D.size>=Vn)throw new Error(`too many device ports open (${D.size})`);let a=Ft.createServer(),c={info:{device:t,remoteHost:o,remotePort:n,localPort:0,openedAt:new Date},server:a,connections:new Set};await new Promise((f,m)=>{a.once("error",m),a.listen(0,Lt,()=>{a.removeListener("error",m),f()})});let u=a.address();if(!u||typeof u=="string")throw a.close(),new Error("failed to bind a local port");return c.info.localPort=u.port,a.on("connection",f=>{Kn(c,f)}),a.on("error",f=>O.warn(`listener for ${t}:${n} failed: ${f.message}`)),D.set(r,c),O.info(`device port ${Lt}:${u.port} \u2192 ${t} ${o}:${n}`),c.info}function V(t,n){let o=Mt,r=Nt(t,o,n),i=D.get(r);if(!i)return!1;D.delete(r);for(let a of i.connections)a.destroy();return i.connections.clear(),i.server.close(),O.info(`closed device port ${i.info.localPort} \u2192 ${t} ${o}:${n}`),!0}function xr(){return[...D.values()].map(t=>({...t.info}))}function yr(){for(let t of[...D.values()])V(t.info.device,t.info.remotePort)}import*as oe from"fs";import*as Yt from"net";import*as Kt from"path";import{spawn as Zt}from"child_process";import*as X from"fs";import*as Ce from"path";import{execFile as Zn,spawn as Jn}from"child_process";import{promisify as Qn}from"util";var eo=Qn(Zn),Bt=$("browser-display");function to(t){if(t.override)return{mode:"attached",display:t.override,takeover:"remote-desktop",reason:`display pinned by configuration (${t.override})`};if(t.platform==="linux"){if(t.envDisplay&&t.usableDisplays.includes(t.envDisplay))return{mode:"attached",display:t.envDisplay,takeover:"remote-desktop",reason:`$DISPLAY ${t.envDisplay} is reachable`};if(t.usableDisplays.length>0){let n=t.usableDisplays[0];return{mode:"attached",display:n,takeover:"remote-desktop",reason:`graphical session ${n} belongs to this user and is reachable`}}return t.hasXvfb?{mode:"virtual",display:null,takeover:"vnc-required",reason:"no reachable session; a virtual display will be created (a VNC bridge is needed to watch it)"}:{mode:"headless",display:null,takeover:"none",reason:"no graphical session and no Xvfb \u2014 the agent can browse, but nobody can take over"}}return t.platform==="darwin"||t.platform==="win32"?t.interactiveSession?{mode:"attached",display:null,takeover:"remote-desktop",reason:"running inside an interactive desktop session"}:{mode:"headless",display:null,takeover:"none",reason:t.platform==="win32"?"service session (Session 0) cannot show a window \u2014 CDP still works, takeover cannot":"no Aqua session (daemon context) \u2014 CDP still works, takeover cannot"}:{mode:"headless",display:null,takeover:"none",reason:`unsupported platform ${t.platform}`}}async function no(){let t;try{t=await X.promises.readdir("/tmp/.X11-unix")}catch{return[]}let n=typeof process.getuid=="function"?process.getuid():-1;return(await Promise.all(t.filter(r=>/^X\d+$/.test(r)).map(async r=>{try{let a=await X.promises.stat(`/tmp/.X11-unix/${r}`);if(n>=0&&a.uid!==n)return null}catch{return null}let i=`:${r.slice(1)}`;return await oo(i)?i:null}))).filter(r=>r!==null).sort((r,i)=>Number(r.slice(1))-Number(i.slice(1)))}async function oo(t){let n=[["xdpyinfo",["-display",t]],["xset",["-display",t,"q"]]];for(let[o,r]of n){let i=await Wt(o,r,3e3);if(i!=="missing")return i===0}return Bt.warn("neither xdpyinfo nor xset is installed \u2014 trusting X socket ownership"),!0}function Wt(t,n,o){return new Promise(r=>{let i=Jn(t,n,{stdio:"ignore",timeout:o});i.once("error",a=>r(a.code==="ENOENT"?"missing":-1)),i.once("exit",a=>r(a??-1))})}async function _e(t){return await Wt("which",[t],2e3)===0}async function so(t,n=process.env){if(t==="darwin")try{let{stdout:o}=await eo("launchctl",["managername"],{encoding:"utf8",timeout:2e3});return o.trim()==="Aqua"}catch{return!1}if(t==="win32"){let o=n.SESSIONNAME;return!!o&&o.toLowerCase()!=="services"}return!1}function Gt(t,n="/tmp"){for(let o=t;o<t+100;o++)if(!(X.existsSync(Ce.join(n,`.X${o}-lock`))||X.existsSync(Ce.join(n,".X11-unix",`X${o}`))))return o;return null}async function Ht(t=process.env){let n=process.platform,o=t.CORTEX_BROWSER_DISPLAY,r=n==="linux"&&!o,[i,a,c]=await Promise.all([r?no():[],r?_e("Xvfb"):!1,o?!1:so(n,t)]),u=to({platform:n,override:o,envDisplay:t.DISPLAY,usableDisplays:i,hasXvfb:a,interactiveSession:c});return Bt.info(`display \u2192 ${u.mode}${u.display?` (${u.display})`:""}: ${u.reason}`),u}var R=$("managed-browser"),qt=Kt.join(et,"browser","profile"),ro=9222,io=600*1e3,Vt=3e4,Xt=1e4,ao=99,co=3,Pe="browser stopped while starting",lo=6e4,uo=3,h=null,te=null,z=null,E=0,v=null,ne=[],k="server";async function Ae(){E++,v&&(clearTimeout(v),v=null);try{return await en()}catch(t){throw E>0&&E--,t}}function Oe(){E!==0&&(E--,E===0&&po())}function Jt(){return{running:!!h,refs:E,browser:h?{cdpEndpoint:h.cdpEndpoint,port:h.port,display:h.display,pid:h.pid}:null}}function _r(){v&&(clearTimeout(v),v=null),E=0,z&&(z.cancelled=!0,be(z.procs,"SIGTERM")),Qt()}function po(){v&&clearTimeout(v),v=setTimeout(()=>{v=null,E===0&&(R.info("no browser sessions left \u2014 reclaiming Chrome"),Qt())},io),v.unref?.()}function Qt(){let t=h;h=null,t&&be([t.proc,...t.xvfb?[t.xvfb]:[]],"SIGTERM")}function be(t,n){for(let o of t)try{o.kill(n)}catch{}}async function en(){return h||te||(te=mo().finally(()=>{te=null}),te)}async function mo(){let t={cancelled:!1,procs:[]};z=t;try{return await fo(t)}catch(n){throw be(t.procs,"SIGKILL"),n}finally{z===t&&(z=null)}}async function fo(t){let n=()=>{if(t.cancelled)throw new Error(Pe)},o=await Io();if(!o)throw new Error("no Chrome/Chromium found \u2014 install Google Chrome, or set CORTEX_BROWSER_BINARY to its path");let r=await Ht();n(),oe.mkdirSync(qt,{recursive:!0});let i=await wo(ro);n();let a,c=r.display;if(r.mode==="virtual"){let g=await ho(t);a=g.proc,c=g.display}let u=[`--remote-debugging-port=${i}`,`--user-data-dir=${qt}`,"--no-first-run","--no-default-browser-check","--disable-features=Translate","--remote-debugging-address=127.0.0.1"];r.mode==="headless"&&u.push("--headless=new"),process.platform==="linux"&&u.push("--password-store=basic");let f={...process.env};c?f.DISPLAY=c:delete f.DISPLAY,R.info(`launching ${o} on port ${i} (${r.mode}${c?` ${c}`:""})`);let m=Zt(o,u,{env:f,stdio:"ignore",detached:!1});t.procs.push(m);let b=null;return m.on("exit",(g,N)=>go(m,g,N)),m.on("error",g=>{b=g.message,R.error(`Chrome failed to spawn: ${g.message}`)}),await xo(i,()=>t.cancelled?Pe:b?`Chrome failed to spawn: ${b}`:m.exitCode!==null||m.signalCode!==null?`Chrome exited during startup (code=${m.exitCode} signal=${m.signalCode})`:null),n(),h={cdpEndpoint:`http://127.0.0.1:${i}`,port:i,display:{...r,display:c},pid:m.pid??-1,proc:m,xvfb:a},R.info(`Chrome ready at ${h.cdpEndpoint} (pid ${h.pid})`),h}function go(t,n,o){if(!h||h.proc!==t||(R.warn(`Chrome exited (code=${n} signal=${o})`),h.xvfb?.kill("SIGTERM"),h=null,E===0))return;let r=Date.now();if(ne=ne.filter(i=>r-i<lo),ne.length>=uo){R.error("Chrome crashed repeatedly \u2014 giving up until the next acquire"),ne=[];return}ne.push(r),R.info(`${E} session(s) still need a browser \u2014 restarting`),en().catch(i=>R.error(`restart failed: ${String(i)}`))}async function ho(t){let n=ao,o="no free display number";for(let r=0;r<co;r++){let i=Gt(n);if(i===null)break;let a=`:${i}`,c=Zt("Xvfb",[a,"-screen","0","1920x1080x24","-nolisten","tcp","-displayfd","3"],{stdio:["ignore","ignore","ignore","pipe"]});t.procs.push(c);let u=await bo(c);if(t.cancelled)throw new Error(Pe);if(!u)return{proc:c,display:a};o=`${a}: ${u}`,R.warn(`Xvfb ${o}`),be([c],"SIGKILL"),n=i+1}throw new Error(`Xvfb could not start a virtual display (${o})`)}function bo(t){return new Promise(n=>{let o=!1,r="",i=u=>{o||(o=!0,clearTimeout(a),n(u))},a=setTimeout(()=>i(`not ready within ${Xt}ms`),Xt),c=t.stdio[3];c?.on("data",u=>{r+=String(u),r.includes(`
|
|
8
|
+
`)&&i(null)}),c?.on("error",()=>{}),t.once("exit",(u,f)=>i(`exited (code=${u} signal=${f})`)),t.once("error",u=>i(u.message))})}async function Io(t=process.env){if(t.CORTEX_BROWSER_BINARY)return oe.existsSync(t.CORTEX_BROWSER_BINARY)?t.CORTEX_BROWSER_BINARY:null;let n=process.platform==="darwin"?["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome","/Applications/Chromium.app/Contents/MacOS/Chromium"]:process.platform==="win32"?[`${t.ProgramFiles??"C:\\Program Files"}\\Google\\Chrome\\Application\\chrome.exe`,`${t["ProgramFiles(x86)"]??"C:\\Program Files (x86)"}\\Google\\Chrome\\Application\\chrome.exe`,`${t.LOCALAPPDATA??""}\\Google\\Chrome\\Application\\chrome.exe`]:[];for(let o of n)try{if(oe.existsSync(o))return o}catch{}for(let o of["google-chrome","google-chrome-stable","chromium","chromium-browser","chrome"])if(await _e(o))return o;return null}async function wo(t){if(await zt(t))return t;for(let n=t+1;n<t+20;n++)if(await zt(n))return n;throw new Error(`no free CDP port near ${t}`)}function zt(t){return new Promise(n=>{let o=Yt.createServer();o.once("error",()=>n(!1)),o.once("listening",()=>o.close(()=>n(!0))),o.listen(t,"127.0.0.1")})}async function xo(t,n){let o=Date.now()+Vt,r="";for(;Date.now()<o;){let i=n();if(i)throw new Error(i);try{let a=await fetch(`http://127.0.0.1:${t}/json/version`,{signal:AbortSignal.timeout(2e3)});if(a.ok)return;r=`HTTP ${a.status}`}catch(a){r=a instanceof Error?a.message:String(a)}await new Promise(a=>setTimeout(a,250))}throw new Error(`Chrome did not expose CDP on ${t} within ${Vt}ms (${r})`)}var tn=".cortex/browser/profile",Ie="DevToolsActivePort";function yo(t){return t==="darwin"?["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome","/Applications/Chromium.app/Contents/MacOS/Chromium"]:[]}var So=["google-chrome","google-chrome-stable","chromium","chromium-browser","chrome"],De="Cortex Managed Browser",vo=`
|
|
9
|
+
$ErrorActionPreference = "Stop"
|
|
10
|
+
$profile = Join-Path $env:USERPROFILE ".cortex\\browser\\profile"
|
|
11
|
+
$portFile = Join-Path $profile "${Ie}"
|
|
12
|
+
New-Item -ItemType Directory -Force -Path $profile | Out-Null
|
|
13
|
+
if ((Test-Path -LiteralPath $portFile) -and (Get-Item -LiteralPath $portFile).Length -gt 0) {
|
|
14
|
+
Get-Content -LiteralPath $portFile -TotalCount 1
|
|
15
|
+
exit 0
|
|
16
|
+
}
|
|
17
|
+
$candidates = @(
|
|
18
|
+
(Join-Path $env:ProgramFiles "Google\\Chrome\\Application\\chrome.exe"),
|
|
19
|
+
(Join-Path ([Environment]::GetEnvironmentVariable("ProgramFiles(x86)")) "Google\\Chrome\\Application\\chrome.exe"),
|
|
20
|
+
(Join-Path $env:LOCALAPPDATA "Google\\Chrome\\Application\\chrome.exe")
|
|
21
|
+
)
|
|
22
|
+
$chrome = $candidates | Where-Object { $_ -and (Test-Path -LiteralPath $_) } | Select-Object -First 1
|
|
23
|
+
if (-not $chrome) {
|
|
24
|
+
foreach ($name in @("google-chrome", "google-chrome-stable", "chromium", "chromium-browser", "chrome")) {
|
|
25
|
+
$found = Get-Command $name -ErrorAction SilentlyContinue
|
|
26
|
+
if ($found) { $chrome = $found.Source; break }
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (-not $chrome) { [Console]::Error.WriteLine("chrome-not-found"); exit 3 }
|
|
30
|
+
$user = (Get-CimInstance Win32_ComputerSystem).UserName
|
|
31
|
+
if (-not $user) { [Console]::Error.WriteLine("no-interactive-user"); exit 5 }
|
|
32
|
+
$current = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name
|
|
33
|
+
if ($user -ine $current) { [Console]::Error.WriteLine("interactive-user-mismatch"); exit 6 }
|
|
34
|
+
$quote = [char]34
|
|
35
|
+
$arguments = "--remote-debugging-port=0 --remote-debugging-address=127.0.0.1 --user-data-dir=$quote$profile$quote --no-first-run --no-default-browser-check about:blank"
|
|
36
|
+
$action = New-ScheduledTaskAction -Execute $chrome -Argument $arguments
|
|
37
|
+
$principal = New-ScheduledTaskPrincipal -UserId $user -LogonType Interactive -RunLevel Limited
|
|
38
|
+
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -ExecutionTimeLimit ([TimeSpan]::Zero) -MultipleInstances IgnoreNew
|
|
39
|
+
Register-ScheduledTask -TaskName "${De}" -Action $action -Principal $principal -Settings $settings -Force | Out-Null
|
|
40
|
+
Start-ScheduledTask -TaskName "${De}"
|
|
41
|
+
for ($i = 0; $i -lt 60; $i++) {
|
|
42
|
+
if ((Test-Path -LiteralPath $portFile) -and (Get-Item -LiteralPath $portFile).Length -gt 0) { break }
|
|
43
|
+
Start-Sleep -Milliseconds 500
|
|
44
|
+
}
|
|
45
|
+
if (-not ((Test-Path -LiteralPath $portFile) -and (Get-Item -LiteralPath $portFile).Length -gt 0)) {
|
|
46
|
+
[Console]::Error.WriteLine("chrome-did-not-listen")
|
|
47
|
+
exit 4
|
|
48
|
+
}
|
|
49
|
+
Get-Content -LiteralPath $portFile -TotalCount 1
|
|
50
|
+
`.trim();function Eo(t){let n=yo(t).map(o=>` [ -f "${o}" ] && { CHROME="${o}"; }`).join(`
|
|
51
|
+
`);return[`PROFILE="$HOME/${tn}"`,`PORTFILE="$PROFILE/${Ie}"`,'mkdir -p "$PROFILE"','if [ -s "$PORTFILE" ]; then head -1 "$PORTFILE"; exit 0; fi','CHROME=""',...n?[`if [ -z "$CHROME" ]; then :
|
|
52
|
+
${n}
|
|
53
|
+
fi`]:[],`for b in ${So.join(" ")}; do`,' [ -n "$CHROME" ] && break',' p=$(command -v "$b" 2>/dev/null) && CHROME="$p"',"done",'[ -n "$CHROME" ] || { echo "chrome-not-found" >&2; exit 3; }','nohup "$CHROME" --remote-debugging-port=0 --remote-debugging-address=127.0.0.1 --user-data-dir="$PROFILE" --no-first-run --no-default-browser-check --password-store=basic about:blank >/dev/null 2>&1 &','for _ in $(seq 1 60); do [ -s "$PORTFILE" ] && break; sleep 0.5; done','[ -s "$PORTFILE" ] || { echo "chrome-did-not-listen" >&2; exit 4; }','head -1 "$PORTFILE"'].join(`
|
|
54
|
+
`)}function nn(t){return t==="win32"?`powershell.exe -NoProfile -Command '${vo}' </dev/null`:Eo(t)}function Le(t){let n=`"$HOME/${tn}"`;return t==="win32"?[`powershell.exe -NoProfile -Command '${['$ErrorActionPreference = "SilentlyContinue"',`Stop-ScheduledTask -TaskName "${De}" -ErrorAction SilentlyContinue`,"Get-CimInstance Win32_Process | Where-Object {",' $_.Name -eq "chrome.exe" -and $_.CommandLine -like "*.cortex*browser*profile*"',"} | ForEach-Object { Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue }"].join(`
|
|
55
|
+
`)}' </dev/null >/dev/null 2>&1 || true`,`rm -f ${n}/${Ie}`].join(`
|
|
56
|
+
`):[`pkill -f -- ${n} >/dev/null 2>&1 || true`,`rm -f ${n}/${Ie}`].join(`
|
|
57
|
+
`)}var se=$("device-browser"),$o=9e4,ko=5e3,To=10*6e4,L=new Map;async function Me(t,n,o){let r=await xt(t,{action:"bash",params:{command:n},timeout:o});if(r?.exitCode!==void 0&&r.exitCode!==0){let i=String(r.stderr??"").trim()||`exit ${r.exitCode}`;throw new Error(i)}return typeof r?.stdout=="string"?r.stdout:""}function Ro(t){let n=t.split(`
|
|
58
|
+
`).map(r=>r.trim()).filter(r=>/^\d+$/.test(r));if(n.length===0)return null;let o=Number(n[n.length-1]);return o>0&&o<=65535?o:null}function sn(t){return pe().find(n=>n.device===t)?.platform??""}async function Fe(t){try{return(await fetch(`${t}/json/version`,{signal:AbortSignal.timeout(ko)})).ok}catch{return!1}}async function on(t,n){let o=await Me(t,nn(n),$o),r=Ro(o);if(r===null)throw new Error(`device ${t} reported no debugging port`);let i=await Ut(t,r);return{device:t,remotePort:r,cdpEndpoint:`http://127.0.0.1:${i.localPort}`,refs:0,idleTimer:null}}async function Ne(t){let n=sn(t),o=L.get(t);if(o){if(o.idleTimer&&(clearTimeout(o.idleTimer),o.idleTimer=null),await Fe(o.cdpEndpoint))return o.refs++,{device:t,remotePort:o.remotePort,cdpEndpoint:o.cdpEndpoint};se.info(`${t}: mapped browser no longer answers \u2014 relaunching`),V(t,o.remotePort),L.delete(t)}let r=await on(t,n);if(!await Fe(r.cdpEndpoint)&&(se.info(`${t}: adopted debugging port ${r.remotePort} is dead \u2014 stopping and relaunching`),V(t,r.remotePort),await Me(t,Le(n),3e4),r=await on(t,n),!await Fe(r.cdpEndpoint)))throw V(t,r.remotePort),new Error(`device ${t} launched Chrome but its debugging port is unreachable`);return r.refs=1,L.set(t,r),se.info(`${t}: browser on device port ${r.remotePort} \u2192 ${r.cdpEndpoint}`),{device:t,remotePort:r.remotePort,cdpEndpoint:r.cdpEndpoint}}function jo(t){t.idleTimer=setTimeout(()=>{t.refs>0||(se.info(`${t.device}: no browser sessions left \u2014 reclaiming Chrome`),Co(t.device).catch(n=>se.warn(`${t.device}: could not stop Chrome: ${n.message}`)))},To),t.idleTimer.unref?.()}function rn(t){let n=L.get(t);n&&(n.refs=Math.max(0,n.refs-1),n.refs===0&&!n.idleTimer&&jo(n))}async function Co(t){let n=L.get(t);n?.idleTimer&&clearTimeout(n.idleTimer),L.delete(t),n&&V(t,n.remotePort),await Me(t,Le(sn(t)),3e4)}function Mr(){for(let t of L.values())t.idleTimer&&clearTimeout(t.idleTimer);L.clear()}var F=$("browser-broker"),_o=10*6e4,Po=15e3,Ao=5e3,y=class extends Error{code;hint;constructor(n,o,r){super(o),this.name="BrowserLeaseError",this.code=n,this.hint=r}};function we(t){return typeof t=="string"?t.trim():""}function Oo(t,n){let o=n.trim(),r="or run without --device to use the server's browser";return o.includes("chrome-not-found")?{message:`Chrome is not installed on ${t}`,hint:`install Google Chrome on ${t}, ${r}`}:o.includes("no-interactive-user")?{message:`nobody is logged in to the desktop on ${t}`,hint:`log in on ${t}, ${r}`}:o.includes("interactive-user-mismatch")?{message:`the Cortex client on ${t} runs as a different user than the desktop session`,hint:`run the Cortex client as the logged-in user on ${t}`}:o.includes("chrome-did-not-listen")?{message:`Chrome on ${t} did not open its debugging port in time`,hint:`close any Chrome window still using the Cortex profile on ${t} and retry`}:/timed out/i.test(o)?{message:`${t} did not answer while starting Chrome (${o})`,hint:`check that ${t} is awake and its Cortex client is connected`}:{message:`could not start Chrome on ${t}: ${o||"unknown error"}`}}function Do(t){let n=new Map,o=new Map,r=new Map,i=new Map,a=new Set,c=null;function u(){for(let s of a)try{s()}catch(l){F.warn(`listener failed: ${l.message}`)}}function f(s,l,p){let I=(s.get(l)??Promise.resolve()).catch(()=>{}).then(p),w=I.catch(()=>{});return s.set(l,w),w.then(()=>{s.get(l)===w&&s.delete(l)}),I}function m(){if(c)return c;try{c={bin:t.resolveBin(),env:t.baseEnv()}}catch(s){throw s instanceof lt?new y("engine-missing",s.message,s.hint):s}return c}function b(s){s.idleTimer&&clearTimeout(s.idleTimer),s.idleTimer=setTimeout(()=>{if(s.idleTimer=null,s.takenOver){b(s);return}n.get(s.sessionId)===s&&(F.info(`${s.sessionId}: browser idle for ${Math.round(t.idleMs/6e4)} min \u2014 releasing`),f(o,s.sessionId,async()=>{n.get(s.sessionId)===s&&!s.takenOver&&await N(s)}))},t.idleMs),s.idleTimer.unref?.()}function g(s){s.lastUsedAt=t.now(),b(s)}async function N(s){if(s.idleTimer&&clearTimeout(s.idleTimer),s.idleTimer=null,n.get(s.sessionId)===s&&n.delete(s.sessionId),i.delete(s),s.holdsRef&&(s.holdsRef=!1,t.release(s.device)),u(),!(!s.cdpEndpoint||!c))for(let l of[["tab","close"],["close"]])await t.run(c.bin,W(s.cdpEndpoint,s.abSession,l),c.env).catch(()=>{})}function K(s,l){return s.holdsRef&&(s.holdsRef=!1,t.release(s.device)),i.delete(s),s.state="error",s.error=l.hint?`${l.message} \u2014 ${l.hint}`:l.message,s.cdpEndpoint=null,u(),l}function C(s){if(s===k)return;let{state:l,online:p}=t.availability(s);if(l==="online")return;let d=p.length?`online devices: ${["server",...p].join(", ")}`:"no devices are online";throw l==="offline"?new y("device-offline",`device "${s}" is offline`,`start its Cortex client, or pick another device (${d})`):new y("unknown-device",`unknown device "${s}"`,`use one of: server${p.length?`, ${p.join(", ")}`:""}`)}function ze(s,l){if(l instanceof y)return l;let p=l?.message??String(l);if(s===k)return new y("chrome-failed",`could not start Chrome on the server: ${p}`);let{message:d,hint:I}=Oo(s,p);return new y("chrome-failed",d,I)}function yn(s){return s===k?t.acquire(s):f(r,s,()=>t.acquire(s))}async function Sn(s){try{C(s.device),m(),s.cdpEndpoint=await yn(s.device),s.holdsRef=!0,await Ze(s),s.state="ready",s.error=void 0,i.set(s,t.now()),F.info(`${s.sessionId}: browser ready on ${s.device} (${s.abSession})`)}catch(l){throw K(s,ze(s.device,l))}u()}async function vn(s){if(!(!(s.device===k||t.now()-(i.get(s)??0)>=Po)||!s.cdpEndpoint))try{C(s.device);let p=await(s.device===k?t.refresh(s.device,s.cdpEndpoint):f(r,s.device,()=>t.refresh(s.device,s.cdpEndpoint)));i.set(s,t.now()),p!==s.cdpEndpoint&&(F.info(`${s.sessionId}: ${s.device} browser moved to ${p}`),s.cdpEndpoint=p,u())}catch(p){throw K(s,ze(s.device,p))}}function Ye(s,l,p){return f(o,s,async()=>{let d=n.get(s);if(p&&d?.takenOver)throw new y("taken-over","the user is controlling this browser right now","wait for them to hand it back, or ask them; do not retry in a loop");let I=l||d?.device||k;if(d&&(d.device!==I||d.state==="error")){let $n=d.takenOver;await N(d),d=void 0,$n&&F.info(`${s}: switching device ends the takeover`)}if(d?.state==="ready")return await vn(d),g(d),d;let w={sessionId:s,device:I,abSession:pt(s,I),state:"starting",cdpEndpoint:null,holdsRef:!1,takenOver:!1,lastUsedAt:t.now(),idleTimer:null,refreshing:!1,refreshAgain:!1};return n.set(s,w),g(w),u(),await Sn(w),w})}function Ke(s){let l=n.get(s);if(!l)throw new y("no-lease",`session ${s} has no browser`);return l}function En(s){let l=Ke(s);if(l.state!=="ready"||!l.cdpEndpoint)throw new y("no-lease",`the browser for session ${s} is ${l.state}`);return l}async function ae(s,l){let p=m(),d=()=>t.run(p.bin,W(s.cdpEndpoint,s.abSession,l),p.env),I=await d();return I.code===0||!mt(I.stderr)||(F.info(`${s.sessionId}: bound tab is gone \u2014 opening a new one`),(await t.run(p.bin,W(s.cdpEndpoint,s.abSession,["tab","new"]),p.env)).code!==0)?I:(await Ze(s),d())}async function Ze(s){let l=m(),p=await t.run(l.bin,W(s.cdpEndpoint,s.abSession,dt),l.env).catch(d=>({code:-1,stdout:"",stderr:String(d)}));p.code!==0&&F.warn(`${s.sessionId}: could not set the viewport: ${p.stderr.trim().slice(0,200)}`)}async function Je(s){if(s.refreshing){s.refreshAgain=!0;return}s.refreshing=!0;try{do{if(s.refreshAgain=!1,n.get(s.sessionId)!==s||s.state!=="ready"||!c)return;let l=async I=>{let w=await t.run(c.bin,W(s.cdpEndpoint,s.abSession,["--json","get",I]),c.env);if(w.code===0)try{return we(JSON.parse(w.stdout)?.data?.[I])||void 0}catch{return}},[p,d]=[await l("url"),await l("title")];(p!==s.url||d!==s.title)&&(s.url=p,s.title=d,u())}while(s.refreshAgain)}finally{s.refreshing=!1}}function Qe(s){try{return JSON.parse(s)}catch{return null}}return{async leaseBrowser({sessionId:s,device:l}){let p=we(s);if(!p)throw new y("bad-request","no session id","cortex-browser must run inside a Cortex session (CORTEX_SESSION_ID is unset)");let d=await Ye(p,we(l)||null,!0);return{device:d.device,cdpEndpoint:d.cdpEndpoint,abSession:d.abSession}},listBrowserSessions(){return[...n.values()].sort((s,l)=>l.lastUsedAt-s.lastUsedAt).map(s=>({sessionId:s.sessionId,device:s.device,abSession:s.abSession,state:s.state,...s.error?{error:s.error}:{},...s.url?{url:s.url}:{},...s.title?{title:s.title}:{},takenOver:s.takenOver,lastUsedAt:s.lastUsedAt}))},async runAgentBrowser(s,l){let p=await Ye(s,null,!1),d=await ae(p,l);return Je(p),d},async streamPort(s){let l=n.get(s);if(!l||l.state!=="ready")return null;let p=Qe((await ae(l,["--json","stream","status"])).stdout);if(p?.data?.enabled&&typeof p.data.port=="number")return p.data.port;let d=Qe((await ae(l,["--json","stream","enable"])).stdout);return typeof d?.data?.port=="number"?d.data.port:null},setTakeover(s,l){let p=Ke(s);p.takenOver!==l&&(p.takenOver=l,g(p),F.info(`${s}: browser ${l?"taken over by the user":"handed back to the agent"}`),u())},isTakenOver(s){return n.get(s)?.takenOver??!1},async insertText(s,l){let p=En(s),d=await ae(p,["keyboard","inserttext",l]);if(d.code!==0)throw new Error(d.stderr.trim()||`agent-browser exited ${d.code}`)},noteBrowserCommand(s){let l=n.get(we(s));l&&(g(l),Je(l))},agentBrowserRuntime(){return m()},onBrowserSessionsChanged(s){return a.add(s),()=>{a.delete(s)}},shutdown(){for(let s of n.values())s.idleTimer&&clearTimeout(s.idleTimer);n.clear(),a.clear()}}}async function Lo(t){try{return(await fetch(`${t}/json/version`,{signal:AbortSignal.timeout(Ao)})).ok}catch{return!1}}function Fo(){return{async acquire(t){return t===k?(await Ae()).cdpEndpoint:(await Ne(t)).cdpEndpoint},release(t){t===k?Oe():rn(t)},async refresh(t,n){if(t===k){let o=Jt().browser?.cdpEndpoint;if(o)return o;let r=(await Ae()).cdpEndpoint;return Oe(),r}return await Lo(n)?n:(await Ne(t)).cdpEndpoint},availability(t){let n=pe().map(o=>o.device).sort();return It(t)?{state:"online",online:n}:{state:Object.hasOwn(ht(),t)?"offline":"unknown",online:n}},resolveBin:()=>ut(),baseEnv:()=>ft(),run:(t,n,o)=>gt(t,n,{env:o}),now:()=>Date.now(),idleMs:_o}}var Ue=null;function M(){return Ue??=Do(Fo()),Ue}var Vr=t=>M().leaseBrowser(t),Xr=()=>M().listBrowserSessions();var zr=t=>M().streamPort(t),Yr=(t,n)=>M().setTakeover(t,n),Kr=t=>M().isTakenOver(t),Zr=(t,n)=>M().insertText(t,n),Jr=t=>M().noteBrowserCommand(t),Qr=()=>M().agentBrowserRuntime();function ei(){Ue?.shutdown()}import*as S from"node:fs";import*as T from"node:path";var Mo=["mission.md","roadmap.md","STATUS.md"],No=["experiments","knowledge","patterns","decisions"];function Be(t){return Object.assign(new Error(t),{code:"not-found"})}function xe(t){return Object.assign(new Error(t),{code:"invalid-args"})}function cn(t,n){let o=t.projectStore.get(n);if(!o)throw Be(`project not found: ${n}`);try{return S.realpathSync(o.contextDir)}catch{throw Be(`project directory not found: ${n}`)}}function an(t,n){return n===t||n.startsWith(t+T.sep)}function Uo(t,n){if(T.isAbsolute(n))throw xe(`absolute path not allowed: ${n}`);let o=T.resolve(t,n);if(!an(t,o))throw xe(`path escapes project root: ${n}`);let r;try{r=S.realpathSync(o)}catch{throw Be(`file not found: ${n}`)}if(!an(t,r))throw xe(`path escapes project root: ${n}`);if(!S.statSync(r).isFile())throw xe(`not a file: ${n}`);return r}async function si(t,n){let o=cn(t,n.projectId),r=Mo.flatMap(a=>{let c=T.join(o,a),u;try{u=S.statSync(c)}catch{return[]}return u.isFile()?[{name:a,sizeBytes:u.size,modifiedAt:u.mtime.toISOString()}]:[]}),i=No.flatMap(a=>{let c=T.join(o,a),u;try{u=S.readdirSync(c,{withFileTypes:!0})}catch{return[]}let f=u.filter(m=>m.isFile()&&m.name.endsWith(".md")&&m.name!=="index.md"&&m.name!=="AGENTS.md").map(m=>{let b=S.statSync(T.join(c,m.name));return{name:m.name,sizeBytes:b.size,modifiedAt:b.mtime.toISOString()}}).sort((m,b)=>m.name.localeCompare(b.name));return[{name:a,entryCount:f.length,entries:f}]});return{projectId:n.projectId,files:r,dirs:i}}async function Bo(t,n){let o=await H("git",["diff","--numstat","HEAD","--",n],{cwd:t,timeoutMs:5e3,maxBuffer:1048576,env:{...process.env,GIT_TERMINAL_PROMPT:"0"}});if(!o.ok)return null;let i=o.stdout.split(`
|
|
59
|
+
`).find(m=>m.trim().length>0);if(!i)return{added:0,removed:0};let[a,c]=i.split(" "),u=Number(a),f=Number(c);return!Number.isFinite(u)||!Number.isFinite(f)?null:{added:u,removed:f}}var Wo=/\b(?:task|manager|gate)\s+([0-9a-f]{4})\b/i;function Go(t){let n=Wo.exec(t);return n?n[1].toLowerCase():null}function Ho(t){let n=[],o=new Map,r=null,i=0;for(let a of t.split(`
|
|
60
|
+
`)){if(a.startsWith(" ")){r&&n.push({line:i,commit:r.slice(0,8),taskRef:o.get(r)??null}),r=null;continue}let c=/^([0-9a-f]{40}) \d+ (\d+)(?: \d+)?$/.exec(a);if(c){r=c[1],i=Number(c[2]);continue}r&&a.startsWith("summary ")&&o.set(r,Go(a.slice(8)))}return n}async function qo(t,n){let o=await H("git",["blame","--line-porcelain","HEAD","--",n],{cwd:t,timeoutMs:5e3,maxBuffer:8388608,env:{...process.env,GIT_TERMINAL_PROMPT:"0"}});return o.ok?Ho(o.stdout):null}async function ri(t,n){let o=cn(t,n.projectId),r=Uo(o,n.path),i=S.statSync(r),a=S.readFileSync(r,"utf8"),[c,u]=yt()?await Promise.all([Bo(o,n.path),qo(o,n.path)]):[null,null];return{projectId:n.projectId,path:n.path,content:a,sizeBytes:i.size,modifiedAt:i.mtime.toISOString(),lineDiff:c,blame:u}}var ln={feishu:["FEISHU_APP_ID","FEISHU_APP_SECRET","FEISHU_DOMAIN","FEISHU_ENCRYPT_KEY","FEISHU_VERIFICATION_TOKEN"],slack:["SLACK_BOT_TOKEN","SLACK_SIGNING_SECRET","SLACK_APP_TOKEN"]},ci={feishu:["FEISHU_APP_ID","FEISHU_APP_SECRET"],slack:ln.slack},li=["FEISHU_APP_ID","FEISHU_DOMAIN"],B=e.string().min(1).max(4096).regex(/^[^\s'\\\u0000-\u001f\u007f]+$/,"Invalid credential characters"),Vo=e.object({FEISHU_APP_ID:B.nullable().optional(),FEISHU_APP_SECRET:B.nullable().optional(),FEISHU_DOMAIN:e.enum(["feishu","lark"]).nullable().optional(),FEISHU_ENCRYPT_KEY:B.nullable().optional(),FEISHU_VERIFICATION_TOKEN:B.nullable().optional(),SLACK_BOT_TOKEN:B.nullable().optional(),SLACK_SIGNING_SECRET:B.nullable().optional(),SLACK_APP_TOKEN:B.nullable().optional()}).strict(),un=e.object({platform:e.enum(["feishu","slack"]),enabled:e.boolean().optional(),fields:Vo}).strict().refine(t=>Object.keys(t.fields).every(n=>ln[t.platform].includes(n)),"Fields must belong to the selected platform");var We=["openai-codex","anthropic"];function pi(t){return We.includes(t)}var pn=e.object({sessionId:e.string().min(1),starred:e.boolean()}),dn=e.object({sessionId:e.string().min(1),label:e.string().trim().min(1).max(60)});var Xo=e.object({projectId:e.string().optional(),resumable:e.boolean().optional(),origin:e.enum(["direct","thread","scheduled"]).optional(),boardId:e.string().max(128).optional()}),zo=e.object({perProject:e.number().int().min(1).max(200).optional(),fullProjects:e.array(e.string().max(128)).max(200).optional(),include:e.array(e.string().max(128)).max(50).optional(),depth:e.record(e.string().max(128),e.number().int().min(1).max(1e4)).optional(),projectId:e.string().max(128).optional()}),Yo=e.object({sessionId:e.string().min(1).max(128)}),Ko=e.object({query:e.string().trim().min(1).max(200),origin:e.enum(["direct","thread","scheduled"]).optional(),limit:e.number().int().min(1).max(200).optional()}),Zo=e.object({sessionId:e.string(),compactSubagents:e.boolean().optional(),since:e.string().max(64).optional(),tailRows:e.number().int().positive().optional(),beforeRow:e.number().int().nonnegative().optional(),pageRows:e.number().int().positive().optional()}),Jo=e.object({sessionId:e.string(),subagentId:e.string().min(1).max(512)}),Qo=e.object({sessionId:e.string(),ref:e.string().min(1).max(512)}),es=e.object({sessionId:e.string().min(1)}),ts=e.object({sessionId:e.string().min(1)}),ns=e.object({projectId:e.string().optional(),paused:e.boolean().optional()}),os=e.object({projectId:e.string().optional()}),ss=e.object({boardId:e.string()}),rs=e.object({boardId:e.string()}),is=e.object({}),as=e.object({sessionId:e.string().min(1)}),cs=e.object({sessionId:e.string().min(1)}),ls=e.object({status:e.array(e.string()).optional(),limit:e.number().optional()}),us=e.object({executionId:e.string()}),ps=e.object({projectId:e.string()}),ds=e.object({projectId:e.string(),path:e.string()}),ms=e.object({status:e.enum(["pending","approved","rejected","failed"]).optional()}),fs=e.object({projectId:e.string()}),gs=e.object({projectId:e.string()});var ki=e.object({}),Ti=e.object({projectId:e.string().nullish()}),hs=e.enum(["24h","7d","30d","90d"]),bs=e.object({range:hs,page:e.number().int().min(0).max(400).optional(),projectId:e.string().nullish()}),Ri=bs.extend({kind:e.enum(["tool","skill","mcp"]).optional()}),ji=e.object({provider:e.string().nullish(),route:e.string().nullish()}),Ci=e.object({}),_i=e.object({}),Pi=e.object({flowId:e.string().min(1)}),Ai=e.object({}),Oi=e.object({enabled:e.boolean(),name:e.string().trim().optional(),org:e.string().trim().optional(),email:e.string().trim().optional()}),Di=e.object({}),Li=st,Ge=e.number().nonnegative().max(6e5),Fi=e.object({sessionId:e.string().min(1).max(128),totalMs:Ge,transcriptMs:Ge.optional(),cached:e.boolean(),rows:e.number().int().nonnegative().max(1e6),longTaskMs:Ge.optional()}),Mi=e.object({}),Ni=e.object({}),Is=50,qe=e.string().min(1).optional(),Ui=e.object({device:qe,path:e.string().min(1),showHidden:e.boolean().optional()}),Bi=e.object({}),Wi=e.object({device:qe,path:e.string().min(1),kind:e.enum(["dir","file"])}),ws=e.object({device:qe,path:e.string().min(1),write:e.boolean()}),bn=e.array(ws).max(Is),Gi=e.object({machine:e.string().min(1)}),Hi=e.object({}),qi=e.object({sessionId:e.string().min(1).optional(),agentName:e.string().min(1).nullable().optional()}),Vi=e.object({}),Xi=e.object({}),zi=e.object({}),Yi=e.object({}),Ki=e.object({}),Zi=e.object({}),Ji=e.object({limit:e.number().int().positive().max(50).optional()}),Qi=e.object({}),ea=e.object({}),ta=e.object({}),Ve=e.string().min(1).regex(ce).nullable().optional(),na=e.object({backend:e.enum(["claude","pi"]),provider:e.string().min(1),connection:Ve,authType:e.enum(["api_key","oauth"]),noticeId:e.string().min(1).optional()}),oa=e.object({backend:e.enum(["claude","pi"]),label:e.string().trim().min(1).max(64),provider:e.string().min(1).optional(),authType:e.enum(["api_key","oauth"]).optional()}),sa=e.object({backend:e.enum(["claude","pi"]),id:e.string().min(1).regex(ce)}),ra=e.object({flowId:e.string().min(1),value:e.string(),promptId:e.number().int().nonnegative().optional()}),ia=e.object({flowId:e.string().min(1)}),aa=e.object({backend:e.enum(["claude","pi"]).optional()}),ca=e.object({backend:e.enum(["claude","pi"]),provider:e.string().min(1),connection:Ve,authType:e.enum(["api_key","oauth"])}),ye=e.string().min(1).regex(ce),mn=e.array(e.string().min(1)),la=e.object({}),ua=e.discriminatedUnion("kind",[e.object({kind:e.literal("claude"),id:ye,label:e.string().optional(),baseUrl:e.string().optional(),authStyle:e.enum(["x-api-key","bearer"]).optional(),billing:e.enum(["metered","subscription"]).optional(),models:mn.optional(),key:e.string().optional(),create:e.boolean().optional()}),e.object({kind:e.literal("pi-override"),provider:ye,baseUrl:e.string(),key:e.string().optional(),create:e.boolean().optional()}),e.object({kind:e.literal("pi-custom"),provider:ye,api:e.enum(rt),baseUrl:e.string(),models:mn.min(1),key:e.string().optional(),create:e.boolean().optional()})]),pa=e.object({backend:e.enum(["claude","pi"]),id:ye}),da=e.object({name:e.string()}),ma=e.object({projectId:e.string().min(1)}),fa=e.object({sessionId:e.string().min(1)}),ga=e.object({projectId:e.string().optional()}),ha=e.object({sessionId:e.string(),text:e.string(),attachments:e.array(e.object({name:e.string(),path:e.string(),size:e.number(),mimeType:e.string(),type:e.enum(["image","video","file","view"])})).optional()}),ba=e.object({sessionId:e.string()}),Ia=e.object({sessionId:e.string(),pendingId:e.string(),action:e.enum(["send","edit"])}),wa=e.object({sessionId:e.string()}),xa=e.object({sessionId:e.string()}),ya=e.object({sessionIds:e.array(e.string()).min(1).max(500)}),Sa=e.object({sessionId:e.string(),agentName:e.string().min(1).nullable().optional()}),In=e.object({backend:e.enum(["claude","pi"]),provider:e.string().min(1).nullable(),model:e.string().min(1),thinking:e.string().min(1).nullable(),connection:e.string().min(1).nullable()}).strict(),re=In,va=e.object({sessionId:e.string(),selection:re}).strict(),Ea=e.object({requestId:e.string().min(1),answers:e.record(e.string(),e.string()),sessionId:e.string().min(1).optional()}),$a=e.object({requestId:e.string().min(1),approved:e.boolean(),feedback:e.string().optional()}),ka=e.object({sessionId:e.string().min(1),decisionId:e.string().min(1),action:e.enum(["approve","explain","revise"]),message:e.string().optional()}),Ta=e.object({sessionId:e.string().regex(/^[\w-]+$/),ts:e.string().min(1),src:e.string().min(1)}),Ra=e.object({sessionId:e.string().min(1),allowedPaths:bn}),ja=e.object({sessionId:e.string()}),Ca=e.object({sessionId:e.string(),turnIndex:e.number().int().min(0),text:e.string().min(1)}),_a=e.object({projectId:e.string(),agentName:e.string().min(1).optional(),selection:re.optional(),clean:e.boolean().optional(),allowedPaths:bn.optional(),text:e.string(),draftUploadId:e.string().uuid().optional(),attachments:e.array(e.object({name:e.string(),path:e.string(),size:e.number(),mimeType:e.string(),type:e.enum(["image","video","file"])})).optional()}),Pa=e.object({waitpointId:e.string().min(1)}),Aa=e.object({monitorId:e.string().min(1)}),Oa=e.object({executionId:e.string()}),Da=e.object({scheduleId:e.string()}),La=e.object({type:e.enum(["interval","daily","weekly","once"]),message:e.string().min(1),projectId:e.string().optional(),selection:re.optional(),intervalMs:e.number().int().positive().optional(),time:e.string().regex(/^\d{2}:\d{2}$/).optional(),dayOfWeek:e.number().int().min(0).max(6).optional(),delay:e.number().int().positive().optional()}).superRefine((t,n)=>{t.type==="interval"&&t.intervalMs===void 0&&n.addIssue({code:e.ZodIssueCode.custom,path:["intervalMs"],message:_("ui.schedule.intervalRequired")}),(t.type==="daily"||t.type==="weekly")&&t.time===void 0&&n.addIssue({code:e.ZodIssueCode.custom,path:["time"],message:_("ui.schedule.timeRequired",{type:t.type})}),t.type==="weekly"&&t.dayOfWeek===void 0&&n.addIssue({code:e.ZodIssueCode.custom,path:["dayOfWeek"],message:_("ui.schedule.dayOfWeekRequired")}),t.type==="once"&&t.delay===void 0&&n.addIssue({code:e.ZodIssueCode.custom,path:["delay"],message:_("ui.schedule.delayRequired")})}),Fa=e.object({scheduleId:e.string(),message:e.string().min(1).optional(),projectId:e.string().optional(),selection:re.optional(),intervalMs:e.number().int().positive().optional(),time:e.string().regex(/^\d{2}:\d{2}$/).optional(),dayOfWeek:e.number().int().min(0).max(6).optional()}),fn=new Set(["__proto__","prototype","constructor"]),He=120,xs={boolean:e.boolean(),number:e.number().finite(),"number|null":e.number().finite().nullable(),"string[]":e.array(e.string()),"string|null":e.string().nullable()};function ys(t){let n=xs[t.type];return!("validate"in t)||typeof t.validate!="function"?n:n.superRefine((o,r)=>{let i=t.validate(o);i&&r.addIssue({code:e.ZodIssueCode.custom,message:i})})}var Ss=Object.fromEntries(Object.entries(ot).filter(([t])=>t!=="providerRateLimits").map(([t,n])=>[t,ys(n)]));function vs(t,n){for(let[o,r]of Object.entries(t))r===void 0&&n.addIssue({code:e.ZodIssueCode.custom,path:[o],message:"setting must not be undefined"})}var Es=e.object(Ss).partial().strict().superRefine(vs),Ma=e.discriminatedUnion("section",[e.object({section:e.literal("budget"),project:e.string().min(1).nullish(),value:e.object({daily_usd:e.number().finite().positive(),monthly_usd:e.number().finite().positive()}).nullish()}).superRefine((t,n)=>{t.value==null&&!t.project&&n.addIssue({code:e.ZodIssueCode.custom,path:["value"],message:"a budget write without a value clears a per-project override and requires `project`"})}),e.object({section:e.literal("settings"),value:Es}),e.object({section:e.literal("preferences"),value:e.object({lang:e.enum(["en","zh"])})})]),Na=e.object({provider:e.string().trim().min(1).max(He).refine(t=>!fn.has(t),"provider key is reserved"),windowType:e.string().trim().min(1).nullish(),windowLabel:e.string().trim().min(1).nullish(),account:e.string().trim().min(1).max(He).refine(t=>!fn.has(t),"account key is reserved").nullish(),enabled:e.boolean(),threshold:e.union([e.number().finite().gt(0).lte(1),e.null()]).optional(),stopThreshold:e.union([e.number().finite().gt(0).lte(1),e.null()]).optional()}).superRefine((t,n)=>{t.stopThreshold!==void 0&&!nt.has(t.windowType??"")&&n.addIssue({code:e.ZodIssueCode.custom,path:["stopThreshold"],message:"stopThreshold applies only to five_hour and codex_primary windows"}),t.windowLabel&&!t.windowType&&n.addIssue({code:e.ZodIssueCode.custom,path:["windowType"],message:"windowType is required when windowLabel is set"}),t.account&&!t.windowType&&n.addIssue({code:e.ZodIssueCode.custom,path:["windowType"],message:"windowType is required when account is set"})}),Ua=e.object({}),$s=e.union([e.string(),e.number(),e.boolean(),e.null()]),wn={event:e.string().min(1),matcher:e.string().optional(),matcherFilters:e.record(e.string(),$s).optional(),script:e.string().min(1).optional(),command:e.string().min(1).optional(),timeoutSec:e.number().finite().positive().optional(),backends:e.array(e.enum(["claude","pi"])).optional(),requiresTool:e.string().min(1).optional(),result:e.enum(["stdout-as-prompt","none"]).optional(),enabled:e.boolean().optional()};function xn(t,n){let o=t.script!==void 0,r=t.command!==void 0;o===r&&n.addIssue({code:e.ZodIssueCode.custom,path:["script"],message:_("ui.hook.exactlyOneRun")})}var Ba=e.object({id:e.string().min(1),...wn}).superRefine(xn),Wa=e.object({id:e.string().min(1),...wn}).superRefine(xn),Ga=e.object({id:e.string().min(1),enabled:e.boolean()}),Ha=e.object({id:e.string().min(1)}),qa=e.object({id:e.string().min(1),payload:e.string()}),ks=In.pick({backend:!0,provider:!0,model:!0}),Va=e.object({backend:e.enum(["claude","pi"]),provider:e.string().min(1).nullable().optional(),model:e.string().min(1)}).strict(),Xa=e.object({ref:ks,thinking:e.string().nullable()}).strict(),za=e.object({selection:re}).strict(),gn=e.array(e.string().trim().min(1).max(200)).max(200),Ya=e.object({allow:e.union([e.literal("all"),e.literal("favorites"),gn]),deny:gn}).strict(),Ts=t=>new TextEncoder().encode(t).byteLength<=255,Rs=t=>t!=="."&&t!==".."&&!t.includes("/")&&!t.includes("\\")&&!t.includes("\0"),js=e.string().max(240).regex(/^[A-Za-z0-9][A-Za-z0-9_-]*$/),Cs=e.string().min(1).refine(Ts).refine(Rs),Xe=e.string().regex(/^[a-f0-9]{64}$/),_s=e.object({kind:e.literal("agent"),name:js,baseHash:Xe}),Ka=e.object({target:_s,pluginIds:e.array(Cs),acknowledgeMcp:e.boolean().optional()}),j=e.string().min(1).max(64).regex(/^(?!.*--)[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/),Y={pluginId:j,skill:j},Za=e.object(Y),Ja=e.object({...Y,content:e.string().max(512*1024),baseHash:Xe}),Qa=e.object({...Y,description:e.string().min(1).max(1024)}),ec=e.object({...Y,toPluginId:j,toSkill:j}),tc=e.object(Y),nc=e.object(Y),oc=e.object({id:j,description:e.string().max(1024).optional()}),sc=e.object({id:j}),rc=e.object({id:j}),ic=e.object({pluginId:j}),hn=e.record(e.string().min(1).max(200),e.string().max(4096).nullable()),ac=e.object({pluginId:j,servers:e.array(e.object({name:e.string().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9_-]*$/),type:e.enum(["stdio","streamable-http","sse"]),command:e.string().max(1024).optional(),args:e.array(e.string().max(1024)).max(64).optional(),cwd:e.string().max(1024).optional(),url:e.string().max(2048).optional(),env:hn.optional(),headers:hn.optional()})).max(32),baseHash:Xe}),ie=e.string().regex(/^[A-Za-z0-9][A-Za-z0-9_-]*$/),cc=e.object({name:ie}),lc=e.object({name:ie,body:e.record(e.string(),e.unknown())}),uc=e.object({name:ie,body:e.record(e.string(),e.unknown()),baseHash:e.string().optional()}),pc=e.object({name:ie}),dc=e.object({name:ie,text:e.string().max(65536)}),mc=e.object({id:e.string()}),fc=e.object({projectId:e.string(),id:e.string()}),Ps=e.string().trim().min(1).max(1e3).refine(t=>!/[\r\n]/.test(t),{error:()=>_("ui.note.oneLine")}),As=e.object({projectId:e.string(),text:Ps}),gc=As.extend({id:e.string()}),hc=e.object({projectId:e.string(),id:e.string(),completed:e.boolean()}),bc=e.object({projectId:e.string(),id:e.string()}),Ic=e.object({projectId:e.string()}),wc=e.object({id:e.string(),feedback:e.string().optional()}),xc=e.object({kind:e.enum(["soft","hard","force"])}),yc=e.object({provider:e.string().optional()}),Sc=e.object({}),Se=e.string().trim().min(1).max(He),vc=e.object({provider:Se,route:Se.nullable(),until:e.number().int().positive().nullish()}),Ec=e.object({provider:Se,route:Se}),$c=e.object({sessionId:e.string().trim().min(1)}),kc=e.object({provider:e.enum(We),connection:Ve,creditId:e.string().min(1).optional()}),Tc=e.object({}),Rc=e.object({}),jc=e.object({}),Cc=e.object({}),_c=e.object({}),Pc=e.object({kind:e.enum(["reconnect-platform","add-machine"]),platform:e.enum(["slack","feishu"]).optional(),machineName:e.string().min(1).optional()}).superRefine((t,n)=>{t.kind==="reconnect-platform"&&t.platform===void 0&&n.addIssue({code:e.ZodIssueCode.custom,path:["platform"],message:"platform is required for kind=reconnect-platform"}),t.kind==="add-machine"&&(t.machineName===void 0||t.machineName.trim()==="")&&n.addIssue({code:e.ZodIssueCode.custom,path:["machineName"],message:_("ui.approval.machineNameRequired")})});export{ln as a,ci as b,li as c,un as d,We as e,pi as f,pn as g,dn as h,Xo as i,zo as j,Yo as k,Ko as l,Zo as m,Jo as n,Qo as o,es as p,ts as q,ns as r,os as s,ss as t,rs as u,is as v,as as w,cs as x,ls as y,us as z,ps as A,ds as B,ms as C,fs as D,gs as E,ki as F,Ti as G,bs as H,Ri as I,ji as J,Ci as K,_i as L,Pi as M,Ai as N,Oi as O,Di as P,Li as Q,Fi as R,Mi as S,Ni as T,Ui as U,Bi as V,Wi as W,Gi as X,Hi as Y,qi as Z,Vi as _,Xi as $,zi as aa,Yi as ba,Ki as ca,Zi as da,Ji as ea,Qi as fa,ea as ga,ta as ha,na as ia,oa as ja,sa as ka,ra as la,ia as ma,aa as na,ca as oa,la as pa,ua as qa,pa as ra,da as sa,ma as ta,fa as ua,ga as va,ha as wa,ba as xa,Ia as ya,wa as za,xa as Aa,ya as Ba,Sa as Ca,re as Da,va as Ea,Ea as Fa,$a as Ga,ka as Ha,Ta as Ia,Ra as Ja,ja as Ka,Ca as La,_a as Ma,Pa as Na,Aa as Oa,Oa as Pa,Da as Qa,La as Ra,Fa as Sa,Ma as Ta,Na as Ua,Ua as Va,Ba as Wa,Wa as Xa,Ga as Ya,Ha as Za,qa as _a,ks as $a,Va as ab,Xa as bb,za as cb,Ya as db,Ka as eb,Za as fb,Ja as gb,Qa as hb,ec as ib,tc as jb,nc as kb,oc as lb,sc as mb,rc as nb,ic as ob,ac as pb,cc as qb,lc as rb,uc as sb,pc as tb,dc as ub,mc as vb,fc as wb,As as xb,gc as yb,hc as zb,bc as Ab,Ic as Bb,wc as Cb,xc as Db,yc as Eb,Sc as Fb,vc as Gb,Ec as Hb,$c as Ib,kc as Jb,Tc as Kb,Rc as Lb,jc as Mb,Cc as Nb,_c as Ob,Pc as Pb,$t as Qb,Hs as Rb,kt as Sb,qs as Tb,H as Ub,er as Vb,Ns as Wb,Us as Xb,Nn as Yb,gr as Zb,_r as _b,Ut as $b,V as ac,xr as bc,yr as cc,Mr as dc,y as ec,Vr as fc,Xr as gc,zr as hc,Yr as ic,Kr as jc,Zr as kc,Jr as lc,Qr as mc,ei as nc,cn as oc,Uo as pc,si as qc,Go as rc,ri as sc};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire as __cortexCreateRequire } from 'node:module';
|
|
2
|
+
const require = __cortexCreateRequire(import.meta.url);
|
|
3
|
+
const __cortexPackageRoot = new URL("../../", import.meta.url);
|
|
4
|
+
var s=new Set;function t(e){return s.add(e),()=>{s.delete(e)}}function c(e){let r=[];for(let o of s)try{o(e)}catch(n){r.push(n)}if(r.length>0)throw new AggregateError(r,"Failed to cleanup session resources")}export{t as a,c as b};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire as __cortexCreateRequire } from 'node:module';
|
|
2
|
+
const require = __cortexCreateRequire(import.meta.url);
|
|
3
|
+
const __cortexPackageRoot = new URL("../../", import.meta.url);
|
|
4
|
+
import{e as a}from"./chunk-B3NB243Z.js";import{d as p}from"./chunk-LIIZI3HY.js";import{e as n,o as s}from"./chunk-T54CZKNJ.js";import*as o from"path";var c=o.join(n,"data","pi"),j=o.join(n,"logs","sessions-pi");function l(r=c){return o.resolve(r)===o.resolve(c)?a():o.join(r,"auth.json")}function I(r){return o.join(r,"models.json")}function x(r,t=s){if(!p.test(r))throw new Error(`Invalid account id: ${r}`);return o.join(t,r)}import{existsSync as u,readFileSync as f}from"fs";function h(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;let t=r;return typeof t.api=="string"&&Array.isArray(t.models)}function A(r){if(!u(r))return{};try{let t=JSON.parse(f(r,"utf8"));if(!t||typeof t!="object"||Array.isArray(t))return{};let e=t.providers;return!e||typeof e!="object"||Array.isArray(e)?{}:e}catch{return{}}}function E(r){let t={};for(let[e,i]of Object.entries(A(r)))h(i)&&(t[e]=i);return t}export{h as a,A as b,E as c,c as d,j as e,l as f,I as g,x as h};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire as __cortexCreateRequire } from 'node:module';
|
|
2
|
+
const require = __cortexCreateRequire(import.meta.url);
|
|
3
|
+
const __cortexPackageRoot = new URL("../../", import.meta.url);
|
|
4
|
+
import{a as _}from"./chunk-PTS3J4DQ.js";import{c as P}from"./chunk-OJ37ZWBG.js";import{a as w}from"./chunk-OKRK6JPY.js";import{a as g}from"./chunk-B3NB243Z.js";import{a as i,b as l,c as S,v as T,w as b,x as v,z as E}from"./chunk-KST6OY76.js";import{e as m,h as f,j as h}from"./chunk-LIIZI3HY.js";import{mkdtempSync as x,rmSync as R,writeFileSync as A}from"node:fs";import C from"node:os";import u from"node:path";var O=new Set(["Bash","Read","Write","Edit","MultiEdit","Grep","Glob","LS","WebFetch","WebSearch","AskUserQuestion","EnterPlanMode","ExitPlanMode","TodoWrite","Skill","Agent","Task","TaskOutput","TaskStop","NotebookEdit","NotebookRead","BashOutput","KillShell","KillBash","SlashCommand","ToolSearch","ListMcpResourcesTool","ReadMcpResourceTool","bash","read","write","edit","grep","glob","find","ls","powershell","web_fetch","web_search","todo_write","skill","agent","agent_stop"]),I=/[^A-Za-z0-9._:/@[\]-]/g;function a(e){return e.replace(I,"_").slice(0,80)||i}function V(e){return O.has(e)?e:e.startsWith("mcp__cortex-")?a(e):e.startsWith("mcp__")?S:i}function L(e,r,t){return e==="claude"?{provider:"anthropic",customApi:null}:t.customProviders.has(r)?{provider:l,customApi:a(t.customProviders.get(r))}:{provider:t.piProviders.has(r)?r:i,customApi:null}}function X(e,r,t,n){return e==="claude"?w.includes(t)||n.modelIds.has(t.replace(/\[1m\]$/,""))?a(t):i:n.customProviders.has(r)?l:n.piModels.has(`${r}/${t}`)?a(t):i}function k(e,r){return[...new Set(e.map(t=>L("pi",t,r).provider))]}function N(e){let r=P(e),t=new Map(Object.entries(r).map(([n,o])=>[n,String(o.api)]));for(let n of f(h()))m(n)&&t.set(n.provider,n.api);return t}async function j(){let e=x(u.join(C.tmpdir(),"cortex-telemetry-catalog-"));try{let r=u.join(e,"auth.json");return A(r,""),(await(await g()).ModelRuntime.create({authPath:r,modelsPath:u.join(e,"absent","models.json"),allowModelNetwork:!1})).getAllModels().map(o=>({provider:String(o.provider),id:String(o.id)}))}finally{R(e,{recursive:!0,force:!0})}}function H(e,r){return{piProviders:new Set(e.map(t=>t.provider)),piModels:new Set(e.map(t=>`${t.provider}/${t.id}`)),modelIds:new Set(e.map(t=>t.id)),customProviders:r}}var d=null;function ee(e,r=_){if(d?.day===e)return d.catalog;let t=j().catch(()=>[]).then(n=>H(n,N(r)));return d={day:e,catalog:t},t}var W=["teamEnabled","serverAutoUpdate","serverUpdateDisable","autoResume","bgContinuation","streamDeltas","clientHotReloadEnabled","storeArchiveEnabled","providerUsageCollectionEnabled","claudeWindowWarmupEnabled","feishuSkillsInWeb","memoryIndexRegenEnabled"];function c(e){return e.state==="logged-in"||e.state==="expiring"}function D(e){let r=e.find(t=>t.backend==="claude"&&c(t));return r?r.authType==="api_key"?"api":"plan":"none"}function B(e){let r={};for(let{platform:t}of e){let n=["linux","darwin","win32"].includes(t)?t:"other";r[n]=(r[n]??0)+1}return r}function U(e){return Object.fromEntries(W.filter(r=>typeof e[r]=="boolean").map(r=>[a(r),e[r]]))}async function ne(e,r=new Date){let n=(await e.authStatus().catch(()=>null))?.accounts.filter(c)??[],o=e.onlineDevices(),y=n.filter(s=>s.backend==="pi").map(s=>s.provider);return{type:"heartbeat",at:r.toISOString(),backends:[...new Set(n.map(s=>s.backend))],claudeBilling:D(n),piProviders:k(y,await e.catalog()).slice(0,60),projects:e.projects(),onlineClients:o.length,clientPlatforms:B(o),activeSessions24h:await e.activeSessions24h().catch(()=>0),uptimeH:Math.round(e.uptimeS()/3600*100)/100,settings:U(e.settings())}}var p=new Set;function M(e){return p.has(e)?!0:b().funnelSent.includes(e)?(p.add(e),!0):!1}function z(e,r=null){M(e)||!E({type:"funnel",at:new Date().toISOString(),source:"server",step:e,detail:r})||(p.add(e),v(n=>({...n,funnelSent:[...new Set([...n.funnelSent,e])]})))}async function le(e){if(!T()||M("provider_authed"))return;let t=(await e().catch(()=>null))?.accounts.find(c);t&&z("provider_authed",t.backend)}export{a,V as b,L as c,X as d,ee as e,ne as f,z as g,le as h};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as __cortexCreateRequire } from 'node:module';
|
|
2
2
|
const require = __cortexCreateRequire(import.meta.url);
|
|
3
3
|
const __cortexPackageRoot = new URL("../../", import.meta.url);
|
|
4
|
-
import{
|
|
4
|
+
import{d as y}from"./chunk-RW2F2QNP.js";import{a as E}from"./chunk-5M4PFLRW.js";import{c as b,j as w}from"./chunk-T54CZKNJ.js";import*as f from"node:fs";import*as i from"node:path";var S=i.join(b,"config","hooks");function p(){return{user:i.join(w,"hooks"),builtin:E()?S:null}}var x=new Set(["agent:pre-tool","agent:post-tool","agent:session-start","agent:session-end","agent:pre-compact","agent:user-prompt","agent:turn-end"]),R=/^\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?$/,T=new Set(["stdout-as-prompt","none"]),g="hook-result",$=new Map([["cortex:session.new","stdout-as-prompt"],["cortex:session.messageEnd","stdout-as-prompt"]]),d=class extends Error{};function u(e,t){if(typeof e!="object"||e===null||Array.isArray(e))throw new Error(`${t} must be an object`);return e}function a(e,t){if(typeof e!="string"||e.trim()==="")throw new Error(`${t} must be a non-empty string`);return e}function O(e){let t=a(e,"event");if(x.has(t)||t.match(/^(?:cc|pi|cortex):(.*)$/s)?.[1].trim())return t;throw new Error(`unsupported hook event "${t}"`)}function M(e){return e===null||["string","number","boolean"].includes(typeof e)}function _(e,t){if(typeof e!="string")throw new Error(`${t}: matcher must be a string`);try{new RegExp(e)}catch{throw new Error(`${t}: matcher must be a valid regular expression`)}}function j(e,t){let n;try{n=u(e,"matcher")}catch{throw new Error(`${t}: matcher must be an object`)}if(!Object.values(n).every(M))throw new Error(`${t}: matcher values must be primitive`)}function A(e,t,n){e!==void 0&&(t.startsWith("cortex:")?j(e,n):_(e,n))}function I(e){let t=a(e,"run.script"),n=t.split(/[\\/]/).includes("..");if(i.isAbsolute(t)||i.win32.isAbsolute(t)||n)throw new Error("run.script must stay relative to the hooks directory")}function H(e){if(e!==void 0&&(typeof e!="number"||!Number.isFinite(e)||e<=0))throw new Error("run.timeout must be a positive number")}function N(e){let t=u(e,"run"),n=t.script!==void 0,r=t.command!==void 0;if(n===r)throw new Error("run must contain exactly one of script or command");n&&I(t.script),r&&a(t.command,"run.command"),H(t.timeout)}function B(e){if(!Array.isArray(e))throw new Error("scope.backends must be an array");if(!e.every(t=>t==="claude"||t==="pi"))throw new Error("scope.backends contains an unsupported backend")}function D(e){if(e===void 0)return;let t=u(e,"scope");t.backends!==void 0&&B(t.backends),t.requiresTool!==void 0&&a(t.requiresTool,"scope.requiresTool")}function F(e){if(e===void 0)return;let t=u(e,"blocking");if(t.mode!=="webhook")throw new Error("blocking.mode must be webhook");if(typeof t.ttlMin!="number"||!Number.isFinite(t.ttlMin)||t.ttlMin<=0)throw new Error("blocking.ttlMin must be a positive number")}function L(e,t){if(e!==void 0){if(e===g)throw new d(`result mode "${g}" is retired; remove the hook or its result field`);if(typeof e!="string"||!T.has(e))throw new Error("result must be stdout-as-prompt or none");if(e!=="none"&&$.get(t)!==e)throw new Error(`result mode "${e}" is not permitted for event "${t}"`)}}function P(e,t){if(D(e.scope),F(e.blocking),L(e.result,t),e.enabled!==void 0&&typeof e.enabled!="boolean")throw new Error("enabled must be a boolean");if(e.version!==void 0&&!R.test(a(e.version,"version")))throw new Error("version must be a CalVer string")}function l(e){let t=u(e,"hook entry"),n=a(t.id,"id"),r=O(t.event);return A(t.matcher,r,n),N(t.run),P(t,r),t}function m(e,t){let n=t instanceof Error?t.message:String(t);(t instanceof d?console.warn:console.error)(`[hook-registry] skipped ${e}: ${n}`)}function k(e){if(!e)return new Set;try{return new Set(f.readdirSync(e).filter(t=>t.endsWith(".json")))}catch(t){return t.code!=="ENOENT"&&m(e,t),new Set}}function h(e){return u(JSON.parse(f.readFileSync(e,"utf8")),"hook entry")}function C(e,t){if(!t)return null;try{return h(e)}catch(n){return m(i.basename(e),n),null}}function U(e,t,n){let r=i.join(t.builtin,e),o=l(h(r)),c=i.join(t.user,e),s=C(c,n);return{entry:s?l({...o,...s,id:o.id}):o,filePath:s?c:r,source:"builtin",builtin:{entry:o,overridePath:c,override:s}}}function q(e,t){let n=i.join(t.user,e);return{entry:l(h(n)),filePath:n,source:"user"}}function v(e=p()){let t=k(e.builtin),n=k(e.user),r=[],o=new Set;for(let c of[...new Set([...t,...n])].sort())try{let s=t.has(c)?U(c,e,n.has(c)):q(c,e);if(o.has(s.entry.id))throw new Error(`duplicate hook id "${s.entry.id}"`);o.add(s.entry.id),r.push(s)}catch(s){m(c,s)}return r}function re(e=p()){return v(e).map(t=>t.entry)}function V(e){return{kind:"registry",id:e.entry.id,event:e.entry.event,enabled:e.entry.enabled!==!1,source:e.source,overridden:e.builtin?.override!=null,entry:e.entry,filePath:e.filePath}}function W(e=p()){return v(e).map(V)}function G(e){return{id:e.id,event:e.event,enabled:e.enabled,source:e.source,overridden:e.overridden}}function oe(e=p()){return W(e).map(G)}function Y(e){return`'${e.replace(/'/g,"'\\''")}'`}function ie(e,t,n,r=1/0){let o=e.entry.run;return{command:o.script===void 0?o.command:`node ${y(o.script,t).map(Y).join(" ")}`,timeoutMs:Math.min((o.timeout??30)*1e3,r),stdinPayload:n,label:e.id}}function K(e){return e.startsWith("agent:")?["claude","pi"]:e.startsWith("cc:")?["claude"]:e.startsWith("pi:")?["pi"]:[]}function z(e){let t=K(e.event),n=e.scope?.backends;return n?t.filter(r=>n.includes(r)):t}function J(e,t){return t.event===void 0||e.event===t.event}function Q(e,t){return t.backend===void 0||z(e).includes(t.backend)}function X(e,t){let n=e.scope?.requiresTool;return n===void 0||t.availableTools===void 0||t.availableTools.has(n)}function se(e,t={}){return e.filter(n=>n.enabled!==!1).filter(n=>J(n,t)).filter(n=>Q(n,t)).filter(n=>X(n,t))}export{p as a,$ as b,l as c,v as d,re as e,W as f,G as g,oe as h,ie as i,z as j,se as k};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire as __cortexCreateRequire } from 'node:module';
|
|
2
|
+
const require = __cortexCreateRequire(import.meta.url);
|
|
3
|
+
const __cortexPackageRoot = new URL("../../", import.meta.url);
|
|
4
|
+
var o={"anthropic-messages":{"chat:claude-fable-5":{id:"claude-fable-5",name:"Claude Fable 5",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:10,output:50,cacheRead:1,cacheWrite:12.5},contextWindow:1e6,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictTools:!0,forceAdaptiveThinking:!0,supportsMidConvoSystemMessages:!0},thinkingLevelMap:{off:null,xhigh:"xhigh",max:"max"},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:claude-fable-5.1":{id:"claude-fable-5.1",name:"Claude Fable 5.1",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:10,output:50,cacheRead:.25,cacheWrite:12.5},contextWindow:1e6,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictTools:!0,forceAdaptiveThinking:!0,supportsMidConvoSystemMessages:!0},thinkingLevelMap:{off:null,xhigh:"xhigh",max:"max"},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:claude-fable-5.2":{id:"claude-fable-5.2",name:"Claude Fable 5.2",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:8,output:40,cacheRead:.2,cacheWrite:10},contextWindow:1e6,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictTools:!0,forceAdaptiveThinking:!0,supportsMidConvoSystemMessages:!0},thinkingLevelMap:{off:null,xhigh:"xhigh",max:"max"},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:claude-haiku-4.5":{id:"claude-haiku-4.5",name:"Claude Haiku 4.5 (latest)",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},contextWindow:2e5,maxTokens:64e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictTools:!0,supportsEagerToolInputStreaming:!1},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:claude-haiku-5.5":{id:"claude-haiku-5.5",name:"Claude Haiku 5.5",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:.1,output:.5,cacheRead:.01,cacheWrite:.125,tiers:[{inputTokensAbove:1e5,input:.5,output:2.5,cacheRead:.05,cacheWrite:.625}]},contextWindow:1e6,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictTools:!0,forceAdaptiveThinking:!0,supportsTemperature:!1,supportsMidConvoSystemMessages:!0},thinkingLevelMap:{xhigh:"xhigh",max:"max"},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:claude-opus-4.8":{id:"claude-opus-4.8",name:"Claude Opus 4.8",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:64e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictTools:!0,forceAdaptiveThinking:!0,supportsTemperature:!1,supportsMidConvoSystemMessages:!0},thinkingLevelMap:{xhigh:"xhigh",max:"max",minimal:"low"},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:claude-opus-5":{id:"claude-opus-5",name:"Claude Opus 5",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},contextWindow:1e6,maxTokens:64e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictTools:!0,forceAdaptiveThinking:!0,supportsTemperature:!1,supportsMidConvoSystemMessages:!0},thinkingLevelMap:{xhigh:"xhigh",max:"max",minimal:"low"},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:claude-opus-5.5":{id:"claude-opus-5.5",name:"Claude Opus 5.5",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:4,output:20,cacheRead:.2,cacheWrite:5},contextWindow:1e6,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},compat:{supportsStrictTools:!0,forceAdaptiveThinking:!0,supportsTemperature:!1,supportsMidConvoSystemMessages:!0},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:claude-sonnet-4.6":{id:"claude-sonnet-4.6",name:"Claude Sonnet 4.6",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},contextWindow:1e6,maxTokens:32e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictTools:!0,forceAdaptiveThinking:!0},thinkingLevelMap:{max:"max",minimal:"low"},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:claude-sonnet-5":{id:"claude-sonnet-5",name:"Claude Sonnet 5",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:2,output:10,cacheRead:.2,cacheWrite:2.5},contextWindow:1e6,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictTools:!0,forceAdaptiveThinking:!0,supportsTemperature:!1},thinkingLevelMap:{xhigh:"xhigh",max:"max"},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:claude-sonnet-5.5":{id:"claude-sonnet-5.5",name:"Claude Sonnet 5.5",api:"anthropic-messages",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:2,output:10,cacheRead:.1,cacheWrite:2.5},contextWindow:1e6,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictTools:!0,forceAdaptiveThinking:!0,supportsTemperature:!1,supportsMidConvoSystemMessages:!0},thinkingLevelMap:{xhigh:"xhigh",max:"max"},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"}},"openai-completions":{"chat:gemini-3.8-flash":{id:"gemini-3.8-flash",name:"Gemini 3.8 Flash",api:"openai-completions",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:.75,output:3.75,cacheRead:.075,cacheWrite:0},contextWindow:1e6,maxTokens:64e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictMode:!0,supportsStore:!1,supportsReasoningEffort:!0},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gemini-4-argon":{id:"gemini-4-argon",name:"Gemini 4 Argon",api:"openai-completions",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:2,output:10,cacheRead:.1,cacheWrite:0},contextWindow:1048576,maxTokens:65536,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictMode:!0,supportsStore:!1,supportsReasoningEffort:!0},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gemini-4-carbon":{id:"gemini-4-carbon",name:"Gemini 4 Carbon",api:"openai-completions",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:2,output:10,cacheRead:.1,cacheWrite:0},contextWindow:1048576,maxTokens:65536,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictMode:!0,supportsStore:!1,supportsReasoningEffort:!0},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gemini-4-hydrogen":{id:"gemini-4-hydrogen",name:"Gemini 4 Hydrogen",api:"openai-completions",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:1.5,output:7.5,cacheRead:.075,cacheWrite:0},contextWindow:1048576,maxTokens:65536,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictMode:!0,supportsStore:!1,supportsReasoningEffort:!0},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gemini-4-neon":{id:"gemini-4-neon",name:"Gemini 4 Neon",api:"openai-completions",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.15,cacheWrite:0},contextWindow:1048576,maxTokens:65536,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictMode:!0,supportsStore:!1,supportsReasoningEffort:!0},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:kimi-k3":{id:"kimi-k3",name:"Kimi K3",api:"openai-completions",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:3,output:15,cacheRead:.3,cacheWrite:0},contextWindow:1048576,maxTokens:1048576,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictMode:!0,supportsStore:!1,supportsReasoningEffort:!0,supportsMidConvoSystemMessages:!0},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:null,high:"high",xhigh:null,max:"max"},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"}},"openai-responses":{"chat:gpt-5.3-codex":{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:1.75,output:14,cacheRead:.175,cacheWrite:0},contextWindow:1e6,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictMode:!0,supportsOpenAIGrammarTools:!0},thinkingLevelMap:{off:null,minimal:"low",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-5.4-nano":{id:"gpt-5.4-nano",name:"GPT-5.4 nano",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:.2,output:1.25,cacheRead:.02,cacheWrite:0},contextWindow:4e5,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictMode:!0,supportsOpenAIGrammarTools:!0},thinkingLevelMap:{off:null,minimal:"low",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-5.6-luna":{id:"gpt-5.6-luna",name:"GPT-5.6 Luna",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:.2,output:1.2,cacheRead:.02,cacheWrite:.25,tiers:[{inputTokensAbove:2e5,input:.4,output:1.8,cacheRead:.04,cacheWrite:.5}]},contextWindow:105e4,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictMode:!0,supportsMidConvoSystemMessages:!0,supportsAdditionalTools:!0,supportsOpenAIGrammarTools:!0},thinkingLevelMap:{off:null,minimal:"low",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-5.6-sol":{id:"gpt-5.6-sol",name:"GPT-5.6 Sol",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:4,output:20,cacheRead:.4,cacheWrite:5,tiers:[{inputTokensAbove:272e3,input:8,output:30,cacheRead:.8,cacheWrite:10}]},contextWindow:105e4,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictMode:!0,supportsMidConvoSystemMessages:!0,supportsAdditionalTools:!0,supportsOpenAIGrammarTools:!0},thinkingLevelMap:{off:null,minimal:"low",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-5.6-terra":{id:"gpt-5.6-terra",name:"GPT-5.6 Terra",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:2,output:12,cacheRead:.2,cacheWrite:2.5,tiers:[{inputTokensAbove:272e3,input:4,output:18,cacheRead:.4,cacheWrite:5}]},contextWindow:105e4,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictMode:!0,supportsMidConvoSystemMessages:!0,supportsAdditionalTools:!0,supportsOpenAIGrammarTools:!0},thinkingLevelMap:{off:null,minimal:"low",low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-6-astra":{id:"gpt-6-astra",name:"GPT-6 Astra",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:10,output:50,cacheRead:1,cacheWrite:12.5,tiers:[{inputTokensAbove:272e3,input:20,output:75,cacheRead:2,cacheWrite:25}]},contextWindow:1e6,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictMode:!0,supportsMidConvoSystemMessages:!0,supportsAdditionalTools:!0,supportsOpenAIGrammarTools:!0},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-6-luna":{id:"gpt-6-luna",name:"GPT-6 Luna",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:.1,output:.5,cacheRead:.01,cacheWrite:.125,tiers:[{inputTokensAbove:272e3,input:.2,output:.75,cacheRead:.02,cacheWrite:.25}]},contextWindow:1e6,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictMode:!0,supportsMidConvoSystemMessages:!0,supportsAdditionalTools:!0,supportsOpenAIGrammarTools:!0},thinkingLevelMap:{off:"none",minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-6-sol":{id:"gpt-6-sol",name:"GPT-6 Sol",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:2,output:10,cacheRead:.2,cacheWrite:2.5,tiers:[{inputTokensAbove:272e3,input:4,output:15,cacheRead:.4,cacheWrite:5}]},contextWindow:1e6,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictMode:!0,supportsMidConvoSystemMessages:!0,supportsAdditionalTools:!0,supportsOpenAIGrammarTools:!0},thinkingLevelMap:{off:"none",minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-6.1-sol":{id:"gpt-6.1-sol",name:"GPT-6.1 Sol",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:2,output:10,cacheRead:.1,cacheWrite:2.5,tiers:[{inputTokensAbove:272e3,input:4,output:15,cacheRead:.2,cacheWrite:5}]},contextWindow:105e4,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictMode:!0,supportsMidConvoSystemMessages:!0,supportsAdditionalTools:!0,supportsOpenAIGrammarTools:!0},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-6.1-terra":{id:"gpt-6.1-terra",name:"GPT-6.1 Terra",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:1,output:5,cacheRead:.05,cacheWrite:1.25,tiers:[{inputTokensAbove:272e3,input:2,output:7.5,cacheRead:.1,cacheWrite:2.5}]},contextWindow:105e4,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictMode:!0,supportsMidConvoSystemMessages:!0,supportsAdditionalTools:!0,supportsOpenAIGrammarTools:!0},thinkingLevelMap:{off:"none",minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-6.2-astra":{id:"gpt-6.2-astra",name:"GPT-6.2 Astra",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:8,output:40,cacheRead:.4,cacheWrite:10,tiers:[{inputTokensAbove:272e3,input:16,output:60,cacheRead:.8,cacheWrite:20}]},contextWindow:105e4,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictMode:!0,supportsMidConvoSystemMessages:!0,supportsAdditionalTools:!0,supportsOpenAIGrammarTools:!0},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:gpt-6.2-sol":{id:"gpt-6.2-sol",name:"GPT-6.2 Sol",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:2,output:10,cacheRead:.1,cacheWrite:2.5,tiers:[{inputTokensAbove:272e3,input:4,output:15,cacheRead:.2,cacheWrite:5}]},contextWindow:105e4,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictMode:!0,supportsMidConvoSystemMessages:!0,supportsAdditionalTools:!0,supportsOpenAIGrammarTools:!0},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:grok-4.5":{id:"grok-4.5",name:"Grok 4.5",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:2,output:6,cacheRead:.5,cacheWrite:0,tiers:[{inputTokensAbove:2e5,input:4,output:12,cacheRead:1,cacheWrite:0}]},contextWindow:5e5,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictMode:!0},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:grok-4.6":{id:"grok-4.6",name:"Grok 4.6",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:2,output:6,cacheRead:.5,cacheWrite:0,tiers:[{inputTokensAbove:2e5,input:4,output:12,cacheRead:1,cacheWrite:0}]},contextWindow:5e5,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictMode:!0},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:grok-4.7":{id:"grok-4.7",name:"Grok 4.7",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:2,output:6,cacheRead:.5,cacheWrite:0,tiers:[{inputTokensAbove:2e5,input:4,output:12,cacheRead:1,cacheWrite:0}]},contextWindow:5e5,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictMode:!0},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:null},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:mai-code-1.1-flash":{id:"mai-code-1.1-flash",name:"MAI-Code-1.1-Flash",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:.2,output:1.2,cacheRead:.02,cacheWrite:0},contextWindow:256e3,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictMode:!0},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:null,max:null},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:mai-code-2":{id:"mai-code-2",name:"MAI Code 2",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:.5,output:2.5,cacheRead:.025,cacheWrite:0},contextWindow:105e4,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictMode:!0},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"},"chat:mai-code-2-flash":{id:"mai-code-2-flash",name:"MAI Code 2 Flash",api:"openai-responses",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",reasoning:!0,input:["text","image"],cost:{input:.05,output:.25,cacheRead:.005,cacheWrite:0},contextWindow:105e4,maxTokens:128e3,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},compat:{supportsStrictMode:!0},thinkingLevelMap:{off:null,minimal:null,low:"low",medium:"medium",high:"high",xhigh:"xhigh",max:"max"},inputLimits:{images:{resize:{maxWidth:2e3,maxHeight:2e3,maxBytes:4718592,jpegQuality:80}}},type:"chat"}},"typesafe-system-one":{"classifier:microsoft-decision-1":{type:"classifier",id:"microsoft-decision-1",name:"Microsoft-Decision-1",api:"typesafe-system-one",provider:"github-copilot",baseUrl:"https://api.individual.githubcopilot.com",input:["text"],cost:{input:.042,output:0,cacheRead:0,cacheWrite:0},contextWindow:32768,headers:{"User-Agent":"GitHubCopilotChat/0.35.0","Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"}}}};function a(e,t){return Object.fromEntries(Object.values(e).flatMap(i=>Object.values(i)).filter(i=>i.type===t).map(i=>[i.id,i]))}function s(e,t){return a(t,"chat")}function n(e,t){return a(t,"image")}function p(e,t){return a(t,"classifier")}var m=s("github-copilot",o),d=n("github-copilot",o),g=p("github-copilot",o);export{s as a,n as b,p as c,m as d,d as e,g as f};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createRequire as __cortexCreateRequire } from 'node:module';
|
|
2
|
+
const require = __cortexCreateRequire(import.meta.url);
|
|
3
|
+
const __cortexPackageRoot = new URL("../../", import.meta.url);
|
|
4
|
+
import{d as n,e as g}from"./chunk-OJ37ZWBG.js";import{f as u}from"./chunk-SKHFU5DI.js";import{f as p}from"./chunk-B3NB243Z.js";import{e as c}from"./chunk-7W7VYUTK.js";import{mkdirSync as f,readFileSync as D,writeFileSync as m}from"fs";import*as s from"path";var l=c("pi-agent-dir"),x=p(),I=s.join(n,"agents");function P(t){u({defaultsDir:t?.defaultsDir,rolesDir:t?.rolesDir,legacyDir:t?.legacyDir??I})}function E(){f(n,{recursive:!0}),f(g,{recursive:!0}),P(),d()}function d(t){let r=s.join(t?.agentDir??n,"settings.json"),e=y(r);if(e.transport!=="sse")try{m(r,`${JSON.stringify({...e,transport:"sse"},null,2)}
|
|
5
|
+
`)}catch(o){l.warn(`Failed to pin PI transport in ${r}: ${o.message}`)}}function O(t,r){let e=s.join(r?.agentDir??n,"settings.json"),o=y(e),i=o.compaction,a=i&&typeof i=="object"&&!Array.isArray(i)?i:{};if(a.reserveTokens!==t)try{m(e,`${JSON.stringify({...o,compaction:{...a,reserveTokens:t}},null,2)}
|
|
6
|
+
`)}catch(S){l.warn(`Failed to set PI compaction reserve in ${e}: ${S.message}`)}}function y(t){try{let r=JSON.parse(D(t,"utf-8"));return r&&typeof r=="object"&&!Array.isArray(r)?r:{}}catch{return{}}}export{x as a,P as b,E as c,d,O as e};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as __cortexCreateRequire } from 'node:module';
|
|
2
2
|
const require = __cortexCreateRequire(import.meta.url);
|
|
3
3
|
const __cortexPackageRoot = new URL("../../", import.meta.url);
|
|
4
|
-
import{c as m}from"./chunk-LMDWRRX4.js";import{e as o}from"./chunk-
|
|
4
|
+
import{c as m}from"./chunk-LMDWRRX4.js";import{e as o}from"./chunk-7W7VYUTK.js";import{createReadStream as c,promises as u}from"fs";var s=o("feishu-image"),f=10*1024*1024,g=16,l=new Set(["image/png","image/jpeg","image/gif","image/webp","image/bmp"]);async function d(i,a){if(!(a>0)||a>f)return null;let n;try{n=await u.open(i,"r");let e=Buffer.alloc(g),{bytesRead:r}=await n.read(e,0,g,0),t=m(e.subarray(0,r));return t&&l.has(t)?t:null}catch{return null}finally{await n?.close().catch(()=>{})}}async function I(i,a,n){if(!await d(a,n))return null;try{let e=await i.im.v1.image.create({data:{image_type:"message",image:c(a)}});if(e&&typeof e.code=="number"&&e.code!==0)throw new Error(`Feishu API error ${e.code}: ${e.msg??"unknown"}`);let r=e?.data?.image_key??e?.image_key;if(r)return r;s.warn(`image upload returned no image_key for ${a}; sending it as a file`)}catch(e){s.warn(`image upload failed for ${a} (${e.message}); sending it as a file`)}return null}export{I as a};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createRequire as __cortexCreateRequire } from 'node:module';
|
|
2
|
+
const require = __cortexCreateRequire(import.meta.url);
|
|
3
|
+
const __cortexPackageRoot = new URL("../../", import.meta.url);
|
|
4
|
+
import{a as t}from"./chunk-PMG4YGDU.js";import{e}from"./chunk-7GGPYU5E.js";function a(){return["Initialize Cortex data directory","","Usage: cortex init [--home <path>] [--force] [--answers <file>] [--json]","","Creates the CORTEX_HOME directory structure and asks for the language, interaction","platform (Slack / Feishu), machine name, usage leaderboard sharing and system service.","Writes .env, copies default configs and generates mcp-config*.json, machines.json","and agent-state.json. It then detects provider logins, offers to log in, and picks","the default model and favorites from the models those logins can run.","","Options:"," --home <path> Set CORTEX_HOME (default: $CORTEX_HOME or ~/.cortex/)"," --force Overwrite existing configs (.env, budget.json, agent-state.json, etc.)"," --answers <file> Read answers from a JSON file instead of prompting; omitted fields use defaults"," --json Print NDJSON progress events on stdout and send human output to stderr"," --help, -h Show this help","","With --answers or --json, init does not prompt or start provider login; it reports","credential status and can finish before any provider is set up.","","Examples:"," cortex init"," cortex init --home /data/cortex"," cortex init --answers answers.json --json"].join(`
|
|
5
|
+
`)}function s(){return["Start the Cortex TUI (terminal UI) client","","Usage: cortex tui [options]","","Connects to a running Cortex daemon via WebSocket and opens","a terminal-based chat interface.","","Options:"," --resume Open the resume-session picker on connect"," --project <id> Start a fresh session in the named project"," --port <n> Server port (default: CORTEX_UI_PORT from the environment or .env, else 26789)"," --help, -h Show this help"].join(`
|
|
6
|
+
`)}function c(){return t({name:"cortex ui",description:"Manage the Web UI endpoint used by the Cortex apps and browsers",usage:"cortex ui <enable|pair> [--port <port>] [--home <path>] [--json]",commands:[{name:"enable",description:"Turn on the loopback Web UI endpoint and print how to reach it"},{name:"pair",description:"Print a one-time pairing code (10 minutes) for a new app or browser"}],options:[{flag:"--port <port>",description:"enable: TCP port this install serves on (must be free)",default:"the configured CORTEX_UI_PORT, else the first free port from 26789"},{flag:"--home <path>",description:"CORTEX_HOME to use",default:"$CORTEX_HOME or ~/.cortex"},{flag:"--json",description:"Print the result as JSON (enable: endpoint, token, change state; pair: code, expiry)"},{flag:"--help, -h",description:"Show this help"}],examples:[{description:"Enable the endpoint, keeping the configured port",command:"cortex ui enable"},{description:"Serve on another port",command:"cortex ui enable --port 4000"},{description:"Machine-readable output for the desktop setup flow",command:"cortex ui enable --json"},{description:"Get a code to connect a phone or another computer",command:"cortex ui pair"}]})}function d(){return t({name:"cortex path",description:"Make this install's commands (cortex, cortex-signal, \u2026) available in new terminals",usage:"cortex path <install|remove|status> [--home <path>] [--dry-run] [--json]",commands:[{name:"install",description:"Write launchers that use this install's Node into <home>/runtime/bin and put that directory on PATH (shell profiles on Linux/macOS, the user Path on Windows)"},{name:"remove",description:"Delete the launchers and undo the PATH change"},{name:"status",description:"Show whether the launchers exist, are current, and are on PATH"}],options:[{flag:"--home <path>",description:"CORTEX_HOME the launchers belong to",default:"$CORTEX_HOME or ~/.cortex"},{flag:"--dry-run",description:"Report what install or remove would change and change nothing"},{flag:"--json",description:"Print the result as JSON"},{flag:"--help, -h",description:"Show this help"}],examples:[{description:"Add cortex to new terminals",command:"cortex path install"},{description:"Preview the change",command:"cortex path install --dry-run --json"},{description:"Check the current state",command:"cortex path status"},{description:"Undo it",command:"cortex path remove"}]})}function m(){return t({name:"cortex client",description:"Manage the cortex-client installs on remote machines",usage:"cortex client remove --device <name> [--keep-remote] [--dry-run] [--home <path>]",commands:[{name:"remove",description:"Unregister a machine from machines.json, stop and uninstall its client over SSH, and drop its runtime state"}],options:[{flag:"--device <name>",description:"Machine name as registered in machines.json (required)"},{flag:"--keep-remote",description:"Only unregister locally; leave the remote process and files alone"},{flag:"--dry-run",description:"Print what would be removed as JSON and change nothing"},{flag:"--home <path>",description:"CORTEX_HOME of the server",default:"$CORTEX_HOME or ~/.cortex"},{flag:"--help, -h",description:"Show this help"}],examples:[{description:"Preview the removal",command:"cortex client remove --device trainer --dry-run"},{description:"Remove a machine and uninstall its client",command:"cortex client remove --device trainer"},{description:"Unregister a machine that no longer exists",command:"cortex client remove --device trainer --keep-remote"}]})}function p(){return t({name:"cortex memory",description:`Project memory under $CORTEX_HOME/context/projects (experiments/, knowledge/, patterns/).
|
|
7
|
+
regen rewrites only the generated index.md files; the EXP/K/PAT files are never modified. Output is JSON.`,usage:"cortex memory <command> [--project <name>]... [options]",commands:[{name:"regen",description:"Rebuild experiments/knowledge/patterns index.md from frontmatter and the access log"},{name:"consolidate",description:"Report contradictions, stale entries, anti-pattern signals and consolidation candidates"}],options:[{flag:"--project <name>",description:"Limit to one project; repeat for several",default:"every project with memory directories"},{flag:"--text",description:"consolidate: print a human-readable summary instead of JSON"},{flag:"--help, -h",description:"Show this help"}],examples:[{description:"Rebuild every index",command:"cortex memory regen"},{description:"Rebuild one project's indexes",command:"cortex memory regen --project wm-align"},{description:"Lifecycle report for all projects",command:"cortex memory consolidate --text"},{description:"Lifecycle report as JSON for one project",command:"cortex memory consolidate --project wm-align"}]})}function l(){return t({name:"cortex schedule",description:`Manage scheduled tasks. Each fire opens a new session in the schedule's project and sends it the message.
|
|
8
|
+
Changes land in schedules.json; a running daemon picks them up within a second. Output is JSON.`,usage:"cortex schedule <command> [<id>] [options]",commands:[{name:"list",description:"List schedules (--project to filter)"},{name:"get <id>",description:"Show one schedule"},{name:"add --type <type>",description:"Create a schedule"},{name:"edit <id>",description:"Change message, project, model, thinking, pre-check or timing (the type is fixed)"},{name:"pause <id>",description:"Pause a recurring schedule"},{name:"resume <id>",description:"Resume a paused schedule"},{name:"remove <id>",description:"Delete a schedule (--dry-run to preview)"}],options:[{flag:"--type <type>",description:"add: interval | daily | weekly | once"},{flag:"--interval <duration>",description:"interval: repeat period, e.g. 30m, 2h, 1d"},{flag:"--time <HH:MM>",description:"daily/weekly: time of day, 24-hour, server local time"},{flag:"--day <day>",description:"weekly: sun..sat or 0-6"},{flag:"--delay <duration>",description:"once: fire this long from now, e.g. 90m, 2h"},{flag:"--message <text|->",description:'Prompt for the fired session; "-" reads stdin'},{flag:"--project <id>",description:"Project the fired session belongs to",default:"general"},{flag:"--model [provider/]model",description:"Model to run",default:"the default model"},{flag:"--thinking <level>",description:"Thinking level for the selected model"},{flag:"--pre-check <cmd>",description:"Shell gate run before each fire; non-zero exit skips it"},{flag:"--idempotency-key <key>",description:"add: return the schedule already created with this key"},{flag:"--dry-run",description:"remove: show what would be removed"},{flag:"--help, -h",description:"Show this help"}],examples:[{description:"Every 30 minutes in a project",command:'cortex schedule add --type interval --interval 30m --project nimbus --message "Check GPU usage on lab2 and report a one-line summary"'},{description:"Every day at 09:00",command:`cortex schedule add --type daily --time 09:00 --message "Summarize yesterday's sessions"`},{description:"Every Monday at 21:00",command:'cortex schedule add --type weekly --day mon --time 21:00 --message "Weekly review"'},{description:"Once, two hours from now, prompt from stdin",command:'echo "Check training run r42 on lab2" | cortex schedule add --type once --delay 2h --message -'},{description:"List one project's schedules",command:"cortex schedule list --project nimbus"},{description:"Move a daily schedule to 10:30",command:"cortex schedule edit a1b2c3d4 --time 10:30"},{description:"Preview a removal",command:"cortex schedule remove a1b2c3d4 --dry-run"}]})}function n(){return[{name:"init",description:"Initialize CORTEX_HOME directory with configs and API keys"},{name:"start",description:"Start the Cortex server (node dist/entry/app.js)"},{name:"daemon",description:"Start daemon mode with file watching and auto-restart"},{name:"daemon stop",description:"Stop the running daemon (SIGTERM) and the local client it launched"},{name:"daemon status",description:"Check daemon + child status (PID, uptime)"},{name:"daemon restart",description:"Graceful restart \u2014 signal daemon to drain and respawn app.js"},{name:"daemon restart --hard",description:"Hard restart \u2014 send SIGTERM directly to app.js (daemon auto-recovers)"},{name:"daemon restart --force",description:"Force restart \u2014 send SIGKILL immediately to app.js"},{name:"daemon restart-self",description:"Stop and restart the daemon process itself"},{name:"restart",description:"Legacy alias for daemon restart (touches $STORE_DIR/.restart)"},{name:"install latest",description:"Install the latest version of Cortex from npm"},{name:"config",description:"Show resolved paths and initialization status"},{name:"doctor",description:"Health-check the install (runtime, login, platform); --fix to repair"},{name:"auth status",description:e("cmd.auth.cli.statusDescription")},{name:"feishu",description:"Manage Feishu user-identity login (login / status / logout)"},{name:"ui enable",description:"Enable the local Web UI endpoint the desktop app connects to"},{name:"client remove",description:"Unregister a remote machine and uninstall its cortex-client"},{name:"path install",description:"Make cortex available in new terminals (remove / status to undo or check)"},{name:"schedule",description:"List, add, edit, pause, resume and remove scheduled tasks"},{name:"memory",description:"Rebuild project memory indexes; report knowledge lifecycle findings"},{name:"tui",description:"Start the Terminal UI (TUI) client for local interaction"}]}function o(){return[{description:"Interactive init",command:"cortex init"},{description:"Init to custom directory",command:"cortex init --home /tmp/my-cortex"},{description:"Show resolved paths",command:"cortex config"},{description:"Health-check the install",command:"cortex doctor"},{description:e("cmd.auth.cli.exampleSummary"),command:"cortex auth status"},{description:e("cmd.auth.cli.exampleJson"),command:"cortex auth status --json"},{description:"Diagnose and auto-repair",command:"cortex doctor --fix"},{description:"Enable the local Web UI endpoint",command:"cortex ui enable"},{description:"Remove a remote machine and its client",command:"cortex client remove --device trainer"},{description:"Add cortex to new terminals",command:"cortex path install"},{description:"List scheduled tasks",command:"cortex schedule list"},{description:"Rebuild every project memory index",command:"cortex memory regen"},{description:"Start the server",command:"cortex start"},{description:"Stop the daemon",command:"cortex daemon stop"},{description:"Check daemon status",command:"cortex daemon status"},{description:"Graceful restart",command:"cortex daemon restart"},{description:"Hard restart app.js",command:"cortex daemon restart --hard"},{description:"Restart daemon itself",command:"cortex daemon restart-self"}]}function h(){return t({name:"cortex",description:"Cortex CLI \u2014 server management and initialization",usage:"cortex <command> [options]",commands:n(),options:[{flag:"--help, -h",description:"Show this help"}],examples:o()})}function u(){return t({name:"cortex auth",description:e("cmd.auth.cli.description"),usage:"cortex auth <status|login|provider> [options]",commands:[{name:"status",description:e("cmd.auth.cli.statusDescription")},{name:"login",description:e("init.auth.loginDescription")},{name:"provider",description:e("provider.cli.description")}],options:[{flag:"--json",description:e("cmd.auth.cli.jsonDescription")},{flag:"--help, -h",description:e("cmd.auth.cli.helpDescription")}],examples:[{description:e("cmd.auth.cli.exampleSummary"),command:"cortex auth status"},{description:e("cmd.auth.cli.exampleJson"),command:"cortex auth status --json"},{description:e("provider.cli.exampleList"),command:"cortex auth provider list"}],labels:{usage:e("cmd.auth.cli.helpUsage"),commands:e("cmd.auth.cli.helpCommands"),options:e("cmd.auth.cli.helpOptions"),examples:e("cmd.auth.cli.helpExamples")}})}export{a,s as b,c,d,m as e,p as f,l as g,h,u as i};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __cortexCreateRequire } from 'node:module';
|
|
2
2
|
const require = __cortexCreateRequire(import.meta.url);
|
|
3
3
|
const __cortexPackageRoot = new URL("../../", import.meta.url);
|
|
4
|
-
import{a,c as y,d as f}from"./chunk-
|
|
4
|
+
import{a,c as y,d as f}from"./chunk-PG7452XE.js";import{e as u}from"./chunk-TRXLIL7V.js";import*as o from"node:fs";import*as d from"node:path";var p=/^[A-Za-z0-9][A-Za-z0-9_-]*$/,v="50-";function c(e,n){return Object.assign(new Error(n),{code:e})}function l(e,n){let t=f(e).find(i=>i.entry.id===n);if(!t)throw c("not-found",`Unknown hook id: '${n}'`);return t}function h(e){if(e.source!=="user")throw c("invalid-args",`Hook '${e.entry.id}' is ${e.source}; only user entries can be edited or removed`)}function k(e){if(typeof e!="object"||e===null)throw c("invalid-args","run must be an object");let n={};return e.script!==void 0&&(n.script=e.script),e.command!==void 0&&(n.command=e.command),e.timeout!==void 0&&(n.timeout=e.timeout),n}function g(e,n){let t={id:e,event:n.event};n.matcher!==void 0&&(t.matcher=n.matcher),t.run=k(n.run),n.scope!==void 0&&(t.scope=n.scope),n.blocking!==void 0&&(t.blocking=n.blocking),n.result!==void 0&&(t.result=n.result),n.enabled!==void 0&&(t.enabled=n.enabled);try{return y(t)}catch(i){throw c("invalid-args",i instanceof Error?i.message:String(i))}}function m(e){return`${JSON.stringify(e,null,2)}
|
|
5
5
|
`}function E(e,n){let t={...e.override??{}};if(delete t.version,e.entry.enabled!==!1===n?delete t.enabled:t.enabled=n,Object.keys(t).length===0){o.rmSync(e.overridePath,{force:!0});return}o.mkdirSync(d.dirname(e.overridePath),{recursive:!0}),u(e.overridePath,`${JSON.stringify(t,null,2)}
|
|
6
6
|
`)}function $(e=a(),n,t){let i=l(e,n),r=i.entry.enabled!==!1!==t;return r?(i.builtin?E(i.builtin,t):u(i.filePath,m({...i.entry,enabled:t})),{changed:r}):{changed:r}}function H(e=a(),n){let t=e.user,i=n.id;if(typeof i!="string"||!p.test(i))throw c("invalid-args",`Hook id '${String(i)}' must start with a letter or digit and contain only letters, digits, '-' and '_'`);if(f(e).some(b=>b.entry.id===i))throw c("invalid-args",`Hook id '${i}' already exists in the registry`);let r=g(i,n),s=d.join(t,`${v}${i}.json`);if(o.existsSync(s))throw c("invalid-args",`${d.basename(s)} already exists`);return o.mkdirSync(t,{recursive:!0}),u(s,m(r)),{id:i,filePath:s}}function P(e=a(),n,t){let i=l(e,n);h(i);let r=g(n,t),s=JSON.stringify(r)!==JSON.stringify(i.entry);return s&&u(i.filePath,m(r)),{changed:s}}function x(e=a(),n){let t=l(e,n);return h(t),o.rmSync(t.filePath,{force:!0}),{removed:!0}}export{$ as a,H as b,P as c,x as d};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire as __cortexCreateRequire } from 'node:module';
|
|
2
|
+
const require = __cortexCreateRequire(import.meta.url);
|
|
3
|
+
const __cortexPackageRoot = new URL("../../", import.meta.url);
|
|
4
|
+
import{a as m,c as h}from"./chunk-Y6ZEVVL5.js";import{c as l,w as u,z as f}from"./chunk-T54CZKNJ.js";import{existsSync as E,mkdirSync as c,readFileSync as x,promises as o}from"node:fs";import*as d from"node:os";import*as i from"node:path";var w="inputs",F="CORTEX_CLEAN",P="clean-workspace.md";function A(t){return t?.clean===!0&&t.workspaceDir?t.workspaceDir:null}function I(t,e=u){c(e,{recursive:!0});for(let r=1;;r++){let a=i.join(e,r===1?t:`${t}-${r}`);if(y(a))return c(i.join(a,w)),a}}function y(t){try{return c(t),!0}catch(e){if(e.code==="EEXIST")return!1;throw e}}async function D(t,e,r){let a=i.join(t,w);await o.mkdir(a,{recursive:!0});let n=m(r||i.basename(e)),s=i.join(a,n);if(await R(e,s))return s;let{destPath:p}=await h(a,n);return await o.cp(e,p,{recursive:!0}),p}async function R(t,e){let[r,a]=await Promise.all([o.stat(t).catch(()=>null),o.stat(e).catch(()=>null)]);if(!r?.isFile()||!a?.isFile()||r.size!==a.size)return!1;let[n,s]=await Promise.all([o.readFile(t),o.readFile(e)]);return n.equals(s)}function j(t,e){let r=t==="~"||t.startsWith("~/")?i.join(d.homedir(),t.slice(1)):t;return i.resolve(e,r)}function C(t){let e=i.join(f,P),r=E(e)?e:i.join(l,"prompts",P);return x(r,"utf8").replaceAll("{{workspace}}",t).trim()}export{F as a,A as b,I as c,D as d,j as e,C as f};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as __cortexCreateRequire } from 'node:module';
|
|
2
2
|
const require = __cortexCreateRequire(import.meta.url);
|
|
3
3
|
const __cortexPackageRoot = new URL("../../", import.meta.url);
|
|
4
|
-
import{
|
|
4
|
+
import{b as o}from"./chunk-T54CZKNJ.js";import{readFileSync as t}from"node:fs";import{join as r}from"node:path";var n=r(o,"package.json"),p=JSON.parse(t(n,"utf-8")),a=p.version,c="https://fangxm233.github.io/cortex-agent/";export{a,c as b};
|