tenjin-cli 0.1.0-alpha.2 → 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 (215) hide show
  1. package/NOTICE.md +54 -7
  2. package/README.md +161 -257
  3. package/dist/{_esm-FEASBWRP.js → _esm-CE7KNONL.js} +9 -10
  4. package/dist/{ccip-NQXCEK2U.js → ccip-7RMRLAGV.js} +4 -4
  5. package/dist/{ccip-XR5NE5QK.js → ccip-NLCSCHKI.js} +5 -5
  6. package/dist/chunk-2E6GVIRP.js +888 -0
  7. package/dist/chunk-2E6GVIRP.js.map +1 -0
  8. package/dist/chunk-2G2WLVHB.js +102 -0
  9. package/dist/chunk-2G2WLVHB.js.map +1 -0
  10. package/dist/chunk-2QYORQBF.js +55 -0
  11. package/dist/chunk-2QYORQBF.js.map +1 -0
  12. package/dist/chunk-3BS55ANY.js +245 -0
  13. package/dist/chunk-3BS55ANY.js.map +1 -0
  14. package/dist/chunk-3KKKB2AQ.js +40 -0
  15. package/dist/chunk-3KKKB2AQ.js.map +1 -0
  16. package/dist/chunk-4AS52HUG.js +165 -0
  17. package/dist/chunk-4AS52HUG.js.map +1 -0
  18. package/dist/chunk-4M5FBWT5.js +368 -0
  19. package/dist/chunk-4M5FBWT5.js.map +1 -0
  20. package/dist/chunk-5FYKPQNX.js +1784 -0
  21. package/dist/chunk-5FYKPQNX.js.map +1 -0
  22. package/dist/{chunk-ZMHYXMO6.js → chunk-5IEP5EGE.js} +3 -3
  23. package/dist/chunk-5KD5HRAJ.js +241 -0
  24. package/dist/chunk-5KD5HRAJ.js.map +1 -0
  25. package/dist/chunk-72UHZRG6.js +231 -0
  26. package/dist/chunk-72UHZRG6.js.map +1 -0
  27. package/dist/chunk-7ACHDNJA.js +155 -0
  28. package/dist/chunk-7ACHDNJA.js.map +1 -0
  29. package/dist/chunk-7QKHZQKW.js +1680 -0
  30. package/dist/chunk-7QKHZQKW.js.map +1 -0
  31. package/dist/chunk-A36LQPHV.js +29 -0
  32. package/dist/chunk-A36LQPHV.js.map +1 -0
  33. package/dist/{chunk-UGX7YPX2.js → chunk-AWQPGIR6.js} +7 -9
  34. package/dist/{chunk-UGX7YPX2.js.map → chunk-AWQPGIR6.js.map} +1 -1
  35. package/dist/{chunk-5CLSD5YN.js → chunk-BPMWXTFX.js} +2 -2
  36. package/dist/{chunk-XJIW7USF.js → chunk-BTX2QE2Y.js} +115 -11
  37. package/dist/chunk-BTX2QE2Y.js.map +1 -0
  38. package/dist/{chunk-OYMYCW7J.js → chunk-CCDOV45D.js} +588 -97
  39. package/dist/chunk-CCDOV45D.js.map +1 -0
  40. package/dist/chunk-CXUYCDPX.js +127 -0
  41. package/dist/chunk-CXUYCDPX.js.map +1 -0
  42. package/dist/{chunk-YALGASEU.js → chunk-EGELTSPU.js} +2 -2
  43. package/dist/chunk-HH3PDYIG.js +194 -0
  44. package/dist/chunk-HH3PDYIG.js.map +1 -0
  45. package/dist/{chunk-CYOF7ROH.js → chunk-HPWO4O6S.js} +3 -3
  46. package/dist/chunk-JLEF5WHM.js +132 -0
  47. package/dist/chunk-JLEF5WHM.js.map +1 -0
  48. package/dist/{chunk-QVX5MWJZ.js → chunk-JRGFKVAZ.js} +2 -2
  49. package/dist/{chunk-HIVZG55D.js → chunk-KG3D7FIF.js} +2 -2
  50. package/dist/chunk-LHHMV4GU.js +27 -0
  51. package/dist/chunk-LHHMV4GU.js.map +1 -0
  52. package/dist/chunk-LI44XLMB.js +242 -0
  53. package/dist/chunk-LI44XLMB.js.map +1 -0
  54. package/dist/chunk-LN2HISWU.js +172 -0
  55. package/dist/chunk-LN2HISWU.js.map +1 -0
  56. package/dist/{chunk-YBMMV4Y4.js → chunk-MEFB5KHA.js} +13 -5
  57. package/dist/chunk-MEFB5KHA.js.map +1 -0
  58. package/dist/{chunk-NCE5NSN6.js → chunk-N35E6CM2.js} +140 -10
  59. package/dist/chunk-N35E6CM2.js.map +1 -0
  60. package/dist/chunk-NSG5TVZQ.js +447 -0
  61. package/dist/chunk-NSG5TVZQ.js.map +1 -0
  62. package/dist/chunk-O2JYBOUO.js +47 -0
  63. package/dist/chunk-O2JYBOUO.js.map +1 -0
  64. package/dist/{chunk-N62ROTMC.js → chunk-P42QX3QF.js} +14 -10
  65. package/dist/chunk-P42QX3QF.js.map +1 -0
  66. package/dist/chunk-PO4HAXAW.js +10528 -0
  67. package/dist/chunk-PO4HAXAW.js.map +1 -0
  68. package/dist/{chunk-ZABPQJ3M.js → chunk-POUWHWID.js} +2 -2
  69. package/dist/{chunk-S3IGX57D.js → chunk-RGVOODF4.js} +7703 -7475
  70. package/dist/chunk-RGVOODF4.js.map +1 -0
  71. package/dist/chunk-RPR2C2JO.js +112 -0
  72. package/dist/chunk-RPR2C2JO.js.map +1 -0
  73. package/dist/chunk-S2NRVRPF.js +171 -0
  74. package/dist/chunk-S2NRVRPF.js.map +1 -0
  75. package/dist/chunk-TGLKKLQG.js +11 -0
  76. package/dist/chunk-TGLKKLQG.js.map +1 -0
  77. package/dist/{chunk-RRN3YTK7.js → chunk-TTNESUPQ.js} +3 -3
  78. package/dist/chunk-TU7XH3JJ.js +97 -0
  79. package/dist/chunk-TU7XH3JJ.js.map +1 -0
  80. package/dist/{chunk-HSDCI7OV.js → chunk-XZKD7DIF.js} +3 -3
  81. package/dist/{chunk-Z6MFJV5Z.js → chunk-YEBNE5NW.js} +851 -500
  82. package/dist/chunk-YEBNE5NW.js.map +1 -0
  83. package/dist/chunk-YREKMJPP.js +131 -0
  84. package/dist/chunk-YREKMJPP.js.map +1 -0
  85. package/dist/{cli-4NNBEQYH.js → cli-XJQYUOHI.js} +355 -217
  86. package/dist/cli-XJQYUOHI.js.map +1 -0
  87. package/dist/config-KMJLFPSI.js +39 -0
  88. package/dist/dist-3LOO6M4U.js +2842 -0
  89. package/dist/dist-3LOO6M4U.js.map +1 -0
  90. package/dist/doctor-KMN55D7U.js +444 -0
  91. package/dist/doctor-KMN55D7U.js.map +1 -0
  92. package/dist/{ethersCompat-Df4a6QIZ-3YZIAXDK.js → ethersCompat-Df4a6QIZ-THAVUGIJ.js} +5 -5
  93. package/dist/fund-LT6ZPGEQ.js +298 -0
  94. package/dist/fund-LT6ZPGEQ.js.map +1 -0
  95. package/dist/hook-command-U5XPEHAJ.js +1052 -0
  96. package/dist/hook-command-U5XPEHAJ.js.map +1 -0
  97. package/dist/index.js +11 -3
  98. package/dist/index.js.map +1 -1
  99. package/dist/install-MMNXJ5LM.js +61 -0
  100. package/dist/install-identity-B7FVIWML.js +27 -0
  101. package/dist/install-wallet-XMVUBCHS.js +107 -0
  102. package/dist/install-wallet-XMVUBCHS.js.map +1 -0
  103. package/dist/mcp-TUPRIPSI.js +10000 -0
  104. package/dist/mcp-TUPRIPSI.js.map +1 -0
  105. package/dist/paths-LRMWNTJP.js +51 -0
  106. package/dist/pay-XAWW3NV3.js +44 -0
  107. package/dist/redact-6W23GGJC.js +15 -0
  108. package/dist/{secp256k1-N3ZHU7LB.js → secp256k1-ZZZT2CAX.js} +3 -3
  109. package/dist/secp256k1-ZZZT2CAX.js.map +1 -0
  110. package/dist/send-HESQYRKM.js +225 -0
  111. package/dist/send-HESQYRKM.js.map +1 -0
  112. package/dist/status-ANZPRZJJ.js +71 -0
  113. package/dist/status-ANZPRZJJ.js.map +1 -0
  114. package/dist/status-line-J3TUWVRQ.js +87 -0
  115. package/dist/status-line-J3TUWVRQ.js.map +1 -0
  116. package/dist/status-line-wiring-HSV7DXO5.js +29 -0
  117. package/dist/status-line-wiring-HSV7DXO5.js.map +1 -0
  118. package/dist/tenjin-daemon.mjs +20547 -0
  119. package/dist/tenjin-shim.mjs +251 -0
  120. package/dist/tenjin-vitest-reporter.mjs +49 -0
  121. package/dist/uninstall-GUU34YKP.js +165 -0
  122. package/dist/uninstall-GUU34YKP.js.map +1 -0
  123. package/dist/update-KO2NZRJ5.js +433 -0
  124. package/dist/update-KO2NZRJ5.js.map +1 -0
  125. package/dist/{viemAdapter-By13KInL-ZZE6UV4Y.js → viemAdapter-By13KInL-X2VY6CY3.js} +5 -5
  126. package/dist/viemAdapter-By13KInL-X2VY6CY3.js.map +1 -0
  127. package/dist/wallet-3URC5QPK.js +33 -0
  128. package/dist/wallet-3URC5QPK.js.map +1 -0
  129. package/dist/wallet-kdf-worker.mjs +980 -0
  130. package/docs/agent-permissions.md +139 -0
  131. package/docs/safety-model.md +70 -0
  132. package/package.json +14 -9
  133. package/LICENSE +0 -21
  134. package/dist/buy-U35DQ6XM.js +0 -1598
  135. package/dist/buy-U35DQ6XM.js.map +0 -1
  136. package/dist/candidate-RLYCQMF5.js +0 -127
  137. package/dist/candidate-RLYCQMF5.js.map +0 -1
  138. package/dist/chunk-27ONARHV.js +0 -171
  139. package/dist/chunk-27ONARHV.js.map +0 -1
  140. package/dist/chunk-3OV7E5G5.js +0 -18
  141. package/dist/chunk-3OV7E5G5.js.map +0 -1
  142. package/dist/chunk-7KUW4MJD.js +0 -59
  143. package/dist/chunk-7KUW4MJD.js.map +0 -1
  144. package/dist/chunk-7PHSZKQS.js +0 -333
  145. package/dist/chunk-7PHSZKQS.js.map +0 -1
  146. package/dist/chunk-IYLHQMT5.js +0 -211
  147. package/dist/chunk-IYLHQMT5.js.map +0 -1
  148. package/dist/chunk-JPHG2JW3.js +0 -96
  149. package/dist/chunk-JPHG2JW3.js.map +0 -1
  150. package/dist/chunk-MUBUQVC3.js +0 -67
  151. package/dist/chunk-MUBUQVC3.js.map +0 -1
  152. package/dist/chunk-N62ROTMC.js.map +0 -1
  153. package/dist/chunk-NCE5NSN6.js.map +0 -1
  154. package/dist/chunk-OYMYCW7J.js.map +0 -1
  155. package/dist/chunk-QNP7H47L.js +0 -152
  156. package/dist/chunk-QNP7H47L.js.map +0 -1
  157. package/dist/chunk-RY4XKNV3.js +0 -140
  158. package/dist/chunk-RY4XKNV3.js.map +0 -1
  159. package/dist/chunk-S3IGX57D.js.map +0 -1
  160. package/dist/chunk-TFGSOPWR.js +0 -261
  161. package/dist/chunk-TFGSOPWR.js.map +0 -1
  162. package/dist/chunk-TLCMMYLY.js +0 -126
  163. package/dist/chunk-TLCMMYLY.js.map +0 -1
  164. package/dist/chunk-UO22YNY4.js +0 -69
  165. package/dist/chunk-UO22YNY4.js.map +0 -1
  166. package/dist/chunk-UPIEAMGH.js +0 -160
  167. package/dist/chunk-UPIEAMGH.js.map +0 -1
  168. package/dist/chunk-XJIW7USF.js.map +0 -1
  169. package/dist/chunk-YBMMV4Y4.js.map +0 -1
  170. package/dist/chunk-YIYQ2ZNT.js +0 -286
  171. package/dist/chunk-YIYQ2ZNT.js.map +0 -1
  172. package/dist/chunk-YN5SHIXQ.js +0 -126
  173. package/dist/chunk-YN5SHIXQ.js.map +0 -1
  174. package/dist/chunk-Z52RA3NC.js +0 -137
  175. package/dist/chunk-Z52RA3NC.js.map +0 -1
  176. package/dist/chunk-Z6MFJV5Z.js.map +0 -1
  177. package/dist/cli-4NNBEQYH.js.map +0 -1
  178. package/dist/config-2VSXWWHK.js +0 -21
  179. package/dist/doctor-JJPNIBYH.js +0 -20
  180. package/dist/inspect-JGYJWFDP.js +0 -96
  181. package/dist/inspect-JGYJWFDP.js.map +0 -1
  182. package/dist/install-ZQRMSRGW.js +0 -378
  183. package/dist/install-ZQRMSRGW.js.map +0 -1
  184. package/dist/lookup-WYVTOMVY.js +0 -113
  185. package/dist/lookup-WYVTOMVY.js.map +0 -1
  186. package/dist/outcome-HKKT6QIA.js +0 -66
  187. package/dist/outcome-HKKT6QIA.js.map +0 -1
  188. package/dist/publish-D76B3MBK.js +0 -1480
  189. package/dist/publish-D76B3MBK.js.map +0 -1
  190. package/dist/usdc-JIAJW4SV.js +0 -22
  191. package/dist/wallet-6QKS6UHW.js +0 -179
  192. package/dist/wallet-6QKS6UHW.js.map +0 -1
  193. package/dist/wallet-PA54CRBL.js +0 -30
  194. package/skills/tenjin/SKILL.md +0 -199
  195. package/skills/tenjin-publish/SKILL.md +0 -96
  196. package/skills/tenjin-search/SKILL.md +0 -122
  197. /package/dist/{_esm-FEASBWRP.js.map → _esm-CE7KNONL.js.map} +0 -0
  198. /package/dist/{ccip-NQXCEK2U.js.map → ccip-7RMRLAGV.js.map} +0 -0
  199. /package/dist/{ccip-XR5NE5QK.js.map → ccip-NLCSCHKI.js.map} +0 -0
  200. /package/dist/{chunk-ZMHYXMO6.js.map → chunk-5IEP5EGE.js.map} +0 -0
  201. /package/dist/{chunk-5CLSD5YN.js.map → chunk-BPMWXTFX.js.map} +0 -0
  202. /package/dist/{chunk-YALGASEU.js.map → chunk-EGELTSPU.js.map} +0 -0
  203. /package/dist/{chunk-CYOF7ROH.js.map → chunk-HPWO4O6S.js.map} +0 -0
  204. /package/dist/{chunk-QVX5MWJZ.js.map → chunk-JRGFKVAZ.js.map} +0 -0
  205. /package/dist/{chunk-HIVZG55D.js.map → chunk-KG3D7FIF.js.map} +0 -0
  206. /package/dist/{chunk-ZABPQJ3M.js.map → chunk-POUWHWID.js.map} +0 -0
  207. /package/dist/{chunk-RRN3YTK7.js.map → chunk-TTNESUPQ.js.map} +0 -0
  208. /package/dist/{chunk-HSDCI7OV.js.map → chunk-XZKD7DIF.js.map} +0 -0
  209. /package/dist/{config-2VSXWWHK.js.map → config-KMJLFPSI.js.map} +0 -0
  210. /package/dist/{doctor-JJPNIBYH.js.map → ethersCompat-Df4a6QIZ-THAVUGIJ.js.map} +0 -0
  211. /package/dist/{ethersCompat-Df4a6QIZ-3YZIAXDK.js.map → install-MMNXJ5LM.js.map} +0 -0
  212. /package/dist/{secp256k1-N3ZHU7LB.js.map → install-identity-B7FVIWML.js.map} +0 -0
  213. /package/dist/{usdc-JIAJW4SV.js.map → paths-LRMWNTJP.js.map} +0 -0
  214. /package/dist/{viemAdapter-By13KInL-ZZE6UV4Y.js.map → pay-XAWW3NV3.js.map} +0 -0
  215. /package/dist/{wallet-PA54CRBL.js.map → redact-6W23GGJC.js.map} +0 -0
