tenjin-cli 0.1.0-alpha.19 → 0.1.0-alpha.20

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 (100) hide show
  1. package/dist/{_esm-OVVGTKHH.js → _esm-CE7KNONL.js} +4 -4
  2. package/dist/{chunk-AMG4SONW.js → chunk-2E6GVIRP.js} +9 -9
  3. package/dist/{chunk-2SQEFBAM.js → chunk-3BS55ANY.js} +21 -4
  4. package/dist/chunk-3BS55ANY.js.map +1 -0
  5. package/dist/{chunk-XNP6VUAJ.js → chunk-4AS52HUG.js} +3 -3
  6. package/dist/{chunk-LSWVVSFX.js → chunk-4M5FBWT5.js} +18 -50
  7. package/dist/chunk-4M5FBWT5.js.map +1 -0
  8. package/dist/{chunk-ZDKEU2GF.js → chunk-5FYKPQNX.js} +3 -3
  9. package/dist/{chunk-5DOHKQ24.js → chunk-5KD5HRAJ.js} +10 -2
  10. package/dist/{chunk-5DOHKQ24.js.map → chunk-5KD5HRAJ.js.map} +1 -1
  11. package/dist/{chunk-ZTFIQC4C.js → chunk-72UHZRG6.js} +2 -2
  12. package/dist/{chunk-TDGN476R.js → chunk-7ACHDNJA.js} +3 -3
  13. package/dist/{chunk-Y66XUXVI.js → chunk-AWQPGIR6.js} +5 -5
  14. package/dist/{chunk-A6CY6BUW.js → chunk-BTX2QE2Y.js} +3 -3
  15. package/dist/{chunk-UNV4K45L.js → chunk-CCDOV45D.js} +6 -2
  16. package/dist/{chunk-UNV4K45L.js.map → chunk-CCDOV45D.js.map} +1 -1
  17. package/dist/{chunk-AISBL7EY.js → chunk-CXUYCDPX.js} +4 -4
  18. package/dist/{chunk-VFVFVQM6.js → chunk-HH3PDYIG.js} +5 -5
  19. package/dist/{chunk-FPUPBQHX.js → chunk-HPWO4O6S.js} +2 -2
  20. package/dist/{chunk-3VYGDRRL.js → chunk-LI44XLMB.js} +5 -5
  21. package/dist/{chunk-WUU3BH6G.js → chunk-LN2HISWU.js} +2 -2
  22. package/dist/{chunk-6DCELMQA.js → chunk-N35E6CM2.js} +6 -6
  23. package/dist/{chunk-FHBGTOFA.js → chunk-NSG5TVZQ.js} +8 -8
  24. package/dist/{chunk-PZQRSZJV.js → chunk-P42QX3QF.js} +2 -2
  25. package/dist/{chunk-PZQRSZJV.js.map → chunk-P42QX3QF.js.map} +1 -1
  26. package/dist/{chunk-SCAOYGKX.js → chunk-PO4HAXAW.js} +55 -31
  27. package/dist/chunk-PO4HAXAW.js.map +1 -0
  28. package/dist/{chunk-KTAW4KGH.js → chunk-RGVOODF4.js} +5 -5
  29. package/dist/chunk-RPR2C2JO.js +112 -0
  30. package/dist/chunk-RPR2C2JO.js.map +1 -0
  31. package/dist/{chunk-2BKS2FVE.js → chunk-TU7XH3JJ.js} +5 -1
  32. package/dist/chunk-TU7XH3JJ.js.map +1 -0
  33. package/dist/{chunk-XDADPAWW.js → chunk-YEBNE5NW.js} +23 -23
  34. package/dist/{chunk-BG2EXNAA.js → chunk-YREKMJPP.js} +3 -3
  35. package/dist/{cli-456F77ZY.js → cli-XJQYUOHI.js} +32 -24
  36. package/dist/{cli-456F77ZY.js.map → cli-XJQYUOHI.js.map} +1 -1
  37. package/dist/{config-BLUWOH6S.js → config-KMJLFPSI.js} +8 -8
  38. package/dist/{doctor-PS45CR3T.js → doctor-KMN55D7U.js} +23 -23
  39. package/dist/{fund-4SW2ZBWC.js → fund-LT6ZPGEQ.js} +20 -20
  40. package/dist/{hook-command-YTV7X333.js → hook-command-U5XPEHAJ.js} +31 -23
  41. package/dist/hook-command-U5XPEHAJ.js.map +1 -0
  42. package/dist/index.js +5 -2
  43. package/dist/index.js.map +1 -1
  44. package/dist/{install-U4BIDCHH.js → install-MMNXJ5LM.js} +11 -11
  45. package/dist/install-identity-B7FVIWML.js +27 -0
  46. package/dist/{install-wallet-EYHELQMG.js → install-wallet-XMVUBCHS.js} +14 -14
  47. package/dist/{mcp-AC4PIXH5.js → mcp-TUPRIPSI.js} +33 -29
  48. package/dist/{mcp-AC4PIXH5.js.map → mcp-TUPRIPSI.js.map} +1 -1
  49. package/dist/{paths-P2N4JTDZ.js → paths-LRMWNTJP.js} +4 -2
  50. package/dist/{pay-VJOP6TFT.js → pay-XAWW3NV3.js} +19 -19
  51. package/dist/{send-YH75Z6LB.js → send-HESQYRKM.js} +14 -14
  52. package/dist/{status-5CHCDLUE.js → status-ANZPRZJJ.js} +6 -6
  53. package/dist/{status-line-CZAZUOAY.js → status-line-J3TUWVRQ.js} +7 -7
  54. package/dist/{status-line-wiring-2ABDVXSJ.js → status-line-wiring-HSV7DXO5.js} +5 -5
  55. package/dist/tenjin-daemon.mjs +141 -4
  56. package/dist/{uninstall-BYVGAQMO.js → uninstall-GUU34YKP.js} +11 -11
  57. package/dist/{update-7QJDSHST.js → update-KO2NZRJ5.js} +6 -6
  58. package/dist/{viemAdapter-By13KInL-N2GIVMZ7.js → viemAdapter-By13KInL-X2VY6CY3.js} +2 -2
  59. package/dist/{wallet-YZOXIXBC.js → wallet-3URC5QPK.js} +14 -14
  60. package/dist/wallet-3URC5QPK.js.map +1 -0
  61. package/docs/agent-permissions.md +1 -1
  62. package/package.json +1 -1
  63. package/dist/chunk-2BKS2FVE.js.map +0 -1
  64. package/dist/chunk-2SQEFBAM.js.map +0 -1
  65. package/dist/chunk-LSWVVSFX.js.map +0 -1
  66. package/dist/chunk-SCAOYGKX.js.map +0 -1
  67. package/dist/hook-command-YTV7X333.js.map +0 -1
  68. /package/dist/{_esm-OVVGTKHH.js.map → _esm-CE7KNONL.js.map} +0 -0
  69. /package/dist/{chunk-AMG4SONW.js.map → chunk-2E6GVIRP.js.map} +0 -0
  70. /package/dist/{chunk-XNP6VUAJ.js.map → chunk-4AS52HUG.js.map} +0 -0
  71. /package/dist/{chunk-ZDKEU2GF.js.map → chunk-5FYKPQNX.js.map} +0 -0
  72. /package/dist/{chunk-ZTFIQC4C.js.map → chunk-72UHZRG6.js.map} +0 -0
  73. /package/dist/{chunk-TDGN476R.js.map → chunk-7ACHDNJA.js.map} +0 -0
  74. /package/dist/{chunk-Y66XUXVI.js.map → chunk-AWQPGIR6.js.map} +0 -0
  75. /package/dist/{chunk-A6CY6BUW.js.map → chunk-BTX2QE2Y.js.map} +0 -0
  76. /package/dist/{chunk-AISBL7EY.js.map → chunk-CXUYCDPX.js.map} +0 -0
  77. /package/dist/{chunk-VFVFVQM6.js.map → chunk-HH3PDYIG.js.map} +0 -0
  78. /package/dist/{chunk-FPUPBQHX.js.map → chunk-HPWO4O6S.js.map} +0 -0
  79. /package/dist/{chunk-3VYGDRRL.js.map → chunk-LI44XLMB.js.map} +0 -0
  80. /package/dist/{chunk-WUU3BH6G.js.map → chunk-LN2HISWU.js.map} +0 -0
  81. /package/dist/{chunk-6DCELMQA.js.map → chunk-N35E6CM2.js.map} +0 -0
  82. /package/dist/{chunk-FHBGTOFA.js.map → chunk-NSG5TVZQ.js.map} +0 -0
  83. /package/dist/{chunk-KTAW4KGH.js.map → chunk-RGVOODF4.js.map} +0 -0
  84. /package/dist/{chunk-XDADPAWW.js.map → chunk-YEBNE5NW.js.map} +0 -0
  85. /package/dist/{chunk-BG2EXNAA.js.map → chunk-YREKMJPP.js.map} +0 -0
  86. /package/dist/{config-BLUWOH6S.js.map → config-KMJLFPSI.js.map} +0 -0
  87. /package/dist/{doctor-PS45CR3T.js.map → doctor-KMN55D7U.js.map} +0 -0
  88. /package/dist/{fund-4SW2ZBWC.js.map → fund-LT6ZPGEQ.js.map} +0 -0
  89. /package/dist/{install-U4BIDCHH.js.map → install-MMNXJ5LM.js.map} +0 -0
  90. /package/dist/{paths-P2N4JTDZ.js.map → install-identity-B7FVIWML.js.map} +0 -0
  91. /package/dist/{install-wallet-EYHELQMG.js.map → install-wallet-XMVUBCHS.js.map} +0 -0
  92. /package/dist/{pay-VJOP6TFT.js.map → paths-LRMWNTJP.js.map} +0 -0
  93. /package/dist/{status-line-wiring-2ABDVXSJ.js.map → pay-XAWW3NV3.js.map} +0 -0
  94. /package/dist/{send-YH75Z6LB.js.map → send-HESQYRKM.js.map} +0 -0
  95. /package/dist/{status-5CHCDLUE.js.map → status-ANZPRZJJ.js.map} +0 -0
  96. /package/dist/{status-line-CZAZUOAY.js.map → status-line-J3TUWVRQ.js.map} +0 -0
  97. /package/dist/{viemAdapter-By13KInL-N2GIVMZ7.js.map → status-line-wiring-HSV7DXO5.js.map} +0 -0
  98. /package/dist/{uninstall-BYVGAQMO.js.map → uninstall-GUU34YKP.js.map} +0 -0
  99. /package/dist/{update-7QJDSHST.js.map → update-KO2NZRJ5.js.map} +0 -0
  100. /package/dist/{wallet-YZOXIXBC.js.map → viemAdapter-By13KInL-X2VY6CY3.js.map} +0 -0
