@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,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __cortexCreateRequire } from 'node:module';
|
|
2
2
|
const require = __cortexCreateRequire(import.meta.url);
|
|
3
3
|
const __cortexPackageRoot = new URL("../../", import.meta.url);
|
|
4
|
-
import{e as a}from"./chunk-
|
|
4
|
+
import{e as a}from"./chunk-7GGPYU5E.js";import{e as k}from"./chunk-7W7VYUTK.js";import{m as R}from"./chunk-T54CZKNJ.js";import{spawn as Tt}from"node:child_process";import{randomUUID as V}from"node:crypto";var S=1800*1e3,F=200,Z=8,Q="***",tt=k("login-flow"),I=class extends Error{code;name="LoginFlowError";constructor(e,n,r){super(n,r===void 0?void 0:{cause:r}),this.code=e}};function b(t){if(!t||typeof t!="object")return!1;let e=t;return e.name==="LoginFlowError"&&typeof e.message=="string"&&typeof e.code=="string"}function et(t){let n=(t instanceof Error?t.message:typeof t=="string"?t:"").split(`
|
|
5
5
|
`).map(r=>r.trim()).find(Boolean)??"";return n.length>F?`${n.slice(0,F-1)}\u2026`:n}function nt(t,e){let n=et(e),r=t.replace(/[.。]\s*$/u,"");return!n||n===t||n===r?t:a("ux.auth.failureDetail",{message:r,detail:n})}var rt=new Set(["done","failed","cancelled"]),l=new Map,d=new Map;function y(t){return`${t.backend}\0${t.provider}\0${t.connection??""}`}function Dt(t){let e=d.get(y(t)),n=e?T(e):null;return!!n&&!p(n)}function f(t){let e=new Error(t);return e.name="AbortError",e}function p(t){return rt.has(t.state.step)}function ot(t){if(!t)return null;let e=t.options?.map(n=>({...n}));return e?{...t,options:e}:{...t}}function it(t){return t?t.kind!=="info"||!t.links?{...t}:{...t,links:t.links.map(e=>({...e}))}:null}function D(t){return t?{...t}:null}function c(t){t.state.revision+=1}function _(t){return{...t.state,pendingPrompt:ot(t.state.pendingPrompt),notice:it(t.state.notice),outcome:D(t.state.outcome)}}function E(t){d.get(t.pairKey)===t.state.flowId&&d.delete(t.pairKey)}function A(t){let e=t.pending;return e?(e.signal?.removeEventListener("abort",e.onAbort),t.pending=null,t.state.pendingPrompt=null,c(t),e):null}function N(t,e){t.controller.signal.aborted||t.controller.abort(f(e))}function U(t){l.get(t.state.flowId)===t&&(l.delete(t.state.flowId),E(t),clearTimeout(t.timer),t.secrets.clear(),p(t)||N(t,"Login flow expired."),A(t)?.reject(f("Login flow expired.")))}function T(t){let e=l.get(t);return e?Date.now()<e.expiresAtMs?e:(U(e),null):null}function st(t){let e=T(t);if(!e)throw new Error(a("ux.auth.flowNotFound"));return e}function C(t){let e=st(t);if(p(e))throw new Error(a("ux.auth.flowNotActive"));return e}function at(t,e){let n={id:e,kind:t.type,message:t.message};return t.type==="select"?n.options=t.options.map(r=>({...r})):t.placeholder&&(n.placeholder=t.placeholder),n}function ut(t,e){t.pending===e&&(A(t),t.state.step==="prompt"&&(t.state.step="running"),e.reject(f("Authentication prompt aborted.")))}async function ct(t,e){let n=C(t);if(n.pending)throw new Error("Login flow already has a pending prompt.");if(e.signal?.aborted)throw f("Authentication prompt aborted.");return c(n),n.state.step="prompt",n.state.pendingPrompt=at(e,n.state.revision),new Promise((r,o)=>{let i={resolve:r,reject:o,signal:e.signal};i.onAbort=()=>ut(n,i),n.pending=i,e.signal?.addEventListener("abort",i.onAbort,{once:!0})})}function lt(t){if(t.type==="info"){let e=t.links?.map(n=>({...n}));return e?{kind:"info",message:t.message,links:e}:{kind:"info",message:t.message}}return t.type==="auth_url"?{kind:"auth_url",url:t.url,instructions:t.instructions}:t.type==="device_code"?{kind:"device_code",userCode:t.userCode,verificationUri:t.verificationUri,intervalSeconds:t.intervalSeconds,expiresInSeconds:t.expiresInSeconds}:{kind:"progress",message:t.message}}function dt(t){return{signal:t.controller.signal,prompt:e=>ct(t.state.flowId,e),notify:e=>{let n=C(t.state.flowId);n.state.notice=lt(e),c(n)}}}function H(t){return l.get(t.state.flowId)===t&&!p(t)}var w=new Set;function Nt(t){return w.add(t),()=>{w.delete(t)}}function ft(t){for(let e of w)try{e(t)}catch{}}function pt(t,e){H(t)&&(t.state.step="done",t.state.pendingPrompt=null,c(t),t.state.outcome=D(e),t.state.error=null,t.state.errorCode=null,t.secrets.clear(),E(t),ft({backend:t.state.backend,provider:e.provider||t.state.provider||"",connection:t.state.connection,authType:e.authType}))}function m(t,e){return[...e].filter(r=>r.length>=Z).sort((r,o)=>o.length-r.length).reduce((r,o)=>r.split(o).join(Q),t)}function ht(t,e,n){e!=="secret"&&e!=="manual_code"||(t.secrets.add(n),t.secrets.add(n.trim()))}function gt(t){let e=b(t)&&t.cause!==void 0?t.cause:t;return e instanceof Error?b(e)?e.message:e.stack??e.message:String(e)}function mt(t,e){if(!H(t))return;let n=b(e)?e:null,r=`login ${t.state.backend}/${t.state.provider} failed (${n?.code??"unexpected"}):`;tt.warn(r,m(gt(e),t.secrets)),t.state.step="failed",t.state.pendingPrompt=null,c(t),t.state.outcome=null;let o=n?.message??nt(a("ux.auth.loginFailed"),e);t.state.error=m(o,t.secrets),t.state.errorCode=n?.code??null,t.secrets.clear(),E(t)}function _t(t,e){Promise.resolve().then(()=>e(dt(t))).then(n=>pt(t,n),n=>mt(t,n))}function Et(t){let e=d.get(y(t));if(!e)return null;let n=T(e);return!n||p(n)?null:n}function j(t){let e=A(t);t.state.step="cancelled",c(t),t.state.outcome=null,t.state.error=null,t.state.errorCode=null,t.secrets.clear(),E(t),N(t,"Login flow cancelled."),e?.reject(f("Login flow cancelled."))}function At(t){let e=Date.now(),o={state:{flowId:V(),revision:0,backend:t.backend,provider:t.provider,connection:t.connection??null,authType:t.authType,step:"running",pendingPrompt:null,notice:null,channel:t.channel,sessionId:t.sessionId,createdAt:new Date(e).toISOString(),expiresAt:new Date(e+S).toISOString(),outcome:null,error:null,errorCode:null},pairKey:y(t),expiresAtMs:e+S,controller:new AbortController,pending:null,secrets:new Set};return o.timer=setTimeout(()=>U(o),S),o.timer.unref(),o}async function Ut(t,e){let n=Et(t);n&&j(n);let r=At(t);return l.set(r.state.flowId,r),d.set(r.pairKey,r.state.flowId),_t(r,e),_(r)}async function Ht(t,e,n){let r=C(t);if(n!==void 0&&r.state.pendingPrompt&&r.state.pendingPrompt.id!==n)throw new I("stale_prompt",a("ux.auth.flowNotWaiting"));let o=r.state.pendingPrompt?.kind,i=A(r);if(!i)throw new Error(a("ux.auth.flowNotWaiting"));return o&&ht(r,o,e),r.state.step="running",i.resolve(e),_(r)}async function jt(t){let e=C(t);return j(e),_(e)}function Gt(t){let e=T(t);return e?_(e):null}var Ct=1800*1e3,G=64*1024,$=200,z="Paste code here if prompted >",B=/https:\/\/claude\.com\/cai\/oauth\/authorize\?[^\s\x1b]+/,St=/\x1B\[[0-?]*[ -/]*[@-~]/g,It=/\x1B\][^\x07]*(?:\x07|\x1B\\)/g,bt=["HOME","PATH","SHELL","USER","LOGNAME","LANG","LC_ALL","LC_CTYPE","TERM","TZ","TMPDIR","TMP","TEMP","XDG_CONFIG_HOME","XDG_CACHE_HOME","XDG_DATA_HOME","HTTPS_PROXY","HTTP_PROXY","NO_PROXY","https_proxy","http_proxy","no_proxy","SSL_CERT_FILE","SSL_CERT_DIR","NODE_EXTRA_CA_CERTS"],L=class extends Error{code;name="ClaudeAuthCliError";constructor(e,n){super(n),this.code=e}};function u(t,e){return new L(t,e)}function X(t,e){return e?`${t.replace(/\.$/,"")}: ${e}`:t}function wt(t=process.env,e=R){let n={BROWSER:"true",CLAUDE_CONFIG_DIR:e};for(let r of bt)t[r]!==void 0&&(n[r]=t[r]);return n}function x(t,e){return(e.spawn??Tt)(e.executable??"claude",t,{env:wt(e.env,e.configDir),stdio:["pipe","pipe","pipe"]})}function h(t,e=""){return u(t,X({claude_auth_login_failed:"Claude authentication login failed.",claude_auth_logout_failed:"Claude authentication logout failed.",claude_auth_status_failed:"Claude authentication status check failed."}[t]??"Claude authentication command failed.",e))}var P=class{child;options;resolve;reject;settled=!1;timer;onAbort=()=>this.stop(u("claude_auth_cancelled","Claude authentication was cancelled."));constructor(e,n,r,o,i){this.child=e,this.options=r,this.resolve=o,this.reject=i,this.timer=setTimeout(()=>this.stop(u("claude_auth_timeout","Claude authentication timed out.")),n.timeoutMs??Ct),r.signal?.addEventListener("abort",this.onAbort,{once:!0}),e.once("error",s=>this.finish(h(r.failureCode,s.message))),e.once("close",s=>this.finish(s===0?void 0:h(r.failureCode,W(r.output)))),r.signal?.aborted&&this.onAbort()}cleanup(){clearTimeout(this.timer),this.options.signal?.removeEventListener("abort",this.onAbort)}finish(e){this.settled||(this.settled=!0,this.cleanup(),e?this.reject(e):this.resolve())}stop(e){if(!this.settled){this.settled=!0,this.cleanup(),this.options.onStop?.(e);try{this.child.kill("SIGTERM")}catch{}this.reject(e)}}};function M(t,e,n){return new Promise((r,o)=>{new P(t,e,n,r,o)})}function v(t,e){let n=t+String(e);return n.length<=G?n:n.slice(-G)}function K(t){return t.replace(It,"").replace(St,"")}function yt(t){let e=t.trim();return e&&!/[\r\n]/.test(e)?e:null}function O(t){let e={text:"",secrets:[]},n=r=>{e.text=v(e.text,r)};return t.stdout.on("data",n),t.stderr.on("data",n),e}function W(t){let e=K(t.text).split(z).join(`
|
|
6
6
|
`).split(/\r\n|\r|\n/).map(r=>r.trim()).filter(r=>r&&!B.test(r)),n=m(e.at(-1)??"",t.secrets);return n.length>$?`${n.slice(0,$-1)}\u2026`:n}async function Lt(t,e){let n=x(["auth","status","--json"],t),r="";n.stdout.on("data",i=>{r=v(r,i)});let o=O(n);return await M(n,t,{signal:e,failureCode:"claude_auth_status_failed",output:o}),r}function Pt(t){try{let e=JSON.parse(t.trim());if(typeof e.loggedIn!="boolean")throw new Error("missing loggedIn");return{loggedIn:e.loggedIn,authMethod:typeof e.authMethod=="string"?e.authMethod:null,apiProvider:typeof e.apiProvider=="string"?e.apiProvider:null}}catch{throw u("claude_auth_status_invalid","Claude authentication status was invalid.")}}async function Y(t={},e){return Pt(await Lt(t,e))}function q(t,e,n){if(!t.settled){if(t.settled=!0,n)try{t.child.kill("SIGTERM")}catch{}t.reject(e)}}function xt(t,e){t.settled=!0,t.output.secrets.push(e);try{t.child.stdin.write(`${e}
|
|
7
7
|
`),t.options.onCodeSubmitted?.(),t.resolve()}catch{try{t.child.kill("SIGTERM")}catch{}t.reject(h("claude_auth_login_failed"))}}async function Mt(t,e){try{let n=yt(await t.options.onAuthorization(e));if(!n)throw h("claude_auth_login_failed");if(t.settled||t.options.signal?.aborted)return;xt(t,n)}catch{q(t,h("claude_auth_login_failed"),!0)}}function vt(t,e){t.buffer=v(t.buffer,e);let n=K(t.buffer),r=n.match(B)?.[0];t.started||!r||!n.includes(z)||(t.started=!0,Mt(t,r))}function Ot(t,e,n,r){return new Promise((o,i)=>{let s={child:t,options:e,output:n,buffer:"",started:!1,settled:!1,resolve:o,reject:i},g=J=>vt(s,J);t.stdout.on("data",g),t.stderr.on("data",g),t.once("close",()=>q(s,r()??u("claude_auth_login_protocol",X("Claude authentication did not complete browser authorization.",W(n))),!1))})}async function Kt(t,e={}){let n=x(["auth","login","--claudeai"],e),r=O(n),o=null,i=Ot(n,t,r,()=>o);await Promise.all([i,M(n,e,{signal:t.signal,failureCode:"claude_auth_login_failed",output:r,onStop:g=>{o=g}})]);let s=await Y(e,t.signal);if(!s.loggedIn)throw u("claude_auth_not_logged_in","Claude Code did not persist the login.");return s}async function Wt(t={}){let e=x(["auth","logout"],t),n=O(e);if(await M(e,t,{failureCode:"claude_auth_logout_failed",output:n}),(await Y(t)).loggedIn)throw u("claude_auth_still_logged_in","Claude Code remained logged in after logout.")}export{S as a,I as b,b as c,nt as d,Dt as e,Nt as f,m as g,gt as h,Ut as i,Ht as j,jt as k,Gt as l,L as m,wt as n,Y as o,Kt as p,Wt as q};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as __cortexCreateRequire } from 'node:module';
|
|
2
2
|
const require = __cortexCreateRequire(import.meta.url);
|
|
3
3
|
const __cortexPackageRoot = new URL("../../", import.meta.url);
|
|
4
|
-
var s="1.
|
|
4
|
+
var s="1.6.0";var M={name:"pi",url:"https://pi.dev",categories:["cli-agent"]},d="integrate.api.nvidia.com",l="opencode.ai";function g(...e){let o;for(let n of e)n&&(o={...o},n.userAgent!==void 0&&(o.userAgent=n.userAgent),n.attribution!==void 0&&(o.attribution=n.attribution),n.version!==void 0&&(o.version=n.version));return o}function v(e){return e?.version??s}function A(){if(typeof process>"u")return;let e=process.versions;if(e?.bun)return`bun/${e.bun}`;if(e?.node)return`node/${process.version}`}function b(e){let o=e?.userAgent??"detailed";if(typeof o=="object")return o.custom;if(o==="short")return"pi";let n=`pi/${v(e)}`,u=A();return u?`${n} (${process.platform}; ${u}; ${process.arch})`:`${n} (browser)`}function f(e,o){try{return new URL(e).hostname===o}catch{return!1}}function I(e){return e.provider==="openrouter"||e.baseUrl.includes("openrouter.ai")}function h(e){return e.provider==="nvidia"||f(e.baseUrl,d)}function a(e){return e.provider==="opencode"||e.provider==="opencode-go"||f(e.baseUrl,l)}function O(e,o){let n=o?.attribution;if(!n)return{};let{name:u,url:c,categories:r}=n;return I(e)?{"HTTP-Referer":c,"X-OpenRouter-Title":u,...r===void 0||r.length===0?{}:{"X-OpenRouter-Categories":r.join(",")}}:h(e)?{"X-BILLING-INVOKE-ORIGIN":u.charAt(0).toUpperCase()+u.slice(1)}:a(e)?{"x-opencode-client":u}:{}}function x(e,o){return o&&a(e)?{"x-opencode-session":o}:void 0}function N(e,o){return{"User-Agent":b(o),...O(e,o)}}function P(e){return"setProvider"in e&&"deleteProvider"in e&&"clearProviders"in e}function D(e,o){let n=r=>({...r,identity:g(o,r?.identity)}),u={getProviders:()=>e.getProviders(),getProvider:r=>e.getProvider(r),getModels:r=>e.getModels(r),getModel:(r,t)=>e.getModel(r,t),getModelsOfType:(r,t)=>e.getModelsOfType(r,t),getModelOfType:(r,t,i)=>e.getModelOfType(r,t,i),getAllModels:r=>e.getAllModels(r),refresh:r=>e.refresh(r),checkAuth:(r,t)=>e.checkAuth(r,t),getAvailable:(r,t)=>e.getAvailable(r,t),getAvailableOfType:(r,t,i)=>e.getAvailableOfType(r,t,i),getAllAvailable:(r,t)=>e.getAllAvailable(r,t),getAuth:e.getAuth.bind(e),login:(r,t,i,p)=>e.login(r,t,i,p),logout:(r,t)=>e.logout(r,t),stream:(r,t,i)=>e.stream(r,t,n(i)),complete:(r,t,i)=>e.complete(r,t,n(i)),streamSimple:(r,t,i)=>e.streamSimple(r,t,n(i)),completeSimple:(r,t,i)=>e.completeSimple(r,t,n(i)),streamDeferred:(r,t,i)=>e.streamDeferred(r,t,n(i)),fetchDeferred:(r,t,i)=>e.fetchDeferred(r,t,n(i)),cancelDeferred:(r,t,i)=>e.cancelDeferred(r,t,n(i)),generateImages:(r,t,i)=>e.generateImages(r,t,n(i)),classify:(r,t,i)=>e.classify(r,t,n(i))};return P(e)?{...u,setProvider:r=>e.setProvider(r),deleteProvider:r=>e.deleteProvider(r),clearProviders:()=>e.clearProviders()}:u}export{s as a,M as b,g as c,v as d,b as e,O as f,x as g,N as h,D as i};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as __cortexCreateRequire } from 'node:module';
|
|
2
2
|
const require = __cortexCreateRequire(import.meta.url);
|
|
3
3
|
const __cortexPackageRoot = new URL("../../", import.meta.url);
|
|
4
|
-
function a(t){let e=(t.CORTEX_UI_HTTP||"").trim().toLowerCase();return e==="1"||e==="true"||e==="on"||e==="yes"}async function m(t,e){if(!a(process.env))return null;let{createUiHttp:r}=await import("./start-ui-http-
|
|
4
|
+
function a(t){let e=(t.CORTEX_UI_HTTP||"").trim().toLowerCase();return e==="1"||e==="true"||e==="on"||e==="yes"}async function m(t,e){if(!a(process.env))return null;let{createUiHttp:r}=await import("./start-ui-http-7K5JOLPU.js");return r({uiService:t},e)}import{accessSync as c,constants as p,realpathSync as u,statSync as l}from"node:fs";import{execFileSync as i}from"node:child_process";import*as n from"node:path";function s(t){try{return c(t,p.X_OK),l(t).isFile()}catch{return!1}}function f(){let t=process.platform==="win32"?(process.env.PATHEXT||".EXE;.CMD;.BAT").split(";"):[""];return(process.env.PATH||"").split(n.delimiter).flatMap(r=>t.map(o=>n.resolve(r,`git${o}`))).find(s)??null}function d(t){if(process.platform!=="darwin"||u(t)!=="/usr/bin/git")return!0;let e=i("/usr/bin/xcode-select",["-p"],{encoding:"utf8",stdio:"pipe",timeout:5e3}).trim();return!!e&&s(n.join(e,"usr/bin/git"))}function b(){try{let t=f();return!t||!d(t)?!1:i(t,["--version"],{encoding:"utf8",stdio:"pipe",timeout:5e3}).startsWith("git version ")}catch{return!1}}export{b as a,a as b,m as c};
|
|
@@ -0,0 +1,57 @@
|
|
|
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{ia as S}from"./chunk-54P7TSY3.js";import{d as Q}from"./chunk-CEJIYYVE.js";import{A as v,Da as Y,I as h,Ma as j,U as b,g as X,t as L,w as Z,x as V,y as K}from"./chunk-GOS3P7KS.js";import{a as I}from"./chunk-YWPBE5LP.js";import{C as q,h as G,l as z}from"./chunk-2BVUA256.js";import{randomBytes as Me}from"node:crypto";import{createWriteStream as Re}from"node:fs";import{writeFile as Ie}from"node:fs/promises";import{tmpdir as Le}from"node:os";import{join as ve}from"node:path";var ee=384;function te(e,t){return ve(Le(),`${e}-${Me(8).toString("hex")}${t}`)}async function qt(e,t,n){let r=te(e,t);return await Ie(r,n,{mode:ee,flag:"wx"}),r}function Xt(e,t){let n=te(e,t);return{path:n,stream:Re(n,{mode:ee,flags:"wx"})}}function je(){return{input:0,output:0,cacheRead:0,cacheWrite:0,cost:0}}function De(e,t){e.input+=t.input,e.output+=t.output,e.cacheRead+=t.cacheRead,e.cacheWrite+=t.cacheWrite,e.cost+=t.cost.total}function Vt(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,totalFromProvider:e.cost.totalFromProvider===!0&&t.cost.totalFromProvider===!0}}}function Kt(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=je(),t.set(r,i)),De(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 Pe(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 c=o==="start"?s.slice(0,t):s.slice(-t),l=s.length-t;return{visualLines:c,skippedCount:l}}var x=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=Pe(n,r,t,0,o),c=s.visualLines;if(s.skippedCount>0){let l=X(i(s.skippedCount),t,"...");this.cachedLines=o==="start"?[...c,l]:[l,...c]}else this.cachedLines=c;this.cachedWidth=t}return this.cachedLines}invalidate(){this.cachedWidth=void 0,this.cachedLines=void 0}};import{pathToFileURL as Je}from"node:url";var We="(?:\\u0007|\\u001B\\u005C|\\u009C)",ne="\\u001B\\]",re="(?:(?:\\u001B\\[|\\u009B)[<=>]|[\\u001B\\u009B][[\\]()#;?]*)(?:\\d{1,4}(?:[;:]\\d{0,4})*)?",Ue="[\\dA-PR-TZcf-nq-uy=><~]",Fe=new RegExp(`(?:${ne}[\\s\\S]*?${We})|${re}${Ue}`,"g"),Be=new RegExp(`(?:${ne}(?:[^\\u0007\\u009C\\u001B]|\\u001B(?!\\\\))*|${re})$`),He=256;function tn(e){if(!e.includes("\x1B")&&!e.includes("\x9B"))return{complete:e,pending:""};let t=Math.max(0,e.length-He),n=Be.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 oe(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return!e.includes("\x1B")&&!e.includes("\x9B")?e:e.replace(Fe,"")}function Ge(e){return typeof e!="string"?"":G(e)}function ze(e,t,n){if(!L().hyperlinks)return e;let r=z(t,n);return V(e,Je(r).href)}function ce(e){return typeof e=="string"?e:e==null?"":null}function ie(e){return typeof e=="string"&&e.trim()!==""&&(e=Number(e)),typeof e=="number"&&Number.isFinite(e)?e:void 0}function un(e,t){if(e==null&&t==null)return"";let n=e==null?1:ie(e);if(n===void 0)return"";if(t==null)return`:${n}`;let r=ie(t);if(r===void 0)return"";let o=n+r-1;return`:${n}${o?`-${o}`:""}`}function E(e){return e.replace(/\t/g," ")}function ln(e){return e.replace(/\r/g,"")}function ue(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=>Q(oe(s.text||"")).replace(/\r/g,"")).join(`
|
|
5
|
+
`),i=L();if(r.length>0&&(!i.images||!t)){let s=r.map(c=>{let l=c.mimeType??"image/unknown",u=c.data&&c.mimeType?Z(c.data,c.mimeType)??void 0:void 0;return K(l,u)}).join(`
|
|
6
|
+
`);o=o?`${o}
|
|
7
|
+
${s}`:s}return o}var se=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(([u,d])=>{let a=typeof d=="string"?d:JSON.stringify(d,null,2)??String(d);return` ${u}: ${E(a).replace(/\r/g,"").split(`
|
|
8
|
+
`).join(`
|
|
9
|
+
`)}`});return`${o}
|
|
10
|
+
${n.fg("muted",l.join(`
|
|
11
|
+
`))}`}let s=i.map(([l,u])=>`${l}=${JSON.stringify(u)??String(u)}`).join(" "),c=s.length>se?`${s.slice(0,se-3)}...`:s;return`${o} ${n.fg("muted",c)}`}function ae(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 le(e){let t=e.state;e.executionStarted&&t.startedAt===void 0&&(t.startedAt=Date.now(),t.endedAt=void 0)}function pe(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 ${ae(e.durationMs)}`;if(n.startedAt===void 0)return;let r=n.endedAt??Date.now();return`${t?"Elapsed":"Took"} ${ae(r-n.startedAt)}`}function qe(e){return e.fg("error","[invalid arg]")}function dn(e,t,n,r){if(e===null)return qe(t);let o=e||r?.emptyFallback;return o?ze(t.fg("accent",Ge(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 Xe=/^[A-Za-z_$][A-Za-z0-9_$]*$/,C=" ",Ze=16e3,Ve=32,Ke=["minimum","exclusiveMinimum","maximum","exclusiveMaximum","multipleOf","minLength","maxLength","pattern","format","minItems","maxItems"],de=new Set(["minimum","exclusiveMinimum","minLength","minItems"]),Ye=new Set(["maximum","exclusiveMaximum","maxLength","maxItems"]),Qe=80,ge=/[\r\n\u2028\u2029]/g;function et(e,t={}){let n=e.inputSchema===void 0?"unknown":ye(e.inputSchema,{maxChars:t.inputMaxChars??Ze});return`${T(e.name)}(args: ${n}): Promise<${P(e.outputSchema)}>;`}function he(e,t={}){let n=`declare const tools: { ${et(e,t)} };`;return`${e.description?.trim()??""}
|
|
12
|
+
|
|
13
|
+
codemode tool declaration:
|
|
14
|
+
\`\`\`ts
|
|
15
|
+
${n}
|
|
16
|
+
\`\`\``}function P(e){return e===void 0?"unknown":ye(e)}function tt(e){return Xe.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 ye(e,t={}){let n=i=>y(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 w(e,t){if(e!=="#"&&!e.startsWith("#/"))return;let n=t;for(let r of e.slice(2).split("/").filter(Boolean)){let o;try{o=decodeURIComponent(r)}catch{return}let i=o.replaceAll("~1","/").replaceAll("~0","~");if(typeof n!="object"||n===null||Array.isArray(n)||!(i in n))return;n=n[i]}return typeof n=="boolean"||typeof n=="object"&&n!==null&&!Array.isArray(n)?n:void 0}function y(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>=Ve)return"unknown";let i=w(o,t.root);if(i===void 0)return"unknown";t.expansions++,t.resolving.add(o);try{return y(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=>y(o,t)));if(Array.isArray(e.allOf)){let o=e.allOf.map(i=>y(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=>y({...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 fe(e,t);case"object":return me(e,t);case void 0:return"properties"in e||"additionalProperties"in e||"required"in e?me(e,t):"items"in e||"prefixItems"in e?fe(e,t):"unknown";default:return"unknown"}}function fe(e,t){if(e.items!==void 0&&!Array.isArray(e.items))return`Array<${y(e.items,t)}>`;let n=Array.isArray(e.prefixItems)?e.prefixItems:Array.isArray(e.items)?e.items:[];return n.length>0?`[${n.map(r=>y(r,t)).join(", ")}]`:"unknown[]"}function nt(e){let t=e?.description;return typeof t=="string"?t.trim():""}function rt(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(u=>u?.type!=="null"):[],o=r.length===1?r[0]:void 0,s=(typeof o=="object"&&o!==null&&!Array.isArray(o)?[t,o]:[t]).map(u=>({...u,...u.exclusiveMinimum===!0?{minimum:void 0,exclusiveMinimum:u.minimum}:{},...u.exclusiveMaximum===!0?{maximum:void 0,exclusiveMaximum:u.maximum}:{}})),c=[],l=u=>u==="integer"||Array.isArray(u)&&u.includes("integer");s.some(u=>l(u.type))&&c.push("@integer");for(let u of Ke){let d=s.map(a=>a[u]);if(de.has(u)||Ye.has(u)){let a=d.filter(p=>typeof p=="number");if(a.length===0)continue;c.push(`@${u} ${de.has(u)?Math.max(...a):Math.min(...a)}`);continue}for(let a of new Set(d))(typeof a=="number"||typeof a=="string")&&c.push(`@${u} ${a}`)}return s.some(u=>u.uniqueItems===!0)&&c.push("@uniqueItems"),t.default!==void 0&&t.default!==null&&c.push(`@default ${JSON.stringify(t.default)}`),t.deprecated===!0&&c.push("@deprecated"),c.filter(u=>u.length<=Qe).map(u=>u.replace(ge,d=>`\\u${d.charCodeAt(0).toString(16).padStart(4,"0")}`)).join(" ")}function me(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(u=>{let d=r.has(u)?"":"?";return`${tt(u)}${d}: ${y(n[u],t)};`}),s=e.additionalProperties;if(s!==void 0&&s!==!1){let u=s===!0?"unknown":y(s,t);i.push(`[key: string]: ${u};`)}else s===void 0&&o.length===0&&i.push("[key: string]: unknown;");if(i.length===0)return"{}";let c=o.map(u=>{let d=nt(n[u]).split(ge).map(p=>p.trim()).filter(Boolean),a=t.tags?rt(n[u]):"";return a?[...d,a]:d});if(!c.some(u=>u.length>0))return`{ ${i.join(" ")} }`;let l=["{"];c.forEach((u,d)=>{for(let a of u)l.push(`${C}// ${a}`);l.push(`${C}${i[d].replaceAll(`
|
|
17
|
+
`,`
|
|
18
|
+
${C}`)}`)});for(let u of i.slice(o.length))l.push(`${C}${u}`);return l.push("}"),l.join(`
|
|
19
|
+
`)}var k="// @options:",ot=["max_output_tokens","timeout_ms"],N="`max_output_tokens` and `timeout_ms`";var Se=String.raw`
|
|
20
|
+
start: options_source | plain_source
|
|
21
|
+
options_source: OPTIONS_LINE NEWLINE SOURCE
|
|
22
|
+
plain_source: SOURCE
|
|
23
|
+
|
|
24
|
+
OPTIONS_LINE: /[ \t]*\/\/ @options:[^\r\n]*/
|
|
25
|
+
NEWLINE: /\r?\n/
|
|
26
|
+
SOURCE: /[\s\S]+/
|
|
27
|
+
`,m=class extends Error{constructor(t){super(t),this.name="CodemodeSourceError"}};function $e(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>=0}function it(e){if(e==="")throw new m(`@options must be a JSON object with supported fields ${N}`);let t;try{t=JSON.parse(e)}catch(s){throw new m(`@options must be valid JSON with supported fields ${N}: ${s instanceof Error?s.message:String(s)}`)}if(typeof t!="object"||t===null||Array.isArray(t))throw new m(`@options must be a JSON object with supported fields ${N}`);let n=t;for(let s of Object.keys(n))if(!ot.includes(s))throw new m(`@options only supports ${N}; got \`${s}\``);let r={},{max_output_tokens:o,timeout_ms:i}=n;if(o!==void 0){if(!$e(o))throw new m("@options field `max_output_tokens` must be a non-negative safe integer");r.maxOutputTokens=o}if(i!==void 0){if(!$e(i)||i===0||i>2147483647)throw new m("@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 m('Expected JavaScript source text (non-empty). Provide JS only, optionally with a first line `// @options: {"max_output_tokens": 1000}`.');let t=e.split(`
|
|
28
|
+
`),n=t.findIndex((c,l)=>l>0&&c.trimStart().startsWith(k));if(n!==-1)throw new m(`The ${k} line must be the first line of the input; found one on line ${n+1}`);let r=e.indexOf(`
|
|
29
|
+
`),i=t[0].replace(/\r$/,"").trimStart();if(!i.startsWith(k))return{code:e,options:{}};let s=r===-1?"":e.slice(r);if(s.trim()==="")throw new m("The @options line must be followed by JavaScript source on subsequent lines");return{code:s,options:it(i.slice(k.length).trim())}}var M="tool_search",xe=8,st=new Intl.Segmenter(void 0,{granularity:"word"}),at=new Set(["a","an","and","are","as","at","be","by","for","from","in","is","it","of","on","or","that","the","this","to","with"]);function ct(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 A(e){let t=e.normalize("NFC").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").toLowerCase().replace(/[^\p{L}\p{M}\p{N}]+/gu," ");return(/^[a-z0-9 ]*$/.test(t)?t.split(" "):Array.from(st.segment(t),r=>r.isWordLike?r.segment:"")).filter(r=>r.length>0&&!at.has(r)).map(r=>/^[a-z0-9]+$/.test(r)?ct(r):r)}function W(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function O(e,t,n,r){if(W(e)){if(typeof e.$ref=="string"){let o=w(e.$ref,t);W(o)&&!r.has(o)&&(r.add(o),O(o,t,n,r))}if(typeof e.description=="string"&&n.push(e.description),W(e.properties))for(let[o,i]of Object.entries(e.properties))n.push(o),O(i,t,n,r);O(e.items,t,n,r);for(let o of["anyOf","oneOf","allOf"]){let i=e[o];if(Array.isArray(i))for(let s of i)O(s,t,n,r)}}}function ut(e,t){let n=[e.description];O(e.parameters,e.parameters,n,new Set([e.parameters]));let r=t?[t.name,t.description??"",t.instructions??""].join(" "):"";return{name:e.name,text:n.filter(o=>o.trim()).join(" "),namespaceText:r}}function Te(e){return e.trim().toLowerCase().replace(/[^a-z0-9_$]/g,"_")}function lt(e,t){let n=Te(t);return n===e||n.endsWith(`__${e}`)}function pt(e){let t=new Map;for(let r of A(e.text))t.set(r,(t.get(r)??0)+1);let n=e.name.split("__");return{name:e.name,nameTerms:new Set(A(e.name)),localNameTerms:[...new Set(A(n[n.length-1]))],textCounts:t,textLength:[...t.values()].reduce((r,o)=>r+o,0),namespaceTerms:new Set(A(e.namespaceText??""))}}var dt=3,ft=.5,U=class{k1;b;constructor(t={}){this.k1=t.k1??1.2,this.b=t.b??.75}rank(t,n,r){let o=new Set(A(t));if(o.size===0||n.length===0||r<=0)return[];let i=n.map(pt),s=i.reduce((a,p)=>a+p.textLength,0)/i.length||1,c=new Map([...o].map(a=>{let p=i.filter(f=>f.nameTerms.has(a)||f.textCounts.has(a)||f.namespaceTerms.has(a)).length;return[a,Math.log(1+(i.length-p+.5)/(p+.5))]})),l=[...c.values()].reduce((a,p)=>a+p,0),u=Te(t),d=[];for(let a of i){let p=this.k1*(1-this.b+this.b*a.textLength/s),f=0,g=0;for(let $ of o){let H=a.textCounts.get($)??0,J=(a.nameTerms.has($)?dt:0)+(a.namespaceTerms.has($)?ft:0)+H*(this.k1+1)/(H+p);J>0&&g++,f+=(c.get($)??0)*J}if(f===0)continue;let _=a.localNameTerms;_.length>0&&_.every($=>o.has($))&&(f+=l),d.push({name:a.name,score:f,covered:g,exact:lt(u,a.name)})}return d.sort((a,p)=>Number(p.exact)-Number(a.exact)||p.covered-a.covered||p.score-a.score).slice(0,r).map(({name:a,score:p})=>({name:a,score:p}))}},mt=S.Object({query:S.String({description:"Search query for deferred tools."}),limit:S.Optional(S.Number({description:`Maximum number of tools to return. Defaults to ${xe}.`}))});function gt(e){return e==="codemode"||e==="deferred"}function ht(e,t,n){let r=e.getActiveTools(),o=e.getAllTools().filter(c=>gt(c.exposure)&&!r.includes(c.name)),i=o.map(c=>ut(c,c.namespace)),s=new U().rank(t,i,n);return s.length>0&&e.setActiveTools([...r,...s.map(c=>c.name)]),s.map(c=>({name:c.name,description:o.find(l=>l.name===c.name)?.description??""}))}var yt=`# Tool discovery
|
|
30
|
+
|
|
31
|
+
Searches over deferred tool metadata with BM25 and exposes matching tools for the next model call.
|
|
32
|
+
|
|
33
|
+
Some of the tools, such as tools of MCP servers, may not have been provided to you upfront, and you should use this tool (\`${M}\`) to search for the required tools. For MCP tool discovery, always use \`${M}\`.`;function Tn(e={}){return{name:M,label:M,description:yt,promptSnippet:"Search for tools that are not loaded yet and load the matches",parameters:mt,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??xe;if(!Number.isInteger(o)||o<=0)throw new Error("limit must be a positive integer");let i=e.tools?ht(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:
|
|
34
|
+
${i.map(c=>`- ${c.name}: ${c.description.trim().split(/\r?\n/)[0]}`).join(`
|
|
35
|
+
`)}`}],details:{loaded:i.map(c=>c.name)}}}}}import{join as bt}from"node:path";function $t(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 we=()=>import("../../vendor/pi/dist/extensions/codemode/execute.js");var St=10,xt=8,Tt=5,Ae=80,wt=/^Script (completed|failed)\nWall time [\d.]+ seconds\nOutput:\n$/;function Oe(e,t,n){return`${e.fg("muted",`... (${t} more ${n},`)} ${j("app.tools.expand","to expand")}${e.fg("muted",")")}`}function At(e){return e===void 0?"":e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(1)}s`}function _e(e){return`$${e>=.01?e.toFixed(2):e.toPrecision(2)}`}function Ot(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>Ae?`${e.args.slice(0,Ae-3)}...`:e.args,o=At(e.durationMs),i=`${Ot(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",_e(e.cost))}`),n&&e.error&&(i+=`
|
|
36
|
+
${t.fg("error",e.error.split(`
|
|
37
|
+
`).join(`
|
|
38
|
+
`))}`),i}var be={renderCall(e,t,n){le(n);let r=ce(e?.code),o=t.fg("toolTitle",t.bold("codemode")),i=n.lastComponent??new v;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=n.state;s.scriptHighlighter??=new Y;let c=s.scriptHighlighter.highlight(E(r.replace(/\r/g,"").trimEnd()),"javascript").join(`
|
|
39
|
+
`);i.addChild(n.expanded?new h(c,0,0):new x({text:c,maxVisualLines:St,keep:"start",formatHint:l=>Oe(t,l,"lines")}))}return i},renderResult(e,t,n,r){let o=pe(r,t.isPartial),i=r.lastComponent??new v;i.clear();let s=e.details?.calls??[];if(s.length>0){let a=t.expanded?s:s.slice(-xt),p=a.map(g=>_t(g,n,t.expanded));a.length<s.length&&p.unshift(`${n.fg("muted",`... (${s.length-a.length} earlier calls,`)} ${j("app.tools.expand","to expand")}${n.fg("muted",")")}`);let f=s.filter(g=>g.cost);if(f.length>1){let g=f.reduce((_,$)=>_+($.cost??0),0);p.push(n.fg("muted",`Model calls: ${_e(g)}`))}i.addChild(new b(1)),i.addChild(new h(p.join(`
|
|
40
|
+
`),0,0))}let[c,...l]=e.content,u=c?.type==="text"&&wt.test(c.text),d=t.isPartial?"":ue({...e,content:u?l:e.content},r.showImages).trim();if(d){let a=r.isError?"error":"toolOutput",p=E(d).split(`
|
|
41
|
+
`).map(f=>n.fg(a,f)).join(`
|
|
42
|
+
`);if(i.addChild(new b(1)),t.expanded)i.addChild(new h(p,0,0));else{i.addChild(new x({text:p,maxVisualLines:Tt,keep:"start",formatHint:g=>Oe(n,g,"lines")}));let f=e.details?.fullOutputPath;f&&i.addChild(new h(n.fg("muted",`Full output: ${f}`),0,0))}}return o&&(i.addChild(new b(1)),i.addChild(new h(n.fg("muted",o),0,0))),i}};var R="codemode",Fn="codemode-store",Et={type:"string"},Ct=S.Object({code:S.String({description:"Raw JavaScript source."})}),Ee={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."]},kt=bt(q(),"codemode.md"),Nt='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 Mt(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 ${kt} first.`),t.join(`
|
|
43
|
+
`)}var Rt=I.codemode.inlineBudget,It=4;function Ce(e,t=[]){let n=t.flatMap(r=>r.trim()?[`- ${r.trim()}`]:[]);return{name:e.name,description:n.length>0?`${e.description.trim()}
|
|
44
|
+
|
|
45
|
+
${n.join(`
|
|
46
|
+
`)}`:e.description,inputSchema:e.parameters,outputSchema:e.outputSchema??Et}}function ke(e){return e.filter(t=>t.name!==R)}function Lt(e){let t=T(e.name);return`${t===e.name?`### \`${t}\``:`### \`${t}\` (\`${e.name}\`)`}
|
|
47
|
+
${he(e).trim()}`}function vt(e,t){if(t===void 0)return new Set(e.flatMap(s=>s.entries.map(c=>c.name)));let n=e.map(s=>[...s.entries].sort((c,l)=>c.cost-l.cost)),r=new Set,o=t,i=n.filter(s=>s.length>0);for(;i.length>0;)i=i.filter(s=>{let c=s[0];return c.cost>o?!1:(o-=c.cost,r.add(c.name),s.shift(),s.length>0)});return r}function Ne(e,t={}){let n=ke(e).filter(l=>!t.deferred?.has(l.name)).map(l=>Ce(l,t.guidelines?.get(l.name))),r=new Map([["",{namespace:void 0,entries:[]}]]);for(let l of n){let u=t.namespaces?.get(l.name),d=u?`ns:${u.name}`:"",a=r.get(d)??{namespace:u,entries:[]};r.set(d,a);let p=Lt(l);a.entries.push({name:l.name,section:p,cost:Math.ceil(p.length/It)})}let o=[...r.values()].sort((l,u)=>l.namespace===void 0?-1:u.namespace===void 0?1:l.namespace.name.localeCompare(u.namespace.name)),i=vt(o,t.inlineBudget),s=[Nt,Mt(t.models===!0)];if(n.length===0)return s.join(`
|
|
48
|
+
|
|
49
|
+
`);let c=["Nested tools:"];for(let{namespace:l,entries:u}of o){let d=u.filter(a=>i.has(a.name));if(l){let a=d.length===u.length?"":d.length===0?" (tools not listed)":" (some tools not listed)",p=l.description?.trim();c.push(`## ${l.name}${a}${p?`
|
|
50
|
+
${p}`:""}`)}for(let a of d)c.push(a.section)}return s.push(c.join(`
|
|
51
|
+
|
|
52
|
+
`)),s.join(`
|
|
53
|
+
|
|
54
|
+
`)}function B(e,t,n){let r=F(e,t);if(typeof r!="object"||r===null)return;let{type:o,properties:i,required:s}=r;if(o!=="object"||typeof i!="object"||i===null)return;let c=new Set(Array.isArray(s)?s:[]);return`{ ${Object.entries(i).map(([u,d])=>{let a=F(d,t)?.const,p=a!==void 0?JSON.stringify(a):n>0?B(d,t,n-1):void 0;return`${u}${c.has(u)?"":"?"}${p?`: ${p}`:""}`}).join(", ")} }`}function jt(e,t){let n=P(t);if(n==="string")return"a string";let r=t===void 0?void 0:B(t,t,1)??Dt(t,t);return r?`\`${r}\``:n.includes(`
|
|
55
|
+
`)?`a value; \`await describeTool(${JSON.stringify(e)})\` shows its type`:`\`${n}\``}function Dt(e,t){let n=F(e,t);if(typeof n!="object"||n===null)return;let{anyOf:r,oneOf:o}=n,i=r??o;if(!Array.isArray(i)||i.length===0)return;let s=i.map(c=>B(c,t,0));return s.every(c=>c!==void 0)?s.join(" | "):void 0}function F(e,t){let n=new Set,r=e;for(;typeof r=="object"&&r!==null&&!n.has(r);){let o=r.$ref;if(typeof o!="string")break;let i=w(o,t);if(i===void 0)break;n.add(r),r=i}return r}function Pt(e){return`${e.description.trim()}
|
|
56
|
+
|
|
57
|
+
Codemode: \`tools.${T(e.name)}(args)\` resolves to ${jt(e.name,Ce(e).outputSchema)}.`}function Wt(e,t){let n=t.getMode?.()??I.codemode.mode,r=a=>e.getExposure(a.name)==="direct",o=ke(e.callable),i=new Set(o.map(a=>a.name)),s={};if(n==="on")for(let a of e.declared)i.has(a.name)&&(s[a.name]=Pt(a));let c=n==="only"?o:o.filter(a=>!r(a)),l=new Map(c.flatMap(a=>{let p=e.getNamespace(a.name);return p?[[a.name,p]]:[]})),u=new Map(c.map(a=>[a.name,e.getPromptGuidelines(a.name)]));s[R]=Ne(c,{models:t.models===!0,namespaces:l,guidelines:u,deferred:new Set(c.filter(a=>e.getExposure(a.name)==="deferred").map(a=>a.name)),inlineBudget:t.getInlineBudget?.()??Rt});let d=new Set(e.declared.map(a=>a.name));return{descriptions:s,hiddenDeclarations:n==="only"?o.filter(a=>r(a)&&d.has(a.name)).map(a=>a.name):[]}}var Ut=/\b(searchTools|describeNamespace|describeTool|ALL_TOOLS)\b/;function Ft(e){return typeof e!="string"?[]:Ut.test(e)?"all":e.match(/\w+/g)??[]}function Bn(e={}){return{name:R,label:R,description:Ne([],{models:e.models===!0}),promptSnippet:Ee.snippet,promptGuidelines:[...Ee.guidelines],parameters:Ct,exposure:"model-only",prepareLoadout:t=>Wt(t,e),reachesTools:t=>Ft(t.code),constrainedSampling:{type:"grammar",variants:{openai_lark:Se}},execute:async(t,n,r,o,i)=>(await we()).executeCodemode(t,n,r,o,i,e),...be}}export{tn as a,oe as b,qt as c,Xt as d,je as e,De as f,Vt as g,Kt as h,$t as i,An as j,Pe as k,x as l,Ge as m,ce as n,un as o,E as p,ln as q,ue as r,pn as s,le as t,pe as u,qe as v,dn as w,T as x,he as y,yn as z,M as A,xe as B,ut as C,U as D,Tn as E,R as F,Fn as G,kt as H,Ce as I,ke as J,Bn as K};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire as __cortexCreateRequire } from 'node:module';
|
|
2
|
+
const require = __cortexCreateRequire(import.meta.url);
|
|
3
|
+
const __cortexPackageRoot = new URL("../../", import.meta.url);
|
|
4
|
+
import{a as n}from"./chunk-6R73ICDB.js";var T=function(_,E){return typeof _=="string"&&/^\.\.?\//.test(_)?_.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(e,I,A,N,P){return I?E?".jsx":".js":A&&(!N||!P)?e:A+N+"."+P.toLowerCase()+"js"}):_},t=null,O=null,s=null,i=_=>import(T(_)),a="node:fs",K="node:os",c="node:path";typeof process<"u"&&(process.versions?.node||process.versions?.bun)&&(i(a).then(_=>{t=_.existsSync}),i(K).then(_=>{O=_.homedir}),i(c).then(_=>{s=_.join}));var r="ANTHROPIC_AUTH_TOKEN",C="ANTHROPIC_OAUTH_TOKEN",R="ANTHROPIC_API_KEY",L="ANTHROPIC_FEDERATION_RULE_ID",d="ANTHROPIC_ORGANIZATION_ID",p="ANTHROPIC_SERVICE_ACCOUNT_ID",D="ANTHROPIC_IDENTITY_TOKEN_FILE",S="ANTHROPIC_WORKSPACE_ID",o=null;function l(_){let E=_?.GOOGLE_APPLICATION_CREDENTIALS;if(E)return t?t(E):!1;if(o===null){if(!t||!O||!s)return typeof process<"u"&&(process.versions?.node||process.versions?.bun)||(o=!1),!1;let e=n("GOOGLE_APPLICATION_CREDENTIALS",_);e?o=t(e):o=t(s(O(),".config","gcloud","application_default_credentials.json"))}return o}function Y(_){if(_==="github-copilot")return["COPILOT_GITHUB_TOKEN"];if(_==="anthropic")return[r,C,R];let e={"ant-ling":"ANT_LING_API_KEY","qwen-token-plan":["QWEN_TOKEN_PLAN_TEAM_API_KEY","QWEN_TOKEN_PLAN_API_KEY"],"qwen-token-plan-cn":["QWEN_TOKEN_PLAN_TEAM_CN_API_KEY","QWEN_TOKEN_PLAN_CN_API_KEY"],"qwen-token-plan-individual":["QWEN_TOKEN_PLAN_INDIVIDUAL_API_KEY","QWEN_TOKEN_PLAN_API_KEY"],"qwen-token-plan-individual-cn":["QWEN_TOKEN_PLAN_INDIVIDUAL_CN_API_KEY","QWEN_TOKEN_PLAN_CN_API_KEY"],openai:"OPENAI_API_KEY",azure:"AZURE_OPENAI_API_KEY",nvidia:"NVIDIA_API_KEY",deepseek:"DEEPSEEK_API_KEY",google:"GEMINI_API_KEY","google-vertex":"GOOGLE_CLOUD_API_KEY",groq:"GROQ_API_KEY",cerebras:"CEREBRAS_API_KEY",xai:"XAI_API_KEY",typesafe:"TYPESAFE_API_KEY",radius:"RADIUS_API_KEY",openrouter:"OPENROUTER_API_KEY","vercel-ai-gateway":"AI_GATEWAY_API_KEY",zai:"ZAI_API_KEY","zai-coding-cn":"ZAI_CODING_CN_API_KEY",mistral:"MISTRAL_API_KEY",minimax:"MINIMAX_API_KEY","minimax-cn":"MINIMAX_CN_API_KEY",moonshotai:"MOONSHOT_API_KEY","moonshotai-cn":"MOONSHOT_API_KEY",huggingface:"HF_TOKEN",fireworks:"FIREWORKS_API_KEY",together:"TOGETHER_API_KEY",baseten:"BASETEN_API_KEY",opencode:"OPENCODE_API_KEY","opencode-go":"OPENCODE_API_KEY","kimi-coding":"KIMI_API_KEY",meta:"META_API_KEY","cloudflare-workers-ai":"CLOUDFLARE_API_KEY","cloudflare-ai-gateway":"CLOUDFLARE_API_KEY",xiaomi:"XIAOMI_API_KEY","xiaomi-token-plan-cn":"XIAOMI_TOKEN_PLAN_CN_API_KEY","xiaomi-token-plan-ams":"XIAOMI_TOKEN_PLAN_AMS_API_KEY","xiaomi-token-plan-sgp":"XIAOMI_TOKEN_PLAN_SGP_API_KEY"}[_];return typeof e=="string"?[e]:e}function u(_,E){let e=Y(_);if(!e)return;let I=e.filter(A=>!!n(A,E));return I.length>0?I:void 0}function g(_,E){let e=u(_,E);if(e?.[0]){let I=_==="anthropic"?e.find(A=>A!==r):e[0];if(I)return n(I,E)}if(_==="google-vertex"){let I=l(E),A=!!(n("GOOGLE_CLOUD_PROJECT",E)||n("GCLOUD_PROJECT",E)),N=!!n("GOOGLE_CLOUD_LOCATION",E);if(I&&A&&N)return"<authenticated>"}if(_==="amazon-bedrock"&&(n("AWS_PROFILE",E)||n("AWS_ACCESS_KEY_ID",E)&&n("AWS_SECRET_ACCESS_KEY",E)||n("AWS_BEARER_TOKEN_BEDROCK",E)||n("AWS_CONTAINER_CREDENTIALS_RELATIVE_URI",E)||n("AWS_CONTAINER_CREDENTIALS_FULL_URI",E)||n("AWS_WEB_IDENTITY_TOKEN_FILE",E)))return"<authenticated>"}export{r as a,C as b,R as c,L as d,d as e,p as f,D as g,S as h,u as i,g as j};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire as __cortexCreateRequire } from 'node:module';
|
|
2
|
+
const require = __cortexCreateRequire(import.meta.url);
|
|
3
|
+
const __cortexPackageRoot = new URL("../../", import.meta.url);
|
|
4
|
+
import{a as d}from"./chunk-OKRK6JPY.js";var h="Model override: pi provider/model[:thinking], claude model ID. Default: role model, then parent model.",A="Backend override. Default: role backend, then parent backend.",D="Delegate isolated, one-shot work; children cannot delegate. Give self-contained prompts. Use one mode: the single fields, parallel, or chain; both backends. clean (for work Cortex context must not shape): the child starts in a fresh workspace with its brief and the files listed, copied to inputs/. The brief must stand alone and name them as inputs/<name>. To let the child use paths outside its workspace, list them in allow \u2014 only paths the user authorized; children of a clean session also get its authorized paths. The result ends with the workspace path holding its output.",$="Tasks to run concurrently, each with the single-mode fields.",G="Tasks to run in order, each with the single-mode fields; {previous} inserts the prior output.",P="Run in a fresh workspace without Cortex context. Implied by files.",L="Files or directories (absolute or ~ paths) copied into the workspace inputs/. Implies clean.",K="Paths the user authorized that the child may use in place: path (absolute or ~), device for a path on a connected device, write (default true; false for read only).",E=["description","prompt","subagent_type"];function T(t,e){if(t!=null){if(t==="claude"||t==="pi")return t;throw new Error(`${e} backend must be "claude" or "pi".`)}}function g(t){for(let e of E)if(typeof t[e]!="string"||t[e].trim()==="")throw new Error(`Agent task requires a non-empty ${e}.`);T(t.backend,"Agent task"),_(t)}function _(t){if(t.clean!==void 0&&typeof t.clean!="boolean")throw new Error("Agent task clean must be a boolean.");let e=t.files;if(e!==void 0&&(!Array.isArray(e)||e.some(n=>typeof n!="string"||n.trim()==="")))throw new Error("Agent task files must be a list of non-empty paths.");let o=t.allow;if(o!==void 0&&(!Array.isArray(o)||!o.every(N)))throw new Error("Agent task allow must be a list of { path, device?, write? } with a non-empty path.")}function N(t){let e=t;return!e||typeof e!="object"||typeof e.path!="string"||e.path.trim()===""?!1:(e.device===void 0||typeof e.device=="string"&&e.device.trim()!=="")&&(e.write===void 0||typeof e.write=="boolean")}function m(t,e){if(e.length===0)throw new Error(`${t} requires at least one task.`);if(e.length>8)throw new Error(`Agent ${t} task maximum is 8.`);for(let o of e)g(o);return{mode:t,tasks:e}}function j(t){let e=t??{},o=E.some(s=>s in e),n=Array.isArray(e.parallel),r=Array.isArray(e.chain);if(Number(o)+Number(n)+Number(r)!==1)throw new Error("Provide exactly one Agent mode: single fields, parallel, or chain.");if(n)return m("parallel",e.parallel);if(r)return m("chain",e.chain);let i=e;return g(i),{mode:"single",tasks:[i]}}var k=24,u=480;function z(t){let e=t.subagentClaudeModels;return[...e?S(e.map(n=>({backend:"claude",id:n.id})),t.claudeModel):C(t.claudeModel),...t.subagentPiModels??[]]}var w={model:h,backend:A},x="Role name, such as explore, general-purpose, or plan.";function Y(t){let e=(t.roles??[]).map(r=>({name:r.name.trim(),summary:r.summary.trim()})).filter(r=>r.name!=="").sort((r,i)=>r.name.localeCompare(i.name)),o=t.models??[],n=e.length>0?` Available here: ${v(e)}.`:"";return{subagentType:e.length>0?`Role name.${n}`:x,...w,catalog:U(o)}}function q(t){let e=[];for(let o of t){let n=o.name.trim();n&&e.push({name:n,summary:M(o.description)})}return e}function C(t,e=d){let o=e.length>0?e:d;return S(o.map(n=>({backend:"claude",id:n})),t)}function S(t,e){let o=e?.trim();return!o||t.some(n=>n.id===o)?t:[...t,{backend:"claude",id:o}]}function J(t){let e=[];for(let o of t){let n=o.id.trim();if(!n)continue;let r=o.provider.trim();e.push(r?{backend:"pi",provider:r,id:n}:{backend:"pi",id:n})}return e}function W(t){return JSON.stringify(t)}function Q(t){return t?I(t):null}function I(t){if(!t)return[];let e;try{e=JSON.parse(t)}catch{return[]}if(!Array.isArray(e))return[];let o=e,n=[];for(let r of o){if(!O(r))continue;let{backend:i,provider:s,id:c}=r;if(i!=="claude"&&i!=="pi"||typeof c!="string"||!c.trim())continue;let l={backend:i,id:c.trim()};typeof s=="string"&&s.trim()&&(l.provider=s.trim()),n.push(l)}return n}function O(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function M(t){let e=t.trim(),o=e.indexOf(". "),n=o>=0?e.slice(0,o):e;return n.endsWith(".")&&(n=n.slice(0,-1)),n.length>80&&(n=`${n.slice(0,80)}\u2026`),n}function R(t){let e=t.id.trim();if(!e)return null;if(t.backend==="claude")return e;let o=t.provider?.trim()??"";return o?`${o}/${e}`:e}function B(t){let e=new Set,o=[];for(let n of t){let r=R(n);if(!r)continue;let i=`${n.backend}:${r}`;e.has(i)||(e.add(i),o.push({backend:n.backend,name:r}))}return o.sort((n,r)=>n.backend===r.backend?n.name.localeCompare(r.name):n.backend==="claude"?-1:1),o}var b=" Known models \u2014 ";function U(t){let e=B(t),o=["claude","pi"].flatMap(n=>{let r=e.filter(i=>i.backend===n).map(i=>i.name);return r.length?[`${n}: ${r.join(", ")}`]:[]});return o.length?`${b}${o.join("; ")}.`:""}function V(t){return t.split(b)[0]}function v(t){let e=t.slice(0,k),o=t.length-e.length,n=o>0?` (+${o} more)`:"",r=e.map(a=>a.summary?`${a.name} \u2014 ${a.summary}`:a.name).join("; ");if(r.length+n.length<=u)return r+n;let i=e.map(a=>a.name).join(", ");if(i.length+n.length<=u)return i+n;let s=[],c=0;for(let a of e){let p=a.name.length+(s.length>0?2:0),f=t.length-(s.length+1),y=f>0?` (+${f} more)`.length:0;if(c+p+y>u)break;s.push(a.name),c+=p}let l=t.length-s.length;return s.join(", ")+(l>0?` (+${l} more)`:"")}export{D as a,$ as b,G as c,P as d,L as e,K as f,j as g,z as h,Y as i,q as j,J as k,W as l,Q as m,I as n,U as o,V as p};
|