@@ -0,0 +1,127 @@
1
+ import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+ import {
3
+ findAllProjectFiles,
4
+ findNearestProjectFiles,
5
+ mainWorktreeOf,
6
+ ownedCandidates,
7
+ projectRoot
8
+ } from "./chunk-5KD5HRAJ.js";
9
+ import {
10
+ CONFIG_DEFAULTS,
11
+ loadRawConfig,
12
+ parseRouterLayer
13
+ } from "./chunk-CCDOV45D.js";
14
+ import {
15
+ CliError
16
+ } from "./chunk-JLEF5WHM.js";
17
+ import {
18
+ configPath
19
+ } from "./chunk-TU7XH3JJ.js";
20
+
21
+ // src/router/settings.ts
22
+ import { readFile } from "node:fs/promises";
23
+ import { homedir } from "node:os";
24
+ import { join, resolve } from "node:path";
25
+ var PROJECT_ROUTER_FILE = join(".tenjin", "config.json");
26
+ var LOCAL_ROUTER_FILE = join(".tenjin", "config.local.json");
27
+ async function routerSettings(input, deps = {}) {
28
+ const globalPath = configPath(input.dataDir);
29
+ const global = (input.config ?? await loadRawConfig(input.dataDir)).router;
30
+ let enabled = {
31
+ value: CONFIG_DEFAULTS.router.enabled,
32
+ source: "default"
33
+ };
34
+ let context = {
35
+ value: CONFIG_DEFAULTS.router.context,
36
+ source: "default"
37
+ };
38
+ if (global?.enabled !== void 0) {
39
+ enabled = { value: global.enabled, source: "file", path: globalPath };
40
+ }
41
+ if (global?.context !== void 0) {
42
+ context = { value: global.context, source: "file", path: globalPath };
43
+ }
44
+ for (const { source, path, layer } of await projectLayers(input, deps)) {
45
+ if (layer.enabled !== void 0 && (layer.enabled === false || enabled.value)) {
46
+ enabled = { value: layer.enabled, source, path };
47
+ }
48
+ if (layer.context !== void 0 && (layer.context === "turn" || context.value === "session")) {
49
+ context = { value: layer.context, source, path };
50
+ }
51
+ }
52
+ return { enabled, context };
53
+ }
54
+ var ROUTER_FILES = [PROJECT_ROUTER_FILE, LOCAL_ROUTER_FILE];
55
+ async function projectLayers(input, deps) {
56
+ const { levels, gitRoot } = await findAllProjectFiles(input.cwd, ROUTER_FILES, {
57
+ ...deps,
58
+ // $HOME/.tenjin is the global scope, not a project.
59
+ homeIsProject: false
60
+ });
61
+ const main = gitRoot === null ? null : await mainWorktreeOf(gitRoot, deps.homeDir);
62
+ const outer = main === null ? [] : [{ dir: main, found: await ownedCandidates(main, ROUTER_FILES, deps) }];
63
+ const layers = [];
64
+ for (const { dir, found } of [...outer, ...levels.reverse()]) {
65
+ if (resolve(dir, ".tenjin") === resolve(input.dataDir)) continue;
66
+ for (const path of found) {
67
+ const file = await readProjectRouterFile(path);
68
+ if (file === null) continue;
69
+ layers.push({
70
+ source: path === join(dir, LOCAL_ROUTER_FILE) ? "local" : "project",
71
+ path,
72
+ layer: file.layer
73
+ });
74
+ }
75
+ }
76
+ return layers;
77
+ }
78
+ var ABSENT = /* @__PURE__ */ new Set(["ENOENT", "ENOTDIR"]);
79
+ async function readProjectRouterFile(path) {
80
+ let raw;
81
+ try {
82
+ raw = await readFile(path, "utf8");
83
+ } catch (err) {
84
+ if (ABSENT.has(String(err.code))) return null;
85
+ throw invalid(path, "could not be read", err);
86
+ }
87
+ let json;
88
+ try {
89
+ json = JSON.parse(raw);
90
+ } catch (err) {
91
+ throw invalid(path, "is not valid JSON", err);
92
+ }
93
+ const layer = parseRouterLayer(json, path);
94
+ return { json, layer };
95
+ }
96
+ async function projectRouterPath(input, deps = {}) {
97
+ const home = deps.homeDir ?? homedir();
98
+ const hit = await findNearestProjectFiles(input.cwd, [PROJECT_ROUTER_FILE, LOCAL_ROUTER_FILE], {
99
+ ...deps,
100
+ warn: () => void 0,
101
+ homeIsProject: false
102
+ });
103
+ const dir = hit?.dir ?? await projectRoot(input.cwd, home);
104
+ if (dir === home) {
105
+ throw new CliError(
106
+ "USAGE",
107
+ "Your home directory is not a project: its .tenjin is the global config.",
108
+ {
109
+ fix: "Run it from inside the project, or drop --project to set it for this machine."
110
+ }
111
+ );
112
+ }
113
+ return join(dir, input.local ? LOCAL_ROUTER_FILE : PROJECT_ROUTER_FILE);
114
+ }
115
+ function invalid(path, what, cause) {
116
+ return new CliError("CONFIG_INVALID", `Config at ${path} ${what}`, {
117
+ fix: `Fix ${path}, or delete it.`,
118
+ ...cause !== void 0 ? { cause } : {}
119
+ });
120
+ }
121
+
122
+ export {
123
+ routerSettings,
124
+ readProjectRouterFile,
125
+ projectRouterPath
126
+ };
127
+ //# sourceMappingURL=chunk-CXUYCDPX.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/router/settings.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { homedir } from 'node:os';\nimport { join, resolve } from 'node:path';\nimport {\n CONFIG_DEFAULTS,\n loadRawConfig,\n parseRouterLayer,\n type PartialConfig,\n type RouterContext,\n type RouterLayer,\n} from '../lib/config';\nimport { CliError } from '../lib/errors';\nimport { configPath } from '../lib/paths';\nimport {\n findAllProjectFiles,\n findNearestProjectFiles,\n mainWorktreeOf,\n ownedCandidates,\n projectRoot,\n type ProjectWalkDeps,\n} from '../lib/settings';\n\n/**\n * THE ONE READER OF THE ROUTER'S OWN KEYS, `router.enabled` and\n * `router.context`. Both hooks, the `request` tool, doctor, the status line and\n * `tenjin config` call {@link routerSettings} first, and nothing reads a router\n * key any other way.\n *\n * THE LAYERS: the default, `~/.tenjin/config.json`, then EVERY\n * `.tenjin/config.json` and `config.local.json` from the working directory up\n * to the git root, and in a linked git worktree the main checkout's pair too.\n * No environment variable.\n *\n * EVERY LAYER IS A FLOOR. `enabled` is false when any layer says false, and\n * `context` is `turn` when any layer says turn; a key a file leaves out\n * inherits, and a looser value is not read. So a file a cloned repository\n * carries cannot undo `tenjin config set router.enabled false` on this\n * machine, a package in a monorepo cannot undo its root, and a\n * `config.local.json` a repository commits anyway cannot undo the committed\n * one. Both keys fail toward less data sent, and no project file has a spend\n * key to loosen. The source reported is the nearest layer at the value.\n *\n * ONE PARSER. The global block is the one `loadRawConfig` already validated,\n * and a project file goes through `parseRouterLayer` from the same schema.\n */\n\n/** The committed project file and the personal one beside it. */\nexport const PROJECT_ROUTER_FILE = join('.tenjin', 'config.json');\nexport const LOCAL_ROUTER_FILE = join('.tenjin', 'config.local.json');\n\nexport type RouterSource = 'default' | 'file' | 'project' | 'local';\n\nexport interface RouterSetting<T> {\n value: T;\n source: RouterSource;\n /** The file that set it; absent for the default. */\n path?: string;\n}\n\nexport interface RouterSettings {\n enabled: RouterSetting<boolean>;\n context: RouterSetting<RouterContext>;\n}\n\nexport interface RouterSettingsInput {\n /** The directory the harness is working in. */\n cwd: string;\n /** The data dir whose `config.json` is the global layer. */\n dataDir: string;\n /** That file, when the caller has already loaded it; read here otherwise. */\n config?: PartialConfig;\n}\n\nexport async function routerSettings(\n input: RouterSettingsInput,\n deps: ProjectWalkDeps = {},\n): Promise<RouterSettings> {\n const globalPath = configPath(input.dataDir);\n const global = (input.config ?? (await loadRawConfig(input.dataDir))).router;\n let enabled: RouterSetting<boolean> = {\n value: CONFIG_DEFAULTS.router.enabled,\n source: 'default',\n };\n let context: RouterSetting<RouterContext> = {\n value: CONFIG_DEFAULTS.router.context,\n source: 'default',\n };\n if (global?.enabled !== undefined) {\n enabled = { value: global.enabled, source: 'file', path: globalPath };\n }\n if (global?.context !== undefined) {\n context = { value: global.context, source: 'file', path: globalPath };\n }\n\n for (const { source, path, layer } of await projectLayers(input, deps)) {\n // Every layer is a floor: a value looser than the one so far is not read.\n if (layer.enabled !== undefined && (layer.enabled === false || enabled.value)) {\n enabled = { value: layer.enabled, source, path };\n }\n if (layer.context !== undefined && (layer.context === 'turn' || context.value === 'session')) {\n context = { value: layer.context, source, path };\n }\n }\n return { enabled, context };\n}\n\nconst ROUTER_FILES = [PROJECT_ROUTER_FILE, LOCAL_ROUTER_FILE];\n\n/**\n * Every project layer, outermost first so the nearest one at a value is the\n * one reported: the main checkout's pair when this is a linked worktree, then\n * each directory from the git root down to `cwd`, its project file before its\n * personal one.\n */\nasync function projectLayers(\n input: RouterSettingsInput,\n deps: ProjectWalkDeps,\n): Promise<{ source: 'project' | 'local'; path: string; layer: RouterLayer }[]> {\n const { levels, gitRoot } = await findAllProjectFiles(input.cwd, ROUTER_FILES, {\n ...deps,\n // $HOME/.tenjin is the global scope, not a project.\n homeIsProject: false,\n });\n const main = gitRoot === null ? null : await mainWorktreeOf(gitRoot, deps.homeDir);\n const outer =\n main === null ? [] : [{ dir: main, found: await ownedCandidates(main, ROUTER_FILES, deps) }];\n const layers = [];\n for (const { dir, found } of [...outer, ...levels.reverse()]) {\n // A data dir kept inside a project is the global file, already read.\n if (resolve(dir, '.tenjin') === resolve(input.dataDir)) continue;\n for (const path of found) {\n const file = await readProjectRouterFile(path);\n if (file === null) continue;\n layers.push({\n source: path === join(dir, LOCAL_ROUTER_FILE) ? ('local' as const) : ('project' as const),\n path,\n layer: file.layer,\n });\n }\n }\n return layers;\n}\n\nconst ABSENT = new Set(['ENOENT', 'ENOTDIR']);\n\n/**\n * One project file: its whole JSON, for a writer that keeps sibling keys, and\n * its router layer through the one parser. Null when there is no file.\n */\nexport async function readProjectRouterFile(\n path: string,\n): Promise<{ json: Record<string, unknown>; layer: RouterLayer } | null> {\n let raw: string;\n try {\n raw = await readFile(path, 'utf8');\n } catch (err) {\n if (ABSENT.has(String((err as { code?: unknown }).code))) return null;\n throw invalid(path, 'could not be read', err);\n }\n let json: unknown;\n try {\n json = JSON.parse(raw);\n } catch (err) {\n throw invalid(path, 'is not valid JSON', err);\n }\n const layer = parseRouterLayer(json, path);\n return { json: json as Record<string, unknown>, layer };\n}\n\n/**\n * Where `tenjin config set --project [--local]` writes from `cwd`: beside the\n * layer {@link routerSettings} already reads there, else at the git root, else\n * in `cwd`. Never in $HOME, whose `.tenjin/config.json` is the global file.\n */\nexport async function projectRouterPath(\n input: { cwd: string; local: boolean },\n deps: ProjectWalkDeps = {},\n): Promise<string> {\n const home = deps.homeDir ?? homedir();\n const hit = await findNearestProjectFiles(input.cwd, [PROJECT_ROUTER_FILE, LOCAL_ROUTER_FILE], {\n ...deps,\n warn: () => undefined,\n homeIsProject: false,\n });\n const dir = hit?.dir ?? (await projectRoot(input.cwd, home));\n if (dir === home) {\n throw new CliError(\n 'USAGE',\n 'Your home directory is not a project: its .tenjin is the global config.',\n {\n fix: 'Run it from inside the project, or drop --project to set it for this machine.',\n },\n );\n }\n return join(dir, input.local ? LOCAL_ROUTER_FILE : PROJECT_ROUTER_FILE);\n}\n\nfunction invalid(path: string, what: string, cause?: unknown): CliError {\n return new CliError('CONFIG_INVALID', `Config at ${path} ${what}`, {\n fix: `Fix ${path}, or delete it.`,\n ...(cause !== undefined ? { cause } : {}),\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,gBAAgB;AACzB,SAAS,eAAe;AACxB,SAAS,MAAM,eAAe;AA6CvB,IAAM,sBAAsB,KAAK,WAAW,aAAa;AACzD,IAAM,oBAAoB,KAAK,WAAW,mBAAmB;AAyBpE,eAAsB,eACpB,OACA,OAAwB,CAAC,GACA;AACzB,QAAM,aAAa,WAAW,MAAM,OAAO;AAC3C,QAAM,UAAU,MAAM,UAAW,MAAM,cAAc,MAAM,OAAO,GAAI;AACtE,MAAI,UAAkC;AAAA,IACpC,OAAO,gBAAgB,OAAO;AAAA,IAC9B,QAAQ;AAAA,EACV;AACA,MAAI,UAAwC;AAAA,IAC1C,OAAO,gBAAgB,OAAO;AAAA,IAC9B,QAAQ;AAAA,EACV;AACA,MAAI,QAAQ,YAAY,QAAW;AACjC,cAAU,EAAE,OAAO,OAAO,SAAS,QAAQ,QAAQ,MAAM,WAAW;AAAA,EACtE;AACA,MAAI,QAAQ,YAAY,QAAW;AACjC,cAAU,EAAE,OAAO,OAAO,SAAS,QAAQ,QAAQ,MAAM,WAAW;AAAA,EACtE;AAEA,aAAW,EAAE,QAAQ,MAAM,MAAM,KAAK,MAAM,cAAc,OAAO,IAAI,GAAG;AAEtE,QAAI,MAAM,YAAY,WAAc,MAAM,YAAY,SAAS,QAAQ,QAAQ;AAC7E,gBAAU,EAAE,OAAO,MAAM,SAAS,QAAQ,KAAK;AAAA,IACjD;AACA,QAAI,MAAM,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BAAqB,GAAG;AAAA,EAC9C;AACA,MAAI;AACJ,MAAI;AACF,WAAO,KAAK,MAAM,GAAG;AAAA,EACvB,SAAS,KAAK;AACZ,UAAM,QAAQ,MAAM,qBAAqB,GAAG;AAAA,EAC9C;AACA,QAAM,QAAQ,iBAAiB,MAAM,IAAI;AACzC,SAAO,EAAE,MAAuC,MAAM;AACxD;AAOA,eAAsB,kBACpB,OACA,OAAwB,CAAC,GACR;AACjB,QAAM,OAAO,KAAK,WAAW,QAAQ;AACrC,QAAM,MAAM,MAAM,wBAAwB,MAAM,KAAK,CAAC,qBAAqB,iBAAiB,GAAG;AAAA,IAC7F,GAAG;AAAA,IACH,MAAM,MAAM;AAAA,IACZ,eAAe;AAAA,EACjB,CAAC;AACD,QAAM,MAAM,KAAK,OAAQ,MAAM,YAAY,MAAM,KAAK,IAAI;AAC1D,MAAI,QAAQ,MAAM;AAChB,UAAM,IAAI;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,QACE,KAAK;AAAA,MACP;AAAA,IACF;AAAA,EACF;AACA,SAAO,KAAK,KAAK,MAAM,QAAQ,oBAAoB,mBAAmB;AACxE;AAEA,SAAS,QAAQ,MAAc,MAAc,OAA2B;AACtE,SAAO,IAAI,SAAS,kBAAkB,aAAa,IAAI,IAAI,IAAI,IAAI;AAAA,IACjE,KAAK,OAAO,IAAI;AAAA,IAChB,GAAI,UAAU,SAAY,EAAE,MAAM,IAAI,CAAC;AAAA,EACzC,CAAC;AACH;","names":[]}
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
2
  import {
3
3
  keccak_256
4
- } from "./chunk-HIVZG55D.js";
4
+ } from "./chunk-KG3D7FIF.js";
5
5
  import {
6
6
  equalBytes
7
7
  } from "./chunk-RBJPAZFI.js";
