@cortex-agent/server 2026.11.17 → 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/README.md +5 -5
- package/THIRD_PARTY_NOTICES.txt +860 -294
- package/defaults/hooks/quota-stop.mjs +37 -0
- 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/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-VTL3Z2OP.js → chunk-2ABET62E.js} +1 -1
- package/dist/chunks/chunk-2BVUA256.js +4 -0
- package/dist/chunks/{chunk-4YLAGSDM.js → chunk-2WFL62UO.js} +1 -1
- package/dist/chunks/{chunk-LQTFDC67.js → chunk-335SSANX.js} +1 -1
- package/dist/chunks/chunk-377OPTXX.js +17 -0
- package/dist/chunks/chunk-3EZNVLBF.js +129 -0
- package/dist/chunks/{chunk-V6X7Y62J.js → chunk-3O6ZG5HA.js} +1 -1
- package/dist/chunks/{chunk-6AKUD3CF.js → chunk-3XLHL5YT.js} +1 -1
- package/dist/chunks/{chunk-2ATTYCRJ.js → chunk-4HRI75GU.js} +1 -1
- 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-S3MR37DL.js → chunk-5FHETFZM.js} +1 -1
- package/dist/chunks/{chunk-CEGSDGYQ.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-B3NB243Z.js +4 -0
- package/dist/chunks/{chunk-XPPZ6Y3X.js → chunk-BKYP6AGM.js} +1 -1
- package/dist/chunks/{chunk-QUXPMNFQ.js → chunk-BVEDNESB.js} +1 -1
- 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-5PAW3DEU.js → chunk-CI2RHH74.js} +4 -4
- package/dist/chunks/{chunk-OFEPDNRB.js → chunk-CMSOOLJB.js} +1 -1
- 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-ROVKOIHF.js → chunk-DK4UCK7L.js} +1 -1
- package/dist/chunks/chunk-DYLBVUAU.js +4 -0
- package/dist/chunks/{chunk-WBSE3EF3.js → chunk-FDC2GRBK.js} +1 -1
- 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-2VVRTJQN.js → chunk-HVN37UXD.js} +1 -1
- package/dist/chunks/{chunk-53TQNK7Z.js → chunk-IGZWZP7Z.js} +1 -1
- package/dist/chunks/{chunk-AFTBQRPN.js → chunk-IJ7XFQMI.js} +1 -1
- package/dist/chunks/{chunk-U23S37TT.js → chunk-IMMGYDAB.js} +1 -1
- package/dist/chunks/chunk-IOWBF7UK.js +10 -0
- package/dist/chunks/{chunk-MGYYSX7Y.js → chunk-ITGCWQFK.js} +1 -1
- package/dist/chunks/{chunk-QEL6CMLE.js → chunk-IVZ7QUEG.js} +1 -1
- package/dist/chunks/{chunk-EE3WT25T.js → chunk-IWY2HIFK.js} +1 -1
- package/dist/chunks/{chunk-KGJZAYQD.js → chunk-J7OBATRN.js} +1 -1
- package/dist/chunks/{chunk-NXZS5PEW.js → chunk-JGUEIW2W.js} +1 -1
- package/dist/chunks/chunk-JZ7U7RUK.js +351 -0
- package/dist/chunks/{chunk-VIMHSW6J.js → chunk-KJUQCCB5.js} +1 -1
- package/dist/chunks/{chunk-BUZQBTV2.js → chunk-KST6OY76.js} +1 -1
- package/dist/chunks/{chunk-KDPY2YA3.js → chunk-KZSAFVSY.js} +2 -2
- package/dist/chunks/chunk-LD2ZSH3M.js +903 -0
- package/dist/chunks/{chunk-RYLSRII6.js → chunk-LE6QPXN6.js} +1 -1
- package/dist/chunks/{chunk-TX46YMGI.js → chunk-LIIZI3HY.js} +1 -1
- package/dist/chunks/{chunk-3CZPBLB3.js → chunk-MJQ2D2OP.js} +1 -1
- package/dist/chunks/{chunk-P7TVR4GY.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-T73GHMFB.js → chunk-OJ37ZWBG.js} +1 -1
- package/dist/chunks/{chunk-7GEBDPTT.js → chunk-OZXMPBUX.js} +1 -1
- package/dist/chunks/chunk-PG7452XE.js +4 -0
- package/dist/chunks/chunk-PJCUB7YJ.js +4 -0
- package/dist/chunks/{chunk-RA2BUYI3.js → chunk-PTS3J4DQ.js} +1 -1
- package/dist/chunks/{chunk-2ROGTDM2.js → chunk-PVVEEBUU.js} +1 -1
- package/dist/chunks/{chunk-W6AKCEYF.js → chunk-Q7BZLPBU.js} +1 -1
- package/dist/chunks/{chunk-SY2HV3V5.js → chunk-QC66ZXPP.js} +1 -1
- package/dist/chunks/chunk-QXFWIL4C.js +4 -0
- package/dist/chunks/{chunk-NRD57ICT.js → chunk-R2CCD4OF.js} +1 -1
- package/dist/chunks/{chunk-R52AVUQB.js → chunk-RG5GP4RB.js} +1 -1
- package/dist/chunks/{chunk-IKLTEWA3.js → chunk-RW2F2QNP.js} +1 -1
- package/dist/chunks/{chunk-XEBEWR6Y.js → chunk-RWPO3NZ3.js} +1 -1
- package/dist/chunks/chunk-SDUS2H3E.js +4 -0
- package/dist/chunks/chunk-SIHGKM4E.js +4 -0
- package/dist/chunks/{chunk-NNBSSISP.js → chunk-SKHFU5DI.js} +1 -1
- package/dist/chunks/{chunk-STUHNKQS.js → chunk-SM45TH22.js} +1 -1
- package/dist/chunks/chunk-T54CZKNJ.js +6 -0
- package/dist/chunks/chunk-TRXLIL7V.js +4 -0
- package/dist/chunks/{chunk-KUDK7GPS.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-BDLKI2NT.js → chunk-VHX2GHBF.js} +1 -1
- package/dist/chunks/chunk-VOAKRJ4R.js +4 -0
- package/dist/chunks/{chunk-FP7ML72L.js → chunk-WU7RNAZD.js} +1 -1
- package/dist/chunks/chunk-WZC4TDDM.js +6 -0
- package/dist/chunks/chunk-X2TKJ7KR.js +11 -0
- package/dist/chunks/{chunk-H4QZ2P3Z.js → chunk-X5ND4H4P.js} +1 -1
- package/dist/chunks/{chunk-5A6CA5TM.js → chunk-Y3AOGNDT.js} +1 -1
- package/dist/chunks/chunk-Y6DGVTKM.js +6 -0
- package/dist/chunks/{chunk-LP7T32PW.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-CZH7AYZ7.js → easter-egg-3d-XR5S2O3T.js} +1 -1
- package/dist/chunks/execution-repo-5TLV2NM4.js +4 -0
- package/dist/chunks/{executions-BN6OLLVM.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-ABBD7DO5.js → install-cli-FALWKQYO.js} +1 -1
- package/dist/chunks/{interaction-ask-EE2UPR3Q.js → interaction-ask-O5HGF6CH.js} +1 -1
- package/dist/chunks/{interaction-plan-C446T2GZ.js → interaction-plan-JTVDN3BC.js} +1 -1
- package/dist/chunks/kimi-coding-ZCIBMDZ6.js +4 -0
- package/dist/chunks/{llama-cpp-classify-IA2F2H7A.js → llama-cpp-classify-NRUXAIGQ.js} +3 -3
- package/dist/chunks/local-client-stop-RS4AHNF4.js +4 -0
- package/dist/chunks/memory-cli-DIT4DQF3.js +11 -0
- 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/openai-codex-responses-U6DGMGDK.js +12 -0
- package/dist/chunks/openai-completions-PP4XLLOM.js +9 -0
- package/dist/chunks/{openai-decisions-P5UX7BWY.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/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-6PLXHSTB.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-W5M3BE55.js → waitpoint-M6JZBSLT.js} +1 -1
- package/dist/chunks/workers-SQ2R32TK.js +4 -0
- package/dist/client-bundle/client.mjs +229 -62
- 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 +1 -1
- package/dist/entry/app.js +138 -556
- package/dist/entry/browser-cli.js +1 -1
- package/dist/entry/cli.js +1 -1
- package/dist/entry/cortex-cli.js +1 -1
- package/dist/entry/daemon.js +3 -3
- package/dist/entry/hook-cli.js +1 -1
- 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 +1 -1
- package/dist/tui/index.js +1 -1
- package/package.json +1 -1
- 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-BgIyUG-C.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-C2eMpcuI.js → index-jl30Gy8P.js} +1 -1
- package/web/dist/index.html +2 -2
- package/dist/chunks/anthropic-messages-M732OMEE.js +0 -8
- package/dist/chunks/azure-openai-responses-RAKTV6JY.js +0 -4
- package/dist/chunks/bedrock-converse-stream-WNUGNZ27.js +0 -62
- package/dist/chunks/child-runner-MO5RT6FH.js +0 -4
- package/dist/chunks/chunk-3CPIMAYX.js +0 -30
- package/dist/chunks/chunk-3ORG56I5.js +0 -8
- package/dist/chunks/chunk-4EX2JJWB.js +0 -4
- package/dist/chunks/chunk-5DF5WJNM.js +0 -60
- package/dist/chunks/chunk-7GAYFN52.js +0 -18
- package/dist/chunks/chunk-AVXDF7AG.js +0 -4
- package/dist/chunks/chunk-BJGYGEZO.js +0 -6
- package/dist/chunks/chunk-BZDIAI5M.js +0 -125
- package/dist/chunks/chunk-CK3P345X.js +0 -133
- package/dist/chunks/chunk-CVC66CFV.js +0 -33
- package/dist/chunks/chunk-ETIBCA2S.js +0 -4
- package/dist/chunks/chunk-FF7UELTU.js +0 -4
- 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-IYVZHGUQ.js +0 -5
- package/dist/chunks/chunk-JJDEQ6N2.js +0 -4
- package/dist/chunks/chunk-KDYEGGMW.js +0 -4
- package/dist/chunks/chunk-L6VCIGWS.js +0 -11
- package/dist/chunks/chunk-LACGULCN.js +0 -10
- package/dist/chunks/chunk-LAWOWPZX.js +0 -363
- package/dist/chunks/chunk-NNTQUHLO.js +0 -877
- package/dist/chunks/chunk-OE4KH3NJ.js +0 -4
- package/dist/chunks/chunk-OSEIQ7SS.js +0 -4
- package/dist/chunks/chunk-PZMGBKUR.js +0 -13
- package/dist/chunks/chunk-QBKCAIJG.js +0 -4
- package/dist/chunks/chunk-QMSSIDRQ.js +0 -70
- package/dist/chunks/chunk-QUUEQRIT.js +0 -4
- package/dist/chunks/chunk-RA6HKFBV.js +0 -4
- package/dist/chunks/chunk-RDW6FRF5.js +0 -4
- package/dist/chunks/chunk-RF4JLYBX.js +0 -6
- package/dist/chunks/chunk-SFX7V5O2.js +0 -10
- package/dist/chunks/chunk-SKHLZ6XY.js +0 -9
- package/dist/chunks/chunk-STCNHXPJ.js +0 -6
- package/dist/chunks/chunk-UT6DGZDO.js +0 -4
- package/dist/chunks/chunk-VBN2JSER.js +0 -5
- package/dist/chunks/chunk-VK5J556O.js +0 -4
- package/dist/chunks/chunk-VPVSKJGX.js +0 -6
- package/dist/chunks/chunk-VQUPKMDR.js +0 -4
- package/dist/chunks/chunk-WEZWKMYU.js +0 -4
- package/dist/chunks/chunk-XYSXL3KX.js +0 -4
- package/dist/chunks/chunk-Y3GFB5XM.js +0 -8
- package/dist/chunks/chunk-YAAKL3QS.js +0 -80
- package/dist/chunks/chunk-YB5LUJHS.js +0 -65
- package/dist/chunks/chunk-YKKEI5GI.js +0 -4
- package/dist/chunks/chunk-Z24SBRJK.js +0 -4
- package/dist/chunks/cli-5DBTRMHU.js +0 -53
- package/dist/chunks/cloudflare-workers-ai-system-one-32JCFHI3.js +0 -4
- package/dist/chunks/context-GQKWKFRM.js +0 -4
- package/dist/chunks/cost-OOO32GLC.js +0 -5
- package/dist/chunks/dist-V5FRMUFH.js +0 -4
- package/dist/chunks/execution-repo-XXL4FXC6.js +0 -4
- package/dist/chunks/file-H572PL2Z.js +0 -4
- package/dist/chunks/github-copilot-HAI2DA62.js +0 -4
- package/dist/chunks/google-generative-ai-2G4ITOZL.js +0 -4
- package/dist/chunks/google-vertex-PACHCMRZ.js +0 -4
- package/dist/chunks/init-75F4V7SK.js +0 -4
- package/dist/chunks/kimi-coding-HMJRKCPA.js +0 -4
- package/dist/chunks/local-client-stop-5YOLXGYT.js +0 -4
- package/dist/chunks/memory-cli-5SSF6YJM.js +0 -11
- package/dist/chunks/meta-KY3LNFV2.js +0 -4
- package/dist/chunks/mistral-conversations-VHP63CDS.js +0 -7
- package/dist/chunks/model-resolver-FVJNZ6NA.js +0 -4
- package/dist/chunks/openai-codex-responses-EHJ4AZBE.js +0 -12
- package/dist/chunks/openai-completions-CRAGQFCE.js +0 -9
- package/dist/chunks/openai-responses-IZ22NVQ7.js +0 -6
- package/dist/chunks/openrouter-images-W2JAMSRH.js +0 -4
- package/dist/chunks/pi-messages-MJEEQU2R.js +0 -10
- package/dist/chunks/radius-ZM7ZRMXF.js +0 -4
- package/dist/chunks/remote-ops-O5CR4RGA.js +0 -14
- package/dist/chunks/runner-S6R3US24.js +0 -4
- package/dist/chunks/runtime-6YLTA2ZD.js +0 -4
- package/dist/chunks/schedule-cli-4T4YC5V5.js +0 -4
- package/dist/chunks/slack-2CGM4SMY.js +0 -4
- package/dist/chunks/start-ui-http-3D7QNHGB.js +0 -43
- package/dist/chunks/subagent-OZGUOV3J.js +0 -4
- package/dist/chunks/tool-shims-IA2WELXJ.js +0 -4
- package/dist/chunks/typesafe-system-one-6ULACYD4.js +0 -4
- package/dist/chunks/ui-board-H4INJD6C.js +0 -5
- package/dist/chunks/ui-decision-6HHNROIT.js +0 -4
- package/dist/chunks/ui-view-6MDU4GXY.js +0 -4
- package/dist/chunks/virtual-modules-OFI7QKYH.js +0 -4
- package/dist/chunks/workers-GTFP75MS.js +0 -4
- 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-9lyu2S6W.css +0 -1
- package/web/dist/assets/index-C-hpzey7.js +0 -532
|
@@ -1,60 +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{d as X}from"./chunk-FX6MOGLR.js";import{F as h,Ia as R,R as w,f as W,s as I,v as F,w as G,x as H,y as N,za as J}from"./chunk-CK3P345X.js";import{e as k,na as x}from"./chunk-LACGULCN.js";import{h as P,w as U}from"./chunk-QUUEQRIT.js";import{randomBytes as be}from"node:crypto";import{createWriteStream as Le}from"node:fs";import{writeFile as Ce}from"node:fs/promises";import{tmpdir as Me}from"node:os";import{join as ke}from"node:path";var q=384;function z(e,t){return ke(Me(),`${e}-${be(8).toString("hex")}${t}`)}async function Pt(e,t,n){let r=z(e,t);return await Ce(r,n,{mode:q,flag:"wx"}),r}function Ut(e,t){let n=z(e,t);return{path:n,stream:Le(n,{mode:q,flags:"wx"})}}var Ft=2e3,Gt=51200;function B(e){if(e.length===0)return[];let t=e.split(`
|
|
5
|
-
`);return e.endsWith(`
|
|
6
|
-
`)&&t.pop(),t}function Ht(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function Jt(e,t={}){let n=t.maxLines??2e3,r=t.maxBytes??51200,o=Buffer.byteLength(e,"utf-8"),i=B(e),s=i.length;if(s<=n&&o<=r)return{content:e,truncated:!1,truncatedBy:null,totalLines:s,totalBytes:o,outputLines:s,outputBytes:o,lastLinePartial:!1,firstLineExceedsLimit:!1,maxLines:n,maxBytes:r};if(Buffer.byteLength(i[0],"utf-8")>r)return{content:"",truncated:!0,truncatedBy:"bytes",totalLines:s,totalBytes:o,outputLines:0,outputBytes:0,lastLinePartial:!1,firstLineExceedsLimit:!0,maxLines:n,maxBytes:r};let l=[],c=0,p="lines";for(let d=0;d<i.length&&d<n;d++){let m=i[d],y=Buffer.byteLength(m,"utf-8")+(d>0?1:0);if(c+y>r){p="bytes";break}l.push(m),c+=y}l.length>=n&&c<=r&&(p="lines");let u=l.join(`
|
|
7
|
-
`),f=Buffer.byteLength(u,"utf-8");return{content:u,truncated:!0,truncatedBy:p,totalLines:s,totalBytes:o,outputLines:l.length,outputBytes:f,lastLinePartial:!1,firstLineExceedsLimit:!1,maxLines:n,maxBytes:r}}function Xt(e,t={}){let n=t.maxLines??2e3,r=t.maxBytes??51200,o=Buffer.byteLength(e,"utf-8"),i=B(e),s=i.length;if(s<=n&&o<=r)return{content:e,truncated:!1,truncatedBy:null,totalLines:s,totalBytes:o,outputLines:s,outputBytes:o,lastLinePartial:!1,firstLineExceedsLimit:!1,maxLines:n,maxBytes:r};let a=[],l=0,c="lines",p=!1;for(let d=i.length-1;d>=0&&a.length<n;d--){let m=i[d],y=Buffer.byteLength(m,"utf-8")+(a.length>0?1:0);if(l+y>r){if(c="bytes",a.length===0){let A=Ie(m,r);a.unshift(A),l=Buffer.byteLength(A,"utf-8"),p=!0}break}a.unshift(m),l+=y}a.length>=n&&l<=r&&(c="lines");let u=a.join(`
|
|
8
|
-
`),f=Buffer.byteLength(u,"utf-8");return{content:u,truncated:!0,truncatedBy:c,totalLines:s,totalBytes:o,outputLines:a.length,outputBytes:f,lastLinePartial:p,firstLineExceedsLimit:!1,maxLines:n,maxBytes:r}}function Ie(e,t){let n=Buffer.from(e,"utf-8");if(n.length<=t)return e;let r=n.length-t;for(;r<n.length&&(n[r]&192)===128;)r++;return n.slice(r).toString("utf-8")}function qt(e,t=500){return e.length<=t?{text:e,wasTruncated:!1}:{text:`${e.slice(0,t)}... [truncated]`,wasTruncated:!0}}function zt(e,t){let n=Buffer.from(e,"utf-8"),r=B(e).length;if(n.length<=t)return{content:e,truncated:!1,removedChars:0,totalBytes:n.length,totalLines:r};let o=p=>p>=n.length||(n[p]&192)!==128,i=Math.floor(t/2);for(;i>0&&!o(i);)i--;let s=n.length-(t-Math.floor(t/2));for(;s<n.length&&!o(s);)s++;let a=n.subarray(0,i).toString("utf-8"),l=n.subarray(s).toString("utf-8"),c=Array.from(n.subarray(i,s).toString("utf-8")).length;return{content:`${a}\u2026${c} chars truncated\u2026${l}`,truncated:!0,removedChars:c,totalBytes:n.length,totalLines:r}}function Ne(){return{input:0,output:0,cacheRead:0,cacheWrite:0,cost:0}}function Re(e,t){e.input+=t.input,e.output+=t.output,e.cacheRead+=t.cacheRead,e.cacheWrite+=t.cacheWrite,e.cost+=t.cost.total}function Yt(e,t){return{input:e.input+t.input,output:e.output+t.output,cacheRead:e.cacheRead+t.cacheRead,cacheWrite:e.cacheWrite+t.cacheWrite,...e.cacheWrite1h!==void 0||t.cacheWrite1h!==void 0?{cacheWrite1h:(e.cacheWrite1h??0)+(t.cacheWrite1h??0)}:{},...e.reasoning!==void 0||t.reasoning!==void 0?{reasoning:(e.reasoning??0)+(t.reasoning??0)}:{},totalTokens:e.totalTokens+t.totalTokens,cost:{input:e.cost.input+t.cost.input,output:e.cost.output+t.cost.output,cacheRead:e.cost.cacheRead+t.cost.cacheRead,cacheWrite:e.cost.cacheWrite+t.cost.cacheWrite,total:e.cost.total+t.cost.total}}}function Vt(e){let t=new Map;for(let n of e){let r,o;if(n.type==="message"&&n.message.role==="assistant"?(r=`${n.message.provider}/${n.message.responseModel??n.message.model}`,o=n.message.usage):n.type==="usage"?(r=`${n.provider}/${n.model}`,o=n.usage):n.type==="message"&&n.message.role==="toolResult"&&n.message.usage?(r="Tools/summaries",o=n.message.usage):(n.type==="branch_summary"||n.type==="compaction")&&n.usage&&(r="Tools/summaries",o=n.usage),!r||!o)continue;let i=t.get(r);i||(i=Ne(),t.set(r,i)),Re(i,o)}return Array.from(t,([n,r])=>({key:n,cost:r.cost,tokens:r.input+r.output+r.cacheRead+r.cacheWrite})).filter(n=>n.cost>0||n.tokens>0).sort((n,r)=>r.cost-n.cost)}function Be(e,t,n,r=0,o="end"){if(!e)return{visualLines:[],skippedCount:0};let s=new h(e,r,0).render(n);if(s.length<=t)return{visualLines:s,skippedCount:0};let a=o==="start"?s.slice(0,t):s.slice(-t),l=s.length-t;return{visualLines:a,skippedCount:l}}var S=class{options;cachedWidth;cachedLines;constructor(t){this.options=t}render(t){if(this.cachedLines===void 0||this.cachedWidth!==t){let{text:n,maxVisualLines:r,keep:o,formatHint:i}=this.options,s=Be(n,r,t,0,o),a=s.visualLines;if(s.skippedCount>0){let l=W(i(s.skippedCount),t,"...");this.cachedLines=o==="start"?[...a,l]:[l,...a]}else this.cachedLines=a;this.cachedWidth=t}return this.cachedLines}invalidate(){this.cachedWidth=void 0,this.cachedLines=void 0}};import*as te from"node:os";import{pathToFileURL as We}from"node:url";var De="(?:\\u0007|\\u001B\\u005C|\\u009C)",Z="\\u001B\\]",Y="[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?",je="[\\dA-PR-TZcf-nq-uy=><~]",ve=new RegExp(`(?:${Z}[\\s\\S]*?${De})|${Y}${je}`,"g"),Pe=new RegExp(`(?:${Z}(?:[^\\u0007\\u009C\\u001B]|\\u001B(?!\\\\))*|${Y})$`),Ue=256;function tn(e){if(!e.includes("\x1B")&&!e.includes("\x9B"))return{complete:e,pending:""};let t=Math.max(0,e.length-Ue),n=Pe.exec(e.slice(t));if(!n)return{complete:e,pending:""};let r=t+n.index;return{complete:e.slice(0,r),pending:e.slice(r)}}function V(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return!e.includes("\x1B")&&!e.includes("\x9B")?e:e.replace(ve,"")}function Fe(e){if(typeof e!="string")return"";let t=te.homedir();return e.startsWith(t)?`~${e.slice(t.length)}`:e}function Ge(e,t,n){if(!I().hyperlinks)return e;let r=P(t,n);return G(e,We(r).href)}function ne(e){return typeof e=="string"?e:e==null?"":null}function K(e){return typeof e=="string"&&e.trim()!==""&&(e=Number(e)),typeof e=="number"&&Number.isFinite(e)?e:void 0}function cn(e,t){if(e==null&&t==null)return"";let n=e==null?1:K(e);if(n===void 0)return"";if(t==null)return`:${n}`;let r=K(t);if(r===void 0)return"";let o=n+r-1;return`:${n}${o?`-${o}`:""}`}function _(e){return e.replace(/\t/g," ")}function ln(e){return e.replace(/\r/g,"")}function re(e,t){if(!e)return"";let n=e.content.filter(s=>s.type==="text"),r=e.content.filter(s=>s.type==="image"),o=n.map(s=>X(V(s.text||"")).replace(/\r/g,"")).join(`
|
|
9
|
-
`),i=I();if(r.length>0&&(!i.images||!t)){let s=r.map(a=>{let l=a.mimeType??"image/unknown",c=a.data&&a.mimeType?F(a.data,a.mimeType)??void 0:void 0;return H(l,c)}).join(`
|
|
10
|
-
`);o=o?`${o}
|
|
11
|
-
${s}`:s}return o}var Q=100;function pn(e,t,n,r){let o=n.fg("toolTitle",n.bold(e));if(t==null)return o;let i=typeof t=="object"&&!Array.isArray(t)?Object.entries(t):[["args",t]];if(i.length===0)return o;if(r){let l=i.map(([c,p])=>{let u=typeof p=="string"?p:JSON.stringify(p,null,2)??String(p);return` ${c}: ${_(u).replace(/\r/g,"").split(`
|
|
12
|
-
`).join(`
|
|
13
|
-
`)}`});return`${o}
|
|
14
|
-
${n.fg("muted",l.join(`
|
|
15
|
-
`))}`}let s=i.map(([l,c])=>`${l}=${JSON.stringify(c)??String(c)}`).join(" "),a=s.length>Q?`${s.slice(0,Q-3)}...`:s;return`${o} ${n.fg("muted",a)}`}function ee(e){let t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;let n=Math.floor(t),r=Math.floor(n/60),o=n%60;return r<60?`${r}m ${o}s`:`${Math.floor(r/60)}h ${r%60}m ${o}s`}function oe(e){let t=e.state;e.executionStarted&&t.startedAt===void 0&&(t.startedAt=Date.now(),t.endedAt=void 0)}function ie(e,t){let n=e.state;if(n.startedAt!==void 0&&t&&!n.interval&&(n.interval=setInterval(()=>e.invalidate(),1e3)),(!t||e.isError)&&(n.endedAt??=Date.now(),n.interval&&(clearInterval(n.interval),n.interval=void 0)),!t&&e.durationMs!==void 0)return`Took ${ee(e.durationMs)}`;if(n.startedAt===void 0)return;let r=n.endedAt??Date.now();return`${t?"Elapsed":"Took"} ${ee(r-n.startedAt)}`}function He(e){return e.fg("error","[invalid arg]")}function fn(e,t,n,r){if(e===null)return He(t);let o=e||r?.emptyFallback;return o?Ge(t.fg("accent",Fe(o)),o,n):t.fg("toolOutput","...")}function T(e){let t="";for(let n of e){let r=t===""?/^[A-Za-z_$]$/.test(n):/^[A-Za-z0-9_$]$/.test(n);t+=r?n:"_"}return t===""?"_":t}var Je=/^[A-Za-z_$][A-Za-z0-9_$]*$/,E=" ",Xe=16e3,qe=32,ze=["minimum","exclusiveMinimum","maximum","exclusiveMaximum","multipleOf","minLength","maxLength","pattern","format","minItems","maxItems"],se=new Set(["minimum","exclusiveMinimum","minLength","minItems"]),Ze=new Set(["maximum","exclusiveMaximum","maxLength","maxItems"]),Ye=80,ce=/[\r\n\u2028\u2029]/g;function Ve(e,t={}){let n=e.inputSchema===void 0?"unknown":pe(e.inputSchema,{maxChars:t.inputMaxChars??Xe});return`${T(e.name)}(args: ${n}): Promise<${j(e.outputSchema)}>;`}function le(e,t={}){let n=`declare const tools: { ${Ve(e,t)} };`;return`${e.description?.trim()??""}
|
|
16
|
-
|
|
17
|
-
codemode tool declaration:
|
|
18
|
-
\`\`\`ts
|
|
19
|
-
${n}
|
|
20
|
-
\`\`\``}function j(e){return e===void 0?"unknown":pe(e)}function Ke(e){return Je.test(e)?e:JSON.stringify(e)}function D(e){let t=[...new Set(e)];return t.includes("unknown")?"unknown":t.length===0?"never":t.join(" | ")}function pe(e,t={}){let n=i=>$(e,{root:e,resolving:new Set,expansions:0,tags:i}),r=n(!0);if(t.maxChars===void 0||r.length<=t.maxChars)return r;let o=n(!1);return o.length<=t.maxChars?o:"unknown"}function Qe(e,t){if(e!=="#"&&!e.startsWith("#/"))return;let n=t;for(let r of e.slice(2).split("/").filter(Boolean)){let o=decodeURIComponent(r).replaceAll("~1","/").replaceAll("~0","~");if(typeof n!="object"||n===null||Array.isArray(n)||!(o in n))return;n=n[o]}return typeof n=="boolean"||typeof n=="object"&&n!==null&&!Array.isArray(n)?n:void 0}function $(e,t){if(e===!0)return"unknown";if(e===!1)return"never";if(typeof e!="object"||e===null||Array.isArray(e))return"unknown";if(typeof e.$ref=="string"){let o=e.$ref;if(t.resolving.has(o)||t.expansions>=qe)return"unknown";let i=Qe(o,t.root);if(i===void 0)return"unknown";t.expansions++,t.resolving.add(o);try{return $(i,t)}finally{t.resolving.delete(o)}}if("const"in e)return JSON.stringify(e.const)??"unknown";if(Array.isArray(e.enum))return D(e.enum.map(o=>JSON.stringify(o)??"unknown"));let n=Array.isArray(e.anyOf)?e.anyOf:Array.isArray(e.oneOf)?e.oneOf:void 0;if(n)return D(n.map(o=>$(o,t)));if(Array.isArray(e.allOf)){let o=e.allOf.map(i=>$(i,t)).filter(i=>i!=="unknown");return o.length===0?"unknown":o.map(i=>i.includes(" | ")?`(${i})`:i).join(" & ")}let r=e.type;if(Array.isArray(r))return D(r.map(o=>$({...e,type:o},t)));switch(r){case"string":return"string";case"number":case"integer":return"number";case"boolean":return"boolean";case"null":return"null";case"array":return ae(e,t);case"object":return ue(e,t);case void 0:return"properties"in e||"additionalProperties"in e||"required"in e?ue(e,t):"items"in e||"prefixItems"in e?ae(e,t):"unknown";default:return"unknown"}}function ae(e,t){if(e.items!==void 0&&!Array.isArray(e.items))return`Array<${$(e.items,t)}>`;let n=Array.isArray(e.prefixItems)?e.prefixItems:Array.isArray(e.items)?e.items:[];return n.length>0?`[${n.map(r=>$(r,t)).join(", ")}]`:"unknown[]"}function et(e){let t=e?.description;return typeof t=="string"?t.trim():""}function tt(e){if(typeof e!="object"||e===null||Array.isArray(e))return"";let t=e,n=Array.isArray(t.anyOf)?t.anyOf:t.oneOf,r=Array.isArray(n)?n.filter(c=>c?.type!=="null"):[],o=r.length===1?r[0]:void 0,s=(typeof o=="object"&&o!==null&&!Array.isArray(o)?[t,o]:[t]).map(c=>({...c,...c.exclusiveMinimum===!0?{minimum:void 0,exclusiveMinimum:c.minimum}:{},...c.exclusiveMaximum===!0?{maximum:void 0,exclusiveMaximum:c.maximum}:{}})),a=[],l=c=>c==="integer"||Array.isArray(c)&&c.includes("integer");s.some(c=>l(c.type))&&a.push("@integer");for(let c of ze){let p=s.map(u=>u[c]);if(se.has(c)||Ze.has(c)){let u=p.filter(f=>typeof f=="number");if(u.length===0)continue;a.push(`@${c} ${se.has(c)?Math.max(...u):Math.min(...u)}`);continue}for(let u of new Set(p))(typeof u=="number"||typeof u=="string")&&a.push(`@${c} ${u}`)}return s.some(c=>c.uniqueItems===!0)&&a.push("@uniqueItems"),t.default!==void 0&&t.default!==null&&a.push(`@default ${JSON.stringify(t.default)}`),t.deprecated===!0&&a.push("@deprecated"),a.filter(c=>c.length<=Ye).map(c=>c.replace(ce,p=>`\\u${p.charCodeAt(0).toString(16).padStart(4,"0")}`)).join(" ")}function ue(e,t){let n=typeof e.properties=="object"&&e.properties!==null&&!Array.isArray(e.properties)?e.properties:{},r=new Set(Array.isArray(e.required)?e.required:[]),o=Object.keys(n).sort(),i=o.map(c=>{let p=r.has(c)?"":"?";return`${Ke(c)}${p}: ${$(n[c],t)};`}),s=e.additionalProperties;if(s!==void 0&&s!==!1){let c=s===!0?"unknown":$(s,t);i.push(`[key: string]: ${c};`)}else s===void 0&&o.length===0&&i.push("[key: string]: unknown;");if(i.length===0)return"{}";let a=o.map(c=>{let p=et(n[c]).split(ce).map(f=>f.trim()).filter(Boolean),u=t.tags?tt(n[c]):"";return u?[...p,u]:p});if(!a.some(c=>c.length>0))return`{ ${i.join(" ")} }`;let l=["{"];a.forEach((c,p)=>{for(let u of c)l.push(`${E}// ${u}`);l.push(`${E}${i[p].replaceAll(`
|
|
21
|
-
`,`
|
|
22
|
-
${E}`)}`)});for(let c of i.slice(o.length))l.push(`${E}${c}`);return l.push("}"),l.join(`
|
|
23
|
-
`)}var O="// @options:",nt=["max_output_tokens","timeout_ms"],b="`max_output_tokens` and `timeout_ms`";var de=String.raw`
|
|
24
|
-
start: options_source | plain_source
|
|
25
|
-
options_source: OPTIONS_LINE NEWLINE SOURCE
|
|
26
|
-
plain_source: SOURCE
|
|
27
|
-
|
|
28
|
-
OPTIONS_LINE: /[ \t]*\/\/ @options:[^\r\n]*/
|
|
29
|
-
NEWLINE: /\r?\n/
|
|
30
|
-
SOURCE: /[\s\S]+/
|
|
31
|
-
`,g=class extends Error{constructor(t){super(t),this.name="CodemodeSourceError"}};function fe(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>=0}function rt(e){if(e==="")throw new g(`@options must be a JSON object with supported fields ${b}`);let t;try{t=JSON.parse(e)}catch(s){throw new g(`@options must be valid JSON with supported fields ${b}: ${s instanceof Error?s.message:String(s)}`)}if(typeof t!="object"||t===null||Array.isArray(t))throw new g(`@options must be a JSON object with supported fields ${b}`);let n=t;for(let s of Object.keys(n))if(!nt.includes(s))throw new g(`@options only supports ${b}; got \`${s}\``);let r={},{max_output_tokens:o,timeout_ms:i}=n;if(o!==void 0){if(!fe(o))throw new g("@options field `max_output_tokens` must be a non-negative safe integer");r.maxOutputTokens=o}if(i!==void 0){if(!fe(i)||i===0||i>2147483647)throw new g("@options field `timeout_ms` must be a positive integer up to 2147483647");r.timeoutMs=i}return r}function yn(e){if(e.trim()==="")throw new g('Expected JavaScript source text (non-empty). Provide JS only, optionally with a first line `// @options: {"max_output_tokens": 1000}`.');let t=e.split(`
|
|
32
|
-
`),n=t.findIndex((a,l)=>l>0&&a.trimStart().startsWith(O));if(n!==-1)throw new g(`The ${O} line must be the first line of the input; found one on line ${n+1}`);let r=e.indexOf(`
|
|
33
|
-
`),i=t[0].replace(/\r$/,"").trimStart();if(!i.startsWith(O))return{code:e,options:{}};let s=r===-1?"":e.slice(r);if(s.trim()==="")throw new g("The @options line must be followed by JavaScript source on subsequent lines");return{code:s,options:rt(i.slice(O.length).trim())}}var C="tool_search",he=8,ot=new Set(["a","an","and","are","as","at","be","by","for","from","in","is","it","of","on","or","that","the","this","to","with"]);function it(e){return e.length>4&&e.endsWith("ies")?`${e.slice(0,-3)}y`:e.length>4&&/(ches|shes|sses|xes|zes)$/.test(e)?e.slice(0,-2):e.length>3&&e.endsWith("s")&&!e.endsWith("ss")?e.slice(0,-1):e}function me(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(t=>t.length>0&&!ot.has(t)).map(it)}function ge(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function L(e,t){if(ge(e)){if(typeof e.description=="string"&&t.push(e.description),ge(e.properties))for(let[n,r]of Object.entries(e.properties))t.push(n),L(r,t);L(e.items,t);for(let n of["anyOf","oneOf","allOf"]){let r=e[n];if(Array.isArray(r))for(let o of r)L(o,t)}}}function st(e,t){let n=[e.name,e.name.replaceAll("_"," "),e.description];return L(e.parameters,n),t&&n.push(t.name,t.description??"",t.instructions??""),{name:e.name,text:n.filter(r=>r.trim()).join(" ")}}var v=class{k1;b;constructor(t={}){this.k1=t.k1??1.2,this.b=t.b??.75}rank(t,n,r){let o=[...new Set(me(t))];if(o.length===0||n.length===0||r<=0)return[];let i=n.map(p=>{let u=new Map;for(let f of me(p.text))u.set(f,(u.get(f)??0)+1);return u}),s=i.map(p=>[...p.values()].reduce((u,f)=>u+f,0)),a=s.reduce((p,u)=>p+u,0)/n.length||1,l=new Map(o.map(p=>{let u=i.filter(f=>f.has(p)).length;return[p,Math.log(1+(n.length-u+.5)/(u+.5))]})),c=[];return n.forEach((p,u)=>{let f=0;for(let d of o){let m=i[u].get(d);if(!m)continue;let y=this.k1*(1-this.b+this.b*s[u]/a);f+=(l.get(d)??0)*(m*(this.k1+1)/(m+y))}f>0&&c.push({name:p.name,score:f})}),c.sort((p,u)=>u.score-p.score).slice(0,r)}},at=x.Object({query:x.String({description:"Search query for deferred tools."}),limit:x.Optional(x.Number({description:`Maximum number of tools to return. Defaults to ${he}.`}))});function ut(e){return e==="codemode"||e==="deferred"}function ct(e,t,n){let r=e.getActiveTools(),o=e.getAllTools().filter(a=>ut(a.exposure)&&!r.includes(a.name)),i=o.map(a=>st(a,a.namespace)),s=new v().rank(t,i,n);return s.length>0&&e.setActiveTools([...r,...s.map(a=>a.name)]),s.map(a=>({name:a.name,description:o.find(l=>l.name===a.name)?.description??""}))}var lt=`# Tool discovery
|
|
34
|
-
|
|
35
|
-
Searches over deferred tool metadata with BM25 and exposes matching tools for the next model call.
|
|
36
|
-
|
|
37
|
-
Some of the tools, such as tools of MCP servers, may not have been provided to you upfront, and you should use this tool (\`${C}\`) to search for the required tools. For MCP tool discovery, always use \`${C}\`.`;function Sn(e={}){return{name:C,label:C,description:lt,promptSnippet:"Search for tools that are not loaded yet and load the matches",parameters:at,exposure:"model-only",reachesTools:()=>"all",async execute(t,{query:n,limit:r}){if(n.trim()==="")throw new Error("query must not be empty");let o=r??he;if(!Number.isInteger(o)||o<=0)throw new Error("limit must be a positive integer");let i=e.tools?ct(e.tools,n,o):[];return{content:[{type:"text",text:i.length===0?"No matching tools found.":`Loaded ${i.length} tool${i.length===1?"":"s"}. They are available from your next call:
|
|
38
|
-
${i.map(a=>`- ${a.name}: ${a.description.trim().split(/\r?\n/)[0]}`).join(`
|
|
39
|
-
`)}`}],details:{loaded:i.map(a=>a.name)}}}}}import{join as xt}from"node:path";function pt(e,t){return{name:e.name,label:e.label,description:e.description,parameters:e.parameters,outputSchema:e.outputSchema,constrainedSampling:e.constrainedSampling,prepareArguments:e.prepareArguments,executionMode:e.executionMode,execute:(n,r,o,i,s)=>e.execute(n,r,o,i,s??t?.(n,o))}}function An(e){return{name:e.name,label:e.label,description:e.description,parameters:e.parameters,outputSchema:e.outputSchema,constrainedSampling:e.constrainedSampling,prepareArguments:e.prepareArguments,executionMode:e.executionMode,execute:async(t,n,r,o)=>e.execute(t,n,r,o)}}var ye=()=>import("../../vendor/pi/dist/extensions/codemode/execute.js");var ft=10,dt=8,mt=5,$e=80,gt=/^Script (completed|failed)\nWall time [\d.]+ seconds\nOutput:\n$/;function xe(e,t,n){return`${e.fg("muted",`... (${t} more ${n},`)} ${R("app.tools.expand","to expand")}${e.fg("muted",")")}`}function ht(e){return e===void 0?"":e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(1)}s`}function Se(e){return`$${e>=.01?e.toFixed(2):e.toPrecision(2)}`}function yt(e,t){switch(e.status){case"running":return t.fg("warning","\u2026");case"ok":return t.fg("success","\u2713");case"error":return t.fg("error","\u2717");case"cancelled":return t.fg("muted","\u2298")}}function $t(e,t,n){let r=!n&&e.args.length>$e?`${e.args.slice(0,$e-3)}...`:e.args,o=ht(e.durationMs),i=`${yt(e,t)} ${t.fg("toolTitle",e.name)}`;return r&&(i+=` ${t.fg("muted",r)}`),o&&(i+=` ${t.fg("dim",o)}`),e.cost&&(i+=` ${t.fg("dim",Se(e.cost))}`),n&&e.error&&(i+=`
|
|
40
|
-
${t.fg("error",e.error.split(`
|
|
41
|
-
`).join(`
|
|
42
|
-
`))}`),i}var Te={renderCall(e,t,n){oe(n);let r=ne(e?.code),o=t.fg("toolTitle",t.bold("codemode")),i=n.lastComponent??new N;if(i.clear(),r===null)return i.addChild(new h(`${o} ${t.fg("error","[invalid arg]")}`,0,0)),i;if(i.addChild(new h(o,0,0)),r){let s=J(_(r.replace(/\r/g,"").trimEnd()),"javascript").join(`
|
|
43
|
-
`);i.addChild(n.expanded?new h(s,0,0):new S({text:s,maxVisualLines:ft,keep:"start",formatHint:a=>xe(t,a,"lines")}))}return i},renderResult(e,t,n,r){let o=ie(r,t.isPartial),i=r.lastComponent??new N;i.clear();let s=e.details?.calls??[];if(s.length>0){let u=t.expanded?s:s.slice(-dt),f=u.map(m=>$t(m,n,t.expanded));u.length<s.length&&f.unshift(`${n.fg("muted",`... (${s.length-u.length} earlier calls,`)} ${R("app.tools.expand","to expand")}${n.fg("muted",")")}`);let d=s.filter(m=>m.cost);if(d.length>1){let m=d.reduce((y,A)=>y+(A.cost??0),0);f.push(n.fg("muted",`Model calls: ${Se(m)}`))}i.addChild(new w(1)),i.addChild(new h(f.join(`
|
|
44
|
-
`),0,0))}let[a,...l]=e.content,c=a?.type==="text"&>.test(a.text),p=t.isPartial?"":re({...e,content:c?l:e.content},r.showImages).trim();if(p){let u=r.isError?"error":"toolOutput",f=_(p).split(`
|
|
45
|
-
`).map(d=>n.fg(u,d)).join(`
|
|
46
|
-
`);if(i.addChild(new w(1)),t.expanded)i.addChild(new h(f,0,0));else{i.addChild(new S({text:f,maxVisualLines:mt,keep:"start",formatHint:m=>xe(n,m,"lines")}));let d=e.details?.fullOutputPath;d&&i.addChild(new h(n.fg("muted",`Full output: ${d}`),0,0))}}return o&&(i.addChild(new w(1)),i.addChild(new h(n.fg("muted",o),0,0))),i}};var M="codemode",Un="codemode-store",St={type:"string"},Tt=x.Object({code:x.String({description:"Raw JavaScript source."})}),Ae={snippet:"Run JavaScript that calls other tools",guidelines:["Use codemode to batch independent tool calls (Promise.allSettled), chain them, or filter large output, instead of many separate calls."]},At=xt(U(),"codemode.md"),wt='Run JavaScript that calls other tools. The input is raw JavaScript (not JSON, no code fence), run as an async function body in a QuickJS sandbox: top-level `await` and `return` work. No Node, file system, network, or timers.\n- `await tools.<name>({ ...args })` resolves to a string, or an object if the tool\'s declaration says so, and rejects with an Error on failure. A tool whose declaration returns an object resolves on failure too when it returned that object; check its fields. Calls still running when the script ends are cancelled.\n- Optional first line: `// @options: {"max_output_tokens": 10000, "timeout_ms": 60000}`';function _t(e){let t=["Globals:","- `text(value)`, `image(dataUrlOrImageBlock)`, `console.log(...)`, and top-level `return` add output; `exit()` ends the script. With several text items, each starts with a `==> text N/M <==` line, and `console` lines follow the other output in one `<console_output>` block. `image()` also saves the image to a temp file and the result names its path.","- `store(key, value)` and `load(key)` keep JSON values across codemode calls.","- `ALL_TOOLS`, `await searchTools(query, { limit?, namespace? })`, `await describeTool(name)`, `await describeNamespace(name)`: find unlisted tools, such as MCP tools."];return e&&t.push(`- \`models\`: classifiers and image generation. Read ${At} first.`),t.join(`
|
|
47
|
-
`)}var Et=k.codemode.inlineBudget,Ot=4;function we(e,t=[]){let n=t.flatMap(r=>r.trim()?[`- ${r.trim()}`]:[]);return{name:e.name,description:n.length>0?`${e.description.trim()}
|
|
48
|
-
|
|
49
|
-
${n.join(`
|
|
50
|
-
`)}`:e.description,inputSchema:e.parameters,outputSchema:e.outputSchema??St}}function _e(e){return e.filter(t=>t.name!==M)}function bt(e){let t=T(e.name);return`${t===e.name?`### \`${t}\``:`### \`${t}\` (\`${e.name}\`)`}
|
|
51
|
-
${le(e).trim()}`}function Lt(e,t){if(t===void 0)return new Set(e.flatMap(s=>s.entries.map(a=>a.name)));let n=e.map(s=>[...s.entries].sort((a,l)=>a.cost-l.cost)),r=new Set,o=t,i=n.filter(s=>s.length>0);for(;i.length>0;)i=i.filter(s=>{let a=s[0];return a.cost>o?!1:(o-=a.cost,r.add(a.name),s.shift(),s.length>0)});return r}function Ee(e,t={}){let n=_e(e).filter(l=>!t.deferred?.has(l.name)).map(l=>we(l,t.guidelines?.get(l.name))),r=new Map([["",{namespace:void 0,entries:[]}]]);for(let l of n){let c=t.namespaces?.get(l.name),p=c?`ns:${c.name}`:"",u=r.get(p)??{namespace:c,entries:[]};r.set(p,u);let f=bt(l);u.entries.push({name:l.name,section:f,cost:Math.ceil(f.length/Ot)})}let o=[...r.values()].sort((l,c)=>l.namespace===void 0?-1:c.namespace===void 0?1:l.namespace.name.localeCompare(c.namespace.name)),i=Lt(o,t.inlineBudget),s=[wt,_t(t.models===!0)];if(n.length===0)return s.join(`
|
|
52
|
-
|
|
53
|
-
`);let a=["Nested tools:"];for(let{namespace:l,entries:c}of o){let p=c.filter(u=>i.has(u.name));if(l){let u=p.length===c.length?"":p.length===0?" (tools not listed)":" (some tools not listed)",f=l.description?.trim();a.push(`## ${l.name}${u}${f?`
|
|
54
|
-
${f}`:""}`)}for(let u of p)a.push(u.section)}return s.push(a.join(`
|
|
55
|
-
|
|
56
|
-
`)),s.join(`
|
|
57
|
-
|
|
58
|
-
`)}function Oe(e,t){if(typeof e!="object"||e===null)return;let{type:n,properties:r,required:o}=e;if(n!=="object"||typeof r!="object"||r===null)return;let i=new Set(Array.isArray(o)?o:[]);return`{ ${Object.entries(r).map(([a,l])=>{let c=t>0?Oe(l,t-1):void 0;return`${a}${i.has(a)?"":"?"}${c?`: ${c}`:""}`}).join(", ")} }`}function Ct(e){let t=j(e);return t==="string"?"a string":`\`${Oe(e,1)??t.replace(/\s+/g," ")}\``}function Mt(e){return`${e.description.trim()}
|
|
59
|
-
|
|
60
|
-
Codemode: \`tools.${T(e.name)}(args)\` resolves to ${Ct(we(e).outputSchema)}.`}function kt(e,t){let n=t.getMode?.()??k.codemode.mode,r=u=>e.getExposure(u.name)==="direct",o=_e(e.callable),i=new Set(o.map(u=>u.name)),s={};if(n==="on")for(let u of e.declared)i.has(u.name)&&(s[u.name]=Mt(u));let a=n==="only"?o:o.filter(u=>!r(u)),l=new Map(a.flatMap(u=>{let f=e.getNamespace(u.name);return f?[[u.name,f]]:[]})),c=new Map(a.map(u=>[u.name,e.getPromptGuidelines(u.name)]));s[M]=Ee(a,{models:t.models===!0,namespaces:l,guidelines:c,deferred:new Set(a.filter(u=>e.getExposure(u.name)==="deferred").map(u=>u.name)),inlineBudget:t.getInlineBudget?.()??Et});let p=new Set(e.declared.map(u=>u.name));return{descriptions:s,hiddenDeclarations:n==="only"?o.filter(u=>r(u)&&p.has(u.name)).map(u=>u.name):[]}}var It=/\b(searchTools|describeNamespace|describeTool|ALL_TOOLS)\b/;function Nt(e){return typeof e!="string"?[]:It.test(e)?"all":e.match(/\w+/g)??[]}function Wn(e={}){return{name:M,label:M,description:Ee([],{models:e.models===!0}),promptSnippet:Ae.snippet,promptGuidelines:[...Ae.guidelines],parameters:Tt,exposure:"model-only",prepareLoadout:t=>kt(t,e),reachesTools:t=>Nt(t.code),constrainedSampling:{type:"grammar",variants:{openai_lark:de}},execute:async(t,n,r,o,i)=>(await ye()).executeCodemode(t,n,r,o,i,e),...Te}}export{tn as a,V as b,Pt as c,Ut as d,Ft as e,Gt as f,Ht as g,Jt as h,Xt as i,qt as j,zt as k,Ne as l,Re as m,Yt as n,Vt as o,pt as p,An as q,Be as r,S as s,Fe as t,ne as u,cn as v,_ as w,ln as x,re as y,pn as z,oe as A,ie as B,He as C,fn as D,T as E,le as F,yn as G,C as H,he as I,st as J,v as K,Sn as L,M,Un as N,At as O,we as P,_e as Q,Wn as R};
|
|
@@ -1,18 +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 z}from"./chunk-V3AQJSWR.js";import{c as L,d as N}from"./chunk-SKHLZ6XY.js";import{a as q,b as H,c as V,d as Z,e as K,o as Q}from"./chunk-QBKCAIJG.js";import{F as G,J as F,o as D,p as W,y as B}from"./chunk-PZMGBKUR.js";import{a as T}from"./chunk-USBJFDJ6.js";function te(s,n){let r={v:1,id:s};return n&&(r.phase=n),JSON.stringify(r)}function ne(s){if(s){if(s.startsWith("{"))try{let n=JSON.parse(s);if(n.v===1&&typeof n.id=="string")return n.phase==="commentary"||n.phase==="final_answer"?{id:n.id,phase:n.phase}:{id:n.id}}catch{}return{id:s}}}function oe(s,n){let r=n.filter(l=>l.type==="text").map(l=>l.text).join(`
|
|
5
|
-
`),p=n.filter(l=>l.type==="image"),f=r.trim().length>0;if(p.length===0||!s.input.includes("image"))return T(f?r:p.length>0?"(see attached image)":"(no tool output)");let c=[];f&&c.push({type:"input_text",text:T(r)});for(let l of p)c.push({type:"input_image",detail:"auto",image_url:`data:${l.mimeType};base64,${l.data}`});return c}function se(s){return s.supportsMidConvoSystemMessages&&s.supportsAdditionalTools?"changes":s.supportsToolSearch?"additions":"none"}function ae(s){let n="This is an incremental tools update. Previously declared tools remain available unless explicitly marked unavailable. A tool declared again here is available again, and its latest definition replaces the earlier one.";return s.size>0?`${n}
|
|
6
|
-
Still unavailable: ${[...s].join(", ")}.`:n}function ie(s){return`The following tools are no longer available. Do not call them:
|
|
7
|
-
${s.map(n=>`- ${n}`).join(`
|
|
8
|
-
`)}`}function he(s,n,r,p){let f=B(n,p?.supportsMidConvoSystemMessages),c=[],l=a=>{let _=a.replace(/[^a-zA-Z0-9_-]/g,"_");return(_.length>64?_.slice(0,64):_).replace(/_+$/,"")},$=a=>{let _=`fc_${z(a)}`;return _.length>64?_.slice(0,64):_},v=(a,_,d)=>{if(!r.has(s.provider)||!a.includes("|"))return l(a);let[u,I]=a.split("|"),k=l(u),g=d.provider!==s.provider||d.api!==s.api?$(I):l(I);return g.startsWith("fc_")||(g=l(`fc_${g}`)),`${k}|${g}`},y=Q(f.messages,s,v),b=se(p??{}),J=G(f.messages,b),O=!1,w=new Set,j=(a,_)=>{let d=a.toolsAdded??[];for(let k of d)w.delete(k.name);if(d.length===0)return;if(b==="changes"){O&&c.push({role:i,content:ae(w)}),O=!0,c.push({type:"additional_tools",role:"developer",tools:X(d,p?.toolOptions)});return}if(b!=="additions")return;let u=d.map(k=>k.name),I=`pi_tool_load_${z(`${_}:${u.join(",")}`)}`;c.push({type:"tool_search_call",call_id:I,execution:"client",status:"completed",arguments:{query:u.join(" "),limit:u.length}}),c.push({type:"tool_search_output",call_id:I,execution:"client",status:"completed",tools:X(d,{...p?.toolOptions,toolSearchResult:!0})})},t=p?.includeSystemPrompt??!0,e=a=>{c.push({type:"configuration_update",reasoning:{effort:a}})},o=s.compat,i=s.reasoning&&o?.supportsDeveloperRole!==!1?"developer":"system",x=0,m=0,P=0;for(let a of y){let _=m++===0&&a.role==="system";if(a.role==="system"){let d=P++>=J.foldedSystemMessages;if(d&&j(a,`system:${x}`),!_||t){let u=[_?D(a):W(a)];if(d){let k=new Set((a.toolsAdded??[]).map(g=>g.name)),C=(a.toolsRemoved??[]).map(g=>g.name).filter(g=>!k.has(g));C.length>0&&u.push(ie(C));for(let g of C)w.add(g)}let I=u.filter(k=>k.length>0).join(`
|
|
9
|
-
|
|
10
|
-
`);I.length>0&&c.push({role:i,content:T(I)})}}else if(a.role==="user")if(typeof a.content=="string")c.push({role:"user",content:[{type:"input_text",text:T(a.content)}]});else{let d=a.content.map(u=>u.type==="text"?{type:"input_text",text:T(u.text)}:{type:"input_image",detail:"auto",image_url:`data:${u.mimeType};base64,${u.data}`});if(d.length===0)continue;c.push({role:"user",content:d})}else if(a.role==="assistant"){let d=[],u=a,I=u.provider===s.provider&&u.api===s.api,k=I&&u.model===s.id,C=I&&u.model!==s.id,g=0;for(let R of a.content)if(R.type==="thinking"){if(R.thinkingSignature){let h=JSON.parse(R.thinkingSignature);d.push(h)}}else if(R.type==="text"){let h=R,M=ne(h.textSignature),E=g===0?`msg_pi_${x}`:`msg_pi_${x}_${g}`;g++;let S=M?.id;S?S.length>64&&(S=`msg_${z(S)}`):S=E,d.push({type:"message",role:"assistant",content:[{type:"output_text",text:T(h.text),annotations:[]}],status:"completed",id:S,phase:M?.phase})}else if(R.type==="toolCall"){let h=R,[M,E]=h.id.split("|"),S=p?.grammarToolInputProperties?.get(h.name),A=E,ee=S===void 0?"fc_":"ctc_";(C||!A?.startsWith(ee))&&(A=void 0),S!==void 0?d.push({type:"custom_tool_call",id:A,call_id:M,name:h.name,input:T(H(h.name,h.arguments,S)),...k&&h.namespace!==void 0?{namespace:h.namespace}:{}}):d.push({type:"function_call",id:A,call_id:M,name:h.name,arguments:JSON.stringify(h.arguments),...k&&h.namespace!==void 0?{namespace:h.namespace}:{}})}if(d.length===0)continue;p?.configurationUpdateEffort!==void 0&&k&&a.providerThinkingLevel!==void 0&&e(a.providerThinkingLevel),c.push(...d)}else if(a.role==="toolResult"){let[d]=a.toolCallId.split("|"),u=oe(s,a.content);p?.grammarToolInputProperties?.has(a.toolName)?c.push({type:"custom_tool_call_output",call_id:d,output:u}):c.push({type:"function_call_output",call_id:d,output:u})}_||x++}return p?.configurationUpdateEffort!==void 0&&e(p.configurationUpdateEffort),c}function X(s,n){let r=n?.strict===void 0?!1:n.strict,p=n?.supportsStrictMode??!0,f=n?.supportsOpenAIGrammarTools??!1;return s.map(c=>{let l=K(c,f);if(l)return{type:"custom",name:c.name,description:c.description,format:{type:"grammar",syntax:l.format,definition:l.definition},...n?.toolSearchResult?{defer_loading:!0}:{}};let v=Z(c,p)??r,y={type:"function",name:c.name,description:c.description,parameters:q(c,v===!0),...n?.toolSearchResult?{defer_loading:!0}:{}};return p&&(y.strict=v),y})}function Y(s){let n=s.customInput?.property;if(n===void 0)return"";let r=s.arguments[n];return typeof r=="string"?r:""}function U(s,n,r){let p=s.customInput;if(!p)return;let f=V(p.jsonBuffer,p.property,n,r);return s.arguments={[p.property]:n},f}async function ye(s,n,r,p,f){let c=!1,l=new Map,$=new Map,v=t=>{t.type==="message"&&t.phase==="final_answer"&&(n.stopReason="stop")},y=(t,e)=>{let o=l.get(t);return o?.type===e?o:void 0},b=(t,e)=>{e!==void 0&&r.push({type:"toolcall_delta",contentIndex:t.contentIndex,delta:e,partial:n})},J=(t,e)=>{if(e.type==="reasoning"){let o={type:"thinking",thinking:""};n.content.push(o);let i={type:"thinking",block:o,contentIndex:n.content.length-1};return l.set(t,i),r.push({type:"thinking_start",contentIndex:i.contentIndex,partial:n}),i}if(e.type==="message"){v(e);let o={type:"text",text:""};n.content.push(o);let i={type:"text",block:o,contentIndex:n.content.length-1};return l.set(t,i),r.push({type:"text_start",contentIndex:i.contentIndex,partial:n}),i}if(e.type==="function_call"){let o={type:"toolCall",id:`${e.call_id}|${e.id}`,name:e.name,arguments:{},...e.namespace!==void 0?{namespace:e.namespace}:{},partialJson:e.arguments||""};n.content.push(o);let i={type:"toolCall",block:o,contentIndex:n.content.length-1};return l.set(t,i),r.push({type:"toolcall_start",contentIndex:i.contentIndex,partial:n}),i}if(e.type==="custom_tool_call"){let o=f?.grammarToolInputProperties?.get(e.name)??"input",i=e.input||"",x={type:"toolCall",id:`${e.call_id}|${e.id}`,name:e.name,arguments:{[o]:i},...e.namespace!==void 0?{namespace:e.namespace}:{},customInput:{property:o,jsonBuffer:{input:"",started:!1,closed:!1}}};n.content.push(x);let m={type:"toolCall",block:x,contentIndex:n.content.length-1};return l.set(t,m),r.push({type:"toolcall_start",contentIndex:m.contentIndex,partial:n}),m}},O=(t,e)=>l.get(t)??J(t,e),w=t=>{for(let e of t){if(e.type!=="reasoning"||!e.encrypted_content)continue;let o=$.get(e.id);if(!o?.thinkingSignature)continue;let i=JSON.parse(o.thinkingSignature);i.encrypted_content||(o.thinkingSignature=JSON.stringify({...i,encrypted_content:e.encrypted_content}))}},j=t=>{if(c=!0,w(t.output??[]),t?.id&&(n.responseId=t.id),t?.usage){let m=t.usage.input_tokens_details,P=m?.cached_tokens||0,a=m?.cache_write_tokens||0;n.usage={input:Math.max(0,(t.usage.input_tokens||0)-P-a),output:t.usage.output_tokens||0,cacheRead:P,cacheWrite:a,reasoning:t.usage.output_tokens_details?.reasoning_tokens||0,totalTokens:t.usage.total_tokens||0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}}}if(F(p,n.usage),f?.applyServiceTierPricing){let m=f.resolveServiceTier?f.resolveServiceTier(t?.service_tier,f.serviceTier):t?.service_tier??f.serviceTier;f.applyServiceTierPricing(n.usage,m)}let e=t?.status,o=t?.incomplete_details,i=typeof o?.reason=="string"?o.reason:void 0;n.rawStopReason=i?`${e}.${i}`:e;let x=re(e,i);n.stopReason=x.stopReason,x.errorMessage===void 0?delete n.errorMessage:n.errorMessage=x.errorMessage,n.content.some(m=>m.type==="toolCall")&&n.stopReason==="stop"&&(n.stopReason="toolUse")};for await(let t of s)if(await f?.onProviderStreamEvent?.(t,p),t.type==="response.created")n.responseId=t.response.id;else if(t.type==="response.output_item.added")J(t.output_index,t.item);else if(t.type==="response.reasoning_summary_text.delta"){let e=y(t.output_index,"thinking");if(!e)continue;e.block.thinking+=t.delta,r.push({type:"thinking_delta",contentIndex:e.contentIndex,delta:t.delta,partial:n})}else if(t.type==="response.reasoning_summary_part.done"){let e=y(t.output_index,"thinking");if(!e)continue;e.block.thinking+=`
|
|
11
|
-
|
|
12
|
-
`,r.push({type:"thinking_delta",contentIndex:e.contentIndex,delta:`
|
|
13
|
-
|
|
14
|
-
`,partial:n})}else if(t.type==="response.reasoning_text.delta"){let e=y(t.output_index,"thinking");if(!e)continue;e.block.thinking+=t.delta,r.push({type:"thinking_delta",contentIndex:e.contentIndex,delta:t.delta,partial:n})}else if(t.type==="response.output_text.delta"){let e=y(t.output_index,"text");if(!e)continue;e.block.text+=t.delta,r.push({type:"text_delta",contentIndex:e.contentIndex,delta:t.delta,partial:n})}else if(t.type==="response.refusal.delta"){let e=y(t.output_index,"text");if(!e)continue;e.block.text+=t.delta,r.push({type:"text_delta",contentIndex:e.contentIndex,delta:t.delta,partial:n})}else if(t.type==="response.function_call_arguments.delta"){let e=y(t.output_index,"toolCall");if(!e||e.block.partialJson===void 0)continue;e.block.partialJson+=t.delta,e.block.arguments=N(e.block.partialJson),b(e,t.delta)}else if(t.type==="response.function_call_arguments.done"){let e=y(t.output_index,"toolCall");if(!e||e.block.partialJson===void 0)continue;let o=e.block.partialJson;if(e.block.partialJson=t.arguments,e.block.arguments=N(e.block.partialJson),t.arguments.startsWith(o)){let i=t.arguments.slice(o.length);i.length>0&&b(e,i)}}else if(t.type==="response.custom_tool_call_input.delta"){let e=y(t.output_index,"toolCall");if(!e||!e.block.customInput)continue;b(e,U(e.block,Y(e.block)+t.delta,!1))}else if(t.type==="response.custom_tool_call_input.done"){let e=y(t.output_index,"toolCall");if(!e||!e.block.customInput)continue;b(e,U(e.block,t.input,!0))}else if(t.type==="response.output_item.done"){let e=t.item;v(e);let o=O(t.output_index,e);if(e.type==="reasoning"&&o?.type==="thinking"){let i=e.summary?.map(m=>m.text).join(`
|
|
15
|
-
|
|
16
|
-
`)||"",x=e.content?.map(m=>m.text).join(`
|
|
17
|
-
|
|
18
|
-
`)||"";o.block.thinking=i||x||o.block.thinking,o.block.thinkingSignature=JSON.stringify(e),$.set(e.id,o.block),r.push({type:"thinking_end",contentIndex:o.contentIndex,content:o.block.thinking,partial:n}),l.delete(t.output_index)}else e.type==="message"&&o?.type==="text"?(o.block.text=e.content?.map(i=>i.type==="output_text"?i.text:i.refusal).join("")||"",o.block.textSignature=te(e.id,e.phase??void 0),r.push({type:"text_end",contentIndex:o.contentIndex,content:o.block.text,partial:n}),l.delete(t.output_index)):e.type==="function_call"&&o?.type==="toolCall"&&o.block.partialJson!==void 0?(Object.assign(o.block,L(e.arguments||o.block.partialJson)),e.namespace!==void 0&&(o.block.namespace=e.namespace),delete o.block.partialJson,r.push({type:"toolcall_end",contentIndex:o.contentIndex,toolCall:o.block,partial:n}),l.delete(t.output_index)):e.type==="custom_tool_call"&&o?.type==="toolCall"&&o.block.customInput&&(b(o,U(o.block,e.input??Y(o.block),!0)),e.namespace!==void 0&&(o.block.namespace=e.namespace),delete o.block.customInput,r.push({type:"toolcall_end",contentIndex:o.contentIndex,toolCall:o.block,partial:n}),l.delete(t.output_index))}else if(t.type==="response.completed"||t.type==="response.incomplete")j(t.response);else{if(t.type==="error")throw new Error(`Error Code ${t.code}: ${t.message}`||"Unknown error");if(t.type==="response.failed"){c=!0,n.rawStopReason=t.response?.status;let e=t.response?.error,o=t.response?.incomplete_details,i=e?`${e.code||"unknown"}: ${e.message||"no message"}`:o?.reason?`incomplete: ${o.reason}`:"Unknown error (no error details in response)";throw new Error(i)}}if(!c)throw new Error("OpenAI Responses stream ended before a terminal response event");if(n.stopReason==="toolUse")for(let t of n.content){if(t.type!=="toolCall")continue;let e=t;if(e.partialJson!==void 0||e.customInput!==void 0)throw new Error(`OpenAI Responses stream completed with an unfinished tool call: ${e.name} (${e.id})`)}}function re(s,n){if(!s)return{stopReason:"stop"};switch(s){case"completed":return{stopReason:"stop"};case"incomplete":return n==="max_output_tokens"?{stopReason:"length"}:{stopReason:"error",errorMessage:n?`Response incomplete: ${n}`:"Response incomplete without a provider reason"};case"failed":case"cancelled":return{stopReason:"error"};case"in_progress":case"queued":return{stopReason:"stop"};default:{let r=s;throw new Error(`Unhandled stop reason: ${r}`)}}}export{se as a,he as b,X as c,ye as d};
|
|
@@ -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 from"node:fs/promises";import m from"node:path";var g=10,M=3e4,O=2e4,A=1e3;function p(t){return`${t}.mutation-lock`}var w=class extends Error{filePath;timeoutMs;holderPid;constructor(e,r,n){let i=n===null?"":` held by pid ${n}`;super(`Timed out after ${r} ms waiting for the lock on ${e} (${p(e)}${i}).`),this.filePath=e,this.timeoutMs=r,this.holderPid=n,this.name="FileLockTimeoutError"}};function v(t){try{return process.kill(t,0),!0}catch(e){return e?.code!=="ESRCH"}}async function y(t){try{let e=await a.readFile(`/proc/${t}/stat`,"utf8");return e.slice(e.lastIndexOf(")")+2).split(" ")[19]??null}catch{return null}}async function u(t){try{let e=JSON.parse(await a.readFile(m.join(t,"owner.json"),"utf8"));return typeof e.pid!="number"||typeof e.token!="string"?null:{pid:e.pid,token:e.token,processStart:typeof e.processStart=="string"?e.processStart:null,acquiredAt:typeof e.acquiredAt=="number"?e.acquiredAt:null}}catch{return null}}async function I(t){if(!v(t.pid))return!0;let e=await y(t.pid);return t.processStart!==null&&e!==null&&t.processStart!==e}async function f(t){let e;try{e=Date.now()-(await a.stat(t)).mtimeMs}catch{return!1}let r=await u(t);return r?r.acquiredAt!==null&&Date.now()-r.acquiredAt>O?!0:I(r):e>A}async function _(t,e){if((await u(t))?.token!==e)return;let r=`${t}.released.${encodeURIComponent(e)}`;try{await a.rename(t,r),(await u(r))?.token===e&&await a.rm(r,{recursive:!0,force:!0})}catch{}}async function L(t){if(await f(t))try{let e=await a.stat(t);await a.writeFile(m.join(t,".reclaimed"),"");let r=await a.stat(t);if(r.dev!==e.dev||r.ino!==e.ino||await u(t)&&!await f(t))return;let n=`${r.dev}.${r.ino}.${String(r.ctimeMs).replace(".","-")}`,i=`${t}.reclaimed.${n}`;await a.rename(t,i),await a.rm(i,{recursive:!0,force:!0})}catch{}}async function F(t){let e=`${process.pid}:${Date.now()}:${Math.random()}`,r=`${t}.candidate.${encodeURIComponent(e)}`;try{await a.mkdir(r);let n={pid:process.pid,token:e,processStart:await y(process.pid),acquiredAt:Date.now()};return await a.writeFile(m.join(r,"owner.json"),JSON.stringify(n),{mode:384}),await a.rename(r,t),()=>_(t,e)}catch(n){if(await a.rm(r,{recursive:!0,force:!0}),n?.code==="EEXIST"||n?.code==="ENOTEMPTY"||n?.code==="EPERM"&&await a.stat(t).then(()=>!0,()=>!1))return null;throw n}}async function x(t,e){e.signal?.throwIfAborted(),await a.mkdir(m.dirname(t),{recursive:!0});let r=p(t),n=e.timeoutMs??M,i=Date.now()+n;for(;Date.now()<i;){e.signal?.throwIfAborted();let c=await F(r);if(c)return c;await f(r)?await L(r):await new Promise(T=>setTimeout(T,g))}throw new w(t,n,(await u(r))?.pid??null)}async function S(t,e,r={}){let n=await x(t,r);try{return await e()}finally{await n()}}import s from"node:fs/promises";import{writeFileSync as D,renameSync as $,mkdirSync as N,chmodSync as R}from"node:fs";import d from"node:path";import*as h from"node:os";function E(){return!!process.env.NODE_TEST_CONTEXT}var b=[".cortex",".pi",".aistatus"].map(t=>d.join(h.homedir(),t));function l(t){if(!E())return;let e=d.resolve(t),r=b.find(n=>e===n||e.startsWith(n+d.sep));if(r)throw new Error(`atomicWrite blocked: test process attempted to write under the real ${r} (${e}). Isolate state first: run the test through vitest \u2014 \`npm test\` / \`npm run test:file <file>\` \u2014 whose setup file points CORTEX_HOME at an isolated temp home; repoint HOME too for files under it.`)}function o(t){if(t?.aborted)throw t.reason instanceof Error?t.reason:new Error("Atomic write aborted.")}async function k(t){try{return await s.readFile(t,"utf8")}catch(e){if(e.code==="ENOENT")return"";throw e}}async function q(t,e){try{await s.chmod(t,e)}catch(r){if(r.code!=="ENOENT")throw r}}async function z(t,e,r={}){l(t),await S(t,async()=>{o(r.signal);let n=await k(t);o(r.signal);let i=await e(n);o(r.signal),i!==n?await C(t,i,r):r.mode!==void 0&&await q(t,r.mode)},{signal:r.signal})}async function C(t,e,r={}){l(t),o(r.signal),await s.mkdir(d.dirname(t),{recursive:!0}),o(r.signal);let n=Math.random().toString(36).slice(2,8),i=`${t}.tmp.${process.pid}.${Date.now()}.${n}`,c=!1;try{await s.writeFile(i,e,{encoding:"utf8",mode:r.mode}),o(r.signal),r.mode!==void 0&&await s.chmod(i,r.mode),o(r.signal),$(i,t),c=!0}finally{c||await s.rm(i,{force:!0})}}function B(t,e,r={}){l(t),N(d.dirname(t),{recursive:!0});let n=Math.random().toString(36).slice(2,8),i=`${t}.tmp.${process.pid}.${Date.now()}.${n}`;D(i,e,{encoding:"utf8",mode:r.mode}),r.mode!==void 0&&R(i,r.mode),$(i,t)}export{S as a,E as b,z as c,C as d,B as e};
|
|
@@ -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{f as k,h as U,i as F}from"./chunk-RA6HKFBV.js";import{G as D,M as _,c as $,h as w,m as N,n as b,o as V}from"./chunk-QUUEQRIT.js";import*as v from"node:fs";import{createRequire as le}from"node:module";import*as p from"node:path";import{fileURLToPath as A}from"node:url";import{EventEmitter as ne}from"node:events";function z(){let e=new ne;return{emit:(r,l)=>{e.emit(r,l)},on:(r,l)=>{let n=async c=>{try{await l(c)}catch(a){console.error(`Event handler error (${r}):`,a)}};return e.on(r,n),()=>e.off(r,n)},clear:()=>{e.removeAllListeners()}}}import{spawn as se}from"node:child_process";async function B(e,r,l,n){return new Promise(c=>{let a=se(e,r,{cwd:l,shell:!1,stdio:["ignore","pipe","pipe"]}),i="",d="",o=!1,u,g=()=>{o||(o=!0,a.kill("SIGTERM"),setTimeout(()=>{a.killed||a.kill("SIGKILL")},5e3))};n?.signal&&(n.signal.aborted?g():n.signal.addEventListener("abort",g,{once:!0})),n?.timeout&&n.timeout>0&&(u=setTimeout(()=>{g()},n.timeout)),a.stdout?.on("data",h=>{i+=h.toString()}),a.stderr?.on("data",h=>{d+=h.toString()}),$(a).then(h=>{u&&clearTimeout(u),n?.signal&&n.signal.removeEventListener("abort",g),c({stdout:i,stderr:d,code:h??0,killed:o})}).catch(h=>{u&&clearTimeout(u),n?.signal&&n.signal.removeEventListener("abort",g),c({stdout:i,stderr:d,code:1,killed:o})})})}import{readFileSync as ie}from"node:fs";var oe=["extensions","skills","prompts","themes"];function O(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function W(e){try{let r=JSON.parse(N(ie(e,"utf-8")));if(!O(r)||!O(r.pi))return null;let l={};for(let n of oe){let c=r.pi[n];Array.isArray(c)&&c.every(a=>typeof a=="string")&&(l[n]=c)}return l}catch{return null}}var J="builtin:";function G(e){if(e.startsWith(J))return"builtin";if(e.startsWith("<")&&e.endsWith(">"))return e.slice(1,-1).split(":")[0]||"temporary"}function q(e){return e.startsWith(J)||e.startsWith("<")}function Ie(e,r){return{path:e,source:r.source,scope:r.scope,origin:r.origin,baseDir:r.baseDir}}function H(e,r){return{path:e,source:r.source,scope:r.scope??"temporary",origin:r.origin??"top-level",baseDir:r.baseDir}}var P=process.env.PI_TIMING==="1",S=new Map;function ae(e="main"){P&&S.set(e,{timings:[],lastTime:Date.now()})}function T(e,r="main"){if(!P)return;let l=Date.now();S.has(r)||ae(r);let n=S.get(r);n.timings.push({label:e,ms:l-n.lastTime}),n.lastTime=l}function ce(e,r){let l=r.filter(n=>n.ms>=0);if(l.length!==0){console.error(`
|
|
5
|
-
--- ${e} ---`);for(let n of l)console.error(` ${n.label}: ${n.ms}ms`);console.error(` TOTAL: ${l.reduce((n,c)=>n+c.ms,0)}ms`),console.error(`${"-".repeat(e.length+8)}
|
|
6
|
-
`)}}function je(){if(P)for(let[e,r]of S)ce(`Startup Timings: ${e}`,r.timings)}var R=le(new URL("vendor/pi/dist/core/extensions/loader.js",__cortexPackageRoot).href),de="sea"in process.features&&process.features.sea===!0||process.getBuiltinModule("node:sea")?.isSea()===!0,ue=!b&&p.extname(A(new URL("vendor/pi/dist/core/extensions/loader.js",__cortexPackageRoot).href))===".ts",Z=b||de||V,K;function fe(){return K??=(Z?import("./jiti-static-loader-W3QZ4GDS.js"):import("./jiti-loader-WANUXUDO.js")).then(e=>e.createJiti),K}var X;function Q(){return X??=import("./virtual-modules-OFI7QKYH.js").then(e=>e.VIRTUAL_MODULES),X}var M=null;function pe(){if(M)return M;let e=p.dirname(A(new URL("vendor/pi/dist/core/extensions/loader.js",__cortexPackageRoot).href)),r=p.resolve(e,"../..","index.js"),l=R.resolve("typebox"),n=R.resolve("typebox/compile"),c=R.resolve("typebox/value"),a=p.resolve(e,"../../../../"),i=(f,y)=>{let m=p.join(a,f);return v.existsSync(m)?m:A(import.meta.resolve(y))},d=r,o=i("agent/dist/index.js","@earendil-works/pi-agent-core"),u=i("tui/dist/index.js","@earendil-works/pi-tui"),g=i("ai/dist/compat.js","@earendil-works/pi-ai/compat"),h=i("ai/dist/models.js","@earendil-works/pi-ai/models"),t=i("ai/dist/oauth.js","@earendil-works/pi-ai/oauth"),s=i("ai/dist/providers/all.js","@earendil-works/pi-ai/providers/all");return M={"@earendil-works/pi-coding-agent":d,"@earendil-works/pi-agent-core":o,"@earendil-works/pi-tui":u,"@earendil-works/pi-ai/providers/all":s,"@earendil-works/pi-ai/compat":g,"@earendil-works/pi-ai/models":h,"@earendil-works/pi-ai/oauth":t,"@earendil-works/pi-ai":g,"@mariozechner/pi-coding-agent":d,"@mariozechner/pi-agent-core":o,"@mariozechner/pi-tui":u,"@mariozechner/pi-ai/providers/all":s,"@mariozechner/pi-ai/compat":g,"@mariozechner/pi-ai/models":h,"@mariozechner/pi-ai/oauth":t,"@mariozechner/pi-ai":g,typebox:l,"typebox/compile":n,"typebox/value":c,"@sinclair/typebox":l,"@sinclair/typebox/compile":n,"@sinclair/typebox/value":c},M}var x,L=0,I=new Map;function ge(){I.clear(),x=void 0,L++}function he(e){let r=w(e);return x!==void 0&&x!==r&&ge(),x=r,{cwd:r,generation:L}}function me(){let e=()=>{throw new Error("Extension runtime not initialized. Action methods cannot be called during extension loading.")},r={},l=new Set,n=()=>{if(r.staleMessage)throw new Error(r.staleMessage)},c={sendMessage:e,sendUserMessage:e,appendEntry:e,setSessionName:e,getSessionName:e,setLabel:e,getActiveTools:e,getAllTools:e,getSettings:e,setActiveTools:e,refreshTools:()=>{},getCommands:e,setModel:()=>Promise.reject(new Error("Extension runtime not initialized")),getThinkingLevel:e,setThinkingLevel:e,flagValues:new Map,pendingProviderRegistrations:[],pendingNativeProviderRegistrations:[],mcpServers:new F,pendingVirtualModelRegistrations:[],createContext:e,assertActive:n,invalidate:a=>{if(!r.staleMessage){r.staleMessage=a??"This extension ctx is stale after session replacement or reload. Do not use a captured pi or command ctx after ctx.newSession(), ctx.fork(), ctx.switchSession(), or ctx.reload(). For newSession, fork, and switchSession, move post-replacement work into withSession and use the ctx passed to withSession. For reload, do not use the old ctx after await ctx.reload().";for(let i of l)i();l.clear()}},trackEventBusSubscription:a=>{let i=!0,d=()=>{i&&(i=!1,l.delete(d),a())};return l.add(d),d},registerProvider:(a,i,d="<unknown>")=>{c.pendingProviderRegistrations.push({name:a,config:i,extensionPath:d})},registerNativeProvider:(a,i="<unknown>")=>{c.pendingNativeProviderRegistrations.push({provider:a,extensionPath:i})},unregisterProvider:a=>{c.pendingProviderRegistrations=c.pendingProviderRegistrations.filter(i=>i.name!==a),c.pendingNativeProviderRegistrations=c.pendingNativeProviderRegistrations.filter(i=>i.provider.id!==a)},registerVirtualModel:(a,i="<unknown>")=>{c.pendingVirtualModelRegistrations.push({definition:a,extensionPath:i})},unregisterVirtualModel:(a,i)=>{c.pendingVirtualModelRegistrations=c.pendingVirtualModelRegistrations.filter(({definition:d})=>d.provider!==a||d.id!==i)}};return c}function ve(e,r,l,n){let c=new Map,a=[],i=[],d="loading",o=()=>{if(d==="failed")throw new Error(`Extension "${e.path}" failed to load and its API is no longer active.`);r.assertActive()},u=t=>{d==="loading"?a.push(t):t()},g=()=>{c.clear(),a.length=0,i.length=0};return{api:{on(t,s){o();let f=(...m)=>s(...m),y=e.handlers.get(t)??[];return y.push(f),e.handlers.set(t,y),()=>{let m=e.handlers.get(t);if(!m)return;let E=m.indexOf(f);E!==-1&&(m.splice(E,1),m.length===0&&e.handlers.delete(t))}},registerTool(t){if(o(),typeof t.parameters!="object"||t.parameters===null||Array.isArray(t.parameters))throw new Error(`Tool "${t.name}" registered by extension "${e.path}" must define an object parameter schema.`);e.tools.set(t.name,{definition:t,sourceInfo:e.sourceInfo}),r.refreshTools()},registerCommand(t,s){if(o(),typeof t!="string"||t.length===0)throw new Error(`Command registered by extension "${e.path}" must have a non-empty string name. Use pi.registerCommand("name", { description, handler }).`);if(typeof s?.handler!="function")throw new Error(`Command "/${t}" registered by extension "${e.path}" must define handler().`);e.commands.set(t,{name:t,sourceInfo:e.sourceInfo,...s})},registerShortcut(t,s){o(),e.shortcuts.set(t,{shortcut:t,extensionPath:e.path,...s})},registerFlag(t,s){if(o(),s.default!==void 0&&typeof s.default!==s.type)throw new Error(`Invalid default for flag "${t}": expected ${s.type}, got ${typeof s.default}`);e.flags.set(t,{name:t,extensionPath:e.path,...s}),s.default!==void 0&&!r.flagValues.has(t)&&(d==="loading"?c.has(t)||c.set(t,s.default):r.flagValues.set(t,s.default))},registerMessageRenderer(t,s){o(),e.messageRenderers.set(t,s)},registerMarkdownTransformer(t){o(),e.markdownTransformer=t},registerEntryRenderer(t,s){o(),e.entryRenderers??=new Map,e.entryRenderers.set(t,s)},registerToolRenderer(t){o(),e.toolRenderers??=[],e.toolRenderers.push(t)},getFlag(t){if(o(),!!e.flags.has(t))return r.flagValues.has(t)?r.flagValues.get(t):c.get(t)},sendMessage(t,s){o(),r.sendMessage(t,s)},sendUserMessage(t,s){o(),r.sendUserMessage(t,s)},appendEntry(t,s){o(),r.appendEntry(t,s)},setSessionName(t){o(),r.setSessionName(t)},getSessionName(){return o(),r.getSessionName()},setLabel(t,s){o(),r.setLabel(t,s)},exec(t,s,f){return o(),B(t,s,f?.cwd??l,f)},getActiveTools(){return o(),r.getActiveTools()},getAllTools(){return o(),r.getAllTools()},getSettings(){return o(),r.getSettings()},setActiveTools(t){o(),r.setActiveTools(t)},getCommands(){return o(),r.getCommands()},setModel(t){return o(),r.setModel(t)},getThinkingLevel(){return o(),r.getThinkingLevel()},setThinkingLevel(t){o(),r.setThinkingLevel(t)},registerProvider(t,s){if(o(),typeof t=="string"){if(!s)throw new Error("Provider config is required when registering by name");u(()=>r.registerProvider(t,s,e.path));return}u(()=>r.registerNativeProvider(t,e.path))},unregisterProvider(t){o(),u(()=>r.unregisterProvider(t,e.path))},registerMcpServer(t,s){o();let f=U(t,s);if(typeof f=="string")throw new Error(`Invalid MCP server registered by extension "${e.path}": ${f}`);let y=r.mcpServers.get(t)?.extensionPath;if(y!==void 0&&y!==e.path)throw new Error(`MCP server "${t}" is already registered by extension "${y}"`);let m=r.mcpServers.list().find(j=>j.name!==t&&k(j.name)===k(t));if(m)throw new Error(`MCP server "${t}" conflicts with registered server "${m.name}"`);let E={name:t,config:structuredClone(f),extensionPath:e.path};u(()=>r.mcpServers.register(E))},unregisterMcpServer(t){o(),u(()=>r.mcpServers.unregister(t,e.path))},getMcpServers(){return o(),r.mcpServers.list()},registerVirtualModel(t){o();let s={...t,route:f=>t.route(f,r.createContext())};u(()=>r.registerVirtualModel(s,e.path))},unregisterVirtualModel(t,s){o(),u(()=>r.unregisterVirtualModel(t,s))},events:{emit(t,s){o(),n.emit(t,s)},on(t,s){o();let f=r.trackEventBusSubscription(n.on(t,s));return d==="loading"&&i.push(f),f}}},commit:()=>{if(d==="loading"){r.assertActive();for(let[t,s]of c)r.flagValues.has(t)||r.flagValues.set(t,s);for(let t of a)t();d="active",g()}},discard:()=>{if(d==="loading"){d="failed";for(let t of i)t();g()}}}}function Y(e){return e!==void 0&&x===e.cwd&&L===e.generation}async function ye(e,r){if(Y(r)){let d=I.get(e);if(d)return d}let l=await fe(),n=Z?{virtualModules:await Q(),tryNative:!1}:ue?{virtualModules:await Q(),tsconfigPaths:!0}:{alias:pe()},i=await l(new URL("vendor/pi/dist/core/extensions/loader.js",__cortexPackageRoot).href,{moduleCache:!1,...n}).import(e,{default:!0});if(typeof i=="function")return Y(r)&&I.set(e,i),i}function we(e,r){let l=G(e)??"local",n=q(e)?void 0:p.dirname(r);return{path:e,resolvedPath:r,sourceInfo:H(e,{source:l,baseDir:n}),handlers:new Map,tools:new Map,messageRenderers:new Map,entryRenderers:new Map,commands:new Map,flags:new Map,shortcuts:new Map}}async function ee(e,r,l,n,c,a){let i=we(r,l),d=ve(i,a,n,c);try{await e(d.api),d.commit()}catch(o){throw d.discard(),o}return T(`${r} factory`,"extensions"),i}async function xe(e,r,l,n,c){let a=w(e,r,{normalizeUnicodeSpaces:!0});try{let i=await ye(a,c);return T(`${e} module import`,"extensions"),i?{extension:await ee(i,e,a,r,l,n),error:null}:{extension:null,error:`Extension does not export a valid factory function: ${e}`}}catch(i){return{extension:null,error:`Failed to load extension: ${i instanceof Error?i.message:String(i)}`}}}async function Je(e,r,l,n,c="<inline>"){let a=w(r);return ee(e,c,c,a,l,n)}async function te(e,r,l,n,c=!1){let a=[],i=[],d=[],o=c?he(r):void 0,u=o?.cwd??w(r),g=l??z(),h=n??me();for(let t of e){let{extension:s,error:f}=await xe(t,u,g,h,o);if(f){i.push({path:t,error:f});continue}s&&a.push(s)}return{extensions:a,errors:i,warnings:d,runtime:h}}async function Ee(e,r,l,n){return te(e,r,l,n)}async function Ge(e,r,l,n){return te(e,r,l,n,!0)}function Se(e){return e.endsWith(".ts")||e.endsWith(".js")}function re(e){let r=p.join(e,"package.json");if(v.existsSync(r)){let c=W(r);if(c?.extensions?.length){let a=[];for(let i of c.extensions){let d=p.resolve(e,i);v.existsSync(d)&&a.push(d)}if(a.length>0)return a}}let l=p.join(e,"index.ts"),n=p.join(e,"index.js");return v.existsSync(l)?[l]:v.existsSync(n)?[n]:null}function C(e){if(!v.existsSync(e))return[];let r=[];try{let l=v.readdirSync(e,{withFileTypes:!0});for(let n of l){let c=p.join(e,n.name);if((n.isFile()||n.isSymbolicLink())&&Se(n.name)){r.push(c);continue}if(n.isDirectory()||n.isSymbolicLink()){let a=re(c);a&&r.push(...a)}}}catch{return[]}return r}async function qe(e,r,l=_(),n){let c=w(r),a=w(l),i=[],d=new Set,o=h=>{for(let t of h){let s=p.resolve(t);d.has(s)||(d.add(s),i.push(t))}},u=p.join(c,D,"extensions");o(C(u));let g=p.join(a,"extensions");o(C(g));for(let h of e){let t=w(h,c,{normalizeUnicodeSpaces:!0});if(v.existsSync(t)&&v.statSync(t).isDirectory()){let s=re(t);if(s){o(s);continue}o(C(t));continue}o([t])}return Ee(i,c,n)}export{z as a,W as b,J as c,G as d,q as e,Ie as f,H as g,ae as h,T as i,je as j,ge as k,me as l,Je as m,Ee as n,Ge as o,qe as p};
|