tenjin-cli 0.1.0-alpha.32 → 0.1.0-alpha.33

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.
Files changed (165) hide show
  1. package/README.md +42 -23
  2. package/dist/{_esm-RLLC72MS.js → _esm-BIN7VY2L.js} +2 -2
  3. package/dist/{alive-MROUMFH3.js → alive-GSOWKUOY.js} +4 -4
  4. package/dist/{auto-update-OPWMRZLS.js → auto-update-Y24UL56V.js} +5 -3
  5. package/dist/{chunk-2GNOFONN.js → chunk-2M2VPI2E.js} +2 -2
  6. package/dist/chunk-2M2VPI2E.js.map +1 -0
  7. package/dist/{chunk-VUGQTZ2L.js → chunk-2RWB7RKE.js} +89 -33
  8. package/dist/chunk-2RWB7RKE.js.map +1 -0
  9. package/dist/{chunk-OTWLERSW.js → chunk-36RVGZNY.js} +2 -2
  10. package/dist/{chunk-B7EM4GGF.js → chunk-3GNJXKIT.js} +2 -2
  11. package/dist/{chunk-DRDUIZIA.js → chunk-4K7TQHNP.js} +4 -4
  12. package/dist/{chunk-SYOS5CAC.js → chunk-4YOZGGTZ.js} +73 -2
  13. package/dist/chunk-4YOZGGTZ.js.map +1 -0
  14. package/dist/{chunk-AD226HDR.js → chunk-A5GKIG5O.js} +5 -5
  15. package/dist/{chunk-JEVQ5LKO.js → chunk-AGMVASXZ.js} +3 -3
  16. package/dist/{chunk-ADV4LDTB.js → chunk-BF4XHEQK.js} +12 -2
  17. package/dist/chunk-BF4XHEQK.js.map +1 -0
  18. package/dist/{chunk-IDTRSAHE.js → chunk-C2Q76BVM.js} +48 -49
  19. package/dist/chunk-C2Q76BVM.js.map +1 -0
  20. package/dist/{chunk-VJUVFZ2D.js → chunk-FVIGCDSV.js} +1 -1
  21. package/dist/chunk-FVIGCDSV.js.map +1 -0
  22. package/dist/{chunk-QF3LSMGS.js → chunk-GTTUCOPD.js} +2 -2
  23. package/dist/{chunk-3DIL66VX.js → chunk-HGGWCP7W.js} +2 -2
  24. package/dist/{chunk-D5TOQSO4.js → chunk-HMWYAUA6.js} +10 -6
  25. package/dist/{chunk-D5TOQSO4.js.map → chunk-HMWYAUA6.js.map} +1 -1
  26. package/dist/{chunk-445VQTVM.js → chunk-IE7P2BZE.js} +2 -2
  27. package/dist/{chunk-VOZA6O7K.js → chunk-ILNIZ5I2.js} +190 -96
  28. package/dist/chunk-ILNIZ5I2.js.map +1 -0
  29. package/dist/{chunk-TF5HCP33.js → chunk-INTFHMU4.js} +4 -4
  30. package/dist/{chunk-HREHWL32.js → chunk-J57UC3DD.js} +2 -2
  31. package/dist/{chunk-AV5NZMYO.js → chunk-KM7RY2ZS.js} +2 -2
  32. package/dist/{chunk-TAW4UFFF.js → chunk-L6JEXB3E.js} +132 -132
  33. package/dist/chunk-L6JEXB3E.js.map +1 -0
  34. package/dist/{chunk-E7LGOMH6.js → chunk-LRW6S53P.js} +4 -3
  35. package/dist/chunk-LRW6S53P.js.map +1 -0
  36. package/dist/{chunk-PKHI276N.js → chunk-LXAYUOXI.js} +18 -9
  37. package/dist/chunk-LXAYUOXI.js.map +1 -0
  38. package/dist/{chunk-WOM257PW.js → chunk-NDGZDTSJ.js} +3 -3
  39. package/dist/{chunk-SFASB5FL.js → chunk-P3LFTKE7.js} +3 -14
  40. package/dist/chunk-P3LFTKE7.js.map +1 -0
  41. package/dist/{chunk-YUY4SAGM.js → chunk-RVPYTUP4.js} +5 -5
  42. package/dist/chunk-RVPYTUP4.js.map +1 -0
  43. package/dist/{chunk-GAKUQHKA.js → chunk-TC2WZLSC.js} +3 -3
  44. package/dist/{chunk-D3ZURCG7.js → chunk-TKPF35W6.js} +2 -2
  45. package/dist/{chunk-I5TDIUKM.js → chunk-U3IKUGRP.js} +23 -5
  46. package/dist/chunk-U3IKUGRP.js.map +1 -0
  47. package/dist/{chunk-BI673VEJ.js → chunk-UXZONNEQ.js} +3 -3
  48. package/dist/{chunk-PJNENX2A.js → chunk-WFSPCCVW.js} +2 -2
  49. package/dist/{chunk-PJNENX2A.js.map → chunk-WFSPCCVW.js.map} +1 -1
  50. package/dist/{chunk-DW4YTVR3.js → chunk-WXA2BWTE.js} +6 -2
  51. package/dist/chunk-WXA2BWTE.js.map +1 -0
  52. package/dist/{chunk-JRZBBPO6.js → chunk-ZDZERB6L.js} +56 -228
  53. package/dist/chunk-ZDZERB6L.js.map +1 -0
  54. package/dist/{chunk-G75OPGAK.js → chunk-ZNNXRNFD.js} +5 -3
  55. package/dist/chunk-ZNNXRNFD.js.map +1 -0
  56. package/dist/{chunk-CISYM4EO.js → chunk-ZURZHELF.js} +2 -2
  57. package/dist/{cli-FB4LOA5A.js → cli-E36SPKBW.js} +44 -44
  58. package/dist/{cli-FB4LOA5A.js.map → cli-E36SPKBW.js.map} +1 -1
  59. package/dist/{codex-event-TYVES3UX.js → codex-event-ZO2GEFE6.js} +2 -2
  60. package/dist/{codex-host-WW4H2SKT.js → codex-host-KECJVTA2.js} +3 -3
  61. package/dist/{codex-install-2C623HPW.js → codex-install-HQZDGFXW.js} +90 -47
  62. package/dist/codex-install-HQZDGFXW.js.map +1 -0
  63. package/dist/{config-HOVJFEKD.js → config-HY2E4GGW.js} +8 -8
  64. package/dist/{doctor-NKU4V5OV.js → doctor-I6XQEKWD.js} +42 -31
  65. package/dist/doctor-I6XQEKWD.js.map +1 -0
  66. package/dist/{fund-WEBHTZGN.js → fund-2QRO7OJL.js} +16 -11
  67. package/dist/{fund-WEBHTZGN.js.map → fund-2QRO7OJL.js.map} +1 -1
  68. package/dist/{hook-command-ZA2PNKS6.js → hook-command-2UBCSZG6.js} +12 -13
  69. package/dist/hosts/claude/.claude-plugin/marketplace.json +2 -2
  70. package/dist/hosts/claude/tenjin/.claude-plugin/plugin.json +2 -2
  71. package/dist/hosts/claude/tenjin/hooks/register.tsx +51 -11
  72. package/dist/hosts/claude/tenjin/types/index.d.ts +2 -1
  73. package/dist/{hosts-AV5MHBAU.js → hosts-DVQJ32QC.js} +2 -2
  74. package/dist/index.js +16 -15
  75. package/dist/index.js.map +1 -1
  76. package/dist/{install-PT4EZS4R.js → install-ILUX5C4A.js} +24 -17
  77. package/dist/{install-identity-5A4OE6YC.js → install-identity-TZKGY6LQ.js} +7 -7
  78. package/dist/{install-wallet-SAAPKB73.js → install-wallet-5M4OTYLX.js} +13 -13
  79. package/dist/isows-native-Q2UDIVPT.js +9 -0
  80. package/dist/isows-native-Q2UDIVPT.js.map +1 -0
  81. package/dist/{mcp-HAWKCTPQ.js → mcp-LE4DUS22.js} +23 -24
  82. package/dist/{mcp-HAWKCTPQ.js.map → mcp-LE4DUS22.js.map} +1 -1
  83. package/dist/{package-SR2WB6MK.js → package-IJFGMWEV.js} +2 -2
  84. package/dist/{pay-OXC3WKYV.js → pay-WCG3IH4R.js} +13 -13
  85. package/dist/{payments-3KHMP2MG.js → payments-HFPPWHTV.js} +6 -6
  86. package/dist/{plugin-registration-N3GRIZVM.js → plugin-registration-PZFI5GZW.js} +18 -17
  87. package/dist/{runtime-UVNUA3AS.js → runtime-UZOKSUZX.js} +145 -27
  88. package/dist/runtime-UZOKSUZX.js.map +1 -0
  89. package/dist/{runtime-fetch-EKFRNR6Z.js → runtime-fetch-ZSSSK72Y.js} +5 -2
  90. package/dist/{runtime-layout-BDWZG2TQ.js → runtime-layout-WIDILZ6K.js} +2 -2
  91. package/dist/{send-HMKJLT34.js → send-GCVEAQKL.js} +8 -8
  92. package/dist/{status-RWXIIWYS.js → status-HCVAOCN7.js} +10 -10
  93. package/dist/{status-line-77XYZP7E.js → status-line-OPCXDHL2.js} +6 -6
  94. package/dist/{uninstall-D5G67UJH.js → uninstall-BAWRBXXQ.js} +19 -18
  95. package/dist/{uninstall-D5G67UJH.js.map → uninstall-BAWRBXXQ.js.map} +1 -1
  96. package/dist/{update-LRNOEGSB.js → update-CACXLQLR.js} +20 -17
  97. package/dist/{usdc-D6X7EIQ2.js → usdc-VG4CIOUK.js} +4 -4
  98. package/dist/{viemAdapter-By13KInL-RL742ETX.js → viemAdapter-By13KInL-DOFTEIJV.js} +2 -2
  99. package/dist/{wallet-XFYC27BR.js → wallet-QL4UUXEZ.js} +11 -11
  100. package/docs/agent-permissions.md +16 -12
  101. package/docs/troubleshooting.md +5 -5
  102. package/package.json +4 -4
  103. package/scripts/installers/install.ps1 +67 -0
  104. package/scripts/installers/install.sh +68 -0
  105. package/dist/_esm-C5CRWCYU.js +0 -3737
  106. package/dist/_esm-C5CRWCYU.js.map +0 -1
  107. package/dist/chunk-2GNOFONN.js.map +0 -1
  108. package/dist/chunk-ADV4LDTB.js.map +0 -1
  109. package/dist/chunk-DW4YTVR3.js.map +0 -1
  110. package/dist/chunk-E7LGOMH6.js.map +0 -1
  111. package/dist/chunk-G75OPGAK.js.map +0 -1
  112. package/dist/chunk-I5TDIUKM.js.map +0 -1
  113. package/dist/chunk-IDTRSAHE.js.map +0 -1
  114. package/dist/chunk-JRZBBPO6.js.map +0 -1
  115. package/dist/chunk-PKHI276N.js.map +0 -1
  116. package/dist/chunk-SFASB5FL.js.map +0 -1
  117. package/dist/chunk-SYOS5CAC.js.map +0 -1
  118. package/dist/chunk-TAW4UFFF.js.map +0 -1
  119. package/dist/chunk-VJUVFZ2D.js.map +0 -1
  120. package/dist/chunk-VOZA6O7K.js.map +0 -1
  121. package/dist/chunk-VUGQTZ2L.js.map +0 -1
  122. package/dist/chunk-YUY4SAGM.js.map +0 -1
  123. package/dist/codex-install-2C623HPW.js.map +0 -1
  124. package/dist/doctor-NKU4V5OV.js.map +0 -1
  125. package/dist/runtime-UVNUA3AS.js.map +0 -1
  126. /package/dist/{_esm-RLLC72MS.js.map → _esm-BIN7VY2L.js.map} +0 -0
  127. /package/dist/{alive-MROUMFH3.js.map → alive-GSOWKUOY.js.map} +0 -0
  128. /package/dist/{auto-update-OPWMRZLS.js.map → auto-update-Y24UL56V.js.map} +0 -0
  129. /package/dist/{chunk-OTWLERSW.js.map → chunk-36RVGZNY.js.map} +0 -0
  130. /package/dist/{chunk-B7EM4GGF.js.map → chunk-3GNJXKIT.js.map} +0 -0
  131. /package/dist/{chunk-DRDUIZIA.js.map → chunk-4K7TQHNP.js.map} +0 -0
  132. /package/dist/{chunk-AD226HDR.js.map → chunk-A5GKIG5O.js.map} +0 -0
  133. /package/dist/{chunk-JEVQ5LKO.js.map → chunk-AGMVASXZ.js.map} +0 -0
  134. /package/dist/{chunk-QF3LSMGS.js.map → chunk-GTTUCOPD.js.map} +0 -0
  135. /package/dist/{chunk-3DIL66VX.js.map → chunk-HGGWCP7W.js.map} +0 -0
  136. /package/dist/{chunk-445VQTVM.js.map → chunk-IE7P2BZE.js.map} +0 -0
  137. /package/dist/{chunk-TF5HCP33.js.map → chunk-INTFHMU4.js.map} +0 -0
  138. /package/dist/{chunk-HREHWL32.js.map → chunk-J57UC3DD.js.map} +0 -0
  139. /package/dist/{chunk-AV5NZMYO.js.map → chunk-KM7RY2ZS.js.map} +0 -0
  140. /package/dist/{chunk-WOM257PW.js.map → chunk-NDGZDTSJ.js.map} +0 -0
  141. /package/dist/{chunk-GAKUQHKA.js.map → chunk-TC2WZLSC.js.map} +0 -0
  142. /package/dist/{chunk-D3ZURCG7.js.map → chunk-TKPF35W6.js.map} +0 -0
  143. /package/dist/{chunk-BI673VEJ.js.map → chunk-UXZONNEQ.js.map} +0 -0
  144. /package/dist/{chunk-CISYM4EO.js.map → chunk-ZURZHELF.js.map} +0 -0
  145. /package/dist/{codex-event-TYVES3UX.js.map → codex-event-ZO2GEFE6.js.map} +0 -0
  146. /package/dist/{codex-host-WW4H2SKT.js.map → codex-host-KECJVTA2.js.map} +0 -0
  147. /package/dist/{config-HOVJFEKD.js.map → config-HY2E4GGW.js.map} +0 -0
  148. /package/dist/{hook-command-ZA2PNKS6.js.map → hook-command-2UBCSZG6.js.map} +0 -0
  149. /package/dist/{hosts-AV5MHBAU.js.map → hosts-DVQJ32QC.js.map} +0 -0
  150. /package/dist/{install-PT4EZS4R.js.map → install-ILUX5C4A.js.map} +0 -0
  151. /package/dist/{install-identity-5A4OE6YC.js.map → install-identity-TZKGY6LQ.js.map} +0 -0
  152. /package/dist/{install-wallet-SAAPKB73.js.map → install-wallet-5M4OTYLX.js.map} +0 -0
  153. /package/dist/{package-SR2WB6MK.js.map → package-IJFGMWEV.js.map} +0 -0
  154. /package/dist/{pay-OXC3WKYV.js.map → pay-WCG3IH4R.js.map} +0 -0
  155. /package/dist/{payments-3KHMP2MG.js.map → payments-HFPPWHTV.js.map} +0 -0
  156. /package/dist/{plugin-registration-N3GRIZVM.js.map → plugin-registration-PZFI5GZW.js.map} +0 -0
  157. /package/dist/{runtime-fetch-EKFRNR6Z.js.map → runtime-fetch-ZSSSK72Y.js.map} +0 -0
  158. /package/dist/{runtime-layout-BDWZG2TQ.js.map → runtime-layout-WIDILZ6K.js.map} +0 -0
  159. /package/dist/{send-HMKJLT34.js.map → send-GCVEAQKL.js.map} +0 -0
  160. /package/dist/{status-RWXIIWYS.js.map → status-HCVAOCN7.js.map} +0 -0
  161. /package/dist/{status-line-77XYZP7E.js.map → status-line-OPCXDHL2.js.map} +0 -0
  162. /package/dist/{update-LRNOEGSB.js.map → update-CACXLQLR.js.map} +0 -0
  163. /package/dist/{usdc-D6X7EIQ2.js.map → usdc-VG4CIOUK.js.map} +0 -0
  164. /package/dist/{viemAdapter-By13KInL-RL742ETX.js.map → viemAdapter-By13KInL-DOFTEIJV.js.map} +0 -0
  165. /package/dist/{wallet-XFYC27BR.js.map → wallet-QL4UUXEZ.js.map} +0 -0
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-OJNTCYQQ.js";
8
8
 