@@ -2862,4 +2862,4 @@ export {
2862
2862
  trimLeft as trimLeft2,
2863
2863
  validate as validate2
2864
2864
  };
2865
- //# sourceMappingURL=chunk-YALGASEU.js.map
2865
+ //# sourceMappingURL=chunk-EGELTSPU.js.map
@@ -0,0 +1,194 @@
1
+ import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+ import {
3
+ emitNotice
4
+ } from "./chunk-72UHZRG6.js";
5
+ import {
6
+ external_exports,
7
+ loadConfig
8
+ } from "./chunk-CCDOV45D.js";
9
+ import {
10
+ package_default
11
+ } from "./chunk-P42QX3QF.js";
12
+ import {
13
+ writeFileAtomic
14
+ } from "./chunk-JLEF5WHM.js";
15
+ import {
16
+ updateCheckPath
17
+ } from "./chunk-TU7XH3JJ.js";
18
+
19
+ // src/lib/update-check.ts
20
+ import { readFile } from "node:fs/promises";
21
+ var NUDGE_OPT_OUT = "TENJIN_NO_UPDATE_CHECK";
22
+ var CHECK_INTERVAL_MS = 864e5;
23
+ var FETCH_TIMEOUT_MS = 1500;
24
+ var DIST_TAGS_URL = "https://registry.npmjs.org/-/package/tenjin-cli/dist-tags";
25
+ var TagEntrySchema = external_exports.object({
26
+ checkedAtMs: external_exports.number(),
27
+ /** The version the tag named. Absent when the answer was unusable. */
28
+ latest: external_exports.string().optional(),
29
+ /** When the nudge was last PRINTED for this tag. Absent until one has been. */
30
+ notifiedAtMs: external_exports.number().optional()
31
+ });
32
+ var CacheSchema = external_exports.object({
33
+ schemaVersion: external_exports.literal(1),
34
+ tags: external_exports.record(external_exports.string(), TagEntrySchema),
35
+ /**
36
+ * The resolved "you could upgrade" fact, written whenever it changes and
37
+ * cleared when it stops being true.
38
+ *
39
+ * Denormalized from `tags` on purpose: the generated hook scripts are
40
+ * standalone .mjs that cannot import this module and do not know which
41
+ * version is running, so a per-tag entry would leave them unable to tell an
42
+ * upgrade from a match. Storing the comparison's ANSWER is what lets a hook
43
+ * report it without reimplementing any of it.
44
+ */
45
+ signal: external_exports.object({ current: external_exports.string(), latest: external_exports.string() }).optional()
46
+ });
47
+ var DistTagsSchema = external_exports.record(external_exports.string(), external_exports.string());
48
+ async function maybeUpdate(deps) {
49
+ try {
50
+ const env = deps.env ?? process.env;
51
+ if (env.CI !== void 0 && env.CI.length > 0) return;
52
+ if (env[NUDGE_OPT_OUT] === "1") return;
53
+ const mode = deps.mode ?? (await loadConfig(deps.dir)).update.mode;
54
+ if (mode === "off") return;
55
+ const nowMs = (deps.now ?? Date.now)();
56
+ const current = deps.currentVersion ?? package_default.version;
57
+ const path = updateCheckPath(deps.dir);
58
+ const tag = channelTag(current);
59
+ if (tag === null) return;
60
+ const cached = await readCache(path);
61
+ const entry = cached?.tags[tag];
62
+ const fresh = entry !== void 0 && nowMs - entry.checkedAtMs < CHECK_INTERVAL_MS;
63
+ let latest;
64
+ if (fresh) {
65
+ latest = entry.latest ?? null;
66
+ } else {
67
+ const answer = await resolveLatest(current, deps);
68
+ if (answer === null) return;
69
+ latest = answer.latest;
70
+ }
71
+ const upgradeable = latest !== null && isNewer(latest, current);
72
+ const human = deps.io.isTTY && !deps.json;
73
+ const notifiedAtMs = entry?.notifiedAtMs;
74
+ const due = human && upgradeable && (notifiedAtMs === void 0 || nowMs - notifiedAtMs >= CHECK_INTERVAL_MS);
75
+ const nudgedAtMs = due ? nowMs : notifiedAtMs;
76
+ const signal = upgradeable && latest !== null ? { current, latest } : void 0;
77
+ const signalChanged = cached?.signal?.current !== signal?.current || cached?.signal?.latest !== signal?.latest;
78
+ if (!fresh || due || signalChanged) {
79
+ await writeCache(path, {
80
+ schemaVersion: 1,
81
+ ...signal !== void 0 ? { signal } : {},
82
+ // Read-modify-write: the tag this run did not ask about keeps whatever it
83
+ // knew, including its own nudge clock.
84
+ tags: {
85
+ ...cached?.tags,
86
+ [tag]: {
87
+ checkedAtMs: fresh ? entry.checkedAtMs : nowMs,
88
+ ...latest !== null ? { latest } : {},
89
+ ...nudgedAtMs !== void 0 ? { notifiedAtMs: nudgedAtMs } : {}
90
+ }
91
+ }
92
+ });
93
+ }
94
+ if (due && latest !== null) {
95
+ emitNotice(
96
+ deps.io,
97
+ `tenjin-cli ${latest} is available (you have ${current}). Update: run tenjin update`,
98
+ { json: deps.json }
99
+ );
100
+ }
101
+ } catch {
102
+ }
103
+ }
104
+ async function readUpdateSignal(dir, currentVersion) {
105
+ try {
106
+ const current = currentVersion ?? package_default.version;
107
+ const tag = channelTag(current);
108
+ if (tag === null) return null;
109
+ if ((await loadConfig(dir)).update.mode === "off") return null;
110
+ const cached = await readCache(updateCheckPath(dir));
111
+ const latest = cached?.tags[tag]?.latest;
112
+ if (latest === void 0 || !isNewer(latest, current)) return null;
113
+ return { current, latest };
114
+ } catch {
115
+ return null;
116
+ }
117
+ }
118
+ function channelTag(version) {
119
+ return parseVersion(version) === null ? null : "latest";
120
+ }
121
+ function resolveTarget(current, tags) {
122
+ const channel = channelTag(current);
123
+ if (channel === null) return null;
124
+ const candidate = tags[channel];
125
+ if (candidate === void 0 || parseVersion(candidate) === null) return null;
126
+ return candidate;
127
+ }
128
+ async function fetchDistTags(opts) {
129
+ const doFetch = opts.fetchImpl ?? fetch;
130
+ let json;
131
+ try {
132
+ const res = await doFetch(DIST_TAGS_URL, { signal: AbortSignal.timeout(opts.timeoutMs) });
133
+ if (!res.ok) return null;
134
+ json = await res.json();
135
+ } catch {
136
+ return null;
137
+ }
138
+ const parsed = DistTagsSchema.safeParse(json);
139
+ return parsed.success ? parsed.data : null;
140
+ }
141
+ async function resolveLatest(current, deps) {
142
+ const tags = await fetchDistTags({ fetchImpl: deps.fetchImpl, timeoutMs: FETCH_TIMEOUT_MS });
143
+ return tags === null ? null : { latest: resolveTarget(current, tags) };
144
+ }
145
+ async function writeCache(path, cache) {
146
+ await writeFileAtomic(path, `${JSON.stringify(cache, null, 2)}
147
+ `, {
148
+ mode: 384,
149
+ dirMode: 448
150
+ });
151
+ }
152
+ async function readCache(path) {
153
+ try {
154
+ const parsed = CacheSchema.safeParse(JSON.parse(await readFile(path, "utf8")));
155
+ return parsed.success ? parsed.data : null;
156
+ } catch {
157
+ return null;
158
+ }
159
+ }
160
+ var VERSION_RE = /^(\d+)\.(\d+)\.(\d+)(?:-alpha\.(\d+))?$/;
161
+ function parseVersion(raw) {
162
+ const m = VERSION_RE.exec(raw);
163
+ if (m === null) return null;
164
+ const [, major, minor, patch, alpha] = m;
165
+ if (major === void 0 || minor === void 0 || patch === void 0) return null;
166
+ return {
167
+ major: Number(major),
168
+ minor: Number(minor),
169
+ patch: Number(patch),
170
+ alpha: alpha !== void 0 ? Number(alpha) : null
171
+ };
172
+ }
173
+ function isNewer(candidate, current) {
174
+ const a = parseVersion(candidate);
175
+ const b = parseVersion(current);
176
+ if (a === null || b === null) return false;
177
+ if (a.major !== b.major) return a.major > b.major;
178
+ if (a.minor !== b.minor) return a.minor > b.minor;
179
+ if (a.patch !== b.patch) return a.patch > b.patch;
180
+ if (a.alpha === null) return b.alpha !== null;
181
+ if (b.alpha === null) return false;
182
+ return a.alpha > b.alpha;
183
+ }
184
+
185
+ export {
186
+ NUDGE_OPT_OUT,
187
+ maybeUpdate,
188
+ readUpdateSignal,
189
+ channelTag,
190
+ resolveTarget,
191
+ fetchDistTags,
192
+ isNewer
193
+ };
194
+ //# sourceMappingURL=chunk-HH3PDYIG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/update-check.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { z } from 'zod';\nimport pkg from '../../package.json';\nimport { writeFileAtomic } from './atomic-json';\nimport { loadConfig } from './config';\nimport type { UpdateMode } from './config';\nimport { emitNotice } from './output';\nimport type { Io } from './output';\nimport type { UpdateAvailable } from '../schemas';\nimport { updateCheckPath } from './paths';\n\n/**\n * \"A newer tenjin-cli exists\", asked of npm at most once a day and reported\n * three ways: one dim stderr line for a human at a terminal, `updateAvailable`\n * on the JSON envelope, and a line on the generated hook scripts' output.\n *\n * It REPORTS and never installs. A CLI that starts a fresh process per\n * invocation has no deferred-activation window to hide a binary swap in — \"next\n * start\" is \"mid-session\" for whatever is driving it — so the decision to run\n * `tenjin update` belongs to the agent or the human, not to this check.\n *\n * Everything here is subordinate to the command that ran: the fetch happens\n * AFTER the envelope is written, it never touches stdout, it never changes an\n * exit code, and every failure it can have (offline, slow registry, junk JSON, a\n * tag that does not exist) is swallowed. CI skips the whole thing: a build log\n * can act on none of it. `update.mode off` is the opt-out and silences all three\n * surfaces, including the request to npm.\n */\n\n/**\n * Silences this check for one process, cache write and registry request\n * included. Set by `update` on the `install --refresh` children it spawns: their\n * data dirs come out of a settings file this CLI does not own, and this check is\n * the one thing in a refresh that would CREATE such a directory — `writeCache`\n * mkdirs the tree — where the refresh itself only converges what exists.\n *\n * A separate switch rather than `CI`, which would also stand the skills heal\n * down (lib/skill-heal) and so gut the refresh it was set for.\n */\nexport const NUDGE_OPT_OUT = 'TENJIN_NO_UPDATE_CHECK';\n\nconst CHECK_INTERVAL_MS = 86_400_000; // 24h\nconst FETCH_TIMEOUT_MS = 1500;\nconst DIST_TAGS_URL = 'https://registry.npmjs.org/-/package/tenjin-cli/dist-tags';\n\n/** What is known about ONE dist-tag: when it was asked, and what it said. */\nconst TagEntrySchema = z.object({\n checkedAtMs: z.number(),\n /** The version the tag named. Absent when the answer was unusable. */\n latest: z.string().optional(),\n /** When the nudge was last PRINTED for this tag. Absent until one has been. */\n notifiedAtMs: z.number().optional(),\n});\n\n/**\n * The cache is a pure optimization, so a bad one is re-fetched, never repaired.\n * Keyed by dist-tag: an entry this build did not ask about is carried forward\n * untouched rather than evicted.\n */\nconst CacheSchema = z.object({\n schemaVersion: z.literal(1),\n tags: z.record(z.string(), TagEntrySchema),\n /**\n * The resolved \"you could upgrade\" fact, written whenever it changes and\n * cleared when it stops being true.\n *\n * Denormalized from `tags` on purpose: the generated hook scripts are\n * standalone .mjs that cannot import this module and do not know which\n * version is running, so a per-tag entry would leave them unable to tell an\n * upgrade from a match. Storing the comparison's ANSWER is what lets a hook\n * report it without reimplementing any of it.\n */\n signal: z.object({ current: z.string(), latest: z.string() }).optional(),\n});\ntype Cache = z.infer<typeof CacheSchema>;\n\n/** `{\"latest\":\"1.2.3\",\"alpha\":\"1.3.0-alpha.1\"}` — tag names are not fixed. */\nconst DistTagsSchema = z.record(z.string(), z.string());\n\nexport interface UpdateCheckDeps {\n dir: string;\n io: Io;\n /** The global --json flag; ANDed with io.isTTY exactly as the emit path does. */\n json: boolean;\n env?: NodeJS.ProcessEnv;\n /** Clock seam (ms since epoch) for deterministic TTL tests. */\n now?: () => number;\n /** Override global fetch (tests inject a stub returning canned Responses). */\n fetchImpl?: typeof fetch;\n /** The running version; defaults to this build's. Injectable for tests. */\n currentVersion?: string;\n /** Resolved update.mode; defaults to reading the config file. */\n mode?: UpdateMode;\n}\n\n/**\n * Print the update nudge if one is due. NEVER rejects — the caller awaits it\n * between a command's output and its exit, so a throw here would replace a\n * finished command's result with an internal error.\n */\nexport async function maybeUpdate(deps: UpdateCheckDeps): Promise<void> {\n try {\n const env = deps.env ?? process.env;\n // Never in CI, in either mode: a build log cannot act on a nudge, and a\n // build machine must not silently acquire a different binary mid-pipeline.\n if (env.CI !== undefined && env.CI.length > 0) return;\n if (env[NUDGE_OPT_OUT] === '1') return;\n\n const mode = deps.mode ?? (await loadConfig(deps.dir)).update.mode;\n if (mode === 'off') return;\n\n const nowMs = (deps.now ?? Date.now)();\n const current = deps.currentVersion ?? pkg.version;\n const path = updateCheckPath(deps.dir);\n const tag = channelTag(current);\n if (tag === null) return; // a version this build cannot parse follows no channel\n\n // Only this tag's entry answers this binary's question; the other channel's\n // is neither used nor disturbed.\n const cached = await readCache(path);\n const entry = cached?.tags[tag];\n const fresh = entry !== undefined && nowMs - entry.checkedAtMs < CHECK_INTERVAL_MS;\n\n // Resolved through the same function `tenjin update` uses, so the nudge can\n // never advertise a version the command would decline to install, nor stay\n // quiet about one it would.\n //\n // Only a registry that could not be ASKED returns without caching; an answer\n // this build cannot use has still been answered, and moves the clock below.\n let latest: string | null;\n if (fresh) {\n latest = entry.latest ?? null;\n } else {\n const answer = await resolveLatest(current, deps);\n if (answer === null) return;\n latest = answer.latest;\n }\n\n const upgradeable = latest !== null && isNewer(latest, current);\n\n // Once a day means once a day, not once per FETCH: a fresh cache would\n // otherwise repeat the same line on every command for 24h. The two clocks are\n // separate because they answer separate questions — when we last asked npm,\n // and when we last interrupted the human.\n //\n // `human` is part of `due` for the second of those: this code now runs on\n // every surface, to feed the envelope signal, so without it an agent run\n // would stamp the nudge clock having printed nothing and leave a shared\n // machine's terminal quiet for 24h.\n const human = deps.io.isTTY && !deps.json;\n const notifiedAtMs = entry?.notifiedAtMs;\n const due =\n human &&\n upgradeable &&\n (notifiedAtMs === undefined || nowMs - notifiedAtMs >= CHECK_INTERVAL_MS);\n\n // Carried forward when nothing is printed: the day since the last nudge does\n // not restart just because the registry was asked again.\n const nudgedAtMs = due ? nowMs : notifiedAtMs;\n\n // Carries the agent-visible half of the answer, so a hook or an envelope can\n // report it without knowing which version is running.\n const signal = upgradeable && latest !== null ? { current, latest } : undefined;\n const signalChanged =\n cached?.signal?.current !== signal?.current || cached?.signal?.latest !== signal?.latest;\n\n // Nothing learned and nothing said means nothing to write. Deliberately NOT\n // locked: two concurrent CLI processes can both nudge, and one duplicated\n // line is cheaper than a lock on the exit path of every command.\n if (!fresh || due || signalChanged) {\n await writeCache(path, {\n schemaVersion: 1,\n ...(signal !== undefined ? { signal } : {}),\n // Read-modify-write: the tag this run did not ask about keeps whatever it\n // knew, including its own nudge clock.\n tags: {\n ...cached?.tags,\n [tag]: {\n checkedAtMs: fresh ? entry.checkedAtMs : nowMs,\n ...(latest !== null ? { latest } : {}),\n ...(nudgedAtMs !== undefined ? { notifiedAtMs: nudgedAtMs } : {}),\n },\n },\n });\n }\n\n // Named as the command, not the npm invocation it wraps: `update` prints the\n // right instructions itself for an install it cannot perform (a source\n // checkout, a yarn global), so this line is correct everywhere.\n if (due && latest !== null) {\n emitNotice(\n deps.io,\n `tenjin-cli ${latest} is available (you have ${current}). Update: run tenjin update`,\n { json: deps.json },\n );\n }\n } catch {\n // Unreachable by construction (every step below is already guarded); here so\n // that staying invisible does not depend on that remaining true.\n }\n}\n\n/**\n * What the last check learned, for the envelope. Cache only: this runs before\n * every command's output, so it may not fetch, may not block, and may not throw.\n * Null when nothing newer is known, when the cache is absent or stale-shaped, or\n * when `update.mode` is `off` — off silences BOTH surfaces, not just the line a\n * human sees.\n *\n * Reporting rather than installing is the whole design. A CLI that starts a\n * fresh process per invocation has no deferred-activation moment to hide a\n * binary swap in, so the agent is told and decides for itself.\n */\nexport async function readUpdateSignal(\n dir: string,\n currentVersion?: string,\n): Promise<UpdateAvailable | null> {\n try {\n const current = currentVersion ?? pkg.version;\n const tag = channelTag(current);\n if (tag === null) return null;\n if ((await loadConfig(dir)).update.mode === 'off') return null;\n const cached = await readCache(updateCheckPath(dir));\n const latest = cached?.tags[tag]?.latest;\n if (latest === undefined || !isNewer(latest, current)) return null;\n return { current, latest };\n } catch {\n return null; // never the command's business\n }\n}\n\n/**\n * Which dist-tag this build follows, or null for a version string this package\n * has no channel for. Null rather than a default, because every caller's right\n * answer differs: the nudge goes quiet, and `tenjin update` refuses instead of\n * silently reporting a foreign build \"up to date\" against a tag it never\n * belonged to.\n *\n * Every build follows `latest`; see RELEASING.md, which changes with this.\n */\nexport function channelTag(version: string): 'latest' | null {\n return parseVersion(version) === null ? null : 'latest';\n}\n\n/**\n * The version this build can move to: whatever sits on the tag it follows.\n * Consulting a second tag added no reachable version and one way to be wrong: a\n * tag sitting ahead of `latest` could redirect the self-update to a build the\n * release line never promoted. Null both when that tag is absent and when it\n * names a version VERSION_RE rejects; `runUpdate` separates those, and neither\n * means the registry was unreachable.\n */\nexport function resolveTarget(current: string, tags: Record<string, string>): string | null {\n const channel = channelTag(current);\n if (channel === null) return null;\n const candidate = tags[channel];\n // Unparseable counts as absent: isNewer loses every comparison against junk,\n // so admitting one would read as \"up to date\" forever.\n if (candidate === undefined || parseVersion(candidate) === null) return null;\n return candidate;\n}\n\n/**\n * Ask the registry for tenjin-cli's whole dist-tag map. Returns null for every\n * failure there is, INCLUDING a response that arrives too late — the AbortSignal\n * is what bounds the delay a finished command can suffer. Nothing is written\n * here: a failed check caches nothing, so the next command retries rather than\n * going quiet for 24h over one dropped packet. The nudge passes its own short\n * budget; `tenjin update` passes the run's request timeout, because there the\n * fetch IS the command rather than a stowaway on someone else's exit path.\n *\n * The whole map rather than one tag, so a caller can tell an unreachable\n * registry (null) from one that answered without the tag it asked for (a map\n * that lacks the key) — two failures with two different fixes.\n */\nexport async function fetchDistTags(opts: {\n fetchImpl?: typeof fetch;\n timeoutMs: number;\n}): Promise<Record<string, string> | null> {\n const doFetch = opts.fetchImpl ?? fetch;\n let json: unknown;\n try {\n const res = await doFetch(DIST_TAGS_URL, { signal: AbortSignal.timeout(opts.timeoutMs) });\n if (!res.ok) return null;\n json = await res.json();\n } catch {\n return null;\n }\n const parsed = DistTagsSchema.safeParse(json);\n return parsed.success ? parsed.data : null;\n}\n\n/**\n * The nudge's one-shot: fetch, then resolve. Null when the registry could not be\n * asked; `{ latest: null }` when it answered with nothing usable.\n */\nasync function resolveLatest(\n current: string,\n deps: UpdateCheckDeps,\n): Promise<{ latest: string | null } | null> {\n const tags = await fetchDistTags({ fetchImpl: deps.fetchImpl, timeoutMs: FETCH_TIMEOUT_MS });\n return tags === null ? null : { latest: resolveTarget(current, tags) };\n}\n\nasync function writeCache(path: string, cache: Cache): Promise<void> {\n await writeFileAtomic(path, `${JSON.stringify(cache, null, 2)}\\n`, {\n mode: 0o600,\n dirMode: 0o700,\n });\n}\n\nasync function readCache(path: string): Promise<Cache | null> {\n try {\n const parsed = CacheSchema.safeParse(JSON.parse(await readFile(path, 'utf8')));\n return parsed.success ? parsed.data : null;\n } catch {\n return null;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Version comparison: this package's shape only, no semver dependency.\n// ---------------------------------------------------------------------------\n\n/** `major.minor.patch` with an optional `-alpha.N` — every version tenjin-cli\n * has ever published. Anything else is unparseable ON PURPOSE (see isNewer). */\nconst VERSION_RE = /^(\\d+)\\.(\\d+)\\.(\\d+)(?:-alpha\\.(\\d+))?$/;\n\ninterface Version {\n major: number;\n minor: number;\n patch: number;\n /** null = a release; a number = that prerelease counter. */\n alpha: number | null;\n}\n\nfunction parseVersion(raw: string): Version | null {\n const m = VERSION_RE.exec(raw);\n if (m === null) return null;\n const [, major, minor, patch, alpha] = m;\n if (major === undefined || minor === undefined || patch === undefined) return null;\n return {\n major: Number(major),\n minor: Number(minor),\n patch: Number(patch),\n alpha: alpha !== undefined ? Number(alpha) : null,\n };\n}\n\n/**\n * Is `candidate` newer than `current`? An unparseable version on EITHER side is\n * \"not newer\": the registry is untrusted input, and the failure mode of guessing\n * is nagging every single command with a line the user cannot act on. A true\n * return therefore also certifies that BOTH sides parse, which is what lets\n * `tenjin update` splice the candidate into an npm argv without re-validating.\n */\nexport function isNewer(candidate: string, current: string): boolean {\n const a = parseVersion(candidate);\n const b = parseVersion(current);\n if (a === null || b === null) return false;\n if (a.major !== b.major) return a.major > b.major;\n if (a.minor !== b.minor) return a.minor > b.minor;\n if (a.patch !== b.patch) return a.patch > b.patch;\n // Same release triple: semver says a prerelease precedes its own release, so\n // 0.1.0 beats 0.1.0-alpha.9 and never the other way around.\n if (a.alpha === null) return b.alpha !== null;\n if (b.alpha === null) return false;\n return a.alpha > b.alpha;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,SAAS,gBAAgB;AAuClB,IAAM,gBAAgB;AAE7B,IAAM,oBAAoB;AAC1B,IAAM,mBAAmB;AACzB,IAAM,gBAAgB;AAGtB,IAAM,iBAAiB,iBAAE,OAAO;AAAA,EAC9B,aAAa,iBAAE,OAAO;AAAA;AAAA,EAEtB,QAAQ,iBAAE,OAAO,EAAE,SAAS;AAAA;AAAA,EAE5B,cAAc,iBAAE,OAAO,EAAE,SAAS;AACpC,CAAC;AAOD,IAAM,cAAc,iBAAE,OAAO;AAAA,EAC3B,eAAe,iBAAE,QAAQ,CAAC;AAAA,EAC1B,MAAM,iBAAE,OAAO,iBAAE,OAAO,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CAAC,EAAE,OAAO,OAAO,OAAO,KAAK,IAAI;AACvC,MAAI,UAAU,UAAa,UAAU,UAAa,UAAU,OAAW,QAAO;AAC9E,SAAO;AAAA,IACL,OAAO,OAAO,KAAK;AAAA,IACnB,OAAO,OAAO,KAAK;AAAA,IACnB,OAAO,OAAO,KAAK;AAAA,IACnB,OAAO,UAAU,SAAY,OAAO,KAAK,IAAI;AAAA,EAC/C;AACF;AASO,SAAS,QAAQ,WAAmB,SAA0B;AACnE,QAAM,IAAI,aAAa,SAAS;AAChC,QAAM,IAAI,aAAa,OAAO;AAC9B,MAAI,MAAM,QAAQ,MAAM,KAAM,QAAO;AACrC,MAAI,EAAE,UAAU,EAAE,MAAO,QAAO,EAAE,QAAQ,EAAE;AAC5C,MAAI,EAAE,UAAU,EAAE,MAAO,QAAO,EAAE,QAAQ,EAAE;AAC5C,MAAI,EAAE,UAAU,EAAE,MAAO,QAAO,EAAE,QAAQ,EAAE;AAG5C,MAAI,EAAE,UAAU,KAAM,QAAO,EAAE,UAAU;AACzC,MAAI,EAAE,UAAU,KAAM,QAAO;AAC7B,SAAO,EAAE,QAAQ,EAAE;AACrB;","names":[]}
@@ -5,7 +5,7 @@ import {
5
5
  p,
6
6
  r,
7
7
  t
8
- } from "./chunk-HSDCI7OV.js";
8
+ } from "./chunk-XZKD7DIF.js";
9
9
 