@@ -12,6 +12,7 @@ import {
12
12
  defaultDataDir,
13
13
  hookHealthPath,
14
14
  hooksDir,
15
+ installIdPath,
15
16
  loopDbPath,
16
17
  passphraseBlobPath,
17
18
  passphraseBlobPathFor,
@@ -21,7 +22,7 @@ import {
21
22
  updateCheckPath,
22
23
  vitestReporterPath,
23
24
  walletPath
24
- } from "./chunk-2BKS2FVE.js";
25
+ } from "./chunk-TU7XH3JJ.js";
25
26
  import "./chunk-ZXTAQYNA.js";
26
27
  export {
27
28
  VITEST_REPORTER_FILE,
@@ -36,6 +37,7 @@ export {
36
37
  defaultDataDir,
37
38
  hookHealthPath,
38
39
  hooksDir,
40
+ installIdPath,
39
41
  loopDbPath,
40
42
  passphraseBlobPath,
41
43
  passphraseBlobPathFor,
@@ -46,4 +48,4 @@ export {
46
48
  vitestReporterPath,
47
49
  walletPath
48
50
  };
49
- //# sourceMappingURL=paths-P2N4JTDZ.js.map
51
+ //# sourceMappingURL=paths-LRMWNTJP.js.map
@@ -3,42 +3,42 @@ import {
3
3
  MAX_PAID_LEG_TIMEOUT_MS,
4
4
  paidLegTimeoutMs,
5
5
  runPay
6
- } from "./chunk-SCAOYGKX.js";
6
+ } from "./chunk-PO4HAXAW.js";
7
7
  import "./chunk-2G2WLVHB.js";
8
- import "./chunk-KTAW4KGH.js";
9
- import "./chunk-2SQEFBAM.js";
8
+ import "./chunk-RGVOODF4.js";
10
9
  import "./chunk-TTNESUPQ.js";
11
- import "./chunk-FPUPBQHX.js";
10
+ import "./chunk-HPWO4O6S.js";
12
11
  import "./chunk-POUWHWID.js";
13
12
  import "./chunk-XZKD7DIF.js";
14
13
  import "./chunk-LHHMV4GU.js";
15
- import "./chunk-A6CY6BUW.js";
14
+ import "./chunk-BTX2QE2Y.js";
16
15
  import "./chunk-3KKKB2AQ.js";
17
- import "./chunk-XDADPAWW.js";
18
- import "./chunk-BG2EXNAA.js";
19
- import "./chunk-TDGN476R.js";
20
- import "./chunk-Y66XUXVI.js";
21
- import "./chunk-6DCELMQA.js";
16
+ import "./chunk-YEBNE5NW.js";
17
+ import "./chunk-YREKMJPP.js";
18
+ import "./chunk-7ACHDNJA.js";
19
+ import "./chunk-AWQPGIR6.js";
20
+ import "./chunk-N35E6CM2.js";
21
+ import "./chunk-JRGFKVAZ.js";
22
22
  import "./chunk-5IEP5EGE.js";
23
23
  import "./chunk-EGELTSPU.js";
24
24
  import "./chunk-KG3D7FIF.js";
25
- import "./chunk-ZTFIQC4C.js";
25
+ import "./chunk-RBJPAZFI.js";
26
+ import "./chunk-BPMWXTFX.js";
27
+ import "./chunk-72UHZRG6.js";
26
28
  import "./chunk-7QKHZQKW.js";
29
+ import "./chunk-3BS55ANY.js";
27
30
  import "./chunk-MEFB5KHA.js";
28
31
  import "./chunk-2I4QTOLB.js";
29
- import "./chunk-5DOHKQ24.js";
32
+ import "./chunk-5KD5HRAJ.js";
30
33
  import "./chunk-O2JYBOUO.js";
31
- import "./chunk-UNV4K45L.js";
32
- import "./chunk-PZQRSZJV.js";
34
+ import "./chunk-CCDOV45D.js";
35
+ import "./chunk-P42QX3QF.js";
33
36
  import "./chunk-JLEF5WHM.js";
34
- import "./chunk-2BKS2FVE.js";
35
- import "./chunk-JRGFKVAZ.js";
36
- import "./chunk-RBJPAZFI.js";
37
- import "./chunk-BPMWXTFX.js";
37
+ import "./chunk-TU7XH3JJ.js";
38
38
  import "./chunk-ZXTAQYNA.js";
39
39
  export {
40
40
  MAX_PAID_LEG_TIMEOUT_MS,
41
41
  paidLegTimeoutMs,
42
42
  runPay
43
43
  };
44
- //# sourceMappingURL=pay-VJOP6TFT.js.map
44
+ //# sourceMappingURL=pay-XAWW3NV3.js.map
@@ -10,16 +10,17 @@ import {
10
10
  broadcastUsdcSend,
11
11
  getUsdcBalance,
12
12
  prepareUsdcSend
13
- } from "./chunk-A6CY6BUW.js";
13
+ } from "./chunk-BTX2QE2Y.js";
14
14
  import "./chunk-3KKKB2AQ.js";
