@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 +0,0 @@
|
|
|
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 f=class extends Error{status;body;constructor(r,e){super(`HTTP ${r}`),this.name="HTTPStatusError",this.status=r,this.body=e}};function h(r,e){return`${r.replace(/\/+$/,"")}/${e.replace(/^\/+/,"")}`}function y(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}async function v(r,e={}){let n=new AbortController,a=e.timeoutMs??3e3,l=setTimeout(()=>{n.abort(new Error(`Request timed out after ${a}ms`))},a),o=e.signal,c=()=>{n.abort(o?.reason)};o&&(o.aborted?n.abort(o.reason):o.addEventListener("abort",c,{once:!0}));try{let s=new Headers(e.headers??{}),t=e.body;t!=null&&typeof t!="string"&&!(t instanceof URLSearchParams)&&!(t instanceof FormData)&&!(t instanceof Blob)&&!(t instanceof ArrayBuffer)&&(t=JSON.stringify(t)),typeof t=="string"&&!s.has("content-type")&&s.set("content-type","application/json");let i=await fetch(r,{...e,headers:s,body:t,signal:n.signal}),u=await i.text(),d=u?p(u):null;if(!i.ok)throw new f(i.status,d);return d}finally{clearTimeout(l),o?.removeEventListener("abort",c)}}function p(r){try{return JSON.parse(r)}catch{return r}}export{f as a,h as b,y as c,v as d};
|
|
@@ -1,8 +0,0 @@
|
|
|
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 Le}from"./chunk-EQIMHXC4.js";import{a as de}from"./chunk-FX6MOGLR.js";import{M as O,e as v,g as I,m as $}from"./chunk-QUUEQRIT.js";import{a as Oe}from"./chunk-B3XBQEFM.js";import{e as ce}from"./chunk-WHC7AYZD.js";import{execSync as Ve,spawnSync as De}from"child_process";var G=new Map,Ne=/^[A-Za-z_][A-Za-z0-9_]*$/,ke=/^[A-Za-z_][A-Za-z0-9_]*/;function C(s,e){if(!e)return;let t=s[s.length-1];if(t?.type==="literal"){t.value+=e;return}s.push({type:"literal",value:e})}function qe(s){let e=[],t=0;for(;t<s.length;){let r=s.indexOf("$",t);if(r<0){C(e,s.slice(t));break}C(e,s.slice(t,r));let n=s[r+1];if(n==="$"||n==="!"){C(e,n),t=r+2;continue}if(n==="{"){let o=s.indexOf("}",r+2);if(o<0){C(e,"$"),t=r+1;continue}let a=s.slice(r+2,o);Ne.test(a)?e.push({type:"env",name:a}):C(e,s.slice(r,o+1)),t=o+1;continue}let i=s.slice(r+1).match(ke);if(i){e.push({type:"env",name:i[0]}),t=r+1+i[0].length;continue}C(e,"$"),t=r+1}return e}function L(s){return s.startsWith("!")?{type:"command",config:s}:{type:"template",parts:qe(s)}}function le(s,e){return e?.[s]||process.env[s]||void 0}function $e(s){let e=[];for(let t of s)t.type!=="env"||e.includes(t.name)||e.push(t.name);return e}function fe(s,e){let t="";for(let r of s){if(r.type==="literal"){t+=r.value;continue}let n=le(r.name,e);if(n===void 0)return;t+=n}return t}function je(s){let e=L(s);return e.type==="template"?$e(e.parts):[]}function he(s,e){return je(s).filter(t=>le(t,e)===void 0)}function pe(s){return L(s).type==="command"}function wt(s,e){return he(s,e).length===0}function W(s,e){let t=L(s);return t.type==="command"?Fe(t.config):fe(t.parts,e)}function Be(s){try{let{shell:e,args:t,commandTransport:r}=de(),n=r==="stdin",i=De(e,n?t:[...t,s],{encoding:"utf-8",input:n?s:void 0,timeout:1e4,stdio:[n?"pipe":"ignore","pipe","ignore"],shell:!1,windowsHide:!0});return i.error?i.error.code==="ENOENT"?{executed:!1,value:void 0}:{executed:!0,value:void 0}:i.status!==0?{executed:!0,value:void 0}:{executed:!0,value:(i.stdout??"").trim()||void 0}}catch{return{executed:!1,value:void 0}}}function ue(s){try{return Ve(s,{encoding:"utf-8",timeout:1e4,stdio:["ignore","pipe","ignore"]}).trim()||void 0}catch{return}}function me(s){let e=s.slice(1);return process.platform==="win32"?(()=>{let t=Be(e);return t.executed?t.value:ue(e)})():ue(e)}function Fe(s){if(G.has(s))return G.get(s);let e=me(s);return G.set(s,e),e}function Je(s,e){let t=L(s);return t.type==="command"?me(t.config):fe(t.parts,e)}function Ue(s,e,t){let r=Je(s,t);if(r!==void 0)return r;let n=L(s);if(n.type==="command")throw new Error(`Failed to resolve ${e} from shell command: ${n.config.slice(1)}`);if(n.type==="template"){let i=he(s,t);if(i.length===1)throw new Error(`Failed to resolve ${e} from environment variable: ${i[0]}`);if(i.length>1)throw new Error(`Failed to resolve ${e} from environment variables: ${i.join(", ")}`)}throw new Error(`Failed to resolve ${e}`)}function Et(s,e,t){if(!s)return;let r={};for(let[n,i]of Object.entries(s))r[n]=Ue(i,`${e} header "${n}"`,t);return Object.keys(r).length>0?r:void 0}var K=ce(Le(),1);import{existsSync as j,mkdirSync as ze,readFileSync as F,writeFileSync as Y}from"fs";import{dirname as He,join as J}from"path";import{setTimeout as we}from"timers/promises";function ye(s){if(s.reason!==void 0)return s.reason;let e=new Error("The operation was aborted");return e.name="AbortError",e}function St(s){return s??new AbortController().signal}function X(s,e){return e?e.aborted?(s.catch(()=>{}),Promise.reject(ye(e))):new Promise((t,r)=>{let n=!1,i=()=>e.removeEventListener("abort",o),o=()=>{n||(n=!0,i(),r(ye(e)))};e.addEventListener("abort",o,{once:!0}),s.then(a=>{n||(n=!0,i(),t(a))},a=>{n||(n=!0,i(),r(a))}),e.aborted&&o()}):s}var Ge=5;function Ee(s){let e=s instanceof Error&&"code"in s?s.code:void 0;if(e==="ELOCKED"||e==="EPERM"&&process.platform==="win32")return e}var Z={encoding:"utf-8",mode:384},B,Q=class{authPath;constructor(e=J(O(),"auth.json")){this.authPath=I(e)}ensureParentDir(){let e=He(this.authPath);j(e)||ze(e,{recursive:!0,mode:448})}ensureFileExists(){j(this.authPath)||Y(this.authPath,"{}",Z)}acquireLockSyncWithRetry(e){for(let n=1;;n++)try{return K.default.lockSync(e,{realpath:!1})}catch(i){if(!Ee(i)||n===10)throw i;let o=Date.now();for(;Date.now()-o<20;);}}withLock(e){this.ensureParentDir(),this.ensureFileExists();let t;try{t=this.acquireLockSyncWithRetry(this.authPath);let r=j(this.authPath)?F(this.authPath,"utf-8"):void 0,{result:n,next:i}=e(r);return i!==void 0&&Y(this.authPath,i,Z),n}finally{t&&t()}}async acquireLockAsync(e,t){let i=Date.now()+3e4,o=0,a=0;for(;;){e?.throwIfAborted();let d;try{d=await K.default.lock(this.authPath,{realpath:!1,retries:0,stale:3e4,onCompromised:t})}catch(c){e?.throwIfAborted();let l=Ee(c),x=i-Date.now();if(!l||x<=0||l==="EPERM"&&++a>Ge)throw c;let f=Math.min(10*2**o,2e3/2);o++;let h=Math.min(Math.round(f*(1+Math.random())),x);e?await we(h,void 0,{signal:e}):await we(h);continue}return e?.aborted&&(await d(),e.throwIfAborted()),d}}async withLockAsync(e,t){t?.signal?.throwIfAborted(),this.ensureParentDir(),this.ensureFileExists();let r,n=!1,i,o=()=>{if(n)throw i??new Error("Auth storage lock was compromised")};try{r=await this.acquireLockAsync(t?.signal,l=>{n=!0,i=l}),o(),t?.signal?.throwIfAborted();let a=j(this.authPath)?F(this.authPath,"utf-8"):void 0,{result:d,next:c}=await e(a);return o(),t?.signal?.throwIfAborted(),c!==void 0&&Y(this.authPath,c,Z),o(),d}finally{if(r)try{await r()}catch{}}}},ge=class{authPath;data;constructor(e=J(O(),"auth.json")){this.authPath=I(e)}load(){if(this.data)return this.data;let e;try{e=JSON.parse($(F(this.authPath,"utf-8")))}catch(t){if(t.code==="ENOENT")return this.data={},this.data;throw new Error(`Failed to read auth.json: ${t instanceof Error?t.message:String(t)}`)}if(typeof e!="object"||e===null||Array.isArray(e))throw new Error("Invalid auth.json: expected an object");for(let[t,r]of Object.entries(e)){if(typeof r!="object"||r===null||Array.isArray(r))throw new Error(`Invalid auth.json credential for provider "${t}"`);let n=r;if(n.type==="api_key"){let i=n.key===void 0||typeof n.key=="string",o=n.env===void 0||typeof n.env=="object"&&n.env!==null&&!Array.isArray(n.env)&&Object.values(n.env).every(a=>typeof a=="string");if(i&&o)continue}else if(n.type==="oauth"&&typeof n.access=="string"&&typeof n.refresh=="string"&&typeof n.expires=="number"&&Number.isFinite(n.expires))continue;throw new Error(`Invalid auth.json credential for provider "${t}"`)}return this.data=e,this.data}async read(e,t){t?.signal?.throwIfAborted();let r=this.load()[e];if(t?.signal?.throwIfAborted(),!!r)return r.type!=="api_key"||!r.key||pe(r.key)?structuredClone(r):{...r,key:W(r.key,r.env)}}async list(e){e?.signal?.throwIfAborted();let t=Object.entries(this.load()).map(([r,n])=>({providerId:r,type:n.type}));return e?.signal?.throwIfAborted(),t}async modify(e,t,r){throw new Error("Read-only credential storage cannot modify auth.json")}async delete(e,t){throw new Error("Read-only credential storage cannot modify auth.json")}},ee=class{value;asyncChain=Promise.resolve();withLock(e){let{result:t,next:r}=e(this.value);return r!==void 0&&(this.value=r),t}withLockAsync(e,t){let r=this.asyncChain,n=(async()=>{await r.catch(()=>{}),t?.signal?.throwIfAborted();let{result:i,next:o}=await e(this.value);return t?.signal?.throwIfAborted(),o!==void 0&&(this.value=o),i})();return this.asyncChain=n.catch(()=>{}),X(n,t?.signal)}},Se=class s{storage;authPath;readState;constructor(e,t){if(this.storage=e,this.authPath=t,this.readState=t&&B?.authPath===t?B.readState:{data:{}},t&&!B&&(B={authPath:t,readState:this.readState}),t){let r=v(t);if(r!==void 0&&r===this.readState.revision)return}this.reload()}static create(e=J(O(),"auth.json")){let t=I(e);return new s(new Q(t),t)}static fromStorage(e){return new s(e)}static inMemory(e={}){let t=new ee;return t.withLock(()=>({result:void 0,next:JSON.stringify(e,null,2)})),s.fromStorage(t)}parseStorageData(e){return e?JSON.parse($(e)):{}}updateReadState(e,t){this.readState.data=e,this.readState.revision=t}reload(){let e,t;try{this.storage.withLock(r=>(e=r,t=this.authPath?v(this.authPath):void 0,{result:void 0})),this.updateReadState(this.parseStorageData(e),t)}catch{}}async reloadFromStorageAsync(e){return this.storage.withLockAsync(async t=>{let r=this.parseStorageData(t),n=this.authPath?v(this.authPath):void 0;return this.updateReadState(r,n),{result:r}},e)}async readLatestData(e){if(e?.signal?.throwIfAborted(),!this.authPath){let n=this.reloadFromStorageAsync(e);return e?.signal?n:n.catch(()=>this.readState.data)}let t=v(this.authPath);if(t!==void 0&&t===this.readState.revision)return this.readState.data;if(!this.readState.reload){let n=new AbortController,i={controller:n,promise:this.reloadFromStorageAsync({signal:n.signal}),readers:0};this.readState.reload=i,i.promise.then(()=>{this.readState.reload===i&&(this.readState.reload=void 0)},()=>{this.readState.reload===i&&(this.readState.reload=void 0)})}let r=this.readState.reload;r.readers++;try{let n=X(r.promise,e?.signal);return e?.signal?await n:await n.catch(()=>this.readState.data)}finally{r.readers--,r.readers===0&&this.readState.reload===r&&(this.readState.reload=void 0,r.controller.abort())}}async read(e,t){let r=(await this.readLatestData(t))[e];return t?.signal?.throwIfAborted(),r?.type!=="api_key"||r.key===void 0?r:{...r,key:W(r.key,r.env)}}async modify(e,t,r){let n=this.readState.data,i,o=await this.storage.withLockAsync(async a=>{let d=this.parseStorageData(a),c=await t(d[e]);if(c===void 0)return n=d,i=this.authPath?v(this.authPath):void 0,{result:d[e]};let l={...d,[e]:c};return n=l,{result:c,next:JSON.stringify(l,null,2)}},r);return this.updateReadState(n,i),o}async delete(e,t){let r=this.readState.data;await this.storage.withLockAsync(async n=>{let i=this.parseStorageData(n);return delete i[e],r=i,{result:void 0,next:JSON.stringify(i,null,2)}},t),this.updateReadState(r)}async list(e){let t=Object.entries(await this.readLatestData(e));return e?.signal?.throwIfAborted(),t.map(([r,n])=>({providerId:r,type:n.type}))}};function _t(s,e=J(O(),"auth.json")){try{return JSON.parse($(F(I(e),"utf-8")))[s]}catch{return}}var w={parseError:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internalError:-32603},y=class extends Error{code;data;constructor(e,t,r){super(t),this.name="McpError",this.code=e,this.data=r}},p=class extends Error{constructor(e="MCP connection closed"){super(e),this.name="McpConnectionClosedError"}},V=class extends Error{timeoutMs;constructor(e){super(`MCP request timed out after ${e}ms`),this.name="McpTimeoutError",this.timeoutMs=e}},S=class extends Error{constructor(e="MCP request aborted"){super(e),this.name="AbortError"}};function u(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)}function R(s){return s instanceof Error?s:new Error(String(s))}function D(s){return typeof s=="string"||typeof s=="number"&&Number.isFinite(s)}function b(s){return u(s)&&s.jsonrpc==="2.0"&&D(s.id)&&typeof s.method=="string"}function U(s){return u(s)&&s.jsonrpc==="2.0"&&!("id"in s)&&typeof s.method=="string"}function P(s){return!u(s)||s.jsonrpc!=="2.0"||!D(s.id)?!1:"result"in s?!("error"in s):!("error"in s)||!u(s.error)?!1:typeof s.error.code=="number"&&typeof s.error.message=="string"}function M(s){if(b(s)||U(s)||P(s))return s;throw new y(w.invalidRequest,"Invalid JSON-RPC message")}var te="2025-11-25",xe=[te,"2025-06-18","2025-03-26","2024-11-05"];var We=3e4,Re=1e3;function Xe(s){if(!u(s)||typeof s.protocolVersion!="string"||!u(s.capabilities)||!u(s.serverInfo)||typeof s.serverInfo.name!="string"||typeof s.serverInfo.version!="string"||s.instructions!==void 0&&typeof s.instructions!="string")throw new y(w.invalidRequest,"Invalid MCP initialize result");return s}function N(s){return new y(w.invalidRequest,s)}function Ye(s,e,t,r){let n=u(t)?t[e]:void 0;if(!u(t)||!Array.isArray(n))throw N(`Invalid MCP ${s} result`);for(let o of n)if(!u(o)||!r(o))throw N(`Invalid entry in MCP ${s} result`);let i=t.nextCursor===null||t.nextCursor===""?void 0:t.nextCursor;if(i!==void 0&&typeof i!="string")throw N(`Invalid MCP ${s} cursor`);return{items:n,...i===void 0?{}:{nextCursor:i}}}var Ze=s=>typeof s.name=="string"&&u(s.inputSchema),ve=s=>typeof s.uri=="string"&&(s.name===void 0||typeof s.name=="string"),Ce=s=>typeof s.uriTemplate=="string"&&(s.name===void 0||typeof s.name=="string");function be(s){return{...s,name:s.name??s.uri}}function Pe(s){return{...s,name:s.name??s.uriTemplate}}function Me(s){return s.nextCursor===void 0?{}:{nextCursor:s.nextCursor}}function Ke(s){if(!u(s)||!Array.isArray(s.contents))throw N("Invalid MCP resources/read result");for(let e of s.contents)if(!u(e)||typeof e.uri!="string"||typeof e.text!="string"&&typeof e.blob!="string")throw N("Invalid contents in MCP resources/read result");return s}function Qe(s){if(!u(s)||s.content!==void 0&&!Array.isArray(s.content))throw new y(w.invalidRequest,"Invalid MCP tools/call result");return s.content===void 0?{...s,content:[]}:s}var re=class{options;state="idle";transport;nextRequestId=1;serverInfoValue;serverCapabilitiesValue;instructionsValue;protocolVersionValue;pending=new Map;progressRequests=new Map;incoming=new Map;requestHandlers=new Map;notificationListeners=new Map;errorListeners=new Set;closeListeners=new Set;disposers=[];constructor(e){this.options=Object.freeze({...e}),this.requestHandlers.set("ping",()=>({}));let t=e.roots;t&&this.requestHandlers.set("roots/list",async()=>({roots:[...typeof t=="function"?await t():t]}))}get connectionState(){return this.state}get serverInfo(){return this.serverInfoValue}get serverCapabilities(){return this.serverCapabilitiesValue}get instructions(){return this.instructionsValue}get protocolVersion(){return this.protocolVersionValue}async connect(e){if(this.state!=="idle")throw new Error(`Cannot connect MCP client in ${this.state} state`);this.state="connecting",this.transport=e,this.disposers=[e.onMessage(t=>this.handleMessage(t)),e.onError(t=>this.emitError(t)),e.onClose(()=>this.handleTransportClose())];try{await e.start();let t={...this.options.capabilities};this.options.roots&&t.roots===void 0&&(t.roots={});let r=Xe(await this.requestInternal("initialize",{protocolVersion:this.options.protocolVersion??te,capabilities:t,clientInfo:{name:this.options.name,version:this.options.version,...this.options.title===void 0?{}:{title:this.options.title}}},{},!0));if(!xe.includes(r.protocolVersion))throw new Error(`MCP server selected unsupported protocol version ${r.protocolVersion}`);return this.protocolVersionValue=r.protocolVersion,this.serverInfoValue=r.serverInfo,this.serverCapabilitiesValue=r.capabilities,this.instructionsValue=r.instructions,e.setProtocolVersion?.(r.protocolVersion),await this.notifyInternal("notifications/initialized",void 0,!0),this.state="connected",r}catch(t){throw await this.close().catch(()=>{}),t}}request(e,t,r={}){return this.requestInternal(e,t,r,!1)}notify(e,t){return this.notifyInternal(e,t,!1)}setRequestHandler(e,t){return this.requestHandlers.set(e,t),()=>{this.requestHandlers.get(e)===t&&this.requestHandlers.delete(e)}}onNotification(e,t){let r=this.notificationListeners.get(e)??new Set;return this.notificationListeners.set(e,r),r.add(t),()=>{r.delete(t),r.size===0&&this.notificationListeners.delete(e)}}onError(e){return this.errorListeners.add(e),()=>this.errorListeners.delete(e)}onClose(e){return this.closeListeners.add(e),()=>this.closeListeners.delete(e)}async ping(e={}){await this.request("ping",void 0,e)}async listTools(e={}){return await this.listAll("tools/list","tools",Ze,e)}async listResources(e={}){return(await this.listAll("resources/list","resources",ve,e)).map(be)}async listResourcesPage(e,t={}){let r=await this.listPage("resources/list","resources",ve,e,t);return{resources:r.items.map(be),...Me(r)}}async listResourceTemplates(e={}){return(await this.listAll("resources/templates/list","resourceTemplates",Ce,e)).map(Pe)}async listResourceTemplatesPage(e,t={}){let r=await this.listPage("resources/templates/list","resourceTemplates",Ce,e,t);return{resourceTemplates:r.items.map(Pe),...Me(r)}}async readResource(e,t={}){return Ke(await this.request("resources/read",{uri:e},t))}async listPage(e,t,r,n,i){return Ye(e,t,await this.request(e,n===void 0?void 0:{cursor:n},i),r)}async listAll(e,t,r,n){let i=[],o=new Set,a;for(let d=0;d<Re;d++){let c=await this.listPage(e,t,r,a,n);if(i.push(...c.items),c.nextCursor===void 0)return i;if(o.has(c.nextCursor))throw new Error(`MCP ${e} returned duplicate cursor: ${c.nextCursor}`);o.add(c.nextCursor),a=c.nextCursor}throw new Error(`MCP ${e} exceeded ${Re} pages`)}async callTool(e,t,r={}){return Qe(await this.request("tools/call",{name:e,...t===void 0?{}:{arguments:t}},r))}async close(){let e=this.transport;this.transport=void 0,this.disposeTransportListeners(),this.markClosed(new p),await e?.close()}async requestInternal(e,t,r,n){let i=this.requireTransport(n);if(r.signal?.aborted)throw new S;let o=this.nextRequestId++,a=r.onProgress?o:void 0,d=a===void 0?t:{...t,_meta:{...u(t?._meta)?t._meta:{},progressToken:a}},c={jsonrpc:"2.0",id:o,method:e,...d===void 0?{}:{params:d}};return new Promise((l,x)=>{let f={resolve:l,reject:x,timeoutMs:r.timeoutMs??this.options.requestTimeoutMs??We,timer:void 0,signal:r.signal,onAbort:()=>this.cancelPending(o,new S,e!=="initialize",String(r.signal?.reason??"Aborted")),sendController:new AbortController,cancellable:e!=="initialize",onProgress:r.onProgress,progressToken:a};this.pending.set(o,f),a!==void 0&&this.progressRequests.set(a,o),r.signal?.addEventListener("abort",f.onAbort,{once:!0}),this.armTimeout(o,f),i.send(c,{signal:f.sendController.signal}).catch(h=>this.cancelPending(o,h,!1))})}async notifyInternal(e,t,r){await this.requireTransport(r).send({jsonrpc:"2.0",method:e,...t===void 0?{}:{params:t}})}requireTransport(e){if(this.transport&&(this.state==="connected"||e&&this.state==="connecting"))return this.transport;throw new p(`MCP client is ${this.state}`)}handleMessage(e){if(P(e)){this.handleResponse(e);return}if(b(e)){this.handleRequest(e);return}if(U(e)){this.handleNotification(e.method,e.params);return}this.emitError(new y(w.invalidRequest,"Received invalid JSON-RPC message"))}handleResponse(e){let t=this.pending.get(e.id);if(!t){this.emitError(new Error(`Received response for unknown MCP request ${String(e.id)}`));return}this.removePending(e.id,t),"error"in e?t.reject(new y(e.error.code,e.error.message,e.error.data)):t.resolve(e.result)}async handleRequest(e){let t=this.transport;if(!t)return;let r=this.requestHandlers.get(e.method);if(!r){await t.send({jsonrpc:"2.0",id:e.id,error:{code:w.methodNotFound,message:`Method not found: ${e.method}`}}).catch(i=>this.emitError(i));return}let n=new AbortController;this.incoming.set(e.id,n);try{let i=await r(e.params,{signal:n.signal});await t.send({jsonrpc:"2.0",id:e.id,result:i??{}})}catch(i){let o=i instanceof y?{code:i.code,message:i.message,data:i.data}:{code:w.internalError,message:R(i).message};await t.send({jsonrpc:"2.0",id:e.id,error:o}).catch(a=>this.emitError(a))}finally{this.incoming.delete(e.id)}}handleNotification(e,t){e==="notifications/progress"?this.handleProgress(t):e==="notifications/cancelled"&&this.handleCancelled(t);for(let r of this.notificationListeners.get(e)??[])try{r(t)}catch(n){this.emitError(n)}}handleProgress(e){if(!u(e)||!D(e.progressToken)||typeof e.progress!="number")return;let t=this.progressRequests.get(e.progressToken),r=t===void 0?void 0:this.pending.get(t);if(!(t===void 0||!r)){this.armTimeout(t,r);try{r.onProgress?.(e)}catch(n){this.emitError(n)}}}handleCancelled(e){u(e)&&D(e.requestId)&&this.incoming.get(e.requestId)?.abort(e.reason)}armTimeout(e,t){t.timer&&clearTimeout(t.timer),!(!Number.isFinite(t.timeoutMs)||t.timeoutMs<=0)&&(t.timer=setTimeout(()=>{this.cancelPending(e,new V(t.timeoutMs),t.cancellable,"Request timed out")},t.timeoutMs))}cancelPending(e,t,r,n){let i=this.pending.get(e);i&&(this.removePending(e,i),i.reject(t),r&&this.transport&&this.transport.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:e,...n?{reason:n}:{}}}).catch(o=>this.emitError(o)))}removePending(e,t){this.pending.delete(e),t.timer&&clearTimeout(t.timer),t.progressToken!==void 0&&this.progressRequests.delete(t.progressToken),t.signal?.removeEventListener("abort",t.onAbort),t.sendController.abort()}rejectPending(e){for(let[t,r]of this.pending)this.removePending(t,r),r.reject(e)}handleTransportClose(){this.markClosed(new p)}markClosed(e){let t=this.state==="closed";this.state="closed",this.rejectPending(e);for(let r of this.incoming.values())r.abort(e);if(this.incoming.clear(),!t)for(let r of[...this.closeListeners])try{r()}catch(n){this.emitError(n)}}emitError(e){let t=R(e);for(let r of this.errorListeners)r(t)}disposeTransportListeners(){for(let e of this.disposers.splice(0))e()}};var Ae=ce(Oe(),1);import{spawn as et}from"node:child_process";import A from"node:process";var k=16*1024*1024,T=class{messageListeners=new Set;errorListeners=new Set;closeListeners=new Set;closeEmitted=!1;onMessage(e){return this.messageListeners.add(e),()=>this.messageListeners.delete(e)}onError(e){return this.errorListeners.add(e),()=>this.errorListeners.delete(e)}onClose(e){return this.closeListeners.add(e),()=>this.closeListeners.delete(e)}emitMessage(e){for(let t of this.messageListeners)t(e)}emitError(e){let t=R(e);for(let r of this.errorListeners)r(t)}emitClose(){if(!this.closeEmitted){this.closeEmitted=!0;for(let e of this.closeListeners)e()}}};var tt=64*1024,rt=2e3,st=500,ne=A.platform!=="win32",ie=new Set,Te=!1;function se(s,e){let t=s.pid;if(A.platform==="win32"&&t!==void 0){if(s.exitCode!==null)return;et("taskkill",["/pid",String(t),"/T","/F"],{stdio:"ignore",windowsHide:!0}).on("error",()=>{});return}if(ne&&t!==void 0)try{A.kill(-t,e);return}catch{}try{s.kill(e)}catch{}}function nt(){Te||(Te=!0,A.once("exit",()=>{for(let s of ie)try{A.kill(-s,"SIGTERM")}catch{}}))}var oe=class extends T{options;child;stdoutBuffer=Buffer.alloc(0);stderrBuffer=Buffer.alloc(0);started=!1;closed=!1;constructor(e){super(),this.options=Object.freeze({...e,args:e.args?[...e.args]:void 0})}get pid(){return this.child?.pid}get stderr(){return this.stderrBuffer.toString("utf8")}async start(){if(this.started)throw new Error("MCP stdio transport already started");if(this.closed)throw new p;this.started=!0;let e=this.options.inheritEnv===!1?{...this.options.env}:{...A.env,...this.options.env},t=(0,Ae.default)(this.options.command,this.options.args??[],{cwd:this.options.cwd,env:e,stdio:["pipe","pipe",this.options.stderr==="inherit"?"inherit":"pipe"],windowsHide:!0,detached:ne});this.child=t;let r=t.pid;ne&&r!==void 0&&(nt(),ie.add(r),t.once("exit",()=>ie.delete(r))),t.stdout?.on("data",n=>this.handleStdout(n)),t.stdout?.on("error",n=>this.emitError(n)),t.stdin?.on("error",n=>{this.closed||this.emitError(n)}),t.stderr?.on("data",n=>this.handleStderr(n)),t.stderr?.on("error",n=>this.emitError(n)),t.on("close",()=>{this.child=void 0,this.stdoutBuffer.toString("utf8").trim()&&this.emitError(new Error("MCP stdio server closed with an incomplete JSON-RPC message")),this.stdoutBuffer=Buffer.alloc(0),this.emitClose()}),await new Promise((n,i)=>{let o=()=>{t.off("error",a),n()},a=d=>{t.off("spawn",o),i(d)};t.once("spawn",o),t.once("error",a)}),t.on("error",n=>{this.closed||this.emitError(n)})}async send(e){let t=this.child?.stdin;if(!this.started||this.closed||!t?.writable)throw new p;let r=`${JSON.stringify(e)}
|
|
5
|
-
`;await new Promise((n,i)=>{t.write(r,o=>o?i(o):n())})}async close(){if(this.closed)return;this.closed=!0;let e=this.child;if(!e){this.emitClose();return}if(e.exitCode!==null||e.signalCode!==null){e.stdin?.end();return}let t=this.options.closeTimeoutMs??rt;await new Promise(r=>{let n=[];e.once("close",()=>{for(let o of n)clearTimeout(o);se(e,"SIGTERM"),r()});let i=Math.min(st,t);n.push(setTimeout(()=>se(e,"SIGTERM"),i)),n.push(setTimeout(()=>se(e,"SIGKILL"),i+t)),e.stdin?.end()})}handleStdout(e){this.stdoutBuffer=Buffer.concat([this.stdoutBuffer,Buffer.isBuffer(e)?e:Buffer.from(e)]);let t=this.options.maxMessageBytes??k;for(;;){let r=this.stdoutBuffer.indexOf(10);if(r<0){this.stdoutBuffer.length>t&&(this.stdoutBuffer=Buffer.alloc(0),this.emitError(new Error(`MCP stdio message exceeds ${t} bytes`)));return}let n=this.stdoutBuffer.subarray(0,r);if(this.stdoutBuffer=this.stdoutBuffer.subarray(r+1),n.length>t){this.emitError(new Error(`MCP stdio message exceeds ${t} bytes`));continue}let i=n.toString("utf8").replace(/\r$/,"");if(i.trim())try{this.emitMessage(M(JSON.parse(i)))}catch(o){this.emitError(o)}}}handleStderr(e){let t=Buffer.isBuffer(e)?e:Buffer.from(e),r=this.options.maxStderrBytes??tt;this.stderrBuffer=Buffer.concat([this.stderrBuffer,t]),this.stderrBuffer.length>r&&(this.stderrBuffer=this.stderrBuffer.subarray(-r)),this.options.onStderr?.(t.toString("utf8"))}};var it=8*1024,_e=500,ot=1e3,at=3e4,ct=5;async function dt(s,e){let t=s.getReader(),r=new TextDecoder,n="",i,o,a=[],d=0,c=e.maxEventBytes??k,l=()=>{if(a.length===0){i=void 0,o=void 0;return}let f=a.join(`
|
|
6
|
-
`);e.onEvent({...i?{event:i}:{},data:f,...o?{id:o}:{}}),i=void 0,o=void 0,a=[],d=0},x=f=>{let h=f.endsWith("\r")?f.slice(0,-1):f;if(h===""){l();return}if(h.startsWith(":"))return;let g=h.indexOf(":"),q=g<0?h:h.slice(0,g),m=g<0?"":h.slice(g+1);if(m.startsWith(" ")&&(m=m.slice(1)),q==="data"){if(d+=Buffer.byteLength(m)+(a.length>0?1:0),d>c)throw new Error(`MCP SSE event exceeds ${c} bytes`);a.push(m)}else q==="event"?i=m:q==="id"&&!m.includes("\0")?(o=m,e.onId?.(m)):q==="retry"&&/^\d+$/.test(m)&&e.onRetry?.(Number(m))};try{for(;;){let{done:f,value:h}=await t.read();if(f)break;n+=r.decode(h,{stream:!0});let g=n.indexOf(`
|
|
7
|
-
`);for(;g>=0;)x(n.slice(0,g)),n=n.slice(g+1),g=n.indexOf(`
|
|
8
|
-
`);if(Buffer.byteLength(n)>c)throw new Error(`MCP SSE event exceeds ${c} bytes`)}n+=r.decode(),n&&x(n),l()}finally{t.releaseLock()}}var E=class extends Error{status;body;constructor(e,t,r=""){super(t),this.name="McpHttpError",this.status=e,this.body=r}},z=class extends E{wwwAuthenticate;constructor(e,t=""){super(401,"MCP server requires authentication",t),this.name="McpAuthRequiredError",this.wwwAuthenticate=e.headers.get("www-authenticate")}},H=class extends E{constructor(e=""){super(404,"MCP session expired",e),this.name="McpSessionExpiredError"}};function Ie(s){return s.headers.get("content-type")?.split(";",1)[0]?.trim().toLowerCase()}function ut(s){return s.status===401?!0:s.status!==403?!1:/(?:^|[\s,])error="?insufficient_scope"?/i.test(s.headers.get("www-authenticate")??"")}function lt(s){return s===408||s===429||s>=500}function _(s){return s.body?.cancel().catch(()=>{})??Promise.resolve()}function ft(s,e){let t=e.trim(),r=t.length>_e?`${t.slice(0,_e-3)}...`:t;return`MCP HTTP request failed with status ${s}${r?`: ${r}`:""}`}var ae=class extends T{url;options;fetch;controller=new AbortController;started=!1;closed=!1;sessionIdValue;protocolVersion;getStreamStarted=!1;lastToken;constructor(e){super(),this.options=Object.freeze({...e,headers:e.headers?{...e.headers}:void 0}),this.url=new URL(e.url);let t=e.fetch??globalThis.fetch;this.fetch=(r,n)=>t(r,n)}get sessionId(){return this.sessionIdValue}async start(){if(this.started)throw new Error("MCP Streamable HTTP transport already started");if(this.closed)throw new p;this.started=!0}setProtocolVersion(e){this.protocolVersion=e}async send(e,{signal:t}={}){if(!this.started||this.closed)throw new p;let r=await this.authorizedFetch("POST",{headers:{accept:"application/json, text/event-stream","content-type":"application/json"},body:JSON.stringify(e)},t);if(await this.checkResponse(r),this.captureSession(r),!b(e)){await _(r),"method"in e&&e.method==="notifications/initialized"&&this.startGetStream();return}if(r.status===202||r.status===204)throw new E(r.status,`MCP server accepted request ${e.method} without a response`);let n=Ie(r);if(n==="application/json"){let i=await r.json();for(let o of Array.isArray(i)?i:[i])this.emitMessage(M(o));return}if(n==="text/event-stream"&&r.body){this.consumeResponseStream(r.body,e.id);return}throw await _(r),new E(r.status,`Unsupported MCP response content type: ${n??"missing"}`)}async close(){if(!this.closed){if(this.closed=!0,this.controller.abort(),this.started&&this.sessionIdValue)try{let e=await this.fetch(this.url,{method:"DELETE",headers:this.buildHeaders({},this.lastToken),signal:AbortSignal.timeout(1e3)});await _(e)}catch{}this.emitClose()}}async authorizedFetch(e,t,r){let n=this.options.authProvider?.onUnauthorized?.bind(this.options.authProvider);for(let i=0;;i++){let{headers:o,token:a}=await this.headers(t.headers);if(r?.aborted)throw new S;let d=await this.fetch(this.url,{method:e,headers:o,body:t.body,signal:this.controller.signal});if(i>0||!n||!ut(d))return d;try{await n({response:d,serverUrl:this.url,fetch:this.fetch,token:a})}finally{await _(d)}}}async headers(e={}){let t=await this.options.authProvider?.token();return this.lastToken=t,{headers:this.buildHeaders(e,t),...t?{token:t}:{}}}buildHeaders(e,t){let r=new Headers(this.options.headers);for(let[n,i]of Object.entries(e))r.set(n,i);return this.sessionIdValue&&r.set("Mcp-Session-Id",this.sessionIdValue),this.protocolVersion&&r.set("MCP-Protocol-Version",this.protocolVersion),t&&r.set("Authorization",`Bearer ${t}`),r}captureSession(e){let t=e.headers.get("mcp-session-id");t&&(this.sessionIdValue=t)}async checkResponse(e){if(e.ok)return;let t=(await e.text().catch(()=>"")).slice(0,it);throw e.status===401?new z(e,t):e.status===404&&this.sessionIdValue?new H(t):new E(e.status,ft(e.status,t),t)}async consumeSse(e,t,r){await dt(e,{maxEventBytes:this.options.maxMessageBytes??k,onId:n=>{t.lastEventId=n},onRetry:n=>{t.retryMs=n},onEvent:n=>{if(t.received=!0,!n.data.trim()||n.event!==void 0&&n.event!=="message")return;let i;try{i=M(JSON.parse(n.data))}catch(o){this.emitError(o);return}r?.(i),this.emitMessage(i)}})}async consumeResponseStream(e,t){let r={lastEventId:void 0,retryMs:void 0,received:!1},n=!1,i=c=>{P(c)&&c.id===t&&(n=!0)},o=e,a;for(let c=0;;){if(o)try{await this.consumeSse(o,r,i),a=void 0}catch(l){a=l}if(n||this.closed)return;if(a!==void 0&&!this.isRetryable(a)||r.lastEventId===void 0||c>=this.maxRetries())break;if(r.received&&(c=0),r.received=!1,!await this.sleep(this.reconnectDelay(c++,r.retryMs)))return;try{o=await this.openSseStream(r.lastEventId)}catch(l){if(a=l,!this.isRetryable(l))break;o=void 0}}if(this.closed)return;let d=a===void 0?"stream ended without a response":R(a).message;this.emitMessage({jsonrpc:"2.0",id:t,error:{code:w.internalError,message:`MCP response stream failed: ${d}`}})}startGetStream(){this.options.openGetStream===!1||this.getStreamStarted||this.closed||(this.getStreamStarted=!0,this.runGetStream())}async runGetStream(){let e={lastEventId:void 0,retryMs:void 0,received:!1};for(let t=0;!this.closed;){try{let r=await this.openSseStream(e.lastEventId);if(!r)return;let n=Date.now();await this.consumeSse(r,e),(e.received||Date.now()-n>this.maxDelay())&&(t=0)}catch(r){if(this.closed)return;if(!this.isRetryable(r)){this.emitError(r);return}}if(e.received=!1,t>=this.maxRetries()){this.emitError(new Error("MCP server-to-client stream dropped and could not be reopened"));return}if(!await this.sleep(this.reconnectDelay(t++,e.retryMs)))return}}async openSseStream(e){let t=await this.authorizedFetch("GET",{headers:{accept:"text/event-stream",...e===void 0?{}:{"last-event-id":e}}});if(t.status===405){await _(t);return}await this.checkResponse(t),this.captureSession(t);let r=Ie(t);if(r!=="text/event-stream"||!t.body)throw await _(t),new E(t.status,`Unsupported MCP GET response content type: ${r??"missing"}`);return t.body}isRetryable(e){if(e instanceof E)return lt(e.status);if(e instanceof TypeError)return!0;let t=e?.code;return typeof t=="string"&&(t.startsWith("E")||t.startsWith("UND_ERR"))}reconnectDelay(e,t){if(t!==void 0)return t;let r=this.options.reconnect?.initialDelayMs??ot;return Math.min(r*2**e,this.maxDelay())}maxDelay(){return this.options.reconnect?.maxDelayMs??at}maxRetries(){return this.options.reconnect?.maxRetries??ct}sleep(e){let t=this.controller.signal;return t.aborted?Promise.resolve(!1):new Promise(r=>{let n=()=>{clearTimeout(i),r(!1)},i=setTimeout(()=>{t.removeEventListener("abort",n),r(!0)},e);i.unref?.(),t.addEventListener("abort",n,{once:!0})})}};function ht(s){switch(s.type){case"text":return{type:"text",text:s.text};case"image":return{type:"image",data:s.data,mimeType:s.mimeType};case"audio":return{type:"text",text:`[audio ${s.mimeType} omitted]`};case"resource_link":return{type:"text",text:`${s.name}: ${s.uri}`};case"resource":{let e=s.resource;return"text"in e?{type:"text",text:e.text}:e.mimeType?.startsWith("image/")?{type:"image",data:e.blob,mimeType:e.mimeType}:{type:"text",text:`[binary resource ${e.uri} (${e.mimeType??"unknown type"}) omitted]`}}default:return{type:"text",text:`[unsupported MCP content ${s.type}]`}}}function pt(s){let e=(s.content??[]).map(ht);return e.length===0&&s.structuredContent!==void 0&&e.push({type:"text",text:JSON.stringify(s.structuredContent,null,2)}),e}export{je as a,pe as b,wt as c,Ue as d,Et as e,St as f,X as g,Q as h,ge as i,Se as j,_t as k,w as l,y as m,u as n,te as o,re as p,pt as q,oe as r,E as s,z as t,H as u,ae as v};
|
|
@@ -1,6 +0,0 @@
|
|
|
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 i,b as m}from"./chunk-7MU2AKNM.js";import{f as g}from"./chunk-LMSQZ6TQ.js";import{e as f,f as y}from"./chunk-BGVHA2D4.js";import{e as l}from"./chunk-NAA7GF6Q.js";import{mkdirSync as a,existsSync as u,readFileSync as D,writeFileSync as S,lstatSync as h,readlinkSync as d,unlinkSync as I,symlinkSync as _,copyFileSync as x}from"fs";import*as o from"path";var p=l("pi-agent-dir"),j=f(),O=y();function N(t){let r=t?.userAuthPath??j,n=t?.agentDir??i,e=o.join(n,"auth.json");if(u(r)){if(a(n,{recursive:!0}),u(e)||R(e))try{if(h(e).isSymbolicLink()&&d(e)===r&&process.platform!=="win32")return;I(e)}catch(s){p.warn(`Failed to inspect/remove existing ${e}: ${s.message}`);return}process.platform==="win32"?x(r,e):_(r,e)}}function R(t){try{return h(t).isSymbolicLink()?!u(t):!1}catch{return!1}}var k=o.join(i,"agents");function $(t){g({defaultsDir:t?.defaultsDir,rolesDir:t?.rolesDir,legacyDir:t?.legacyDir??k})}function T(){a(i,{recursive:!0}),a(m,{recursive:!0}),$(),E()}function E(t){let r=o.join(t?.agentDir??i,"settings.json"),n=A(r);if(n.transport!=="sse")try{S(r,`${JSON.stringify({...n,transport:"sse"},null,2)}
|
|
5
|
-
`)}catch(e){p.warn(`Failed to pin PI transport in ${r}: ${e.message}`)}}function U(t,r){let n=o.join(r?.agentDir??i,"settings.json"),e=A(n),s=e.compaction,c=s&&typeof s=="object"&&!Array.isArray(s)?s:{};if(c.reserveTokens!==t)try{S(n,`${JSON.stringify({...e,compaction:{...c,reserveTokens:t}},null,2)}
|
|
6
|
-
`)}catch(P){p.warn(`Failed to set PI compaction reserve in ${n}: ${P.message}`)}}function A(t){try{let r=JSON.parse(D(t,"utf-8"));return r&&typeof r=="object"&&!Array.isArray(r)?r:{}}catch{return{}}}export{O as a,N as b,$ as c,T as d,U as e};
|
|
@@ -1,4 +0,0 @@
|
|
|
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 a=["anthropic-messages","openai-completions","openai-responses","google-generative-ai"],c=/^[a-zA-Z0-9_-]+$/,p="cortex-gateway",m={"anthropic-messages":"anthropic","openai-completions":"openai","openai-responses":"openai","google-generative-ai":"google"};function f(e){return m[e]}function d(e,o){return e==="anthropic-messages"?"anthropic":o}function u(e,o,s){return`${e.replace(/\/+$/,"")}/m/${o}/${d(s,o)}`}function l(e){let o=[],s=e.name?.trim()??"";s?c.test(s)||o.push("name-charset"):o.push("name-required"),a.includes(e.api)||o.push("api-invalid");let n=e.upstreamUrl?.trim()??"";n?/^https?:\/\/\S+$/i.test(n)||o.push("upstream-scheme"):o.push("upstream-required");let t=e.models??[];if(t.length===0)o.push("models-required");else{let r=t.map(i=>i.id?.trim()??"");r.some(i=>!i)?o.push("model-id-required"):new Set(r).size!==r.length&&o.push("model-id-duplicate")}return o}function g(e){return{...e,name:e.name?.trim()??"",upstreamUrl:e.upstreamUrl?.trim()??"",models:(e.models??[]).map(o=>({...o,id:o.id?.trim()??""}))}}function h(e,o){let s={baseUrl:u(o,e.name,e.api),api:e.api,apiKey:p,models:e.models.map(n=>{let t={id:n.id};return n.contextWindow!==void 0&&(t.contextWindow=n.contextWindow),n.maxTokens!==void 0&&(t.maxTokens=n.maxTokens),n.reasoning!==void 0&&(t.reasoning=n.reasoning),t})};return e.headers&&Object.keys(e.headers).length>0&&(s.headers=e.headers),e.compat&&Object.keys(e.compat).length>0&&(s.compat=e.compat),s}function x(e){return(Array.isArray(e.models)?e.models:[]).filter(s=>!!s&&typeof s=="object").map(s=>{let n={id:String(s.id??"")};return typeof s.contextWindow=="number"&&(n.contextWindow=s.contextWindow),typeof s.maxTokens=="number"&&(n.maxTokens=s.maxTokens),typeof s.reasoning=="boolean"&&(n.reasoning=s.reasoning),n})}export{a,c as b,f as c,d,l as e,g as f,h as g,x as h};
|
|
@@ -1,4 +0,0 @@
|
|
|
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 f=new Set;function g(r){return f.add(r),()=>{f.delete(r)}}function l(r){let t=[];for(let s of f)try{s(r)}catch(e){t.push(e)}if(t.length>0)throw new AggregateError(t,"Failed to cleanup session resources")}var a=(1n<<41n)-1n,u=-1,n;function x(r){let t=r??Date.now();if(!Number.isInteger(t)||t<0||t>0xffffffffffff)throw new RangeError(`UUIDv7 timestamp must be an integer between 0 and ${0xffffffffffff}`);let s=r===void 0?Math.max(t,u):r;r===void 0&&(u=s);let e=new Uint8Array(16);if(globalThis.crypto.getRandomValues(e),n===void 0)n=BigInt(e[1])<<32n|BigInt(e[2])<<24n|BigInt(e[3])<<16n|BigInt(e[4])<<8n|BigInt(e[5]);else{if(n===a)throw new RangeError("UUIDv7 generator sequence exhausted");n++}let c=BigInt(s);for(let o=5;o>=0;o--)e[o]=Number(c>>BigInt((5-o)*8))&255;e[6]=112|Number(n>>37n&0x0fn),e[7]=Number(n>>29n&0xffn),e[8]=128|Number(n>>23n&0x3fn),e[9]=Number(n>>15n&0xffn),e[10]=Number(n>>7n&0xffn),e[11]=Number((n&0x7fn)<<1n)|e[11]&1;let i=Array.from(e,o=>o.toString(16).padStart(2,"0"));return`${i.slice(0,4).join("")}-${i.slice(4,6).join("")}-${i.slice(6,8).join("")}-${i.slice(8,10).join("")}-${i.slice(10).join("")}`}export{g as a,l as b,x as c};
|
|
@@ -1,92 +0,0 @@
|
|
|
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 K}from"./chunk-JERCOLY3.js";import{e as x}from"./chunk-WHC7AYZD.js";var g=x(K(),1);import*as _ from"fs";import*as m from"path";import*as E from"os";var v=m.join(E.homedir(),".aistatus"),T=m.join(v,"gateway.yaml"),A=100,C=new Set(["host","port","mode","auth","status_check","max_body_size_mb","websocket","endpoint_modes","endpoints"]),P={anthropic:"https://api.anthropic.com",openai:"https://api.openai.com",google:"https://generativelanguage.googleapis.com","openai-codex":"https://chatgpt.com/backend-api",deepseek:"https://api.deepseek.com"},I={anthropic:["x-api-key",""],openai:["authorization","Bearer "],bearer:["authorization","Bearer "],google:["x-goog-api-key",""]},Y={ANTHROPIC_API_KEY:"anthropic",OPENAI_API_KEY:"openai",GEMINI_API_KEY:"google",DEEPSEEK_API_KEY:"deepseek"},w={openrouter:{base_url:"https://openrouter.ai/api/v1",env:"OPENROUTER_API_KEY"},deepseek:{base_url:"https://api.deepseek.com",env:"DEEPSEEK_API_KEY"},together:{base_url:"https://api.together.xyz/v1",env:"TOGETHER_API_KEY"},groq:{base_url:"https://api.groq.com/openai/v1",env:"GROQ_API_KEY"}};function O(e){return typeof e=="string"&&e.startsWith("$")?process.env[e.slice(1)]??"":e}function S(e){let t=[];for(let a of e){let s=O(String(a));s&&t.push(s)}return t}function N(e){if(e==null)return{};if(typeof e!="object"||Array.isArray(e))throw new Error("model_fallbacks must be a mapping");let t={};for(let[a,s]of Object.entries(e)){let n=String(a).trim();if(!n)throw new Error("source model must be a non-empty string");if(!Array.isArray(s)||s.length===0)throw new Error(`model_fallbacks[${JSON.stringify(n)}] fallback list must be a non-empty list`);let o=[];for(let u of s){let i=String(u).trim();if(!i)throw new Error(`model_fallbacks[${JSON.stringify(n)}] fallback target must be a non-empty string`);o.push(i)}t[n]=o}return t}function k(e,t){let a=S(t.keys??[]),s=t.auth_style??(e in I?e:"bearer"),n=t.base_url??P[e]??"",o=[];for(let r of t.fallbacks??[]){let h=O(r.key??r.api_key??"");o.push({name:r.name??"fallback",base_url:r.base_url,api_key:h,auth_style:r.auth_style??"bearer",model_prefix:r.model_prefix??"",model_map:r.model_map??{},translate:r.translate??null})}let u=t.passthrough!==!1,i=N(t.model_fallbacks);return{name:e,base_url:n,auth_style:s,keys:a,passthrough:u,fallbacks:o,model_fallbacks:i}}function R(e){return!e||typeof e!="object"||Array.isArray(e)?!1:Object.keys(e).some(a=>["keys","base_url","auth_style","passthrough","fallbacks","model_fallbacks"].includes(a))}function D(e){if(e===void 0)return A;if(typeof e!="number"||!Number.isFinite(e)||e<=0)throw new Error("max_body_size_mb must be a finite number greater than zero");return e}function j(e){let t=e.host??"127.0.0.1",a=e.port??9880,s=e.status_check!==!1,n=e.websocket!==!1,o=D(e.max_body_size_mb),u={},i=[];for(let c of Object.keys(e)){if(C.has(c))continue;let l=e[c];if(!(!l||typeof l!="object"||Array.isArray(l))){if(R(l)){u.default??={},u.default[c]=k(c,l);continue}for(let[f,d]of Object.entries(l))!d||typeof d!="object"||Array.isArray(d)||(u[f]??={},u[f][c]=k(c,d),i.includes(f)||i.push(f))}}let r=Object.keys(u),h=e.mode??i[0]??r[0]??"default",b=u[h]?h:r[0]??"default";u[b]??={};let y,p=e.auth;if(p){let c=S(p.keys??[]);y={enabled:p.enabled!==!1&&c.length>0,keys:c,header:p.header??"authorization",public_paths:p.public_paths??["/health"]}}return{host:t,port:a,status_check:s,websocket:n,max_body_size_mb:o,mode:b,auth:y,endpoints:u[b],endpoint_modes:u}}function z(e="127.0.0.1",t=9880){let a={};for(let[n,o]of Object.entries(Y)){let u=process.env[n];if(!u)continue;let i=o in I?o:"bearer",r=P[o]??"";a[o]={name:o,base_url:r,auth_style:i,keys:[u],passthrough:!0,fallbacks:[],model_fallbacks:{}}}let s=process.env.OPENROUTER_API_KEY;if(s){let n=w.openrouter.base_url;for(let[o,u]of Object.entries(a)){let i=o!=="openai"?`${o}/`:"openai/",r=o==="anthropic"?"anthropic-to-openai":null;u.fallbacks.push({name:"openrouter",base_url:n,api_key:s,model_prefix:i,model_map:{},auth_style:"bearer",translate:r})}}return{host:e,port:t,status_check:!0,websocket:!0,max_body_size_mb:A,mode:"default",endpoints:a,endpoint_modes:{default:a}}}function M(e){let t=e??T;if(!_.existsSync(t))return z();let a=_.readFileSync(t,"utf-8"),s=g.default.parse(a)??{};return j(s)}function $(){return`# aistatus gateway configuration
|
|
5
|
-
# Docs: https://aistatus.cc/docs
|
|
6
|
-
#
|
|
7
|
-
# After editing, start with:
|
|
8
|
-
# npx aistatus-gateway start
|
|
9
|
-
#
|
|
10
|
-
# Or skip this file entirely with auto-discovery:
|
|
11
|
-
# npx aistatus-gateway start --auto
|
|
12
|
-
|
|
13
|
-
port: 9880
|
|
14
|
-
max_body_size_mb: 100
|
|
15
|
-
|
|
16
|
-
# Proxy WebSocket upgrades as well as HTTP (default true). Clients that speak both \u2014 such as
|
|
17
|
-
# PI's Codex backend \u2014 fall back to SSE over HTTP when this is off.
|
|
18
|
-
# websocket: true
|
|
19
|
-
|
|
20
|
-
# \u2500\u2500 Authentication \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
21
|
-
# auth:
|
|
22
|
-
# keys:
|
|
23
|
-
# - $GATEWAY_API_KEY
|
|
24
|
-
# # header: authorization # default: Bearer scheme
|
|
25
|
-
# # public_paths: ["/health"] # default
|
|
26
|
-
|
|
27
|
-
# \u2500\u2500 Anthropic (for Claude Code) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
28
|
-
anthropic:
|
|
29
|
-
# Multiple keys \u2192 automatic rotation on rate-limit / 5xx
|
|
30
|
-
keys:
|
|
31
|
-
- $ANTHROPIC_API_KEY
|
|
32
|
-
# - sk-ant-your-second-key
|
|
33
|
-
|
|
34
|
-
# Hybrid mode: when true (default), the caller's own API key is
|
|
35
|
-
# tried after managed keys, before fallbacks.
|
|
36
|
-
# Set to false to use only managed keys.
|
|
37
|
-
# Automatic model-level degradation order.
|
|
38
|
-
# When a model is unhealthy, later tasks can switch to the first healthy fallback.
|
|
39
|
-
# model_fallbacks:
|
|
40
|
-
# claude-opus-4-6:
|
|
41
|
-
# - claude-sonnet-4-6
|
|
42
|
-
# - claude-haiku-4-5
|
|
43
|
-
|
|
44
|
-
fallbacks:
|
|
45
|
-
# OpenRouter serves Claude models via OpenAI-compatible API
|
|
46
|
-
- name: openrouter
|
|
47
|
-
base_url: https://openrouter.ai/api/v1
|
|
48
|
-
key: $OPENROUTER_API_KEY
|
|
49
|
-
model_prefix: "anthropic/"
|
|
50
|
-
translate: anthropic-to-openai
|
|
51
|
-
|
|
52
|
-
# \u2500\u2500 OpenAI (for Codex) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
53
|
-
openai:
|
|
54
|
-
keys:
|
|
55
|
-
- $OPENAI_API_KEY
|
|
56
|
-
|
|
57
|
-
fallbacks:
|
|
58
|
-
- name: openrouter
|
|
59
|
-
base_url: https://openrouter.ai/api/v1
|
|
60
|
-
key: $OPENROUTER_API_KEY
|
|
61
|
-
model_prefix: "openai/"
|
|
62
|
-
|
|
63
|
-
# DeepSeek as budget fallback (different models)
|
|
64
|
-
# - name: deepseek
|
|
65
|
-
# base_url: https://api.deepseek.com
|
|
66
|
-
# key: $DEEPSEEK_API_KEY
|
|
67
|
-
# model_map:
|
|
68
|
-
# gpt-4o: deepseek-chat
|
|
69
|
-
# gpt-4o-mini: deepseek-chat
|
|
70
|
-
|
|
71
|
-
# \u2500\u2500 OpenAI Codex (ChatGPT Plus/Pro OAuth subscription) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
72
|
-
# Codex uses OAuth bearer tokens tied to a ChatGPT subscription, NOT a static
|
|
73
|
-
# API key. The gateway transparently passes through the caller's own bearer
|
|
74
|
-
# token; no managed keys are set here.
|
|
75
|
-
openai-codex:
|
|
76
|
-
base_url: https://chatgpt.com/backend-api
|
|
77
|
-
auth_style: bearer
|
|
78
|
-
passthrough: true
|
|
79
|
-
|
|
80
|
-
# \u2500\u2500 DeepSeek \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
81
|
-
deepseek:
|
|
82
|
-
keys:
|
|
83
|
-
- $DEEPSEEK_API_KEY
|
|
84
|
-
base_url: https://api.deepseek.com
|
|
85
|
-
auth_style: bearer
|
|
86
|
-
passthrough: true
|
|
87
|
-
|
|
88
|
-
# \u2500\u2500 Google (for Gemini CLI) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
89
|
-
# google:
|
|
90
|
-
# keys:
|
|
91
|
-
# - $GEMINI_API_KEY
|
|
92
|
-
`}export{A as a,C as b,P as c,I as d,j as e,z as f,M as g,$ as h};
|
|
@@ -1,4 +0,0 @@
|
|
|
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{K as L,L as M,O as v,P as V,R as w,S as P,U as m,Z as $,_ as d,a as y,aa as z,ba as O,c as _,ca as A,da as U,e as E,ea as H,fa as x,ga as B,k as S,l as k,o as f,q as R,r as q,t as I,v as T}from"./chunk-FOQ7VLIL.js";var b=class{constructor(e){this._server=e}requestStream(e,t,s){return this._server.requestStream(e,t,s)}createMessageStream(e,t){let s=this._server.getClientCapabilities();if((e.tools||e.toolChoice)&&!s?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let i=e.messages[e.messages.length-1],r=Array.isArray(i.content)?i.content:[i.content],n=r.some(a=>a.type==="tool_result"),o=e.messages.length>1?e.messages[e.messages.length-2]:void 0,u=o?Array.isArray(o.content)?o.content:[o.content]:[],c=u.some(a=>a.type==="tool_use");if(n){if(r.some(a=>a.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let a=new Set(u.filter(h=>h.type==="tool_use").map(h=>h.id)),l=new Set(r.filter(h=>h.type==="tool_result").map(h=>h.toolUseId));if(a.size!==l.size||![...a].every(h=>l.has(h)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:e},w,t)}elicitInputStream(e,t){let s=this._server.getClientCapabilities(),i=e.mode??"form";switch(i){case"url":{if(!s?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!s?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let r=i==="form"&&e.mode===void 0?{...e,mode:"form"}:e;return this.requestStream({method:"elicitation/create",params:r},m,t)}async getTask(e,t){return this._server.getTask({taskId:e},t)}async getTaskResult(e,t,s){return this._server.getTaskResult({taskId:e},t,s)}async listTasks(e,t){return this._server.listTasks(e?{cursor:e}:void 0,t)}async cancelTask(e,t){return this._server.cancelTask({taskId:e},t)}};var D=class extends z{constructor(e,t){super(t),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(v.options.map((s,i)=>[s,i])),this.isMessageIgnored=(s,i)=>{let r=this._loggingLevels.get(i);return r?this.LOG_LEVEL_SEVERITY.get(s)<this.LOG_LEVEL_SEVERITY.get(r):!1},this._capabilities=t?.capabilities??{},this._instructions=t?.instructions,this._jsonSchemaValidator=t?.jsonSchemaValidator??new A,this.setRequestHandler(q,s=>this._oninitialize(s)),this.setNotificationHandler(I,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(V,async(s,i)=>{let r=i.sessionId||i.requestInfo?.headers["mcp-session-id"]||void 0,{level:n}=s.params,o=v.safeParse(n);return o.success&&this._loggingLevels.set(r,o.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new b(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=O(this._capabilities,e)}setRequestHandler(e,t){let i=E(e)?.method;if(!i)throw new Error("Schema is missing a method literal");let r;if(y(i)){let o=i;r=o._zod?.def?.value??o.value}else{let o=i;r=o._def?.value??o.value}if(typeof r!="string")throw new Error("Schema method literal must be a string");if(r==="tools/call"){let o=async(u,c)=>{let a=_(M,u);if(!a.success){let p=a.error instanceof Error?a.error.message:String(a.error);throw new d(f.InvalidParams,`Invalid tools/call request: ${p}`)}let{params:l}=a.data,h=await Promise.resolve(t(u,c));if(l.task){let p=_(T,h);if(!p.success){let G=p.error instanceof Error?p.error.message:String(p.error);throw new d(f.InvalidParams,`Invalid task creation result: ${G}`)}return p.data}let g=_(L,h);if(!g.success){let p=g.error instanceof Error?g.error.message:String(g.error);throw new d(f.InvalidParams,`Invalid tools/call result: ${p}`)}return g.data};return super.setRequestHandler(e,o)}return super.setRequestHandler(e,t)}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${e})`);break;case"ping":break}}assertNotificationCapability(e){switch(e){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${e})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${e})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${e})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${e})`);break;case"ping":case"initialize":break}}assertTaskCapability(e){H(this._clientCapabilities?.tasks?.requests,e,"Client")}assertTaskHandlerCapability(e){this._capabilities&&U(this._capabilities.tasks?.requests,e,"Server")}async _oninitialize(e){let t=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:k.includes(t)?t:S,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},R)}async createMessage(e,t){if((e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let s=e.messages[e.messages.length-1],i=Array.isArray(s.content)?s.content:[s.content],r=i.some(c=>c.type==="tool_result"),n=e.messages.length>1?e.messages[e.messages.length-2]:void 0,o=n?Array.isArray(n.content)?n.content:[n.content]:[],u=o.some(c=>c.type==="tool_use");if(r){if(i.some(c=>c.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!u)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(u){let c=new Set(o.filter(l=>l.type==="tool_use").map(l=>l.id)),a=new Set(i.filter(l=>l.type==="tool_result").map(l=>l.toolUseId));if(c.size!==a.size||![...c].every(l=>a.has(l)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return e.tools?this.request({method:"sampling/createMessage",params:e},P,t):this.request({method:"sampling/createMessage",params:e},w,t)}async elicitInput(e,t){switch(e.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let i=e;return this.request({method:"elicitation/create",params:i},m,t)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let i=e.mode==="form"?e:{...e,mode:"form"},r=await this.request({method:"elicitation/create",params:i},m,t);if(r.action==="accept"&&r.content&&i.requestedSchema)try{let o=this._jsonSchemaValidator.getValidator(i.requestedSchema)(r.content);if(!o.valid)throw new d(f.InvalidParams,`Elicitation response content does not match requested schema: ${o.errorMessage}`)}catch(n){throw n instanceof d?n:new d(f.InternalError,`Error validating elicitation response: ${n instanceof Error?n.message:String(n)}`)}return r}}}createElicitationCompletionNotifier(e,t){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:e}},t)}async listRoots(e,t){return this.request({method:"roots/list",params:e},$,t)}async sendLoggingMessage(e,t){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,t))return this.notification({method:"notifications/message",params:e})}async sendResourceUpdated(e){return this.notification({method:"notifications/resources/updated",params:e})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};import j from"node:process";var N=class{constructor(e=j.stdin,t=j.stdout){this._stdin=e,this._stdout=t,this._readBuffer=new x,this._started=!1,this._ondata=s=>{this._readBuffer.append(s),this.processReadBuffer()},this._onerror=s=>{this.onerror?.(s)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(e){return new Promise(t=>{let s=B(e);this._stdout.write(s)?t():this._stdout.once("drain",t)})}};export{D as a,N as b};
|
|
@@ -1,53 +0,0 @@
|
|
|
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 Y,b as z,c as V,d as B,e as K,f as W}from"./chunk-L6VCIGWS.js";import{c as k,d as _,e as U,g as F,h as H}from"./chunk-HGPBHTVD.js";import"./chunk-Y3GFB5XM.js";import"./chunk-EQIMHXC4.js";import"./chunk-IRWZ7UPF.js";import{g as L,h as R}from"./chunk-RA6HKFBV.js";import"./chunk-FX6MOGLR.js";import{a as x}from"./chunk-3TGQSGG4.js";import{E as h,G as M}from"./chunk-QUUEQRIT.js";import"./chunk-AWFUHWQK.js";import"./chunk-B3XBQEFM.js";import"./chunk-WHC7AYZD.js";import{existsSync as X}from"node:fs";import{join as S}from"node:path";import{createInterface as Z}from"node:readline/promises";var ee=`${x.bold("Usage:")}
|
|
5
|
-
${h} mcp add <server> [options] -- <command> [args...]
|
|
6
|
-
${h} mcp add <server> [options] --url <url>
|
|
7
|
-
${h} mcp remove <server> [-l]
|
|
8
|
-
${h} mcp list [--json]
|
|
9
|
-
${h} mcp login <server> [--timeout <seconds>]
|
|
10
|
-
${h} mcp logout <server>
|
|
11
|
-
|
|
12
|
-
Configure and check MCP servers and sign in to OAuth servers without starting a session.
|
|
13
|
-
Reads ~/${M}/agent/mcp.json and, in trusted projects, ${M}/mcp.json.
|
|
14
|
-
|
|
15
|
-
Commands:
|
|
16
|
-
add <server> Add or replace a server in mcp.json
|
|
17
|
-
remove <server> Remove a server from mcp.json
|
|
18
|
-
list Show state, tools, and errors (exits 1 on failure)
|
|
19
|
-
login <server> Sign in through the browser
|
|
20
|
-
logout <server> Delete the stored OAuth credentials
|
|
21
|
-
|
|
22
|
-
Options for add and remove:
|
|
23
|
-
-l, --local Use ${M}/mcp.json in the current project instead of the global file
|
|
24
|
-
|
|
25
|
-
Options for add:
|
|
26
|
-
--url <url> Streamable HTTP server URL (instead of a command)
|
|
27
|
-
--env <KEY=VALUE> Environment variable for a stdio server (repeatable)
|
|
28
|
-
--cwd <dir> Working directory for a stdio server
|
|
29
|
-
--header <KEY=VALUE> HTTP header (repeatable)
|
|
30
|
-
--bearer-token-env-var <NAME>
|
|
31
|
-
Send "Authorization: Bearer \${NAME}"
|
|
32
|
-
--oauth-client-id <id> Pre-registered OAuth client id
|
|
33
|
-
--oauth-client-secret <secret>
|
|
34
|
-
OAuth client secret (may be \${NAME} or !command)
|
|
35
|
-
--oauth-callback-port <port>
|
|
36
|
-
Fixed OAuth callback port
|
|
37
|
-
--oauth-client-name <name>
|
|
38
|
-
Client name sent when registering with the OAuth server
|
|
39
|
-
--exposure <mode> codemode (default), deferred, direct, or hidden
|
|
40
|
-
--description <text> What the server offers, shown in the system prompt
|
|
41
|
-
|
|
42
|
-
Other options:
|
|
43
|
-
--json Print the list as JSON
|
|
44
|
-
--timeout <seconds> Time limit for the whole sign-in (default: 300)`,b=x.dim(`Use "${h} mcp --help" for usage.`),te=300;function A(o){return o instanceof Error?o.message:String(o)}function re(o){let{config:t}=o;return"url"in t?t.url:[t.command,...t.args??[]].join(" ")}function G(o,t,i){return new W({entry:o,cwd:t.cwd,createTransport:K,credentials:i,log:new B(S(t.agentDir,"mcp.log")),onTools:()=>{}})}var ne=new Map([["-l","--local"]]);function y(o,t,i,c=Number.POSITIVE_INFINITY){let n=[],a=new Map,l=new Map;for(let f=0;f<o.length;f++){let e=ne.get(o[f])??o[f];if(e==="--"||n.length>=c){n.push(...o.slice(e==="--"?f+1:f));break}if(!e.startsWith("--")){n.push(e);continue}let d=e.slice(2),s=t[d];if(!s){i(`Unknown option ${e}.
|
|
45
|
-
${b}`);return}if(s==="flag"){a.set(d,!0);continue}let r=o[++f];if(r===void 0){i(`${e} needs a value.`);return}s==="list"?l.set(d,[...l.get(d)??[],r]):a.set(d,r)}return{positional:n,values:a,lists:l}}async function we(o,t){let i=t.log??(r=>console.log(r)),c=t.error??(r=>console.error(r)),[n,...a]=o;if(n===void 0||n==="help"||o.includes("--help")||o.includes("-h"))return i(ee),0;let l=S(t.cwd,M,"mcp.json");if(n==="add"||n==="remove")return n==="add"?oe(a,l,t,i,c):se(a,l,t,i,c);let f=new k(t.agentDir).get(t.cwd)===!0,e=U({agentDir:t.agentDir,cwd:t.cwd,projectTrusted:f}),d=!f&&X(l)?`${l} is ignored because the project is not trusted. Start ${h} in the project to trust it.`:void 0,s=t.credentials??new Y;switch(n){case"list":{let r=y(a,{json:"flag"},c);return r?r.positional.length>0?(c(`Usage: ${h} mcp list [--json]
|
|
46
|
-
${b}`),1):ie(e,r.values.has("json"),d,t,s,i):1}case"login":case"logout":{let r=y(a,n==="login"?{timeout:"value"}:{},c);if(!r)return 1;let[u,...p]=r.positional;if(!u||p.length>0)return c(`Usage: ${h} mcp ${n} <server>
|
|
47
|
-
${b}`),1;let g=e.servers.find(v=>v.name===u);if(!g)return c(`No MCP server named "${u}".${d?` ${d}`:""} Configured: ${e.servers.map(v=>v.name).join(", ")||"none"}.`),1;let O=G(g,t,s),P=O.oauthUrl;if(!P)return c(`MCP server "${u}" does not use OAuth. Only HTTP servers without an Authorization header do.`),1;if(n==="logout"){let v=s.remove(u,P);return i(v?`Signed out of MCP server "${u}".`:`No stored credentials for MCP server "${u}".`),0}let w=Number(r.values.get("timeout")??te);if(!Number.isFinite(w)||w<=0)return c("--timeout must be a positive number of seconds."),1;try{return await ae(g,O,P,w*1e3,t,s,i,c)}finally{await O.close()}}default:return c(`Unknown mcp command "${n}".
|
|
48
|
-
${b}`),1}}function q(o,t,i){if(!t)return{};let c={};for(let n of t){let a=n.indexOf("=");if(a<=0){i(`--${o} expects KEY=VALUE, got "${n}".`);return}c[n.slice(0,a)]=n.slice(a+1)}return c}function oe(o,t,i,c,n){let a=`Usage: ${h} mcp add <server> [options] (--url <url> | -- <command> [args...])
|
|
49
|
-
${b}`,l=y(o,{local:"flag",url:"value",env:"list",cwd:"value",header:"list","bearer-token-env-var":"value","oauth-client-id":"value","oauth-client-secret":"value","oauth-callback-port":"value","oauth-client-name":"value",exposure:"value",description:"value"},n,2);if(!l)return 1;let{positional:f,values:e,lists:d}=l,[s,...r]=f,u=e.get("url");if(!s||u===void 0==(r.length===0))return n(a),1;let p=m=>{let $=e.get(m);return typeof $=="string"?$:void 0},g=p("exposure"),w=(u===void 0?["header","bearer-token-env-var","oauth-client-id","oauth-client-secret","oauth-callback-port","oauth-client-name"]:["env","cwd"]).find(m=>e.has(m)||d.has(m));if(w)return n(`--${w} only applies to ${u===void 0?"HTTP servers (--url)":"stdio servers"}.`),1;let v;if(typeof u=="string"){let m=q("header",d.get("header"),n);if(!m)return 1;let $=p("bearer-token-env-var");$!==void 0&&(m.Authorization=`Bearer \${${$}}`);let C=p("oauth-callback-port"),D={...p("oauth-client-id")===void 0?{}:{clientId:p("oauth-client-id")},...p("oauth-client-secret")===void 0?{}:{clientSecret:p("oauth-client-secret")},...C===void 0?{}:{callbackPort:Number(C)},...p("oauth-client-name")===void 0?{}:{clientName:p("oauth-client-name")}};v={url:u,...Object.keys(m).length>0?{headers:m}:{},...Object.keys(D).length>0?{oauth:D}:{}}}else{let m=q("env",d.get("env"),n);if(!m)return 1;let[$,...C]=r;v={command:$,...C.length>0?{args:C}:{},...Object.keys(m).length>0?{env:m}:{},...p("cwd")===void 0?{}:{cwd:p("cwd")}}}g!==void 0&&(v.exposure=g);let N=p("description");N!==void 0&&(v.description=N);let j=R(s,v);if(typeof j=="string")return n(j),1;let T=e.has("local"),E=T?t:S(i.agentDir,"mcp.json"),J=T?"project":"global",I;try{I=F(E,s,j)}catch(m){return n(`Could not update ${E}: ${A(m)}`),1}c(`${I?"Replaced":"Added"} ${J} MCP server "${s}" in ${E}.`),T&&new k(i.agentDir).get(i.cwd)!==!0&&c(`The project is not trusted, so ${E} is ignored until you start ${h} in the project and trust it.`);let Q="url"in j&&!Object.keys(j.headers??{}).some(m=>m.toLowerCase()==="authorization");return c(`Check it with: ${h} mcp list${Q?`. If it requires sign-in: ${h} mcp login ${s}`:""}`),0}function se(o,t,i,c,n){let a=y(o,{local:"flag"},n);if(!a)return 1;let[l,...f]=a.positional;if(!l||f.length>0)return n(`Usage: ${h} mcp remove <server> [-l]
|
|
50
|
-
${b}`),1;let e=a.values.has("local"),d=S(i.agentDir,"mcp.json"),s=e?t:d,r=e?"project":"global",u;try{u=H(s,l)}catch(g){return n(`Could not update ${s}: ${A(g)}`),1}if(u)return c(`Removed ${r} MCP server "${l}" from ${s}.`),0;let p=U({agentDir:i.agentDir,cwd:i.cwd,projectTrusted:!0}).servers.find(g=>g.name===l&&g.scope!==r);return n(`No ${r} MCP server named "${l}" in ${s}.${p?` It is defined in ${p.source}${p.scope==="project"?"; use --local":"; omit --local"}.`:""}`),1}async function ie(o,t,i,c,n,a){let l=await Promise.all(o.servers.map(async e=>{let d={name:e.name,scope:e.scope??"global",source:e.source,...e.override?{override:e.override}:{},enabled:e.config.enabled!==!1,exposure:e.config.exposure??"codemode",transport:re(e),state:"disabled",tools:[]};if(!d.enabled)return d;let s=G(e,c,n);try{await s.getClient()}catch{}d.state=s.state,d.tools=s.tools.map(u=>u.name);let r=s.tools.flatMap(u=>{let p=L(e.config,u.name);return p===d.exposure?[]:[[u.name,p]]});return r.length>0&&(d.toolExposure=Object.fromEntries(r)),s.hasResources&&(d.resources=!0),s.state!=="connected"&&s.error&&(d.error=s.error),await s.close(),d})),f=o.errors.length>0||l.some(e=>e.enabled&&e.state!=="connected");if(t)return a(JSON.stringify({servers:l,errors:o.errors,...i?{note:i}:{}},null,2)),f?1:0;l.length===0&&o.errors.length===0&&a(`No MCP servers configured. Add them to ${S(c.agentDir,"mcp.json")} or .pi/mcp.json.`);for(let e of l){let d=e.state==="connected"?`connected, ${e.tools.length} tool${e.tools.length===1?"":"s"}`:e.state==="needs-auth"?"needs sign-in":e.state;if(a(`${e.name}: ${d} (${e.exposure}, ${e.scope})`),a(` ${e.transport}`),e.override&&a(` project override: ${e.override}`),e.state==="needs-auth"&&a(` sign in with: ${h} mcp login ${e.name}`),e.tools.length>0){let s=e.tools.map(r=>{let u=e.toolExposure?.[r];return u?`${r} [${u}]`:r});a(` tools: ${s.join(", ")}`)}e.resources&&a(" offers resources"),e.error&&a(` ${e.error.split(`
|
|
51
|
-
`).join(`
|
|
52
|
-
`)}`)}for(let e of o.errors)a(`config error: ${e}`);return i&&a(i),f?1:0}async function ae(o,t,i,c,n,a,l,f){let{name:e}=o;try{return await t.getClient(),l(`Already signed in to MCP server "${e}" (${t.tools.length} tools).`),0}catch{if(t.state!=="needs-auth")return f(`MCP server "${e}" failed to connect: ${t.error??"unknown error"}`),1}let d=n.openUrl??_,s=process.stdin.isTTY===!0&&n.openUrl===void 0;try{await V({serverUrl:i,store:a.forServer(e,i),settings:t.oauthSettings(),challenge:t.challenge,prompt:{showAuthorizationUrl:r=>{l(`Sign in to MCP server "${e}" in your browser:
|
|
53
|
-
${r.href}`),d(r.href)},promptForRedirectUrl:r=>ce(r,s)},signal:AbortSignal.timeout(c)})}catch(r){return f(r instanceof z?`Sign-in to MCP server "${e}" was cancelled or not completed within ${Math.round(c/1e3)} seconds.`:`Sign-in to MCP server "${e}" failed: ${A(r)}`),1}t.challenge=void 0;try{await t.reconnect()}catch(r){return f(`Signed in, but ${A(r)}`),1}return l(`Signed in to MCP server "${e}" (${t.tools.length} tools).`),0}async function ce(o,t){if(!t){o.aborted||await new Promise(c=>o.addEventListener("abort",c,{once:!0}));return}let i=Z({input:process.stdin,output:process.stderr});try{return await i.question("If the browser cannot reach this machine, paste the URL it was redirected to: ",{signal:o})}catch{return}finally{i.close()}}export{we as runMcpCommand};
|
|
@@ -1,4 +0,0 @@
|
|
|
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 m}from"./chunk-FH74NME3.js";import"./chunk-KIGMAATV.js";import"./chunk-N6BTQN7R.js";import"./chunk-4LLH5OWM.js";import{k as p}from"./chunk-6LZK4DDH.js";import"./chunk-J5DVLUKY.js";import"./chunk-WHC7AYZD.js";var c=null;function t(){return c||(c=m()),c}var S={error:(...e)=>console.error("[lark:error]",...e),warn:(...e)=>console.error("[lark:warn]",...e),info:(...e)=>console.error("[lark:info]",...e),debug:(...e)=>console.error("[lark:debug]",...e),trace:(...e)=>console.error("[lark:trace]",...e)};function I(e){let r=e.domain==="lark"?t().Domain.Lark:t().Domain.Feishu;return new(t()).Client({appId:e.appId,appSecret:e.appSecret,appType:t().AppType.SelfBuild,domain:r,logger:S,loggerLevel:t().LoggerLevel.warn})}function w(e,r){let o=a=>new Proxy(a,{get(l,s,u){let n=Reflect.get(l,s,u);return typeof n=="function"?(d,i)=>r().then(f=>{let k=t().withUserAccessToken(f),g={...i??{},lark:{...i?.lark??{},...k.lark}};return n.call(l,d,g)}):n&&typeof n=="object"?o(n):n}});return o(e)}function F(e=process.env){let r=e.FEISHU_APP_ID,o=e.FEISHU_APP_SECRET;if(!r||!o)return null;let a=e.FEISHU_DOMAIN||void 0,l=I({appId:r,appSecret:o,domain:a});return e.FEISHU_AUTH_MODE==="user"?w(l,()=>p({appId:r,appSecret:o,domain:a})):l}export{F as buildFeishuClientFromEnv,I as createFeishuClient,S as stderrLogger,w as wrapWithUserToken};
|
|
@@ -1,4 +0,0 @@
|
|
|
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 o}from"./chunk-E6BYRULL.js";import{a as n}from"./chunk-KGJZAYQD.js";import"./chunk-23PRJECN.js";import"./chunk-FF7UELTU.js";import"./chunk-PZMGBKUR.js";import"./chunk-D6VMBA4C.js";import"./chunk-K4NTZEDJ.js";import"./chunk-6AKUD3CF.js";import"./chunk-OSEIQ7SS.js";import"./chunk-CXT5IR5T.js";import"./chunk-WHC7AYZD.js";var s="Cloudflare Workers AI";function a(e){if(Array.isArray(e)){let r=e.map(t=>n(t)&&typeof t.message=="string"?t.message:void 0).filter(t=>t!==void 0);if(r.length>0)return`${s} error: ${r.join("; ")}`}return`${s} request failed`}var i={api:"cloudflare-workers-ai-system-one",label:s,detectCompat:e=>({imageInput:e.id.startsWith("@cf/cloudflare/clef")?"images":"assets",sendImageOptInHeader:!1}),url:e=>new URL("run",`${e.baseUrl.replace(/\/+$/u,"")}/`),payload:(e,r)=>({model:e.id,input:r}),output:e=>{if(!n(e))throw new Error(`${s} returned an unexpected response`);if(e.success===!1)throw new Error(a(e.errors));let r=e.result;if(!n(r))throw new Error(`${s} returned an unexpected response`);if("answers"in r)return r;if(r.state!=="Completed")throw new Error(`${s} run did not complete (state: ${String(r.state)})`);if(!n(r.result))throw new Error(`${s} returned an unexpected response`);return r.result}},f=(e,r,t)=>o(i,e,r,t);export{f as classify};
|
|
@@ -1,4 +0,0 @@
|
|
|
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 o,b as E,c as _,d as S,e as r,f as D,g as e,h as i}from"./chunk-YZSHTWNM.js";import"./chunk-JERCOLY3.js";import"./chunk-WHC7AYZD.js";export{S as AUTH_STYLES,_ as DEFAULT_BASE_URLS,o as DEFAULT_MAX_BODY_SIZE_MB,E as RESERVED_KEYS,D as autoDiscover,r as fromDict,i as generateConfig,e as loadConfig};
|
|
@@ -1,4 +0,0 @@
|
|
|
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 a,c as b,d as c,e as d,f as e,g as f}from"./chunk-TAWLERZA.js";import"./chunk-CQLH4UVX.js";import"./chunk-OKRK6JPY.js";import"./chunk-OE4KH3NJ.js";import"./chunk-WHC7AYZD.js";export{a as DEFAULT_WEBHOOK_PORT,f as registerContextTools,e as resolveCortexContext,b as toolContextFromEnv,d as webSessionId,c as webhookAuthHeaders};
|
|
@@ -1,5 +0,0 @@
|
|
|
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{c as y,h as s}from"./chunk-UD3NMUHR.js";import"./chunk-HALUQ7ZF.js";import"./chunk-KRXTI4JO.js";import{J as $}from"./chunk-DPQPXBTP.js";import"./chunk-Q4UGYGU5.js";import"./chunk-W5LGYSPZ.js";import"./chunk-E7ZMYIY6.js";import"./chunk-NAA7GF6Q.js";import"./chunk-J5DVLUKY.js";import"./chunk-WHC7AYZD.js";function A(m){m.tool("cost_query","Report daily/monthly spending, budgets and remaining amounts, API/plan split, source breakdown, and token usage.",{projectId:$.string().optional().describe("Scope the report to one project. Omit for the global view.")},{readOnlyHint:!0},async({projectId:h})=>{try{let n=h??null,t=await y(n),{dailyBudget:i,monthlyBudget:d,budgetScope:g}=t,a=new Date,r=l=>String(l).padStart(2,"0"),b=`${a.getFullYear()}-${r(a.getMonth()+1)}-${r(a.getDate())}`,x=`${a.getFullYear()}-${r(a.getMonth()+1)}`,c=t.byMode.today.total,u=t.byMode.month.total,F=t.byMode.today.api,S=t.byMode.today.plan,P=t.byMode.month.api,f=t.byMode.month.plan,j=(c/i*100).toFixed(1),M=(u/d*100).toFixed(1),o=[n?`Project: ${n} (${g==="project"?"per-project budget":"global budget"})`:"Scope: all projects (global budget)",`Today (${b}): $${c.toFixed(2)} / $${i} (${j}%, ${t.entryCount} sessions in window)`,` API: $${F.toFixed(2)} | Plan: $${S.toFixed(2)}`,`Month (${x}): $${u.toFixed(2)} / $${d} (${M}%)`,` API: $${P.toFixed(2)} | Plan: $${f.toFixed(2)}`,`Remaining today: $${(i-c).toFixed(2)}`,`Remaining month: $${(d-u).toFixed(2)}`];if(t.bySource&&Object.keys(t.bySource).length>0){o.push(""),o.push("By source:");for(let[l,p]of Object.entries(t.bySource))o.push(` ${l}: today $${p.today.toFixed(2)} | month $${p.month.toFixed(2)}`)}let e=t.tokens;return e&&(e.total.input>0||e.total.output>0)&&(o.push(""),o.push(`Tokens today: ${s(e.today.input)} in / ${s(e.today.output)} out`),o.push(`Tokens month: ${s(e.month.input)} in / ${s(e.month.output)} out`)),{content:[{type:"text",text:o.join(`
|
|
5
|
-
`)}]}}catch(n){return{content:[{type:"text",text:`Failed to query cost: ${n.message}`}],isError:!0}}})}export{A as registerCostTools};
|
|
@@ -1,4 +0,0 @@
|
|
|
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{$ as Fa,$a as Lb,A as X,Aa as hb,B as Y,Ba as ib,C as Z,Ca as jb,D as _,Da as kb,E as da,Ea as lb,F as ea,Fa as ob,G as fa,Ga as pb,H as ga,Ha as qb,I as ha,Ia as rb,J as ia,Ja as sb,K as ja,Ka as tb,L as ka,La as ub,M as la,Ma as vb,N as ma,Na as wb,O as na,Oa as xb,P as oa,Pa as zb,Q as pa,Qa as Ab,R as qa,Ra as Bb,S as ra,Sa as Cb,T as sa,Ta as Db,U as ta,Ua as Eb,V as za,Va as Fb,W as Aa,Wa as Gb,X as Ba,Xa as Hb,Y as Ca,Ya as Ib,Z as Da,Za as Jb,_ as Ea,_a as Kb,aa as Ga,ab as Mb,ba as Ha,bb as Nb,ca as Ia,cb as Ob,d as q,da as Ja,db as Pb,e as r,ea as Ka,eb as Qb,f as s,fa as La,fb as Rb,g as D,ga as Ma,gb as Sb,h as E,ha as Na,hb as Tb,i as F,ia as Oa,ib as Ub,j as G,ja as Pa,jb as Vb,k as H,ka as Qa,kb as Wb,l as I,la as Ra,m as J,ma as Sa,n as K,na as Ta,o as L,oa as Ua,p as M,pa as Va,q as N,qa as Wa,r as O,ra as Xa,s as P,sa as Ya,t as Q,ta as Za,u as R,ua as _a,v as S,va as cb,w as T,wa as db,x as U,xa as eb,y as V,ya as fb,z as W,za as gb}from"./chunk-KIWMQPH7.js";import{L as ab,N as bb,j as h,l as i}from"./chunk-EXJA5RIX.js";import{b as mb,c as nb}from"./chunk-HGPBHTVD.js";import{k as $a}from"./chunk-Y3GFB5XM.js";import"./chunk-EQIMHXC4.js";import{d as yb}from"./chunk-FXDIR3SQ.js";import"./chunk-WEZWKMYU.js";import"./chunk-VQUPKMDR.js";import"./chunk-YKKEI5GI.js";import"./chunk-KDYEGGMW.js";import"./chunk-ZNZFWSPH.js";import"./chunk-PZMGBKUR.js";import"./chunk-6R73ICDB.js";import"./chunk-SKHLZ6XY.js";import"./chunk-D6VMBA4C.js";import"./chunk-6AKUD3CF.js";import{a as t,b as u}from"./chunk-4EX2JJWB.js";import{a as $,g as aa,l as ba,p as ca}from"./chunk-P52RMIYX.js";import"./chunk-RA6HKFBV.js";import"./chunk-NR6U3WIZ.js";import"./chunk-UNVEZI57.js";import"./chunk-OSEIQ7SS.js";import"./chunk-CXT5IR5T.js";import{e as x,f as y,g as z,h as A,i as B,j as C,r as xa,v as ya}from"./chunk-PBJ5MPPX.js";import"./chunk-LACGULCN.js";import{a as v,b as w}from"./chunk-FX6MOGLR.js";import{Aa as m,Ba as n,Ca as o,Ea as p,Ga as ua,Ia as va,Ja as wa,ia as j,sa as k,za as l}from"./chunk-Q7CE3UIE.js";import"./chunk-3TGQSGG4.js";import"./chunk-ZQ7LGTSN.js";import{G as e,H as f,M as g,s as a,v as b,w as c,x as d}from"./chunk-QUUEQRIT.js";import"./chunk-AWFUHWQK.js";import"./chunk-OPYXNSMY.js";import"./chunk-G2V65UBA.js";import"./chunk-NHD2ESHA.js";import"./chunk-B3XBQEFM.js";import"./chunk-JERCOLY3.js";import"./chunk-WHC7AYZD.js";export{_a as AgentSession,jb as AgentSessionRuntime,yb as ArminComponent,zb as AssistantMessageComponent,Ab as BashExecutionComponent,wb as BorderedLoader,Bb as BranchSummaryMessageComponent,e as CONFIG_DIR_NAME,E as CURRENT_SESSION_VERSION,Cb as CompactionSummaryMessageComponent,cb as CredentialSynchronizationError,Db as CustomEditor,Eb as CustomMessageComponent,O as DEFAULT_COMPACTION_SETTINGS,y as DEFAULT_MAX_BYTES,x as DEFAULT_MAX_LINES,eb as DefaultPackageManager,gb as DefaultResourceLoader,qb as DynamicBorder,xb as ExtensionEditorComponent,tb as ExtensionInputComponent,ga as ExtensionRunner,ub as ExtensionSelectorComponent,Fb as FooterComponent,Qb as InteractiveMode,Gb as LoginDialogComponent,ta as ModelRegistry,db as ModelRuntime,Hb as ModelSelectorComponent,Ib as OAuthSelectorComponent,nb as ProjectTrustStore,Sb as RpcClient,M as SessionManager,vb as SessionSelectorComponent,h as SettingsManager,Jb as SettingsSelectorComponent,Vb as ShowImagesSelectorComponent,Kb as SkillInvocationMessageComponent,j as Theme,Wb as ThemeSelectorComponent,Lb as ThinkingSelectorComponent,Mb as ToolExecutionComponent,Nb as TreeSelectorComponent,Ob as UserMessageComponent,Pb as UserMessageSelectorComponent,f as VERSION,Ya as VIRTUAL_MODEL_STATE_ENTRY,J as buildContextEntries,L as buildSessionContext,K as buildSessionProjection,P as calculateContextTokens,Y as collectEntriesForBranchSummary,X as compact,D as convertToLlm,s as convertToPng,pb as copyToClipboard,lb as createAgentSession,ib as createAgentSessionFromServices,kb as createAgentSessionRuntime,hb as createAgentSessionServices,Ba as createBashTool,Aa as createBashToolDefinition,ob as createCodemodeExtension,Wa as createCodingTools,Ha as createEditTool,Ga as createEditToolDefinition,$ as createEventBus,ba as createExtensionRuntime,Ja as createFindTool,Ia as createFindToolDefinition,La as createGrepTool,Ka as createGrepToolDefinition,za as createLocalBashOperations,Oa as createLocalPowerShellOperations,Na as createLsTool,Ma as createLsToolDefinition,rb as createMcpExtension,Qa as createPowerShellTool,Pa as createPowerShellToolDefinition,Xa as createReadOnlyTools,Ta as createReadTool,Sa as createReadToolDefinition,aa as createSyntheticSourceInfo,sb as createToolSearchExtension,Va as createWriteTool,Ua as createWriteToolDefinition,ha as defineTool,Ra as detectSupportedImageMimeTypeFromFile,ca as discoverAndLoadExtensions,S as estimateTokens,U as findCutPoint,T as findTurnStartIndex,u as formatDimensionNote,ya as formatReadLineRange,z as formatSize,ea as formatSkillsForPrompt,_ as generateBranchSummary,Da as generateDiffString,V as generateSummary,W as generateSummaryWithUsage,Ca as generateUnifiedPatch,g as getAgentDir,c as getDocsPath,d as getExamplesPath,m as getLanguageFromPath,Q as getLastAssistantUsage,H as getLatestCompactionEntry,n as getMarkdownTheme,a as getPackageDir,w as getPowerShellConfig,b as getReadmePath,o as getSelectListTheme,p as getSettingsListTheme,v as getShellConfig,mb as hasTrustRequiringProjectResources,l as highlightCode,k as initTheme,ia as isBashToolResult,la as isEditToolResult,oa as isFindToolResult,na as isGrepToolResult,pa as isLsToolResult,ja as isPowerShellToolResult,ka as isReadToolResult,qa as isToolCallEventType,ma as isWriteToolResult,va as keyHint,ua as keyText,fb as loadProjectContextFiles,fa as loadSkills,da as loadSkillsFromDir,Ub as main,F as migrateSessionEntries,i as parseArgs,q as parseFrontmatter,G as parseSessionEntries,Za as parseSkillBlock,Z as prepareBranchEntries,wa as rawKeyHint,$a as readStoredCredential,Fa as renderDiff,t as resizeImage,bb as resolveCliModel,ab as resolveModelScopeWithDiagnostics,Rb as runPrintMode,Tb as runRpcMode,N as serializeConversation,I as sessionEntryToContextMessages,R as shouldCompact,r as stripFrontmatter,A as truncateHead,C as truncateLine,B as truncateTail,xa as truncateToVisualLines,Ea as withFileMutationQueue,ra as wrapRegisteredTool,sa as wrapRegisteredTools};
|
|
@@ -1,4 +0,0 @@
|
|
|
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 Dt,b as Pt,c as kt}from"./chunk-FXDIR3SQ.js";import{E as ft,Fa as Xt,d as wt,i as Yt,j as Tt,l as Et,n as Lt,o as Rt,qa as W}from"./chunk-Q7CE3UIE.js";import"./chunk-3TGQSGG4.js";import"./chunk-ZQ7LGTSN.js";import"./chunk-QUUEQRIT.js";import"./chunk-OPYXNSMY.js";import"./chunk-B3XBQEFM.js";import"./chunk-WHC7AYZD.js";var it=.7,G=.1,rt=1.3,Jt=.1;function Vt(i,t,e,o){let n=[];for(let s=0;s<t;s++)for(let u=0;u<i;u++){let h=e(u,s);h&&n.push({home:[u,s,0],color:h})}return{columns:i,rows:t,blocks:n,cameraDistance:o.cameraDistance,radius:Math.hypot(i/2,t/2,1+it/2),widthShare:o.widthShare,puzzleMoves:s=>o.puzzleMoves(s,n.length),origin:o.origin}}var jt=[228,138,122],Qt=[79,142,179],te=[234,182,93],ee=["ccc.","b.c.","bb.y","b..y"],ne={c:jt,b:Qt,y:te};function se(i){return Vt(4,4,(t,e)=>ne[ee[e][t]],{cameraDistance:10,widthShare:.35,puzzleMoves:t=>t<.4?2:1,origin:i})}function oe(i){return Vt(Dt,Pt,(t,e)=>kt(t,e)?i:void 0,{cameraDistance:80,widthShare:.45,puzzleMoves:(t,e)=>Math.round(e*(.03+t*.04)),origin:void 0})}var ct=G+rt+3,q=.3,tt=12,at=1,Zt=.6,dt=q*tt+at+Zt,ie=[[1,0,0],[-1,0,0],[0,1,0],[0,-1,0],[1,0,0],[-1,0,0],[0,1,0],[0,-1,0],[0,0,1],[0,0,-1]];function ce(i,t){let{columns:e,rows:o}=i,n=i.blocks.map(r=>r.home),s=[n],u=new Set,h=t*7919+1,b=()=>Q(h++),f=([r,m,y])=>((y+1)*o+m)*e+r;for(let r=0;r<tt;r++){let m=new Set(n.map(f)),y=[...n],c=new Set,d=i.puzzleMoves(b());for(let A=0;A<d;A++){let l=[];for(let Y=0;Y<n.length;Y++){if(c.has(Y))continue;let[I,k,R]=n[Y];for(let[p,L,E]of ie){let T=[I+p,k+L,R+E];T[0]<0||T[0]>=e||T[1]<0||T[1]>=o||T[2]<-1||T[2]>1||m.has(f(T))||l.push({block:Y,target:T})}}let M=l.filter(Y=>!u.has(Y.block)),a=M.length>0?M:l,x=a[Math.floor(b()*a.length)];if(!x)break;m.add(f(x.target)),y[x.block]=x.target,c.add(x.block)}u.clear();for(let A of c)u.add(A);n=y,s.push(n)}return s}var re=1e3/30,Wt=.35,Gt=.55,Kt=.12,Ot=G+Gt+Kt+Wt,ae=.5,le=1.1,he=2.5,fe=2,ue=.018,vt=[[255,255,255],[170,195,255],[255,225,170],[255,190,205]],V=5,me=.3,B=6,$=3,Ct=32,Ut=8,Nt=3,de=.5,xt=[1,8,2,16,4,32,64,128],ut=Array.from({length:256},(i,t)=>String.fromCharCode(10240+t)),J=Bt([-.45,-.6,.75]),mt=Bt([J[0],J[1],J[2]+1]);function Bt(i){let t=Math.hypot(i[0],i[1],i[2]);return[i[0]/t,i[1]/t,i[2]/t]}function Z(i){return i<0?0:i>1?1:i}function N(i){let t=Z(i);return t*t*t*(t*(t*6-15)+10)}function xe(i){let t=1-Z(i);return 1-t*t*t}function z(i,t,e){return[i[0]+(t[0]-i[0])*e,i[1]+(t[1]-i[1])*e,i[2]+(t[2]-i[2])*e]}function Q(i){let t=Math.imul(i^2654435769,2246822507);return t^=t>>>13,t=Math.imul(t,3266489909),t^=t>>>16,(t>>>0)/4294967296}function $t([i,t,e]){return .2126*i+.7152*t+.0722*e>128}function et(i){let{r:t,g:e,b:o}=Et(i);return[t,e,o]}function ge(i,t){return i.trim()===""?0:/^[.,:;'`\-_·]$/.test(i)?2:/^[\u2500-\u257f]$/.test(i)?3:4+Math.floor(t*3)}var pe=new Intl.Segmenter;function Me(i,t,e,o){let n=s=>et(Yt(s));return i.map(s=>{let u=[],h,b,f=!1,r=!1,m=d=>{let A=d===""?["0"]:d.split(";");for(let l=0;l<A.length;l++){let M=A[l].split(":").map(x=>Number.parseInt(x,10)),a=M[0]??0;if(a===38||a===48){let x;if(M.length>1)x=M.slice(1).filter(I=>!Number.isNaN(I));else{let I=Number.parseInt(A[l+1]??"",10),k=I===5?2:I===2?4:1;x=A.slice(l+1,l+1+k).map(R=>Number.parseInt(R,10)),l+=k}let Y;x[0]===5&&x[1]!==void 0?Y=n(x[1]):x[0]===2&&x.length>=4&&(Y=[x[1],x[2],x[3]]),Y&&(a===38?h=Y:b=Y)}else a===0?(h=void 0,b=void 0,f=!1,r=!1):a===2?f=!0:a===22?f=!1:a===7?r=!0:a===27?r=!1:a>=30&&a<=37?h=n(a-30):a>=90&&a<=97?h=n(a-90+8):a===39?h=void 0:a>=40&&a<=47?b=n(a-40):a>=100&&a<=107?b=n(a-100+8):a===49&&(b=void 0)}},y=d=>{for(let{segment:A}of pe.segment(d)){let l=wt(A);if(l===0||u.length+l>t)continue;let M=h??e,a=b;r&&(M=b??o,a=h??e),f&&(M=z(M,a??o,.4));let x={text:A,width:l,fg:M,bg:a,delay:0,ink:0,seed:0};u.push(x),l===2&&u.push({...x,text:"",width:0})}},c=0;for(;c<s.length;){let d=s.indexOf("\x1B",c);if(d===-1){y(s.slice(c));break}d>c&&y(s.slice(c,d));let A=s[d+1];if(A==="["){let l=d+2;for(;l<s.length&&(s.charCodeAt(l)<64||s.charCodeAt(l)>126);)l++;s[l]==="m"&&m(s.slice(d+2,l)),c=l+1}else if(A==="]"||A==="_"||A==="P"||A==="^"){let l=s.indexOf("\x07",d+2),M=s.indexOf("\x1B\\",d+2);if(l===-1&&M===-1)break;c=l!==-1&&(M===-1||l<M)?l+1:M+2}else c=d+2}return u})}function ye(i,t,e){let[o,n,s,u,h,b]=[Math.sin(i),Math.cos(i),Math.sin(t),Math.cos(t),Math.sin(e),Math.cos(e)],f=[n,0,o,0,1,0,-o,0,n],r=[1,0,0,0,u,-s,0,s,u],m=[b,-h,0,h,b,0,0,0,1];return Ft(m,Ft(r,f))}function Ft(i,t){let e=new Array(9);for(let o=0;o<3;o++)for(let n=0;n<3;n++)e[o*3+n]=i[o*3]*t[n]+i[o*3+1]*t[3+n]+i[o*3+2]*t[6+n];return e}var st=1.4,Ht=Math.PI*2/dt,be=.6,Ae=ct+q*tt+at+Zt/2;function qt(i){let t=i-G;if(t<=0)return 0;let e=t/st;return e<1?Ht*st*(e**6-3*e**5+2.5*e**4):Ht*(st*.5+t-st)}var Se=Math.PI*2-qt(Ae)%(Math.PI*2);function gt(i){return qt(i)+Se*N((i-G)/rt)}function zt(i){let t=gt(i);return t-be*Math.sin(t)}var pt=class{bits=new Uint8Array(0);counts=new Uint8Array(0);rgb=new Float32Array(0);haloAmount=new Float32Array(0);haloRgb=new Float32Array(0);width=0;height=0;depth=new Float32Array(0);faceIds=new Uint16Array(0);dirty;haloDirty;cameraDistance;constructor(t){this.cameraDistance=t}render(t,e,o,n,s,u){let h=t*2,b=e*4;if(t!==this.width||e!==this.height)this.width=t,this.height=e,this.bits=new Uint8Array(t*e),this.counts=new Uint8Array(t*e),this.rgb=new Float32Array(t*e*3),this.haloAmount=new Float32Array(t*e),this.haloRgb=new Float32Array(t*e*3),this.haloDirty=void 0,this.depth=new Float32Array(h*b).fill(1/0),this.faceIds=new Uint16Array(h*b),this.dirty=void 0;else if(this.dirty){let{minX:g,minY:_,maxX:S,maxY:D}=this.dirty;for(let w=_;w<=D;w++)this.bits.fill(0,w*t+g,w*t+S+1),this.counts.fill(0,w*t+g,w*t+S+1),this.rgb.fill(0,(w*t+g)*3,(w*t+S+1)*3);this.dirty=void 0}if(this.haloDirty){let{minX:g,minY:_,maxX:S,maxY:D}=this.haloDirty;for(let w=_;w<=D;w++)this.haloAmount.fill(0,w*t+g,w*t+S+1),this.haloRgb.fill(0,(w*t+g)*3,(w*t+S+1)*3);this.haloDirty=void 0}let f=ye(o.yaw,o.pitch,o.roll),{centerX:r,centerY:m,scale:y}=o,c=this.cameraDistance,d=[f[6]*c,f[7]*c,f[8]*c],A=$t(s),l=this.visibleFaces(f,d,o,n,h,b,A);if(l.length===0)return;let M=h,a=b,x=-1,Y=-1;for(let g of l)M=Math.min(M,g.minX),a=Math.min(a,g.minY),x=Math.max(x,g.maxX),Y=Math.max(Y,g.maxY);if(x<M||Y<a)return;let I=this.depth,k=this.faceIds;for(let g=0;g<l.length;g++){let _=l[g],S=_.axis,D=(S+1)%3,w=(S+2)%3,v=d[S],U=d[D],C=d[w],F=f[S]/y,lt=f[D]/y,O=f[w]/y,H=(_.minX+.5-r)/y;for(let K=_.minY;K<=_.maxY;K++){let ht=(K+.5-m)/y,yt=f[S]*H+f[3+S]*ht-f[6+S]*c,bt=f[D]*H+f[3+D]*ht-f[6+D]*c,At=f[w]*H+f[3+w]*ht-f[6+w]*c,nt=K*h+_.minX;for(let St=_.minX;St<=_.maxX;St++,nt++){let j=(_.plane-v)/yt;if(j>0&&j<I[nt]){let It=U+j*bt,_t=C+j*At;It>=_.uMin&&It<=_.uMax&&_t>=_.vMin&&_t<=_.vMax&&(I[nt]=j,k[nt]=g+1)}yt+=F,bt+=lt,At+=O}}}let R=this.bits,p=this.counts,L=this.rgb,E=t,T=e,X=-1,P=-1;for(let g=a;g<=Y;g++){let _=g*h+M;for(let S=M;S<=x;S++,_++){let D=k[_];if(D===0)continue;let w=l[D-1],v=Z(.15-c*(1-I[_])*.12)*(A?.5:1);k[_]=0,I[_]=1/0;let U=S>>1,C=g>>2,F=C*t+U;R[F]|=xt[(g&3)*2+(S&1)],p[F]++,L[F*3]+=w.red+(s[0]-w.red)*v,L[F*3+1]+=w.green+(s[1]-w.green)*v,L[F*3+2]+=w.blue+(s[2]-w.blue)*v,U<E&&(E=U),U>X&&(X=U),C<T&&(T=C),C>P&&(P=C)}}X>=0&&(this.dirty={minX:E,minY:T,maxX:X,maxY:P}),u>0&&this.renderHalo(u)}renderHalo(t){let e=this.dirty;if(!e)return;let{width:o,height:n,counts:s,rgb:u}=this,h=Math.max(0,e.minX-B),b=Math.min(o-1,e.maxX+B),f=Math.max(0,e.minY-$),r=Math.min(n-1,e.maxY+$),m=b-h+1,y=M=>{let a=Array.from({length:M*2+1},(Y,I)=>M+1-Math.abs(I-M)),x=a.reduce((Y,I)=>Y+I,0);return a.map(Y=>Y/x)},c=y(B),d=y($),A=e.maxY-e.minY+1,l=new Float32Array(A*m*4);for(let M=e.minY;M<=e.maxY;M++)for(let a=h;a<=b;a++){let x=0,Y=0,I=0,k=0;for(let p=-B;p<=B;p++){let L=a+p;if(L<e.minX||L>e.maxX)continue;let E=M*o+L,T=s[E];if(T===0)continue;let X=c[p+B]/8;x+=T*X,Y+=u[E*3]*X,I+=u[E*3+1]*X,k+=u[E*3+2]*X}let R=((M-e.minY)*m+(a-h))*4;l[R]=x,l[R+1]=Y,l[R+2]=I,l[R+3]=k}for(let M=f;M<=r;M++)for(let a=h;a<=b;a++){let x=0,Y=0,I=0,k=0;for(let E=-$;E<=$;E++){let T=M+E;if(T<e.minY||T>e.maxY)continue;let X=d[E+$],P=((T-e.minY)*m+(a-h))*4;x+=l[P]*X,Y+=l[P+1]*X,I+=l[P+2]*X,k+=l[P+3]*X}let R=M*o+a,p=s[R];if(p>0&&p/8>x&&(x=p/8,Y=u[R*3]/p*x,I=u[R*3+1]/p*x,k=u[R*3+2]/p*x),x<=0)continue;let L=Math.round(t*Math.min(1,x)**.7*Ct)/Ct;L<=0||(this.haloAmount[R]=L,this.haloRgb[R*3]=Math.round(Y/x/V)*V,this.haloRgb[R*3+1]=Math.round(I/x/V)*V,this.haloRgb[R*3+2]=Math.round(k/x/V)*V)}this.haloDirty={minX:h,minY:f,maxX:b,maxY:r}}visibleFaces(t,e,o,n,s,u,h){let b=[],f=this.cameraDistance;for(let r of n)for(let m=0;m<3;m++){let y=(m+1)%3,c=(m+2)%3;for(let d of[-1,1]){let A=d>0?r.max[m]:r.min[m];if((e[m]-A)*d<=0||n.some(g=>g!==r&&(d>0?g.min[m]:g.max[m])===A&&g.min[y]<=r.min[y]&&g.max[y]>=r.max[y]&&g.min[c]<=r.min[c]&&g.max[c]>=r.max[c]))continue;let M=1/0,a=1/0,x=-1/0,Y=-1/0,I=[0,0,0];for(let g of[r.min[y],r.max[y]])for(let _ of[r.min[c],r.max[c]]){I[m]=A,I[y]=g,I[c]=_;let S=t[0]*I[0]+t[1]*I[1]+t[2]*I[2],D=t[3]*I[0]+t[4]*I[1]+t[5]*I[2],w=t[6]*I[0]+t[7]*I[1]+t[8]*I[2],v=o.scale*f/(f-w),U=o.centerX+S*v,C=o.centerY+D*v;M=Math.min(M,U),a=Math.min(a,C),x=Math.max(x,U),Y=Math.max(Y,C)}let k={minX:Math.max(0,Math.floor(M)),minY:Math.max(0,Math.floor(a)),maxX:Math.min(s-1,Math.ceil(x)),maxY:Math.min(u-1,Math.ceil(Y))};if(k.maxX<k.minX||k.maxY<k.minY)continue;let R=t[m]*d,p=t[3+m]*d,L=t[6+m]*d,E=Math.max(0,R*J[0]+p*J[1]+L*J[2]),T=Math.max(0,R*.8-L*.3),X=h?0:Math.max(0,R*mt[0]+p*mt[1]+L*mt[2])**24*.6*255,P=h?Math.min(1,.55+E*.45+T*.1):.45+E*.78+T*.25;b.push({axis:m,plane:A,uMin:r.min[y],uMax:r.max[y],vMin:r.min[c],vMax:r.max[c],...k,red:Math.min(255,r.color[0]*P+X),green:Math.min(255,r.color[1]*P+X),blue:Math.min(255,r.color[2]*P+X)})}}return b}},ot=!1;async function Te(i,t,e){if(ot)return;ot=!0;let o=await i.queryTerminalColors({timeoutMs:100}),n=W.appearance==="dark",s=(r,m)=>r?[r.r,r.g,r.b]:m,u={foreground:s(o.foreground,et(W.colors.text)),background:s(o.background,n?[0,0,0]:[255,255,255])};if(i.hasOverlay()){ot=!1;return}let h=e.kind==="armin"?oe(et(W.colors.accent)):se({column:e.column,row:e.row}),b=new Mt(i,t,h,u,()=>{ot=!1,f.hide()}),f=i.showOverlay(b,{anchor:"top-left",width:"100%",maxHeight:"100%"})}var Mt=class{tui;screen;model;foreground;background;onDone;startTime=performance.now();lastRender=performance.now();timer;exit;shuffle;screenWidth=-1;screenHeight=-1;stars=[];cells=[];ansiCache=new Map;raster;constructor(t,e,o,n,s){this.tui=t,this.screen=e,this.model=o,this.raster=new pt(o.cameraDistance),this.foreground=n.foreground,this.background=n.background,this.onDone=s,this.timer=setInterval(()=>{this.exit&&this.exitProgress()>=1||performance.now()-this.lastRender>1e3?this.finish():this.tui.requestRender()},re),this.timer.unref?.()}close(){if(this.exit){this.finish();return}let t=this.elapsed(),e=zt(t),o=Math.PI*2;this.exit={start:performance.now(),time:t,yaw:e,targetYaw:Math.ceil(e/o)*o,offsets:this.blockOffsets(t)}}handleInput(t){let e=ft();(e.matches(t,"tui.select.cancel")||e.matches(t,"app.clear"))&&this.close()}handleMouse(t){return t.type==="click"&&this.close(),{handled:!0,render:!1}}invalidate(){this.screenWidth=-1,this.screenHeight=-1,this.ansiCache.clear()}render(t){let e=Math.max(1,this.tui.terminal.rows),o=this.foreground,n=this.background;this.lastRender=performance.now(),(t!==this.screenWidth||e!==this.screenHeight)&&(this.screenWidth=t,this.screenHeight=e,this.cells=this.prepareCells(t,o),this.stars=this.prepareStars(t,e));let s,u,h,b,f;if(this.exit){let p=this.exitProgress(),L=Z(p/.8),E=1-N(L);s=Math.min(this.exit.time,Ot)*(1-p),u=this.pose(t,e,this.flyProgress(this.exit.time)*E,this.exit.time),u.yaw=this.exit.yaw+(this.exit.targetYaw-this.exit.yaw)*xe(L),u.pitch*=E,u.roll*=E,h=this.hintAlpha(this.exit.time)*(1-N(p/.2)),b=this.starAlpha(this.exit.time)*(1-N(p/.3));let T=1-N(p/.5);f=this.exit.offsets.map(([X,P,g])=>[X*T,P*T,g*T])}else{let p=this.elapsed();s=p,u=this.pose(t,e,this.flyProgress(p),p),h=this.hintAlpha(p),b=this.starAlpha(p),f=this.blockOffsets(p)}let{columns:r,rows:m}=this.model,y=this.model.blocks.map((p,L)=>{let[E,T,X]=f[L],P=p.home[0]-r/2+E,g=p.home[1]-m/2+T;return{min:[P,g,X-it/2],max:[P+1,g+1,X+it/2],color:p.color}}),c=this.raster;c.render(t,e,u,y,n,$t(n)?me:0);let d=(p,L)=>{let E=c.haloAmount[p];if(E<=0)return L;let T=c.haloRgb;return z(L??n,[T[p*3],T[p*3+1],T[p*3+2]],E)},A=N(s/ae),l=N(s/.6)*.3,M=s<Ot||A<1,a=this.hint(t,e,h,n),x=Math.floor(s*14),Y=this.elapsed(),I=Math.round(b*Ut)/Ut,k=p=>{if(I<=0)return;let L=this.stars[p];if(!L)return;let E=Math.round((.5+.5*Math.sin(Y*L.speed+L.phase))*Nt)/Nt;return{text:L.glyph,fg:z(n,z(o,L.tint,.5),L.strength*(.7+.3*E)*I)}},R=[];for(let p=0;p<e;p++){let L=this.cells[p]??[],E="",T=-1,X=-1,P=(g,_,S)=>{let D=_?this.pack(_):-1,w=S?this.pack(S):-1;D!==T&&g!==" "&&(E+=_?this.ansi(D,!1):"\x1B[39m",T=D),w!==X&&(E+=S?this.ansi(w,!0):"\x1B[49m",X=w),E+=g};for(let g=0;g<t;g++){let _=p*t+g,S=M?L[g]:void 0,D=d(_,S?.bg&&A<1?z(S.bg,n,A):void 0);if(a&&p===a.row&&g>=a.start&&g<a.start+a.text.length){let O=g-a.start;P(a.text[O],O<a.keyLength?a.keyColor:a.color,D);continue}let w=c.bits[_];if(w){let O=V*c.counts[_],H=c.rgb,K=[Math.round(H[_*3]/O)*V,Math.round(H[_*3+1]/O)*V,Math.round(H[_*3+2]/O)*V];P(ut[w],K,D);continue}if(!S){let O=k(_);P(O?.text??" ",O?.fg,D);continue}let v=(s-S.delay)/Wt;if(v<0&&S.width===2&&!c.bits[_+1]){P(S.text,z(S.fg,n,l),D),g++;continue}if(v<0&&S.width===1){P(S.text,z(S.fg,n,l),D);continue}let U=v<0?S.ink:Math.round(S.ink*(1-Z(v)));if(U<=0){let O=k(_);P(O?.text??" ",O?.fg,D);continue}let C=0,F=0;for(let O=0;F<U&&O<32;O++){let H=xt[Math.floor(Q(S.seed*7919+x*131+O)*8)];C&H||(C|=H,F++)}let lt=l+(1-l)*Z(v)**.8;P(ut[C],z(S.fg,n,lt),D)}R.push(`${E}\x1B[0m`)}return R}elapsed(){return(performance.now()-this.startTime)/1e3}exitProgress(){return this.exit?Z((performance.now()-this.exit.start)/1e3/le):0}finish(){this.timer&&(clearInterval(this.timer),this.timer=void 0,this.onDone())}blockOffsets(t){let e=this.model.blocks,o=()=>e.map(()=>[0,0,0]);if(t<ct)return o();let n=Math.floor((t-ct)/dt),s=t-ct-n*dt;this.shuffle?.cycle!==n&&(this.shuffle={cycle:n,steps:ce(this.model,n)});let u=this.shuffle.steps,h=(f,r)=>{let m=e[r].home;return[f[0]-m[0],f[1]-m[1],f[2]-m[2]]},b=q*tt;if(s<b){let f=Math.floor(s/q),r=N((s-f*q)/q);return u[f].map((m,y)=>{let c=h(m,y),d=h(u[f+1][y],y);return[c[0]+(d[0]-c[0])*r,c[1]+(d[1]-c[1])*r,c[2]+(d[2]-c[2])*r]})}if(s<b+at){let f=(s-b)/at,r=1-N(f),m=Math.sin(Math.PI*Z(f))*.8;return u[tt].map((y,c)=>{let[d,A,l]=h(y,c);return[d*r,A*r,l*r+(c%2===0?m:-m)]})}return o()}flyProgress(t){return N((t-G)/rt)}starAlpha(t){return N((t-he)/fe)}hintAlpha(t){return N((t-G-rt)/de)}pose(t,e,o,n){let{columns:s,rows:u,cameraDistance:h,radius:b,widthShare:f,origin:r}=this.model,m=b*(h/(h-b)),y=r?2*(h-it/2)/h:Jt,c=Math.max(y,Math.min(t*2*f,(e*4-8)*.48)/m),d=t,A=e*2-2,l=r?r.column*2+s:d,M=r?r.row*4+u:A;return{centerX:l+(d-l)*o,centerY:M+(A-M)*o,scale:y*(c/y)**o,yaw:zt(n),pitch:.3*Math.sin(gt(n))*o,roll:.06*Math.sin(2*gt(n))*o}}hint(t,e,o,n){if(o<=0)return;let s=Xt(ft().getKeys("tui.select.cancel")[0]??"escape"),u=`${s} to return`;if(!(u.length>t))return{row:e-2,start:Math.floor((t-u.length)/2),text:u,keyLength:s.length,keyColor:z(n,et(W.colors.muted),o),color:z(n,et(W.colors.dim),o)}}prepareStars(t,e){let o=new Array(t*e);for(let n=0;n<t*e;n++){if(Q(n*3+20973)>=ue)continue;let s=u=>Q(n*7+u*40503);o[n]={glyph:ut[xt[Math.floor(s(1)*8)]],tint:vt[Math.floor(s(2)*vt.length)],strength:.1+s(3)*.12,phase:s(4)*Math.PI*2,speed:.4+s(5)*.8}}return o}prepareCells(t,e){let o=Me(this.screen,t,e,this.background),n=Math.max(1,this.tui.terminal.rows),{columns:s,rows:u,origin:h}=this.model,b=h?h.column+s/2:t/2,f=h?h.row+u/4:n/2,r=Math.hypot(Math.max(b,t-b),Math.max(f,n-f)*2);for(let m=0;m<o.length;m++){let y=o[m];for(let c=0;c<y.length;c++){let d=y[c],A=d.width===0?y[c-1]:d,l=Q(m*65537+c);if(d.width!==0){let M=Math.hypot(c-b,(m-f)*2)/r;d.delay=G+M*Gt+l*Kt}else d.delay=A.delay;d.seed=m*65537+c,d.ink=ge(A.text,l)}}if(h)for(let m=h.row;m<h.row+Math.ceil(u/2);m++){let y=o[m];if(y)for(let c=h.column;c<h.column+s;c++){let d=y[c];d&&(d.text=" ",d.width=1,d.ink=0,d.bg=void 0)}}return o}pack(t){return Math.round(t[0])<<16|Math.round(t[1])<<8|Math.round(t[2])}ansi(t,e){let o=t*2+(e?1:0),n=this.ansiCache.get(o);if(n===void 0){let s=Tt(t>>16&255,t>>8&255,t&255),u=W.getColorMode();n=e?Rt(s,u):Lt(s,u),this.ansiCache.set(o,n)}return n}};export{Mt as EasterEgg3dAnimation,Te as playEasterEgg3d};
|
|
@@ -1,4 +0,0 @@
|
|
|
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{c as k}from"./chunk-WHC7AYZD.js";var x=k((m,P)=>{(function(g,d){typeof m=="object"&&typeof P=="object"?P.exports=d():typeof define=="function"&&define.amd?define([],d):typeof m=="object"?m.bowser=d():g.bowser=d()})(m,(function(){return(function(g){var d={};function b(u){if(d[u])return d[u].exports;var i=d[u]={i:u,l:!1,exports:{}};return g[u].call(i.exports,i,i.exports,b),i.l=!0,i.exports}return b.m=g,b.c=d,b.d=function(u,i,n){b.o(u,i)||Object.defineProperty(u,i,{enumerable:!0,get:n})},b.r=function(u){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(u,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(u,"__esModule",{value:!0})},b.t=function(u,i){if(1&i&&(u=b(u)),8&i||4&i&&typeof u=="object"&&u&&u.__esModule)return u;var n=Object.create(null);if(b.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:u}),2&i&&typeof u!="string")for(var f in u)b.d(n,f,function(e){return u[e]}.bind(null,f));return n},b.n=function(u){var i=u&&u.__esModule?function(){return u.default}:function(){return u};return b.d(i,"a",i),i},b.o=function(u,i){return Object.prototype.hasOwnProperty.call(u,i)},b.p="",b(b.s=90)})({17:function(g,d,b){"use strict";d.__esModule=!0,d.default=void 0;var u=b(18),i=(function(){function n(){}return n.getFirstMatch=function(f,e){var t=e.match(f);return t&&t.length>0&&t[1]||""},n.getSecondMatch=function(f,e){var t=e.match(f);return t&&t.length>1&&t[2]||""},n.matchAndReturnConst=function(f,e,t){if(f.test(e))return t},n.getWindowsVersionName=function(f){switch(f){case"NT":return"NT";case"XP":return"XP";case"NT 5.0":return"2000";case"NT 5.1":return"XP";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}},n.getMacOSVersionName=function(f){var e=f.split(".").splice(0,2).map((function(l){return parseInt(l,10)||0}));e.push(0);var t=e[0],r=e[1];if(t===10)switch(r){case 5:return"Leopard";case 6:return"Snow Leopard";case 7:return"Lion";case 8:return"Mountain Lion";case 9:return"Mavericks";case 10:return"Yosemite";case 11:return"El Capitan";case 12:return"Sierra";case 13:return"High Sierra";case 14:return"Mojave";case 15:return"Catalina";default:return}switch(t){case 11:return"Big Sur";case 12:return"Monterey";case 13:return"Ventura";case 14:return"Sonoma";case 15:return"Sequoia";default:return}},n.getAndroidVersionName=function(f){var e=f.split(".").splice(0,2).map((function(t){return parseInt(t,10)||0}));if(e.push(0),!(e[0]===1&&e[1]<5))return e[0]===1&&e[1]<6?"Cupcake":e[0]===1&&e[1]>=6?"Donut":e[0]===2&&e[1]<2?"Eclair":e[0]===2&&e[1]===2?"Froyo":e[0]===2&&e[1]>2?"Gingerbread":e[0]===3?"Honeycomb":e[0]===4&&e[1]<1?"Ice Cream Sandwich":e[0]===4&&e[1]<4?"Jelly Bean":e[0]===4&&e[1]>=4?"KitKat":e[0]===5?"Lollipop":e[0]===6?"Marshmallow":e[0]===7?"Nougat":e[0]===8?"Oreo":e[0]===9?"Pie":void 0},n.getVersionPrecision=function(f){return f.split(".").length},n.compareVersions=function(f,e,t){t===void 0&&(t=!1);var r=n.getVersionPrecision(f),l=n.getVersionPrecision(e),s=Math.max(r,l),a=0,o=n.map([f,e],(function(c){var h=s-n.getVersionPrecision(c),M=c+new Array(h+1).join(".0");return n.map(M.split("."),(function(p){return new Array(20-p.length).join("0")+p})).reverse()}));for(t&&(a=s-Math.min(r,l)),s-=1;s>=a;){if(o[0][s]>o[1][s])return 1;if(o[0][s]===o[1][s]){if(s===a)return 0;s-=1}else if(o[0][s]<o[1][s])return-1}},n.map=function(f,e){var t,r=[];if(Array.prototype.map)return Array.prototype.map.call(f,e);for(t=0;t<f.length;t+=1)r.push(e(f[t]));return r},n.find=function(f,e){var t,r;if(Array.prototype.find)return Array.prototype.find.call(f,e);for(t=0,r=f.length;t<r;t+=1){var l=f[t];if(e(l,t))return l}},n.assign=function(f){for(var e,t,r=f,l=arguments.length,s=new Array(l>1?l-1:0),a=1;a<l;a++)s[a-1]=arguments[a];if(Object.assign)return Object.assign.apply(Object,[f].concat(s));var o=function(){var c=s[e];typeof c=="object"&&c!==null&&Object.keys(c).forEach((function(h){r[h]=c[h]}))};for(e=0,t=s.length;e<t;e+=1)o();return f},n.getBrowserAlias=function(f){return u.BROWSER_ALIASES_MAP[f]},n.getBrowserTypeByAlias=function(f){return u.BROWSER_MAP[f]||""},n})();d.default=i,g.exports=d.default},18:function(g,d,b){"use strict";d.__esModule=!0,d.ENGINE_MAP=d.OS_MAP=d.PLATFORMS_MAP=d.BROWSER_MAP=d.BROWSER_ALIASES_MAP=void 0,d.BROWSER_ALIASES_MAP={AmazonBot:"amazonbot","Amazon Silk":"amazon_silk","Android Browser":"android",BaiduSpider:"baiduspider",Bada:"bada",BingCrawler:"bingcrawler",Brave:"brave",BlackBerry:"blackberry","ChatGPT-User":"chatgpt_user",Chrome:"chrome",ClaudeBot:"claudebot",Chromium:"chromium",Diffbot:"diffbot",DuckDuckBot:"duckduckbot",DuckDuckGo:"duckduckgo",Electron:"electron",Epiphany:"epiphany",FacebookExternalHit:"facebookexternalhit",Firefox:"firefox",Focus:"focus",Generic:"generic","Google Search":"google_search",Googlebot:"googlebot",GPTBot:"gptbot","Internet Explorer":"ie",InternetArchiveCrawler:"internetarchivecrawler","K-Meleon":"k_meleon",LibreWolf:"librewolf",Linespider:"linespider",Maxthon:"maxthon","Meta-ExternalAds":"meta_externalads","Meta-ExternalAgent":"meta_externalagent","Meta-ExternalFetcher":"meta_externalfetcher","Meta-WebIndexer":"meta_webindexer","Microsoft Edge":"edge","MZ Browser":"mz","NAVER Whale Browser":"naver","OAI-SearchBot":"oai_searchbot",Omgilibot:"omgilibot",Opera:"opera","Opera Coast":"opera_coast","Pale Moon":"pale_moon",PerplexityBot:"perplexitybot","Perplexity-User":"perplexity_user",PhantomJS:"phantomjs",PingdomBot:"pingdombot",Puffin:"puffin",QQ:"qq",QQLite:"qqlite",QupZilla:"qupzilla",Roku:"roku",Safari:"safari",Sailfish:"sailfish","Samsung Internet for Android":"samsung_internet",SlackBot:"slackbot",SeaMonkey:"seamonkey",Sleipnir:"sleipnir","Sogou Browser":"sogou",Swing:"swing",Tizen:"tizen","UC Browser":"uc",Vivaldi:"vivaldi","WebOS Browser":"webos",WeChat:"wechat",YahooSlurp:"yahooslurp","Yandex Browser":"yandex",YandexBot:"yandexbot",YouBot:"youbot"},d.BROWSER_MAP={amazonbot:"AmazonBot",amazon_silk:"Amazon Silk",android:"Android Browser",baiduspider:"BaiduSpider",bada:"Bada",bingcrawler:"BingCrawler",blackberry:"BlackBerry",brave:"Brave",chatgpt_user:"ChatGPT-User",chrome:"Chrome",claudebot:"ClaudeBot",chromium:"Chromium",diffbot:"Diffbot",duckduckbot:"DuckDuckBot",duckduckgo:"DuckDuckGo",edge:"Microsoft Edge",electron:"Electron",epiphany:"Epiphany",facebookexternalhit:"FacebookExternalHit",firefox:"Firefox",focus:"Focus",generic:"Generic",google_search:"Google Search",googlebot:"Googlebot",gptbot:"GPTBot",ie:"Internet Explorer",internetarchivecrawler:"InternetArchiveCrawler",k_meleon:"K-Meleon",librewolf:"LibreWolf",linespider:"Linespider",maxthon:"Maxthon",meta_externalads:"Meta-ExternalAds",meta_externalagent:"Meta-ExternalAgent",meta_externalfetcher:"Meta-ExternalFetcher",meta_webindexer:"Meta-WebIndexer",mz:"MZ Browser",naver:"NAVER Whale Browser",oai_searchbot:"OAI-SearchBot",omgilibot:"Omgilibot",opera:"Opera",opera_coast:"Opera Coast",pale_moon:"Pale Moon",perplexitybot:"PerplexityBot",perplexity_user:"Perplexity-User",phantomjs:"PhantomJS",pingdombot:"PingdomBot",puffin:"Puffin",qq:"QQ Browser",qqlite:"QQ Browser Lite",qupzilla:"QupZilla",roku:"Roku",safari:"Safari",sailfish:"Sailfish",samsung_internet:"Samsung Internet for Android",seamonkey:"SeaMonkey",slackbot:"SlackBot",sleipnir:"Sleipnir",sogou:"Sogou Browser",swing:"Swing",tizen:"Tizen",uc:"UC Browser",vivaldi:"Vivaldi",webos:"WebOS Browser",wechat:"WeChat",yahooslurp:"YahooSlurp",yandex:"Yandex Browser",yandexbot:"YandexBot",youbot:"YouBot"},d.PLATFORMS_MAP={bot:"bot",desktop:"desktop",mobile:"mobile",tablet:"tablet",tv:"tv"},d.OS_MAP={Android:"Android",Bada:"Bada",BlackBerry:"BlackBerry",ChromeOS:"Chrome OS",HarmonyOS:"HarmonyOS",iOS:"iOS",Linux:"Linux",MacOS:"macOS",PlayStation4:"PlayStation 4",Roku:"Roku",Tizen:"Tizen",WebOS:"WebOS",Windows:"Windows",WindowsPhone:"Windows Phone"},d.ENGINE_MAP={Blink:"Blink",EdgeHTML:"EdgeHTML",Gecko:"Gecko",Presto:"Presto",Trident:"Trident",WebKit:"WebKit"}},90:function(g,d,b){"use strict";d.__esModule=!0,d.default=void 0;var u,i=(u=b(91))&&u.__esModule?u:{default:u},n=b(18);function f(t,r){for(var l=0;l<r.length;l++){var s=r[l];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}var e=(function(){function t(){}var r,l,s;return t.getParser=function(a,o,c){if(o===void 0&&(o=!1),c===void 0&&(c=null),typeof a!="string")throw new Error("UserAgent should be a string");return new i.default(a,o,c)},t.parse=function(a,o){return o===void 0&&(o=null),new i.default(a,o).getResult()},r=t,s=[{key:"BROWSER_MAP",get:function(){return n.BROWSER_MAP}},{key:"ENGINE_MAP",get:function(){return n.ENGINE_MAP}},{key:"OS_MAP",get:function(){return n.OS_MAP}},{key:"PLATFORMS_MAP",get:function(){return n.PLATFORMS_MAP}}],(l=null)&&f(r.prototype,l),s&&f(r,s),t})();d.default=e,g.exports=d.default},91:function(g,d,b){"use strict";d.__esModule=!0,d.default=void 0;var u=t(b(92)),i=t(b(93)),n=t(b(94)),f=t(b(95)),e=t(b(17));function t(l){return l&&l.__esModule?l:{default:l}}var r=(function(){function l(a,o,c){if(o===void 0&&(o=!1),c===void 0&&(c=null),a==null||a==="")throw new Error("UserAgent parameter can't be empty");this._ua=a;var h=!1;typeof o=="boolean"?(h=o,this._hints=c):this._hints=o!=null&&typeof o=="object"?o:null,this.parsedResult={},h!==!0&&this.parse()}var s=l.prototype;return s.getHints=function(){return this._hints},s.hasBrand=function(a){if(!this._hints||!Array.isArray(this._hints.brands))return!1;var o=a.toLowerCase();return this._hints.brands.some((function(c){return c.brand&&c.brand.toLowerCase()===o}))},s.getBrandVersion=function(a){if(this._hints&&Array.isArray(this._hints.brands)){var o=a.toLowerCase(),c=this._hints.brands.find((function(h){return h.brand&&h.brand.toLowerCase()===o}));return c?c.version:void 0}},s.getUA=function(){return this._ua},s.test=function(a){return a.test(this._ua)},s.parseBrowser=function(){var a=this;this.parsedResult.browser={};var o=e.default.find(u.default,(function(c){if(typeof c.test=="function")return c.test(a);if(Array.isArray(c.test))return c.test.some((function(h){return a.test(h)}));throw new Error("Browser's test function is not valid")}));return o&&(this.parsedResult.browser=o.describe(this.getUA(),this)),this.parsedResult.browser},s.getBrowser=function(){return this.parsedResult.browser?this.parsedResult.browser:this.parseBrowser()},s.getBrowserName=function(a){return a?String(this.getBrowser().name).toLowerCase()||"":this.getBrowser().name||""},s.getBrowserVersion=function(){return this.getBrowser().version},s.getOS=function(){return this.parsedResult.os?this.parsedResult.os:this.parseOS()},s.parseOS=function(){var a=this;this.parsedResult.os={};var o=e.default.find(i.default,(function(c){if(typeof c.test=="function")return c.test(a);if(Array.isArray(c.test))return c.test.some((function(h){return a.test(h)}));throw new Error("Browser's test function is not valid")}));return o&&(this.parsedResult.os=o.describe(this.getUA())),this.parsedResult.os},s.getOSName=function(a){var o=this.getOS().name;return a?String(o).toLowerCase()||"":o||""},s.getOSVersion=function(){return this.getOS().version},s.getPlatform=function(){return this.parsedResult.platform?this.parsedResult.platform:this.parsePlatform()},s.getPlatformType=function(a){a===void 0&&(a=!1);var o=this.getPlatform().type;return a?String(o).toLowerCase()||"":o||""},s.parsePlatform=function(){var a=this;this.parsedResult.platform={};var o=e.default.find(n.default,(function(c){if(typeof c.test=="function")return c.test(a);if(Array.isArray(c.test))return c.test.some((function(h){return a.test(h)}));throw new Error("Browser's test function is not valid")}));return o&&(this.parsedResult.platform=o.describe(this.getUA())),this.parsedResult.platform},s.getEngine=function(){return this.parsedResult.engine?this.parsedResult.engine:this.parseEngine()},s.getEngineName=function(a){return a?String(this.getEngine().name).toLowerCase()||"":this.getEngine().name||""},s.parseEngine=function(){var a=this;this.parsedResult.engine={};var o=e.default.find(f.default,(function(c){if(typeof c.test=="function")return c.test(a);if(Array.isArray(c.test))return c.test.some((function(h){return a.test(h)}));throw new Error("Browser's test function is not valid")}));return o&&(this.parsedResult.engine=o.describe(this.getUA())),this.parsedResult.engine},s.parse=function(){return this.parseBrowser(),this.parseOS(),this.parsePlatform(),this.parseEngine(),this},s.getResult=function(){return e.default.assign({},this.parsedResult)},s.satisfies=function(a){var o=this,c={},h=0,M={},p=0;if(Object.keys(a).forEach((function(v){var A=a[v];typeof A=="string"?(M[v]=A,p+=1):typeof A=="object"&&(c[v]=A,h+=1)})),h>0){var _=Object.keys(c),S=e.default.find(_,(function(v){return o.isOS(v)}));if(S){var y=this.satisfies(c[S]);if(y!==void 0)return y}var F=e.default.find(_,(function(v){return o.isPlatform(v)}));if(F){var w=this.satisfies(c[F]);if(w!==void 0)return w}}if(p>0){var B=Object.keys(M),O=e.default.find(B,(function(v){return o.isBrowser(v,!0)}));if(O!==void 0)return this.compareVersion(M[O])}},s.isBrowser=function(a,o){o===void 0&&(o=!1);var c=this.getBrowserName().toLowerCase(),h=a.toLowerCase(),M=e.default.getBrowserTypeByAlias(h);return o&&M&&(h=M.toLowerCase()),h===c},s.compareVersion=function(a){var o=[0],c=a,h=!1,M=this.getBrowserVersion();if(typeof M=="string")return a[0]===">"||a[0]==="<"?(c=a.substr(1),a[1]==="="?(h=!0,c=a.substr(2)):o=[],a[0]===">"?o.push(1):o.push(-1)):a[0]==="="?c=a.substr(1):a[0]==="~"&&(h=!0,c=a.substr(1)),o.indexOf(e.default.compareVersions(M,c,h))>-1},s.isOS=function(a){return this.getOSName(!0)===String(a).toLowerCase()},s.isPlatform=function(a){return this.getPlatformType(!0)===String(a).toLowerCase()},s.isEngine=function(a){return this.getEngineName(!0)===String(a).toLowerCase()},s.is=function(a,o){return o===void 0&&(o=!1),this.isBrowser(a,o)||this.isOS(a)||this.isPlatform(a)},s.some=function(a){var o=this;return a===void 0&&(a=[]),a.some((function(c){return o.is(c)}))},l})();d.default=r,g.exports=d.default},92:function(g,d,b){"use strict";d.__esModule=!0,d.default=void 0;var u,i=(u=b(17))&&u.__esModule?u:{default:u},n=/version\/(\d+(\.?_?\d+)+)/i,f=[{test:[/gptbot/i],describe:function(e){var t={name:"GPTBot"},r=i.default.getFirstMatch(/gptbot\/(\d+(\.\d+)+)/i,e)||i.default.getFirstMatch(n,e);return r&&(t.version=r),t}},{test:[/chatgpt-user/i],describe:function(e){var t={name:"ChatGPT-User"},r=i.default.getFirstMatch(/chatgpt-user\/(\d+(\.\d+)+)/i,e)||i.default.getFirstMatch(n,e);return r&&(t.version=r),t}},{test:[/oai-searchbot/i],describe:function(e){var t={name:"OAI-SearchBot"},r=i.default.getFirstMatch(/oai-searchbot\/(\d+(\.\d+)+)/i,e)||i.default.getFirstMatch(n,e);return r&&(t.version=r),t}},{test:[/claudebot/i,/claude-web/i,/claude-user/i,/claude-searchbot/i],describe:function(e){var t={name:"ClaudeBot"},r=i.default.getFirstMatch(/(?:claudebot|claude-web|claude-user|claude-searchbot)\/(\d+(\.\d+)+)/i,e)||i.default.getFirstMatch(n,e);return r&&(t.version=r),t}},{test:[/omgilibot/i,/webzio-extended/i],describe:function(e){var t={name:"Omgilibot"},r=i.default.getFirstMatch(/(?:omgilibot|webzio-extended)\/(\d+(\.\d+)+)/i,e)||i.default.getFirstMatch(n,e);return r&&(t.version=r),t}},{test:[/diffbot/i],describe:function(e){var t={name:"Diffbot"},r=i.default.getFirstMatch(/diffbot\/(\d+(\.\d+)+)/i,e)||i.default.getFirstMatch(n,e);return r&&(t.version=r),t}},{test:[/perplexitybot/i],describe:function(e){var t={name:"PerplexityBot"},r=i.default.getFirstMatch(/perplexitybot\/(\d+(\.\d+)+)/i,e)||i.default.getFirstMatch(n,e);return r&&(t.version=r),t}},{test:[/perplexity-user/i],describe:function(e){var t={name:"Perplexity-User"},r=i.default.getFirstMatch(/perplexity-user\/(\d+(\.\d+)+)/i,e)||i.default.getFirstMatch(n,e);return r&&(t.version=r),t}},{test:[/youbot/i],describe:function(e){var t={name:"YouBot"},r=i.default.getFirstMatch(/youbot\/(\d+(\.\d+)+)/i,e)||i.default.getFirstMatch(n,e);return r&&(t.version=r),t}},{test:[/meta-webindexer/i],describe:function(e){var t={name:"Meta-WebIndexer"},r=i.default.getFirstMatch(/meta-webindexer\/(\d+(\.\d+)+)/i,e)||i.default.getFirstMatch(n,e);return r&&(t.version=r),t}},{test:[/meta-externalads/i],describe:function(e){var t={name:"Meta-ExternalAds"},r=i.default.getFirstMatch(/meta-externalads\/(\d+(\.\d+)+)/i,e)||i.default.getFirstMatch(n,e);return r&&(t.version=r),t}},{test:[/meta-externalagent/i],describe:function(e){var t={name:"Meta-ExternalAgent"},r=i.default.getFirstMatch(/meta-externalagent\/(\d+(\.\d+)+)/i,e)||i.default.getFirstMatch(n,e);return r&&(t.version=r),t}},{test:[/meta-externalfetcher/i],describe:function(e){var t={name:"Meta-ExternalFetcher"},r=i.default.getFirstMatch(/meta-externalfetcher\/(\d+(\.\d+)+)/i,e)||i.default.getFirstMatch(n,e);return r&&(t.version=r),t}},{test:[/googlebot/i],describe:function(e){var t={name:"Googlebot"},r=i.default.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,e)||i.default.getFirstMatch(n,e);return r&&(t.version=r),t}},{test:[/linespider/i],describe:function(e){var t={name:"Linespider"},r=i.default.getFirstMatch(/(?:linespider)(?:-[-\w]+)?[\s/](\d+(\.\d+)+)/i,e)||i.default.getFirstMatch(n,e);return r&&(t.version=r),t}},{test:[/amazonbot/i],describe:function(e){var t={name:"AmazonBot"},r=i.default.getFirstMatch(/amazonbot\/(\d+(\.\d+)+)/i,e)||i.default.getFirstMatch(n,e);return r&&(t.version=r),t}},{test:[/bingbot/i],describe:function(e){var t={name:"BingCrawler"},r=i.default.getFirstMatch(/bingbot\/(\d+(\.\d+)+)/i,e)||i.default.getFirstMatch(n,e);return r&&(t.version=r),t}},{test:[/baiduspider/i],describe:function(e){var t={name:"BaiduSpider"},r=i.default.getFirstMatch(/baiduspider\/(\d+(\.\d+)+)/i,e)||i.default.getFirstMatch(n,e);return r&&(t.version=r),t}},{test:[/duckduckbot/i],describe:function(e){var t={name:"DuckDuckBot"},r=i.default.getFirstMatch(/duckduckbot\/(\d+(\.\d+)+)/i,e)||i.default.getFirstMatch(n,e);return r&&(t.version=r),t}},{test:[/ia_archiver/i],describe:function(e){var t={name:"InternetArchiveCrawler"},r=i.default.getFirstMatch(/ia_archiver\/(\d+(\.\d+)+)/i,e)||i.default.getFirstMatch(n,e);return r&&(t.version=r),t}},{test:[/facebookexternalhit/i,/facebookcatalog/i],describe:function(){return{name:"FacebookExternalHit"}}},{test:[/slackbot/i,/slack-imgProxy/i],describe:function(e){var t={name:"SlackBot"},r=i.default.getFirstMatch(/(?:slackbot|slack-imgproxy)(?:-[-\w]+)?[\s/](\d+(\.\d+)+)/i,e)||i.default.getFirstMatch(n,e);return r&&(t.version=r),t}},{test:[/yahoo!?[\s/]*slurp/i],describe:function(){return{name:"YahooSlurp"}}},{test:[/yandexbot/i,/yandexmobilebot/i],describe:function(){return{name:"YandexBot"}}},{test:[/pingdom/i],describe:function(){return{name:"PingdomBot"}}},{test:[/opera/i],describe:function(e){var t={name:"Opera"},r=i.default.getFirstMatch(n,e)||i.default.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/opr\/|opios/i],describe:function(e){var t={name:"Opera"},r=i.default.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,e)||i.default.getFirstMatch(n,e);return r&&(t.version=r),t}},{test:[/SamsungBrowser/i],describe:function(e){var t={name:"Samsung Internet for Android"},r=i.default.getFirstMatch(n,e)||i.default.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/Whale/i],describe:function(e){var t={name:"NAVER Whale Browser"},r=i.default.getFirstMatch(n,e)||i.default.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/PaleMoon/i],describe:function(e){var t={name:"Pale Moon"},r=i.default.getFirstMatch(n,e)||i.default.getFirstMatch(/(?:PaleMoon)[\s/](\d+(?:\.\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/MZBrowser/i],describe:function(e){var t={name:"MZ Browser"},r=i.default.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(n,e);return r&&(t.version=r),t}},{test:[/focus/i],describe:function(e){var t={name:"Focus"},r=i.default.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(n,e);return r&&(t.version=r),t}},{test:[/swing/i],describe:function(e){var t={name:"Swing"},r=i.default.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(n,e);return r&&(t.version=r),t}},{test:[/coast/i],describe:function(e){var t={name:"Opera Coast"},r=i.default.getFirstMatch(n,e)||i.default.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/opt\/\d+(?:.?_?\d+)+/i],describe:function(e){var t={name:"Opera Touch"},r=i.default.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(n,e);return r&&(t.version=r),t}},{test:[/yabrowser/i],describe:function(e){var t={name:"Yandex Browser"},r=i.default.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(n,e);return r&&(t.version=r),t}},{test:[/ucbrowser/i],describe:function(e){var t={name:"UC Browser"},r=i.default.getFirstMatch(n,e)||i.default.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/Maxthon|mxios/i],describe:function(e){var t={name:"Maxthon"},r=i.default.getFirstMatch(n,e)||i.default.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/epiphany/i],describe:function(e){var t={name:"Epiphany"},r=i.default.getFirstMatch(n,e)||i.default.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/puffin/i],describe:function(e){var t={name:"Puffin"},r=i.default.getFirstMatch(n,e)||i.default.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sleipnir/i],describe:function(e){var t={name:"Sleipnir"},r=i.default.getFirstMatch(n,e)||i.default.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/k-meleon/i],describe:function(e){var t={name:"K-Meleon"},r=i.default.getFirstMatch(n,e)||i.default.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/micromessenger/i],describe:function(e){var t={name:"WeChat"},r=i.default.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(n,e);return r&&(t.version=r),t}},{test:[/qqbrowser/i],describe:function(e){var t={name:/qqbrowserlite/i.test(e)?"QQ Browser Lite":"QQ Browser"},r=i.default.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(n,e);return r&&(t.version=r),t}},{test:[/msie|trident/i],describe:function(e){var t={name:"Internet Explorer"},r=i.default.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/\sedg\//i],describe:function(e){var t={name:"Microsoft Edge"},r=i.default.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/edg([ea]|ios)/i],describe:function(e){var t={name:"Microsoft Edge"},r=i.default.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/vivaldi/i],describe:function(e){var t={name:"Vivaldi"},r=i.default.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/seamonkey/i],describe:function(e){var t={name:"SeaMonkey"},r=i.default.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sailfish/i],describe:function(e){var t={name:"Sailfish"},r=i.default.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,e);return r&&(t.version=r),t}},{test:[/silk/i],describe:function(e){var t={name:"Amazon Silk"},r=i.default.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/phantom/i],describe:function(e){var t={name:"PhantomJS"},r=i.default.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/slimerjs/i],describe:function(e){var t={name:"SlimerJS"},r=i.default.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t={name:"BlackBerry"},r=i.default.getFirstMatch(n,e)||i.default.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t={name:"WebOS Browser"},r=i.default.getFirstMatch(n,e)||i.default.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/bada/i],describe:function(e){var t={name:"Bada"},r=i.default.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/tizen/i],describe:function(e){var t={name:"Tizen"},r=i.default.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(n,e);return r&&(t.version=r),t}},{test:[/qupzilla/i],describe:function(e){var t={name:"QupZilla"},r=i.default.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(n,e);return r&&(t.version=r),t}},{test:[/librewolf/i],describe:function(e){var t={name:"LibreWolf"},r=i.default.getFirstMatch(/(?:librewolf)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/firefox|iceweasel|fxios/i],describe:function(e){var t={name:"Firefox"},r=i.default.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/electron/i],describe:function(e){var t={name:"Electron"},r=i.default.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sogoumobilebrowser/i,/metasr/i,/se 2\.[x]/i],describe:function(e){var t={name:"Sogou Browser"},r=i.default.getFirstMatch(/(?:sogoumobilebrowser)[\s/](\d+(\.?_?\d+)+)/i,e),l=i.default.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e),s=i.default.getFirstMatch(/se ([\d.]+)x/i,e),a=r||l||s;return a&&(t.version=a),t}},{test:[/MiuiBrowser/i],describe:function(e){var t={name:"Miui"},r=i.default.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){return!!e.hasBrand("DuckDuckGo")||e.test(/\sDdg\/[\d.]+$/i)},describe:function(e,t){var r={name:"DuckDuckGo"};if(t){var l=t.getBrandVersion("DuckDuckGo");if(l)return r.version=l,r}var s=i.default.getFirstMatch(/\sDdg\/([\d.]+)$/i,e);return s&&(r.version=s),r}},{test:function(e){return e.hasBrand("Brave")},describe:function(e,t){var r={name:"Brave"};if(t){var l=t.getBrandVersion("Brave");if(l)return r.version=l,r}return r}},{test:[/chromium/i],describe:function(e){var t={name:"Chromium"},r=i.default.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(n,e);return r&&(t.version=r),t}},{test:[/chrome|crios|crmo/i],describe:function(e){var t={name:"Chrome"},r=i.default.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/GSA/i],describe:function(e){var t={name:"Google Search"},r=i.default.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){var t=!e.test(/like android/i),r=e.test(/android/i);return t&&r},describe:function(e){var t={name:"Android Browser"},r=i.default.getFirstMatch(n,e);return r&&(t.version=r),t}},{test:[/playstation 4/i],describe:function(e){var t={name:"PlayStation 4"},r=i.default.getFirstMatch(n,e);return r&&(t.version=r),t}},{test:[/safari|applewebkit/i],describe:function(e){var t={name:"Safari"},r=i.default.getFirstMatch(n,e);return r&&(t.version=r),t}},{test:[/.*/i],describe:function(e){var t=e.search("\\(")!==-1?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return{name:i.default.getFirstMatch(t,e),version:i.default.getSecondMatch(t,e)}}}];d.default=f,g.exports=d.default},93:function(g,d,b){"use strict";d.__esModule=!0,d.default=void 0;var u,i=(u=b(17))&&u.__esModule?u:{default:u},n=b(18),f=[{test:[/Roku\/DVP/],describe:function(e){var t=i.default.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,e);return{name:n.OS_MAP.Roku,version:t}}},{test:[/windows phone/i],describe:function(e){var t=i.default.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,e);return{name:n.OS_MAP.WindowsPhone,version:t}}},{test:[/windows /i],describe:function(e){var t=i.default.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,e),r=i.default.getWindowsVersionName(t);return{name:n.OS_MAP.Windows,version:t,versionName:r}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(e){var t={name:n.OS_MAP.iOS},r=i.default.getSecondMatch(/(Version\/)(\d[\d.]+)/,e);return r&&(t.version=r),t}},{test:[/macintosh/i],describe:function(e){var t=i.default.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,e).replace(/[_\s]/g,"."),r=i.default.getMacOSVersionName(t),l={name:n.OS_MAP.MacOS,version:t};return r&&(l.versionName=r),l}},{test:[/(ipod|iphone|ipad)/i],describe:function(e){var t=i.default.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,e).replace(/[_\s]/g,".");return{name:n.OS_MAP.iOS,version:t}}},{test:[/OpenHarmony/i],describe:function(e){var t=i.default.getFirstMatch(/OpenHarmony\s+(\d+(\.\d+)*)/i,e);return{name:n.OS_MAP.HarmonyOS,version:t}}},{test:function(e){var t=!e.test(/like android/i),r=e.test(/android/i);return t&&r},describe:function(e){var t=i.default.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,e),r=i.default.getAndroidVersionName(t),l={name:n.OS_MAP.Android,version:t};return r&&(l.versionName=r),l}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t=i.default.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,e),r={name:n.OS_MAP.WebOS};return t&&t.length&&(r.version=t),r}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t=i.default.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,e)||i.default.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,e)||i.default.getFirstMatch(/\bbb(\d+)/i,e);return{name:n.OS_MAP.BlackBerry,version:t}}},{test:[/bada/i],describe:function(e){var t=i.default.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,e);return{name:n.OS_MAP.Bada,version:t}}},{test:[/tizen/i],describe:function(e){var t=i.default.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,e);return{name:n.OS_MAP.Tizen,version:t}}},{test:[/linux/i],describe:function(){return{name:n.OS_MAP.Linux}}},{test:[/CrOS/],describe:function(){return{name:n.OS_MAP.ChromeOS}}},{test:[/PlayStation 4/],describe:function(e){var t=i.default.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,e);return{name:n.OS_MAP.PlayStation4,version:t}}}];d.default=f,g.exports=d.default},94:function(g,d,b){"use strict";d.__esModule=!0,d.default=void 0;var u,i=(u=b(17))&&u.__esModule?u:{default:u},n=b(18),f=[{test:[/googlebot/i],describe:function(){return{type:n.PLATFORMS_MAP.bot,vendor:"Google"}}},{test:[/linespider/i],describe:function(){return{type:n.PLATFORMS_MAP.bot,vendor:"Line"}}},{test:[/amazonbot/i],describe:function(){return{type:n.PLATFORMS_MAP.bot,vendor:"Amazon"}}},{test:[/gptbot/i],describe:function(){return{type:n.PLATFORMS_MAP.bot,vendor:"OpenAI"}}},{test:[/chatgpt-user/i],describe:function(){return{type:n.PLATFORMS_MAP.bot,vendor:"OpenAI"}}},{test:[/oai-searchbot/i],describe:function(){return{type:n.PLATFORMS_MAP.bot,vendor:"OpenAI"}}},{test:[/baiduspider/i],describe:function(){return{type:n.PLATFORMS_MAP.bot,vendor:"Baidu"}}},{test:[/bingbot/i],describe:function(){return{type:n.PLATFORMS_MAP.bot,vendor:"Bing"}}},{test:[/duckduckbot/i],describe:function(){return{type:n.PLATFORMS_MAP.bot,vendor:"DuckDuckGo"}}},{test:[/claudebot/i,/claude-web/i,/claude-user/i,/claude-searchbot/i],describe:function(){return{type:n.PLATFORMS_MAP.bot,vendor:"Anthropic"}}},{test:[/omgilibot/i,/webzio-extended/i],describe:function(){return{type:n.PLATFORMS_MAP.bot,vendor:"Webz.io"}}},{test:[/diffbot/i],describe:function(){return{type:n.PLATFORMS_MAP.bot,vendor:"Diffbot"}}},{test:[/perplexitybot/i],describe:function(){return{type:n.PLATFORMS_MAP.bot,vendor:"Perplexity AI"}}},{test:[/perplexity-user/i],describe:function(){return{type:n.PLATFORMS_MAP.bot,vendor:"Perplexity AI"}}},{test:[/youbot/i],describe:function(){return{type:n.PLATFORMS_MAP.bot,vendor:"You.com"}}},{test:[/ia_archiver/i],describe:function(){return{type:n.PLATFORMS_MAP.bot,vendor:"Internet Archive"}}},{test:[/meta-webindexer/i],describe:function(){return{type:n.PLATFORMS_MAP.bot,vendor:"Meta"}}},{test:[/meta-externalads/i],describe:function(){return{type:n.PLATFORMS_MAP.bot,vendor:"Meta"}}},{test:[/meta-externalagent/i],describe:function(){return{type:n.PLATFORMS_MAP.bot,vendor:"Meta"}}},{test:[/meta-externalfetcher/i],describe:function(){return{type:n.PLATFORMS_MAP.bot,vendor:"Meta"}}},{test:[/facebookexternalhit/i,/facebookcatalog/i],describe:function(){return{type:n.PLATFORMS_MAP.bot,vendor:"Meta"}}},{test:[/slackbot/i,/slack-imgProxy/i],describe:function(){return{type:n.PLATFORMS_MAP.bot,vendor:"Slack"}}},{test:[/yahoo/i],describe:function(){return{type:n.PLATFORMS_MAP.bot,vendor:"Yahoo"}}},{test:[/yandexbot/i,/yandexmobilebot/i],describe:function(){return{type:n.PLATFORMS_MAP.bot,vendor:"Yandex"}}},{test:[/pingdom/i],describe:function(){return{type:n.PLATFORMS_MAP.bot,vendor:"Pingdom"}}},{test:[/huawei/i],describe:function(e){var t=i.default.getFirstMatch(/(can-l01)/i,e)&&"Nova",r={type:n.PLATFORMS_MAP.mobile,vendor:"Huawei"};return t&&(r.model=t),r}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:function(){return{type:n.PLATFORMS_MAP.tablet,vendor:"Nexus"}}},{test:[/ipad/i],describe:function(){return{type:n.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(){return{type:n.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/kftt build/i],describe:function(){return{type:n.PLATFORMS_MAP.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"}}},{test:[/silk/i],describe:function(){return{type:n.PLATFORMS_MAP.tablet,vendor:"Amazon"}}},{test:[/tablet(?! pc)/i],describe:function(){return{type:n.PLATFORMS_MAP.tablet}}},{test:function(e){var t=e.test(/ipod|iphone/i),r=e.test(/like (ipod|iphone)/i);return t&&!r},describe:function(e){var t=i.default.getFirstMatch(/(ipod|iphone)/i,e);return{type:n.PLATFORMS_MAP.mobile,vendor:"Apple",model:t}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:function(){return{type:n.PLATFORMS_MAP.mobile,vendor:"Nexus"}}},{test:[/Nokia/i],describe:function(e){var t=i.default.getFirstMatch(/Nokia\s+([0-9]+(\.[0-9]+)?)/i,e),r={type:n.PLATFORMS_MAP.mobile,vendor:"Nokia"};return t&&(r.model=t),r}},{test:[/[^-]mobi/i],describe:function(){return{type:n.PLATFORMS_MAP.mobile}}},{test:function(e){return e.getBrowserName(!0)==="blackberry"},describe:function(){return{type:n.PLATFORMS_MAP.mobile,vendor:"BlackBerry"}}},{test:function(e){return e.getBrowserName(!0)==="bada"},describe:function(){return{type:n.PLATFORMS_MAP.mobile}}},{test:function(e){return e.getBrowserName()==="windows phone"},describe:function(){return{type:n.PLATFORMS_MAP.mobile,vendor:"Microsoft"}}},{test:function(e){var t=Number(String(e.getOSVersion()).split(".")[0]);return e.getOSName(!0)==="android"&&t>=3},describe:function(){return{type:n.PLATFORMS_MAP.tablet}}},{test:function(e){return e.getOSName(!0)==="android"},describe:function(){return{type:n.PLATFORMS_MAP.mobile}}},{test:[/smart-?tv|smarttv/i],describe:function(){return{type:n.PLATFORMS_MAP.tv}}},{test:[/netcast/i],describe:function(){return{type:n.PLATFORMS_MAP.tv}}},{test:function(e){return e.getOSName(!0)==="macos"},describe:function(){return{type:n.PLATFORMS_MAP.desktop,vendor:"Apple"}}},{test:function(e){return e.getOSName(!0)==="windows"},describe:function(){return{type:n.PLATFORMS_MAP.desktop}}},{test:function(e){return e.getOSName(!0)==="linux"},describe:function(){return{type:n.PLATFORMS_MAP.desktop}}},{test:function(e){return e.getOSName(!0)==="playstation 4"},describe:function(){return{type:n.PLATFORMS_MAP.tv}}},{test:function(e){return e.getOSName(!0)==="roku"},describe:function(){return{type:n.PLATFORMS_MAP.tv}}}];d.default=f,g.exports=d.default},95:function(g,d,b){"use strict";d.__esModule=!0,d.default=void 0;var u,i=(u=b(17))&&u.__esModule?u:{default:u},n=b(18),f=[{test:function(e){return e.getBrowserName(!0)==="microsoft edge"},describe:function(e){if(/\sedg\//i.test(e))return{name:n.ENGINE_MAP.Blink};var t=i.default.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,e);return{name:n.ENGINE_MAP.EdgeHTML,version:t}}},{test:[/trident/i],describe:function(e){var t={name:n.ENGINE_MAP.Trident},r=i.default.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){return e.test(/presto/i)},describe:function(e){var t={name:n.ENGINE_MAP.Presto},r=i.default.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){var t=e.test(/gecko/i),r=e.test(/like gecko/i);return t&&!r},describe:function(e){var t={name:n.ENGINE_MAP.Gecko},r=i.default.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/(apple)?webkit\/537\.36/i],describe:function(){return{name:n.ENGINE_MAP.Blink}}},{test:[/(apple)?webkit/i],describe:function(e){var t={name:n.ENGINE_MAP.WebKit},r=i.default.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}}];d.default=f,g.exports=d.default}})}))});export default x();
|
|
@@ -1,4 +0,0 @@
|
|
|
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 g,c as F}from"./chunk-XNSSUVT6.js";import{a as y}from"./chunk-PXS5SHOV.js";import{a as h}from"./chunk-NT32UURL.js";import"./chunk-LMDWRRX4.js";import"./chunk-TAWLERZA.js";import"./chunk-CQLH4UVX.js";import"./chunk-OKRK6JPY.js";import"./chunk-OE4KH3NJ.js";import"./chunk-KRXTI4JO.js";import{J as l}from"./chunk-DPQPXBTP.js";import"./chunk-NAA7GF6Q.js";import"./chunk-J5DVLUKY.js";import"./chunk-WHC7AYZD.js";import*as b from"fs";import*as d from"path";function m(e){return{content:[{type:"text",text:typeof e=="string"?e:JSON.stringify(e,null,2)}]}}function w(e){return{content:[{type:"text",text:e}],isError:!0}}var S="Feishu is not configured (missing FEISHU_APP_ID / FEISHU_APP_SECRET). Set them in the Cortex config and restart, and grant the app docx/drive/wiki/bitable/sheets scopes.";function x(e){let t=e;if(t&&typeof t.code=="number"&&t.code!==0)throw new Error(`Feishu API error ${t.code}: ${t.msg??"unknown"}`);return t?.data??t}async function _(e,t){if(!e)return w(S);try{return await t(e)}catch(i){return w(`Feishu operation failed: ${i.message}`)}}function E(e){let t=d.extname(e).toLowerCase();return{".pdf":"pdf",".doc":"doc",".xls":"xls",".ppt":"ppt",".mp4":"mp4",".opus":"opus"}[t]||"stream"}async function N(e,t,i){let n=await e.im.v1.file.create({data:{file_type:E(i),file_name:i,file:b.readFileSync(t)}}),c=x(n).file_key;if(!c)throw new Error("Feishu file upload failed: no file_key returned");return c}async function k(e,{channel:t,filePath:i,fileName:n,title:c}){let{resolved:r,size:a}=h(i),p=n||d.basename(r),f=g(t,"feishu:"),s=await y(e,r,a),u=s?"image":"file",o=JSON.stringify(s?{image_key:s}:{file_key:await N(e,r,p)});return await e.im.v1.message.create({params:{receive_id_type:"chat_id"},data:{receive_id:f,msg_type:u,content:o}}),{path:r,fileName:p,size:a}}function z(e,t){e.tool("feishu_send_file","Share a local or remote-device file in Feishu.",{file_path:l.string().describe("File path to upload. Local path, or an absolute path on `device`."),file_name:l.string().optional().describe("Optional filename override shown in Feishu"),title:l.string().optional().describe("Optional file title shown in Feishu"),channel:l.string().optional().describe("Optional chat/channel ID (uses route context if not provided)"),device:l.string().optional().describe("Connected device to read from; omit for this server.")},async({file_path:i,file_name:n,title:c,channel:r,device:a})=>_(t.client,async p=>{let f=r||t.fallbackChannel||"";if(!f)throw new Error("No Feishu channel available (no session channel or channel parameter)");let s=(o,v)=>k(p,{channel:f,filePath:o,fileName:v,title:c});if(!a){let o=await s(i,n);return m(`File uploaded: ${o.fileName} (${o.size} bytes)`)}let u=await F(t.ctx,a,i,o=>s(o.localPath,n||o.name));return m(`File uploaded from ${a}: ${u.fileName} (${u.size} bytes)`)}))}export{z as registerFileTools,k as uploadFileToFeishu};
|