10
10
  // node_modules/.pnpm/@signinwithethereum+siwe@4.2.0_viem@2.55.2_typescript@6.0.3_zod@4.4.3_/node_modules/@signinwithethereum/siwe/dist/viemAdapter-By13KInL.js
11
11
  var a2 = /* @__PURE__ */ t({ createViemConfig: () => s });
@@ -28,7 +28,7 @@ var o = [{
28
28
  async function s(e) {
29
29
  let a3;
30
30
  try {
31
- a3 = await import("./_esm-FEASBWRP.js");
31
+ a3 = await import("./_esm-CE7KNONL.js");
32
32
  } catch {
33
33
  throw new r(i.MISSING_PROVIDER_LIBRARY, "viem installed (npm install viem)", "viem not found");
34
34
  }
@@ -67,4 +67,4 @@ export {
67
67
  a2 as a,
68
68
  s
69
69
  };
70
- //# sourceMappingURL=chunk-CYOF7ROH.js.map
70
+ //# sourceMappingURL=chunk-HPWO4O6S.js.map
@@ -0,0 +1,132 @@
1
+ import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
+
3
+ // src/lib/atomic-json.ts
4
+ import { chmod, link, mkdir, open, rename, rm, writeFile } from "node:fs/promises";
5
+ import { randomBytes } from "node:crypto";
6
+ import { basename, dirname, join } from "node:path";
7
+ var isWindows = process.platform === "win32";
8
+ async function writeFileAtomic(targetPath, data, opts = {}) {
9
+ const dir = dirname(targetPath);
10
+ const fileMode = opts.mode ?? 420;
11
+ const dirMode = opts.dirMode ?? 493;
12
+ await mkdir(dir, { recursive: true, ...isWindows ? {} : { mode: dirMode } });
13
+ const tmpPath = join(dir, `.${basename(targetPath)}.${randomBytes(6).toString("hex")}.tmp`);
14
+ try {
15
+ await writeFile(tmpPath, data, isWindows ? void 0 : { mode: fileMode });
16
+ if (!isWindows) await chmod(tmpPath, fileMode);
17
+ await rename(tmpPath, targetPath);
18
+ } catch (err) {
19
+ await rm(tmpPath, { force: true }).catch(() => void 0);
20
+ throw err;
21
+ }
22
+ }
23
+ async function writeFileAtomicExclusive(targetPath, data, opts = {}) {
24
+ const dir = dirname(targetPath);
25
+ const fileMode = opts.mode ?? 420;
26
+ const dirMode = opts.dirMode ?? 493;
27
+ await mkdir(dir, { recursive: true, ...isWindows ? {} : { mode: dirMode } });
28
+ if (isWindows) {
29
+ const handle = await open(targetPath, "wx");
30
+ try {
31
+ await handle.writeFile(data);
32
+ await handle.sync();
33
+ } finally {
34
+ await handle.close();
35
+ }
36
+ return;
37
+ }
38
+ const tmpPath = join(dir, `.${basename(targetPath)}.${randomBytes(6).toString("hex")}.tmp`);
39
+ try {
40
+ const handle = await open(tmpPath, "wx", fileMode);
41
+ try {
42
+ await handle.writeFile(data);
43
+ await handle.chmod(fileMode);
44
+ await handle.sync();
45
+ } finally {
46
+ await handle.close();
47
+ }
48
+ await link(tmpPath, targetPath);
49
+ await fsyncDir(dir);
50
+ } finally {
51
+ await rm(tmpPath, { force: true }).catch(() => void 0);
52
+ }
53
+ }
54
+ async function fsyncDir(dir) {
55
+ const handle = await open(dir, "r");
56
+ try {
57
+ await handle.sync();
58
+ } finally {
59
+ await handle.close();
60
+ }
61
+ }
62
+
63
+ // src/lib/errors.ts
64
+ var EXIT_BY_CODE = {
65
+ NODE_UNSUPPORTED: 1,
66
+ USAGE: 2,
67
+ CONFIG_INVALID: 2,
68
+ WALLET_EXISTS: 3,
69
+ WALLET_MISSING: 1,
70
+ WALLET_INVALID_KEY: 1,
71
+ PROVIDER_ERROR: 1,
72
+ RPC_ERROR: 1,
73
+ API_UNREACHABLE: 1,
74
+ CONTRACT_MISMATCH: 1,
75
+ REFUSED: 3,
76
+ NETWORK_ERROR: 1,
77
+ INTERNAL: 1,
78
+ NOT_IMPLEMENTED: 1,
79
+ POLICY_REFUSED: 3,
80
+ PAYMENT_FAILED: 4,
81
+ RESOURCE_NOT_FOUND: 1,
82
+ SEARCH_NOT_FOUND: 1,
83
+ RATE_LIMITED: 1,
84
+ // A publish awaiting confirmation or hard-blocked is understood-but-refused (3),
85
+ // the same posture as POLICY_REFUSED; a write that failed after approval is a
86
+ // settlement-class failure (4), like PAYMENT_FAILED.
87
+ NEEDS_CONFIRMATION: 3,
88
+ PUBLISH_BLOCKED: 3,
89
+ PUBLISH_FAILED: 4,
90
+ // A send that reverted or stalled AFTER the human approved it and it was
91
+ // broadcast: the post-decision failure class (4), like PAYMENT_FAILED.
92
+ SEND_FAILED: 4,
93
+ // A delete the operator confirmed and the server then refused: same class.
94
+ DELETE_FAILED: 4,
95
+ UPDATE_FAILED: 1,
96
+ // Refused BEFORE any signature existed: the Bazaar lane's fail-closed check.
97
+ REGISTRY_MISMATCH: 3,
98
+ // The seller's 402 challenge does not fit this process's header limit, so the
99
+ // terms could not be read and nothing was sent. Understood and refused (3),
100
+ // not a transport failure: the connection was fine and a retry changes
101
+ // nothing without an operator raising `--max-http-header-size`.
102
+ CHALLENGE_TOO_LARGE: 3
103
+ };
104
+ function exitCodeFor(code) {
105
+ return EXIT_BY_CODE[code];
106
+ }
107
+ var CliError = class extends Error {
108
+ code;
109
+ exitCode;
110
+ fix;
111
+ details;
112
+ constructor(code, message, opts = {}) {
113
+ super(message, opts.cause !== void 0 ? { cause: opts.cause } : void 0);
114
+ this.name = "CliError";
115
+ this.code = code;
116
+ this.exitCode = opts.exitCode ?? exitCodeFor(code);
117
+ this.fix = opts.fix;
118
+ this.details = opts.details;
119
+ }
120
+ };
121
+
122
+ // src/adapters/types.ts
123
+ var HARNESSES = ["claude", "codex"];
124
+
125
+ export {
126
+ writeFileAtomic,
127
+ writeFileAtomicExclusive,
128
+ fsyncDir,
129
+ CliError,
130
+ HARNESSES
131
+ };
132
+ //# sourceMappingURL=chunk-JLEF5WHM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/atomic-json.ts","../src/lib/errors.ts","../src/adapters/types.ts"],"sourcesContent":["import { chmod, link, mkdir, open, rename, rm, writeFile } from 'node:fs/promises';\nimport { randomBytes } from 'node:crypto';\nimport { basename, dirname, join } from 'node:path';\n\n/** fs modes are no-ops on Windows; the 0600/0700 custody story does not apply. */\nconst isWindows = process.platform === 'win32';\n\nexport interface AtomicWriteOptions {\n /** Mode for the written file (ignored on win32). Default 0o644. */\n mode?: number;\n /** Mode for the parent dir when this call creates it (ignored on win32). Default 0o755. */\n dirMode?: number;\n}\n\n/**\n * Write `data` to `targetPath` atomically: a uniquely-named temp file is created\n * in the SAME directory (so the rename is atomic — a cross-filesystem rename is\n * not), given the final mode at open time, then renamed over the target. A\n * reader therefore sees either the old file or the fully-written new one, never\n * a partial write.\n *\n * The temp file is born with the caller's `mode` (0o600 for a wallet key) so the\n * bytes are never written through a world-readable descriptor; the follow-up\n * chmod only makes the mode exact under an unusual umask and only ever touches\n * the temp path, so the live target still appears atomically at its final mode.\n */\nexport async function writeFileAtomic(\n targetPath: string,\n data: string | Buffer,\n opts: AtomicWriteOptions = {},\n): Promise<void> {\n const dir = dirname(targetPath);\n const fileMode = opts.mode ?? 0o644;\n const dirMode = opts.dirMode ?? 0o755;\n\n await mkdir(dir, { recursive: true, ...(isWindows ? {} : { mode: dirMode }) });\n\n const tmpPath = join(dir, `.${basename(targetPath)}.${randomBytes(6).toString('hex')}.tmp`);\n try {\n await writeFile(tmpPath, data, isWindows ? undefined : { mode: fileMode });\n if (!isWindows) await chmod(tmpPath, fileMode);\n await rename(tmpPath, targetPath);\n } catch (err) {\n await rm(tmpPath, { force: true }).catch(() => undefined);\n throw err;\n }\n}\n\n/**\n * Like {@link writeFileAtomic} but NO-CLOBBER and crash-durable: the commit fails\n * with `EEXIST` when `targetPath` already exists instead of replacing it, and the\n * new entry is fsynced before returning. This is what a wallet key needs — two\n * concurrent `create`/`import` runs must not both \"succeed\" and silently lose one\n * key; the loser gets a distinguishable EEXIST the wallet layer maps to\n * WALLET_EXISTS.\n *\n * The temp file is fsynced, then `link()` commits it — link is atomic and throws\n * EEXIST if the target already exists, so the check-then-write race is closed at\n * the filesystem, not by an earlier stat. The parent dir is then fsynced so the\n * new entry survives a crash. On win32, link semantics differ and a directory\n * cannot be fsynced, so we fall back to an exclusive `wx` open (still atomic\n * create-or-EEXIST, just not crash-durable — win32 has no 0600 custody story to\n * protect anyway).\n */\nexport async function writeFileAtomicExclusive(\n targetPath: string,\n data: string,\n opts: AtomicWriteOptions = {},\n): Promise<void> {\n const dir = dirname(targetPath);\n const fileMode = opts.mode ?? 0o644;\n const dirMode = opts.dirMode ?? 0o755;\n\n await mkdir(dir, { recursive: true, ...(isWindows ? {} : { mode: dirMode }) });\n\n if (isWindows) {\n const handle = await open(targetPath, 'wx');\n try {\n await handle.writeFile(data);\n await handle.sync();\n } finally {\n await handle.close();\n }\n return;\n }\n\n const tmpPath = join(dir, `.${basename(targetPath)}.${randomBytes(6).toString('hex')}.tmp`);\n try {\n const handle = await open(tmpPath, 'wx', fileMode);\n try {\n await handle.writeFile(data);\n await handle.chmod(fileMode); // exact mode even under an unusual umask\n await handle.sync();\n } finally {\n await handle.close();\n }\n await link(tmpPath, targetPath); // atomic; throws EEXIST when the target exists\n await fsyncDir(dir);\n } finally {\n // On success the temp is now a redundant link to the target; on EEXIST it is\n // the orphaned write. Either way remove it before returning/throwing.\n await rm(tmpPath, { force: true }).catch(() => undefined);\n }\n}\n\n/** fsync a directory so a freshly linked entry is durable. Never call on win32. */\nexport async function fsyncDir(dir: string): Promise<void> {\n const handle = await open(dir, 'r');\n try {\n await handle.sync();\n } finally {\n await handle.close();\n }\n}\n","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","/**\n * The harness adapter contract (tenjin-notes loop-redesign/04-harness-adapters.md).\n *\n * This and `error-markers.ts` (data both sides read) are the ONLY files the\n * kernel (`src/hooks/*`) imports from `src/adapters/`.\n * A harness is one module exporting a {@link HarnessAdapter}: a pure `decode`\n * from its native payload to {@link HookInput}, a pure `encode` from the\n * kernel's {@link Emit} to its native response, and a {@link Registrar} the\n * installer uses to write its hook entries. The daemon holds one adapter per\n * member of {@link Harness} and one route, `POST /hook/:harness`.\n *\n * Adding a harness is an adapter file plus a transport; nothing in `src/hooks`\n * or `src/daemon` changes. The union gains a member when an adapter lands, not\n * before.\n */\n\nimport type { PublishMode } from '../lib/config';\nimport type {\n CodexGrantResult,\n HarnessPermissions,\n PermissionsResult,\n} from '../lib/harness-permissions';\nimport type { CodexTrustReport, TrustProbeOptions, TrustResult } from '../lib/codex-trust';\n\n/** Harnesses with an adapter in this build. */\nexport type Harness = 'claude' | 'codex';\n\n/** The same union at run time: the installer's ownership predicate matches a\n * registered URL against `/hook/<harness>`, and a list it cannot iterate would\n * have to be spelled a second time. */\nexport const HARNESSES: readonly Harness[] = ['claude', 'codex'];\n\n/**\n * The canonical event vocabulary every adapter maps its native events onto.\n * `session.end` is deliberately absent: no arm registers on it and retention\n * never runs there (a daemon serves many sessions; one ending is not the\n * machine going quiet).\n */\nexport type Event =\n | 'session.start'\n | 'prompt'\n | 'tool.before'\n | 'tool.after'\n | 'agent.start'\n | 'agent.stop'\n | 'turn.end';\n\nexport const EVENTS: readonly Event[] = [\n 'session.start',\n 'prompt',\n 'tool.before',\n 'tool.after',\n 'agent.start',\n 'agent.stop',\n 'turn.end',\n];\n\n/**\n * What a tool IS to the arms. Anything unmatched is `'other'`, never a key.\n *\n * `web` and `fetch` are separate kinds because they are separate arms: a page\n * fetch and a real web search ask different questions, and one agent's six page\n * fetches must not spend the budget its search needed.\n */\nexport type ToolKind = 'web' | 'fetch' | 'dispatch' | 'shell' | 'edit' | 'read';\n\nexport interface ToolResult {\n stdout?: string;\n stderr?: string;\n error?: string;\n text?: string;\n}\n\ninterface ToolBase {\n /** The native tool name, verbatim. */\n name: string;\n callId?: string;\n /**\n * `tool.after` only, and DECIDED IN DECODE, never by an arm reading the\n * result text. `false` is a failure the harness stated or an error marker in\n * a shell's output; `true` is a completion the harness vouched for;\n * `undefined` is unknown, which is what a harness that reports no exit status\n * leaves behind. No marker never means success.\n */\n ok?: boolean;\n result?: ToolResult;\n interrupted?: boolean;\n}\n\n/**\n * The fields the arms read, canonical per kind. Native argument shapes (a\n * `file_path`, a patch body, a `message`) stop at the adapter; an arm never\n * reads a vendor field. One native invocation is one tool value, so an edit\n * that touches several files carries them all in `paths` and the context arm\n * marks every one in a single fire.\n */\nexport type HookTool = ToolBase &\n (\n | { kind: 'shell'; command: string }\n | { kind: 'edit'; paths: string[] }\n | { kind: 'read'; paths: string[] }\n | { kind: 'dispatch'; task: string; description?: string }\n | { kind: 'web'; query: string }\n | { kind: 'fetch'; url: string; prompt: string }\n | { kind: 'other' }\n );\n\n/** The normalized payload the kernel runs on. */\nexport interface HookInput {\n harness: Harness;\n event: Event;\n /** `hook_event_name` verbatim; `encode` stamps its response with it. */\n native: { event: string };\n /** The ROOT session as the harness names it: the id the lead and all its\n * children share. `actorOf` namespaces it by harness before anything is\n * stored, so equal native ids across harnesses never share state. */\n session: string;\n /** Child id; undefined = the lead. Present-but-invalid makes `decode` return null. */\n agent?: string;\n /** Required; '' is allowed and recorded. */\n cwd: string;\n /** Claude `prompt_id`, Codex `turn_id`. */\n turn?: string;\n tool?: HookTool;\n /** The prompt on `prompt`; the spawn prompt on `agent.start` when the harness has it. */\n prompt?: string;\n agentType?: string;\n lastMessage?: string;\n /** Claude/Codex `stop_hook_active`: this stop was raised by a hook's own\n * feedback rather than by the agent finishing. The capture arm reads it to\n * tell an ask turn from the answer turn after one. */\n stopFuse?: boolean;\n transcript?: { path?: string; agentPath?: string };\n /** `session.start` source (`startup`, `clear`, `compact`, `resume`). */\n source?: string;\n /** The native payload. Ledger `question` on error rows and tests only; never read by arms. */\n raw: unknown;\n}\n\n/**\n * What the kernel hands back to the harness. `null` is \"nothing to say\" (204).\n *\n * ONE CHANNEL. Everything an arm says is context beside the turn, including the\n * turn-end ask: on Stop and SubagentStop `additionalContext` keeps the\n * conversation going through the same loop protections a blocking decision\n * would, and shows in the transcript as hook feedback rather than a hook error.\n * A second channel with a red banner said the same words for a worse price.\n */\nexport interface Emit {\n context?: string;\n}\n\n/**\n * What the installer needs to register a harness, and nothing the daemon runs\n * on: `selectArm` reads the event and tool kind off the decoded input, so a\n * registrar carries no event or tool metadata that would claim an enforcement\n * nothing performs.\n */\nexport interface Registrar {\n /** The harness's own hooks file under `home`. */\n configPath(home: string, env?: NodeJS.ProcessEnv): string;\n /**\n * Entries the installer merges additively into that file, each\n * `{ event, matcher?, hooks }` in the harness's own JSON shape.\n */\n plan(target: { url: string; token: string; shimPath: string; timeoutSeconds: number }): unknown[];\n /**\n * The steps left to a PERSON once the file is written, for a harness that\n * gates entries it has not been told to trust. Takes the path actually\n * written, because a machine on `$CODEX_HOME` is not reading `~/.codex`.\n * One sentence was not enough: as a clause on the undo line, operators\n * finished an install reporting \"7 entries\" with a loop that never fired\n * (tenjin-agent#342).\n */\n activation?(hooksPath: string): string[];\n /** The harness-native persistent command grant, when this harness has one. */\n grant?: {\n path(home: string, env?: NodeJS.ProcessEnv): string;\n inspect(home: string, mode: PublishMode, env?: NodeJS.ProcessEnv): Promise<HarnessPermissions>;\n write(\n home: string,\n mode: PublishMode,\n env?: NodeJS.ProcessEnv,\n ): Promise<PermissionsResult | CodexGrantResult>;\n remove?(home: string, env?: NodeJS.ProcessEnv): Promise<{ path: string; removed: boolean }>;\n };\n /** A harness-native trust gate for registered hook handlers. */\n trust?: {\n ensure(\n home: string,\n keys: readonly string[],\n ownedBy: (row: { command?: unknown; sourcePath?: unknown }) => boolean,\n opts?: TrustProbeOptions,\n ): Promise<TrustResult>;\n read(\n home: string,\n keys: readonly string[],\n opts?: TrustProbeOptions,\n ): Promise<CodexTrustReport>;\n };\n}\n\nexport interface HarnessAdapter {\n id: Harness;\n /** Pure. `null` = drop the fire quietly (unknown event, invalid identity). */\n decode(raw: unknown): HookInput | null;\n /** Pure. `null`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A;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;;;AC7DO,IAAM,YAAgC,CAAC,UAAU,OAAO;","names":[]}
@@ -35,7 +35,7 @@ import {
35
35
  randomBytes,
36
36
  rotr,
37
37
  toBytes
38
- } from "./chunk-5CLSD5YN.js";
38
+ } from "./chunk-BPMWXTFX.js";
39
39
 
40
40
  // node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/_md.js
41
41
  function setBigUint64(view, byteOffset, value, isLE) {
@@ -2250,4 +2250,4 @@ export {
2250
2250
  @noble/curves/esm/secp256k1.js:
2251
2251
  (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
2252
2252
  */
2253
- //# sourceMappingURL=chunk-QVX5MWJZ.js.map
2253
+ //# sourceMappingURL=chunk-JRGFKVAZ.js.map
@@ -15,7 +15,7 @@ import {
15
15
  swap32IfBE,
16
16
  toBytes,
17
17
  u32
18
- } from "./chunk-5CLSD5YN.js";
18
+ } from "./chunk-BPMWXTFX.js";
19
19
 
20
20
  // node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/sha3.js
21
21
  var _0n = BigInt(0);
@@ -201,4 +201,4 @@ var keccak_256 = /* @__PURE__ */ (() => gen(1, 136, 256 / 8))();
201
201
  export {
202
202
  keccak_256
203
203
  };
204
- //# sourceMappingURL=chunk-HIVZG55D.js.map
204
+ //# sourceMappingURL=chunk-KG3D7FIF.js.map