15
15
  import {
16
16
  describeWallet,
17
17
  resolveWalletProvider
18
- } from "./chunk-XDADPAWW.js";
19
- import "./chunk-BG2EXNAA.js";
20
- import "./chunk-TDGN476R.js";
21
- import "./chunk-Y66XUXVI.js";
22
- import "./chunk-6DCELMQA.js";
18
+ } from "./chunk-YEBNE5NW.js";
19
+ import "./chunk-YREKMJPP.js";
20
+ import "./chunk-7ACHDNJA.js";
21
+ import "./chunk-AWQPGIR6.js";
22
+ import "./chunk-N35E6CM2.js";
23
+ import "./chunk-JRGFKVAZ.js";
23
24
  import "./chunk-5IEP5EGE.js";
24
25
  import {
25
26
  formatEther,
@@ -27,26 +28,25 @@ import {
27
28
  isAddress
28
29
  } from "./chunk-EGELTSPU.js";
29
30
  import "./chunk-KG3D7FIF.js";
30
- import "./chunk-ZTFIQC4C.js";
31
+ import "./chunk-RBJPAZFI.js";
32
+ import "./chunk-BPMWXTFX.js";
33
+ import "./chunk-72UHZRG6.js";
31
34
  import "./chunk-MEFB5KHA.js";
32
35
  import "./chunk-2I4QTOLB.js";
33
36
  import {
34
37
  resolveContextSettings
35
- } from "./chunk-5DOHKQ24.js";
38
+ } from "./chunk-5KD5HRAJ.js";
36
39
  import {
37
40
  parseUsdToAtomic,
38
41
  toMoney
39
42
  } from "./chunk-O2JYBOUO.js";