9
9
  // src/lib/usdc-balance.ts
10
- import { readFile } from "node:fs/promises";
10
+ import { readFile, rm } from "node:fs/promises";
11
11
  var USDC_ADDRESS = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
12
12
  var BALANCE_OF_SELECTOR = "0x70a08231";
13
13
  var ADDRESS_RE = /^0x[0-9a-fA-F]{40}$/;
@@ -64,6 +64,9 @@ function sameUrl(a, b) {
64
64
  }
65
65
  }
66
66
  var LAST_KNOWN_BALANCE_MS = 6e4;
67
+ async function forgetRememberedBalance(dataDir) {
68
+ await rm(balanceCachePath(dataDir), { force: true }).catch(() => void 0);
69
+ }
67
70
  function rememberingBalanceReader(dataDir, opts = {}) {
68
71
  const read = opts.read ?? readUsdcBalanceWithFallback;
69
72
  const now = opts.now ?? Date.now;
@@ -103,6 +106,7 @@ export {
103
106
  readUsdcBalance,
104
107
  DEFAULT_RPC_URL,
105
108
  readUsdcBalanceWithFallback,
109
+ forgetRememberedBalance,
106
110
  rememberingBalanceReader
107
111
  };
108
- //# sourceMappingURL=chunk-DW4YTVR3.js.map
112
+ //# sourceMappingURL=chunk-WXA2BWTE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/usdc-balance.ts"],"sourcesContent":["/**\n * Base USDC's address and one `balanceOf` over plain JSON-RPC. No viem on\n * purpose: the router hooks read a balance before they redirect a call, and\n * their chunk graph must stay free of it (`src/router/dist-chunks.test.ts`).\n * One `eth_call` needs nothing viem adds. `usdc.ts` keeps the viem client for\n * the send path and re-exports the address from here.\n */\n\nimport { readFile, rm } from 'node:fs/promises';\nimport { writeFileAtomic } from './atomic-json';\nimport { balanceCachePath } from './paths';\n\n// Values mirror the app's lib/chain.ts Base mainnet entry (chain 8453).\nexport const USDC_ADDRESS = '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913';\n\n/** `balanceOf(address)`: the first four bytes of its keccak-256. */\nconst BALANCE_OF_SELECTOR = '0x70a08231';\nconst ADDRESS_RE = /^0x[0-9a-fA-F]{40}$/;\n/** One ABI word: what `balanceOf` returns. */\nconst WORD_RE = /^0x[0-9a-fA-F]{64}$/;\n\n/**\n * The address's USDC balance in atomic units, or null when it could not be\n * read inside `timeoutMs`: a transport failure, a non-2xx, an RPC error, or an\n * answer that is not one word. Never throws, so the caller picks which way an\n * unreadable balance falls.\n */\nexport async function readUsdcBalance(\n address: string,\n rpcUrl: string,\n opts: { timeoutMs: number; fetchImpl?: typeof fetch },\n): Promise<bigint | null> {\n if (!ADDRESS_RE.test(address) || opts.timeoutMs <= 0) return null;\n try {\n const res = await (opts.fetchImpl ?? fetch)(rpcUrl, {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({\n jsonrpc: '2.0',\n id: 1,\n method: 'eth_call',\n params: [\n {\n to: USDC_ADDRESS,\n data: `${BALANCE_OF_SELECTOR}${address.slice(2).toLowerCase().padStart(64, '0')}`,\n },\n 'latest',\n ],\n }),\n signal: AbortSignal.timeout(opts.timeoutMs),\n });\n if (!res.ok) return null;\n const result = ((await res.json()) as { result?: unknown } | null)?.result;\n return typeof result === 'string' && WORD_RE.test(result) ? BigInt(result) : null;\n } catch {\n return null;\n }\n}\n\n/** Base's public RPC: the shipped `rpcUrl` default (`CONFIG_DEFAULTS`). */\nexport const DEFAULT_RPC_URL = 'https://mainnet.base.org';\n\n/**\n * Public Base RPCs a balance read on the DEFAULT `rpcUrl` falls back to, in\n * order, only after it fails. mainnet.base.org rate-limits a busy IP\n * (`-32016 over rate limit`): four paid lookups across two research runs were\n * refused with `balance_unavailable` before signing, while these two answered\n * every read. They see the wallet's address only when the default did not\n * answer, as the default sees it on every read.\n */\nexport const FALLBACK_RPC_URLS: readonly string[] = [\n 'https://base-rpc.publicnode.com',\n 'https://base.drpc.org',\n];\n\n/**\n * {@link readUsdcBalance} from `rpcUrl` first and, when that is the default,\n * then from each of {@link FALLBACK_RPC_URLS} until one answers, all inside the\n * one `timeoutMs`. Every RPC but the last gets half of what is left, so one\n * that hangs still leaves the others time to answer.\n *\n * AN RPC THE USER CONFIGURED IS THE ONLY ONE ASKED. Choosing one can be about\n * privacy, and the public RPCs would see the wallet's address; a read that\n * fails there fails, as it did before the fallbacks.\n */\nexport async function readUsdcBalanceWithFallback(\n address: string,\n rpcUrl: string,\n opts: { timeoutMs: number; fetchImpl?: typeof fetch },\n): Promise<bigint | null> {\n const urls = sameUrl(rpcUrl, DEFAULT_RPC_URL) ? [rpcUrl, ...FALLBACK_RPC_URLS] : [rpcUrl];\n const deadline = Date.now() + opts.timeoutMs;\n for (const [index, url] of urls.entries()) {\n const left = deadline - Date.now();\n if (left <= 0) return null;\n const timeoutMs = index === urls.length - 1 ? left : Math.ceil(left / 2);\n const balance = await readUsdcBalance(address, url, { ...opts, timeoutMs });\n if (balance !== null) return balance;\n }\n return null;\n}\n\nfunction sameUrl(a: string, b: string): boolean {\n try {\n return new URL(a).href === new URL(b).href;\n } catch {\n return a === b;\n }\n}\n\n/**\n * How long the hooks remember a balance read. Base's public RPC refuses the\n * sixth `eth_call` in a second, which a burst of parallel lookups reaches, and\n * each hook then waited on a failed read. A minute carries a burst past that;\n * the hooks' read only decides whether to offer.\n */\nexport const LAST_KNOWN_BALANCE_MS = 60_000;\n\n/** An explicit balance check or observed funding makes a hook's cached balance obsolete. */\nexport async function forgetRememberedBalance(dataDir: string): Promise<void> {\n await rm(balanceCachePath(dataDir), { force: true }).catch(() => undefined);\n}\n\n/**\n * {@link readUsdcBalanceWithFallback} for the router hooks, which returns the\n * last read it made for this address while it is under\n * {@link LAST_KNOWN_BALANCE_MS} old, without asking an RPC, and reads the chain\n * otherwise. A read that fails on every RPC is null, never the remembered\n * balance. The RPC URL is never stored, since it can embed a key.\n *\n * NEVER FOR A PAYMENT. `tenjin pay` reads the signer's balance live\n * immediately before signing (docs/agent-permissions.md): a minute-old balance\n * can be one the wallet has since spent.\n */\nexport function rememberingBalanceReader(\n dataDir: string,\n opts: { now?: () => number; read?: typeof readUsdcBalance } = {},\n): typeof readUsdcBalance {\n const read = opts.read ?? readUsdcBalanceWithFallback;\n const now = opts.now ?? Date.now;\n const path = balanceCachePath(dataDir);\n return async (address, rpcUrl, readOpts) => {\n const remembered = await recallBalance(path, address, now());\n if (remembered !== null) return remembered;\n const live = await read(address, rpcUrl, readOpts);\n if (live === null) return null;\n const record = {\n version: 1,\n address: address.toLowerCase(),\n atomic: live.toString(),\n at: now(),\n };\n try {\n await writeFileAtomic(path, JSON.stringify(record), { mode: 0o600, dirMode: 0o700 });\n } catch {\n // A cache that cannot be written is a cache that is not used.\n }\n return live;\n };\n}\n\n/** The remembered balance for this address while it is fresh, else null. */\nasync function recallBalance(path: string, address: string, now: number): Promise<bigint | null> {\n try {\n const row = JSON.parse(await readFile(path, 'utf8')) as Record<string, unknown> | null;\n if (\n row?.version !== 1 ||\n row.address !== address.toLowerCase() ||\n typeof row.atomic !== 'string' ||\n !/^\\d{1,40}$/.test(row.atomic) ||\n typeof row.at !== 'number' ||\n now - row.at < 0 ||\n now - row.at > LAST_KNOWN_BALANCE_MS\n ) {\n return null;\n }\n return BigInt(row.atomic);\n } catch {\n return null;\n }\n}\n"],"mappings":"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","names":[]}
@@ -5,7 +5,7 @@ import {
5
5
  import {
6
6
  codexRouterEvent,
7
7
  codexSession
8
- } from "./chunk-SFASB5FL.js";
8
+ } from "./chunk-P3LFTKE7.js";
9
9
  import {
10
10
  UNREACHABLE_BACKOFF_MS,
11
11
  clearRouterMemo,
@@ -26,7 +26,7 @@ import {
26
26
  OfferSpecSchema,
27
27
  ROUTER_PATH,
28
28
  requestDecision
29
- } from "./chunk-PKHI276N.js";
29
+ } from "./chunk-LXAYUOXI.js";
30
30
  import {
31
31
  FEE_REQUIRED,
32
32
  depositSentence,
@@ -40,23 +40,17 @@ import {
40
40
  launchedByPlugin,
41
41
  requestToolName
42
42
  } from "./chunk-MPZUYCAP.js";
43
- import {
44
- proxyVariable
45
- } from "./chunk-3FMZGI7I.js";
46
- import {
47
- composeUserAgent
48
- } from "./chunk-OTWLERSW.js";
49
43
  import {
50
44
  mask
51
45
  } from "./chunk-IADZOXKN.js";
52
46
  import {
53
- augmentOf,
54
47
  bindDecision,
55
- claimQuery,
48
+ claimNote,
56
49
  claimRedirect,
57
- markAugment,
50
+ markNoted,
58
51
  markOffered,
59
52
  newCallId,
53
+ noteOf,
60
54
  noteSession,
61
55
  pruneProgress,
62
56
  pruneSessions,
@@ -64,13 +58,13 @@ import {
64
58
  sessionDir,
65
59
  wasOffered,
66
60
  writeProgress
67
- } from "./chunk-IDTRSAHE.js";
61
+ } from "./chunk-C2Q76BVM.js";
68
62
  import {
69
63
  routerSettings
70
- } from "./chunk-JEVQ5LKO.js";
64
+ } from "./chunk-AGMVASXZ.js";
71
65
  import {
72
66
  resolveContextSettings
73
- } from "./chunk-AV5NZMYO.js";
67
+ } from "./chunk-KM7RY2ZS.js";
74
68
  import {
75
69
  parseUsdToAtomic,
76
70
  toMoney
@@ -81,7 +75,7 @@ import {
81
75
  readWalletFacts,
82
76
  sessionServedByPlugin,
83
77
  settleCurrent
84
- } from "./chunk-WOM257PW.js";
78
+ } from "./chunk-NDGZDTSJ.js";
85
79
  import {
86
80
  WALLET_UNLOCKED,
87
81
  agentFixFor
@@ -90,13 +84,10 @@ import {
90
84
  loadRawConfig,
91
85
  resolveExperimentalBazaar,
92
86
  resolveSettings
93
- } from "./chunk-2GNOFONN.js";
87
+ } from "./chunk-2M2VPI2E.js";
94
88
  import {
95
89
  rememberingBalanceReader
96
- } from "./chunk-DW4YTVR3.js";
97
- import {
98
- isSameDeployment
99
- } from "./chunk-XQJXNMSB.js";
90
+ } from "./chunk-WXA2BWTE.js";
100
91
  import {
101
92
  external_exports
102
93
  } from "./chunk-SNNSAGMT.js";
