tenjin-cli 0.1.0-alpha.30 → 0.1.0-alpha.32
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 +65 -116
- package/dist/{_esm-CE7KNONL.js → _esm-RLLC72MS.js} +127 -131
- package/dist/alive-MROUMFH3.js +38 -0
- package/dist/auto-update-OPWMRZLS.js +22 -0
- package/dist/{ccip-7RMRLAGV.js → ccip-DHDFKTQV.js} +2 -2
- package/dist/chunk-2GNOFONN.js +560 -0
- package/dist/chunk-2GNOFONN.js.map +1 -0
- package/dist/{chunk-TTNESUPQ.js → chunk-2GP3HRYK.js} +2120 -193
- package/dist/chunk-2GP3HRYK.js.map +1 -0
- package/dist/chunk-3623BLPV.js +184 -0
- package/dist/chunk-3623BLPV.js.map +1 -0
- package/dist/chunk-3AIHRXKO.js +72 -0
- package/dist/chunk-3AIHRXKO.js.map +1 -0
- package/dist/chunk-3DIL66VX.js +120 -0
- package/dist/chunk-3DIL66VX.js.map +1 -0
- package/dist/{chunk-S4SAZ7OD.js → chunk-3FMZGI7I.js} +12 -2
- package/dist/{chunk-S4SAZ7OD.js.map → chunk-3FMZGI7I.js.map} +1 -1
- package/dist/chunk-3UCIG4TG.js +65 -0
- package/dist/chunk-3UCIG4TG.js.map +1 -0
- package/dist/{chunk-LFZJM56J.js → chunk-445VQTVM.js} +3 -3
- package/dist/{chunk-A36LQPHV.js → chunk-4LMUQMBH.js} +1 -1
- package/dist/{chunk-A36LQPHV.js.map → chunk-4LMUQMBH.js.map} +1 -1
- package/dist/{chunk-RAULEAZ6.js → chunk-4USCZ2NI.js} +3 -3
- package/dist/chunk-62KNUYWD.js +111 -0
- package/dist/chunk-62KNUYWD.js.map +1 -0
- package/dist/{chunk-POUWHWID.js → chunk-6CMM6YCB.js} +3 -3
- package/dist/{chunk-POUWHWID.js.map → chunk-6CMM6YCB.js.map} +1 -1
- package/dist/chunk-7WEQQJLG.js +68 -0
- package/dist/chunk-7WEQQJLG.js.map +1 -0
- package/dist/{chunk-3O2BQIF6.js → chunk-AD226HDR.js} +344 -534
- package/dist/chunk-AD226HDR.js.map +1 -0
- package/dist/chunk-ADV4LDTB.js +106 -0
- package/dist/chunk-ADV4LDTB.js.map +1 -0
- package/dist/{chunk-AWFUPKTM.js → chunk-AV5NZMYO.js} +15 -7
- package/dist/{chunk-AWFUPKTM.js.map → chunk-AV5NZMYO.js.map} +1 -1
- package/dist/chunk-B7EM4GGF.js +198 -0
- package/dist/chunk-B7EM4GGF.js.map +1 -0
- package/dist/chunk-BFDQ4WNW.js +119 -0
- package/dist/chunk-BFDQ4WNW.js.map +1 -0
- package/dist/{chunk-OSYTBCUC.js → chunk-BI673VEJ.js} +531 -503
- package/dist/chunk-BI673VEJ.js.map +1 -0
- package/dist/chunk-CEXSOI5R.js +808 -0
- package/dist/chunk-CEXSOI5R.js.map +1 -0
- package/dist/{chunk-OK2TDZQU.js → chunk-CISYM4EO.js} +9 -7
- package/dist/chunk-CISYM4EO.js.map +1 -0
- package/dist/{chunk-VFMQTSXG.js → chunk-D3ZURCG7.js} +3 -3
- package/dist/chunk-D5TOQSO4.js +474 -0
- package/dist/chunk-D5TOQSO4.js.map +1 -0
- package/dist/{chunk-P7LABKCW.js → chunk-DOQGNFHM.js} +33 -2
- package/dist/{chunk-P7LABKCW.js.map → chunk-DOQGNFHM.js.map} +1 -1
- package/dist/{chunk-QUVVWYJW.js → chunk-DRDUIZIA.js} +11 -9
- package/dist/{chunk-QUVVWYJW.js.map → chunk-DRDUIZIA.js.map} +1 -1
- package/dist/{chunk-O2FRQ2L2.js → chunk-DW4YTVR3.js} +5 -65
- package/dist/chunk-DW4YTVR3.js.map +1 -0
- package/dist/chunk-E7LGOMH6.js +449 -0
- package/dist/chunk-E7LGOMH6.js.map +1 -0
- package/dist/chunk-E7SW44LM.js +138 -0
- package/dist/chunk-E7SW44LM.js.map +1 -0
- package/dist/chunk-EDJWHDDL.js +33 -0
- package/dist/chunk-EDJWHDDL.js.map +1 -0
- package/dist/chunk-F3ED5WTR.js +13 -0
- package/dist/chunk-F3ED5WTR.js.map +1 -0
- package/dist/chunk-G75OPGAK.js +111 -0
- package/dist/chunk-G75OPGAK.js.map +1 -0
- package/dist/{chunk-YFQOA5AU.js → chunk-GAKUQHKA.js} +13 -17
- package/dist/{chunk-YFQOA5AU.js.map → chunk-GAKUQHKA.js.map} +1 -1
- package/dist/{chunk-PAYV4XUA.js → chunk-HDPUXS3Z.js} +20 -49
- package/dist/chunk-HDPUXS3Z.js.map +1 -0
- package/dist/{chunk-ORWL5BSN.js → chunk-HGZEPQUT.js} +2 -2
- package/dist/{chunk-HPWO4O6S.js → chunk-HREHWL32.js} +4 -4
- package/dist/{chunk-HPWO4O6S.js.map → chunk-HREHWL32.js.map} +1 -1
- package/dist/{chunk-VZGAONSJ.js → chunk-I5TDIUKM.js} +16 -35
- package/dist/chunk-I5TDIUKM.js.map +1 -0
- package/dist/{chunk-7QKHZQKW.js → chunk-IADZOXKN.js} +39 -6
- package/dist/chunk-IADZOXKN.js.map +1 -0
- package/dist/{chunk-U6YQ6FRI.js → chunk-IDTRSAHE.js} +32 -12
- package/dist/chunk-IDTRSAHE.js.map +1 -0
- package/dist/{chunk-SPAVAYSW.js → chunk-JEVQ5LKO.js} +7 -5
- package/dist/{chunk-SPAVAYSW.js.map → chunk-JEVQ5LKO.js.map} +1 -1
- package/dist/{chunk-EBVIKMCH.js → chunk-JKKAIPTU.js} +2 -2
- package/dist/chunk-JNJWBTU2.js +3497 -0
- package/dist/chunk-JNJWBTU2.js.map +1 -0
- package/dist/{chunk-TTBKWWTV.js → chunk-JRZBBPO6.js} +390 -146
- package/dist/chunk-JRZBBPO6.js.map +1 -0
- package/dist/{chunk-WVUSXNIE.js → chunk-MPZUYCAP.js} +9 -2
- package/dist/{chunk-WVUSXNIE.js.map → chunk-MPZUYCAP.js.map} +1 -1
- package/dist/{chunk-SJLTEINJ.js → chunk-OJNTCYQQ.js} +17 -1
- package/dist/chunk-OJNTCYQQ.js.map +1 -0
- package/dist/{chunk-IOODYAXL.js → chunk-OTWLERSW.js} +25 -6
- package/dist/chunk-OTWLERSW.js.map +1 -0
- package/dist/{chunk-AWQPGIR6.js → chunk-PJNENX2A.js} +1535 -422
- package/dist/chunk-PJNENX2A.js.map +1 -0
- package/dist/{chunk-KHE6L6TD.js → chunk-PKHI276N.js} +97 -11
- package/dist/chunk-PKHI276N.js.map +1 -0
- package/dist/{chunk-YHKXNYTB.js → chunk-QF3LSMGS.js} +2 -2
- package/dist/chunk-QXP3Z3JN.js +131 -0
- package/dist/chunk-QXP3Z3JN.js.map +1 -0
- package/dist/{chunk-XZKD7DIF.js → chunk-RL5UUDT4.js} +3 -3
- package/dist/{chunk-XZKD7DIF.js.map → chunk-RL5UUDT4.js.map} +1 -1
- package/dist/chunk-SFASB5FL.js +69 -0
- package/dist/chunk-SFASB5FL.js.map +1 -0
- package/dist/{chunk-WO5BJNIB.js → chunk-SNNSAGMT.js} +7273 -2741
- package/dist/chunk-SNNSAGMT.js.map +1 -0
- package/dist/{chunk-NZIP4PA2.js → chunk-SO3XRZPX.js} +3 -3
- package/dist/chunk-SYOS5CAC.js +176 -0
- package/dist/chunk-SYOS5CAC.js.map +1 -0
- package/dist/chunk-TAW4UFFF.js +293 -0
- package/dist/chunk-TAW4UFFF.js.map +1 -0
- package/dist/chunk-TF5HCP33.js +271 -0
- package/dist/chunk-TF5HCP33.js.map +1 -0
- package/dist/{chunk-AKWGE6JQ.js → chunk-UUGOUOVT.js} +37 -2
- package/dist/chunk-UUGOUOVT.js.map +1 -0
- package/dist/{chunk-AEG2PXBP.js → chunk-V2LQLN5H.js} +7 -7
- package/dist/{chunk-KYFZTGMC.js → chunk-VJUVFZ2D.js} +5 -3
- package/dist/{chunk-KYFZTGMC.js.map → chunk-VJUVFZ2D.js.map} +1 -1
- package/dist/{chunk-JMM6YE7J.js → chunk-VOZA6O7K.js} +708 -709
- package/dist/chunk-VOZA6O7K.js.map +1 -0
- package/dist/{chunk-5LJCEMFD.js → chunk-VUGQTZ2L.js} +209 -77
- package/dist/chunk-VUGQTZ2L.js.map +1 -0
- package/dist/chunk-WOM257PW.js +393 -0
- package/dist/chunk-WOM257PW.js.map +1 -0
- package/dist/chunk-WYXUQGOL.js +191 -0
- package/dist/chunk-WYXUQGOL.js.map +1 -0
- package/dist/chunk-X5ZBP3IY.js +97 -0
- package/dist/chunk-X5ZBP3IY.js.map +1 -0
- package/dist/chunk-XQJXNMSB.js +23 -0
- package/dist/chunk-XQJXNMSB.js.map +1 -0
- package/dist/chunk-Y527D4TV.js +56 -0
- package/dist/chunk-Y527D4TV.js.map +1 -0
- package/dist/{chunk-VUFAK2LW.js → chunk-YUY4SAGM.js} +17 -2
- package/dist/chunk-YUY4SAGM.js.map +1 -0
- package/dist/clack-EZ7TDWQU.js +19 -0
- package/dist/claude-cli-2YKABJJZ.js +31 -0
- package/dist/{cli-O5SN7ZJ4.js → cli-FB4LOA5A.js} +221 -68
- package/dist/{cli-O5SN7ZJ4.js.map → cli-FB4LOA5A.js.map} +1 -1
- package/dist/codex-event-TYVES3UX.js +16 -0
- package/dist/codex-host-WW4H2SKT.js +29 -0
- package/dist/codex-install-2C623HPW.js +393 -0
- package/dist/codex-install-2C623HPW.js.map +1 -0
- package/dist/{config-OJQI27LT.js → config-HOVJFEKD.js} +25 -15
- package/dist/doctor-NKU4V5OV.js +1312 -0
- package/dist/doctor-NKU4V5OV.js.map +1 -0
- package/dist/{env-proxy-XL4P73MZ.js → env-proxy-R6ZMLQTT.js} +6 -2
- package/dist/{ethersCompat-Df4a6QIZ-THAVUGIJ.js → ethersCompat-Df4a6QIZ-X6YZWAML.js} +3 -3
- package/dist/{fund-WEV6DMTD.js → fund-WEBHTZGN.js} +38 -30
- package/dist/{fund-WEV6DMTD.js.map → fund-WEBHTZGN.js.map} +1 -1
- package/dist/hook-command-ZA2PNKS6.js +44 -0
- package/dist/hosts/claude/.claude-plugin/marketplace.json +2 -2
- package/dist/hosts/claude/tenjin/.claude-plugin/plugin.json +3 -2
- package/dist/hosts/claude/tenjin/hooks/hooks.json +4 -1
- package/dist/hosts/claude/tenjin/hooks/register.tsx +589 -0
- package/dist/hosts/claude/tenjin/skills/tenjin-pay/SKILL.md +82 -0
- package/dist/hosts/claude/tenjin/types/index.d.ts +41 -0
- package/dist/hosts/codex/.agents/plugins/marketplace.json +20 -0
- package/dist/hosts/codex/tenjin/.codex-plugin/plugin.json +16 -0
- package/dist/hosts/codex/tenjin/.mcp.json +15 -0
- package/dist/hosts/codex/tenjin/hooks/hooks.json +98 -0
- package/dist/hosts-AV5MHBAU.js +38 -0
- package/dist/index.js +28 -8
- package/dist/index.js.map +1 -1
- package/dist/install-PT4EZS4R.js +100 -0
- package/dist/{install-identity-WHPNMNMQ.js → install-identity-5A4OE6YC.js} +13 -8
- package/dist/install-wallet-SAAPKB73.js +281 -0
- package/dist/install-wallet-SAAPKB73.js.map +1 -0
- package/dist/{mcp-QML7ZMPH.js → mcp-HAWKCTPQ.js} +909 -208
- package/dist/mcp-HAWKCTPQ.js.map +1 -0
- package/dist/{mine.wasm-6PIT3DK6.js → mine.wasm-QFAHIFPY.js} +2 -2
- package/dist/{mine.wasm-6PIT3DK6.js.map → mine.wasm-QFAHIFPY.js.map} +1 -1
- package/dist/{package-LGKYOEPV.js → package-SR2WB6MK.js} +4 -2
- package/dist/passphrase-IFTDS3CU.js +44 -0
- package/dist/{paths-POPTXJO6.js → paths-XCSAKISU.js} +10 -2
- package/dist/pay-OXC3WKYV.js +55 -0
- package/dist/pay-OXC3WKYV.js.map +1 -0
- package/dist/{payments-C44QUFXU.js → payments-3KHMP2MG.js} +18 -13
- package/dist/{payments-C44QUFXU.js.map → payments-3KHMP2MG.js.map} +1 -1
- package/dist/plugin-registration-N3GRIZVM.js +67 -0
- package/dist/plugin-registration-N3GRIZVM.js.map +1 -0
- package/dist/{redact-6W23GGJC.js → redact-D7ASVWKL.js} +2 -2
- package/dist/redact-D7ASVWKL.js.map +1 -0
- package/dist/runtime-UVNUA3AS.js +1203 -0
- package/dist/runtime-UVNUA3AS.js.map +1 -0
- package/dist/runtime-fetch-EKFRNR6Z.js +20 -0
- package/dist/runtime-fetch-EKFRNR6Z.js.map +1 -0
- package/dist/runtime-layout-BDWZG2TQ.js +25 -0
- package/dist/runtime-layout-BDWZG2TQ.js.map +1 -0
- package/dist/{send-KVJX4XIR.js → send-HMKJLT34.js} +26 -18
- package/dist/{send-KVJX4XIR.js.map → send-HMKJLT34.js.map} +1 -1
- package/dist/{status-S7C3WMSH.js → status-RWXIIWYS.js} +57 -22
- package/dist/status-RWXIIWYS.js.map +1 -0
- package/dist/{status-line-YR2T5HC4.js → status-line-77XYZP7E.js} +13 -8
- package/dist/{status-line-YR2T5HC4.js.map → status-line-77XYZP7E.js.map} +1 -1
- package/dist/uninstall-D5G67UJH.js +480 -0
- package/dist/uninstall-D5G67UJH.js.map +1 -0
- package/dist/update-LRNOEGSB.js +53 -0
- package/dist/update-LRNOEGSB.js.map +1 -0
- package/dist/{usdc-JK4RRFFQ.js → usdc-D6X7EIQ2.js} +7 -8
- package/dist/usdc-D6X7EIQ2.js.map +1 -0
- package/dist/{viemAdapter-By13KInL-X2VY6CY3.js → viemAdapter-By13KInL-RL742ETX.js} +3 -3
- package/dist/viemAdapter-By13KInL-RL742ETX.js.map +1 -0
- package/dist/wallet-XFYC27BR.js +55 -0
- package/dist/wallet-XFYC27BR.js.map +1 -0
- package/dist/wallet-kdf-worker.mjs +8 -8
- package/docs/agent-permissions.md +56 -22
- package/docs/safety-model.md +1 -1
- package/docs/troubleshooting.md +72 -1
- package/package.json +14 -1
- package/dist/alive-3J3CHOQP.js +0 -21
- package/dist/ccip-NLCSCHKI.js +0 -19
- package/dist/chunk-3O2BQIF6.js.map +0 -1
- package/dist/chunk-5IEP5EGE.js +0 -5332
- package/dist/chunk-5IEP5EGE.js.map +0 -1
- package/dist/chunk-5LJCEMFD.js.map +0 -1
- package/dist/chunk-6W5GYG3W.js +0 -128
- package/dist/chunk-6W5GYG3W.js.map +0 -1
- package/dist/chunk-7EKYXMUO.js +0 -7536
- package/dist/chunk-7EKYXMUO.js.map +0 -1
- package/dist/chunk-7QKHZQKW.js.map +0 -1
- package/dist/chunk-AKWGE6JQ.js.map +0 -1
- package/dist/chunk-AWQPGIR6.js.map +0 -1
- package/dist/chunk-EGELTSPU.js +0 -2865
- package/dist/chunk-EGELTSPU.js.map +0 -1
- package/dist/chunk-EL56RW2J.js +0 -7611
- package/dist/chunk-EL56RW2J.js.map +0 -1
- package/dist/chunk-HE2MS4QO.js +0 -256
- package/dist/chunk-HE2MS4QO.js.map +0 -1
- package/dist/chunk-IOODYAXL.js.map +0 -1
- package/dist/chunk-JMM6YE7J.js.map +0 -1
- package/dist/chunk-KHE6L6TD.js.map +0 -1
- package/dist/chunk-N35E6CM2.js +0 -1185
- package/dist/chunk-N35E6CM2.js.map +0 -1
- package/dist/chunk-O2FRQ2L2.js.map +0 -1
- package/dist/chunk-OK2TDZQU.js.map +0 -1
- package/dist/chunk-OSYTBCUC.js.map +0 -1
- package/dist/chunk-PAYV4XUA.js.map +0 -1
- package/dist/chunk-SJLTEINJ.js.map +0 -1
- package/dist/chunk-TTBKWWTV.js.map +0 -1
- package/dist/chunk-TTNESUPQ.js.map +0 -1
- package/dist/chunk-U6YQ6FRI.js.map +0 -1
- package/dist/chunk-VUFAK2LW.js.map +0 -1
- package/dist/chunk-VZGAONSJ.js.map +0 -1
- package/dist/chunk-WO5BJNIB.js.map +0 -1
- package/dist/doctor-IQQJHGGM.js +0 -590
- package/dist/doctor-IQQJHGGM.js.map +0 -1
- package/dist/hook-command-D2P3ILRV.js +0 -32
- package/dist/install-TUCRF32I.js +0 -60
- package/dist/install-wallet-MA27FTQ5.js +0 -113
- package/dist/install-wallet-MA27FTQ5.js.map +0 -1
- package/dist/mcp-QML7ZMPH.js.map +0 -1
- package/dist/pay-2C2UBBXJ.js +0 -51
- package/dist/status-S7C3WMSH.js.map +0 -1
- package/dist/uninstall-HY6LKIIT.js +0 -149
- package/dist/uninstall-HY6LKIIT.js.map +0 -1
- package/dist/update-OJV22LR3.js +0 -36
- package/dist/wallet-PD2IMZDU.js +0 -39
- /package/dist/{_esm-CE7KNONL.js.map → _esm-RLLC72MS.js.map} +0 -0
- /package/dist/{alive-3J3CHOQP.js.map → alive-MROUMFH3.js.map} +0 -0
- /package/dist/{ccip-7RMRLAGV.js.map → auto-update-OPWMRZLS.js.map} +0 -0
- /package/dist/{ccip-NLCSCHKI.js.map → ccip-DHDFKTQV.js.map} +0 -0
- /package/dist/{chunk-LFZJM56J.js.map → chunk-445VQTVM.js.map} +0 -0
- /package/dist/{chunk-RAULEAZ6.js.map → chunk-4USCZ2NI.js.map} +0 -0
- /package/dist/{chunk-VFMQTSXG.js.map → chunk-D3ZURCG7.js.map} +0 -0
- /package/dist/{chunk-ORWL5BSN.js.map → chunk-HGZEPQUT.js.map} +0 -0
- /package/dist/{chunk-EBVIKMCH.js.map → chunk-JKKAIPTU.js.map} +0 -0
- /package/dist/{chunk-YHKXNYTB.js.map → chunk-QF3LSMGS.js.map} +0 -0
- /package/dist/{chunk-NZIP4PA2.js.map → chunk-SO3XRZPX.js.map} +0 -0
- /package/dist/{chunk-AEG2PXBP.js.map → chunk-V2LQLN5H.js.map} +0 -0
- /package/dist/{config-OJQI27LT.js.map → clack-EZ7TDWQU.js.map} +0 -0
- /package/dist/{env-proxy-XL4P73MZ.js.map → claude-cli-2YKABJJZ.js.map} +0 -0
- /package/dist/{ethersCompat-Df4a6QIZ-THAVUGIJ.js.map → codex-event-TYVES3UX.js.map} +0 -0
- /package/dist/{hook-command-D2P3ILRV.js.map → codex-host-WW4H2SKT.js.map} +0 -0
- /package/dist/{install-TUCRF32I.js.map → config-HOVJFEKD.js.map} +0 -0
- /package/dist/{install-identity-WHPNMNMQ.js.map → env-proxy-R6ZMLQTT.js.map} +0 -0
- /package/dist/{package-LGKYOEPV.js.map → ethersCompat-Df4a6QIZ-X6YZWAML.js.map} +0 -0
- /package/dist/{paths-POPTXJO6.js.map → hook-command-ZA2PNKS6.js.map} +0 -0
- /package/dist/{pay-2C2UBBXJ.js.map → hosts-AV5MHBAU.js.map} +0 -0
- /package/dist/{redact-6W23GGJC.js.map → install-PT4EZS4R.js.map} +0 -0
- /package/dist/{update-OJV22LR3.js.map → install-identity-5A4OE6YC.js.map} +0 -0
- /package/dist/{usdc-JK4RRFFQ.js.map → package-SR2WB6MK.js.map} +0 -0
- /package/dist/{viemAdapter-By13KInL-X2VY6CY3.js.map → passphrase-IFTDS3CU.js.map} +0 -0
- /package/dist/{wallet-PD2IMZDU.js.map → paths-XCSAKISU.js.map} +0 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
AGENT_ID_RE
|
|
4
|
+
} from "./chunk-XKESD27X.js";
|
|
5
|
+
|
|
6
|
+
// src/hooks/constants.ts
|
|
7
|
+
var HARNESS_MS = 5e3;
|
|
8
|
+
var MAX_BODY_BYTES = 4 * 1024 * 1024;
|
|
9
|
+
var LOG_TRUNCATE_BYTES = 5 * 1024 * 1024;
|
|
10
|
+
var CONTEXT_MAX = 1e4;
|
|
11
|
+
|
|
12
|
+
// src/adapters/error-markers.ts
|
|
13
|
+
var ERROR_MARKERS = [
|
|
14
|
+
// Test-runner verdicts. Uppercase only, and a whole word.
|
|
15
|
+
/\bFAIL\b/,
|
|
16
|
+
/AssertionError/,
|
|
17
|
+
/\b[1-9]\d* (?:failed|failing|errors?)\b/i,
|
|
18
|
+
// `Error:`, `TypeError:`, `ReferenceError:`, `ModuleNotFoundError:` — the
|
|
19
|
+
// JS and Python convention of naming the class before the colon — and the
|
|
20
|
+
// lowercase `error:` that rustc, gcc, clang, esbuild and git open a
|
|
21
|
+
// diagnostic line with. Line-start only: "an error: occurred" mid-sentence
|
|
22
|
+
// is prose.
|
|
23
|
+
/^[ \t]*(?:\w*Error|error):/m,
|
|
24
|
+
/Traceback \(most recent call last\)/,
|
|
25
|
+
/ModuleNotFoundError|ImportError:/,
|
|
26
|
+
/Cannot find module/i,
|
|
27
|
+
// A code the shell or a runner states outright. Never zero.
|
|
28
|
+
/exit code [1-9]\d*/i,
|
|
29
|
+
// libuv/POSIX codes: unambiguous, and the common real failures.
|
|
30
|
+
/\b(?:ENOENT|EADDRINUSE|ECONNREFUSED|EACCES|EPERM)\b/,
|
|
31
|
+
// Toolchain-specific prefixes: npm, pnpm, tsc, cargo, go, git.
|
|
32
|
+
/^[ \t]*npm ERR!/m,
|
|
33
|
+
/ERR_PNPM_/,
|
|
34
|
+
/error TS\d+:/,
|
|
35
|
+
/^[ \t]*error\[E\d+\]/m,
|
|
36
|
+
/^[ \t]*panic:/m,
|
|
37
|
+
/^[ \t]*fatal:/m,
|
|
38
|
+
/Unhandled(?:PromiseRejection|Rejection)/,
|
|
39
|
+
/segmentation fault/i
|
|
40
|
+
];
|
|
41
|
+
function hasErrorMarker(text) {
|
|
42
|
+
return ERROR_MARKERS.some((re) => re.test(text));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// src/adapters/codex-wire.ts
|
|
46
|
+
var NATIVE_TO_EVENT = {
|
|
47
|
+
SessionStart: "session.start",
|
|
48
|
+
UserPromptSubmit: "prompt",
|
|
49
|
+
PreToolUse: "tool.before",
|
|
50
|
+
PostToolUse: "tool.after",
|
|
51
|
+
SubagentStart: "agent.start",
|
|
52
|
+
SubagentStop: "agent.stop",
|
|
53
|
+
Stop: "turn.end"
|
|
54
|
+
};
|
|
55
|
+
var SHELL_TOOL = "Bash";
|
|
56
|
+
var PATCH_TOOL = "apply_patch";
|
|
57
|
+
var BLOCK_EVENTS = /* @__PURE__ */ new Set(["turn.end", "agent.stop"]);
|
|
58
|
+
function isRecord(v) {
|
|
59
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
60
|
+
}
|
|
61
|
+
function str(v) {
|
|
62
|
+
return typeof v === "string" ? v : void 0;
|
|
63
|
+
}
|
|
64
|
+
var PATCH_PATH_RE = /^\*\*\* (?:Add File|Update File|Delete File|Move to): (.+)$/;
|
|
65
|
+
function patchPaths(patch) {
|
|
66
|
+
const out = [];
|
|
67
|
+
for (const line of patch.split("\n")) {
|
|
68
|
+
const m = PATCH_PATH_RE.exec(line.trimEnd());
|
|
69
|
+
const path = m?.[1]?.trim();
|
|
70
|
+
if (path !== void 0 && path.length > 0 && !out.includes(path)) out.push(path);
|
|
71
|
+
}
|
|
72
|
+
return out;
|
|
73
|
+
}
|
|
74
|
+
function canonicalTool(name, input) {
|
|
75
|
+
if (name === SHELL_TOOL) return { name, kind: "shell", command: str(input.command) ?? "" };
|
|
76
|
+
if (name === PATCH_TOOL)
|
|
77
|
+
return { name, kind: "edit", paths: patchPaths(str(input.command) ?? "") };
|
|
78
|
+
if (name === "webrun") {
|
|
79
|
+
const queries = input.search_query;
|
|
80
|
+
if (Object.keys(input).every((key) => key === "search_query" || key === "response_length") && Array.isArray(queries) && queries.length === 1 && isRecord(queries[0]) && Object.keys(queries[0]).every((key) => key === "q") && typeof queries[0].q === "string" && queries[0].q.trim().length > 0) {
|
|
81
|
+
return { name, kind: "web", query: queries[0].q };
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return { name, kind: "other" };
|
|
85
|
+
}
|
|
86
|
+
var HTTP_URL_RE = /^https?:\/\//i;
|
|
87
|
+
var plainSearch = (v) => isRecord(v) && Object.keys(v).every((key) => key === "q") && typeof v.q === "string" && v.q.trim().length > 0;
|
|
88
|
+
var urlOpen = (v) => isRecord(v) && typeof v.ref_id === "string" && HTTP_URL_RE.test(v.ref_id.trim());
|
|
89
|
+
function splitWebrun(input) {
|
|
90
|
+
const searches = Array.isArray(input.search_query) ? input.search_query : [];
|
|
91
|
+
const opens = Array.isArray(input.open) ? input.open : [];
|
|
92
|
+
const s = searches.findIndex(plainSearch);
|
|
93
|
+
const o = s === -1 ? opens.findIndex((v) => urlOpen(v) && Object.keys(v).every((k) => k === "ref_id")) : -1;
|
|
94
|
+
if (s === -1 && o === -1) return null;
|
|
95
|
+
const key = s !== -1 ? "search_query" : "open";
|
|
96
|
+
const index = s !== -1 ? s : o;
|
|
97
|
+
const entry = s !== -1 ? { tool: "WebSearch", query: searches[s].q } : { tool: "WebFetch", url: opens[o].ref_id.trim() };
|
|
98
|
+
const rest = { ...input };
|
|
99
|
+
const left = (s !== -1 ? searches : opens).filter((_, i) => i !== index);
|
|
100
|
+
if (left.length === 0) delete rest[key];
|
|
101
|
+
else rest[key] = left;
|
|
102
|
+
const others = [
|
|
103
|
+
...searches.flatMap(
|
|
104
|
+
(v, i) => key === "search_query" && i === index ? [] : isRecord(v) && typeof v.q === "string" && v.q.trim().length > 0 ? [{ tool: "WebSearch", query: v.q }] : []
|
|
105
|
+
),
|
|
106
|
+
...opens.flatMap(
|
|
107
|
+
(v, i) => key === "open" && i === index || !urlOpen(v) ? [] : [{ tool: "WebFetch", url: v.ref_id.trim() }]
|
|
108
|
+
)
|
|
109
|
+
];
|
|
110
|
+
const operations = Object.keys(rest).filter((k) => k !== "response_length");
|
|
111
|
+
return { entry, rest: operations.length === 0 ? null : rest, targets: [entry, ...others] };
|
|
112
|
+
}
|
|
113
|
+
function decode(raw) {
|
|
114
|
+
if (!isRecord(raw)) return null;
|
|
115
|
+
const native = str(raw.hook_event_name);
|
|
116
|
+
if (native === void 0) return null;
|
|
117
|
+
const event = NATIVE_TO_EVENT[native];
|
|
118
|
+
if (event === void 0) return null;
|
|
119
|
+
const session = str(raw.session_id);
|
|
120
|
+
if (session === void 0 || session.length === 0) return null;
|
|
121
|
+
const input = {
|
|
122
|
+
harness: "codex",
|
|
123
|
+
event,
|
|
124
|
+
native: { event: native },
|
|
125
|
+
session,
|
|
126
|
+
cwd: str(raw.cwd) ?? "",
|
|
127
|
+
raw
|
|
128
|
+
};
|
|
129
|
+
if (raw.agent_id !== void 0 && raw.agent_id !== null) {
|
|
130
|
+
const id = raw.agent_id;
|
|
131
|
+
if (typeof id !== "string" || !AGENT_ID_RE.test(id)) return null;
|
|
132
|
+
input.agent = id;
|
|
133
|
+
}
|
|
134
|
+
const turn = str(raw.turn_id);
|
|
135
|
+
if (turn !== void 0) input.turn = turn;
|
|
136
|
+
const prompt = str(raw.prompt);
|
|
137
|
+
if (prompt !== void 0) input.prompt = prompt;
|
|
138
|
+
const agentType = str(raw.agent_type);
|
|
139
|
+
if (agentType !== void 0) input.agentType = agentType;
|
|
140
|
+
const lastMessage = str(raw.last_assistant_message);
|
|
141
|
+
if (lastMessage !== void 0) input.lastMessage = lastMessage;
|
|
142
|
+
if (typeof raw.stop_hook_active === "boolean") input.stopFuse = raw.stop_hook_active;
|
|
143
|
+
const source = str(raw.source);
|
|
144
|
+
if (source !== void 0) input.source = source;
|
|
145
|
+
const path = str(raw.transcript_path);
|
|
146
|
+
const agentPath = str(raw.agent_transcript_path);
|
|
147
|
+
if (path !== void 0 || agentPath !== void 0) {
|
|
148
|
+
input.transcript = {};
|
|
149
|
+
if (path !== void 0) input.transcript.path = path;
|
|
150
|
+
if (agentPath !== void 0) input.transcript.agentPath = agentPath;
|
|
151
|
+
}
|
|
152
|
+
if (event === "tool.before" || event === "tool.after") {
|
|
153
|
+
const name = str(raw.tool_name) ?? "";
|
|
154
|
+
const tool = canonicalTool(name, isRecord(raw.tool_input) ? raw.tool_input : {});
|
|
155
|
+
const callId = str(raw.tool_use_id);
|
|
156
|
+
if (callId !== void 0) tool.callId = callId;
|
|
157
|
+
if (event === "tool.after") {
|
|
158
|
+
const blocks = Array.isArray(raw.tool_response) ? raw.tool_response : void 0;
|
|
159
|
+
const text = str(raw.tool_response) ?? (blocks?.every((b) => isRecord(b) && b.type === "input_text" && typeof b.text === "string") ? blocks.map((b) => String(b.text)).join("\n") : void 0);
|
|
160
|
+
if (text !== void 0) tool.result = { text };
|
|
161
|
+
if (tool.kind === "shell" && text !== void 0 && hasErrorMarker(text)) tool.ok = false;
|
|
162
|
+
}
|
|
163
|
+
input.tool = tool;
|
|
164
|
+
}
|
|
165
|
+
return input;
|
|
166
|
+
}
|
|
167
|
+
function encode(emit, input) {
|
|
168
|
+
if (emit === null || emit.context === void 0 || emit.context.length === 0) return null;
|
|
169
|
+
const text = emit.context.slice(0, CONTEXT_MAX);
|
|
170
|
+
if (BLOCK_EVENTS.has(input.event)) return { decision: "block", reason: text };
|
|
171
|
+
return { hookSpecificOutput: { hookEventName: input.native.event, additionalContext: text } };
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export {
|
|
175
|
+
HARNESS_MS,
|
|
176
|
+
CONTEXT_MAX,
|
|
177
|
+
hasErrorMarker,
|
|
178
|
+
SHELL_TOOL,
|
|
179
|
+
PATCH_TOOL,
|
|
180
|
+
splitWebrun,
|
|
181
|
+
decode,
|
|
182
|
+
encode
|
|
183
|
+
};
|
|
184
|
+
//# sourceMappingURL=chunk-3623BLPV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/constants.ts","../src/adapters/error-markers.ts","../src/adapters/codex-wire.ts"],"sourcesContent":["/**\n * THE KERNEL'S bounds: every number the lifecycle, the store, the daemon and the\n * shim use that is not one of the two config knobs (`loop.human_wait_ms`,\n * `loop.tool_wait_ms`), each with the reason it is a constant\n * (tenjin-notes loop-redesign/02-redesign.md §7).\n *\n * AN ARM's own bounds are not here and must not be moved here: they are evidence\n * about one arm's input — a prompt's junk rules, the head a skipped row stores,\n * the shelf's own query bound — and each is only readable next to the code and\n * the measurement that justifies it. They live in `hooks/question.ts`,\n * `hooks/text.ts`, `hooks/legs/shelf.ts` and the arm files, and every one\n * carries its reason there the way these do here.\n */\n\n/** Left on every fetch so the response can be encoded and flushed before the\n * fire's own deadline lands. */\nexport const RESERVE_MS = 150;\n\n/** The gap between a fire's deadline and the harness's own kill: encode, socket\n * write, and the harness's parse. */\nexport const SLACK_MS = 500;\n\n/**\n * The harness timeout `install` stamps on every entry, in ms. A backstop only:\n * the fire's own deadline (2500 or 4000) always lands first, and a hung daemon\n * costs a session this much per fire, never a stuck turn. Derived:\n * `tool_wait_ms + SLACK_MS = 4500 -> 5 s`.\n */\nexport const HARNESS_MS = 5000;\n\n/**\n * How long the shim polls `/health` after spawning a daemon. A minimal daemon\n * measured 75 to 120 ms cold on this laptop (03-decisions.md, \"Measured\"); the\n * smoke test re-measures the real bundle against this number.\n */\nexport const SPAWN_MS = 500;\n\n/** The shim's `GET /health` budget. Loopback answers in 1 to 2 ms; anything\n * slower is a daemon mid-exit or a foreign listener. */\nexport const HEALTH_MS = 200;\n\n/**\n * After a spawn that never became healthy, no shim spawns again for this long.\n * A corrupt `loop.db` or a half-written bundle must not cost every prompt a\n * spawn plus `SPAWN_MS`. The record is the mtime of an empty `daemon.spawn`\n * file; `tenjin doctor` reads it (PR E).\n */\nexport const SPAWN_BACKOFF_MS = 60_000;\n\n/** Ledger rows older than this are deleted at the daemon's idle exit. Matches\n * Claude Code's own transcript sweep default. */\nexport const RETENTION_DAYS = 30;\n\n/** And past this many `fires` rows the oldest go regardless of age: a bound for\n * a team on default-on, not for one laptop. */\nexport const FIRES_ROW_CAP = 50_000;\n\n/** Retention runs in batches of this many rows: node 24's `node:sqlite` lacks\n * `DELETE ... LIMIT`, so it is `WHERE id IN (SELECT ... LIMIT n)` looped. */\nexport const RETENTION_BATCH = 500;\n\n/** Retention at idle exit stops after this long so a successor daemon is never\n * refused the port for longer than a shim will wait. */\nexport const RETENTION_MAX_MS = 5000;\n\n/** A request handler whose synchronous span exceeds this logs a warning: the\n * daemon serves every session on the machine from one loop. */\nexport const IDLE_SYNC_WARN_MS = 20;\n\n/** Largest hook body the daemon reads. A `tool_response` or\n * `last_assistant_message` past this is 413 and a log line. */\nexport const MAX_BODY_BYTES = 4 * 1024 * 1024;\n\n/** `daemon.log` is truncated at daemon start once it passes this. No rotation:\n * the idle exit bounds a log's lifetime already. */\nexport const LOG_TRUNCATE_BYTES = 5 * 1024 * 1024;\n\n/** After the idle timer fires this much later than armed, the laptop slept:\n * re-arm for {@link SLEEP_REARM_MS} instead of exiting under a resumed turn. */\nexport const SLEEP_GRACE_MS = 60_000;\nexport const SLEEP_REARM_MS = 120_000;\n\n/** The daemon's `busy_timeout`: the CLI writes `loop.db` rarely and briefly, so\n * a busy wait this long only ever happens at a CLI write's tail. */\nexport const DAEMON_BUSY_TIMEOUT_MS = 2000;\n\n/** `server.requestTimeout` and `headersTimeout` for the daemon's listener. */\nexport const REQUEST_TIMEOUT_MS = 10_000;\nexport const HEADERS_TIMEOUT_MS = 5000;\n\n/** The derived port range: `30000 + hash % 2000` sits below Linux's default\n * ephemeral range (32768+) and below macOS/Windows's (49152+), so a transient\n * outbound socket can never squat it. */\nexport const PORT_BASE = 30_000;\nexport const PORT_SPAN = 2000;\n\n/** Claude Code caps `additionalContext` here; both encoders slice their context to it. */\nexport const CONTEXT_MAX = 10_000;\n\n/** How long `tenjin daemon stop` waits after SIGTERM before SIGKILL. */\nexport const STOP_GRACE_MS = 3000;\n","/**\n * What a Bash `PostToolUse` has to print to count as a failure\n * (13-pr-d-local-arms.md, decision 9). Claude Code raises `PostToolUseFailure`\n * only when the tool itself fails; a command that exits non-zero inside a pipe,\n * or a runner that prints its verdict and exits zero, arrives as a plain\n * `PostToolUse`. So the adapter scans stdout and stderr for a marker a real\n * toolchain emits, and `decode` sets `tool.ok` from it — the arm never reads\n * text to decide.\n *\n * Case-sensitive where the case IS the signal: `FAIL` is a vitest/jest/pytest\n * verdict, `fail` and `failed` are prose. The anchored patterns carry `m` so\n * they work on a whole stdout blob, and leading indentation is allowed because\n * runners indent their own output.\n */\nexport const ERROR_MARKERS: readonly RegExp[] = [\n // Test-runner verdicts. Uppercase only, and a whole word.\n /\\bFAIL\\b/,\n /AssertionError/,\n /\\b[1-9]\\d* (?:failed|failing|errors?)\\b/i,\n // `Error:`, `TypeError:`, `ReferenceError:`, `ModuleNotFoundError:` — the\n // JS and Python convention of naming the class before the colon — and the\n // lowercase `error:` that rustc, gcc, clang, esbuild and git open a\n // diagnostic line with. Line-start only: \"an error: occurred\" mid-sentence\n // is prose.\n /^[ \\t]*(?:\\w*Error|error):/m,\n /Traceback \\(most recent call last\\)/,\n /ModuleNotFoundError|ImportError:/,\n /Cannot find module/i,\n // A code the shell or a runner states outright. Never zero.\n /exit code [1-9]\\d*/i,\n // libuv/POSIX codes: unambiguous, and the common real failures.\n /\\b(?:ENOENT|EADDRINUSE|ECONNREFUSED|EACCES|EPERM)\\b/,\n // Toolchain-specific prefixes: npm, pnpm, tsc, cargo, go, git.\n /^[ \\t]*npm ERR!/m,\n /ERR_PNPM_/,\n /error TS\\d+:/,\n /^[ \\t]*error\\[E\\d+\\]/m,\n /^[ \\t]*panic:/m,\n /^[ \\t]*fatal:/m,\n /Unhandled(?:PromiseRejection|Rejection)/,\n /segmentation fault/i,\n];\n\n/** Whether `text` carries any marker above. The whole output, no bound: the\n * body is already bounded by the daemon's request cap and each pattern is one\n * linear scan. */\nexport function hasErrorMarker(text: string): boolean {\n return ERROR_MARKERS.some((re) => re.test(text));\n}\n","import { AGENT_ID_RE } from '../lib/grade';\nimport { CONTEXT_MAX } from '../hooks/constants';\nimport { hasErrorMarker } from './error-markers';\nimport type { Emit, Event, HookInput, HookTool } from './types';\n\n/**\n * Codex CLI as a harness. Every mapping here is backed by a payload the\n * installed `codex-cli 0.153.4` sent (`fixtures/codex/README.md`, captured\n * 2026-09-08); the schema source is openai/codex at `rust-v0.153.4`.\n *\n * What is NOT mapped, on purpose: the spawn tool (`collaborationspawn_agent`)\n * carries its task as opaque ciphertext, so there is no work order to look up\n * and no dispatch handoff; a shell PostToolUse carries no exit status, so a\n * failure is known only from an error marker and success is never known; the\n * web tool (`webrun`) maps to `web` only as one plain search, while the router\n * reads any `webrun` call through {@link splitWebrun}.\n * Other web operations stay `other`; unknown versions are reported by doctor,\n * not used to disable otherwise valid web events.\n */\n\nconst NATIVE_TO_EVENT: Record<string, Event> = {\n SessionStart: 'session.start',\n UserPromptSubmit: 'prompt',\n PreToolUse: 'tool.before',\n PostToolUse: 'tool.after',\n SubagentStart: 'agent.start',\n SubagentStop: 'agent.stop',\n Stop: 'turn.end',\n};\n\n/** The hook-facing tool names, spelled once for the decoder and the matchers. */\nexport const SHELL_TOOL = 'Bash';\nexport const PATCH_TOOL = 'apply_patch';\n\n/** The events whose only continuation is `decision: block`: their response\n * schema has no `hookSpecificOutput` at all (schema.rs, StopCommandOutputWire). */\nconst BLOCK_EVENTS: ReadonlySet<Event> = new Set<Event>(['turn.end', 'agent.stop']);\n\nfunction isRecord(v: unknown): v is Record<string, unknown> {\n return typeof v === 'object' && v !== null && !Array.isArray(v);\n}\n\nfunction str(v: unknown): string | undefined {\n return typeof v === 'string' ? v : undefined;\n}\n\n/** `*** Add File: p`, `*** Update File: p`, `*** Delete File: p`, `*** Move to: q`. */\nconst PATCH_PATH_RE = /^\\*\\*\\* (?:Add File|Update File|Delete File|Move to): (.+)$/;\n\n/**\n * Every path an apply_patch names, in order, once each. The patch grammar is\n * the tool's own (apply-patch/src/parser.rs); a rename names both its source\n * and its target, because both were attempted work.\n */\nexport function patchPaths(patch: string): string[] {\n const out: string[] = [];\n for (const line of patch.split('\\n')) {\n const m = PATCH_PATH_RE.exec(line.trimEnd());\n const path = m?.[1]?.trim();\n if (path !== undefined && path.length > 0 && !out.includes(path)) out.push(path);\n }\n return out;\n}\n\nfunction canonicalTool(name: string, input: Record<string, unknown>): HookTool {\n if (name === SHELL_TOOL) return { name, kind: 'shell', command: str(input.command) ?? '' };\n if (name === PATCH_TOOL)\n return { name, kind: 'edit', paths: patchPaths(str(input.command) ?? '') };\n if (name === 'webrun') {\n const queries = input.search_query;\n // One complete, unfiltered operation only. Never deny a batch after\n // replacing its first member, or discard another operation/filter.\n if (\n Object.keys(input).every((key) => key === 'search_query' || key === 'response_length') &&\n Array.isArray(queries) &&\n queries.length === 1 &&\n isRecord(queries[0]) &&\n Object.keys(queries[0]).every((key) => key === 'q') &&\n typeof queries[0].q === 'string' &&\n queries[0].q.trim().length > 0\n ) {\n return { name, kind: 'web', query: queries[0].q };\n }\n }\n return { name, kind: 'other' };\n}\n\n/** One search or one page open, as the router weighs it. */\nexport type WebrunEntry = { tool: 'WebSearch'; query: string } | { tool: 'WebFetch'; url: string };\n\n/**\n * A `webrun` call as the router reads it: the one entry it weighs, the exact\n * rest of the call, and every search and URL in it.\n */\nexport interface WebrunSplit {\n entry: WebrunEntry;\n /** The input without the entry, filters and all; null when no operation remains. */\n rest: Record<string, unknown> | null;\n /** Every search and URL in the call, the entry first. */\n targets: WebrunEntry[];\n}\n\nconst HTTP_URL_RE = /^https?:\\/\\//i;\n\nconst plainSearch = (v: unknown): v is { q: string } =>\n isRecord(v) &&\n Object.keys(v).every((key) => key === 'q') &&\n typeof v.q === 'string' &&\n v.q.trim().length > 0;\n\nconst urlOpen = (v: unknown): v is { ref_id: string } =>\n isRecord(v) && typeof v.ref_id === 'string' && HTTP_URL_RE.test(v.ref_id.trim());\n\n/**\n * Pure. The entry is the first search that is only `q`, else the first open of\n * an http(s) URL with no `lineno`; null when the call holds neither. The rest\n * is the input minus that one entry, so entry plus rest is the whole call.\n */\nexport function splitWebrun(input: Record<string, unknown>): WebrunSplit | null {\n const searches = Array.isArray(input.search_query) ? (input.search_query as unknown[]) : [];\n const opens = Array.isArray(input.open) ? (input.open as unknown[]) : [];\n const s = searches.findIndex(plainSearch);\n const o =\n s === -1\n ? opens.findIndex((v) => urlOpen(v) && Object.keys(v as object).every((k) => k === 'ref_id'))\n : -1;\n if (s === -1 && o === -1) return null;\n const key = s !== -1 ? 'search_query' : 'open';\n const index = s !== -1 ? s : o;\n const entry: WebrunEntry =\n s !== -1\n ? { tool: 'WebSearch', query: (searches[s] as { q: string }).q }\n : { tool: 'WebFetch', url: (opens[o] as { ref_id: string }).ref_id.trim() };\n const rest: Record<string, unknown> = { ...input };\n const left = (s !== -1 ? searches : opens).filter((_, i) => i !== index);\n if (left.length === 0) delete rest[key];\n else rest[key] = left;\n const others: WebrunEntry[] = [\n ...searches.flatMap((v, i): WebrunEntry[] =>\n key === 'search_query' && i === index\n ? []\n : isRecord(v) && typeof v.q === 'string' && v.q.trim().length > 0\n ? [{ tool: 'WebSearch', query: v.q }]\n : [],\n ),\n ...opens.flatMap((v, i): WebrunEntry[] =>\n (key === 'open' && i === index) || !urlOpen(v)\n ? []\n : [{ tool: 'WebFetch', url: v.ref_id.trim() }],\n ),\n ];\n const operations = Object.keys(rest).filter((k) => k !== 'response_length');\n return { entry, rest: operations.length === 0 ? null : rest, targets: [entry, ...others] };\n}\n\n/**\n * Pure. Returns null for an unknown event, a missing session, or an `agent_id`\n * that is present but fails `AGENT_ID_RE`, exactly as the Claude adapter does:\n * a child this build cannot name is dropped rather than filed under the lead.\n */\nexport function decode(raw: unknown): HookInput | null {\n if (!isRecord(raw)) return null;\n const native = str(raw.hook_event_name);\n if (native === undefined) return null;\n const event = NATIVE_TO_EVENT[native];\n if (event === undefined) return null;\n const session = str(raw.session_id);\n if (session === undefined || session.length === 0) return null;\n\n const input: HookInput = {\n harness: 'codex',\n event,\n native: { event: native },\n session,\n cwd: str(raw.cwd) ?? '',\n raw,\n };\n if (raw.agent_id !== undefined && raw.agent_id !== null) {\n const id = raw.agent_id;\n if (typeof id !== 'string' || !AGENT_ID_RE.test(id)) return null;\n input.agent = id;\n }\n const turn = str(raw.turn_id);\n if (turn !== undefined) input.turn = turn;\n const prompt = str(raw.prompt);\n if (prompt !== undefined) input.prompt = prompt;\n const agentType = str(raw.agent_type);\n if (agentType !== undefined) input.agentType = agentType;\n const lastMessage = str(raw.last_assistant_message);\n if (lastMessage !== undefined) input.lastMessage = lastMessage;\n if (typeof raw.stop_hook_active === 'boolean') input.stopFuse = raw.stop_hook_active;\n const source = str(raw.source);\n if (source !== undefined) input.source = source;\n const path = str(raw.transcript_path);\n const agentPath = str(raw.agent_transcript_path);\n if (path !== undefined || agentPath !== undefined) {\n input.transcript = {};\n if (path !== undefined) input.transcript.path = path;\n if (agentPath !== undefined) input.transcript.agentPath = agentPath;\n }\n\n if (event === 'tool.before' || event === 'tool.after') {\n const name = str(raw.tool_name) ?? '';\n const tool = canonicalTool(name, isRecord(raw.tool_input) ? raw.tool_input : {});\n const callId = str(raw.tool_use_id);\n if (callId !== undefined) tool.callId = callId;\n if (event === 'tool.after') {\n // The response is the output text and nothing else: no exit status, on\n // a nonzero exit as much as on a clean one (PostToolUse-silent-exit).\n // So a marker is the only failure evidence, and its absence is unknown.\n const blocks = Array.isArray(raw.tool_response) ? raw.tool_response : undefined;\n const text =\n str(raw.tool_response) ??\n (blocks?.every((b) => isRecord(b) && b.type === 'input_text' && typeof b.text === 'string')\n ? blocks.map((b) => String((b as Record<string, unknown>).text)).join('\\n')\n : undefined);\n if (text !== undefined) tool.result = { text };\n if (tool.kind === 'shell' && text !== undefined && hasErrorMarker(text)) tool.ok = false;\n }\n input.tool = tool;\n }\n return input;\n}\n\n/**\n * Pure. `null` when there is nothing to say (the daemon answers 204).\n *\n * Two envelopes, because Codex has two: context beside the turn on prompt,\n * tool and start events, and on Stop/SubagentStop only `decision: block` with\n * the words as the `reason`, which the captured sessions show continues the\n * turn and trips `stop_hook_active` on the next stop. Both wire structs deny\n * unknown fields, so nothing else rides along.\n */\nexport function encode(emit: Emit | null, input: HookInput): unknown {\n if (emit === null || emit.context === undefined || emit.context.length === 0) return null;\n const text = emit.context.slice(0, CONTEXT_MAX);\n if (BLOCK_EVENTS.has(input.event)) return { decision: 'block', reason: text };\n return { hookSpecificOutput: { hookEventName: input.native.event, additionalContext: text } };\n}\n"],"mappings":";;;;;;AA4BO,IAAM,aAAa;AA2CnB,IAAM,iBAAiB,IAAI,OAAO;AAIlC,IAAM,qBAAqB,IAAI,OAAO;AAsBtC,IAAM,cAAc;;;ACnFpB,IAAM,gBAAmC;AAAA;AAAA,EAE9C;AAAA,EACA;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA;A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AACxC,QAAI,UAAU,cAAc;AAI1B,YAAM,SAAS,MAAM,QAAQ,IAAI,aAAa,IAAI,IAAI,gBAAgB;AACtE,YAAM,OACJ,IAAI,IAAI,aAAa,MACpB,QAAQ,MAAM,CAAC,MAAM,SAAS,CAAC,KAAK,EAAE,SAAS,gBAAgB,OAAO,EAAE,SAAS,QAAQ,IACtF,OAAO,IAAI,CAAC,MAAM,OAAQ,EAA8B,IAAI,CAAC,EAAE,KAAK,IAAI,IACxE;AACN,UAAI,SAAS,OAAW,MAAK,SAAS,EAAE,KAAK;AAC7C,UAAI,KAAK,SAAS,WAAW,SAAS,UAAa,eAAe,IAAI,EAAG,MAAK,KAAK;AAAA,IACrF;AACA,UAAM,OAAO;AAAA,EACf;AACA,SAAO;AACT;AAWO,SAAS,OAAO,MAAmB,OAA2B;AACnE,MAAI,SAAS,QAAQ,KAAK,YAAY,UAAa,KAAK,QAAQ,WAAW,EAAG,QAAO;AACrF,QAAM,OAAO,KAAK,QAAQ,MAAM,GAAG,WAAW;AAC9C,MAAI,aAAa,IAAI,MAAM,KAAK,EAAG,QAAO,EAAE,UAAU,SAAS,QAAQ,KAAK;AAC5E,SAAO,EAAE,oBAAoB,EAAE,eAAe,MAAM,OAAO,OAAO,mBAAmB,KAAK,EAAE;AAC9F;","names":[]}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
external_exports
|
|
4
|
+
} from "./chunk-SNNSAGMT.js";
|
|
5
|
+
import {
|
|
6
|
+
writeFileAtomic
|
|
7
|
+
} from "./chunk-7WEQQJLG.js";
|
|
8
|
+
import {
|
|
9
|
+
CliError
|
|
10
|
+
} from "./chunk-3UCIG4TG.js";
|
|
11
|
+
import {
|
|
12
|
+
passphraseRecordPath
|
|
13
|
+
} from "./chunk-OJNTCYQQ.js";
|
|
14
|
+
|
|
15
|
+
// src/lib/passphrase-record.ts
|
|
16
|
+
import { mkdir, readFile } from "node:fs/promises";
|
|
17
|
+
var PASSPHRASE_RECORD_SCHEMA_VERSION = 1;
|
|
18
|
+
var EntrySchema = external_exports.object({
|
|
19
|
+
store: external_exports.enum(["keychain", "secret-service", "dpapi", "file"]),
|
|
20
|
+
recordedAt: external_exports.string(),
|
|
21
|
+
by: external_exports.enum(["create", "repair", "replace"])
|
|
22
|
+
}).strict();
|
|
23
|
+
var RecordSchema = external_exports.object({
|
|
24
|
+
schemaVersion: external_exports.literal(PASSPHRASE_RECORD_SCHEMA_VERSION),
|
|
25
|
+
wallets: external_exports.record(external_exports.string(), external_exports.unknown())
|
|
26
|
+
}).strict();
|
|
27
|
+
var ADDRESS_RE = /^0x[0-9a-f]{40}$/;
|
|
28
|
+
async function readWallets(dir) {
|
|
29
|
+
try {
|
|
30
|
+
const parsed = RecordSchema.safeParse(
|
|
31
|
+
JSON.parse(await readFile(passphraseRecordPath(dir), "utf8"))
|
|
32
|
+
);
|
|
33
|
+
return parsed.success ? parsed.data.wallets : null;
|
|
34
|
+
} catch {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
async function readPassphraseRecord(dir, address) {
|
|
39
|
+
const key = address.toLowerCase();
|
|
40
|
+
if (!ADDRESS_RE.test(key)) return null;
|
|
41
|
+
const wallets = await readWallets(dir);
|
|
42
|
+
if (wallets === null) return null;
|
|
43
|
+
const raw = Object.entries(wallets).find(([k]) => k.toLowerCase() === key)?.[1];
|
|
44
|
+
const entry = EntrySchema.safeParse(raw);
|
|
45
|
+
return entry.success ? entry.data : null;
|
|
46
|
+
}
|
|
47
|
+
async function writePassphraseRecord(dir, address, entry, now = /* @__PURE__ */ new Date()) {
|
|
48
|
+
const key = address.toLowerCase();
|
|
49
|
+
if (!ADDRESS_RE.test(key)) {
|
|
50
|
+
throw new CliError("INTERNAL", `Not a wallet address: ${address}`);
|
|
51
|
+
}
|
|
52
|
+
const wallets = { ...await readWallets(dir) ?? {} };
|
|
53
|
+
for (const k of Object.keys(wallets)) if (k.toLowerCase() === key) delete wallets[k];
|
|
54
|
+
const record = {
|
|
55
|
+
store: entry.store,
|
|
56
|
+
recordedAt: now.toISOString(),
|
|
57
|
+
by: entry.by
|
|
58
|
+
};
|
|
59
|
+
wallets[key] = record;
|
|
60
|
+
await mkdir(dir, { recursive: true, mode: 448 });
|
|
61
|
+
await writeFileAtomic(
|
|
62
|
+
passphraseRecordPath(dir),
|
|
63
|
+
JSON.stringify({ schemaVersion: PASSPHRASE_RECORD_SCHEMA_VERSION, wallets }, null, 2) + "\n",
|
|
64
|
+
{ mode: 384, dirMode: 448 }
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export {
|
|
69
|
+
readPassphraseRecord,
|
|
70
|
+
writePassphraseRecord
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=chunk-3AIHRXKO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/passphrase-record.ts"],"sourcesContent":["import { mkdir, readFile } from 'node:fs/promises';\nimport { z } from 'zod';\nimport { writeFileAtomic } from './atomic-json';\nimport { CliError } from './errors';\nimport { passphraseRecordPath } from './paths';\nimport type { DurableStore } from './wallet-unlock';\n\n/**\n * WHERE EACH WALLET'S PASSPHRASE WAS SAVED, beside the wallet:\n * `<dataDir>/passphrase-store.json`, keyed by lowercase address.\n *\n * Why not a field in wallet.json: that file holds a funded key, and rewriting\n * it to record a storage choice risks the key for no gain. An older CLI also\n * reads wallet.json strictly, and must keep reading it after this one has\n * saved a passphrase somewhere new. So wallet.json is never touched, and the\n * choice lives here, where losing the file costs nothing: an absent,\n * unreadable, unparseable or newer-schema sidecar, or an unknown store value,\n * all read as \"no record\", which means today's lookup order.\n *\n * Hook-safe: `alive` and the hooks read it, so it imports only node, zod and\n * the lib modules the chunk graph allows. Reads never write (no lazy\n * migration): the router's read path stays free of side effects.\n *\n * Only `wallet create`, `wallet create --replace` and `wallet repair` write it,\n * and they hold `wallet.create.lock` while they do, so the read-modify-write\n * below never races another writer. An entry is never deleted in PR 1: a\n * restored archive (`mv wallet.<addr>.json.bak wallet.json`) finds its own\n * entry again by address.\n */\n\nexport const PASSPHRASE_RECORD_SCHEMA_VERSION = 1;\n\nexport interface PassphraseRecordEntry {\n store: DurableStore;\n recordedAt: string;\n by: 'create' | 'repair' | 'replace';\n}\n\nconst EntrySchema = z\n .object({\n store: z.enum(['keychain', 'secret-service', 'dpapi', 'file']),\n recordedAt: z.string(),\n by: z.enum(['create', 'repair', 'replace']),\n })\n .strict();\n\n/**\n * The envelope. Entries are checked one at a time ({@link EntrySchema}) so one\n * malformed entry hides only itself, and a write keeps every other address's\n * entry exactly as it found it.\n */\nconst RecordSchema = z\n .object({\n schemaVersion: z.literal(PASSPHRASE_RECORD_SCHEMA_VERSION),\n wallets: z.record(z.string(), z.unknown()),\n })\n .strict();\n\nconst ADDRESS_RE = /^0x[0-9a-f]{40}$/;\n\n/** The parsed sidecar's wallets, or null when there is none worth keeping. */\nasync function readWallets(dir: string): Promise<Record<string, unknown> | null> {\n try {\n const parsed = RecordSchema.safeParse(\n JSON.parse(await readFile(passphraseRecordPath(dir), 'utf8')),\n );\n return parsed.success ? parsed.data.wallets : null;\n } catch {\n return null;\n }\n}\n\n/**\n * This address's entry, or null for an absent file, unparseable JSON, a\n * `schemaVersion` other than 1, an unknown store value, or no entry for it.\n * Never throws: a sidecar Tenjin cannot read is the same as none.\n */\nexport async function readPassphraseRecord(\n dir: string,\n address: string,\n): Promise<PassphraseRecordEntry | null> {\n const key = address.toLowerCase();\n if (!ADDRESS_RE.test(key)) return null;\n const wallets = await readWallets(dir);\n if (wallets === null) return null;\n // Keys are written lowercase; a hand-edited mixed-case key still matches.\n const raw = Object.entries(wallets).find(([k]) => k.toLowerCase() === key)?.[1];\n const entry = EntrySchema.safeParse(raw);\n return entry.success ? entry.data : null;\n}\n\n/**\n * Record where `address`'s passphrase was saved, keeping every other entry.\n * The caller holds `wallet.create.lock`.\n *\n * A sidecar that does not parse is replaced by a fresh one holding only this\n * entry. That loses nothing a reader could use: a corrupt sidecar already\n * meant \"no record, today's behaviour\" for every address in it.\n */\nexport async function writePassphraseRecord(\n dir: string,\n address: string,\n entry: { store: DurableStore; by: PassphraseRecordEntry['by'] },\n now: Date = new Date(),\n): Promise<void> {\n const key = address.toLowerCase();\n if (!ADDRESS_RE.test(key)) {\n throw new CliError('INTERNAL', `Not a wallet address: ${address}`);\n }\n const wallets = { ...((await readWallets(dir)) ?? {}) };\n // One entry per address, however it was cased before.\n for (const k of Object.keys(wallets)) if (k.toLowerCase() === key) delete wallets[k];\n const record: PassphraseRecordEntry = {\n store: entry.store,\n recordedAt: now.toISOString(),\n by: entry.by,\n };\n wallets[key] = record;\n await mkdir(dir, { recursive: true, mode: 0o700 });\n await writeFileAtomic(\n passphraseRecordPath(dir),\n JSON.stringify({ schemaVersion: PASSPHRASE_RECORD_SCHEMA_VERSION, wallets }, null, 2) + '\\n',\n { mode: 0o600, dirMode: 0o700 },\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA,SAAS,OAAO,gBAAgB;AA8BzB,IAAM,mCAAmC;AAQhD,IAAM,cAAc,iBACjB,OAAO;AAAA,EACN,OAAO,iBAAE,KAAK,CAAC,YAAY,kBAAkB,SAAS,MAAM,CAAC;AAAA,EAC7D,YAAY,iBAAE,OAAO;AAAA,EACrB,IAAI,iBAAE,KAAK,CAAC,UAAU,UAAU,SAAS,CAAC;AAC5C,CAAC,EACA,OAAO;AAOV,IAAM,eAAe,iBAClB,OAAO;AAAA,EACN,eAAe,iBAAE,QAAQ,gCAAgC;AAAA,EACzD,SAAS,iBAAE,OAAO,iBAAE,OAAO,GAAG,iBAAE,QAAQ,CAAC;AAC3C,CAAC,EACA,OAAO;AAEV,IAAM,aAAa;AAGnB,eAAe,YAAY,KAAsD;AAC/E,MAAI;AACF,UAAM,SAAS,aAAa;AAAA,MAC1B,KAAK,MAAM,MA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]}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
resolveCodex,
|
|
4
|
+
withAppServer
|
|
5
|
+
} from "./chunk-E7SW44LM.js";
|
|
6
|
+
import {
|
|
7
|
+
CODEX_ALLOW_HOOK_COMMAND,
|
|
8
|
+
CODEX_ALLOW_HOOK_COMMAND_WINDOWS,
|
|
9
|
+
CODEX_HOOK_COUNT,
|
|
10
|
+
CODEX_LEGS
|
|
11
|
+
} from "./chunk-E7LGOMH6.js";
|
|
12
|
+
import {
|
|
13
|
+
HOOK_TOOL
|
|
14
|
+
} from "./chunk-UUGOUOVT.js";
|
|
15
|
+
import {
|
|
16
|
+
MARKETPLACE_NAME,
|
|
17
|
+
MCP_SERVER_NAME,
|
|
18
|
+
PLUGIN_ID
|
|
19
|
+
} from "./chunk-MPZUYCAP.js";
|
|
20
|
+
|
|
21
|
+
// src/router/codex-host.ts
|
|
22
|
+
import { execFile } from "node:child_process";
|
|
23
|
+
import { homedir } from "node:os";
|
|
24
|
+
import { promisify } from "node:util";
|
|
25
|
+
var CODEX_MARKETPLACE = MARKETPLACE_NAME;
|
|
26
|
+
var CODEX_PLUGIN = PLUGIN_ID;
|
|
27
|
+
var WEB_VERIFIED_VERSION = "0.154.0";
|
|
28
|
+
var exec = promisify(execFile);
|
|
29
|
+
function record(v) {
|
|
30
|
+
return v !== null && typeof v === "object" && !Array.isArray(v);
|
|
31
|
+
}
|
|
32
|
+
function at(v, ...keys) {
|
|
33
|
+
for (const key of keys) {
|
|
34
|
+
if (!record(v)) return void 0;
|
|
35
|
+
v = v[key];
|
|
36
|
+
}
|
|
37
|
+
return v;
|
|
38
|
+
}
|
|
39
|
+
async function codexVersion() {
|
|
40
|
+
const codex = resolveCodex();
|
|
41
|
+
if (codex === null) return null;
|
|
42
|
+
try {
|
|
43
|
+
const { stdout } = await exec(codex.cmd, [...codex.prefix, "--version"], {
|
|
44
|
+
timeout: 2e3,
|
|
45
|
+
maxBuffer: 16384,
|
|
46
|
+
windowsHide: true
|
|
47
|
+
});
|
|
48
|
+
return /(?:codex-cli|codex)\s+(\d+\.\d+\.\d+(?:[-+][\w.-]+)?)/.exec(stdout)?.[1] ?? null;
|
|
49
|
+
} catch {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async function readCodexConfig(cwd, timeoutMs = 500) {
|
|
54
|
+
return withAppServer(
|
|
55
|
+
homedir(),
|
|
56
|
+
process.env,
|
|
57
|
+
timeoutMs,
|
|
58
|
+
async (request) => at(await request("config/read", { includeLayers: false, cwd }), "config")
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
function listCodexHooks(cwd, timeoutMs) {
|
|
62
|
+
return withAppServer(
|
|
63
|
+
homedir(),
|
|
64
|
+
process.env,
|
|
65
|
+
timeoutMs,
|
|
66
|
+
(request) => request("hooks/list", { cwds: [cwd] })
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
function isMcpLeg(hook) {
|
|
70
|
+
return at(hook, "handlerType") === "mcpTool" && at(hook, "server") === MCP_SERVER_NAME && at(hook, "tool") === HOOK_TOOL;
|
|
71
|
+
}
|
|
72
|
+
function isCommandLeg(hook) {
|
|
73
|
+
return /\btenjin(?:\.cmd)?['"]? hook (prompt|native|shortfall)\b/.test(
|
|
74
|
+
String(at(hook, "command") ?? "")
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
function routingOf(ours) {
|
|
78
|
+
if (ours.some(isCommandLeg)) return "free";
|
|
79
|
+
return ours.filter(isMcpLeg).length === CODEX_LEGS.length ? "paid" : "unknown";
|
|
80
|
+
}
|
|
81
|
+
function isAllowHook(hook) {
|
|
82
|
+
return (
|
|
83
|
+
// On Windows, Codex lists the `commandWindows` form as the command.
|
|
84
|
+
[CODEX_ALLOW_HOOK_COMMAND, CODEX_ALLOW_HOOK_COMMAND_WINDOWS].includes(
|
|
85
|
+
String(at(hook, "command"))
|
|
86
|
+
) || String(at(hook, "key")).includes(":permission_request:")
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
function codexHookRows(list) {
|
|
90
|
+
const groups = at(list, "data");
|
|
91
|
+
if (!Array.isArray(groups)) return { state: "unknown", allowOff: false, routing: "unknown" };
|
|
92
|
+
const ours = groups.flatMap((group) => {
|
|
93
|
+
const hooks = at(group, "hooks");
|
|
94
|
+
return Array.isArray(hooks) ? hooks : [];
|
|
95
|
+
}).filter((hook) => at(hook, "pluginId") === CODEX_PLUGIN);
|
|
96
|
+
if (ours.length === 0) return { state: "absent", allowOff: false, routing: "unknown" };
|
|
97
|
+
const optedOut = (hook) => isAllowHook(hook) && at(hook, "enabled") === false;
|
|
98
|
+
const ready = ours.every(
|
|
99
|
+
(hook) => optedOut(hook) || at(hook, "enabled") === true && ["trusted", "managed"].includes(String(at(hook, "trustStatus")))
|
|
100
|
+
);
|
|
101
|
+
const routing = routingOf(ours);
|
|
102
|
+
const complete = ours.length === CODEX_HOOK_COUNT || routing === "free";
|
|
103
|
+
return {
|
|
104
|
+
state: complete && ready ? "trusted" : "review",
|
|
105
|
+
allowOff: ours.some(optedOut),
|
|
106
|
+
routing
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export {
|
|
111
|
+
CODEX_MARKETPLACE,
|
|
112
|
+
CODEX_PLUGIN,
|
|
113
|
+
WEB_VERIFIED_VERSION,
|
|
114
|
+
at,
|
|
115
|
+
codexVersion,
|
|
116
|
+
readCodexConfig,
|
|
117
|
+
listCodexHooks,
|
|
118
|
+
codexHookRows
|
|
119
|
+
};
|
|
120
|
+
//# sourceMappingURL=chunk-3DIL66VX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/router/codex-host.ts"],"sourcesContent":["import { execFile } from 'node:child_process';\nimport { homedir } from 'node:os';\nimport { promisify } from 'node:util';\nimport { withAppServer } from '../lib/codex-app-server';\nimport { resolveCodex } from '../lib/codex-bin';\nimport { HOOK_TOOL } from './hook-tool';\nimport { MARKETPLACE_NAME, MCP_SERVER_NAME, PLUGIN_ID } from './names';\nimport {\n CODEX_ALLOW_HOOK_COMMAND,\n CODEX_ALLOW_HOOK_COMMAND_WINDOWS,\n CODEX_HOOK_COUNT,\n CODEX_LEGS,\n} from './plugin-files';\n\n/**\n * WHAT CODEX SAYS ABOUT THE TENJIN PLUGIN, read through Codex's own app server\n * and CLI and never from its files.\n */\nexport const CODEX_MARKETPLACE = MARKETPLACE_NAME;\nexport const CODEX_PLUGIN = PLUGIN_ID;\n/** The last Codex build a `webrun` hook capture came from: a diagnostic, never a switch. */\nexport const WEB_VERIFIED_VERSION = '0.154.0';\n\nconst exec = promisify(execFile);\n\nfunction record(v: unknown): v is Record<string, unknown> {\n return v !== null && typeof v === 'object' && !Array.isArray(v);\n}\n\nexport function at(v: unknown, ...keys: string[]): unknown {\n for (const key of keys) {\n if (!record(v)) return undefined;\n v = v[key];\n }\n return v;\n}\n\nexport async function codexVersion(): Promise<string | null> {\n const codex = resolveCodex();\n if (codex === null) return null;\n try {\n const { stdout } = await exec(codex.cmd, [...codex.prefix, '--version'], {\n timeout: 2_000,\n maxBuffer: 16_384,\n windowsHide: true,\n });\n return /(?:codex-cli|codex)\\s+(\\d+\\.\\d+\\.\\d+(?:[-+][\\w.-]+)?)/.exec(stdout)?.[1] ?? null;\n } catch {\n return null;\n }\n}\n\n/** Codex's merged config for `cwd`, or null when its app server could not be asked. */\nexport async function readCodexConfig(cwd: string, timeoutMs = 500): Promise<unknown> {\n return withAppServer(homedir(), process.env, timeoutMs, async (request) =>\n at(await request('config/read', { includeLayers: false, cwd }), 'config'),\n );\n}\n\n/** Codex's hook list for `cwd` (`hooks/list`), or null when it could not be asked. */\nexport function listCodexHooks(cwd: string, timeoutMs: number): Promise<unknown> {\n return withAppServer(homedir(), process.env, timeoutMs, (request) =>\n request('hooks/list', { cwds: [cwd] }),\n );\n}\n\n/**\n * The plugin, as Codex's one `hooks/list` shows it. Every row carries its\n * `pluginId`, `enabled` and `trustStatus`: no Tenjin row means the plugin is\n * not installed (or is off), and every row present, enabled and trusted means\n * it is installed, on and trusted.\n */\nexport interface CodexHookRows {\n state: 'trusted' | 'review' | 'absent' | 'unknown';\n /** The request tool's allow hook is off in `/hooks`, so the tool asks first. */\n allowOff: boolean;\n /**\n * How the routing legs reach the router: `paid` when each is an `mcp_tool`\n * hook into the plugin's server, which pays the routing fee; `free` when a\n * plugin copy from an older build still runs them as commands, which cannot\n * pay it and offer nothing once the router charges it.\n */\n routing: 'paid' | 'free' | 'unknown';\n}\n\n/** A routing leg Codex calls on the plugin's own server. */\nfunction isMcpLeg(hook: unknown): boolean {\n return (\n at(hook, 'handlerType') === 'mcpTool' &&\n at(hook, 'server') === MCP_SERVER_NAME &&\n at(hook, 'tool') === HOOK_TOOL\n );\n}\n\n/** A routing leg an older build wrote as a command: `tenjin hook <kind> --harness codex`,\n * or the runtime launcher's quoted path in its place. */\nfunction isCommandLeg(hook: unknown): boolean {\n return /\\btenjin(?:\\.cmd)?['\"]? hook (prompt|native|shortfall)\\b/.test(\n String(at(hook, 'command') ?? ''),\n );\n}\n\nfunction routingOf(ours: unknown[]): CodexHookRows['routing'] {\n if (ours.some(isCommandLeg)) return 'free';\n return ours.filter(isMcpLeg).length === CODEX_LEGS.length ? 'paid' : 'unknown';\n}\n\nfunction isAllowHook(hook: unknown): boolean {\n return (\n // On Windows, Codex lists the `commandWindows` form as the command.\n [CODEX_ALLOW_HOOK_COMMAND, CODEX_ALLOW_HOOK_COMMAND_WINDOWS].includes(\n String(at(hook, 'command')),\n ) || String(at(hook, 'key')).includes(':permission_request:')\n );\n}\n\nexport function codexHookRows(list: unknown): CodexHookRows {\n const groups = at(list, 'data');\n if (!Array.isArray(groups)) return { state: 'unknown', allowOff: false, routing: 'unknown' };\n const ours = groups\n .flatMap((group) => {\n const hooks = at(group, 'hooks');\n return Array.isArray(hooks) ? (hooks as unknown[]) : [];\n })\n .filter((hook) => at(hook, 'pluginId') === CODEX_PLUGIN);\n if (ours.length === 0) return { state: 'absent', allowOff: false, routing: 'unknown' };\n // Turning the allow hook off is the documented opt-out, not a broken install.\n const optedOut = (hook: unknown) => isAllowHook(hook) && at(hook, 'enabled') === false;\n const ready = ours.every(\n (hook) =>\n optedOut(hook) ||\n (at(hook, 'enabled') === true &&\n ['trusted', 'managed'].includes(String(at(hook, 'trustStatus')))),\n );\n const routing = routingOf(ours);\n // An older build's copy carries one hook fewer; its legs are a routing warning.\n const complete = ours.length === CODEX_HOOK_COUNT || routing === 'free';\n return {\n state: complete && ready ? 'trusted' : 'review',\n allowOff: ours.some(optedOut),\n routing,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,gBAAgB;AACzB,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAgBnB,IAAM,oBAAoB;AAC1B,IAAM,eAAe;AAErB,IAAM,uBAAuB;AAEpC,IAAM,OAAO,UAAU,QAAQ;AAE/B,SAAS,OAAO,GAA0C;AACxD,SAAO,MAAM,QAAQ,OAAO,MAAM,YAAY,CAAC,MAAM,QAAQ,CAAC;AAChE;AAEO,SAAS,GAAG,MAAe,MAAyB;AACzD,aAAW,OAAO,MAAM;AACtB,QAAI,CAAC,OAAO,CAAC,EAAG,QAAO;AACvB,QAAI,EAAE,GAAG;AAAA,EACX;AACA,SAAO;AACT;AAEA,eAAsB,eAAuC;AAC3D,QAAM,QAAQ,aAAa;AAC3B,MAAI,UAAU,KAAM,QAAO;AAC3B,MAAI;AACF,UAAM,EAAE,OAAO,IAAI,MAAM,KAAK,MAAM,KAAK,CAAC,GAAG,MAAM,QAAQ,WAAW,GAAG;AAAA,MACvE,SAAS;AAAA,MACT,WAAW;AAAA,MACX,aAAa;AAAA,IACf,CAAC;AACD,WAAO,wDAAwD,KAAK,MAAM,IAAI,CAAC,KAAK;AAAA,EACtF,QAAQ;AACN,WAAO;AAAA,EACT;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B,WAAO,MAAM,QAAQ,KAAK,IAAK,QAAsB,CAAC;AAAA,EACxD,CAAC,EACA,OAAO,CAAC,SAAS,GAAG,MAAM,UAAU,MAAM,YAAY;AACzD,MAAI,KAAK,WAAW,EAAG,QAAO,EAAE,OAAO,UAAU,UAAU,OAAO,SAAS,UAAU;AAErF,QAAM,WAAW,CAAC,SAAkB,YAAY,IAAI,KAAK,GAAG,MAAM,SAAS,MAAM;AACjF,QAAM,QAAQ,KAAK;AAAA,IACjB,CAAC,SACC,SAAS,IAAI,KACZ,GAAG,MAAM,SAAS,MAAM,QACvB,CAAC,WAAW,SAAS,EAAE,SAAS,OAAO,GAAG,MAAM,aAAa,CAAC,CAAC;AAAA,EACrE;AACA,QAAM,UAAU,UAAU,IAAI;AAE9B,QAAM,WAAW,KAAK,WAAW,oBAAoB,YAAY;AACjE,SAAO;AAAA,IACL,OAAO,YAAY,QAAQ,YAAY;AAAA,IACvC,UAAU,KAAK,KAAK,QAAQ;AAAA,IAC5B;AAAA,EACF;AACF;","names":[]}
|
|
@@ -20,11 +20,21 @@ function useEnvProxy(env, setGlobal = nodeSetGlobalProxy ?? null) {
|
|
|
20
20
|
return "invalid";
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
+
function proxySkipped(env, supported = envProxySupported()) {
|
|
24
|
+
const name = proxyVariable(env);
|
|
25
|
+
if (name === void 0 || supported) return null;
|
|
26
|
+
return `this shell sets ${name}, which Node ${process.versions.node} cannot send downloads through`;
|
|
27
|
+
}
|
|
28
|
+
function proxyNodeStep(command) {
|
|
29
|
+
return `run \`${command}\` once with Node 24.14 or newer, which uses the proxy; Tenjin's own Node does from then on`;
|
|
30
|
+
}
|
|
23
31
|
|
|
24
32
|
export {
|
|
25
33
|
PROXY_VARIABLES,
|
|
26
34
|
proxyVariable,
|
|
27
35
|
envProxySupported,
|
|
28
|
-
useEnvProxy
|
|
36
|
+
useEnvProxy,
|
|
37
|
+
proxySkipped,
|
|
38
|
+
proxyNodeStep
|
|
29
39
|
};
|
|
30
|
-
//# sourceMappingURL=chunk-
|
|
40
|
+
//# sourceMappingURL=chunk-3FMZGI7I.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/env-proxy.ts"],"sourcesContent":["import * as http from 'node:http';\n\n/** Named, never quoted: a proxy URL can carry its own credentials. */\nexport const PROXY_VARIABLES = ['HTTPS_PROXY', 'https_proxy', 'HTTP_PROXY', 'http_proxy'] as const;\n\ntype SetGlobalProxy = (env: NodeJS.ProcessEnv) => () => void;\n\n/** Node 24.14 added it. `engines` admits 22.0, where it is absent. */\nconst nodeSetGlobalProxy = (http as { setGlobalProxyFromEnv?: SetGlobalProxy })\n .setGlobalProxyFromEnv;\n\n/** The first proxy variable this environment sets, or undefined. */\nexport function proxyVariable(env: NodeJS.ProcessEnv): string | undefined {\n return PROXY_VARIABLES.find((name) => (env[name] ?? '') !== '');\n}\n\n/** Can this Node route `fetch` through the proxy the environment names? */\nexport function envProxySupported(setGlobal: unknown = nodeSetGlobalProxy): boolean {\n return typeof setGlobal === 'function';\n}\n\nexport type EnvProxyResult = 'none' | 'set' | 'unsupported' | 'invalid';\n\n/**\n * Send `fetch` and `https.request` through the proxy the environment names.\n * Node's `fetch` ignores HTTPS_PROXY, HTTP_PROXY and NO_PROXY unless\n * NODE_USE_ENV_PROXY=1, so on a network where the proxy is the only way out the\n * harness reaches the internet and Tenjin does not. Called once by the bin\n * entry, so the CLI, the hooks and `tenjin mcp` all get it. Never throws: a\n * proxy URL Node cannot parse leaves the transport as it was.\n */\nexport function useEnvProxy(\n env: NodeJS.ProcessEnv,\n setGlobal: SetGlobalProxy | null = nodeSetGlobalProxy ?? null,\n): EnvProxyResult {\n if (proxyVariable(env) === undefined) return 'none';\n if (typeof setGlobal !== 'function') return 'unsupported';\n try {\n setGlobal(env);\n return 'set';\n } catch {\n return 'invalid';\n }\n}\n"],"mappings":";;;AAAA,YAAY,UAAU;AAGf,IAAM,kBAAkB,CAAC,eAAe,eAAe,cAAc,YAAY;AAKxF,IAAM,qBACH;AAGI,SAAS,cAAc,KAA4C;AACxE,SAAO,gBAAgB,KAAK,CAAC,UAAU,IAAI,IAAI,KAAK,QAAQ,EAAE;AAChE;AAGO,SAAS,kBAAkB,YAAqB,oBAA6B;AAClF,SAAO,OAAO,cAAc;AAC9B;AAYO,SAAS,YACd,KACA,YAAmC,sBAAsB,MACzC;AAChB,MAAI,cAAc,GAAG,MAAM,OAAW,QAAO;AAC7C,MAAI,OAAO,cAAc,WAAY,QAAO;AAC5C,MAAI;AACF,cAAU,GAAG;AACb,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/lib/env-proxy.ts"],"sourcesContent":["import * as http from 'node:http';\n\n/** Named, never quoted: a proxy URL can carry its own credentials. */\nexport const PROXY_VARIABLES = ['HTTPS_PROXY', 'https_proxy', 'HTTP_PROXY', 'http_proxy'] as const;\n\ntype SetGlobalProxy = (env: NodeJS.ProcessEnv) => () => void;\n\n/** Node 24.14 added it. `engines` admits 22.0, where it is absent. */\nconst nodeSetGlobalProxy = (http as { setGlobalProxyFromEnv?: SetGlobalProxy })\n .setGlobalProxyFromEnv;\n\n/** The first proxy variable this environment sets, or undefined. */\nexport function proxyVariable(env: NodeJS.ProcessEnv): string | undefined {\n return PROXY_VARIABLES.find((name) => (env[name] ?? '') !== '');\n}\n\n/** Can this Node route `fetch` through the proxy the environment names? */\nexport function envProxySupported(setGlobal: unknown = nodeSetGlobalProxy): boolean {\n return typeof setGlobal === 'function';\n}\n\nexport type EnvProxyResult = 'none' | 'set' | 'unsupported' | 'invalid';\n\n/**\n * Send `fetch` and `https.request` through the proxy the environment names.\n * Node's `fetch` ignores HTTPS_PROXY, HTTP_PROXY and NO_PROXY unless\n * NODE_USE_ENV_PROXY=1, so on a network where the proxy is the only way out the\n * harness reaches the internet and Tenjin does not. Called once by the bin\n * entry, so the CLI, the hooks and `tenjin mcp` all get it. Never throws: a\n * proxy URL Node cannot parse leaves the transport as it was.\n */\nexport function useEnvProxy(\n env: NodeJS.ProcessEnv,\n setGlobal: SetGlobalProxy | null = nodeSetGlobalProxy ?? null,\n): EnvProxyResult {\n if (proxyVariable(env) === undefined) return 'none';\n if (typeof setGlobal !== 'function') return 'unsupported';\n try {\n setGlobal(env);\n return 'set';\n } catch {\n return 'invalid';\n }\n}\n\n/**\n * Why this Node's requests go past the proxy the environment names, or null\n * when none is named or this Node can use it. On a network whose only way out\n * is that proxy, a download then fails however often it is retried while the\n * same Node runs it, so a failure is said as this, never as a bare retry.\n */\nexport function proxySkipped(\n env: NodeJS.ProcessEnv,\n supported: boolean = envProxySupported(),\n): string | null {\n const name = proxyVariable(env);\n if (name === undefined || supported) return null;\n return `this shell sets ${name}, which Node ${process.versions.node} cannot send downloads through`;\n}\n\n/** The step that works once a download skipped the proxy: one run on a Node that uses it. */\nexport function proxyNodeStep(command: string): string {\n return `run \\`${command}\\` once with Node 24.14 or newer, which uses the proxy; Tenjin's own Node does from then on`;\n}\n"],"mappings":";;;AAAA,YAAY,UAAU;AAGf,IAAM,kBAAkB,CAAC,eAAe,eAAe,cAAc,YAAY;AAKxF,IAAM,qBACH;AAGI,SAAS,cAAc,KAA4C;AACxE,SAAO,gBAAgB,KAAK,CAAC,UAAU,IAAI,IAAI,KAAK,QAAQ,EAAE;AAChE;AAGO,SAAS,kBAAkB,YAAqB,oBAA6B;AAClF,SAAO,OAAO,cAAc;AAC9B;AAYO,SAAS,YACd,KACA,YAAmC,sBAAsB,MACzC;AAChB,MAAI,cAAc,GAAG,MAAM,OAAW,QAAO;AAC7C,MAAI,OAAO,cAAc,WAAY,QAAO;AAC5C,MAAI;AACF,cAAU,GAAG;AACb,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAQO,SAAS,aACd,KACA,YAAqB,kBAAkB,GACxB;AACf,QAAM,OAAO,cAAc,GAAG;AAC9B,MAAI,SAAS,UAAa,UAAW,QAAO;AAC5C,SAAO,mBAAmB,IAAI,gBAAgB,QAAQ,SAAS,IAAI;AACrE;AAGO,SAAS,cAAc,SAAyB;AACrD,SAAO,SAAS,OAAO;AACzB;","names":[]}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// src/lib/errors.ts
|
|
4
|
+
var EXIT_BY_CODE = {
|
|
5
|
+
NODE_UNSUPPORTED: 1,
|
|
6
|
+
USAGE: 2,
|
|
7
|
+
CONFIG_INVALID: 2,
|
|
8
|
+
WALLET_EXISTS: 3,
|
|
9
|
+
WALLET_MISSING: 1,
|
|
10
|
+
WALLET_INVALID_KEY: 1,
|
|
11
|
+
PROVIDER_ERROR: 1,
|
|
12
|
+
RPC_ERROR: 1,
|
|
13
|
+
API_UNREACHABLE: 1,
|
|
14
|
+
CONTRACT_MISMATCH: 1,
|
|
15
|
+
REFUSED: 3,
|
|
16
|
+
NETWORK_ERROR: 1,
|
|
17
|
+
INTERNAL: 1,
|
|
18
|
+
NOT_IMPLEMENTED: 1,
|
|
19
|
+
POLICY_REFUSED: 3,
|
|
20
|
+
PAYMENT_FAILED: 4,
|
|
21
|
+
RESOURCE_NOT_FOUND: 1,
|
|
22
|
+
SEARCH_NOT_FOUND: 1,
|
|
23
|
+
RATE_LIMITED: 1,
|
|
24
|
+
// A publish awaiting confirmation or hard-blocked is understood-but-refused (3),
|
|
25
|
+
// the same posture as POLICY_REFUSED; a write that failed after approval is a
|
|
26
|
+
// settlement-class failure (4), like PAYMENT_FAILED.
|
|
27
|
+
NEEDS_CONFIRMATION: 3,
|
|
28
|
+
PUBLISH_BLOCKED: 3,
|
|
29
|
+
PUBLISH_FAILED: 4,
|
|
30
|
+
// A send that reverted or stalled AFTER the human approved it and it was
|
|
31
|
+
// broadcast: the post-decision failure class (4), like PAYMENT_FAILED.
|
|
32
|
+
SEND_FAILED: 4,
|
|
33
|
+
// A delete the operator confirmed and the server then refused: same class.
|
|
34
|
+
DELETE_FAILED: 4,
|
|
35
|
+
UPDATE_FAILED: 1,
|
|
36
|
+
// Refused BEFORE any signature existed: the Bazaar lane's fail-closed check.
|
|
37
|
+
REGISTRY_MISMATCH: 3,
|
|
38
|
+
// The seller's 402 challenge does not fit this process's header limit, so the
|
|
39
|
+
// terms could not be read and nothing was sent. Understood and refused (3),
|
|
40
|
+
// not a transport failure: the connection was fine and a retry changes
|
|
41
|
+
// nothing without an operator raising `--max-http-header-size`.
|
|
42
|
+
CHALLENGE_TOO_LARGE: 3
|
|
43
|
+
};
|
|
44
|
+
function exitCodeFor(code) {
|
|
45
|
+
return EXIT_BY_CODE[code];
|
|
46
|
+
}
|
|
47
|
+
var CliError = class extends Error {
|
|
48
|
+
code;
|
|
49
|
+
exitCode;
|
|
50
|
+
fix;
|
|
51
|
+
details;
|
|
52
|
+
constructor(code, message, opts = {}) {
|
|
53
|
+
super(message, opts.cause !== void 0 ? { cause: opts.cause } : void 0);
|
|
54
|
+
this.name = "CliError";
|
|
55
|
+
this.code = code;
|
|
56
|
+
this.exitCode = opts.exitCode ?? exitCodeFor(code);
|
|
57
|
+
this.fix = opts.fix;
|
|
58
|
+
this.details = opts.details;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export {
|
|
63
|
+
CliError
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=chunk-3UCIG4TG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/errors.ts"],"sourcesContent":["import type { ErrorCode } from '../schemas';\n\n/**\n * The process exit code is API (spec 10): 0 success, 1 runtime/network, 2 usage,\n * 3 understood-but-refused (policy refusal, publish confirmation/hard-block), 4 a\n * failure AFTER an approved spend or write (a settlement that failed, a publish\n * that failed post-consent).\n */\nexport type ExitCode = 1 | 2 | 3 | 4;\n\nexport interface CliErrorOptions {\n /** A copy-pasteable command or one-line remediation. */\n fix?: string;\n /** Structured detail for machine consumers; serialized into the envelope. */\n details?: unknown;\n /** Override the default exit code for this error's code. */\n exitCode?: ExitCode;\n /** Underlying cause, preserved on the Error but never serialized. */\n cause?: unknown;\n}\n\n/**\n * Default code -> exit-code mapping. USAGE/CONFIG_INVALID are malformed\n * invocations (2); WALLET_EXISTS/REFUSED are understood-but-refused (3);\n * everything else is a runtime/network failure (1). A CliError may override its\n * own exit code, but the table is the default every caller relies on.\n */\nconst EXIT_BY_CODE: Record<ErrorCode, ExitCode> = {\n NODE_UNSUPPORTED: 1,\n USAGE: 2,\n CONFIG_INVALID: 2,\n WALLET_EXISTS: 3,\n WALLET_MISSING: 1,\n WALLET_INVALID_KEY: 1,\n PROVIDER_ERROR: 1,\n RPC_ERROR: 1,\n API_UNREACHABLE: 1,\n CONTRACT_MISMATCH: 1,\n REFUSED: 3,\n NETWORK_ERROR: 1,\n INTERNAL: 1,\n NOT_IMPLEMENTED: 1,\n POLICY_REFUSED: 3,\n PAYMENT_FAILED: 4,\n RESOURCE_NOT_FOUND: 1,\n SEARCH_NOT_FOUND: 1,\n RATE_LIMITED: 1,\n // A publish awaiting confirmation or hard-blocked is understood-but-refused (3),\n // the same posture as POLICY_REFUSED; a write that failed after approval is a\n // settlement-class failure (4), like PAYMENT_FAILED.\n NEEDS_CONFIRMATION: 3,\n PUBLISH_BLOCKED: 3,\n PUBLISH_FAILED: 4,\n // A send that reverted or stalled AFTER the human approved it and it was\n // broadcast: the post-decision failure class (4), like PAYMENT_FAILED.\n SEND_FAILED: 4,\n // A delete the operator confirmed and the server then refused: same class.\n DELETE_FAILED: 4,\n UPDATE_FAILED: 1,\n // Refused BEFORE any signature existed: the Bazaar lane's fail-closed check.\n REGISTRY_MISMATCH: 3,\n // The seller's 402 challenge does not fit this process's header limit, so the\n // terms could not be read and nothing was sent. Understood and refused (3),\n // not a transport failure: the connection was fine and a retry changes\n // nothing without an operator raising `--max-http-header-size`.\n CHALLENGE_TOO_LARGE: 3,\n};\n\nexport function exitCodeFor(code: ErrorCode): ExitCode {\n return EXIT_BY_CODE[code];\n}\n\n/**\n * The one error type commands throw. It carries the machine `code`, the resolved\n * `exitCode`, and an optional `fix`/`details` that flow straight into the failure\n * envelope. Commands throw it; the CLI dispatcher catches, serializes, and exits.\n */\nexport class CliError extends Error {\n readonly code: ErrorCode;\n readonly exitCode: ExitCode;\n readonly fix?: string;\n readonly details?: unknown;\n\n constructor(code: ErrorCode, message: string, opts: CliErrorOptions = {}) {\n super(message, opts.cause !== undefined ? { cause: opts.cause } : undefined);\n this.name = 'CliError';\n this.code = code;\n this.exitCode = opts.exitCode ?? exitCodeFor(code);\n this.fix = opts.fix;\n this.details = opts.details;\n }\n}\n"],"mappings":";;;AA2BA,IAAM,eAA4C;AAAA,EAChD,kBAAkB;AAAA,EAClB,OAAO;AAAA,EACP,gBAAgB;AAAA,EAChB,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,oBAAoB;AAAA,EACpB,gBAAgB;AAAA,EAChB,WAAW;AAAA,EACX,iBAAiB;AAAA,EACjB,mBAAmB;AAAA,EACnB,SAAS;AAAA,EACT,eAAe;AAAA,EACf,UAAU;AAAA,EACV,iBAAiB;AAAA,EACjB,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,oBAAoB;AAAA,EACpB,kBAAkB;AAAA,EAClB,cAAc;AAAA;AAAA;AAAA;AAAA,EAId,oBAAoB;AAAA,EACpB,iBAAiB;AAAA,EACjB,gBAAgB;AAAA;AAAA;AAAA,EAGhB,aAAa;AAAA;AAAA,EAEb,eAAe;AAAA,EACf,eAAe;AAAA;AAAA,EAEf,mBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA,EAKnB,qBAAqB;AACvB;AAEO,SAAS,YAAY,MAA2B;AACrD,SAAO,aAAa,IAAI;AAC1B;AAOO,IAAM,WAAN,cAAuB,MAAM;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAET,YAAY,MAAiB,SAAiB,OAAwB,CAAC,GAAG;AACxE,UAAM,SAAS,KAAK,UAAU,SAAY,EAAE,OAAO,KAAK,MAAM,IAAI,MAAS;AAC3E,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,WAAW,KAAK,YAAY,YAAY,IAAI;AACjD,SAAK,MAAM,KAAK;AAChB,SAAK,UAAU,KAAK;AAAA,EACtB;AACF;","names":[]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
hashTypedData
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-PJNENX2A.js";
|
|
5
5
|
import {
|
|
6
6
|
getAddress,
|
|
7
7
|
keccak256,
|
|
8
8
|
toBytes,
|
|
9
9
|
toHex
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-2GP3HRYK.js";
|
|
11
11
|
|
|
12
12
|
// node_modules/.pnpm/@x402+evm@2.28.0_typescript@6.0.3/node_modules/@x402/evm/dist/esm/chunk-EKCH75YB.mjs
|
|
13
13
|
var EIP155_NETWORK_REGEX = /^eip155:(\d+)$/;
|
|
@@ -156,4 +156,4 @@ export {
|
|
|
156
156
|
computeChannelId,
|
|
157
157
|
getBatchSettlementEip712Domain
|
|
158
158
|
};
|
|
159
|
-
//# sourceMappingURL=chunk-
|
|
159
|
+
//# sourceMappingURL=chunk-445VQTVM.js.map
|