40
43
  import {
41
44
  SEND_MAX_UNSET
42
- } from "./chunk-UNV4K45L.js";
45
+ } from "./chunk-CCDOV45D.js";
43
46
  import {
44
47
  CliError
45
48
  } from "./chunk-JLEF5WHM.js";
46
- import "./chunk-2BKS2FVE.js";
47
- import "./chunk-JRGFKVAZ.js";
48
- import "./chunk-RBJPAZFI.js";
49
- import "./chunk-BPMWXTFX.js";
49
+ import "./chunk-TU7XH3JJ.js";
50
50
  import "./chunk-ZXTAQYNA.js";
51
51
 
52
52
  // src/commands/send.ts
@@ -222,4 +222,4 @@ This moves funds out of the agent wallet and cannot be undone. [y/N] `;
222
222
  export {
223
223
  runSend
224
224
  };
225
- //# sourceMappingURL=send-YH75Z6LB.js.map
225
+ //# sourceMappingURL=send-HESQYRKM.js.map
@@ -1,14 +1,14 @@
1
1
  import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
- import "./chunk-BG2EXNAA.js";
2
+ import "./chunk-YREKMJPP.js";
3
3
  import {
4
4
  readSpendSummary,
5
5
  spentOf
6
- } from "./chunk-TDGN476R.js";
6
+ } from "./chunk-7ACHDNJA.js";
7
7
  import "./chunk-MEFB5KHA.js";
8
8
  import "./chunk-2I4QTOLB.js";
9
9
  import {
10
10
  resolveContextSettings
11
- } from "./chunk-5DOHKQ24.js";
11
+ } from "./chunk-5KD5HRAJ.js";
12
12
  import {
13
13
  toMoney
14
14
  } from "./chunk-O2JYBOUO.js";
@@ -16,9 +16,9 @@ import {
16
16
  RETIRED_PAYMENT_GUIDANCE,
17
17
  loadRawConfig,
18
18
  retiredPaymentKeys
19
- } from "./chunk-UNV4K45L.js";
19
+ } from "./chunk-CCDOV45D.js";
20
20
  import "./chunk-JLEF5WHM.js";
21
- import "./chunk-2BKS2FVE.js";
21
+ import "./chunk-TU7XH3JJ.js";
22
22
  import "./chunk-ZXTAQYNA.js";
23
23
 
24
24
  // src/router/status.ts
@@ -68,4 +68,4 @@ async function runRouterStatus(ctx, deps = {}) {
68
68
  export {
69
69
  runRouterStatus
70
70
  };
71
- //# sourceMappingURL=status-5CHCDLUE.js.map
71
+ //# sourceMappingURL=status-ANZPRZJJ.js.map
@@ -1,22 +1,22 @@
1
1
  import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
2
  import {
3
3
  renderProgress
4
- } from "./chunk-LSWVVSFX.js";
4
+ } from "./chunk-4M5FBWT5.js";
5
5
  import {
6
6
  routerSettings
7
- } from "./chunk-AISBL7EY.js";
8
- import "./chunk-5DOHKQ24.js";
7
+ } from "./chunk-CXUYCDPX.js";
8
+ import "./chunk-5KD5HRAJ.js";
9
9
  import "./chunk-O2JYBOUO.js";
10
- import "./chunk-UNV4K45L.js";
10
+ import "./chunk-CCDOV45D.js";
11
11
  import "./chunk-JLEF5WHM.js";
12
- import "./chunk-2BKS2FVE.js";
12
+ import "./chunk-TU7XH3JJ.js";
13
13
  import "./chunk-ZXTAQYNA.js";
14
14
 
15
15
  // src/router/status-line.ts
16
16
  var MAX_EVENT_BYTES = 64e3;
17
17
  var STDIN_TIMEOUT_MS = 1e3;
18
18
  async function statusLineMain() {
19
- const { dataDir } = await import("./paths-P2N4JTDZ.js");
19
+ const { dataDir } = await import("./paths-LRMWNTJP.js");
20
20
  await runStatusLine(
21
21
  { stdout: process.stdout, stderr: process.stderr, isTTY: false },
22
22
  { dataDir: dataDir(process.env) }
@@ -84,4 +84,4 @@ export {
84
84
  runStatusLine,
85
85
  statusLineMain
86
86
  };
87
- //# sourceMappingURL=status-line-CZAZUOAY.js.map
87
+ //# sourceMappingURL=status-line-J3TUWVRQ.js.map
@@ -9,11 +9,11 @@ import {
9
9
  inspectStatusLine,
10
10
  removeStatusLine,
11
11
  statusLineMode
12
- } from "./chunk-WUU3BH6G.js";
13
- import "./chunk-ZDKEU2GF.js";
14
- import "./chunk-PZQRSZJV.js";
12
+ } from "./chunk-LN2HISWU.js";
13
+ import "./chunk-5FYKPQNX.js";
14
+ import "./chunk-P42QX3QF.js";
15
15
  import "./chunk-JLEF5WHM.js";
16
- import "./chunk-2BKS2FVE.js";
16
+ import "./chunk-TU7XH3JJ.js";
17
17
  import "./chunk-ZXTAQYNA.js";
18
18
  export {
19
19
  STATUS_LINE_COMMAND,
@@ -26,4 +26,4 @@ export {
26
26
  removeStatusLine,
27
27
  statusLineMode
28
28
  };
29
- //# sourceMappingURL=status-line-wiring-2ABDVXSJ.js.map
29
+ //# sourceMappingURL=status-line-wiring-HSV7DXO5.js.map
@@ -11,7 +11,7 @@ import { readFileSync as readFileSync4, statSync as statSync4 } from "node:fs";
11
11
  // package.json
12
12
  var package_default = {
13
13
  name: "tenjin-cli",
14
- version: "0.1.0-alpha.19",
14
+ version: "0.1.0-alpha.20",
15
15
  mcpName: "blog.tenjin/tenjin",
16
16
  type: "module",
17
17
  description: "x402 router for coding agents: one paid decision per lookup, a local wallet that pays each provider per call in USDC on Base.",
@@ -191,6 +191,45 @@ async function writeFileAtomic(targetPath, data, opts = {}) {
191
191
  throw err;
192
192
  }
193
193
  }
194
+ async function writeFileAtomicExclusive(targetPath, data, opts = {}) {
195
+ const dir = dirname(targetPath);
196
+ const fileMode = opts.mode ?? 420;
197
+ const dirMode = opts.dirMode ?? 493;
198
+ await mkdir(dir, { recursive: true, ...isWindows ? {} : { mode: dirMode } });
199
+ if (isWindows) {
200
+ const handle = await open(targetPath, "wx");
201
+ try {
202
+ await handle.writeFile(data);
203
+ await handle.sync();
204
+ } finally {
205
+ await handle.close();
206
+ }
207
+ return;
208
+ }
209
+ const tmpPath = join(dir, `.${basename(targetPath)}.${randomBytes(6).toString("hex")}.tmp`);
210
+ try {
211
+ const handle = await open(tmpPath, "wx", fileMode);
212
+ try {
213
+ await handle.writeFile(data);
214
+ await handle.chmod(fileMode);
215
+ await handle.sync();
216
+ } finally {
217
+ await handle.close();
218
+ }
219
+ await link(tmpPath, targetPath);
220
+ await fsyncDir(dir);
221
+ } finally {
222
+ await rm(tmpPath, { force: true }).catch(() => void 0);
223
+ }
224
+ }
225
+ async function fsyncDir(dir) {
226
+ const handle = await open(dir, "r");
227
+ try {
228
+ await handle.sync();
229
+ } finally {
230
+ await handle.close();
231
+ }
232
+ }
194
233
 
195
234
  // src/lib/codex-rules.ts
196
235
  import { execFile } from "node:child_process";
@@ -16103,6 +16142,9 @@ function isSameDeployment(a, b) {
16103
16142
  if (a === b) return true;
16104
16143
  return KNOWN_DEPLOYMENT_ORIGINS.has(a) && KNOWN_DEPLOYMENT_ORIGINS.has(b);
16105
16144
  }
16145
+ function knownDeploymentOrigins() {
16146
+ return [...KNOWN_DEPLOYMENT_ORIGINS];
16147
+ }
16106
16148
 
16107
16149
  // src/lib/client-meta.ts
16108
16150
  var TENJIN_PRODUCT = `tenjin-cli/${package_default.version}`;
@@ -16156,6 +16198,22 @@ function shelfBypassHeaders(url2, bypass) {
16156
16198
  function carriesBypassKey(headers) {
16157
16199
  return Object.keys(headers).some((name) => name.toLowerCase() === SHELF_BYPASS_HEADER);
16158
16200
  }
16201
+ var INSTALL_ID_HEADER = "tenjin-install-id";
16202
+ var tenjinIdentity;
16203
+ function setTenjinIdentity(identity) {
16204
+ tenjinIdentity = identity;
16205
+ }
16206
+ async function tenjinIdentityHeaders(url2) {
16207
+ const identity = tenjinIdentity;
16208
+ if (identity === void 0) return {};
16209
+ try {
16210
+ if (!(await identity.origins()).includes(new URL(url2).origin)) return {};
16211
+ const id = await identity.installId();
16212
+ return id !== void 0 ? { [INSTALL_ID_HEADER]: id } : {};
16213
+ } catch {
16214
+ return {};
16215
+ }
16216
+ }
16159
16217
  function applyUserAgent(headers, callerUserAgent) {
16160
16218
  headers.set("user-agent", composeUserAgent({ caller: callerUserAgent }));
16161
16219
  return headers;
@@ -16224,7 +16282,7 @@ async function httpRequest(url2, opts) {
16224
16282
  try {
16225
16283
  res = await doFetch(url2, {
16226
16284
  method: opts.method ?? "GET",
16227
- headers,
16285
+ headers: { ...headers, ...await tenjinIdentityHeaders(url2) },
16228
16286
  body,
16229
16287
  signal,
16230
16288
  ...pinned ? { redirect: "manual" } : {}
@@ -16463,6 +16521,9 @@ function defaultDataDir(home = homedir()) {
16463
16521
  function configPath(dir = dataDir()) {
16464
16522
  return join6(dir, "config.json");
16465
16523
  }
16524
+ function installIdPath(dir = dataDir()) {
16525
+ return join6(dir, "install-id");
16526
+ }
16466
16527
  function loopDbPath(dir = dataDir()) {
16467
16528
  return join6(dir, "loop.db");
16468
16529
  }
@@ -16721,6 +16782,13 @@ function isTeamShelfOrigin(origin, publicShelfUrl) {
16721
16782
  const publicOrigin = tryOrigin(publicShelfUrl);
16722
16783
  return publicOrigin === void 0 || !isSameDeployment(origin, publicOrigin);
16723
16784
  }
16785
+ function isTeamModeConfig(config2) {
16786
+ const secret = config2.shelfBypassSecret ?? CONFIG_DEFAULTS.shelfBypassSecret;
16787
+ if (typeof secret !== "string" || secret === "") return false;
16788
+ const origin = tryOrigin(config2.baseUrl ?? CONFIG_DEFAULTS.baseUrl);
16789
+ if (origin === void 0) return false;
16790
+ return isTeamShelfOrigin(origin, config2.publicShelfUrl ?? CONFIG_DEFAULTS.publicShelfUrl);
16791
+ }
16724
16792
  var ProjectConfigSchema = external_exports.object({
16725
16793
  publish: external_exports.object({
16726
16794
  mode: PublishModeSchema.optional(),
@@ -19520,6 +19588,74 @@ async function health(port, timeoutMs = HEALTH_MS) {
19520
19588
  }
19521
19589
  }
19522
19590
 
19591
+ // src/lib/install-identity.ts
19592
+ import { randomUUID } from "node:crypto";
19593
+ import { readFile as readFile3 } from "node:fs/promises";
19594
+
19595
+ // src/lib/errno.ts
19596
+ function hasCode(err, code) {
19597
+ return typeof err === "object" && err !== null && "code" in err && err.code === code;
19598
+ }
19599
+
19600
+ // src/lib/install-identity.ts
19601
+ var UUID_RE2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
19602
+ function parseInstallId(raw) {
19603
+ const id = raw.trim();
19604
+ return UUID_RE2.test(id) ? id : void 0;
19605
+ }
19606
+ async function readOrCreateInstallId(dir) {
19607
+ const path = installIdPath(dir);
19608
+ try {
19609
+ return parseInstallId(await readFile3(path, "utf8"));
19610
+ } catch (err) {
19611
+ if (!hasCode(err, "ENOENT")) return void 0;
19612
+ }
19613
+ const id = randomUUID();
19614
+ try {
19615
+ await writeFileAtomicExclusive(path, `${id}
19616
+ `, { mode: 384, dirMode: 448 });
19617
+ return id;
19618
+ } catch (err) {
19619
+ if (!hasCode(err, "EEXIST")) return void 0;
19620
+ }
19621
+ try {
19622
+ return parseInstallId(await readFile3(path, "utf8"));
19623
+ } catch {
19624
+ return void 0;
19625
+ }
19626
+ }
19627
+ function tryOrigin2(url2) {
19628
+ try {
19629
+ return new URL(url2).origin;
19630
+ } catch {
19631
+ return void 0;
19632
+ }
19633
+ }
19634
+ function tenjinOrigins(s) {
19635
+ const origins = new Set(knownDeploymentOrigins());
19636
+ const baseOrigin = tryOrigin2(s.baseUrl);
19637
+ if (baseOrigin !== void 0 && !s.teamMode) origins.add(baseOrigin);
19638
+ return [...origins];
19639
+ }
19640
+ function identityFor(dir, origins) {
19641
+ let install;
19642
+ return {
19643
+ origins,
19644
+ installId: () => install ??= readOrCreateInstallId(dir)
19645
+ };
19646
+ }
19647
+ function enableDaemonIdentity(dir, config2) {
19648
+ setTenjinIdentity(
19649
+ identityFor(dir, async () => {
19650
+ const c = config2();
19651
+ return tenjinOrigins({
19652
+ baseUrl: c.baseUrl,
19653
+ teamMode: isTeamModeConfig(c)
19654
+ });
19655
+ })
19656
+ );
19657
+ }
19658
+
19523
19659
  // src/daemon/lifecycle.ts
19524
19660
  import { createHash as createHash5 } from "node:crypto";
19525
19661
  import {
@@ -19756,7 +19892,7 @@ async function shutdown(d) {
19756
19892
  import { createServer } from "node:http";
19757
19893
 
19758
19894
  // src/hooks/fire.ts
19759
- import { randomUUID } from "node:crypto";
19895
+ import { randomUUID as randomUUID2 } from "node:crypto";
19760
19896
 
19761
19897
  // src/hooks/ask.ts
19762
19898
  var SHELF_RANK = { team: 4, keys: 3, public: 1 };
@@ -19955,7 +20091,7 @@ async function runFire(input, deps, clientSignal) {
19955
20091
  else clientSignal.addEventListener("abort", () => controller.abort(), { once: true });
19956
20092
  }
19957
20093
  const fire = {
19958
- id: randomUUID(),
20094
+ id: randomUUID2(),
19959
20095
  startedAt,
19960
20096
  deadlineMs,
19961
20097
  remaining: () => Math.max(0, deadlineMs - (deps.clock() - startedAt)),
@@ -20307,6 +20443,7 @@ async function main() {
20307
20443
  }
20308
20444
  let config2 = readKernelConfig(dataDir2, log);
20309
20445
  let mtime = configMtime(dataDir2);
20446
+ enableDaemonIdentity(dataDir2, () => config2);
20310
20447
  const clock = () => Date.now();
20311
20448
  const deps = {
20312
20449
  config: () => config2,
@@ -5,35 +5,35 @@ import {
5
5
  mcpScope,
6
6
  readMcpEntry,
7
7
  routerSettingsPath
8
- } from "./chunk-FHBGTOFA.js";
8
+ } from "./chunk-NSG5TVZQ.js";
9
9
  import {
10
10
  MCP_SERVER_NAME
11
11
  } from "./chunk-TGLKKLQG.js";
12
- import "./chunk-ZTFIQC4C.js";
12
+ import "./chunk-72UHZRG6.js";
13
13
  import {
14
14
  onPath,
15
15
  persistRouterProject
16
- } from "./chunk-AMG4SONW.js";
16
+ } from "./chunk-2E6GVIRP.js";
17
17
  import "./chunk-A36LQPHV.js";
18
18
  import "./chunk-2QYORQBF.js";
19
19
  import "./chunk-MEFB5KHA.js";
20
+ import "./chunk-CXUYCDPX.js";
20
21
  import "./chunk-2I4QTOLB.js";
21
- import "./chunk-AISBL7EY.js";
22
- import "./chunk-5DOHKQ24.js";
22
+ import "./chunk-5KD5HRAJ.js";
23
23
  import "./chunk-O2JYBOUO.js";
24
- import "./chunk-UNV4K45L.js";
24
+ import "./chunk-CCDOV45D.js";
25
25
  import {
26
26
  removeStatusLine
27
- } from "./chunk-WUU3BH6G.js";
27
+ } from "./chunk-LN2HISWU.js";
28
28
  import {
29
29
  inspectHooksFile,
30
30
  pruneHooks
31
- } from "./chunk-ZDKEU2GF.js";
32
- import "./chunk-PZQRSZJV.js";
31
+ } from "./chunk-5FYKPQNX.js";
32
+ import "./chunk-P42QX3QF.js";
33
33
  import {
34
34
  writeFileAtomic
35
35
  } from "./chunk-JLEF5WHM.js";
36
- import "./chunk-2BKS2FVE.js";
36
+ import "./chunk-TU7XH3JJ.js";
37
37
  import "./chunk-ZXTAQYNA.js";
38
38
 
39
39
  // src/router/uninstall.ts
@@ -162,4 +162,4 @@ export {
162
162
  MCP_REMOVE_COMMAND,
163
163
  runRouterUninstall
164
164
  };
165
- //# sourceMappingURL=uninstall-BYVGAQMO.js.map
165
+ //# sourceMappingURL=uninstall-GUU34YKP.js.map
@@ -5,21 +5,21 @@ import {
5
5
  fetchDistTags,
6
6
  isNewer,
7
7
  resolveTarget
8
- } from "./chunk-VFVFVQM6.js";
8
+ } from "./chunk-HH3PDYIG.js";
9
9
  import {
10
10
  emitWriteNotice,
11
11
  sanitizeForTerminal
12
- } from "./chunk-ZTFIQC4C.js";
13
- import "./chunk-UNV4K45L.js";
12
+ } from "./chunk-72UHZRG6.js";
13
+ import "./chunk-CCDOV45D.js";
14
14
  import {
15
15
  package_default
16
- } from "./chunk-PZQRSZJV.js";
16
+ } from "./chunk-P42QX3QF.js";
17
17
  import {
18
18
  CliError
19
19
  } from "./chunk-JLEF5WHM.js";
20
20
  import {
21
21
  defaultDataDir
22
- } from "./chunk-2BKS2FVE.js";
22
+ } from "./chunk-TU7XH3JJ.js";
23
23
  import "./chunk-ZXTAQYNA.js";
24
24
 
25
25
  // src/commands/update.ts
@@ -430,4 +430,4 @@ export {
430
430
  spawnCapture,
431
431
  versionFreeEntry
432
432
  };
433
- //# sourceMappingURL=update-7QJDSHST.js.map
433
+ //# sourceMappingURL=update-KO2NZRJ5.js.map
@@ -2,7 +2,7 @@ import { createRequire as __tenjinCreateRequire } from 'node:module'; const requ
2
2
  import {
3
3
  a,
4
4
  s
5
- } from "./chunk-FPUPBQHX.js";
5
+ } from "./chunk-HPWO4O6S.js";
6
6
  import "./chunk-XZKD7DIF.js";
7
7
  import "./chunk-KG3D7FIF.js";
8
8
  import "./chunk-BPMWXTFX.js";
@@ -11,4 +11,4 @@ export {
11
11
  a as n,
12
12
  s as t
13
13
  };
14
- //# sourceMappingURL=viemAdapter-By13KInL-N2GIVMZ7.js.map
14
+ //# sourceMappingURL=viemAdapter-By13KInL-X2VY6CY3.js.map
@@ -3,31 +3,31 @@ import {
3
3
  runWalletBalance,
4
4
  runWalletCreate,
5
5
  runWalletShow
6
- } from "./chunk-3VYGDRRL.js";
7
- import "./chunk-A6CY6BUW.js";
6
+ } from "./chunk-LI44XLMB.js";
7
+ import "./chunk-BTX2QE2Y.js";
8
8
  import "./chunk-3KKKB2AQ.js";
9
- import "./chunk-XDADPAWW.js";
10
- import "./chunk-BG2EXNAA.js";
11
- import "./chunk-TDGN476R.js";
12
- import "./chunk-Y66XUXVI.js";
13
- import "./chunk-6DCELMQA.js";
9
+ import "./chunk-YEBNE5NW.js";
10
+ import "./chunk-YREKMJPP.js";
11
+ import "./chunk-7ACHDNJA.js";
12
+ import "./chunk-AWQPGIR6.js";
13
+ import "./chunk-N35E6CM2.js";
14
+ import "./chunk-JRGFKVAZ.js";
14
15
  import "./chunk-5IEP5EGE.js";
15
16
  import "./chunk-EGELTSPU.js";
16
17
  import "./chunk-KG3D7FIF.js";
17
- import "./chunk-ZTFIQC4C.js";
18
+ import "./chunk-RBJPAZFI.js";
19
+ import "./chunk-BPMWXTFX.js";
20
+ import "./chunk-72UHZRG6.js";
18
21
  import "./chunk-MEFB5KHA.js";
19
22
  import "./chunk-2I4QTOLB.js";
20
23
  import "./chunk-O2JYBOUO.js";
21
- import "./chunk-UNV4K45L.js";
24
+ import "./chunk-CCDOV45D.js";
22
25
  import "./chunk-JLEF5WHM.js";
23
- import "./chunk-2BKS2FVE.js";
24
- import "./chunk-JRGFKVAZ.js";
25
- import "./chunk-RBJPAZFI.js";
26
- import "./chunk-BPMWXTFX.js";
26
+ import "./chunk-TU7XH3JJ.js";
27
27
  import "./chunk-ZXTAQYNA.js";
28
28
  export {
29
29
  runWalletBalance,
30
30
  runWalletCreate,
31
31
  runWalletShow
32
32
  };
33
- //# sourceMappingURL=wallet-YZOXIXBC.js.map
33
+ //# sourceMappingURL=wallet-3URC5QPK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -89,7 +89,7 @@ Prefer the narrow rules on this page to a broad `Bash(tenjin:*)`, `Bash(tenjin w
89
89
  ## What `tenjin install` writes, in full
90
90
 
91
91
  1. Five hook entries in `~/.claude/settings.json` (`--project` writes the project file instead): `UserPromptSubmit` running `tenjin hook prompt`, `PreToolUse` on `WebSearch|WebFetch` running `tenjin hook native`, `PreToolUse` on `Agent|Task` running `tenjin hook agent`, and `PostToolUse` and `PostToolUseFailure` on `WebSearch|WebFetch`, both running `tenjin hook shortfall`. All are plain command entries with a 5 second timeout, except the two `tenjin hook shortfall` entries, which get 15 seconds so a search can wait for the free docs described below. No daemon, no generated script; the one background process is that docs fetch, a single `node` process per such search that exits within 12 seconds. An install from an earlier release already has the first two; `tenjin install --refresh` (which `tenjin update` runs) adds the rest.
92
- 2. The `mcp__x402__request` rule in `permissions.allow`. Nothing goes into `permissions.deny`, and no hook ever approves a call, so WebSearch and WebFetch stay under your own permission rules. Before each one, when a paid lookup fits it, the hook redirects your assistant to `mcp__x402__request` in its place, as earlier releases did; a subagent is redirected only when it is known to have `mcp__x402__request` and your spend policy would pay without asking, and otherwise its call simply runs. For library documentation, which is a free lookup, it never redirects, in the main agent or a subagent: a WebSearch runs as your assistant wrote it while the hook fetches Context7 docs for the same query (up to 500 characters of it go to Tenjin's docs lookup, which asks Context7), and when docs are found they are added above the search's own results, with a line saying the web results below are there if the docs do not cover it; when none are found, or the lookup is slow or fails, the search result is left exactly as it was. One agent's identical search is not looked up again for five minutes, and the fetched docs wait in the status line's 0700 directory (item 5) only until that search reads them, ten minutes at most. A WebFetch with a free lookup simply runs. It never redirects twice in a row to the same kind of lookup: when the redirected lookup does not come back fulfilled (it failed, stopped to ask, or was never called) or was a free lookup, whose success nothing verifies,, your assistant's next WebSearch or WebFetch that the router matches to that same kind runs as it is, while other lookups are routed as usual. After a call that came back short (a failed call, a page that answers 401, 402, 403, 429 or 5xx, an empty page, a search with no results; never a 404 or 410, since a missing page is missing for a paid reader too), the router may offer a paid lookup.
92
+ 2. The `mcp__x402__request` rule in `permissions.allow`. Nothing goes into `permissions.deny`, and no hook ever approves a call, so WebSearch and WebFetch stay under your own permission rules. Before each one, when a paid lookup fits it, the hook redirects your assistant to `mcp__x402__request` in its place, as earlier releases did; a subagent is redirected only when it is known to have `mcp__x402__request` and your spend policy would pay without asking, and otherwise its call simply runs. For library documentation, which is a free lookup, it never redirects, in the main agent or a subagent: a WebSearch runs as your assistant wrote it while the hook fetches Context7 docs for the same query (up to 500 characters of it go to Tenjin's docs lookup, which asks Context7), and when docs are found they are added above the search's own results, with a line saying the web results below are there if the docs do not cover it; when none are found, or the lookup is slow or fails, the search result is left exactly as it was. One agent's identical search is not looked up again for five minutes, and the fetched docs wait in the status line's 0700 directory (item 5) only until that search reads them, ten minutes at most. A WebFetch with a free lookup simply runs. It never redirects the same call twice: once a search or URL has been redirected, your assistant's own retry of that same search or URL runs as it is, whether the redirected lookup succeeded, failed or was never called, and however many other calls ran in between, for ten minutes and separately for each agent, while every other search or URL is routed as usual. After a call that came back short (a failed call, a page that answers 401, 402, 403, 429 or 5xx, an empty page, a search with no results; never a 404 or 410, since a missing page is missing for a paid reader too), the router may offer a paid lookup.
93
93
  3. The `x402` MCP server, through `claude mcp add x402 -s user -- tenjin mcp` when the `claude` binary is on PATH, and printed for you to run when it is not. Under `--project` it registers at project scope instead, from the project directory, so the server lands in that project's `.mcp.json` and your `~/.claude.json` is not touched; `tenjin uninstall --project` removes it from the same place. The scope's own file is read first: a registration that already launches `tenjin mcp` is left exactly as it is and nothing is spawned, an `x402` entry launching anything else is removed and re-added, and a registration file this build cannot parse is reported rather than written over.
94
94
  4. The two automatic spend limits above, only where your config file is silent. Explicit zero, unlimited, custom registry lists and router opt-outs are preserved. Ignored `bazaarPay` and `confirm` keys are removed and reported; refresh removes retired keys without filling absent settings.
95
95
  5. `statusLine`, running `tenjin status-line` once a second, ONLY when that key is not already set. A status line of your own is never replaced: the install prints the command that runs both, and `--status-line compose` writes it only if you ask. The status line stores nothing new off your machine. It reads local files this CLI already writes under your Tenjin data dir: per session, the tool, the provider endpoint, the bounded redacted parameters of the call, its outcome and its price. No prompt text, no result body. Records expire after ten minutes, live in a 0700 directory under a hash of the session id, and are deleted by the next lookup that passes over them.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tenjin-cli",
3
- "version": "0.1.0-alpha.19",
3
+ "version": "0.1.0-alpha.20",
4
4
  "mcpName": "blog.tenjin/tenjin",
5
5
  "type": "module",
6
6
  "description": "x402 router for coding agents: one paid decision per lookup, a local wallet that pays each provider per call in USDC on Base.",