@cortex-agent/server 2026.10.28 → 2026.12.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +255 -21
- package/README.md +36 -7
- package/THIRD_PARTY_NOTICES.txt +1990 -593
- package/defaults/hooks/cortex-hook-api.mjs +2 -1
- package/defaults/hooks/quota-stop.mjs +37 -0
- package/defaults/plugins/cortex-system/skills/client-manage/SKILL.md +23 -15
- package/defaults/prompts/clean-workspace.md +5 -0
- package/dist/agent-adapter/claude/remote-mcp-proxy.js +1 -1
- package/dist/chunks/agent-runner-LVZVKBZX.js +4 -0
- package/dist/chunks/anthropic-messages-TT6454AA.js +8 -0
- package/dist/chunks/azure-openai-responses-52LR2XZD.js +4 -0
- package/dist/chunks/bedrock-converse-stream-EOZGYUNY.js +60 -0
- package/dist/chunks/bowser-MLGGLXTZ.js +20 -0
- package/dist/chunks/child-runner-SMG2VOU5.js +4 -0
- package/dist/chunks/chunk-24DH4IR5.js +4 -0
- package/dist/chunks/chunk-25XKBRDT.js +70 -0
- package/dist/chunks/chunk-2ABET62E.js +23 -0
- package/dist/chunks/chunk-2BVUA256.js +4 -0
- package/dist/chunks/{chunk-LEUENXI2.js → chunk-2WFL62UO.js} +1 -1
- package/dist/chunks/{chunk-OZGBWAT2.js → chunk-2YTYYG4K.js} +1 -1
- package/dist/chunks/chunk-335SSANX.js +4 -0
- package/dist/chunks/chunk-377OPTXX.js +17 -0
- package/dist/chunks/chunk-3EZNVLBF.js +129 -0
- package/dist/chunks/chunk-3O6ZG5HA.js +7 -0
- package/dist/chunks/{chunk-6AKUD3CF.js → chunk-3XLHL5YT.js} +1 -1
- package/dist/chunks/chunk-4HRI75GU.js +4 -0
- package/dist/chunks/chunk-4JBYLRPM.js +57 -0
- package/dist/chunks/chunk-4KKV7VKE.js +4 -0
- package/dist/chunks/chunk-4KQHDDC5.js +4 -0
- package/dist/chunks/chunk-4SWD4JMP.js +33 -0
- package/dist/chunks/chunk-52VCLZS5.js +4 -0
- package/dist/chunks/chunk-54P7TSY3.js +10 -0
- package/dist/chunks/chunk-5DVSAXOI.js +7 -0
- package/dist/chunks/chunk-5F3A62YS.js +4 -0
- package/dist/chunks/{chunk-XNSSUVT6.js → chunk-5FHETFZM.js} +1 -1
- package/dist/chunks/{chunk-A34TDMIC.js → chunk-5LBLRAHS.js} +1 -1
- package/dist/chunks/chunk-5UYVNA3W.js +4 -0
- package/dist/chunks/chunk-6G3OYMCV.js +21 -0
- package/dist/chunks/chunk-7GGPYU5E.js +30 -0
- package/dist/chunks/chunk-7TYSMLUV.js +4 -0
- package/dist/chunks/chunk-7W7VYUTK.js +5 -0
- package/dist/chunks/chunk-AXYAZTTN.js +6 -0
- package/dist/chunks/{chunk-BGVHA2D4.js → chunk-B3NB243Z.js} +1 -1
- package/dist/chunks/chunk-BKYP6AGM.js +8 -0
- package/dist/chunks/chunk-BVEDNESB.js +4 -0
- package/dist/chunks/chunk-BWDJS6A4.js +12 -0
- package/dist/chunks/chunk-C6YVF7EI.js +4 -0
- package/dist/chunks/chunk-CEJIYYVE.js +15 -0
- package/dist/chunks/chunk-CI2RHH74.js +50 -0
- package/dist/chunks/chunk-CMSOOLJB.js +4 -0
- package/dist/chunks/chunk-CSVTYYLP.js +4 -0
- package/dist/chunks/chunk-DE5EGVKG.js +6 -0
- package/dist/chunks/{chunk-E6BYRULL.js → chunk-DK3RPZOQ.js} +1 -1
- package/dist/chunks/{chunk-YPK2CAIZ.js → chunk-DK4UCK7L.js} +1 -1
- package/dist/chunks/chunk-DYLBVUAU.js +4 -0
- package/dist/chunks/chunk-FDC2GRBK.js +27 -0
- package/dist/chunks/chunk-FE7HH5JS.js +18 -0
- package/dist/chunks/chunk-FYD57YRO.js +436 -0
- package/dist/chunks/chunk-G264APQN.js +5 -0
- package/dist/chunks/chunk-G4JYZFEO.js +11 -0
- package/dist/chunks/chunk-GFFM56U2.js +4 -0
- package/dist/chunks/chunk-GOS3P7KS.js +132 -0
- package/dist/chunks/chunk-HVN37UXD.js +4 -0
- package/dist/chunks/chunk-IA6IODY3.js +4 -0
- package/dist/chunks/{chunk-HU6UIDEJ.js → chunk-IGZWZP7Z.js} +1 -1
- package/dist/chunks/{chunk-NR6U3WIZ.js → chunk-IJ7XFQMI.js} +1 -1
- package/dist/chunks/chunk-IMMGYDAB.js +6 -0
- package/dist/chunks/chunk-IOWBF7UK.js +10 -0
- package/dist/chunks/{chunk-HALUQ7ZF.js → chunk-ITGCWQFK.js} +1 -1
- package/dist/chunks/chunk-IVZ7QUEG.js +4 -0
- package/dist/chunks/{chunk-YAEVYJAR.js → chunk-IWY2HIFK.js} +1 -1
- package/dist/chunks/{chunk-KGJZAYQD.js → chunk-J7OBATRN.js} +1 -1
- package/dist/chunks/{chunk-QWAQHHRS.js → chunk-JGUEIW2W.js} +1 -1
- package/dist/chunks/chunk-JKL3AK5D.js +106 -0
- package/dist/chunks/chunk-JZ7U7RUK.js +351 -0
- package/dist/chunks/chunk-KJUQCCB5.js +4 -0
- package/dist/chunks/chunk-KST6OY76.js +10 -0
- package/dist/chunks/chunk-KZSAFVSY.js +129 -0
- package/dist/chunks/chunk-LD2ZSH3M.js +903 -0
- package/dist/chunks/chunk-LE6QPXN6.js +7 -0
- package/dist/chunks/chunk-LEAV3FFG.js +4 -0
- package/dist/chunks/chunk-LIIZI3HY.js +5 -0
- package/dist/chunks/chunk-LP72AF56.js +45 -0
- package/dist/chunks/{chunk-FXDIR3SQ.js → chunk-MJQ2D2OP.js} +1 -1
- package/dist/chunks/{chunk-6LZK4DDH.js → chunk-NHHR4DCF.js} +1 -1
- package/dist/chunks/chunk-NW4GW47L.js +4 -0
- package/dist/chunks/chunk-OALEJ6FG.js +60 -0
- package/dist/chunks/chunk-OIV4DIMB.js +4 -0
- package/dist/chunks/chunk-OJ37ZWBG.js +4 -0
- package/dist/chunks/chunk-OZXMPBUX.js +4 -0
- package/dist/chunks/{chunk-3THJYAEF.js → chunk-PG7452XE.js} +1 -1
- package/dist/chunks/chunk-PJCUB7YJ.js +4 -0
- package/dist/chunks/chunk-PTS3J4DQ.js +6 -0
- package/dist/chunks/{chunk-PXS5SHOV.js → chunk-PVVEEBUU.js} +1 -1
- package/dist/chunks/chunk-Q7BZLPBU.js +8 -0
- package/dist/chunks/{chunk-FOJQXLL2.js → chunk-QC66ZXPP.js} +1 -1
- package/dist/chunks/chunk-QXFWIL4C.js +4 -0
- package/dist/chunks/{chunk-PFMEUFJ7.js → chunk-R2CCD4OF.js} +1 -1
- package/dist/chunks/chunk-R6CGBSTC.js +22 -0
- package/dist/chunks/chunk-RG5GP4RB.js +5 -0
- package/dist/chunks/{chunk-D3NXKK2L.js → chunk-RW2F2QNP.js} +1 -1
- package/dist/chunks/{models-L5VF4I5O-XXNJYQMQ.js → chunk-RWPO3NZ3.js} +1 -1
- package/dist/chunks/chunk-SAJD4EKE.js +10 -0
- package/dist/chunks/chunk-SDUS2H3E.js +4 -0
- package/dist/chunks/chunk-SIHGKM4E.js +4 -0
- package/dist/chunks/chunk-SKHFU5DI.js +4 -0
- package/dist/chunks/{chunk-STUHNKQS.js → chunk-SM45TH22.js} +1 -1
- package/dist/chunks/chunk-T54CZKNJ.js +6 -0
- package/dist/chunks/chunk-TKFFQNAP.js +19 -0
- package/dist/chunks/chunk-TMV2ZDOI.js +18 -0
- package/dist/chunks/chunk-TRXLIL7V.js +4 -0
- package/dist/chunks/{chunk-SUFW24P4.js → chunk-UEEW2R4E.js} +1 -1
- package/dist/chunks/chunk-UHXPRU6G.js +10 -0
- package/dist/chunks/chunk-UPQVWHZ3.js +4 -0
- package/dist/chunks/{chunk-JERCOLY3.js → chunk-V35MFAUQ.js} +4 -6
- package/dist/chunks/chunk-V7K3KNDM.js +4 -0
- package/dist/chunks/chunk-VHX2GHBF.js +4 -0
- package/dist/chunks/chunk-VOAKRJ4R.js +4 -0
- package/dist/chunks/{chunk-X2GYYRVM.js → chunk-VW7TLY3P.js} +1 -1
- package/dist/chunks/chunk-W34AK4SK.js +65 -0
- package/dist/chunks/{chunk-REBNWCKI.js → chunk-WU7RNAZD.js} +1 -1
- package/dist/chunks/chunk-WZC4TDDM.js +6 -0
- package/dist/chunks/chunk-WZYS2HAK.js +4 -0
- package/dist/chunks/chunk-X2TKJ7KR.js +11 -0
- package/dist/chunks/{chunk-H2FP6DG4.js → chunk-X5ND4H4P.js} +1 -1
- package/dist/chunks/{chunk-4U7XXM4W.js → chunk-Y3AOGNDT.js} +1 -1
- package/dist/chunks/chunk-Y6DGVTKM.js +6 -0
- package/dist/chunks/{chunk-KENCMLRE.js → chunk-YAEHSSR4.js} +1 -1
- package/dist/chunks/chunk-YWPBE5LP.js +4 -0
- package/dist/chunks/chunk-ZAVX7G2M.js +15 -0
- package/dist/chunks/chunk-ZD2M73XA.js +19 -0
- package/dist/chunks/chunk-ZD4O6NPV.js +4 -0
- package/dist/chunks/chunk-ZNAMETPQ.js +4 -0
- package/dist/chunks/chunk-ZY6N5LVQ.js +4 -0
- package/dist/chunks/chunk-ZYQ4TDTT.js +81 -0
- package/dist/chunks/cli-VB2N7HEK.js +55 -0
- package/dist/chunks/cloudflare-workers-ai-system-one-YKU742EC.js +4 -0
- package/dist/chunks/context-CI2FKEQE.js +4 -0
- package/dist/chunks/cost-CZRRSIUF.js +5 -0
- package/dist/chunks/dist-QCNQN6DY.js +4 -0
- package/dist/chunks/easter-egg-3d-XR5S2O3T.js +4 -0
- package/dist/chunks/{event-streams-3JSFPOTZ.js → event-streams-AVE4MSS6.js} +1 -1
- package/dist/chunks/{execution-repo-ZLJTBWFC.js → execution-repo-5TLV2NM4.js} +1 -1
- package/dist/chunks/{executions-6ARGR3IO.js → executions-I3UUIGSL.js} +1 -1
- package/dist/chunks/file-Y5G56IUT.js +4 -0
- package/dist/chunks/github-copilot-BRU2SRRZ.js +4 -0
- package/dist/chunks/google-generative-ai-ZF5QEUZV.js +4 -0
- package/dist/chunks/google-vertex-4PJZZI3Y.js +4 -0
- package/dist/chunks/init-A6GY656J.js +4 -0
- package/dist/chunks/{install-cli-4IZCSDFZ.js → install-cli-FALWKQYO.js} +1 -1
- package/dist/chunks/{interaction-ask-G5T3H3CG.js → interaction-ask-O5HGF6CH.js} +1 -1
- package/dist/chunks/{interaction-plan-E5V42MUP.js → interaction-plan-JTVDN3BC.js} +1 -1
- package/dist/chunks/kimi-coding-ZCIBMDZ6.js +4 -0
- package/dist/chunks/{llama-cpp-classify-OTXZWCMW.js → llama-cpp-classify-NRUXAIGQ.js} +3 -3
- package/dist/chunks/local-client-stop-RS4AHNF4.js +4 -0
- package/dist/chunks/{memory-cli-PYOILNN5.js → memory-cli-DIT4DQF3.js} +1 -1
- package/dist/chunks/meta-JQH66YU7.js +4 -0
- package/dist/chunks/mistral-conversations-CXHOECUV.js +7 -0
- package/dist/chunks/model-resolver-GIBPYRKP.js +4 -0
- package/dist/chunks/monitor-Z2HKNY5E.js +4 -0
- package/dist/chunks/{node-PTK2HCDV.js → node-DAO3SX7O.js} +1 -1
- package/dist/chunks/{openai-codex-2REL6UQU.js → openai-codex-JULCKICT.js} +1 -1
- package/dist/chunks/openai-codex-responses-U6DGMGDK.js +12 -0
- package/dist/chunks/openai-completions-PP4XLLOM.js +9 -0
- package/dist/chunks/{openai-decisions-2N6ZRPZC.js → openai-decisions-JU6QQKEM.js} +1 -1
- package/dist/chunks/openai-responses-2SG757TL.js +6 -0
- package/dist/chunks/openrouter-images-32M7YZWC.js +4 -0
- package/dist/chunks/pi-messages-VSINMXN4.js +10 -0
- package/dist/chunks/radius-THYKWV4E.js +4 -0
- package/dist/chunks/remote-ops-2WBEFQ3E.js +14 -0
- package/dist/chunks/runner-5MKMRTIN.js +4 -0
- package/dist/chunks/runtime-DST3H5JP.js +4 -0
- package/dist/chunks/schedule-cli-V7Y2BBVY.js +4 -0
- package/dist/chunks/slack-R7SEJYMY.js +4 -0
- package/dist/chunks/start-ui-http-7K5JOLPU.js +43 -0
- package/dist/chunks/subagent-Z5IQ4L54.js +4 -0
- package/dist/chunks/{time-KEHDQT6K.js → time-P6PE52WL.js} +1 -1
- package/dist/chunks/tool-shims-YCXZWTST.js +4 -0
- package/dist/chunks/typesafe-system-one-M2DABJSZ.js +4 -0
- package/dist/chunks/ui-board-HQIE4RZG.js +5 -0
- package/dist/chunks/ui-decision-YBZDS4YW.js +4 -0
- package/dist/chunks/{ui-file-GVH53O3X.js → ui-file-SRD4ILBS.js} +1 -1
- package/dist/chunks/ui-view-Z25MTZT7.js +4 -0
- package/dist/chunks/virtual-modules-H4DXPJZB.js +4 -0
- package/dist/chunks/waitpoint-M6JZBSLT.js +5 -0
- package/dist/chunks/workers-SQ2R32TK.js +4 -0
- package/dist/client-bundle/client.mjs +273 -93
- package/dist/client-bundle/manifest.json +2 -2
- package/dist/core/pi-sdk.js +1 -1
- package/dist/domain/auth/cc-auth-cli.js +1 -1
- package/dist/domain/mcp/bundled-server.js +1 -1
- package/dist/domain/mcp/feishu/client.js +4 -0
- package/dist/entry/app.js +151 -559
- package/dist/entry/browser-cli.js +10 -10
- package/dist/entry/cli.js +1 -1
- package/dist/entry/cortex-cli.js +1 -1
- package/dist/entry/daemon.js +4 -4
- package/dist/entry/hook-cli.js +2 -2
- package/dist/entry/production-app-bootstrap.js +1 -1
- package/dist/entry/production-evidence-export-cli.js +1 -1
- package/dist/entry/signal-cli.js +2 -2
- package/dist/tui/index.js +41 -41
- package/package.json +3 -3
- package/vendor/pi/CHANGELOG.md +330 -0
- package/vendor/pi/dist/codemode-worker.js +2 -0
- package/vendor/pi/dist/core/export-html/ansi-to-html.js +57 -20
- package/vendor/pi/dist/core/export-html/template.css +9 -0
- package/vendor/pi/dist/core/export-html/template.js +166 -46
- package/vendor/pi/dist/core/export-html/tool-renderer.js +5 -3
- package/vendor/pi/dist/core/extensions/loader.js +1 -1
- package/vendor/pi/dist/extensions/codemode/execute.js +15 -13
- package/vendor/pi/dist/modes/interactive/theme/theme.js +36 -23
- package/vendor/pi/dist/utils/image-resize-worker.js +1 -1
- package/vendor/pi/dist/utils/image-resize.js +1 -1
- package/vendor/pi/docs/cli.md +35 -12
- package/vendor/pi/docs/custom-provider.md +2 -0
- package/vendor/pi/docs/environment-variables.md +2 -0
- package/vendor/pi/docs/extensions.md +3192 -225
- package/vendor/pi/docs/keybindings.md +2 -2
- package/vendor/pi/docs/llama-cpp.md +27 -19
- package/vendor/pi/docs/mcp.md +6 -4
- package/vendor/pi/docs/message-types.md +1 -1
- package/vendor/pi/docs/models-configuration.md +9 -3
- package/vendor/pi/docs/models.md +2 -1
- package/vendor/pi/docs/nvidia-rtx-llama-cpp.md +5 -5
- package/vendor/pi/docs/packages.md +24 -0
- package/vendor/pi/docs/prompt-templates.md +1 -1
- package/vendor/pi/docs/providers.md +4 -2
- package/vendor/pi/docs/quickstart.md +7 -3
- package/vendor/pi/docs/rpc-commands.md +1 -1
- package/vendor/pi/docs/rpc.md +4 -2
- package/vendor/pi/docs/sessions.md +17 -3
- package/vendor/pi/docs/settings.md +6 -5
- package/vendor/pi/docs/slash-commands.md +3 -2
- package/vendor/pi/docs/terminal-setup.md +3 -1
- package/vendor/pi/docs/tmux.md +6 -0
- package/vendor/pi/docs/tui.md +4 -0
- package/vendor/pi/docs/windows.md +27 -0
- package/vendor/pi/examples/extensions/README.md +2 -1
- package/vendor/pi/examples/extensions/custom-provider-anthropic/index.ts +27 -31
- package/vendor/pi/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/vendor/pi/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/vendor/pi/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/vendor/pi/examples/extensions/debug-provider.ts +2 -2
- package/vendor/pi/examples/extensions/gondolin/index.ts +4 -7
- package/vendor/pi/examples/extensions/gondolin/package-lock.json +19 -29
- package/vendor/pi/examples/extensions/gondolin/package.json +2 -2
- package/vendor/pi/examples/extensions/plan-mode/index.ts +23 -13
- package/vendor/pi/examples/extensions/plan-mode/utils.ts +42 -16
- package/vendor/pi/examples/extensions/preset.ts +2 -0
- package/vendor/pi/examples/extensions/reload-runtime.ts +17 -5
- package/vendor/pi/examples/extensions/subagent/README.md +14 -11
- package/vendor/pi/examples/extensions/subagent/index.ts +392 -171
- package/vendor/pi/examples/extensions/todo.ts +7 -0
- package/vendor/pi/examples/extensions/tools.ts +2 -0
- package/vendor/pi/examples/extensions/with-deps/package-lock.json +2 -2
- package/vendor/pi/examples/extensions/with-deps/package.json +1 -1
- package/vendor/pi/examples/tsconfig.json +208 -0
- package/vendor/pi/package.json +15 -16
- package/vendor/pi/schemas/models.schema.json +66 -37
- package/vendor/pi/schemas/settings.schema.json +18 -1
- package/vendor/pi-ai/bedrock.js +1 -1
- package/vendor/pi-ai/oauth-load.js +1 -1
- package/web/dist/assets/{board-math-css-BPXakv_3.js → board-math-css-DKX6FcUS.js} +1 -1
- package/web/dist/assets/index-D11wi0uG.js +540 -0
- package/web/dist/assets/index-JedYumhY.css +1 -0
- package/web/dist/assets/{index-WCm6wwmM.js → index-jl30Gy8P.js} +1 -1
- package/web/dist/assets/pdf-worker-DdZgk2mV.js +57 -0
- package/web/dist/assets/pdf.worker.min-Bz_KHX45.js +55 -0
- package/web/dist/index.html +2 -2
- package/web/dist/theme.css +22 -0
- package/dist/chunks/anthropic-messages-M3SMXACA.js +0 -8
- package/dist/chunks/api-GM53PHIL-GFHEXXE6.js +0 -4
- package/dist/chunks/azure-openai-responses-76YWXHSB.js +0 -4
- package/dist/chunks/bedrock-converse-stream-5UPX4NTQ.js +0 -58
- package/dist/chunks/child-runner-3GHOWGZP.js +0 -4
- package/dist/chunks/chunk-2ZNLUY2U.js +0 -128
- package/dist/chunks/chunk-3F6WW7HR.js +0 -13
- package/dist/chunks/chunk-3OKHUVEM.js +0 -7
- package/dist/chunks/chunk-3YHOCPQU.js +0 -10
- package/dist/chunks/chunk-4EX2JJWB.js +0 -4
- package/dist/chunks/chunk-4LLH5OWM.js +0 -10
- package/dist/chunks/chunk-52T37Y47.js +0 -8
- package/dist/chunks/chunk-7MU2AKNM.js +0 -4
- package/dist/chunks/chunk-AAA3UBIS.js +0 -4
- package/dist/chunks/chunk-ASYQHJVQ.js +0 -9
- package/dist/chunks/chunk-BKHDWCRT.js +0 -79
- package/dist/chunks/chunk-CQLH4UVX.js +0 -4
- package/dist/chunks/chunk-CVC66CFV.js +0 -33
- package/dist/chunks/chunk-D6UA4BZC.js +0 -19
- package/dist/chunks/chunk-DGMNI4AO.js +0 -4
- package/dist/chunks/chunk-DHSA5ACV.js +0 -125
- package/dist/chunks/chunk-DPQPXBTP.js +0 -68
- package/dist/chunks/chunk-DXBSQXJL.js +0 -18
- package/dist/chunks/chunk-E7ZMYIY6.js +0 -30
- package/dist/chunks/chunk-EQITBTJC.js +0 -10
- package/dist/chunks/chunk-EXJA5RIX.js +0 -357
- package/dist/chunks/chunk-FF7UELTU.js +0 -4
- package/dist/chunks/chunk-FH74NME3.js +0 -115
- package/dist/chunks/chunk-FOQ7VLIL.js +0 -17
- package/dist/chunks/chunk-FX6MOGLR.js +0 -11
- package/dist/chunks/chunk-G2V65UBA.js +0 -4
- package/dist/chunks/chunk-HGPBHTVD.js +0 -6
- package/dist/chunks/chunk-J5DVLUKY.js +0 -6
- package/dist/chunks/chunk-JW2HFMTF.js +0 -4
- package/dist/chunks/chunk-KDYEGGMW.js +0 -4
- package/dist/chunks/chunk-KIGMAATV.js +0 -23
- package/dist/chunks/chunk-KIU5FAPY.js +0 -5
- package/dist/chunks/chunk-KIWMQPH7.js +0 -739
- package/dist/chunks/chunk-L6VCIGWS.js +0 -11
- package/dist/chunks/chunk-LACGULCN.js +0 -10
- package/dist/chunks/chunk-LMSQZ6TQ.js +0 -4
- package/dist/chunks/chunk-MEPASGPP.js +0 -6
- package/dist/chunks/chunk-MFAEUHMV.js +0 -28
- package/dist/chunks/chunk-NAA7GF6Q.js +0 -5
- package/dist/chunks/chunk-NKDMKRSB.js +0 -68
- package/dist/chunks/chunk-NKXV32S6.js +0 -4
- package/dist/chunks/chunk-NVX5IPRN.js +0 -4
- package/dist/chunks/chunk-O3JW2F7D.js +0 -8
- package/dist/chunks/chunk-OE4KH3NJ.js +0 -4
- package/dist/chunks/chunk-OISO5JXB.js +0 -4
- package/dist/chunks/chunk-OPYXNSMY.js +0 -4
- package/dist/chunks/chunk-OSEIQ7SS.js +0 -4
- package/dist/chunks/chunk-P52RMIYX.js +0 -6
- package/dist/chunks/chunk-PBJ5MPPX.js +0 -60
- package/dist/chunks/chunk-PZMGBKUR.js +0 -13
- package/dist/chunks/chunk-PZMXHA6X.js +0 -9
- package/dist/chunks/chunk-Q7CE3UIE.js +0 -133
- package/dist/chunks/chunk-QBKCAIJG.js +0 -4
- package/dist/chunks/chunk-QEOFEETJ.js +0 -4
- package/dist/chunks/chunk-QUUEQRIT.js +0 -4
- package/dist/chunks/chunk-RA6HKFBV.js +0 -4
- package/dist/chunks/chunk-REPYBMQS.js +0 -4
- package/dist/chunks/chunk-SKHLZ6XY.js +0 -9
- package/dist/chunks/chunk-TAWLERZA.js +0 -4
- package/dist/chunks/chunk-TWAEABGG.js +0 -52
- package/dist/chunks/chunk-TZFLHVOQ.js +0 -7
- package/dist/chunks/chunk-UD3NMUHR.js +0 -12
- package/dist/chunks/chunk-UNVEZI57.js +0 -4
- package/dist/chunks/chunk-VQUPKMDR.js +0 -4
- package/dist/chunks/chunk-W25TB3PU.js +0 -4
- package/dist/chunks/chunk-W5LGYSPZ.js +0 -4
- package/dist/chunks/chunk-WEZWKMYU.js +0 -4
- package/dist/chunks/chunk-XAJLZR7C.js +0 -28
- package/dist/chunks/chunk-XH6FMP3N.js +0 -71
- package/dist/chunks/chunk-XSRZHN63.js +0 -4
- package/dist/chunks/chunk-Y3GFB5XM.js +0 -8
- package/dist/chunks/chunk-YG7OEPR2.js +0 -6
- package/dist/chunks/chunk-YHIWOGVL.js +0 -4
- package/dist/chunks/chunk-YKKEI5GI.js +0 -4
- package/dist/chunks/chunk-YZSHTWNM.js +0 -92
- package/dist/chunks/chunk-Z4H3VDHI.js +0 -4
- package/dist/chunks/cli-5DBTRMHU.js +0 -53
- package/dist/chunks/client-XOGYH5UR.js +0 -4
- package/dist/chunks/cloudflare-workers-ai-system-one-32JCFHI3.js +0 -4
- package/dist/chunks/config-DJSQI77S-335IXHSM.js +0 -4
- package/dist/chunks/context-VCQH5OB6.js +0 -4
- package/dist/chunks/cost-PGGFI7QJ.js +0 -5
- package/dist/chunks/dist-PUKMZ7GW.js +0 -4
- package/dist/chunks/easter-egg-3d-MO4MOEVF.js +0 -4
- package/dist/chunks/es5-VNTQPCKX.js +0 -4
- package/dist/chunks/file-7BN7RCAY.js +0 -4
- package/dist/chunks/gateway-UCRPMR75.js +0 -36
- package/dist/chunks/github-copilot-HAI2DA62.js +0 -4
- package/dist/chunks/google-generative-ai-2VXWLHWI.js +0 -4
- package/dist/chunks/google-vertex-UA36QP2U.js +0 -4
- package/dist/chunks/init-HA7FAQ73.js +0 -4
- package/dist/chunks/kimi-coding-HMJRKCPA.js +0 -4
- package/dist/chunks/local-client-stop-SQRU7ZZM.js +0 -4
- package/dist/chunks/meta-KY3LNFV2.js +0 -4
- package/dist/chunks/mistral-conversations-34F66L3O.js +0 -7
- package/dist/chunks/model-resolver-N3DTAQ2S.js +0 -4
- package/dist/chunks/openai-codex-responses-ZBVHREB3.js +0 -12
- package/dist/chunks/openai-completions-VVIB26SH.js +0 -9
- package/dist/chunks/openai-responses-735XA2ZX.js +0 -6
- package/dist/chunks/openrouter-images-3IKETHAC.js +0 -4
- package/dist/chunks/pi-messages-I3E4ZFHA.js +0 -10
- package/dist/chunks/radius-HXRZVBDB.js +0 -4
- package/dist/chunks/remote-ops-BALZYKH6.js +0 -14
- package/dist/chunks/runner-PLVZDGHB.js +0 -4
- package/dist/chunks/runtime-6YLTA2ZD.js +0 -4
- package/dist/chunks/schedule-cli-OLASBBYJ.js +0 -4
- package/dist/chunks/slack-WAGSPZUX.js +0 -4
- package/dist/chunks/start-ui-http-QALT7C3P.js +0 -43
- package/dist/chunks/subagent-E3UC7ZHC.js +0 -4
- package/dist/chunks/tool-shims-Q6P6UXVC.js +0 -4
- package/dist/chunks/typesafe-system-one-6ULACYD4.js +0 -4
- package/dist/chunks/ui-board-4GYW6KKW.js +0 -5
- package/dist/chunks/ui-decision-U2FXSEC2.js +0 -4
- package/dist/chunks/ui-view-O7PLANT7.js +0 -4
- package/dist/chunks/virtual-modules-IDC5YKZJ.js +0 -4
- package/dist/chunks/waitpoint-2FGQBIAC.js +0 -5
- package/dist/chunks/workers-XN4PSTH6.js +0 -4
- package/vendor/aistatus/gateway-cli.js +0 -21
- package/vendor/pi/examples/extensions/sandbox/index.ts +0 -321
- package/vendor/pi/examples/extensions/sandbox/package-lock.json +0 -92
- package/vendor/pi/examples/extensions/sandbox/package.json +0 -19
- package/web/dist/assets/index-BHZpFXhc.js +0 -525
- package/web/dist/assets/index-DqWMdMkh.css +0 -1
- package/web/dist/assets/pdf-worker-Hp15W1QJ.js +0 -57
- package/web/dist/assets/pdf.worker.min-DnhTvCwe.js +0 -55
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { createRequire as __cortexCreateRequire } from 'node:module';
|
|
2
|
-
const require = __cortexCreateRequire(import.meta.url);
|
|
3
|
-
const __cortexPackageRoot = new URL("../../", import.meta.url);
|
|
4
|
-
import{a as B,c as v}from"./chunk-Y6ZEVVL5.js";import{a as _,b as $,e as H}from"./chunk-LMSQZ6TQ.js";import{a as K}from"./chunk-BGVHA2D4.js";import{a as O}from"./chunk-OE4KH3NJ.js";import{d as F}from"./chunk-MEPASGPP.js";import{e as j}from"./chunk-NAA7GF6Q.js";import{d as L,v as W,y as X}from"./chunk-J5DVLUKY.js";function S(){return{input:0,output:0,cacheRead:0,cacheWrite:0,cost:0,contextTokens:0,turns:0}}function g(t){return typeof t=="number"&&Number.isFinite(t)?t:0}function V(t,e){t.input+=e.input,t.output+=e.output,t.cacheRead+=e.cacheRead,t.cacheWrite+=e.cacheWrite,t.cost+=e.cost,t.contextTokens=e.contextTokens||t.contextTokens,t.turns+=e.turns}function lt(t,e){t.input+=e.input,t.output+=e.output,t.cacheRead+=e.cacheRead,t.cacheWrite+=e.cacheWrite,t.cost+=e.cost,t.contextTokens+=e.contextTokens,t.turns+=e.turns}function le(t){let e=S();for(let n of t)lt(e,n.usage);return e}import*as b from"node:path";function dt(t,e,n){return t.hasTrustRequiringProjectResources(e)?new t.ProjectTrustStore(n).get(e)===!0:!0}function pt(t,e,n){return n===null||!e||e<=n?t:e-n+Math.min(t,Math.floor(n/2))}function ft(t){let e=t.getCompactionReserveTokens.bind(t);t.getCompactionReserveTokens=n=>pt(e(n),n?.contextWindow,F().maxContextTokens)}function mt(t){if(process.platform!=="win32")return;let e=process.env.CORTEX_GIT_BASH_PATH;if(!e)return;let n=t.getShellPath.bind(t);t.getShellPath=()=>n()??e}function G(t,e,n){let o=t.SettingsManager.create(e,n,{projectTrusted:dt(t,e,n)});return o.getCacheWarmingMode=()=>"off",ft(o),mt(o),o}var A=j("pi-subagent");function gt(t,e,n){if(!e.model)return{model:void 0,thinkingLevel:void 0};let o=e.provider?`${e.provider}/${e.model}`:e.model,r=t.resolveCliModel({cliModel:e.thinking?`${o}:${e.thinking}`:o,modelRuntime:n});if(r.error)throw new Error(r.error);return r.warning&&A.warn(`PI subagent model resolution: ${r.warning}`),{model:r.model,thinkingLevel:r.thinkingLevel}}async function _t(t,e){let n=G(t,e.cwd,e.agentDir),o=await t.ModelRuntime.create({authPath:b.join(e.agentDir,"auth.json"),modelsPath:b.join(e.agentDir,"models.json"),allowModelNetwork:!1});return t.createAgentSessionServices({cwd:e.cwd,agentDir:e.agentDir,settingsManager:n,modelRuntime:o,resourceLoaderOptions:{noExtensions:!0,extensionFactories:e.extensions,appendSystemPrompt:e.appendSystemPrompt,noContextFiles:e.noContextFiles===!0}})}async function z(t){let e=await K(),n=await _t(e,t);for(let i of n.diagnostics)i.type==="error"&&A.warn(`PI subagent session: ${i.message}`);let{model:o,thinkingLevel:r}=gt(e,t,n.modelRuntime),s=await e.createAgentSessionFromServices({services:n,sessionManager:e.SessionManager.inMemory(t.cwd),model:o,thinkingLevel:r,tools:t.tools});return await s.session.bindExtensions({mode:"print",onError:i=>A.warn(`PI subagent extension ${i.extensionPath} failed on ${i.event}: ${String(i.error)}`)}),{session:s.session,dispose:()=>s.session.dispose()}}function E(t){if(!Array.isArray(t))return[];let e=[];for(let n of t){if(!n||typeof n!="object"||n.type!=="image")continue;let o=n,r=o.source;r&&r.type==="base64"&&typeof r.data=="string"&&r.data?e.push({mimeType:typeof r.media_type=="string"?r.media_type:"",data:r.data}):typeof o.data=="string"&&o.data&&e.push({mimeType:typeof o.mimeType=="string"?o.mimeType:"",data:o.data})}return e}function J(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.mimeType=="string"&&typeof e.data=="string"&&e.data.length>0}function Te(t,e,n=!1){if(!e||!t)return;let o=r=>{try{e(r)}catch{}};return{forChild(r,s){let i=`${t}#${r}`,c=n&&r>0;return(a,m)=>{let p=ht(i,s,m,a);for(let f=0;f<p.length;f++)o(c&&f===0?{...p[f],prompt:s.prompt}:p[f]);p.length&&(c=!1)}}}}function yt(t,e,n){return{ref:t,type:e.subagent_type,description:e.description,model:n.model??null,backend:"pi",...e.clean?{clean:!0}:{}}}function ht(t,e,n,o){let r=yt(t,e,n),s=o.type;if(s==="tool_execution_start"){let m=o.toolCallId,p=o.toolName;return typeof m!="string"||typeof p!="string"?[]:[{...r,kind:"tool_use",toolUseId:`${t}:${m}`,name:p,input:o.args??{}}]}if(s==="tool_execution_end")return Et(r,o);let i=P(o);if(!i||i.role!=="assistant")return[];let c=typeof i.model=="string"?i.model:r.model,a=N(i);return a?[{...r,model:c,kind:"assistant_text",text:a}]:[]}function Et(t,e){let n=e.toolCallId;if(typeof n!="string")return[];let o=E(e.result?.content);return[{...t,kind:"tool_result",toolUseId:`${t.ref}:${n}`,ok:e.isError!==!0,content:Tt(e.result),...o.length?{images:o}:{}}]}function P(t){return t.type!=="message_end"||!t.message||typeof t.message!="object"?null:t.message}function N(t){let e=t.content;return typeof e=="string"?e:Array.isArray(e)?e.filter(n=>!!n&&typeof n=="object"&&n.type==="text"&&typeof n.text=="string").map(n=>n.text).join(`
|
|
5
|
-
`):""}function Tt(t){if(typeof t=="string")return t;if(!t||typeof t!="object")return"";let e=t.content;return typeof e=="string"?e:Array.isArray(e)?e.filter(n=>n&&typeof n=="object"&&n.type==="text").map(n=>String(n.text??"")).join(""):""}function Ie(t,e,n,o){return{ref:t,type:e.subagent_type,description:e.description,model:null,backend:n,kind:"end",status:o}}function Ct(t){let e=t.name;return t.backend==="claude"?e:_("pi",e)??e}function Y(t){if(t.kind==="end")return t.status?[{type:"subagent_end",parentToolUseId:t.ref,status:t.status}]:[];let e={parentToolUseId:t.ref,type:t.type||null,description:t.description||null,...t.prompt?{prompt:t.prompt}:{},model:t.model,...t.clean?{clean:!0}:{}};return t.kind==="tool_use"?[{type:"tool_use",toolUseId:t.toolUseId,name:Ct(t),input:t.input??{},subagent:e}]:t.kind==="tool_result"?[{type:"tool_result",toolUseId:t.toolUseId,ok:t.ok!==!1,content:t.content??"",subagent:e,...t.images?.length?{images:t.images}:{}}]:[{type:"assistant_text",text:t.text,subagent:e}]}var Rt=new Set(["pending","in_progress","completed"]);function Q(t){return typeof t=="string"?t:""}function It(t){return typeof t=="string"&&Rt.has(t)?t:"pending"}function kt(t){if(!t||typeof t!="object")return null;let e=t,n=Q(e.content).trim(),o=Q(e.activeForm).trim()||n;return!n&&!o?null:{content:n||o,activeForm:o,status:It(e.status)}}function xt(t,e=Date.now()){if(!t||typeof t!="object")return null;let n=t.todos;if(!Array.isArray(n))return null;let o=[];for(let i of n){let c=kt(i);c&&o.push(c)}let r=0,s=null;for(let i of o)i.status==="completed"?r+=1:i.status==="in_progress"&&s===null&&(s=i.activeForm);return{items:o,total:o.length,completed:r,activeLabel:s,updatedAt:e}}function Z(t,e,n,o=Date.now()){return _(t,e)!=="todo_write"?null:xt(n,o)}function Se(t,e=40){if(!t||t.total===0)return"";let n=`${t.completed}/${t.total}`,o=t.activeLabel?.trim();if(!o)return n;let r=o.length>e?`${o.slice(0,e-1).trimEnd()}\u2026`:o;return`${n} \xB7 ${r}`}function Ue(){return{turnProgressCount:0,pendingCompletion:U()}}function Me(t,e){let n=t;if(typeof n.type!="string")return[];let o=n.type;if(o==="message_update")return St(n);if(o==="tool_execution_start")return bt(n);if(o==="tool_execution_end")return At(n);if(o==="agent_end")return Nt(n,e);if(o==="agent_settled")return wt(e);if(o==="compaction_start")return[{type:"context_compacted",trigger:typeof n.reason=="string"&&n.reason.length>0?n.reason:"auto"}];if(o==="message_end")return e.turnProgressCount++,[{type:"turn_progress",numTurns:e.turnProgressCount}];if(o==="cortex_subagent_event"){let r=Bt(n.notice);return r?Y(r):[]}if(o==="cortex_subagent_usage")return Ft(n.report,e);if(o==="extension_error"){let r=n.error;return[{type:"error",message:typeof r=="string"&&r.length>0?r:"extension error",fatal:!1}]}return o==="extension_ui_request"?vt(n):[]}function R(t){return t!==null&&typeof t=="object"?t:void 0}function tt(t){let e=R(t),n=e?.id??e?.responseId;return typeof n=="string"?n:void 0}function q(t,e){let n=R(t)?.content;return!Array.isArray(n)||typeof e!="number"?!1:R(n[e])?.redacted===!0}function Ot(t,e){let n=e.redacted===!0||q(t.message,e.contentIndex)||q(e.partial,e.contentIndex),o=e.type==="thinking_end"?e.content:e.delta;if(n||typeof o!="string"||o.length===0)return[];let r=tt(t.message),s=r!==void 0&&typeof e.contentIndex=="number"?`${r}:t${e.contentIndex}`:void 0;return e.type==="thinking_end"?[{type:"assistant_thinking",text:o,...s!==void 0?{blockId:s}:{}}]:s!==void 0?[{type:"assistant_thinking_delta",text:o,blockId:s}]:[]}function St(t){let e=R(t.assistantMessageEvent);if(!e)return[];if(e.type==="thinking_delta"||e.type==="thinking_end")return Ot(t,e);if(e.type!=="text_delta"||typeof e.delta!="string"||e.delta.length===0)return[];let n=tt(t.message);return[{type:"assistant_text",text:e.delta,...n!==void 0?{blockId:n}:{}}]}function bt(t){let e=t.toolCallId,n=t.toolName,o=t.args??{};if(typeof e!="string"||typeof n!="string")return[];let r=_("pi",n)??n,s=[{type:"tool_use",toolUseId:e,name:r,input:o}],i=Z("pi",n,o);return i&&s.push({type:"todo_update",toolUseId:e,snapshot:i}),s}function At(t){let e=t.toolCallId;if(typeof e!="string")return[];let n=t.isError===!0,o=t.result,r="",s=[];if(o&&typeof o=="object"){let c=o.content;Array.isArray(c)?(r=c.filter(a=>l(a).type==="text").map(a=>String(l(a).text??"")).join(""),s=E(c)):typeof c=="string"&&(r=c)}return[{type:"tool_result",toolUseId:e,ok:!n,content:r,...s.length?{images:s}:{}}]}function et(t,e){if(t.type!=="tool_execution_end"||!e?.input||e.input.includes("image"))return t;let n=l(t.result),o=n.content;return!Array.isArray(o)||!o.some(r=>l(r).type==="image")?t:{...t,result:{...n,content:o.filter(r=>l(r).type!=="image")}}}function U(){return{numTurns:0,totalCostUsd:null,error:null}}function Pt(){return{...U(),provider:"",model:"",tokensIn:0,tokensOut:0,cacheReadTokens:0,cacheWriteTokens:0,inputReported:!0,outputReported:!0,cacheReadReported:!0,cacheWriteReported:!0}}function Nt(t,e){let n=Array.isArray(t.messages)?t.messages:[],o=Ut(n);if(jt(e,o),o.provider==="")return[];let r=C(o.tokensIn,o.inputReported),s=C(o.tokensOut,o.outputReported),i=C(o.cacheReadTokens,o.cacheReadReported),c=C(o.cacheWriteTokens,o.cacheWriteReported),a=Xt(r,i,c);return[{type:"cost_record",provider:o.provider,model:o.model,tokens_in:o.tokensIn,tokens_out:o.tokensOut,prompt_tokens:a,cached_tokens:i,input_tokens:r,output_tokens:s,cache_read_tokens:i,cache_creation_tokens:c,provider_requests:o.numTurns>0?o.numTurns:null,cost_usd:o.totalCostUsd}]}function wt(t){let e=t.pendingCompletion;t.pendingCompletion=U();let n={type:"turn_complete",numTurns:e.numTurns,totalCostUsd:e.totalCostUsd};return e.error===null?[n]:[{...n,error:e.error}]}function Ut(t){let e=Pt();for(let n of t){let o=l(n);o.role==="assistant"&&(e.numTurns++,Mt(e,o),Dt(e,o),Wt(e,o))}return e}function Mt(t,e){let n=e.provider,o=e.model;t.provider===""&&typeof n=="string"&&n.length>0&&(t.provider=n),t.model===""&&typeof o=="string"&&o.length>0&&(t.model=o)}function Dt(t,e){if(t.error!==null||e.stopReason!=="error")return;let n=e.errorMessage;t.error=typeof n=="string"&&n.length>0?n:"PI agent reported an error during execution"}function Lt(t){return typeof t=="number"&&Number.isSafeInteger(t)&&t>=0}function T(t,e,n){return Lt(n)?[t+n,e]:[t,!1]}function Wt(t,e){let n=l(e.usage);[t.tokensIn,t.inputReported]=T(t.tokensIn,t.inputReported,n.input),[t.tokensOut,t.outputReported]=T(t.tokensOut,t.outputReported,n.output),[t.cacheReadTokens,t.cacheReadReported]=T(t.cacheReadTokens,t.cacheReadReported,n.cacheRead),[t.cacheWriteTokens,t.cacheWriteReported]=T(t.cacheWriteTokens,t.cacheWriteReported,n.cacheWrite);let o=l(n.cost).total;typeof o=="number"&&isFinite(o)&&(t.totalCostUsd=(t.totalCostUsd??0)+o)}function C(t,e){return e?t:null}function Xt(...t){return t.some(e=>e===null)?null:t.reduce((e,n)=>e+n,0)}function jt(t,e){let n=t.pendingCompletion;n.numTurns+=e.numTurns,n.totalCostUsd=nt(n.totalCostUsd,e.totalCostUsd),n.error=e.error}function nt(t,e){return t===null&&e===null?null:(t??0)+(e??0)}function Ft(t,e){let n=l(t),o=n.provider;if(typeof o!="string"||o==="")return[];let r=l(n.usage),s=h(r.input),i=h(r.output),c=h(r.cacheRead),a=h(r.cacheWrite),m=h(r.turns),p=w(r.cost);e.pendingCompletion.totalCostUsd=nt(e.pendingCompletion.totalCostUsd,p);let f=n.model;return[{type:"cost_record",provider:o,model:typeof f=="string"?f:"",tokens_in:s,tokens_out:i,prompt_tokens:s+c+a,cached_tokens:c,input_tokens:s,output_tokens:i,cache_read_tokens:c,cache_creation_tokens:a,provider_requests:m>0?m:null,cost_usd:p}]}function $t(t){return t==="completed"||t==="failed"||t==="killed"}function Bt(t){if(!t||typeof t!="object"||Array.isArray(t))return null;let e=t,{ref:n,kind:o}=e;if(typeof n!="string"||!n||o!=="tool_use"&&o!=="tool_result"&&o!=="assistant_text"&&o!=="end")return null;let r={ref:n,kind:o,type:typeof e.type=="string"?e.type:"",description:typeof e.description=="string"?e.description:"",...typeof e.prompt=="string"?{prompt:e.prompt}:{},model:typeof e.model=="string"?e.model:null};if(o==="tool_use")return typeof e.name!="string"||typeof e.toolUseId!="string"?null:(r.name=e.name,r.toolUseId=e.toolUseId,r.input=e.input??{},r);if(o==="tool_result"){if(typeof e.toolUseId!="string")return null;r.toolUseId=e.toolUseId,r.ok=e.ok!==!1,r.content=typeof e.content=="string"?e.content:"";let s=Array.isArray(e.images)?e.images.filter(J):[];return s.length&&(r.images=s),r}return o==="end"?$t(e.status)?(r.status=e.status,r):null:typeof e.text!="string"||!e.text?null:(r.text=e.text,r)}function vt(t){let e=t.id,n=t.method;if(typeof e!="string"||typeof n!="string")return[];if(n!=="select"&&n!=="confirm"&&n!=="input"&&n!=="editor")return[];let o=t.title,r=typeof o=="string"&&o.length>0?o:`${n} request`,s;if(n==="select"){let i=t.options,c=Array.isArray(i)?i.map(String):void 0;s={question:r},c&&(s.options=c)}else if(n==="confirm"){let i=t.message,c=typeof i=="string"&&i.length>0?`: ${i}`:"";s={question:r+c,options:["Yes","No"]}}else n==="editor"?s={question:r,multi:!0}:s={question:r};return[{type:"ask_user_question",toolUseId:e,questions:[s]}]}function De(t,e=null){let n=l(l(t).contextUsage),o=n.contextWindow;if(typeof o!="number"||!Number.isFinite(o)||o<=0)return null;let r=w(n.tokens);if(e===null||o<=e){let i=w(n.percent);return{usedTokens:r,contextWindow:o,percent:i,accuracy:"estimate"}}let s=r===null?null:r/e*100;return{usedTokens:r,contextWindow:e,percent:s,accuracy:"estimate"}}function h(t){return typeof t=="number"&&Number.isFinite(t)&&t>0?Math.floor(t):0}function w(t){return typeof t=="number"&&Number.isFinite(t)&&t>=0?t:null}function l(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}function ot(t){return t??"direct"}var rt="CORTEX_PI_MCP_COMPOSITION",I="CORTEX_PI_INTERACTION_BRIDGE",k="CORTEX_PI_TEAM_LEAD",x="CORTEX_PI_TEAM_WORKER",st="CORTEX_PI_CLEAN_WORKSPACE",Kt=["SLACK_CHANNEL","FEISHU_CHANNEL","CORTEX_SESSION_ID","CORTEX_PROFILE","CORTEX_BACKEND","CORTEX_MODEL","CORTEX_PROVIDER","CORTEX_THINKING","CORTEX_MODE","CORTEX_PROJECT","CORTEX_SESSION_NAME","CORTEX_EXECUTION_ID","CORTEX_CALLBACK_SOURCE","CORTEX_SCHEDULE_TASK_ID","CORTEX_CONFIG_IMMUTABLE","CORTEX_PRODUCTION_AUTH_FILE","CORTEX_WEBHOOK_BENCHMARK_ONLY","CORTEX_PI_ALLOWED_TOOLS","CORTEX_PI_SUBAGENT",rt,I,k,x,st,O];function u(t,e,n){n!=null&&n!==""&&(t[e]=String(n))}function Ht(t,e){let n=e.context;u(t,"CORTEX_MODEL",n?.selection?.model),u(t,"CORTEX_PROVIDER",n?.selection?.provider),u(t,"CORTEX_THINKING",n?.selection?.thinking),u(t,"CORTEX_MODE",n?.selection?.mode),u(t,"CORTEX_SESSION_ID",n?.trackSessionId??e.sessionId),u(t,"CORTEX_CALLBACK_SOURCE",e.callbackSource),u(t,"CORTEX_SCHEDULE_TASK_ID",e.scheduleTaskId),u(t,"CORTEX_PROJECT",n?.project),u(t,"CORTEX_EXECUTION_ID",n?.executionId)}function Vt(t,e=process.env){let n={...e,...t.routeEnv??{}};for(let o of Kt)delete n[o];for(let o of t.unsetEnv??[])delete n[o];return n.PI_CODING_AGENT_DIR=t.piAgentDir,n.CORTEX_BACKEND="pi",t.channel&&(n.SLACK_CHANNEL=t.channel,n.FEISHU_CHANNEL=t.channel),u(n,"CORTEX_PI_ALLOWED_TOOLS",t.allowedTools),u(n,rt,t.mcpComposition),t.mcpToolAllowlist!==void 0&&t.mcpToolAllowlist!==null&&(n[O]=JSON.stringify(t.mcpToolAllowlist)),t.enableInteractionBridge===!0&&(n[I]="1"),t.enableTeamLead===!0&&(n[k]="1"),t.enableTeamWorker===!0&&(n[x]="1"),u(n,"CORTEX_PI_SUBAGENT",t.subagentMarker),u(n,st,t.cleanWorkspace),Ht(n,t),n}function Gt(t){return t.replace(/\[.*?\]$/,"")}function zt(t){return t?(Array.isArray(t)?t:[t]).filter(e=>e.length>0):[]}function Jt(t){let e=t.tools.canonical&&t.tools.canonical.length>0?t.tools.canonical.map(n=>$("claude",n)).filter(n=>!!n).join(","):void 0;return t.tools.rawClaude??e}function Yt(t){return t.env.sets?.CORTEX_PI_SUBAGENT==="1"?"1":void 0}function Qt(t,e){return e!=="direct"?[]:[...t.mcp.servers??[]]}function $e(t,e){let n=ot(t.mcp.composition),o=Yt(t),r=Vt({sessionId:t.resume.backendSessionId,channel:t.context.channel,callbackSource:t.context.callbackSource,scheduleTaskId:t.context.scheduleTaskId,routeEnv:t.env.sets,unsetEnv:t.env.unsets,context:t.env.context,piAgentDir:e.agentDir,allowedTools:Jt(t),mcpComposition:n,mcpToolAllowlist:t.mcp.allowlist,enableInteractionBridge:n==="direct"&&t.flags.isUserInitiated===!0&&o===void 0,enableTeamLead:n==="direct"&&t.flags.teamLead===!0&&o===void 0,enableTeamWorker:n==="direct"&&t.flags.teamWorker===!0&&o===void 0,subagentMarker:o,cleanWorkspace:t.flags.clean?e.cwd:null},t.env.pinned);return{sessionKey:t.engineKey,cwd:e.cwd,agentDir:e.agentDir,sessionDir:e.sessionDir,sessionPath:e.sessionPath,provider:t.model.provider??null,model:t.model.id?Gt(t.model.id):null,benchmarkMaxOutputTokens:t.model.benchmarkMaxOutputTokens,thinking:t.model.thinking??null,systemPrompt:t.prompt.system||null,appendSystemPrompt:zt(t.prompt.append),skillPaths:t.flags.disableSkills?[]:[...t.plugins.skillDirs??[],...t.plugins.dirs??[]],disableHooks:t.flags.disableHooks===!0,...t.flags.clean?{noContextFiles:!0}:{},reportsProviderQuota:!!t.route.gatewayBaseUrl,pluginMcpServers:Qt(t,n),env:r,streamDeltas:e.streamDeltas}}var Zt=new Set(["CORTEX_EXECUTION_ID"]);function Be(t){let{sessionPath:e,env:n,...o}=t,r=Object.entries(n).filter(([s])=>!Zt.has(s)).sort(([s],[i])=>s<i?-1:s>i?1:0);return JSON.stringify({...o,env:r})}import{existsSync as qt,mkdirSync as M,readFileSync as te,promises as y}from"node:fs";import*as ct from"node:os";import*as d from"node:path";var at="inputs",it="clean-workspace.md";function Ge(t){return t?.clean===!0&&t.workspaceDir?t.workspaceDir:null}function ze(t,e=W){M(e,{recursive:!0});for(let n=1;;n++){let o=d.join(e,n===1?t:`${t}-${n}`);if(ee(o))return M(d.join(o,at)),o}}function ee(t){try{return M(t),!0}catch(e){if(e.code==="EEXIST")return!1;throw e}}async function Je(t,e,n){let o=d.join(t,at);await y.mkdir(o,{recursive:!0});let r=B(n||d.basename(e)),s=d.join(o,r);if(await ne(e,s))return s;let{destPath:i}=await v(o,r);return await y.cp(e,i,{recursive:!0}),i}async function ne(t,e){let[n,o]=await Promise.all([y.stat(t).catch(()=>null),y.stat(e).catch(()=>null)]);if(!n?.isFile()||!o?.isFile()||n.size!==o.size)return!1;let[r,s]=await Promise.all([y.readFile(t),y.readFile(e)]);return r.equals(s)}function Ye(t,e){let n=t==="~"||t.startsWith("~/")?d.join(ct.homedir(),t.slice(1)):t;return d.resolve(e,n)}function ut(t){let e=d.join(X,it),n=qt(e)?e:d.join(L,"prompts",it);return te(n,"utf8").replaceAll("{{workspace}}",t).trim()}function oe(t,e){let n={...t,PI_CODING_AGENT_DIR:e,CORTEX_PI_SUBAGENT:"1"};return delete n[I],delete n[k],delete n[x],n}async function sn(t){let{task:e,role:n}=t,o=t.model??{},r=t.createSession??z,s=t.workspace??null,i=await r({cwd:s??t.cwd,agentDir:t.agentDir,provider:o.provider??null,model:o.model??null,thinking:o.thinking??null,tools:H(n,"pi"),appendSystemPrompt:[...n.systemPrompt?[n.systemPrompt]:[],...s?[ut(s)]:[]],...s?{noContextFiles:!0}:{},extensions:t.childExtensions(oe(t.parentEnv,t.agentDir),o.provider??null)});try{let c=await re(i,e,t.signal,t.forward);return c.model||(c.model=o.model),c}finally{i.dispose()}}async function re(t,e,n,o){if(n?.aborted)throw new Error("Subagent was aborted.");let r={output:"",usage:S()},s=t.session.subscribe(c=>{ie(r,et(c,t.session.model),o)}),i=()=>{t.session.abort().catch(()=>{})};n?.addEventListener("abort",i,{once:!0});try{await t.session.prompt(`Task: ${e.prompt}`)}finally{n?.removeEventListener("abort",i),s()}if(n?.aborted)throw new Error("Subagent was aborted.");return se(e,r)}function se(t,e){return{description:t.description,prompt:t.prompt,subagentType:t.subagent_type,output:e.output,usage:e.usage,model:e.model,provider:e.provider,backend:"pi",stopReason:e.stopReason,errorMessage:e.errorMessage}}function ie(t,e,n){if(n)try{n(e,t)}catch{}let o=P(e);o&&(ce(t,o),ue(t,o))}function ce(t,e){if(e.role!=="assistant")return;let n=e.usage,o=n?.cost;V(t.usage,{input:g(n?.input),output:g(n?.output),cacheRead:g(n?.cacheRead),cacheWrite:g(n?.cacheWrite),cost:g(o?.total),contextTokens:g(n?.totalTokens),turns:1})}function D(t,e){return typeof t=="string"?t:e}function ae(t,e){let n=typeof e.stopReason=="string"?e.stopReason:void 0;if(!n){t.errorMessage=D(e.errorMessage,t.errorMessage);return}t.stopReason=n,t.errorMessage=typeof e.errorMessage=="string"?e.errorMessage:void 0}function ue(t,e){e.role==="assistant"&&(t.output=N(e)||t.output,t.model=D(e.model,t.model),t.provider=D(e.provider,t.provider),ae(t,e))}export{xt as a,Z as b,Se as c,ot as d,E as e,Ie as f,Y as g,Ue as h,Me as i,et as j,De as k,rt as l,I as m,k as n,x as o,st as p,$e as q,Be as r,G as s,z as t,S as u,le as v,Te as w,ht as x,Ge as y,ze as z,Je as A,Ye as B,ut as C,oe as D,sn as E,se as F};
|