@@ -520,6 +511,19 @@ async function readChoices(dataDir, id) {
520
511
  await file.close().catch(() => void 0);
521
512
  }
522
513
  }
514
+ function labelPath(dataDir, id) {
515
+ return join2(dataDir, SPECS_DIR, `${digest(id)}.label.json`);
516
+ }
517
+ async function storeLabel(dataDir, id, label) {
518
+ try {
519
+ await writeFileAtomic(labelPath(dataDir, id), JSON.stringify({ id, label }), {
520
+ mode: 384,
521
+ dirMode: 448
522
+ });
523
+ } catch {
524
+ }
525
+ await prune(join2(dataDir, SPECS_DIR), SPEC_TTL_MS, Date.now());
526
+ }
523
527
  var PaymentSchema = external_exports.discriminatedUnion("state", [
524
528
  external_exports.strictObject({
525
529
  state: external_exports.literal("paid"),
@@ -650,173 +654,6 @@ function savedPdfOf(result, sessionId) {
650
654
  var GATE_TIMEOUT_MS = 3500;
651
655
  var DEPOSIT_GATE_TIMEOUT_MS = 4500;
652
656
 
653
- // src/router/augment.ts
654
- import { spawn } from "node:child_process";
655
- import { constants as constants2 } from "node:fs";
656
- import { open as open3, rm as rm2 } from "node:fs/promises";
657
- import { dirname as dirname2 } from "node:path";
658
- var DOCS_QUERY_MAX = 500;
659
- var PREFETCH_TIMEOUT_MS = 12e3;
660
- var AUGMENT_WAIT_MS = 9e3;
661
- var MAX_DOCS_CHARS = 1e5;
662
- var MAX_BODY_BYTES = 1e6;
663
- var POLL_MS = 100;
664
- var PREFETCH_SCRIPT = [
665
- "const { renameSync, rmSync, writeFileSync } = require('node:fs');",
666
- "const { basename, dirname, join } = require('node:path');",
667
- "const [url, out, agent, timeout, max] = process.argv.slice(1);",
668
- "const tmp = join(dirname(out), '.' + basename(out) + '.' + process.pid + '.tmp');",
669
- // The deadline is a plain timer that answers and exits, not an
670
- // `AbortSignal.timeout`: that one's timer does not hold the process open, so
671
- // a stalled lookup let it exit without writing anything.
672
- "const timer = setTimeout(() => done(0, ''), Number(timeout));",
673
- "const done = (status, text) => {",
674
- " clearTimeout(timer);",
675
- " try {",
676
- " writeFileSync(tmp, JSON.stringify({ status, text }), { mode: 0o600, flag: 'wx' });",
677
- " renameSync(tmp, out);",
678
- " } catch {",
679
- " try { rmSync(tmp, { force: true }); } catch {}",
680
- " }",
681
- " process.exit(0);",
682
- "};",
683
- "fetch(url, {",
684
- " headers: { accept: 'text/plain', 'user-agent': agent },",
685
- " redirect: 'error',",
686
- "})",
687
- " .then(async (res) => done(res.status, res.ok ? (await res.text()).slice(0, Number(max)) : ''))",
688
- " .catch(() => done(0, ''));"
689
- ].join("\n");
690
- function prefetchEnv(env) {
691
- return proxyVariable(env) === void 0 ? env : { ...env, NODE_USE_ENV_PROXY: "1" };
692
- }
693
- function spawnPrefetch(job) {
694
- const child = spawn(
695
- process.execPath,
696
- [
697
- "-e",
698
- PREFETCH_SCRIPT,
699
- job.url,
700
- job.out,
701
- job.userAgent,
702
- String(PREFETCH_TIMEOUT_MS),
703
- String(MAX_DOCS_CHARS)
704
- ],
705
- {
706
- detached: true,
707
- stdio: "ignore",
708
- // Never the session's project: a live child would pin its worktree.
709
- cwd: dirname2(job.out),
710
- env: prefetchEnv(process.env),
711
- windowsHide: true
712
- }
713
- );
714
- child.on("error", () => void 0);
715
- child.unref();
716
- }
717
- function onDeployment(value, baseUrl) {
718
- let url;
719
- let base;
720
- try {
721
- url = new URL(value);
722
- base = new URL(baseUrl);
723
- } catch {
724
- return null;
725
- }
726
- if (url.username !== "" || url.password !== "") return null;
727
- return isSameDeployment(url.origin, base.origin) ? url : null;
728
- }
729
- function docsUrl(endpoint, query, baseUrl) {
730
- const url = onDeployment(endpoint, baseUrl);
731
- if (url === null) return null;
732
- url.searchParams.set("query", query.slice(0, DOCS_QUERY_MAX));
733
- return url.toString();
734
- }
735
- function augmentTarget(offer, query, baseUrl) {
736
- if (offer.delivery === "offer") return null;
737
- if (offer.delivery === "augment") {
738
- if (offer.augmentUrl === void 0) return null;
739
- return onDeployment(offer.augmentUrl, baseUrl)?.toString() ?? null;
740
- }
741
- return docsUrl(offer.endpoint, query, baseUrl);
742
- }
743
- async function startAugment(call, offer, baseUrl, deps) {
744
- if (call.toolUseId === void 0) return false;
745
- const url = augmentTarget(offer, call.query, baseUrl);
746
- if (url === null) return false;
747
- const now = deps.now?.() ?? Date.now();
748
- if (!await claimQuery(deps.dataDir, call.sessionId, call.agentId, call.query, now)) {
749
- return false;
750
- }
751
- const out = await markAugment(
752
- deps.dataDir,
753
- call.sessionId,
754
- call.toolUseId,
755
- { provider: offer.provider, ...offer.label !== void 0 ? { label: offer.label } : {} },
756
- now
757
- );
758
- if (out === null) return false;
759
- try {
760
- (deps.prefetch ?? spawnPrefetch)({ url, out, userAgent: composeUserAgent() });
761
- return true;
762
- } catch {
763
- return false;
764
- }
765
- }
766
- async function finishAugment(call, deps) {
767
- if (call.toolUseId === void 0) return null;
768
- const now = deps.now?.() ?? Date.now();
769
- const marker = await augmentOf(deps.dataDir, call.sessionId, call.toolUseId, now);
770
- if (marker === null) return null;
771
- if (call.search === null) return { updatedToolOutput: null };
772
- const budget = Math.min(
773
- deps.augmentWaitMs ?? AUGMENT_WAIT_MS,
774
- PREFETCH_TIMEOUT_MS + 1e3 - (now - marker.at)
775
- );
776
- const answer = await awaitBody(marker.body, Date.now() + Math.max(0, budget));
777
- await rm2(marker.body, { force: true }).catch(() => void 0);
778
- const text = answer?.status === 200 ? answer.text.trim() : "";
779
- if (text.length === 0) return { updatedToolOutput: null };
780
- return {
781
- updatedToolOutput: {
782
- ...call.search.raw,
783
- results: [
784
- docsLine(marker.label ?? `${marker.provider || "library"} docs`, text),
785
- ...call.search.results
786
- ]
787
- }
788
- };
789
- }
790
- function docsLine(name, text) {
791
- return `Tenjin router added ${name} for this search (free). If they don't cover it, use the web results below.
792
-
793
- ${text}`;
794
- }
795
- async function awaitBody(path, deadline) {
796
- for (; ; ) {
797
- const body = await readBody(path);
798
- if (body !== null) return body;
799
- const left = deadline - Date.now();
800
- if (left <= 0) return null;
801
- await new Promise((resolve) => setTimeout(resolve, Math.min(POLL_MS, left)));
802
- }
803
- }
804
- async function readBody(path) {
805
- const file = await open3(path, constants2.O_RDONLY | constants2.O_NOFOLLOW).catch(() => void 0);
806
- if (file === void 0) return null;
807
- try {
808
- if ((await file.stat()).size > MAX_BODY_BYTES) return { status: 0, text: "" };
809
- const parsed = JSON.parse(await file.readFile("utf8"));
810
- const { status, text } = parsed ?? {};
811
- if (typeof status !== "number" || typeof text !== "string") return { status: 0, text: "" };
812
- return { status, text: text.slice(0, MAX_DOCS_CHARS) };
813
- } catch {
814
- return { status: 0, text: "" };
815
- } finally {
816
- await file.close().catch(() => void 0);
817
- }
818
- }
819
-
820
657
  // src/router/hooks.ts
821
658
  var PromptEventSchema = external_exports.object({
822
659
  session_id: external_exports.string().min(1).max(200),
@@ -886,7 +723,7 @@ function decodeEvent(raw) {
886
723
  kind: "shortfall",
887
724
  eventName: shortfall.data.hook_event_name,
888
725
  nativeOutcome: shortfallOf(shortfall.data),
889
- search: searchOf(shortfall.data),
726
+ ...shortfall.data.is_interrupt === true ? { interrupted: true } : {},
890
727
  savedPdf: savedPdfIn(shortfall.data),
891
728
  ...nativeCallOf(shortfall.data)
892
729
  };
@@ -982,13 +819,6 @@ function answersOf(response, input) {
982
819
  }
983
820
  return null;
984
821
  }
985
- function searchOf(event) {
986
- if (event.hook_event_name !== "PostToolUse" || event.tool_name !== "WebSearch") return null;
987
- const response = event.tool_response;
988
- if (response === null || typeof response !== "object" || Array.isArray(response)) return null;
989
- const raw = response;
990
- return Array.isArray(raw.results) ? { raw, results: raw.results } : null;
991
- }
992
822
  function savedPdfIn(event) {
993
823
  if (event.hook_event_name !== "PostToolUse" || event.tool_name !== "WebFetch") return null;
994
824
  const response = event.tool_response;
@@ -1023,6 +853,9 @@ function savedPdfHint(path) {
1023
853
  function shortfallOffer(tool, hint, host) {
1024
854
  return `${HINT_SOURCE}: your ${tool} call came back short. Optional: ${toolNamed(hint, host)}`;
1025
855
  }
856
+ function noteLine(line, host) {
857
+ return `${HINT_SOURCE}: your WebSearch call ran. Optional: ${toolNamed(line, host)}`;
858
+ }
1026
859
  var NEAR_EMPTY_BYTES = 64;
1027
860
  function shortfallOf(event) {
1028
861
  if (event.hook_event_name === "PostToolUseFailure") {
@@ -1315,8 +1148,8 @@ async function routeNativeCall(event, pending, deps, opts = {}) {
1315
1148
  };
1316
1149
  }
1317
1150
  if (opts.passFree === true && isFree(outcome)) {
1318
- await footer.close(outcome, { withheld: "free lookup, call runs" });
1319
- return { offer: outcome, free: true, baseUrl: resolveBaseUrl(deps, router.config) };
1151
+ const close = (shown) => footer.close(outcome, shown ? void 0 : { withheld: "free lookup, call runs" });
1152
+ return { offer: outcome, free: true, close };
1320
1153
  }
1321
1154
  const vetted = await vetOffer(
1322
1155
  outcome,
@@ -1363,24 +1196,17 @@ async function runNativeHook(raw, deps) {
1363
1196
  });
1364
1197
  if (routed.offer === null) return routed.outcome;
1365
1198
  if (routed.free === true) {
1366
- const { pending } = event;
1367
- const augmenting = pending.tool === "WebSearch" && await startAugment(
1368
- {
1369
- sessionId: session,
1370
- query: pending.query,
1371
- ...event.agentId !== void 0 ? { agentId: event.agentId } : {},
1372
- ...event.toolUseId !== void 0 ? { toolUseId: event.toolUseId } : {}
1373
- },
1374
- routed.offer,
1375
- routed.baseUrl,
1376
- deps
1377
- );
1199
+ const { pending, toolUseId } = event;
1200
+ const now = deps.now?.() ?? Date.now();
1201
+ const { id, hint } = routed.offer;
1202
+ const noted = pending.tool === "WebSearch" && routed.offer.delivery === "note" && toolUseId !== void 0 && await claimNote(deps.dataDir, session, event.agentId, pending.query, now) && await markNoted(deps.dataDir, session, toolUseId, { offerId: id, line: hint }, now);
1203
+ await routed.close(noted);
1378
1204
  return {
1379
1205
  response: null,
1380
1206
  action: "execute",
1381
1207
  id: routed.offer.id,
1382
1208
  free: true,
1383
- ...augmenting ? { augmenting: true } : {}
1209
+ ...noted ? { noted: true } : {}
1384
1210
  };
1385
1211
  }
1386
1212
  if (event.toolUseId !== void 0) {
@@ -1438,6 +1264,7 @@ async function runAskHook(raw, deps) {
1438
1264
  });
1439
1265
  if (routed.offer === null) return routed.outcome;
1440
1266
  if (routed.free === true) {
1267
+ await routed.close(false);
1441
1268
  return { response: null, action: routed.offer.action, id: routed.offer.id, free: true };
1442
1269
  }
1443
1270
  if (event.toolUseId !== void 0) {
@@ -1454,28 +1281,28 @@ async function runAskHook(raw, deps) {
1454
1281
  async function runShortfallHook(raw, deps) {
1455
1282
  const event = eventOf(raw, deps);
1456
1283
  if (event?.kind !== "shortfall") return { response: null };
1457
- const augment = await finishAugment(
1458
- {
1459
- sessionId: localSession(event.sessionId, deps),
1460
- search: event.search,
1461
- ...event.toolUseId !== void 0 ? { toolUseId: event.toolUseId } : {}
1462
- },
1463
- deps
1284
+ const note = event.toolUseId === void 0 ? null : await noteOf(
1285
+ deps.dataDir,
1286
+ localSession(event.sessionId, deps),
1287
+ event.toolUseId,
1288
+ deps.now?.()
1464
1289
  );
1465
- if (augment !== null && augment.updatedToolOutput !== null) {
1290
+ if (note !== null) {
1291
+ if (event.interrupted === true) return { response: null };
1466
1292
  return {
1467
1293
  response: {
1468
1294
  hookSpecificOutput: {
1469
- hookEventName: "PostToolUse",
1470
- updatedToolOutput: augment.updatedToolOutput
1295
+ hookEventName: event.eventName,
1296
+ additionalContext: noteLine(note.line, hostOf(deps))
1471
1297
  }
1472
1298
  },
1473
- augmented: "added"
1299
+ action: "execute",
1300
+ id: note.offerId,
1301
+ noted: true
1474
1302
  };
1475
1303
  }
1476
1304
  if (event.savedPdf !== null) return await pointAtSavedPdf(event, event.savedPdf, deps);
1477
- const outcome = await offerOnShortfall(event, deps, augment !== null);
1478
- return augment === null ? outcome : { ...outcome, augmented: "nothing" };
1305
+ return offerOnShortfall(event, deps);
1479
1306
  }
1480
1307
  async function pointAtSavedPdf(event, path, deps) {
1481
1308
  if (await routerFor(event.cwd, deps) === null) return { response: null };
@@ -1489,7 +1316,7 @@ async function pointAtSavedPdf(event, path, deps) {
1489
1316
  savedPdf: true
1490
1317
  };
1491
1318
  }
1492
- async function offerOnShortfall(event, deps, docsJustMissed = false) {
1319
+ async function offerOnShortfall(event, deps) {
1493
1320
  const { nativeOutcome, pending, eventName } = event;
1494
1321
  if (nativeOutcome === null) return { response: null };
1495
1322
  if (pending === null) return { response: null };
@@ -1503,8 +1330,6 @@ async function offerOnShortfall(event, deps, docsJustMissed = false) {
1503
1330
  }
1504
1331
  const routed = await routeNativeCall(event, pending, deps, { nativeOutcome });
1505
1332
  if (routed.offer === null) return { ...routed.outcome, nativeOutcome };
1506
- if (docsJustMissed && isFree(routed.offer))
1507
- return { response: null, nativeOutcome, action: "execute" };
1508
1333
  return {
1509
1334
  response: {
1510
1335
  hookSpecificOutput: {
@@ -1612,6 +1437,9 @@ async function openFooter(deps, sessionId, operation) {
1612
1437
  if (withheld === void 0 && isOffer(decision)) {
1613
1438
  await bindDecision(deps.dataDir, sessionId, decision.id, now());
1614
1439
  await storeSpecs(deps.dataDir, decision.specs);
1440
+ if (isFree(decision) && decision.label !== void 0) {
1441
+ await storeLabel(deps.dataDir, decision.id, decision.label);
1442
+ }
1615
1443
  if (decision.action === "discovered" && decision.choices !== void 0) {
1616
1444
  await storeChoices(deps.dataDir, decision.id, {
1617
1445
  choices: decision.choices,
@@ -1756,7 +1584,7 @@ async function runHookCommand(kind, io, deps) {
1756
1584
  const raw = await (deps.readEvent ?? readStdin)();
1757
1585
  const event = JSON.parse(raw);
1758
1586
  if (deps.harness === "codex") {
1759
- const { codexResponse } = await import("./codex-event-TYVES3UX.js");
1587
+ const { codexResponse } = await import("./codex-event-ZO2GEFE6.js");
1760
1588
  response = codexResponse(await runHookKind(kind, event, deps));
1761
1589
  } else {
1762
1590
  if (!launchedByPlugin(deps.env) && await sessionServedByPlugin(deps.dataDir, event)) return;
@@ -1846,4 +1674,4 @@ export {
1846
1674
  runHookCommand,
1847
1675
  runHookKind
1848
1676
  };
1849
- //# sourceMappingURL=chunk-JRZBBPO6.js.map
1677
+ //# sourceMappingURL=chunk-ZDZERB6L.js.map