@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,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as __cortexCreateRequire } from 'node:module';
|
|
2
2
|
const require = __cortexCreateRequire(import.meta.url);
|
|
3
3
|
const __cortexPackageRoot = new URL("../../", import.meta.url);
|
|
4
|
-
import{A as w,i as k,o as O}from"./chunk-
|
|
4
|
+
import{A as w,i as k,o as O}from"./chunk-Y6DGVTKM.js";import{a as T,b,c as x,d as v}from"./chunk-5T7IX5KN.js";import{b as M}from"./chunk-VHX2GHBF.js";import{R as N}from"./chunk-C6YVF7EI.js";import{a as E,b as I,f as R,g as j}from"./chunk-52VCLZS5.js";import{a as g}from"./chunk-5M4PFLRW.js";import{e as A}from"./chunk-7W7VYUTK.js";import{c as y,d as a,e as P,j as l}from"./chunk-T54CZKNJ.js";import{createHash as V}from"node:crypto";import{chmodSync as D,mkdirSync as q,readFileSync as K,writeFileSync as F}from"fs";import*as s from"path";var Y=A("config-generator"),Q=s.join(l,"mcp-config.json"),X=s.join(l,"mcp-config-core.json"),Z=s.join(l,"mcp-config-empty.json"),ee=s.join(l,"mcp-config-interaction.json"),ne=s.join(l,"mcp-config-slack.json"),te=s.join(l,"mcp-config-feishu.json"),re=s.join(l,"mcp-config-web.json");function oe(e,t,n){return{command:"node",args:[s.join(t,e)],cwd:t,...n?{env:n}:{}}}function f(e,t){let n=oe("dist/domain/mcp/bundled-server.js",t);return{...n,args:[...n.args,x(e)]}}function ie(e){return JSON.parse(K(e,"utf8"))}function se(e){let t=e.env?.[T];if(t!==void 0)return v(t);let n=Array.isArray(e.args)?e.args:[],r=typeof n[0]=="string"?n[0].replaceAll("\\","/"):"";return s.basename(r)==="bundled-server.js"&&typeof n[1]=="string"?v(n[1]):null}function ce(e){let t={external:{},template:null};for(let n of e)for(let[r,o]of Object.entries(n.mcpServers)){if(se(o)===null){t.external[r]=o;continue}t.template??=o}return t}function ue(e,t,n){let{external:r,template:o}=ce(e);if(!o)return{mcpServers:r};if(r[b])throw new Error(`User MCP server name conflicts with reserved ${b}`);let c=Array.isArray(o.args)?[...o.args]:[];c[1]=x(n);let u={...o.env??{},...t?{[E]:t}:{}};return{mcpServers:{[b]:{...o,args:c,env:u},...r}}}function le(e,t,n,r,o){let c=V("sha256").update(JSON.stringify({configPaths:t,documents:n,encodedAllowlist:r,selectedBundles:o})).digest("hex").slice(0,16);return s.join(e,`mcp-composition-${c}.json`)}function ae(e,t){return j(e),e.filter(n=>t.has(n))}function Fe(e,t,n=s.join(l,"mcp-tool-gates"),r){if(t===void 0)return[...e];let o=e.map(ie),c=new Set(r.flatMap(J=>I[J]??[])),u=ae(R(t),c),C=JSON.stringify(u),W=ue(o,C,r);q(n,{recursive:!0,mode:448}),D(n,448);let h=le(n,e,o,C,r);return F(h,JSON.stringify(W,null,2),{mode:384}),D(h,384),[h]}function fe(e){return{mcpServers:{"cortex-core":f(["cortex-core","cortex-ext"],e)}}}function pe(e){return{mcpServers:{"cortex-core":f(["cortex-core"],e)}}}function de(){return{mcpServers:{}}}function me(e){return{mcpServers:{"cortex-interaction-bridge":f(["cortex-interaction-bridge"],e)}}}function be(e){return{mcpServers:{"cortex-slack":f(["cortex-slack"],e)}}}function he(e){return{mcpServers:{"cortex-feishu":f(["cortex-feishu"],e)}}}function ge(e){return{mcpServers:{"cortex-web":f(["cortex-web"],e)}}}function Be(){let e=[["full",Q,fe(a)],["core",X,pe(a)],["empty",Z,de()],["interaction",ee,me(a)],["Slack",ne,be(a)],["Feishu",te,he(a)],["Web",re,ge(a)]];for(let[t,n,r]of e)F(n,JSON.stringify(r,null,2)),Y.info(`Generated ${t} MCP config at ${n}`)}var xe=[[/(?:\blogin_required\b|please\s+run\s+\/login\b)/i,"login_required"],[/(?:\boauth_expired\b|oauth\s+(?:token|session)\s+(?:has\s+)?expired\b)/i,"oauth_expired"],[/(?:\bauthentication_error\b|\bauthentication\b|\binvalid[_ -]api[_ -]key\b|\binvalid\s+x-api-key\b)/i,"invalid_api_key"],[/(?:\bunauthorized\b|\b401\b)/i,"unauthorized"],[/\binvalid_grant\b/i,"invalid_grant"]],p=null,S=new Set;function B(e,t,n){return n?`${e}:${t}:${n}`:`${e}:${t}`}function $e(e){for(let[t,n]of xe)if(t.test(e))return n;return null}function Ge(e){p=e,S.clear()}function He(e){p&&(S.add(B(e.backend,e.provider,e.connection)),p.publish({type:"auth.required",...e}))}function Ue(e){!p||!S.delete(B(e.backend,e.provider,e.connection))||p.publish({type:"auth.recovered",...e})}function L(e){let t=w({request:e.selection,session:e.session?.selection,draft:O(e.channel??void 0)});if(t.ok===!1)throw new Error(`No runnable model selection (${t.reason}); set a default model first`);let n=e.session;if((n?.backendSessionId===void 0?n?.sessionId:n.backendSessionId)&&n?.backend&&t.selection.backend!==n.backend)throw new Error(`Cannot resume ${n.backend} session on ${t.selection.backend} backend`);return t}function ve(e={}){return L(e).effective}function Ye(e={}){return L(e).selection}function Qe(){return k()?ve():null}function Xe(e){if(e.backend==="claude")return M(e.connection??N(e))}import m from"node:path";import d from"node:fs";import i from"node:path";function tn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function $(e,t){let n=i.resolve(e),r=i.resolve(t);return r===n||r.startsWith(n+i.sep)}function _(e){try{return d.lstatSync(e),!0}catch{return!1}}function Se(e){let t=[],n=i.resolve(e);for(;!_(n);){let r=i.dirname(n);if(r===n)return null;t.unshift(i.basename(n)),n=r}return{base:n,tail:t}}function _e(e,t){return t.reduce((n,r)=>i.join(n,r),e)}function G(e){try{return d.realpathSync(e)}catch{return null}}function Ce(e){let t=Se(e),n=t?G(t.base):null;return n&&t?_e(n,t.tail):null}function ye(e,t){let n=i.relative(i.resolve(e),i.resolve(t));return n===""?[]:n===".."||n.startsWith(`..${i.sep}`)||i.isAbsolute(n)?null:n.split(i.sep).filter(Boolean)}function Pe(e,t,n){let r=i.join(t,n);if(!_(r))return r;let o=G(r);return o&&$(e,o)?o:null}function Ae(e,t){return $(e,t)?t:null}function Ee(e,t){let n=Ce(e),r=ye(e,t);if(!n||!r)return null;let o=n;for(let c of r)if(o=Pe(n,o,c),!o)return null;return Ae(n,o)}function rn(e,t){return Ee(e,i.resolve(e,t))}function on(e){try{return d.statSync(e).isFile()}catch{return!1}}function sn(e){try{return d.statSync(e).isDirectory()}catch{return!1}}function H(e){return _(e)?d.readdirSync(e,{withFileTypes:!0}).filter(n=>n.isDirectory()||n.isSymbolicLink()).map(n=>n.name).sort():[]}var z=m.join(y,"plugins");function Ie(){return g()?z:null}function Re(e=Ie()){return e?H(e):[]}function je(e){return m.posix.join("plugins",e)}function Te(e){return e.skills!==!1&&g()}function U(e,t){return m.isAbsolute(e)?m.resolve(e):m.resolve(t,e)}function pn(e,t={}){let n=t.dataDir??P,r=(e.pluginDirs??[]).map(u=>U(u,n));if(!Te(e))return e.pluginDirs?r:void 0;let o=new Set(e.disabledPlugins??[]),c=(t.builtinIds??Re(z)).filter(u=>!o.has(u)).map(u=>U(je(u),n));return[...new Set([...r,...c])]}export{Fe as a,fe as b,pe as c,de as d,me as e,Be as f,$e as g,Ge as h,He as i,Ue as j,ve as k,Ye as l,Qe as m,Xe as n,tn as o,$ as p,_ as q,G as r,Ee as s,rn as t,on as u,sn as v,H as w,Ie as x,Re as y,Te as z,pn as A};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __cortexCreateRequire } from 'node:module';
|
|
2
2
|
const require = __cortexCreateRequire(import.meta.url);
|
|
3
3
|
const __cortexPackageRoot = new URL("../../", import.meta.url);
|
|
4
|
-
import{a as d,e as p}from"./chunk-
|
|
4
|
+
import{a as d,e as p}from"./chunk-TRXLIL7V.js";import{b as E}from"./chunk-T54CZKNJ.js";import*as o from"node:fs";import*as r from"node:path";import{createHash as C}from"node:crypto";import*as g from"node:fs";import*as u from"node:path";import{createHash as L}from"node:crypto";var b=["client.mjs","cortex-run-watcher.mjs"];function v(n){let t=L("sha256");for(let e of b)t.update(g.readFileSync(u.join(n,e)));return t.digest("hex")}function A(n){let t=JSON.parse(g.readFileSync(u.join(n,"manifest.json"),"utf8"));if(!(typeof t?.version=="string"&&t.version.trim()&&typeof t.hash=="string"&&/^[a-f0-9]{64}$/.test(t.hash)&&typeof t.source=="string"&&/^(unknown|[a-f0-9]{40})$/.test(t.source)))throw new Error("Invalid package-local client manifest; reinstall the server package");return{version:t.version,hash:t.hash,source:t.source}}function x(n=E){let t=u.join(n,"dist","client-bundle"),e=A(t),i=L("sha256"),s=b.map(l=>{let S=g.readFileSync(u.join(t,l));if(!S.length)throw new Error(`Empty package-local client file: ${l}`);return i.update(S),{name:l,data:S.toString("base64")}});if(i.digest("hex")!==e.hash)throw new Error("Package-local client hash mismatch; reinstall the server package");return{...e,files:s}}var F=".local-install-stage",I=n=>C("sha256").update(n).digest("hex"),a=n=>r.join(n.DATA_DIR,"client"),h=n=>r.join(a(n),"local-install.json"),f=n=>r.join(n.CONFIG_DIR,"cortex-client.json");function j(n){return JSON.stringify({deviceName:n,serverHost:"127.0.0.1",serverPort:3002},null,2)+`
|
|
5
5
|
`}function c(n){if(o.lstatSync(n,{throwIfNoEntry:!1})?.isSymbolicLink())throw new Error(`Local client ownership cannot cover a symlink: ${n}`)}function m(n){c(a(n));let t=h(n);if(c(t),!o.existsSync(t))return null;let e;try{e=JSON.parse(o.readFileSync(t,"utf8"))}catch{throw new Error("Invalid local client ownership intent; inspect client/local-install.json")}if(!(e?.schema===1&&["pending","ready"].includes(e.state)&&typeof e.device=="string"&&!!e.device.trim()&&e.configHash===I(j(e.device))&&typeof e.bundleHash=="string"&&/^[a-f0-9]{64}$/.test(e.bundleHash)&&(e.launchAttempted===void 0||typeof e.launchAttempted=="boolean")))throw new Error("Invalid local client ownership intent; inspect client/local-install.json");return e}function H(n,t){if(!(t&&!t.ssh&&!t.clientCommand&&t.clientConnection!=="ssh-reverse"&&typeof t.cortexPath=="string"&&r.resolve(t.cortexPath)===r.resolve(n.DATA_DIR)))throw new Error("Local client machine conflicts with ownership; keep SSH/custom-command machines externally managed")}function k(n,t){let e=r.join(n.CONFIG_DIR,"machines.json");if(!o.existsSync(e))return;let i=JSON.parse(o.readFileSync(e,"utf8"));H(n,i[t])}function N(n,t){if(c(n.CONFIG_DIR),c(f(n)),!!o.existsSync(f(n))&&I(o.readFileSync(f(n),"utf8"))!==t.configHash)throw new Error("Owned local client config was modified; refusing to overwrite config/cortex-client.json")}function O(n){let t=/^local-install\.json\.tmp\.[1-9]\d*\.\d+\.[a-z0-9]{0,6}$/;if(o.readdirSync(a(n),{withFileTypes:!0}).filter(i=>!i.name.startsWith("local-install.json.mutation-lock")&&!(i.isFile()&&t.test(i.name))).length||o.lstatSync(f(n),{throwIfNoEntry:!1}))throw new Error("Unowned local client files/config exist; refusing to adopt or overwrite them")}function w(n,t){p(h(n),JSON.stringify(t,null,2)+`
|
|
6
6
|
`)}function y(n,t,e){if(t.device!==e)throw new Error("Local client ownership belongs to a different device");k(n,e),N(n,t)}async function G(n,t,e){let i=x(e);c(a(n)),o.mkdirSync(a(n),{recursive:!0}),await d(h(n),async()=>{let s=m(n);if(s)return y(n,s,t);if(k(n,t),O(n),!t.trim())throw new Error("Local client device must not be empty");w(n,{schema:1,state:"pending",device:t,launchAttempted:!1,configHash:I(j(t)),bundleHash:i.hash})})}function D(n,t){let e=r.join(a(n),F);c(e),o.mkdirSync(e,{recursive:!0});for(let i of t.files){let s=r.join(e,i.name);c(s),p(s,Buffer.from(i.data,"base64").toString("utf8"))}if(v(e)!==t.hash)throw new Error("Staged local client hash mismatch");o.renameSync(e,r.join(a(n),"current"))}function T(n,t,e){let i=r.join(a(n),"current");if(c(i),o.existsSync(i)){if(t.state==="ready")return;if(v(i)!==t.bundleHash)throw new Error("Pending local client publication hash mismatch")}else w(n,{...t,state:"pending",bundleHash:e.hash}),D(n,e),t={...t,bundleHash:e.hash};w(n,{...t,state:"ready"})}async function U(n,t,e){await d(h(n),async()=>{e.throwIfAborted();let i=m(n);if(!i)throw new Error("Missing local client ownership intent");y(n,i,t),w(n,{...i,launchAttempted:!0})},{signal:e})}async function W(n,t){await d(h(n),async()=>{let e=m(n);!e||e.device!==t||e.launchAttempted===!1||(y(n,e,t),w(n,{...e,launchAttempted:!1}))})}async function z(n,t,e,i){if(i?.throwIfAborted(),!m(n))throw new Error("Missing local client ownership intent");let s=x(e);await d(h(n),async()=>{i?.throwIfAborted();let l=m(n);if(!l)throw new Error("Missing local client ownership intent");y(n,l,t),o.existsSync(f(n))||p(f(n),j(t)),T(n,l,s)},{signal:i})}export{x as a,m as b,H as c,y as d,G as e,U as f,W as g,z as h};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as __cortexCreateRequire } from 'node:module';
|
|
2
2
|
const require = __cortexCreateRequire(import.meta.url);
|
|
3
3
|
const __cortexPackageRoot = new URL("../../", import.meta.url);
|
|
4
|
-
var t;function e(r){t=r}var o=async()=>t?t.anthropic():(await import("./anthropic-SUZWKBRW.js")).anthropicOAuth,i=async()=>t?t.openaiCodex():(await import("./openai-codex-JULCKICT.js")).openaiCodexOAuth,n=async()=>t?t.openaiChatGPT():(await import("./openai-chatgpt-PETGIJOZ.js")).openaiChatGPTOAuth,a=async()=>t?t.githubCopilot():(await import("./github-copilot-
|
|
4
|
+
var t;function e(r){t=r}var o=async()=>t?t.anthropic():(await import("./anthropic-SUZWKBRW.js")).anthropicOAuth,i=async()=>t?t.openaiCodex():(await import("./openai-codex-JULCKICT.js")).openaiCodexOAuth,n=async()=>t?t.openaiChatGPT():(await import("./openai-chatgpt-PETGIJOZ.js")).openaiChatGPTOAuth,a=async()=>t?t.githubCopilot():(await import("./github-copilot-BRU2SRRZ.js")).githubCopilotOAuth,u=async()=>t?t.openrouter():(await import("./openrouter-GDY3BLT2.js")).openRouterOAuth,s=async()=>t?t.kimiCoding():(await import("./kimi-coding-ZCIBMDZ6.js")).kimiCodingOAuth,p=async()=>t?t.meta():(await import("./meta-JQH66YU7.js")).metaOAuth,c=async()=>t?t.xai():(await import("./xai-KEVUJTFV.js")).xaiOAuth,h=async r=>t?t.radius(r):(await import("./radius-THYKWV4E.js")).createRadiusOAuth(r);export{e as a,o as b,i as c,n as d,a as e,u as f,s as g,p as h,c as i,h as j};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __cortexCreateRequire } from 'node:module';
|
|
2
2
|
const require = __cortexCreateRequire(import.meta.url);
|
|
3
3
|
const __cortexPackageRoot = new URL("../../", import.meta.url);
|
|
4
|
-
import{a as c,g as p}from"./chunk-
|
|
4
|
+
import{a as c,g as p}from"./chunk-OJ37ZWBG.js";import{readFileSync as l}from"fs";var a="openai",f=Object.freeze({supportsMidConvoEffort:!1,supportsLongCacheRetention:!1});function u(e){let t;try{t=JSON.parse(l(e,"utf8"))}catch{return new Map}if(!t||typeof t!="object")return new Map;let r=new Map;for(let[n,o]of Object.entries(t))(o?.type==="oauth"||o?.type==="api_key")&&r.set(n,o.type);return r}function v(e){return new Set([...u(e)].filter(([,t])=>t==="oauth").map(([t])=>t))}function C(e,t){return u(e).get(t)??null}import{existsSync as O,readFileSync as h,renameSync as S,unlinkSync as _,writeFileSync as I,mkdirSync as T,chmodSync as P}from"fs";import*as i from"path";var m="runtime-keys.json",R={deepseek:{supportsDeveloperRole:!1,maxTokensField:"max_completion_tokens"}};function j(e,t,r){if(c(t))return t;let o=e===a&&r.has(e)?f:{},d=t.compat&&typeof t.compat=="object"?t.compat:{},s={...R[e],...d,...o};return Object.keys(s).length>0?{...t,compat:s}:t}function w(e,t){let r={};for(let[n,o]of Object.entries(e.providers))r[n]=j(n,o,t);return r}function y(e,t){T(i.dirname(e),{recursive:!0});let r=`${e}.tmp.${process.pid}.${Date.now()}`;try{I(r,t,{encoding:"utf8",mode:384}),P(r,384),S(r,e)}catch(n){try{O(r)&&_(r)}catch{}throw n}}function G(e,t){let r=w(e,t.oauthProviders);y(p(t.agentDir),`${JSON.stringify({providers:r},null,2)}
|
|
5
5
|
`),y(i.join(t.agentDir,m),`${JSON.stringify(e.runtimeKeys,null,2)}
|
|
6
6
|
`)}function A(e){try{let t=JSON.parse(h(i.join(e,m),"utf8"));return!t||typeof t!="object"||Array.isArray(t)?{}:Object.fromEntries(Object.entries(t).filter(([,r])=>typeof r=="string"&&r.length>0))}catch{return{}}}async function b(e,t){for(let[r,n]of Object.entries(A(t)))await e.setRuntimeApiKey(r,n)}export{v as a,C as b,G as c,b as d};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createRequire as __cortexCreateRequire } from 'node:module';
|
|
2
|
+
const require = __cortexCreateRequire(import.meta.url);
|
|
3
|
+
const __cortexPackageRoot = new URL("../../", import.meta.url);
|
|
4
|
+
import{e as it,k as st}from"./chunk-PG7452XE.js";import{a as ot,d as nt}from"./chunk-RW2F2QNP.js";import{c as ct}from"./chunk-VHX2GHBF.js";import{L as at}from"./chunk-C6YVF7EI.js";import{d as rt}from"./chunk-52VCLZS5.js";import{e as I,g as Z,j as N,k as tt,l as v,m as et}from"./chunk-T54CZKNJ.js";import w from"node:fs";import g from"node:path";var lt="cortex-production-benchmark-evidence-context/1",$t=/^[a-f0-9]{64}$/;function u(t){return new Error(`Production benchmark evidence context invalid: ${t}`)}function C(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function ut(t,e){let o=new Set(e);return e.every(n=>Object.hasOwn(t,n))&&Object.keys(t).every(n=>o.has(n))}function E(t,e){if(typeof t!="string"||t.length===0)throw u(e);return t}function H(t){if(t===null)return null;if(typeof t=="string"||typeof t=="boolean"||typeof t=="number"&&Number.isFinite(t))return t;if(Array.isArray(t))return Object.freeze(t.map(H));if(!C(t))throw u("model_execution.model_alias_policy");let e=Object.entries(t).map(([o,n])=>[o,H(n)]);return Object.freeze(Object.fromEntries(e))}function Dt(t){let e=["model_alias_policy","cli_name","cli_version","max_output_tokens"];if(!C(t)||!ut(t,e))throw u("model_execution");if(t.cli_name!=="claude"&&t.cli_name!=="pi")throw u("model_execution.cli_name");let o=t.max_output_tokens;if(o!==null&&(!Number.isInteger(o)||Number(o)<=0))throw u("model_execution.max_output_tokens");return Object.freeze({model_alias_policy:H(t.model_alias_policy),cli_name:t.cli_name,cli_version:E(t.cli_version,"model_execution.cli_version"),max_output_tokens:o})}function dt(t){let e=["schema_version","trial_id","root_run_id","bundle_manifest_hash","model_execution"];if(!C(t)||!ut(t,e))throw u("evidence context envelope");if(t.schema_version!==lt)throw u("schema_version");let o=E(t.bundle_manifest_hash,"bundle_manifest_hash");if(!$t.test(o))throw u("bundle_manifest_hash");return Object.freeze({schema_version:lt,trial_id:E(t.trial_id,"trial_id"),root_run_id:E(t.root_run_id,"root_run_id"),bundle_manifest_hash:o,model_execution:Dt(t.model_execution)})}import{createHash as Ft}from"node:crypto";function Mt(t){return JSON.stringify(t)}function Lt(t){return`[${Array.from({length:t.length},(o,n)=>$(t[n])??"null").join(",")}]`}function Ut(t,e){let o=$(t[e]);return o===void 0?null:`${JSON.stringify(e)}:${o}`}function Jt(t){return t!==null}function qt(t){return`{${Object.keys(t).sort().map(o=>Ut(t,o)).filter(Jt).join(",")}}`}function $(t){return t===null||typeof t!="object"?Mt(t):Array.isArray(t)?Lt(t):qt(t)}function d(t){let e=$(t);if(e===void 0)throw new TypeError("Value is not JSON-serializable");return Ft("sha256").update(e,"utf8").digest("hex")}function mt(t){return d({backend:t.backend,requested_model:t.requestedModel,model_alias_policy:t.modelAliasPolicy,provider_protocol:t.providerProtocol,configured_route_base_host:t.configuredRouteBaseHost,claude_cli_version:t.claudeCliVersion,cli_name:t.cliName,cli_version:t.cliVersion,reasoning_effort:t.reasoningEffort,max_output_tokens:t.maxOutputTokens??null})}function ht(t,e){return t<e?-1:t>e?1:0}function k(t){return d({system_prompt_sha256:t.systemPromptSha256,directive_sha256:t.directiveSha256,tools:[...t.tools].sort(),plugin_dirs:[...t.pluginDirs].sort((e,o)=>ht(e.path,o.path)),skills:[...t.skills].sort((e,o)=>ht(e.name,o.name)),mcp_composition:t.mcpComposition,mcp_tool_allowlist:t.mcpToolAllowlist?[...new Set(t.mcpToolAllowlist)].sort():void 0,hook_policy:t.hookPolicy})}import{createHash as Wt}from"node:crypto";import p from"node:fs";import _ from"node:path";import*as f from"path";var Ze=3900*1e3,to=3600*1e3,eo=f.join(et,"projects"),oo=f.join(I,"logs","sessions"),no=f.join(N,"mcp-config.json"),ro=f.join(N,"mcp-config-empty.json"),io=f.join(I,".claude","settings.json"),so=["plan"],S="AskUserQuestion,Bash,Edit,EnterPlanMode,ExitPlanMode,Glob,Grep,Read,Skill,TaskStop,TodoWrite,WebFetch,WebSearch,Write",O="mcp__cortex-core__",ao=[`${O}cortex_plan_enter`,`${O}cortex_plan_exit`,`${O}cortex_ask_user`],co=new Set(["AskUserQuestion","EnterPlanMode","ExitPlanMode"]),lo=new Set(["Agent"]);function uo(){return rt.map(t=>O+t)}var ft=class extends Error{cancelled;constructor(){super("Cancelled by user"),this.cancelled=!0}};import zt from"node:path";var Bt={"agent:pre-tool":"PreToolUse","agent:post-tool":"PostToolUse","agent:session-start":"SessionStart"};function Vt(t){return t.startsWith("cc:")?t.slice(3):Bt[t]??null}function pt(t){let o={type:"command",command:t.script!==void 0?`node ${nt(t.script).join(" ")}`:t.command};return t.timeout!==void 0&&(o.timeout=t.timeout),o}function Gt(t,e,o){let n=t[e]??[];t[e]===void 0&&(t[e]=n);let r=typeof o.matcher=="string"?o.matcher:void 0,i=n.at(-1);if(i&&i.matcher===r){i.hooks.push(pt(o.run));return}let l=[pt(o.run)];n.push(r===void 0?{hooks:l}:{matcher:r,hooks:l})}function Qt(t){let e=st(it(),{backend:"claude",availableTools:new Set(t)}),o=Object.create(null);for(let n of e){let r=Vt(n.event);r!==null&&Gt(o,r,n)}return o}function wt(t){let e=(t||S).split(",").map(o=>o.trim());return Qt(e)}var wo="CORTEX_QUOTA_ROUTE",_t=zt.join(ot,"quota-stop.mjs");function yt(t){return`'${t.replace(/'/g,"'\\''")}'`}function Kt(t=process.platform){if(t==="win32")return`node "${_t}" "${v}"`;let e=yt(v);return`[ -f ${e} ] || exit 0; exec node ${yt(_t)} ${e}`}function So(t){let e={hooks:[{type:"command",command:Kt()}]};return{...t,PostToolUse:[...t.PostToolUse??[],e]}}function D(t){return Wt("sha256").update(t).digest("hex")}function St(t,e=t){let o=[];for(let n of p.readdirSync(e,{withFileTypes:!0})){let r=_.join(e,n.name);n.isDirectory()&&o.push(...St(t,r)),n.isFile()&&o.push({path:_.relative(t,r),type:"file",sha256:D(p.readFileSync(r))}),n.isSymbolicLink()&&o.push({path:_.relative(t,r),type:"symlink",target:p.readlinkSync(r)})}return o}function F(t,e){return t<e?-1:t>e?1:0}function M(t){if(!p.statSync(t).isDirectory())throw new Error(`Plugin path is not a directory: ${t}`);return d(St(t).sort((e,o)=>F(e.path,o.path)))}function Yt(t,e){let o=t.map(n=>({path:n,content_sha256:M(n)}));return e&&o.push({path:"@plugin-capability",content_sha256:e}),o.sort((n,r)=>F(n.path,r.path))}function Xt(t){let e=_.join(t,"skills");return p.existsSync(e)?p.readdirSync(e,{withFileTypes:!0}).filter(o=>o.isDirectory()).map(o=>({name:o.name,content_sha256:M(_.join(e,o.name))})):[]}function Zt(t){return t.map(e=>({name:_.basename(e),content_sha256:M(e)}))}function te(t){let e=new Set;for(let o of t){if(e.has(o.name))throw new Error(`Duplicate plugin skill name: ${o.name}`);e.add(o.name)}return t.sort((o,n)=>F(o.name,n.name))}function ee(t,e){return te([...t.flatMap(Xt),...Zt(e)])}function xt(t){return t.tools.rawClaude!==void 0?(t.tools.rawClaude||S).split(","):t.tools.canonical?.length?t.tools.canonical:S.split(",")}function oe(t){if(t.flags.disableHooks===!0)return{};let e=xt(t).join(",");return wt(e)}function ne(t){return t.prompt.append===void 0?D(t.prompt.system??""):d({system_prompt:t.prompt.system??"",append_system_prompt:t.prompt.append})}function P(t,e=""){let o=t.plugins.dirs??[],n={systemPromptSha256:ne(t),directiveSha256:D(e),tools:xt(t),pluginDirs:Yt(o,t.plugins.fingerprint),skills:ee(o,t.plugins.skillDirs??[]),mcpComposition:t.mcp.composition??"direct",hookPolicy:oe(t)};return t.mcp.allowlist!==void 0&&(n.mcpToolAllowlist=t.mcp.allowlist),n}import{createHash as G}from"node:crypto";import h from"node:fs";import b from"node:path";import{createHash as re}from"node:crypto";import s from"node:fs";var gt="cortex-bench-journal/2",ie=64*1024,J="direct",j=class extends Error{reason="trajectory_write_failed";constructor(e="Trajectory write failed",o){super(e,o),this.name="TrajectoryWriteFailedError"}},L=class extends Error{operation;constructor(e,o){super(`${e} failed`,{cause:o}),this.operation=e,this.name="FilesystemOperationError"}};function a(t,e){return new L(t,e)}function m(t,e){let o=e.length===1?e[0]:new AggregateError(e);return new j(`${t}: trajectory write failed`,{cause:o})}function Et(t,e){throw e instanceof j?e:m(t,[e])}function kt(t){try{return Buffer.from(`${JSON.stringify(t)}
|
|
5
|
+
`,"utf8")}catch(e){throw a("serialize",e)}}function se(t,e,o){try{return s.writeSync(t,e,o,e.length-o)}catch(n){throw a("write",n)}}function Ot(t,e){let o=0;for(;o<e.length;){let n=se(t,e,o);if(n<=0)throw a("write",new Error("zero-byte write"));o+=n}}function bt(t){try{return s.fsyncSync(t),null}catch(e){return a("fsync",e)}}function q(t){try{return s.closeSync(t),null}catch(e){return a("close",e)}}function T(t,e){e&&t.push(e)}function Pt(t){try{return t().toISOString()}catch(e){throw a("timestamp",e)}}function ae(t,e){return{schema_version:gt,type:"run_header",root_run_id:t.rootRunId,session_id:t.sessionId,agent_slot:t.agentSlot,seq:0,ts:e,resolved_cwd:t.resolvedCwd,canonical_instruction_sha256:t.canonicalInstructionSha256,model_visible_prompt_sha256:t.modelVisiblePromptSha256,system_prompt_sha256:t.systemPromptSha256,tool_manifest_sha256:t.toolManifestSha256,plugin_manifest_sha256:t.pluginManifestSha256,model_execution_identity_hash:t.modelExecutionIdentityHash,role_tool_surface_hash:t.roleToolSurfaceHash,bundle_manifest_hash:t.bundleManifestHash}}function ce(t,e,o,n){return{schema_version:gt,type:"event",root_run_id:e.rootRunId,session_id:t.sessionId,agent_slot:t.agentSlot,seq:o,ts:n,backend:t.backend,provider:t.provider,requested_model:t.requestedModel,reported_model:t.reportedModel,model_execution_identity_hash:e.modelExecutionIdentityHash,role_tool_surface_hash:e.roleToolSurfaceHash,bundle_manifest_hash:e.bundleManifestHash,event:t.event}}var U=class{path;identity;now;fd;nextSeq=1;count=0;constructor(e,o,n,r){this.path=e,this.identity=n,this.now=r,this.fd=o}get eventCount(){return this.count}writeEvent(e){let o;try{let n=this.requireOpenFd();o=ce(e,this.identity,this.nextSeq,Pt(this.now)),Ot(n,kt(o))}catch(n){Et("event write",n)}return this.nextSeq+=1,this.count+=1,o}sha256(){let e=this.fd===null?null:bt(this.fd);if(e)throw m("journal hash flush",[e]);return me(this.path)}closeSync(){if(this.fd===null)return;let e=this.fd;this.fd=null;let o=[];if(T(o,bt(e)),T(o,q(e)),o.length>0)throw m("journal close",o)}requireOpenFd(){if(this.fd!==null)return this.fd;let e=a("write",new Error("journal is closed"));throw m("event write",[e])}};function le(t){return{rootRunId:t.rootRunId,modelExecutionIdentityHash:t.modelExecutionIdentityHash,roleToolSurfaceHash:t.roleToolSurfaceHash,bundleManifestHash:t.bundleManifestHash}}function ue(t){try{let e=s.constants.O_WRONLY|s.constants.O_CREAT|s.constants.O_EXCL|s.constants.O_APPEND;return s.openSync(t,e,384)}catch(e){throw a("open",e)}}function de(t,e){let o=[e];throw T(o,q(t)),m("journal open",o)}function jt(t){let e;try{e=ue(t.path)}catch(r){Et("journal open",r)}let o=t.now??(()=>new Date),n=ae(t.header,Pt(o));try{Ot(e,kt(n))}catch(r){de(e,r)}return new U(t.path,e,le(t.header),o)}function he(t){let e=re("sha256"),o=Buffer.allocUnsafe(ie);for(;;){let n=s.readSync(t,o,0,o.length,null);if(n===0)return e.digest("hex");e.update(o.subarray(0,n))}}function me(t){let e;try{e=s.openSync(t,"r")}catch(r){throw m("journal hash",[a("open",r)])}let o=null,n=[];try{o=he(e)}catch(r){n.push(a("read",r))}if(T(n,q(e)),n.length>0)throw m("journal hash",n);return o}var It="cortex-production-attempt-journal/1",fe=/^[a-f0-9]{64}$/,Tt=["schema_version","attempt_id","execution_id","journal_path","journal_sha256","event_count","closed_at"],y=null,x=null;function pe(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function _e(t){let e=new Set(Tt);return Tt.every(o=>Object.hasOwn(t,o))&&Object.keys(t).every(o=>e.has(o))}function R(t){return typeof t=="string"&&t.length>0}function ye(t){return _e(t)&&t.schema_version===It&&R(t.attempt_id)&&R(t.execution_id)&&R(t.journal_path)&&b.isAbsolute(t.journal_path)&&typeof t.journal_sha256=="string"&&fe.test(t.journal_sha256)&&Number.isInteger(t.event_count)&&Number(t.event_count)>=0&&R(t.closed_at)&&!Number.isNaN(Date.parse(t.closed_at))}function we(t,e){let o;try{o=JSON.parse(t)}catch{throw new Error(`Production attempt journal store malformed at line ${e}`)}if(!pe(o)||!ye(o))throw new Error(`Production attempt journal store invalid at line ${e}`);return o}function Se(t){let e=h.readFileSync(t);if(e.length===0||e.at(-1)!==10)throw new Error(`Production attempt journal is empty or incomplete: ${t}`);let n=e.toString("utf8").trimEnd().split(`
|
|
6
|
+
`).map((r,i)=>{try{return JSON.parse(r)}catch{throw new Error(`Production attempt journal malformed at ${t}:${i+1}`)}});if(n[0]?.type!=="run_header")throw new Error(`Production attempt journal header missing: ${t}`);return{sha256:G("sha256").update(e).digest("hex"),eventCount:n.slice(1).filter(r=>r.type==="event").length}}function Rt(t){let e=Se(t.journal_path);if(e.sha256!==t.journal_sha256)throw new Error(`Production attempt journal digest mismatch: ${t.execution_id}`);if(e.eventCount!==t.event_count)throw new Error(`Production attempt journal event count mismatch: ${t.execution_id}`)}function z(t,e){return JSON.stringify(t)===JSON.stringify(e)}var B=class{filePath;byExecution=new Map;byAttempt=new Map;constructor(e){this.filePath=e,this.load()}load(){let e;try{e=h.readFileSync(this.filePath,"utf8")}catch(o){if(o.code==="ENOENT")return;throw o}e.split(`
|
|
7
|
+
`).filter(Boolean).forEach((o,n)=>{let r=we(o,n+1);Rt(r),this.remember(r)})}remember(e){let o=this.byExecution.get(e.execution_id),n=this.byAttempt.get(e.attempt_id);if(o&&!z(o,e)||n&&!z(n,e))throw new Error(`Production attempt journal identity collision: ${e.execution_id}`);if(o)return o;let r=Object.freeze({...e});return this.byExecution.set(e.execution_id,r),this.byAttempt.set(e.attempt_id,r),r}get(e){return this.byExecution.get(e)??null}append(e){let o=this.get(e.execution_id);if(o){if(!z(o,e))throw new Error(`Production attempt journal changed for execution ${e.execution_id}`);return o}Rt(e),h.mkdirSync(b.dirname(this.filePath),{recursive:!0,mode:448});let n=h.openSync(this.filePath,"a",384);try{h.writeFileSync(n,`${JSON.stringify(e)}
|
|
8
|
+
`,"utf8"),h.fsyncSync(n)}finally{h.closeSync(n)}return this.remember(e)}};function xe(t){return`${G("sha256").update(t.attempt_id).digest("hex")}.ndjson`}function At(t){return G("sha256").update(t,"utf8").digest("hex")}function be(t){let e=P(t.spec,t.canonicalInstruction);if(k(e)!==t.identity.role_tool_surface_hash)throw new Error("Production attempt journal role identity drifted before open");return{canonicalInstructionSha256:At(t.canonicalInstruction),modelVisiblePromptSha256:At(t.message),systemPromptSha256:e.systemPromptSha256,toolManifestSha256:d(e.tools),pluginManifestSha256:d({plugin_dirs:e.pluginDirs,skills:e.skills})}}function ge(t){let{identity:e,spec:o}=t;return{rootRunId:e.root_run_id,sessionId:e.session_id,agentSlot:J,resolvedCwd:Z(o.cwd),...be(t),modelExecutionIdentityHash:e.model_execution_identity_hash,roleToolSurfaceHash:e.role_tool_surface_hash,bundleManifestHash:e.bundle_manifest_hash}}function Ee(t){if(t.type!=="tool_result"||!t.images)return t;let{images:e,...o}=t;return o}function ke(t){return"model"in t&&typeof t.model=="string"&&t.model.length>0?t.model:null}var V=class{identity;journal;repo;closed=!1;writeFailure=null;constructor(e,o,n){this.identity=e,this.journal=o,this.repo=n}onEvent(e){try{this.journal.writeEvent({sessionId:this.identity.session_id,agentSlot:J,backend:this.identity.backend,provider:this.identity.provider,requestedModel:this.identity.requested_model,reportedModel:ke(e),event:Ee(e)})}catch(o){throw this.writeFailure??=o,o}}onClose(){if(!this.closed){if(this.closed=!0,this.journal.closeSync(),this.writeFailure)throw this.writeFailure;this.repo.append(Object.freeze({schema_version:It,attempt_id:this.identity.attempt_id,execution_id:this.identity.execution_id,journal_path:b.resolve(this.journal.path),journal_sha256:this.journal.sha256(),event_count:this.journal.eventCount,closed_at:new Date().toISOString()}))}}};function Nt(t){x=b.resolve(t.journalDir),y=new B(t.storePath)}function Q(){y=null,x=null}function Fo(t){if(!y||!x)throw new Error("Production attempt journal store is not initialized");if(y.get(t.identity.execution_id))throw new Error(`Production attempt journal already exists for execution ${t.identity.execution_id}`);h.mkdirSync(x,{recursive:!0,mode:448});let e=jt({path:b.join(x,xe(t.identity)),header:ge(t)});return new V(t.identity,e,y)}function Mo(t){return y?.get(t)??null}var X="cortex-production-attempt-identity/5",Oe=/^[a-f0-9]{64}$/,Pe=g.join(tt,"benchmark-attempt-identities.jsonl"),je=["schema_version","trial_id","root_run_id","attempt_id","root_attempt_id","spawn_parent_attempt_id","execution_id","session_id","thinking","mode","backend","provider","requested_model","model_execution_identity_hash","role_tool_surface_hash","bundle_manifest_hash","frozen_at"],c=null;function Te(t){return new Error(`Production benchmark evidence context invalid: ${t}`)}function vt(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Re(t,e){let o=new Set(e);return e.every(n=>Object.hasOwn(t,n))&&Object.keys(t).every(n=>o.has(n))}function Ht(t,e){if(typeof t!="string"||t.length===0)throw Te(e);return t}function Ae(t){return t===null||typeof t=="string"&&t.length>0}function Ie(t){let e=["trial_id","root_run_id","attempt_id","root_attempt_id","execution_id","session_id","mode","requested_model","model_execution_identity_hash","role_tool_surface_hash","bundle_manifest_hash","frozen_at"],o=["spawn_parent_attempt_id","provider","thinking"],n=[t.model_execution_identity_hash,t.role_tool_surface_hash,t.bundle_manifest_hash];return Re(t,je)&&t.schema_version===X&&e.every(r=>typeof t[r]=="string"&&String(t[r]).length>0)&&o.every(r=>Ae(t[r]))&&(t.backend==="claude"||t.backend==="pi")&&n.every(r=>typeof r=="string"&&Oe.test(r))}function Ne(t,e){let o;try{o=JSON.parse(t)}catch{throw new Error(`Production attempt identity store malformed at line ${e}`)}if(vt(o)&&typeof o.schema_version=="string"&&o.schema_version!==X)return null;if(!vt(o)||!Ie(o))throw new Error(`Production attempt identity store invalid at line ${e}`);return o}function ve(t,e){return JSON.stringify(t)===JSON.stringify(e)}function K(t,e){return t.trial_id===e.trial_id&&t.root_run_id===e.root_run_id}var W=class{filePath;byExecution=new Map;byAttempt=new Map;ordered=[];constructor(e){this.filePath=e,this.load()}load(){let e;try{e=w.readFileSync(this.filePath,"utf8")}catch(o){if(o.code==="ENOENT")return;throw o}e.split(`
|
|
9
|
+
`).filter(Boolean).forEach((o,n)=>{let r=Ne(o,n+1);r&&this.remember(r)})}latestSessionAttempt(e){for(let o=this.ordered.length-1;o>=0;o-=1){let n=this.ordered[o];if(K(n,e)&&n.session_id===e.session_id)return n}return null}assertRunSession(e){let o=this.ordered.find(n=>K(n,e));if(o&&o.session_id!==e.session_id)throw new Error("Production attempt identity cross-run session collision")}resolveRootAttemptId(e,o){return this.assertRunSession(e),this.latestSessionAttempt(e)?.root_attempt_id??o}resolveSpawnParentAttemptId(e){return this.assertRunSession(e),this.latestSessionAttempt(e)?.attempt_id??null}assertTopology(e){if(e.attempt_id!==`execution-${e.execution_id}`)throw new Error("Production attempt identity collision between execution and attempt");if(e.spawn_parent_attempt_id===e.attempt_id)throw new Error("Production attempt identity cannot self-link");let o=this.resolveRootAttemptId(e,e.attempt_id),n=this.resolveSpawnParentAttemptId(e);if(e.root_attempt_id!==o||e.spawn_parent_attempt_id!==n)throw new Error("Production attempt spawn topology is invalid")}remember(e){if(this.byExecution.has(e.execution_id)||this.byAttempt.has(e.attempt_id))throw new Error(`Production attempt identity collision: ${e.execution_id}`);this.assertTopology(e);let o=Object.freeze({...e});return this.byExecution.set(e.execution_id,o),this.byAttempt.set(e.attempt_id,o),this.ordered.push(o),o}get(e){return this.byExecution.get(e)??null}list(e){let o=Ht(e.trialId,"trial identity"),n=Ht(e.rootRunId,"root run identity"),r=this.ordered.filter(i=>i.trial_id===o&&i.root_run_id===n);if(r.length===0)throw new Error(`No production attempts found for ${o}/${n}`);return Object.freeze([...r])}firstRootAttempt(e){return this.ordered.find(o=>K(o,e))??null}append(e){let o=this.get(e.execution_id);if(o){if(!ve(o,e))throw new Error(`Production attempt identity changed for execution ${e.execution_id}`);return o}this.assertTopology(e),w.mkdirSync(g.dirname(this.filePath),{recursive:!0,mode:448});let n=w.openSync(this.filePath,"a",384);try{w.writeFileSync(n,`${JSON.stringify(e)}
|
|
10
|
+
`,"utf8"),w.fsyncSync(n)}finally{w.closeSync(n)}return this.remember(e)}};function He(t){return t.configurationRevision?.()??null}function Ko(t={}){c=null,Q();let e=t.storePath??Pe,o=g.dirname(e);try{let n=new W(e);Nt({journalDir:g.join(o,"benchmark-attempt-journals"),storePath:g.join(o,"benchmark-attempt-journals.jsonl")}),c={repo:n,revision:He(t),configurationRevision:t.configurationRevision}}catch(n){throw Q(),n}}function Ce(t){let e=t.configurationRevision?.()??null;if(JSON.stringify(e)!==JSON.stringify(t.revision))throw new Error("Production benchmark configuration hot-reload drift detected")}function Y(t,e){if(typeof t!="string"||t.length===0)throw new Error(`Production benchmark attempt is missing ${e}`);return t}var Ct=Object.freeze({deepseek:"https://api.deepseek.com","openai-codex":"https://chatgpt.com/backend-api"});function $e(t){if(!t)return null;let e=at.findPi(t)?.baseUrl;return e||(Object.hasOwn(Ct,t)?Ct[t]:null)}function De(t,e){let o=e==="pi"?$e(t.model.provider):t.env.sets?.ANTHROPIC_BASE_URL??t.route.anthropicBaseUrl;if(!o)return null;try{return new URL(o).host}catch{throw new Error(`Production benchmark resolved route is invalid: ${o}`)}}function Fe(t,e){if(t.model.id!==e.model)throw new Error("Production benchmark resolved model drifted before adapter spawn");if((t.model.thinking??null)!==e.thinking)throw new Error("Production benchmark resolved thinking drifted before adapter spawn");if(e.backend==="pi"&&(t.model.provider??null)!==e.provider)throw new Error("Production benchmark resolved provider drifted before adapter spawn")}function Me(t,e){let o=t.selection;if(!o)throw new Error("Production benchmark attempt is missing selection");if(o.backend!==e.model_execution.cli_name||o.backend!==t.adapterBackend)throw new Error("Production benchmark backend differs from injected CLI identity");return Fe(t.spec,o),o}function Le(t,e){let o=e.model_execution.max_output_tokens,n=t.model.benchmarkMaxOutputTokens??null;if(n!==o)throw new Error("Production benchmark max output token identity drifted");return n}function Ue(t,e,o,n,r){let i=Y(o,"execution identity"),l=`execution-${i}`,A={trial_id:n.trial_id,root_run_id:n.root_run_id,session_id:Y(e.session.sessionId,"session identity")};return{attempt_id:l,root_attempt_id:r?.root_attempt_id??t.repo.resolveRootAttemptId(A,l),spawn_parent_attempt_id:r?.spawn_parent_attempt_id??t.repo.resolveSpawnParentAttemptId(A),execution_id:i,session_id:A.session_id}}function Je(t,e,o){let n=t.model_execution;return mt({backend:o.backend,requestedModel:o.model,modelAliasPolicy:n.model_alias_policy,providerProtocol:o.provider,configuredRouteBaseHost:De(e,o.backend),claudeCliVersion:o.backend==="claude"?n.cli_version:null,cliName:n.cli_name,cliVersion:n.cli_version,reasoningEffort:o.thinking,maxOutputTokens:Le(e,t)})}function qe(t,e){let o=Me(e,t),n=typeof e.request.benchmark?.identityDirective=="string"?e.request.benchmark.identityDirective:"",r=P(e.spec,n);return{thinking:o.thinking,mode:ct(o),backend:o.backend,provider:o.provider,requested_model:o.model,model_execution_identity_hash:Je(t,e.spec,o),role_tool_surface_hash:k(r)}}function ze(t,e,o,n){return{schema_version:X,trial_id:o.trial_id,root_run_id:o.root_run_id,...Ue(t,e.request,e.executionId,o,n),...qe(o,e),bundle_manifest_hash:o.bundle_manifest_hash,frozen_at:new Date().toISOString()}}function Be(t,e){let o=t.firstRootAttempt(e);if(!o)return;if(["trial_id","root_run_id","bundle_manifest_hash","thinking","mode","backend","provider","requested_model","model_execution_identity_hash"].some(r=>o[r]!==e[r]))throw new Error("Production benchmark immutable root identity baseline drifted");if(o.role_tool_surface_hash!==e.role_tool_surface_hash)throw new Error("Production benchmark immutable role tool baseline drifted")}function Wo(t){let e=t.request.benchmark?.evidenceContext??null;if(e==null)return null;if(!c)throw new Error("Production benchmark identity store is not initialized");Ce(c);let o=dt(e),n=Y(t.executionId,"execution identity"),r=c.repo.get(n),i=ze(c,t,o,r),l=r?{...i,frozen_at:r.frozen_at}:i;return Be(c.repo,l),c.repo.append(l)}function Ve(){if(!c)throw new Error("Production benchmark identity store is not initialized");return c.repo}function Yo(t){return Ve().list(t)}export{Ze as a,to as b,eo as c,oo as d,no as e,ro as f,io as g,so as h,S as i,ao as j,co as k,lo as l,uo as m,ft as n,Vt as o,wt as p,wo as q,So as r,dt as s,J as t,Fo as u,Mo as v,Ko as w,Wo as x,Yo as y};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as __cortexCreateRequire } from 'node:module';
|
|
2
2
|
const require = __cortexCreateRequire(import.meta.url);
|
|
3
3
|
const __cortexPackageRoot = new URL("../../", import.meta.url);
|
|
4
|
-
import{a as
|
|
4
|
+
import{a as c}from"./chunk-Q4UGYGU5.js";import{a as l,d as u}from"./chunk-TRXLIL7V.js";import{e as p}from"./chunk-7W7VYUTK.js";import a from"node:fs/promises";import h from"node:path";var f=p("json-repository"),n=new Set;function F(r){n.add(r)}async function x(){await Promise.allSettled([...n].map(r=>r.flush()))}var m=class{opts;cache=null;mutex=new c;sweepPromise=null;constructor(t){this.opts=t,n.add(this)}async sweepOrphans(){try{let t=h.dirname(this.opts.filePath),s=`${h.basename(this.opts.filePath)}.tmp.`,i=await a.readdir(t);await Promise.all(i.filter(o=>o.startsWith(s)).map(o=>a.unlink(h.join(t,o)).catch(()=>{})))}catch{}}ensureSwept(){return this.sweepPromise||(this.sweepPromise=this.sweepOrphans()),this.sweepPromise}async read(){if(this.cache!==null&&!this.opts.sharedFile)return this.cache;this.opts.sharedFile||await this.ensureSwept();let{value:t,migrated:e}=await this.load();return e?this.opts.sharedFile?this.mutate(s=>({next:s,result:s})):(await this.write(t),t):this.cache=t}async load(){try{return this.parse(await a.readFile(this.opts.filePath,"utf8"))}catch(t){if(t.code==="ENOENT")return{value:this.opts.defaultValue(),migrated:!1};if(t instanceof SyntaxError)return{value:await this.recoverCorrupt(t),migrated:!1};throw t}}parse(t){let e=JSON.parse(t);if(!this.opts.migrate)return{value:e,migrated:!1};let s=JSON.stringify(e),i=this.opts.migrate(e);return{value:i,migrated:s!==JSON.stringify(i)}}async recoverCorrupt(t){let e=`${this.opts.filePath}.corrupt.${Date.now()}`;try{await a.copyFile(this.opts.filePath,e),f.warn(`Corrupt JSON in ${this.opts.filePath} (${t.message}); backed up to ${e}, resetting to defaults.`)}catch(s){f.warn(`Corrupt JSON in ${this.opts.filePath} (${t.message}); failed to back up (${s?.message??s}); resetting to defaults.`)}return this.opts.defaultValue()}async write(t){await this.ensureSwept();try{await u(this.opts.filePath,this.serialize(t))}catch(e){throw this.cache=null,e}this.cache=t}serialize(t){return this.opts.compact?JSON.stringify(t):JSON.stringify(t,null,2)}async flush(){await this.mutex.run(async()=>{})}async mutate(t){return this.mutex.run(()=>this.underFileLock(async()=>{await this.ensureSwept();let e=this.cache!==null&&!this.opts.sharedFile?this.cache:(await this.load()).value,{next:s,result:i}=t(e);return await this.write(s),i}))}underFileLock(t){return this.opts.sharedFile?l(this.opts.filePath,t):t()}invalidate(){this.cache=null}};export{F as a,x as b,m as c};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as __cortexCreateRequire } from 'node:module';
|
|
2
2
|
const require = __cortexCreateRequire(import.meta.url);
|
|
3
3
|
const __cortexPackageRoot = new URL("../../", import.meta.url);
|
|
4
|
-
import{a as l,b as i,c as s,e as c}from"./chunk-IA6IODY3.js";import{d as m,j as u}from"./chunk-
|
|
4
|
+
import{a as l,b as i,c as s,e as c}from"./chunk-IA6IODY3.js";import{d as m,j as u}from"./chunk-Y6DGVTKM.js";import{M as f}from"./chunk-C6YVF7EI.js";var a=30;function v(e){return[e.default,...Array.isArray(e.favorites)?e.favorites:[]].filter(t=>{let r=t;return!!r&&typeof r.model=="string"&&!!r.model.trim()})}var y={policy:{allow:"all",deny:[]},favorites:[]};function d(){let e=null;try{e=m.readIfPresent()}catch{}return e?{policy:s(e.delegation),favorites:v(e).map(l)}:y}function p(e){return e.policy.allow==="all"&&e.policy.deny.length===0}function E(e=d()){return p(e)?()=>!0:o=>i(e.policy,l(o),e.favorites)}function b(e=d(),o=f.peek()){let r=[...o.routes.flatMap(n=>n.models.map(g=>l({backend:n.backend,provider:n.provider,model:g}))),...e.favorites].filter(n=>i(e.policy,n,e.favorites));return[...new Set(r)].sort()}function h(e,o){if(e==="claude")return o.model;if(o.provider)return`${o.provider}/${o.model}`;try{return l(u(o.model,"pi"))}catch{return o.model}}function M(e,o){let t=e.parent;return!t?.model||t.backend!==e.backend?!1:l(t)===o}function $(e,o){let t=b(o);if(!t.length)return`Model "${e}" is not available for delegation, and no model is; omit model to use the default.`;let r=t.slice(0,a).join(", "),n=t.length>a?`, and ${t.length-a} more`:"";return`Model "${e}" is not available for delegation. Choose one of: ${r}${n}; or omit model to use the default.`}function N(e){let o=c(e.model);if(!o.model)return;let t=d();if(p(t))return;let r=h(e.backend,{...o,model:o.model});if(!(M(e,r)||i(t.policy,r,t.favorites)))throw new Error($(r,t))}export{E as a,N as b};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as __cortexCreateRequire } from 'node:module';
|
|
2
2
|
const require = __cortexCreateRequire(import.meta.url);
|
|
3
3
|
const __cortexPackageRoot = new URL("../../", import.meta.url);
|
|
4
|
-
import{e as l}from"./chunk-
|
|
4
|
+
import{e as l}from"./chunk-7W7VYUTK.js";import{e as s}from"./chunk-T54CZKNJ.js";import{spawn as f}from"node:child_process";var i=l("hook-exec"),c=2e3;function u(r,n){r.settled||(r.settled=!0,r.resolve(n))}function d(r,n,e,o=null){r.settled||(i.error(e),u(r,{stdout:r.stdout.trim(),stderr:r.stderr.slice(-c),exitCode:o,error:n}))}function m(r,n,e,o){if(o==="SIGTERM"||o==="SIGKILL"){let t=`timed out after ${n.timeoutMs}ms`;d(r,t,`${t} (${n.label})`);return}if(e!==0){let t=`exited with code ${e}`,a=r.stderr?`: ${r.stderr.trim()}`:"";d(r,t,`${t} (${n.label})${a}`,e);return}u(r,{stdout:r.stdout.trim(),stderr:r.stderr.slice(-c),exitCode:0})}function $(r,n){r.on("error",e=>{i.warn(`stdin write failed (${n.label}): ${e.message}`)});try{r.write(n.stdinPayload)}catch(e){i.warn(`stdin write failed (${n.label}): ${String(e)}`)}try{r.end()}catch(e){i.warn(`stdin end failed (${n.label}): ${String(e)}`)}}function w(r){return f("sh",["-c",`${r.command} "$@"`,"hook",...r.args??[]],{stdio:["pipe","pipe","pipe"],cwd:s,timeout:r.timeoutMs,...r.env?{env:r.env}:{}})}function g(r,n){try{let e=w(r);e.stdout.on("data",o=>{n.stdout+=o.toString()}),e.stderr.on("data",o=>{n.stderr+=o.toString()}),e.on("error",o=>{d(n,o.message,`spawn error (${r.label}): ${o.message}`)}),e.on("close",(o,t)=>m(n,r,o,t)),$(e.stdin,r)}catch(e){let o=e instanceof Error?e.message:String(e);d(n,o,`spawn error (${r.label}): ${o}`)}}function I(r){return new Promise(n=>{g(r,{stdout:"",stderr:"",settled:!1,resolve:n})})}export{I as a};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as __cortexCreateRequire } from 'node:module';
|
|
2
2
|
const require = __cortexCreateRequire(import.meta.url);
|
|
3
3
|
const __cortexPackageRoot = new URL("../../", import.meta.url);
|
|
4
|
-
import{a as m}from"./chunk-23PRJECN.js";import{
|
|
4
|
+
import{a as m}from"./chunk-23PRJECN.js";import{G as f}from"./chunk-DE5EGVKG.js";import{a as y,b as h}from"./chunk-K4NTZEDJ.js";import{h as c}from"./chunk-3XLHL5YT.js";function x(e,r,n){let a=new Error(`${e} returned ${r.status}`);return a.status=r.status,a.headers=r.headers,a.body=n,a}function k(e){let r=new Error(`Request timed out after ${e}ms`);return r.name="TimeoutError",r.status=void 0,r.headers=void 0,r.body="",r}function E(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function M(e,r,n){if(typeof r!="number"||!Number.isFinite(r))throw new Error(`${e} returned an invalid ${n}`);return r}function $(e,r,n,a){return h(c(e,a),{authorization:`Bearer ${r}`,"content-type":"application/json"},e.headers,n)??{}}async function N(e,r,n,a,t,g){if(!t?.apiKey)throw new Error(`No API key for provider: ${n.provider}`);let w=t.apiKey,s=a,u=await t.onPayload?.(s,n);u!==void 0&&(s=u);let b=t.fetch??globalThis.fetch,{response:d,json:R}=await m(async()=>{let o=t.timeoutMs!==void 0?AbortSignal.timeout(t.timeoutMs):void 0,l=t.signal&&o?AbortSignal.any([t.signal,o]):t.signal??o;try{let i=await b(r,{method:"POST",headers:$(n,w,t.headers,t.identity),body:JSON.stringify(s),signal:l});if(!i.ok)throw x(e,i,await i.text());return{response:i,json:await i.json()}}catch(i){throw o?.aborted&&!t.signal?.aborted?k(t.timeoutMs):i}},{maxRetries:t.maxRetries??2,maxRetryDelayMs:t.maxRetryDelayMs,signal:t.signal,noRetryStatuses:g});return await t.onResponse?.({status:d.status,headers:y(d.headers)},n),R}function p(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?e:0}function S(e,r){if(!E(e)||e.input_tokens===void 0&&e.output_tokens===void 0)return;let n=p(e.input_tokens),a=p(e.output_tokens),t={input:n,output:a,cacheRead:0,cacheWrite:0,totalTokens:n+a,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}};return f(r,t),t}export{E as a,M as b,N as c,S as d};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as __cortexCreateRequire } from 'node:module';
|
|
2
2
|
const require = __cortexCreateRequire(import.meta.url);
|
|
3
3
|
const __cortexPackageRoot = new URL("../../", import.meta.url);
|
|
4
|
-
import{
|
|
4
|
+
import{b as u}from"./chunk-T54CZKNJ.js";import*as a from"fs";import*as r from"path";import{fileURLToPath as l}from"url";function x(e){return r.dirname(l(e))}function $(e){if(!process.argv[1])return!1;let t=l(e),n=r.resolve(process.argv[1]);if(n===t)return!0;try{return a.realpathSync(n)===t}catch{return!1}}function v(){let e=new Date,t=n=>String(n).padStart(2,"0");return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}_${t(e.getHours())}-${t(e.getMinutes())}-${t(e.getSeconds())}`}function S(e){if(e<60)return`${Math.round(e)}s`;let t=Math.floor(e/60),n=Math.round(e%60);return n>0?`${t}m ${n}s`:`${t}m`}function f(e,t={}){let n=(t.override??process.env.CORTEX_NPM_PREFIX)?.trim();if(n)return n;let o=t.exists??a.existsSync,i=t.pathEnv??process.env.PATH??"";for(let s of i.split(r.delimiter)){if(!s||!o(r.join(s,e)))continue;let c=r.dirname(s);if(o(r.join(c,"lib","node_modules")))return c}return null}function p(e,t,n=process.platform){let o=n==="win32"?r.win32:r.posix,i=o.resolve(e);for(let c of t.split("/").reverse()){if(o.basename(i)!==c)return null;i=o.dirname(i)}if(o.basename(i)!=="node_modules")return null;let s=o.dirname(i);return n==="win32"?s:o.basename(s)==="lib"?o.dirname(s):null}function _(e,t=u){let n=process.env.CORTEX_NPM_PREFIX?.trim()||p(t,"@cortex-agent/server")||f("cortex");return n?[...e,"--prefix",n]:e}function w(e,t=process.platform,n=process.execPath,o=a.existsSync){if(t!=="win32")return{command:"npm",args:e,shell:!1};let i=r.win32.join(r.win32.dirname(n),"node_modules","npm","bin","npm-cli.js");return o(i)?{command:n,args:[i,...e],shell:!1}:{command:"npm.cmd",args:e.map(m),shell:!0}}function m(e){return`"${e.replace(/(\\*)"/g,'$1$1\\"').replace(/(\\+)$/g,"$1$1")}"`}export{x as a,$ as b,v as c,S as d,p as e,_ as f,w as g};
|