tenjin-cli 0.1.0-alpha.3 → 0.1.0-alpha.31
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/NOTICE.md +54 -7
- package/README.md +100 -266
- package/dist/{_esm-FEASBWRP.js → _esm-MEXZI5DL.js} +9 -10
- package/dist/alive-J64H46HI.js +31 -0
- package/dist/{ccip-NQXCEK2U.js → ccip-7RMRLAGV.js} +4 -4
- package/dist/{ccip-XR5NE5QK.js → ccip-NLCSCHKI.js} +5 -5
- package/dist/chunk-27EPWVOY.js +108 -0
- package/dist/chunk-27EPWVOY.js.map +1 -0
- package/dist/chunk-2SNUOHAT.js +75 -0
- package/dist/chunk-2SNUOHAT.js.map +1 -0
- package/dist/{chunk-Z6MFJV5Z.js → chunk-2XLC3AEX.js} +857 -504
- package/dist/chunk-2XLC3AEX.js.map +1 -0
- package/dist/chunk-3623BLPV.js +184 -0
- package/dist/chunk-3623BLPV.js.map +1 -0
- package/dist/chunk-3UCIG4TG.js +65 -0
- package/dist/chunk-3UCIG4TG.js.map +1 -0
- package/dist/chunk-4ZZO6ULA.js +151 -0
- package/dist/chunk-4ZZO6ULA.js.map +1 -0
- package/dist/chunk-5C32RLTA.js +115 -0
- package/dist/chunk-5C32RLTA.js.map +1 -0
- package/dist/{chunk-ZMHYXMO6.js → chunk-5IEP5EGE.js} +3 -3
- package/dist/chunk-5K5W4S66.js +105 -0
- package/dist/chunk-5K5W4S66.js.map +1 -0
- package/dist/chunk-5MARFNSB.js +2018 -0
- package/dist/chunk-5MARFNSB.js.map +1 -0
- package/dist/{chunk-CYOF7ROH.js → chunk-6E5R45ZO.js} +3 -3
- package/dist/chunk-77TCKDEC.js +1987 -0
- package/dist/chunk-77TCKDEC.js.map +1 -0
- package/dist/chunk-7EKYXMUO.js +7536 -0
- package/dist/chunk-7EKYXMUO.js.map +1 -0
- package/dist/chunk-7Q5FDF65.js +159 -0
- package/dist/chunk-7Q5FDF65.js.map +1 -0
- package/dist/chunk-7QKHZQKW.js +1680 -0
- package/dist/chunk-7QKHZQKW.js.map +1 -0
- package/dist/{chunk-MUBUQVC3.js → chunk-7WEQQJLG.js} +6 -5
- package/dist/{chunk-MUBUQVC3.js.map → chunk-7WEQQJLG.js.map} +1 -1
- package/dist/chunk-7WU4OPLP.js +244 -0
- package/dist/chunk-7WU4OPLP.js.map +1 -0
- package/dist/chunk-7ZRL2LBQ.js +192 -0
- package/dist/chunk-7ZRL2LBQ.js.map +1 -0
- package/dist/chunk-A36LQPHV.js +29 -0
- package/dist/chunk-A36LQPHV.js.map +1 -0
- package/dist/chunk-AGZ7PJKY.js +326 -0
- package/dist/chunk-AGZ7PJKY.js.map +1 -0
- package/dist/chunk-AKWGE6JQ.js +49 -0
- package/dist/chunk-AKWGE6JQ.js.map +1 -0
- package/dist/chunk-B7HUUJOK.js +29 -0
- package/dist/chunk-B7HUUJOK.js.map +1 -0
- package/dist/{chunk-S3IGX57D.js → chunk-BL3332HQ.js} +290 -7361
- package/dist/chunk-BL3332HQ.js.map +1 -0
- package/dist/{chunk-5CLSD5YN.js → chunk-BPMWXTFX.js} +2 -2
- package/dist/chunk-D65GNPS3.js +12708 -0
- package/dist/chunk-D65GNPS3.js.map +1 -0
- package/dist/chunk-DOQGNFHM.js +121 -0
- package/dist/chunk-DOQGNFHM.js.map +1 -0
- package/dist/{chunk-YALGASEU.js → chunk-EGELTSPU.js} +2 -2
- package/dist/chunk-FW75G2W4.js +406 -0
- package/dist/chunk-FW75G2W4.js.map +1 -0
- package/dist/chunk-GA7JETVM.js +150 -0
- package/dist/chunk-GA7JETVM.js.map +1 -0
- package/dist/chunk-I3EQFHCD.js +175 -0
- package/dist/chunk-I3EQFHCD.js.map +1 -0
- package/dist/chunk-JKKAIPTU.js +108 -0
- package/dist/chunk-JKKAIPTU.js.map +1 -0
- package/dist/{chunk-QVX5MWJZ.js → chunk-JRGFKVAZ.js} +2 -2
- package/dist/{chunk-NCE5NSN6.js → chunk-K3I7C2MO.js} +142 -12
- package/dist/chunk-K3I7C2MO.js.map +1 -0
- package/dist/chunk-K72RURN3.js +239 -0
- package/dist/chunk-K72RURN3.js.map +1 -0
- package/dist/{chunk-HIVZG55D.js → chunk-KG3D7FIF.js} +2 -2
- package/dist/chunk-KOGZDMHO.js +21 -0
- package/dist/chunk-KOGZDMHO.js.map +1 -0
- package/dist/chunk-KXQ4UIP7.js +228 -0
- package/dist/chunk-KXQ4UIP7.js.map +1 -0
- package/dist/chunk-KXVP2VKA.js +194 -0
- package/dist/chunk-KXVP2VKA.js.map +1 -0
- package/dist/chunk-LEFIX6RS.js +100 -0
- package/dist/chunk-LEFIX6RS.js.map +1 -0
- package/dist/chunk-LHHMV4GU.js +27 -0
- package/dist/chunk-LHHMV4GU.js.map +1 -0
- package/dist/{chunk-YBMMV4Y4.js → chunk-MEFB5KHA.js} +13 -5
- package/dist/chunk-MEFB5KHA.js.map +1 -0
- package/dist/chunk-MNXS2U45.js +1768 -0
- package/dist/chunk-MNXS2U45.js.map +1 -0
- package/dist/{chunk-UGX7YPX2.js → chunk-NEFNKLBE.js} +9 -11
- package/dist/{chunk-UGX7YPX2.js.map → chunk-NEFNKLBE.js.map} +1 -1
- package/dist/chunk-OHRR5OYM.js +63 -0
- package/dist/chunk-OHRR5OYM.js.map +1 -0
- package/dist/chunk-ORWL5BSN.js +269 -0
- package/dist/chunk-ORWL5BSN.js.map +1 -0
- package/dist/chunk-P4NH7OUK.js +398 -0
- package/dist/chunk-P4NH7OUK.js.map +1 -0
- package/dist/{chunk-ZABPQJ3M.js → chunk-POUWHWID.js} +2 -2
- package/dist/chunk-QSCPK4F5.js +145 -0
- package/dist/chunk-QSCPK4F5.js.map +1 -0
- package/dist/chunk-QXP3Z3JN.js +131 -0
- package/dist/chunk-QXP3Z3JN.js.map +1 -0
- package/dist/{chunk-XJIW7USF.js → chunk-R5LCN54M.js} +118 -9
- package/dist/chunk-R5LCN54M.js.map +1 -0
- package/dist/chunk-S4SAZ7OD.js +30 -0
- package/dist/chunk-S4SAZ7OD.js.map +1 -0
- package/dist/chunk-SJLTEINJ.js +117 -0
- package/dist/chunk-SJLTEINJ.js.map +1 -0
- package/dist/{chunk-RRN3YTK7.js → chunk-TTNESUPQ.js} +3 -3
- package/dist/chunk-UKY4CHNC.js +498 -0
- package/dist/chunk-UKY4CHNC.js.map +1 -0
- package/dist/chunk-UQUOVWBG.js +114 -0
- package/dist/chunk-UQUOVWBG.js.map +1 -0
- package/dist/chunk-V6BSF6OC.js +260 -0
- package/dist/chunk-V6BSF6OC.js.map +1 -0
- package/dist/chunk-WJXLQXJY.js +43 -0
- package/dist/chunk-WJXLQXJY.js.map +1 -0
- package/dist/chunk-WK7F3B2E.js +114 -0
- package/dist/chunk-WK7F3B2E.js.map +1 -0
- package/dist/chunk-XKESD27X.js +10 -0
- package/dist/chunk-XKESD27X.js.map +1 -0
- package/dist/chunk-XQJXNMSB.js +23 -0
- package/dist/chunk-XQJXNMSB.js.map +1 -0
- package/dist/{chunk-HSDCI7OV.js → chunk-XZKD7DIF.js} +3 -3
- package/dist/chunk-Y527D4TV.js +56 -0
- package/dist/chunk-Y527D4TV.js.map +1 -0
- package/dist/chunk-YFPY4ONH.js +127 -0
- package/dist/chunk-YFPY4ONH.js.map +1 -0
- package/dist/{chunk-OYMYCW7J.js → chunk-YVFXE7RR.js} +606 -97
- package/dist/chunk-YVFXE7RR.js.map +1 -0
- package/dist/clack-EZ7TDWQU.js +19 -0
- package/dist/claude-cli-2YKABJJZ.js +31 -0
- package/dist/{cli-SBXI5AMS.js → cli-D5OE3URZ.js} +458 -218
- package/dist/cli-D5OE3URZ.js.map +1 -0
- package/dist/codex-event-PPNVRRDH.js +16 -0
- package/dist/codex-host-2RJOJW2B.js +28 -0
- package/dist/codex-install-UUZ6QMBQ.js +221 -0
- package/dist/codex-install-UUZ6QMBQ.js.map +1 -0
- package/dist/config-ZD4OB2DO.js +51 -0
- package/dist/dist-3LOO6M4U.js +2842 -0
- package/dist/dist-3LOO6M4U.js.map +1 -0
- package/dist/doctor-KBR34Q4B.js +601 -0
- package/dist/doctor-KBR34Q4B.js.map +1 -0
- package/dist/env-proxy-XL4P73MZ.js +15 -0
- package/dist/{ethersCompat-Df4a6QIZ-3YZIAXDK.js → ethersCompat-Df4a6QIZ-THAVUGIJ.js} +5 -5
- package/dist/ethersCompat-Df4a6QIZ-THAVUGIJ.js.map +1 -0
- package/dist/fund-5ITKQGYF.js +372 -0
- package/dist/fund-5ITKQGYF.js.map +1 -0
- package/dist/hook-command-4TYCHHRL.js +39 -0
- package/dist/hook-command-4TYCHHRL.js.map +1 -0
- package/dist/hosts/claude/.claude-plugin/marketplace.json +19 -0
- package/dist/hosts/claude/tenjin/.claude-plugin/plugin.json +15 -0
- package/dist/hosts/claude/tenjin/.mcp.json +12 -0
- package/dist/hosts/claude/tenjin/hooks/hooks.json +224 -0
- package/dist/hosts/claude/tenjin/hooks/register.tsx +589 -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 +12 -0
- package/dist/hosts/codex/tenjin/hooks/hooks.json +52 -0
- package/dist/hosts-FWZOV26H.js +216 -0
- package/dist/hosts-FWZOV26H.js.map +1 -0
- package/dist/index.js +21 -2
- package/dist/index.js.map +1 -1
- package/dist/install-XWGE4Q7L.js +77 -0
- package/dist/install-XWGE4Q7L.js.map +1 -0
- package/dist/install-identity-K7EJIQFP.js +30 -0
- package/dist/install-identity-K7EJIQFP.js.map +1 -0
- package/dist/install-wallet-XQ6XFZV4.js +117 -0
- package/dist/install-wallet-XQ6XFZV4.js.map +1 -0
- package/dist/mcp-3LIJSSJB.js +13553 -0
- package/dist/mcp-3LIJSSJB.js.map +1 -0
- package/dist/package-ZKQFDWLE.js +37 -0
- package/dist/package-ZKQFDWLE.js.map +1 -0
- package/dist/paths-POPTXJO6.js +61 -0
- package/dist/paths-POPTXJO6.js.map +1 -0
- package/dist/pay-WHBERZ3W.js +55 -0
- package/dist/pay-WHBERZ3W.js.map +1 -0
- package/dist/payments-KVICEKD2.js +110 -0
- package/dist/payments-KVICEKD2.js.map +1 -0
- package/dist/plugin-registration-5TIA564H.js +54 -0
- package/dist/plugin-registration-5TIA564H.js.map +1 -0
- package/dist/redact-6W23GGJC.js +15 -0
- package/dist/redact-6W23GGJC.js.map +1 -0
- package/dist/{secp256k1-N3ZHU7LB.js → secp256k1-ZZZT2CAX.js} +3 -3
- package/dist/secp256k1-ZZZT2CAX.js.map +1 -0
- package/dist/send-7G7Y7DLN.js +228 -0
- package/dist/send-7G7Y7DLN.js.map +1 -0
- package/dist/status-OF7RH5HM.js +120 -0
- package/dist/status-OF7RH5HM.js.map +1 -0
- package/dist/status-line-XOUE6MPL.js +90 -0
- package/dist/status-line-XOUE6MPL.js.map +1 -0
- package/dist/uninstall-JXUAFNDB.js +158 -0
- package/dist/uninstall-JXUAFNDB.js.map +1 -0
- package/dist/update-ZKUERSO2.js +44 -0
- package/dist/update-ZKUERSO2.js.map +1 -0
- package/dist/usdc-OGOGEHV2.js +40 -0
- package/dist/usdc-OGOGEHV2.js.map +1 -0
- package/dist/{viemAdapter-By13KInL-ZZE6UV4Y.js → viemAdapter-By13KInL-S3DA7DFW.js} +5 -5
- package/dist/viemAdapter-By13KInL-S3DA7DFW.js.map +1 -0
- package/dist/wallet-2HA6W4R4.js +43 -0
- package/dist/wallet-2HA6W4R4.js.map +1 -0
- package/dist/wallet-kdf-worker.mjs +980 -0
- package/docs/agent-permissions.md +196 -0
- package/docs/safety-model.md +59 -0
- package/docs/troubleshooting.md +13 -0
- package/package.json +28 -19
- package/LICENSE +0 -21
- package/dist/buy-EE6SEXP6.js +0 -1598
- package/dist/buy-EE6SEXP6.js.map +0 -1
- package/dist/candidate-ERMSYYQZ.js +0 -127
- package/dist/candidate-ERMSYYQZ.js.map +0 -1
- package/dist/chunk-3OV7E5G5.js +0 -18
- package/dist/chunk-3OV7E5G5.js.map +0 -1
- package/dist/chunk-4ONXEEQL.js +0 -152
- package/dist/chunk-4ONXEEQL.js.map +0 -1
- package/dist/chunk-662MSGZB.js +0 -286
- package/dist/chunk-662MSGZB.js.map +0 -1
- package/dist/chunk-7KUW4MJD.js +0 -59
- package/dist/chunk-7KUW4MJD.js.map +0 -1
- package/dist/chunk-AWPAWHNX.js +0 -333
- package/dist/chunk-AWPAWHNX.js.map +0 -1
- package/dist/chunk-DXTQ3CSI.js +0 -171
- package/dist/chunk-DXTQ3CSI.js.map +0 -1
- package/dist/chunk-ESPNTPQ2.js +0 -207
- package/dist/chunk-ESPNTPQ2.js.map +0 -1
- package/dist/chunk-FJPLRISB.js +0 -79
- package/dist/chunk-FJPLRISB.js.map +0 -1
- package/dist/chunk-GO75V3NZ.js +0 -160
- package/dist/chunk-GO75V3NZ.js.map +0 -1
- package/dist/chunk-JPHG2JW3.js +0 -96
- package/dist/chunk-JPHG2JW3.js.map +0 -1
- package/dist/chunk-NCE5NSN6.js.map +0 -1
- package/dist/chunk-OYMYCW7J.js.map +0 -1
- package/dist/chunk-RY4XKNV3.js +0 -140
- package/dist/chunk-RY4XKNV3.js.map +0 -1
- package/dist/chunk-S3IGX57D.js.map +0 -1
- package/dist/chunk-TLCMMYLY.js +0 -126
- package/dist/chunk-TLCMMYLY.js.map +0 -1
- package/dist/chunk-UO22YNY4.js +0 -69
- package/dist/chunk-UO22YNY4.js.map +0 -1
- package/dist/chunk-XHC6FCGZ.js +0 -261
- package/dist/chunk-XHC6FCGZ.js.map +0 -1
- package/dist/chunk-XJIW7USF.js.map +0 -1
- package/dist/chunk-YBMMV4Y4.js.map +0 -1
- package/dist/chunk-YN5SHIXQ.js +0 -126
- package/dist/chunk-YN5SHIXQ.js.map +0 -1
- package/dist/chunk-Z52RA3NC.js +0 -137
- package/dist/chunk-Z52RA3NC.js.map +0 -1
- package/dist/chunk-Z6MFJV5Z.js.map +0 -1
- package/dist/cli-SBXI5AMS.js.map +0 -1
- package/dist/config-VELDKLHY.js +0 -21
- package/dist/doctor-T3KWNNP2.js +0 -20
- package/dist/inspect-LMKOXE4Y.js +0 -96
- package/dist/inspect-LMKOXE4Y.js.map +0 -1
- package/dist/install-LEX3ENQ6.js +0 -387
- package/dist/install-LEX3ENQ6.js.map +0 -1
- package/dist/lookup-ZPN2Q67N.js +0 -129
- package/dist/lookup-ZPN2Q67N.js.map +0 -1
- package/dist/outcome-N7TAK6WR.js +0 -66
- package/dist/outcome-N7TAK6WR.js.map +0 -1
- package/dist/publish-BKBQQAW4.js +0 -1478
- package/dist/publish-BKBQQAW4.js.map +0 -1
- package/dist/usdc-JIAJW4SV.js +0 -22
- package/dist/wallet-CWEMYVIH.js +0 -179
- package/dist/wallet-CWEMYVIH.js.map +0 -1
- package/dist/wallet-PA54CRBL.js +0 -30
- package/skills/tenjin/SKILL.md +0 -199
- package/skills/tenjin-publish/SKILL.md +0 -111
- package/skills/tenjin-search/SKILL.md +0 -133
- /package/dist/{_esm-FEASBWRP.js.map → _esm-MEXZI5DL.js.map} +0 -0
- /package/dist/{ccip-NQXCEK2U.js.map → alive-J64H46HI.js.map} +0 -0
- /package/dist/{ccip-XR5NE5QK.js.map → ccip-7RMRLAGV.js.map} +0 -0
- /package/dist/{config-VELDKLHY.js.map → ccip-NLCSCHKI.js.map} +0 -0
- /package/dist/{chunk-ZMHYXMO6.js.map → chunk-5IEP5EGE.js.map} +0 -0
- /package/dist/{chunk-CYOF7ROH.js.map → chunk-6E5R45ZO.js.map} +0 -0
- /package/dist/{chunk-5CLSD5YN.js.map → chunk-BPMWXTFX.js.map} +0 -0
- /package/dist/{chunk-YALGASEU.js.map → chunk-EGELTSPU.js.map} +0 -0
- /package/dist/{chunk-QVX5MWJZ.js.map → chunk-JRGFKVAZ.js.map} +0 -0
- /package/dist/{chunk-HIVZG55D.js.map → chunk-KG3D7FIF.js.map} +0 -0
- /package/dist/{chunk-ZABPQJ3M.js.map → chunk-POUWHWID.js.map} +0 -0
- /package/dist/{chunk-RRN3YTK7.js.map → chunk-TTNESUPQ.js.map} +0 -0
- /package/dist/{chunk-HSDCI7OV.js.map → chunk-XZKD7DIF.js.map} +0 -0
- /package/dist/{doctor-T3KWNNP2.js.map → clack-EZ7TDWQU.js.map} +0 -0
- /package/dist/{ethersCompat-Df4a6QIZ-3YZIAXDK.js.map → claude-cli-2YKABJJZ.js.map} +0 -0
- /package/dist/{secp256k1-N3ZHU7LB.js.map → codex-event-PPNVRRDH.js.map} +0 -0
- /package/dist/{usdc-JIAJW4SV.js.map → codex-host-2RJOJW2B.js.map} +0 -0
- /package/dist/{viemAdapter-By13KInL-ZZE6UV4Y.js.map → config-ZD4OB2DO.js.map} +0 -0
- /package/dist/{wallet-PA54CRBL.js.map → env-proxy-XL4P73MZ.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;AA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AAU,IAAI,IAAI,aAAa,CAAC,CAAC;AAC/E,UAAM,SAAS,IAAI,IAAI,WAAW;AAClC,QAAI,WAAW,OAAW,MAAK,SAAS;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,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":[]}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
evaluateSpendPolicy
|
|
4
|
+
} from "./chunk-2SNUOHAT.js";
|
|
5
|
+
import {
|
|
6
|
+
hasCode
|
|
7
|
+
} from "./chunk-2I4QTOLB.js";
|
|
8
|
+
import {
|
|
9
|
+
formatUsdDisplay
|
|
10
|
+
} from "./chunk-Y527D4TV.js";
|
|
11
|
+
|
|
12
|
+
// src/router/fee.ts
|
|
13
|
+
import { createHash } from "node:crypto";
|
|
14
|
+
import { mkdir, open, readFile, readdir, rm } from "node:fs/promises";
|
|
15
|
+
import { join } from "node:path";
|
|
16
|
+
var ROUTE_PAID_PATH = "/api/x402-router/route";
|
|
17
|
+
var ROUTING_FEE_ATOMIC = 3000n;
|
|
18
|
+
var CHANNEL_DEPOSIT_ATOMIC = 250000n;
|
|
19
|
+
var SUGGESTED_FUND_USD = "5";
|
|
20
|
+
var ROUTING_DEPOSIT_KEY = "routing-deposit:";
|
|
21
|
+
var REFUSED = {
|
|
22
|
+
not_allowlisted: "not_allowlisted",
|
|
23
|
+
session_budget_exceeded: "budget_reached",
|
|
24
|
+
above_auto_spend: "limit_below_deposit"
|
|
25
|
+
};
|
|
26
|
+
function refusedWhy(reason) {
|
|
27
|
+
return REFUSED[reason] ?? reason;
|
|
28
|
+
}
|
|
29
|
+
function feeRefusal(policy, host) {
|
|
30
|
+
const evaluation = evaluateSpendPolicy(
|
|
31
|
+
{ ...policy, sessionBudgetAtomic: policy.sessionBudgetAtomic === 0n ? 0n : null },
|
|
32
|
+
{ mode: "automatic", amountAtomic: ROUTING_FEE_ATOMIC, creator: host, sessionSpentAtomic: 0n }
|
|
33
|
+
);
|
|
34
|
+
return evaluation.decision === "allow" ? null : refusedWhy(evaluation.reason);
|
|
35
|
+
}
|
|
36
|
+
var FEE_REQUIRED = "fee_required";
|
|
37
|
+
function isFeeRequired(response) {
|
|
38
|
+
const decision = response?.decision;
|
|
39
|
+
const diagnostics = decision?.diagnostics;
|
|
40
|
+
return decision?.action === "native" && diagnostics?.reasonCode === FEE_REQUIRED;
|
|
41
|
+
}
|
|
42
|
+
var UNPAID = {
|
|
43
|
+
wallet_low: {
|
|
44
|
+
reason: `the wallet holds less than the $${usd(CHANNEL_DEPOSIT_ATOMIC)} routing deposit`,
|
|
45
|
+
fix: `Fund it with \`tenjin wallet fund ${SUGGESTED_FUND_USD}\`.`
|
|
46
|
+
},
|
|
47
|
+
wallet_locked: {
|
|
48
|
+
reason: "`tenjin mcp` cannot unlock the wallet without a prompt",
|
|
49
|
+
fix: "Set TENJIN_WALLET_PASSPHRASE in the environment Claude Code starts from, then restart Claude Code."
|
|
50
|
+
},
|
|
51
|
+
no_wallet: {
|
|
52
|
+
reason: "this machine has no wallet",
|
|
53
|
+
fix: "Run `tenjin doctor`."
|
|
54
|
+
},
|
|
55
|
+
limit_below_deposit: {
|
|
56
|
+
reason: `the per-call spend limit is below the $${usd(CHANNEL_DEPOSIT_ATOMIC)} routing deposit`,
|
|
57
|
+
fix: "Run `tenjin doctor`."
|
|
58
|
+
},
|
|
59
|
+
budget_reached: {
|
|
60
|
+
reason: "the daily spend limit has no room left for the routing fee or its deposit",
|
|
61
|
+
fix: "Run `tenjin doctor`."
|
|
62
|
+
},
|
|
63
|
+
not_allowlisted: {
|
|
64
|
+
reason: "allowlistCreators does not include the router",
|
|
65
|
+
fix: "Run `tenjin doctor`."
|
|
66
|
+
},
|
|
67
|
+
payment_failed: {
|
|
68
|
+
reason: "the routing payment failed",
|
|
69
|
+
fix: "Run `tenjin doctor`."
|
|
70
|
+
},
|
|
71
|
+
[FEE_REQUIRED]: {
|
|
72
|
+
reason: "the router now charges it, and this session cannot pay it",
|
|
73
|
+
fix: "Run `tenjin doctor`."
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
var NO_FAULT = /* @__PURE__ */ new Set([
|
|
77
|
+
"channel_busy",
|
|
78
|
+
"paid_path_absent",
|
|
79
|
+
"busy",
|
|
80
|
+
"no_call",
|
|
81
|
+
"deadline_after_payment_sent"
|
|
82
|
+
]);
|
|
83
|
+
function unpaid(why) {
|
|
84
|
+
if (NO_FAULT.has(why)) return null;
|
|
85
|
+
return UNPAID[why] ?? UNPAID["payment_failed"];
|
|
86
|
+
}
|
|
87
|
+
function depositSentence(amountAtomic) {
|
|
88
|
+
return `Tenjin moved $${usd(amountAtomic)} into prepaid routing credit; each routing call uses $${usd(ROUTING_FEE_ATOMIC)}.`;
|
|
89
|
+
}
|
|
90
|
+
function unpaidSentence(why) {
|
|
91
|
+
const u = unpaid(why);
|
|
92
|
+
if (u === null) return null;
|
|
93
|
+
return `Tenjin routing could not pay its $${usd(ROUTING_FEE_ATOMIC)} fee (${u.reason}), so calls take the free path until that is fixed. ${u.fix}`;
|
|
94
|
+
}
|
|
95
|
+
var ADDRESS_RE = /^0x[0-9a-f]{40}$/;
|
|
96
|
+
function payerDir(dataDir, payer) {
|
|
97
|
+
const name = payer.toLowerCase();
|
|
98
|
+
if (!ADDRESS_RE.test(name)) throw new Error(`not a wallet address: ${payer}`);
|
|
99
|
+
return join(dataDir, "router", "fee", name);
|
|
100
|
+
}
|
|
101
|
+
function usd(atomic) {
|
|
102
|
+
return formatUsdDisplay(atomic.toString());
|
|
103
|
+
}
|
|
104
|
+
var NOTICE_KEEP_MS = 7 * 864e5;
|
|
105
|
+
async function firstNoticeFor(dataDir, sessionId, now) {
|
|
106
|
+
const dir = join(dataDir, "router", "notices");
|
|
107
|
+
const name = createHash("sha256").update(sessionId).digest("hex").slice(0, 32);
|
|
108
|
+
const created = await createExclusive(join(dir, name), String(now));
|
|
109
|
+
if (created) {
|
|
110
|
+
for (const entry of await readdir(dir).catch(() => [])) {
|
|
111
|
+
const path = join(dir, entry);
|
|
112
|
+
const at = Number(await readFile(path, "utf8").catch(() => "NaN"));
|
|
113
|
+
if (!Number.isFinite(at) || now - at > NOTICE_KEEP_MS) await rm(path, { force: true });
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return created;
|
|
117
|
+
}
|
|
118
|
+
async function createExclusive(path, body) {
|
|
119
|
+
try {
|
|
120
|
+
await mkdir(join(path, ".."), { recursive: true, mode: 448 });
|
|
121
|
+
const handle = await open(path, "wx", 384);
|
|
122
|
+
try {
|
|
123
|
+
await handle.writeFile(body);
|
|
124
|
+
} finally {
|
|
125
|
+
await handle.close();
|
|
126
|
+
}
|
|
127
|
+
return true;
|
|
128
|
+
} catch (err) {
|
|
129
|
+
if (hasCode(err, "EEXIST")) return false;
|
|
130
|
+
throw err;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export {
|
|
135
|
+
ROUTE_PAID_PATH,
|
|
136
|
+
ROUTING_FEE_ATOMIC,
|
|
137
|
+
CHANNEL_DEPOSIT_ATOMIC,
|
|
138
|
+
SUGGESTED_FUND_USD,
|
|
139
|
+
ROUTING_DEPOSIT_KEY,
|
|
140
|
+
refusedWhy,
|
|
141
|
+
feeRefusal,
|
|
142
|
+
FEE_REQUIRED,
|
|
143
|
+
isFeeRequired,
|
|
144
|
+
unpaid,
|
|
145
|
+
depositSentence,
|
|
146
|
+
unpaidSentence,
|
|
147
|
+
payerDir,
|
|
148
|
+
usd,
|
|
149
|
+
firstNoticeFor
|
|
150
|
+
};
|
|
151
|
+
//# sourceMappingURL=chunk-4ZZO6ULA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/router/fee.ts"],"sourcesContent":["import { createHash } from 'node:crypto';\nimport { mkdir, open, readFile, readdir, rm } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport { hasCode } from '../lib/errno';\nimport { formatUsdDisplay } from '../lib/money';\nimport { evaluateSpendPolicy, type PolicyReason, type SpendPolicy } from '../lib/policy';\nimport type { DecisionRoute } from './decision';\n\n/**\n * THE ROUTING FEE, WITHOUT ANYTHING THAT PAYS. Every routing call on the paid\n * path pays $0.003 over x402 `batch-settlement`, and the stock SDK client in\n * `tenjin mcp` does all of it (`routing-payer.ts`). Everything else, `tenjin\n * hook` included, is the free path exactly as before this fee existed.\n *\n * Hook-safe: `tenjin hook` loads this module, and its chunk graph stays free\n * of the wallet and the x402 SDK (`dist-chunks.test.ts`).\n */\n\nexport const ROUTE_PAID_PATH = '/api/x402-router/route';\n\n/** The flat fee per routing call, atomic USDC ($0.003). */\nexport const ROUTING_FEE_ATOMIC = 3_000n;\n/** The largest channel deposit, atomic USDC ($0.25), made inline by the SDK\n * on the first paid call of a channel that cannot cover the next fee. */\nexport const CHANNEL_DEPOSIT_ATOMIC = 250_000n;\n/**\n * The top-up every \"fund the wallet\" hint names, in USD: the checkout's Apple\n * Pay and Google Pay minimum, which covers the routing deposit and a few\n * hundred lookups. `tenjin wallet fund` sends it to the checkout as a preset.\n */\nexport const SUGGESTED_FUND_USD = '5';\n/** The spend ledger key a deposit's exposure is recorded under, before its id. */\nexport const ROUTING_DEPOSIT_KEY = 'routing-deposit:';\n\n/** A spend refusal, as the reason the call was not paid. */\nconst REFUSED: Partial<Record<PolicyReason, string>> = {\n not_allowlisted: 'not_allowlisted',\n session_budget_exceeded: 'budget_reached',\n above_auto_spend: 'limit_below_deposit',\n};\n\n/** The reason a spend refusal leaves a routing call unpaid. */\nexport function refusedWhy(reason: PolicyReason): string {\n return REFUSED[reason] ?? reason;\n}\n\n/**\n * THE DEPOSIT IS THE SPEND. It meets the whole policy once, the day's budget\n * included, when the SDK's `depositStrategy` reserves it. Each fee paid from\n * it then gets only the per-payment checks: the per-call limit, the creator\n * allowlist (the router's host) and an explicit zero daily limit. It is never\n * refused for the day's running total, which the deposit already consumed.\n * Null when those checks allow the fee.\n */\nexport function feeRefusal(policy: SpendPolicy, host: string): string | null {\n const evaluation = evaluateSpendPolicy(\n { ...policy, sessionBudgetAtomic: policy.sessionBudgetAtomic === 0n ? 0n : null },\n { mode: 'automatic', amountAtomic: ROUTING_FEE_ATOMIC, creator: host, sessionSpentAtomic: 0n },\n );\n return evaluation.decision === 'allow' ? null : refusedWhy(evaluation.reason);\n}\n\n/** The paid path for this call, or null for the free path. `tenjin mcp` passes\n * its payer's; absent, every call is free. */\nexport type RouteFor = (baseUrl: string) => Promise<DecisionRoute | null>;\n\n/** The free path's reason code once the server routes only paid calls. */\nexport const FEE_REQUIRED = 'fee_required';\n\n/** Whether a decision is the free path's `fee_required` answer. */\nexport function isFeeRequired(response: unknown): boolean {\n const decision = (response as { decision?: { action?: unknown; diagnostics?: unknown } })\n ?.decision;\n const diagnostics = decision?.diagnostics as { reasonCode?: unknown } | undefined;\n return decision?.action === 'native' && diagnostics?.reasonCode === FEE_REQUIRED;\n}\n\n/**\n * WHY A CALL WAS NOT PAID, for the user: the reason and the fix, keyed by the\n * payer's skip reason (or `fee_required`, when the free path answered it and\n * nothing else explains why). Null for a reason that is no fault and needs no\n * fix: another session's call on the channel, a server with no paid path, or\n * a call queued past its own budget, or a payment still out when the call's\n * budget ran out (it finishes in the background).\n */\nconst UNPAID: Record<string, { reason: string; fix: string }> = {\n wallet_low: {\n reason: `the wallet holds less than the $${usd(CHANNEL_DEPOSIT_ATOMIC)} routing deposit`,\n fix: `Fund it with \\`tenjin wallet fund ${SUGGESTED_FUND_USD}\\`.`,\n },\n wallet_locked: {\n reason: '`tenjin mcp` cannot unlock the wallet without a prompt',\n fix: 'Set TENJIN_WALLET_PASSPHRASE in the environment Claude Code starts from, then restart Claude Code.',\n },\n no_wallet: {\n reason: 'this machine has no wallet',\n fix: 'Run `tenjin doctor`.',\n },\n limit_below_deposit: {\n reason: `the per-call spend limit is below the $${usd(CHANNEL_DEPOSIT_ATOMIC)} routing deposit`,\n fix: 'Run `tenjin doctor`.',\n },\n budget_reached: {\n reason: 'the daily spend limit has no room left for the routing fee or its deposit',\n fix: 'Run `tenjin doctor`.',\n },\n not_allowlisted: {\n reason: 'allowlistCreators does not include the router',\n fix: 'Run `tenjin doctor`.',\n },\n payment_failed: {\n reason: 'the routing payment failed',\n fix: 'Run `tenjin doctor`.',\n },\n [FEE_REQUIRED]: {\n reason: 'the router now charges it, and this session cannot pay it',\n fix: 'Run `tenjin doctor`.',\n },\n};\nconst NO_FAULT = new Set([\n 'channel_busy',\n 'paid_path_absent',\n 'busy',\n 'no_call',\n 'deadline_after_payment_sent',\n]);\n\n/** The reason and fix for an unpaid call, or null when it needs no word. */\nexport function unpaid(why: string): { reason: string; fix: string } | null {\n if (NO_FAULT.has(why)) return null;\n return UNPAID[why] ?? UNPAID['payment_failed']!;\n}\n\n/**\n * The one line said when a routing call's deposit went through: the money is\n * prepaid credit the next calls draw from, not a lookup it bought. It still\n * counts toward the daily limit ({@link feeRefusal}).\n */\nexport function depositSentence(amountAtomic: bigint): string {\n return `Tenjin moved $${usd(amountAtomic)} into prepaid routing credit; each routing call uses $${usd(ROUTING_FEE_ATOMIC)}.`;\n}\n\n/** The one line the user sees, once per session, when a call was not paid. */\nexport function unpaidSentence(why: string): string | null {\n const u = unpaid(why);\n if (u === null) return null;\n return `Tenjin routing could not pay its $${usd(ROUTING_FEE_ATOMIC)} fee (${u.reason}), so calls take the free path until that is fixed. ${u.fix}`;\n}\n\nconst ADDRESS_RE = /^0x[0-9a-f]{40}$/;\n\n/** One wallet's folder: the SDK's file storage for its routing channel\n * (`client/<channelId>.json`). */\nexport function payerDir(dataDir: string, payer: string): string {\n const name = payer.toLowerCase();\n if (!ADDRESS_RE.test(name)) throw new Error(`not a wallet address: ${payer}`);\n return join(dataDir, 'router', 'fee', name);\n}\n\n/** Atomic USDC as dollars with at least two decimals, never a float. */\nexport function usd(atomic: bigint): string {\n return formatUsdDisplay(atomic.toString());\n}\n\n/** How long a session's notice marker is kept. */\nconst NOTICE_KEEP_MS = 7 * 86_400_000;\n\n/**\n * TRUE ONCE PER SESSION: the first caller for a session id creates its marker\n * and gets true; every later one gets false. Each marker holds the time it was\n * made, and those older than a week go on the way past, so the directory does\n * not grow with every session ever run.\n */\nexport async function firstNoticeFor(\n dataDir: string,\n sessionId: string,\n now: number,\n): Promise<boolean> {\n const dir = join(dataDir, 'router', 'notices');\n const name = createHash('sha256').update(sessionId).digest('hex').slice(0, 32);\n const created = await createExclusive(join(dir, name), String(now));\n if (created) {\n for (const entry of await readdir(dir).catch(() => [] as string[])) {\n const path = join(dir, entry);\n const at = Number(await readFile(path, 'utf8').catch(() => 'NaN'));\n if (!Number.isFinite(at) || now - at > NOTICE_KEEP_MS) await rm(path, { force: true });\n }\n }\n return created;\n}\n\nasync function createExclusive(path: string, body: string): Promise<boolean> {\n try {\n await mkdir(join(path, '..'), { recursive: true, mode: 0o700 });\n const handle = await open(path, 'wx', 0o600);\n try {\n await handle.writeFile(body);\n } finally {\n await handle.close();\n }\n return true;\n } catch (err) {\n if (hasCode(err, 'EEXIST')) return false;\n throw err;\n }\n}\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,kBAAkB;AAC3B,SAAS,OAAO,MAAM,UAAU,SAAS,UAAU;AACnD,SAAS,YAAY;AAgBd,IAAM,kBAAkB;AAGxB,IAAM,qBAAqB;AAG3B,IAAM,yBAAyB;AAM/B,IAAM,qBAAqB;AAE3B,IAAM,sBAAsB;AAGnC,IAAM,UAAiD;AAAA,EACrD,iBAAiB;AAAA,EACjB,yBAAyB;AAAA,EACzB,kBAAkB;AACpB;AAGO,SAAS,WAAW,QAA8B;AACvD,SAAO,QAAQ,MAAM,KAAK;AAC5B;AAUO,SAAS,WAAW,QAAqB,MAA6B;AAC3E,QAAM,aAAa;AAAA,IACjB,EAAE,GAAG,QAAQ,qBAAqB,OAAO,wBAAwB,KAAK,KAAK,KAAK;AAAA,IAChF,EAAE,MAAM,aAAa,cAAc,oBAAoB,SAAS,MAAM,oBAAoB,GAAG;AAAA,EAC/F;AACA,SAAO,WAAW,aAAa,UAAU,OAAO,WAAW,WAAW,MAAM;AAC9E;AAOO,IAAM,eAAe;AAGrB,SAAS,cAAc,UAA4B;AACxD,QAAM,WAAY,UACd;AACJ,QAAM,cAAc,UAAU;AAC9B,SAAO,UAAU,WAAW,YAAY,aAAa,eAAe;AACtE;AAUA,IAAM,SAA0D;AAAA,EAC9D,YAAY;AAAA,IACV,QAAQ,mCAAmC,IAAI,sBAAsB,CAAC;AAAA,IACtE,KAAK,qCAAqC,kBAAkB;AAAA,EAC9D;AAAA,EACA,eAAe;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iB,OAAO,SAAS,CAAC;AAC3C;AAGA,IAAM,iBAAiB,IAAI;AAQ3B,eAAsB,eACpB,SACA,WACA,KACkB;AAClB,QAAM,MAAM,KAAK,SAAS,UAAU,SAAS;AAC7C,QAAM,OAAO,WAAW,QAAQ,EAAE,OAAO,SAAS,EAAE,OAAO,KAAK,EAAE,MAAM,GAAG,EAAE;AAC7E,QAAM,UAAU,MAAM,gBAAgB,KAAK,KAAK,IAAI,GAAG,OAAO,GAAG,CAAC;AAClE,MAAI,SAAS;AACX,eAAW,SAAS,MAAM,QAAQ,GAAG,EAAE,MAAM,MAAM,CAAC,CAAa,GAAG;AAClE,YAAM,OAAO,KAAK,KAAK,KAAK;AAC5B,YAAM,KAAK,OAAO,MAAM,SAAS,MAAM,MAAM,EAAE,MAAM,MAAM,KAAK,CAAC;AACjE,UAAI,CAAC,OAAO,SAAS,EAAE,KAAK,MAAM,KAAK,eAAgB,OAAM,GAAG,MAAM,EAAE,OAAO,KAAK,CAAC;AAAA,IACvF;AAAA,EACF;AACA,SAAO;AACT;AAEA,eAAe,gBAAgB,MAAc,MAAgC;AAC3E,MAAI;AACF,UAAM,MAAM,KAAK,MAAM,IAAI,GAAG,EAAE,WAAW,MAAM,MAAM,IAAM,CAAC;AAC9D,UAAM,SAAS,MAAM,KAAK,MAAM,MAAM,GAAK;AAC3C,QAAI;AACF,YAAM,OAAO,UAAU,IAAI;AAAA,IAC7B,UAAE;AACA,YAAM,OAAO,MAAM;AAAA,IACrB;AACA,WAAO;AAAA,EACT,SAAS,KAAK;AACZ,QAAI,QAAQ,KAAK,QAAQ,EAAG,QAAO;AACnC,UAAM;AAAA,EACR;AACF;","names":[]}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// package.json
|
|
4
|
+
var name = "tenjin-cli";
|
|
5
|
+
var version = "0.1.0-alpha.31";
|
|
6
|
+
var type = "module";
|
|
7
|
+
var description = "The tool router for coding agents. Tenjin picks the right tool when your agent needs one, and one wallet pays for every call.";
|
|
8
|
+
var repository = {
|
|
9
|
+
type: "git",
|
|
10
|
+
url: "git+https://github.com/BackTrackCo/tenjin-agent.git"
|
|
11
|
+
};
|
|
12
|
+
var homepage = "https://tenjin.sh/agents";
|
|
13
|
+
var bugs = "https://github.com/BackTrackCo/tenjin-agent/issues";
|
|
14
|
+
var keywords = [
|
|
15
|
+
"claude-code",
|
|
16
|
+
"coding-agents",
|
|
17
|
+
"tool-router",
|
|
18
|
+
"ai-agents",
|
|
19
|
+
"agent-tools",
|
|
20
|
+
"mcp",
|
|
21
|
+
"x402",
|
|
22
|
+
"usdc",
|
|
23
|
+
"base",
|
|
24
|
+
"micropayments",
|
|
25
|
+
"agent-payments",
|
|
26
|
+
"claude",
|
|
27
|
+
"codex",
|
|
28
|
+
"cli"
|
|
29
|
+
];
|
|
30
|
+
var bin = {
|
|
31
|
+
tenjin: "dist/index.js"
|
|
32
|
+
};
|
|
33
|
+
var engines = {
|
|
34
|
+
node: ">=22.0.0"
|
|
35
|
+
};
|
|
36
|
+
var files = [
|
|
37
|
+
"dist",
|
|
38
|
+
"docs",
|
|
39
|
+
"NOTICE.md"
|
|
40
|
+
];
|
|
41
|
+
var packageManager = "pnpm@11.11.0";
|
|
42
|
+
var scripts = {
|
|
43
|
+
build: "rm -rf dist && tsup",
|
|
44
|
+
test: "vitest run",
|
|
45
|
+
typecheck: "tsc --noEmit",
|
|
46
|
+
lint: "eslint .",
|
|
47
|
+
format: "prettier --write .",
|
|
48
|
+
"format:check": "prettier --check .",
|
|
49
|
+
check: "pnpm run build && pnpm run test",
|
|
50
|
+
"sync:skill": "node scripts/sync-skill.mjs",
|
|
51
|
+
"pack-smoke": "bash scripts/pack-smoke.sh",
|
|
52
|
+
changeset: "changeset",
|
|
53
|
+
prepublishOnly: "pnpm run build",
|
|
54
|
+
githooks: "git config core.hooksPath .githooks"
|
|
55
|
+
};
|
|
56
|
+
var devDependencies = {
|
|
57
|
+
"@changesets/cli": "^3.0.3",
|
|
58
|
+
"@clack/prompts": "^1.7.0",
|
|
59
|
+
"@eslint/js": "^10",
|
|
60
|
+
"@modelcontextprotocol/sdk": "1.32.0",
|
|
61
|
+
"@types/node": "^22.20.5",
|
|
62
|
+
"@x402/core": "2.28.0",
|
|
63
|
+
"@x402/evm": "2.28.0",
|
|
64
|
+
"@x402/extensions": "2.28.0",
|
|
65
|
+
"@x402/fetch": "2.28.0",
|
|
66
|
+
ajv: "^8.20.0",
|
|
67
|
+
"ajv-formats": "^3.0.1",
|
|
68
|
+
commander: "^14.0.1",
|
|
69
|
+
eslint: "^10",
|
|
70
|
+
"eslint-config-prettier": "^10",
|
|
71
|
+
"lean-qr": "^2.7.4",
|
|
72
|
+
ox: "0.14.30",
|
|
73
|
+
prettier: "^3",
|
|
74
|
+
tsup: "^8.5.0",
|
|
75
|
+
typescript: "^6",
|
|
76
|
+
"typescript-eslint": "^8",
|
|
77
|
+
viem: "^2.53.1",
|
|
78
|
+
vitest: "^4.1.9",
|
|
79
|
+
zod: "^4.4.3"
|
|
80
|
+
};
|
|
81
|
+
var package_default = {
|
|
82
|
+
name,
|
|
83
|
+
version,
|
|
84
|
+
type,
|
|
85
|
+
description,
|
|
86
|
+
repository,
|
|
87
|
+
homepage,
|
|
88
|
+
bugs,
|
|
89
|
+
keywords,
|
|
90
|
+
bin,
|
|
91
|
+
engines,
|
|
92
|
+
files,
|
|
93
|
+
packageManager,
|
|
94
|
+
scripts,
|
|
95
|
+
devDependencies
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export {
|
|
99
|
+
name,
|
|
100
|
+
version,
|
|
101
|
+
type,
|
|
102
|
+
description,
|
|
103
|
+
repository,
|
|
104
|
+
homepage,
|
|
105
|
+
bugs,
|
|
106
|
+
keywords,
|
|
107
|
+
bin,
|
|
108
|
+
engines,
|
|
109
|
+
files,
|
|
110
|
+
packageManager,
|
|
111
|
+
scripts,
|
|
112
|
+
devDependencies,
|
|
113
|
+
package_default
|
|
114
|
+
};
|
|
115
|
+
//# sourceMappingURL=chunk-5C32RLTA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../package.json"],"sourcesContent":["{\n \"name\": \"tenjin-cli\",\n \"version\": \"0.1.0-alpha.31\",\n \"type\": \"module\",\n \"description\": \"The tool router for coding agents. Tenjin picks the right tool when your agent needs one, and one wallet pays for every call.\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/BackTrackCo/tenjin-agent.git\"\n },\n \"homepage\": \"https://tenjin.sh/agents\",\n \"bugs\": \"https://github.com/BackTrackCo/tenjin-agent/issues\",\n \"keywords\": [\n \"claude-code\",\n \"coding-agents\",\n \"tool-router\",\n \"ai-agents\",\n \"agent-tools\",\n \"mcp\",\n \"x402\",\n \"usdc\",\n \"base\",\n \"micropayments\",\n \"agent-payments\",\n \"claude\",\n \"codex\",\n \"cli\"\n ],\n \"bin\": {\n \"tenjin\": \"dist/index.js\"\n },\n \"engines\": {\n \"node\": \">=22.0.0\"\n },\n \"files\": [\n \"dist\",\n \"docs\",\n \"NOTICE.md\"\n ],\n \"packageManager\": \"pnpm@11.11.0\",\n \"scripts\": {\n \"build\": \"rm -rf dist && tsup\",\n \"test\": \"vitest run\",\n \"typecheck\": \"tsc --noEmit\",\n \"lint\": \"eslint .\",\n \"format\": \"prettier --write .\",\n \"format:check\": \"prettier --check .\",\n \"check\": \"pnpm run build && pnpm run test\",\n \"sync:skill\": \"node scripts/sync-skill.mjs\",\n \"pack-smoke\": \"bash scripts/pack-smoke.sh\",\n \"changeset\": \"changeset\",\n \"prepublishOnly\": \"pnpm run build\",\n \"githooks\": \"git config core.hooksPath .githooks\"\n },\n \"devDependencies\": {\n \"@changesets/cli\": \"^3.0.3\",\n \"@clack/prompts\": \"^1.7.0\",\n \"@eslint/js\": \"^10\",\n \"@modelcontextprotocol/sdk\": \"1.32.0\",\n \"@types/node\": \"^22.20.5\",\n \"@x402/core\": \"2.28.0\",\n \"@x402/evm\": \"2.28.0\",\n \"@x402/extensions\": \"2.28.0\",\n \"@x402/fetch\": \"2.28.0\",\n \"ajv\": \"^8.20.0\",\n \"ajv-formats\": \"^3.0.1\",\n \"commander\": \"^14.0.1\",\n \"eslint\": \"^10\",\n \"eslint-config-prettier\": \"^10\",\n \"lean-qr\": \"^2.7.4\",\n \"ox\": \"0.14.30\",\n \"prettier\": \"^3\",\n \"tsup\": \"^8.5.0\",\n \"typescript\": \"^6\",\n \"typescript-eslint\": \"^8\",\n \"viem\": \"^2.53.1\",\n \"vitest\": \"^4.1.9\",\n \"zod\": \"^4.4.3\"\n }\n}\n"],"mappings":";;;AACE,WAAQ;AACR,cAAW;AACX,WAAQ;AACR,kBAAe;AACf,iBAAc;AAAA,EACZ,MAAQ;AAAA,EACR,KAAO;AACT;AACA,eAAY;AACZ,WAAQ;AACR,eAAY;AAAA,EACV;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AACA,UAAO;AAAA,EACL,QAAU;AACZ;AACA,cAAW;AAAA,EACT,MAAQ;AACV;AACA,YAAS;AAAA,EACP;AAAA,EACA;AAAA,EACA;AACF;AACA,qBAAkB;AAClB,cAAW;AAAA,EACT,OAAS;AAAA,EACT,MAAQ;AAAA,EACR,WAAa;AAAA,EACb,MAAQ;AAAA,EACR,QAAU;AAAA,EACV,gBAAgB;AAAA,EAChB,OAAS;AAAA,EACT,cAAc;AAAA,EACd,cAAc;AAAA,EACd,WAAa;AAAA,EACb,gBAAkB;AAAA,EAClB,UAAY;AACd;AACA,sBAAmB;AAAA,EACjB,mBAAmB;AAAA,EACnB,kBAAkB;AAAA,EAClB,cAAc;AAAA,EACd,6BAA6B;AAAA,EAC7B,eAAe;AAAA,EACf,cAAc;AAAA,EACd,aAAa;AAAA,EACb,oBAAoB;AAAA,EACpB,eAAe;AAAA,EACf,KAAO;AAAA,EACP,eAAe;AAAA,EACf,WAAa;AAAA,EACb,QAAU;AAAA,EACV,0BAA0B;AAAA,EAC1B,WAAW;AAAA,EACX,IAAM;AAAA,EACN,UAAY;AAAA,EACZ,MAAQ;AAAA,EACR,YAAc;AAAA,EACd,qBAAqB;AAAA,EACrB,MAAQ;AAAA,EACR,QAAU;AAAA,EACV,KAAO;AACT;AA7EF;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAIA;AAAA,EACA;AAAA,EACA;AAAA,EAgBA;AAAA,EAGA;AAAA,EAGA;AAAA,EAKA;AAAA,EACA;AAAA,EAcA;AAyBF;","names":[]}
|
|
@@ -60,7 +60,7 @@ import {
|
|
|
60
60
|
stringify,
|
|
61
61
|
toBytes,
|
|
62
62
|
trim
|
|
63
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-EGELTSPU.js";
|
|
64
64
|
|
|
65
65
|
// node_modules/.pnpm/abitype@1.2.3_typescript@6.0.3_zod@4.4.3/node_modules/abitype/dist/esm/version.js
|
|
66
66
|
var version = "1.2.3";
|
|
@@ -4796,7 +4796,7 @@ async function call(client, args) {
|
|
|
4796
4796
|
if (isAbortError(err))
|
|
4797
4797
|
throw err;
|
|
4798
4798
|
const data2 = getRevertErrorData(err);
|
|
4799
|
-
const { offchainLookup: offchainLookup2, offchainLookupSignature: offchainLookupSignature2 } = await import("./ccip-
|
|
4799
|
+
const { offchainLookup: offchainLookup2, offchainLookupSignature: offchainLookupSignature2 } = await import("./ccip-NLCSCHKI.js");
|
|
4800
4800
|
if (client.ccipRead !== false && data2?.slice(0, 10) === offchainLookupSignature2 && to)
|
|
4801
4801
|
return {
|
|
4802
4802
|
data: await offchainLookup2(client, { data: data2, requestOptions, to })
|
|
@@ -5329,4 +5329,4 @@ export {
|
|
|
5329
5329
|
ccipRequest,
|
|
5330
5330
|
call
|
|
5331
5331
|
};
|
|
5332
|
-
//# sourceMappingURL=chunk-
|
|
5332
|
+
//# sourceMappingURL=chunk-5IEP5EGE.js.map
|