@rarog/server 0.0.0-stage → 1.1.0-beta.1

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 (1547) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +161 -2
  3. package/THIRD-PARTY-NOTICES +2110 -0
  4. package/bin/rarog.mjs +146 -0
  5. package/node_modules/@rarog/shared/LICENSE +21 -0
  6. package/node_modules/@rarog/shared/package.json +43 -0
  7. package/node_modules/@rarog/shared/src/data-dir.d.mts +49 -0
  8. package/node_modules/@rarog/shared/src/data-dir.mjs +120 -0
  9. package/node_modules/@rarog/shared/src/decode.js +381 -0
  10. package/node_modules/@rarog/shared/src/iroh.js +13 -0
  11. package/node_modules/@rarog/shared/src/notify-copy.js +12 -0
  12. package/node_modules/@rarog/shared/src/pairing-link.js +246 -0
  13. package/node_modules/@rarog/shared/src/protocol/activity.js +42 -0
  14. package/node_modules/@rarog/shared/src/protocol/attachments.js +192 -0
  15. package/node_modules/@rarog/shared/src/protocol/background.js +89 -0
  16. package/node_modules/@rarog/shared/src/protocol/commands.js +34 -0
  17. package/node_modules/@rarog/shared/src/protocol/consent.js +28 -0
  18. package/node_modules/@rarog/shared/src/protocol/dictation.js +23 -0
  19. package/node_modules/@rarog/shared/src/protocol/diff.js +78 -0
  20. package/node_modules/@rarog/shared/src/protocol/directories.js +44 -0
  21. package/node_modules/@rarog/shared/src/protocol/files.js +33 -0
  22. package/node_modules/@rarog/shared/src/protocol/git.js +23 -0
  23. package/node_modules/@rarog/shared/src/protocol/herdr.js +23 -0
  24. package/node_modules/@rarog/shared/src/protocol/inbox.js +38 -0
  25. package/node_modules/@rarog/shared/src/protocol/model.js +214 -0
  26. package/node_modules/@rarog/shared/src/protocol/notes.js +91 -0
  27. package/node_modules/@rarog/shared/src/protocol/resume.js +57 -0
  28. package/node_modules/@rarog/shared/src/protocol/terminal.js +259 -0
  29. package/node_modules/@rarog/shared/src/protocol.js +864 -0
  30. package/node_modules/@rarog/shared/src/relay-auth.js +231 -0
  31. package/node_modules/@rarog/shared/src/relay.js +103 -0
  32. package/node_modules/@rarog/shared/src/rest.js +898 -0
  33. package/node_modules/@rarog/shared/src/sentences/commands.js +203 -0
  34. package/node_modules/@rarog/shared/src/sentences/demo.js +10 -0
  35. package/node_modules/@rarog/shared/src/sentences/dialogs.js +103 -0
  36. package/node_modules/@rarog/shared/src/sentences/herdr.js +111 -0
  37. package/node_modules/@rarog/shared/src/sentences/index.js +362 -0
  38. package/node_modules/@rarog/shared/src/sentences/model.js +73 -0
  39. package/node_modules/@rarog/shared/src/sentences/push.js +56 -0
  40. package/node_modules/@rarog/shared/src/sentences/rest.js +140 -0
  41. package/node_modules/@rarog/shared/src/sentences/restart.js +71 -0
  42. package/node_modules/@rarog/shared/src/sentences/session.js +133 -0
  43. package/node_modules/@rarog/shared/src/sentences/state.js +15 -0
  44. package/node_modules/@rarog/shared/src/sentences/term.js +34 -0
  45. package/node_modules/@rarog/shared/src/sentences/transcript.js +24 -0
  46. package/node_modules/@rarog/shared/src/sentences/uploads.js +32 -0
  47. package/node_modules/@rarog/shared/src/workflow-phases.js +45 -0
  48. package/node_modules/ansi-regex/index.d.ts +37 -0
  49. package/node_modules/ansi-regex/index.js +10 -0
  50. package/node_modules/ansi-regex/license +9 -0
  51. package/node_modules/ansi-regex/package.json +55 -0
  52. package/node_modules/ansi-regex/readme.md +78 -0
  53. package/node_modules/ansi-styles/index.d.ts +345 -0
  54. package/node_modules/ansi-styles/index.js +163 -0
  55. package/node_modules/ansi-styles/license +9 -0
  56. package/node_modules/ansi-styles/package.json +56 -0
  57. package/node_modules/ansi-styles/readme.md +152 -0
  58. package/node_modules/camelcase/index.d.ts +63 -0
  59. package/node_modules/camelcase/index.js +76 -0
  60. package/node_modules/camelcase/license +9 -0
  61. package/node_modules/camelcase/package.json +43 -0
  62. package/node_modules/camelcase/readme.md +99 -0
  63. package/node_modules/cliui/LICENSE.txt +14 -0
  64. package/node_modules/cliui/README.md +115 -0
  65. package/node_modules/cliui/index.js +354 -0
  66. package/node_modules/cliui/package.json +65 -0
  67. package/node_modules/color-convert/LICENSE +21 -0
  68. package/node_modules/color-convert/README.md +68 -0
  69. package/node_modules/color-convert/conversions.js +839 -0
  70. package/node_modules/color-convert/index.js +81 -0
  71. package/node_modules/color-convert/package.json +48 -0
  72. package/node_modules/color-convert/route.js +97 -0
  73. package/node_modules/color-name/LICENSE +8 -0
  74. package/node_modules/color-name/README.md +11 -0
  75. package/node_modules/color-name/index.js +152 -0
  76. package/node_modules/color-name/package.json +28 -0
  77. package/node_modules/decamelize/index.js +13 -0
  78. package/node_modules/decamelize/license +21 -0
  79. package/node_modules/decamelize/package.json +38 -0
  80. package/node_modules/decamelize/readme.md +48 -0
  81. package/node_modules/dijkstrajs/.travis.yml +4 -0
  82. package/node_modules/dijkstrajs/CONTRIBUTING.md +8 -0
  83. package/node_modules/dijkstrajs/LICENSE.md +19 -0
  84. package/node_modules/dijkstrajs/README.md +18 -0
  85. package/node_modules/dijkstrajs/dijkstra.js +165 -0
  86. package/node_modules/dijkstrajs/package.json +60 -0
  87. package/node_modules/dijkstrajs/test/dijkstra.test.js +96 -0
  88. package/node_modules/emoji-regex/LICENSE-MIT.txt +20 -0
  89. package/node_modules/emoji-regex/README.md +73 -0
  90. package/node_modules/emoji-regex/es2015/index.js +6 -0
  91. package/node_modules/emoji-regex/es2015/text.js +6 -0
  92. package/node_modules/emoji-regex/index.d.ts +23 -0
  93. package/node_modules/emoji-regex/index.js +6 -0
  94. package/node_modules/emoji-regex/package.json +50 -0
  95. package/node_modules/emoji-regex/text.js +6 -0
  96. package/node_modules/find-up/index.d.ts +137 -0
  97. package/node_modules/find-up/index.js +89 -0
  98. package/node_modules/find-up/license +9 -0
  99. package/node_modules/find-up/package.json +53 -0
  100. package/node_modules/find-up/readme.md +156 -0
  101. package/node_modules/get-caller-file/LICENSE.md +6 -0
  102. package/node_modules/get-caller-file/README.md +41 -0
  103. package/node_modules/get-caller-file/index.d.ts +2 -0
  104. package/node_modules/get-caller-file/index.js +22 -0
  105. package/node_modules/get-caller-file/index.js.map +1 -0
  106. package/node_modules/get-caller-file/package.json +42 -0
  107. package/node_modules/is-fullwidth-code-point/index.d.ts +17 -0
  108. package/node_modules/is-fullwidth-code-point/index.js +50 -0
  109. package/node_modules/is-fullwidth-code-point/license +9 -0
  110. package/node_modules/is-fullwidth-code-point/package.json +42 -0
  111. package/node_modules/is-fullwidth-code-point/readme.md +39 -0
  112. package/node_modules/locate-path/index.d.ts +83 -0
  113. package/node_modules/locate-path/index.js +65 -0
  114. package/node_modules/locate-path/license +9 -0
  115. package/node_modules/locate-path/package.json +45 -0
  116. package/node_modules/locate-path/readme.md +122 -0
  117. package/node_modules/p-limit/index.d.ts +38 -0
  118. package/node_modules/p-limit/index.js +57 -0
  119. package/node_modules/p-limit/license +9 -0
  120. package/node_modules/p-limit/package.json +52 -0
  121. package/node_modules/p-limit/readme.md +101 -0
  122. package/node_modules/p-locate/index.d.ts +64 -0
  123. package/node_modules/p-locate/index.js +52 -0
  124. package/node_modules/p-locate/license +9 -0
  125. package/node_modules/p-locate/package.json +53 -0
  126. package/node_modules/p-locate/readme.md +90 -0
  127. package/node_modules/p-try/index.d.ts +39 -0
  128. package/node_modules/p-try/index.js +9 -0
  129. package/node_modules/p-try/license +9 -0
  130. package/node_modules/p-try/package.json +42 -0
  131. package/node_modules/p-try/readme.md +58 -0
  132. package/node_modules/path-exists/index.d.ts +28 -0
  133. package/node_modules/path-exists/index.js +23 -0
  134. package/node_modules/path-exists/license +9 -0
  135. package/node_modules/path-exists/package.json +39 -0
  136. package/node_modules/path-exists/readme.md +52 -0
  137. package/node_modules/pngjs/.eslintignore +2 -0
  138. package/node_modules/pngjs/.eslintrc.json +19 -0
  139. package/node_modules/pngjs/.prettierignore +3 -0
  140. package/node_modules/pngjs/LICENSE +20 -0
  141. package/node_modules/pngjs/README.md +429 -0
  142. package/node_modules/pngjs/browser.js +16096 -0
  143. package/node_modules/pngjs/coverage/lcov-report/base.css +354 -0
  144. package/node_modules/pngjs/coverage/lcov-report/bitmapper.js.html +881 -0
  145. package/node_modules/pngjs/coverage/lcov-report/bitpacker.js.html +554 -0
  146. package/node_modules/pngjs/coverage/lcov-report/block-navigation.js +77 -0
  147. package/node_modules/pngjs/coverage/lcov-report/chunkstream.js.html +647 -0
  148. package/node_modules/pngjs/coverage/lcov-report/constants.js.html +176 -0
  149. package/node_modules/pngjs/coverage/lcov-report/crc.js.html +200 -0
  150. package/node_modules/pngjs/coverage/lcov-report/favicon.png +0 -0
  151. package/node_modules/pngjs/coverage/lcov-report/filter-pack.js.html +593 -0
  152. package/node_modules/pngjs/coverage/lcov-report/filter-parse-async.js.html +152 -0
  153. package/node_modules/pngjs/coverage/lcov-report/filter-parse-sync.js.html +143 -0
  154. package/node_modules/pngjs/coverage/lcov-report/filter-parse.js.html +611 -0
  155. package/node_modules/pngjs/coverage/lcov-report/format-normaliser.js.html +359 -0
  156. package/node_modules/pngjs/coverage/lcov-report/index.html +426 -0
  157. package/node_modules/pngjs/coverage/lcov-report/interlace.js.html +365 -0
  158. package/node_modules/pngjs/coverage/lcov-report/packer-async.js.html +230 -0
  159. package/node_modules/pngjs/coverage/lcov-report/packer-sync.js.html +248 -0
  160. package/node_modules/pngjs/coverage/lcov-report/packer.js.html +467 -0
  161. package/node_modules/pngjs/coverage/lcov-report/paeth-predictor.js.html +128 -0
  162. package/node_modules/pngjs/coverage/lcov-report/parser-async.js.html +575 -0
  163. package/node_modules/pngjs/coverage/lcov-report/parser-sync.js.html +404 -0
  164. package/node_modules/pngjs/coverage/lcov-report/parser.js.html +950 -0
  165. package/node_modules/pngjs/coverage/lcov-report/png-sync.js.html +116 -0
  166. package/node_modules/pngjs/coverage/lcov-report/png.js.html +662 -0
  167. package/node_modules/pngjs/coverage/lcov-report/prettify.css +101 -0
  168. package/node_modules/pngjs/coverage/lcov-report/prettify.js +1007 -0
  169. package/node_modules/pngjs/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  170. package/node_modules/pngjs/coverage/lcov-report/sorter.js +169 -0
  171. package/node_modules/pngjs/coverage/lcov-report/sync-inflate.js.html +584 -0
  172. package/node_modules/pngjs/coverage/lcov-report/sync-reader.js.html +215 -0
  173. package/node_modules/pngjs/coverage/lcov.info +2177 -0
  174. package/node_modules/pngjs/lib/bitmapper.js +267 -0
  175. package/node_modules/pngjs/lib/bitpacker.js +158 -0
  176. package/node_modules/pngjs/lib/chunkstream.js +189 -0
  177. package/node_modules/pngjs/lib/constants.js +32 -0
  178. package/node_modules/pngjs/lib/crc.js +40 -0
  179. package/node_modules/pngjs/lib/filter-pack.js +171 -0
  180. package/node_modules/pngjs/lib/filter-parse-async.js +24 -0
  181. package/node_modules/pngjs/lib/filter-parse-sync.js +21 -0
  182. package/node_modules/pngjs/lib/filter-parse.js +177 -0
  183. package/node_modules/pngjs/lib/format-normaliser.js +93 -0
  184. package/node_modules/pngjs/lib/interlace.js +95 -0
  185. package/node_modules/pngjs/lib/packer-async.js +50 -0
  186. package/node_modules/pngjs/lib/packer-sync.js +56 -0
  187. package/node_modules/pngjs/lib/packer.js +129 -0
  188. package/node_modules/pngjs/lib/paeth-predictor.js +16 -0
  189. package/node_modules/pngjs/lib/parser-async.js +165 -0
  190. package/node_modules/pngjs/lib/parser-sync.js +108 -0
  191. package/node_modules/pngjs/lib/parser.js +290 -0
  192. package/node_modules/pngjs/lib/png-sync.js +12 -0
  193. package/node_modules/pngjs/lib/png.js +194 -0
  194. package/node_modules/pngjs/lib/sync-inflate.js +168 -0
  195. package/node_modules/pngjs/lib/sync-reader.js +45 -0
  196. package/node_modules/pngjs/package.json +73 -0
  197. package/node_modules/qrcode/README.md +770 -0
  198. package/node_modules/qrcode/bin/qrcode +159 -0
  199. package/node_modules/qrcode/helper/to-sjis-browser.js +2 -0
  200. package/node_modules/qrcode/helper/to-sjis.js +105 -0
  201. package/node_modules/qrcode/lib/browser.js +76 -0
  202. package/node_modules/qrcode/lib/can-promise.js +7 -0
  203. package/node_modules/qrcode/lib/core/alignment-pattern.js +83 -0
  204. package/node_modules/qrcode/lib/core/alphanumeric-data.js +59 -0
  205. package/node_modules/qrcode/lib/core/bit-buffer.js +37 -0
  206. package/node_modules/qrcode/lib/core/bit-matrix.js +65 -0
  207. package/node_modules/qrcode/lib/core/byte-data.js +30 -0
  208. package/node_modules/qrcode/lib/core/error-correction-code.js +135 -0
  209. package/node_modules/qrcode/lib/core/error-correction-level.js +50 -0
  210. package/node_modules/qrcode/lib/core/finder-pattern.js +22 -0
  211. package/node_modules/qrcode/lib/core/format-info.js +29 -0
  212. package/node_modules/qrcode/lib/core/galois-field.js +69 -0
  213. package/node_modules/qrcode/lib/core/kanji-data.js +54 -0
  214. package/node_modules/qrcode/lib/core/mask-pattern.js +234 -0
  215. package/node_modules/qrcode/lib/core/mode.js +167 -0
  216. package/node_modules/qrcode/lib/core/numeric-data.js +43 -0
  217. package/node_modules/qrcode/lib/core/polynomial.js +62 -0
  218. package/node_modules/qrcode/lib/core/qrcode.js +495 -0
  219. package/node_modules/qrcode/lib/core/reed-solomon-encoder.js +56 -0
  220. package/node_modules/qrcode/lib/core/regex.js +31 -0
  221. package/node_modules/qrcode/lib/core/segments.js +330 -0
  222. package/node_modules/qrcode/lib/core/utils.js +63 -0
  223. package/node_modules/qrcode/lib/core/version-check.js +9 -0
  224. package/node_modules/qrcode/lib/core/version.js +163 -0
  225. package/node_modules/qrcode/lib/index.js +12 -0
  226. package/node_modules/qrcode/lib/renderer/canvas.js +63 -0
  227. package/node_modules/qrcode/lib/renderer/png.js +78 -0
  228. package/node_modules/qrcode/lib/renderer/svg-tag.js +81 -0
  229. package/node_modules/qrcode/lib/renderer/svg.js +19 -0
  230. package/node_modules/qrcode/lib/renderer/terminal/terminal-small.js +85 -0
  231. package/node_modules/qrcode/lib/renderer/terminal/terminal.js +49 -0
  232. package/node_modules/qrcode/lib/renderer/terminal.js +9 -0
  233. package/node_modules/qrcode/lib/renderer/utf8.js +71 -0
  234. package/node_modules/qrcode/lib/renderer/utils.js +99 -0
  235. package/node_modules/qrcode/lib/server.js +138 -0
  236. package/node_modules/qrcode/license +10 -0
  237. package/node_modules/qrcode/package.json +77 -0
  238. package/node_modules/require-directory/.jshintrc +67 -0
  239. package/node_modules/require-directory/.npmignore +1 -0
  240. package/node_modules/require-directory/.travis.yml +3 -0
  241. package/node_modules/require-directory/LICENSE +22 -0
  242. package/node_modules/require-directory/README.markdown +184 -0
  243. package/node_modules/require-directory/index.js +86 -0
  244. package/node_modules/require-directory/package.json +40 -0
  245. package/node_modules/require-main-filename/LICENSE.txt +14 -0
  246. package/node_modules/require-main-filename/README.md +26 -0
  247. package/node_modules/require-main-filename/index.js +18 -0
  248. package/node_modules/require-main-filename/package.json +35 -0
  249. package/node_modules/set-blocking/LICENSE.txt +14 -0
  250. package/node_modules/set-blocking/README.md +31 -0
  251. package/node_modules/set-blocking/index.js +7 -0
  252. package/node_modules/set-blocking/package.json +42 -0
  253. package/node_modules/string-width/index.d.ts +29 -0
  254. package/node_modules/string-width/index.js +47 -0
  255. package/node_modules/string-width/license +9 -0
  256. package/node_modules/string-width/package.json +56 -0
  257. package/node_modules/string-width/readme.md +50 -0
  258. package/node_modules/strip-ansi/index.d.ts +17 -0
  259. package/node_modules/strip-ansi/index.js +4 -0
  260. package/node_modules/strip-ansi/license +9 -0
  261. package/node_modules/strip-ansi/package.json +54 -0
  262. package/node_modules/strip-ansi/readme.md +46 -0
  263. package/node_modules/which-module/LICENSE +13 -0
  264. package/node_modules/which-module/README.md +58 -0
  265. package/node_modules/which-module/index.js +9 -0
  266. package/node_modules/which-module/package.json +41 -0
  267. package/node_modules/wrap-ansi/index.js +186 -0
  268. package/node_modules/wrap-ansi/license +9 -0
  269. package/node_modules/wrap-ansi/package.json +61 -0
  270. package/node_modules/wrap-ansi/readme.md +97 -0
  271. package/node_modules/ws/LICENSE +20 -0
  272. package/node_modules/ws/README.md +548 -0
  273. package/node_modules/ws/browser.js +8 -0
  274. package/node_modules/ws/index.js +22 -0
  275. package/node_modules/ws/lib/buffer-util.js +131 -0
  276. package/node_modules/ws/lib/constants.js +19 -0
  277. package/node_modules/ws/lib/event-target.js +292 -0
  278. package/node_modules/ws/lib/extension.js +203 -0
  279. package/node_modules/ws/lib/limiter.js +55 -0
  280. package/node_modules/ws/lib/permessage-deflate.js +530 -0
  281. package/node_modules/ws/lib/receiver.js +743 -0
  282. package/node_modules/ws/lib/sender.js +607 -0
  283. package/node_modules/ws/lib/stream.js +161 -0
  284. package/node_modules/ws/lib/subprotocol.js +62 -0
  285. package/node_modules/ws/lib/validation.js +152 -0
  286. package/node_modules/ws/lib/websocket-server.js +562 -0
  287. package/node_modules/ws/lib/websocket.js +1407 -0
  288. package/node_modules/ws/package.json +74 -0
  289. package/node_modules/ws/wrapper.mjs +21 -0
  290. package/node_modules/y18n/LICENSE +13 -0
  291. package/node_modules/y18n/README.md +109 -0
  292. package/node_modules/y18n/index.js +188 -0
  293. package/node_modules/y18n/package.json +39 -0
  294. package/node_modules/yargs/LICENSE +21 -0
  295. package/node_modules/yargs/README.md +140 -0
  296. package/node_modules/yargs/build/lib/apply-extends.d.ts +2 -0
  297. package/node_modules/yargs/build/lib/apply-extends.js +65 -0
  298. package/node_modules/yargs/build/lib/argsert.d.ts +2 -0
  299. package/node_modules/yargs/build/lib/argsert.js +65 -0
  300. package/node_modules/yargs/build/lib/command.d.ts +64 -0
  301. package/node_modules/yargs/build/lib/command.js +416 -0
  302. package/node_modules/yargs/build/lib/common-types.d.ts +36 -0
  303. package/node_modules/yargs/build/lib/common-types.js +25 -0
  304. package/node_modules/yargs/build/lib/completion-templates.d.ts +2 -0
  305. package/node_modules/yargs/build/lib/completion-templates.js +50 -0
  306. package/node_modules/yargs/build/lib/completion.d.ts +21 -0
  307. package/node_modules/yargs/build/lib/completion.js +135 -0
  308. package/node_modules/yargs/build/lib/is-promise.d.ts +1 -0
  309. package/node_modules/yargs/build/lib/is-promise.js +9 -0
  310. package/node_modules/yargs/build/lib/levenshtein.d.ts +1 -0
  311. package/node_modules/yargs/build/lib/levenshtein.js +58 -0
  312. package/node_modules/yargs/build/lib/middleware.d.ts +10 -0
  313. package/node_modules/yargs/build/lib/middleware.js +57 -0
  314. package/node_modules/yargs/build/lib/obj-filter.d.ts +1 -0
  315. package/node_modules/yargs/build/lib/obj-filter.js +14 -0
  316. package/node_modules/yargs/build/lib/parse-command.d.ts +11 -0
  317. package/node_modules/yargs/build/lib/parse-command.js +36 -0
  318. package/node_modules/yargs/build/lib/process-argv.d.ts +2 -0
  319. package/node_modules/yargs/build/lib/process-argv.js +31 -0
  320. package/node_modules/yargs/build/lib/usage.d.ts +49 -0
  321. package/node_modules/yargs/build/lib/usage.js +540 -0
  322. package/node_modules/yargs/build/lib/validation.d.ts +34 -0
  323. package/node_modules/yargs/build/lib/validation.js +330 -0
  324. package/node_modules/yargs/build/lib/yargs.d.ts +274 -0
  325. package/node_modules/yargs/build/lib/yargs.js +1190 -0
  326. package/node_modules/yargs/build/lib/yerror.d.ts +4 -0
  327. package/node_modules/yargs/build/lib/yerror.js +11 -0
  328. package/node_modules/yargs/index.js +40 -0
  329. package/node_modules/yargs/locales/be.json +46 -0
  330. package/node_modules/yargs/locales/de.json +46 -0
  331. package/node_modules/yargs/locales/en.json +51 -0
  332. package/node_modules/yargs/locales/es.json +46 -0
  333. package/node_modules/yargs/locales/fi.json +49 -0
  334. package/node_modules/yargs/locales/fr.json +53 -0
  335. package/node_modules/yargs/locales/hi.json +49 -0
  336. package/node_modules/yargs/locales/hu.json +46 -0
  337. package/node_modules/yargs/locales/id.json +50 -0
  338. package/node_modules/yargs/locales/it.json +46 -0
  339. package/node_modules/yargs/locales/ja.json +51 -0
  340. package/node_modules/yargs/locales/ko.json +49 -0
  341. package/node_modules/yargs/locales/nb.json +44 -0
  342. package/node_modules/yargs/locales/nl.json +49 -0
  343. package/node_modules/yargs/locales/nn.json +44 -0
  344. package/node_modules/yargs/locales/pirate.json +13 -0
  345. package/node_modules/yargs/locales/pl.json +49 -0
  346. package/node_modules/yargs/locales/pt.json +45 -0
  347. package/node_modules/yargs/locales/pt_BR.json +48 -0
  348. package/node_modules/yargs/locales/ru.json +46 -0
  349. package/node_modules/yargs/locales/th.json +46 -0
  350. package/node_modules/yargs/locales/tr.json +48 -0
  351. package/node_modules/yargs/locales/zh_CN.json +48 -0
  352. package/node_modules/yargs/locales/zh_TW.json +47 -0
  353. package/node_modules/yargs/package.json +92 -0
  354. package/node_modules/yargs/yargs.js +14 -0
  355. package/node_modules/yargs-parser/LICENSE.txt +14 -0
  356. package/node_modules/yargs-parser/README.md +449 -0
  357. package/node_modules/yargs-parser/index.js +1032 -0
  358. package/node_modules/yargs-parser/lib/tokenize-arg-string.js +40 -0
  359. package/node_modules/yargs-parser/package.json +46 -0
  360. package/node_modules/zod/LICENSE +21 -0
  361. package/node_modules/zod/README.md +191 -0
  362. package/node_modules/zod/index.cjs +33 -0
  363. package/node_modules/zod/index.d.cts +4 -0
  364. package/node_modules/zod/index.d.ts +4 -0
  365. package/node_modules/zod/index.js +4 -0
  366. package/node_modules/zod/locales/index.cjs +17 -0
  367. package/node_modules/zod/locales/index.d.cts +1 -0
  368. package/node_modules/zod/locales/index.d.ts +1 -0
  369. package/node_modules/zod/locales/index.js +1 -0
  370. package/node_modules/zod/locales/package.json +7 -0
  371. package/node_modules/zod/mini/index.cjs +32 -0
  372. package/node_modules/zod/mini/index.d.cts +3 -0
  373. package/node_modules/zod/mini/index.d.ts +3 -0
  374. package/node_modules/zod/mini/index.js +3 -0
  375. package/node_modules/zod/mini/package.json +7 -0
  376. package/node_modules/zod/package.json +135 -0
  377. package/node_modules/zod/src/index.ts +4 -0
  378. package/node_modules/zod/src/locales/index.ts +1 -0
  379. package/node_modules/zod/src/mini/index.ts +3 -0
  380. package/node_modules/zod/src/v3/ZodError.ts +330 -0
  381. package/node_modules/zod/src/v3/benchmarks/datetime.ts +58 -0
  382. package/node_modules/zod/src/v3/benchmarks/discriminatedUnion.ts +80 -0
  383. package/node_modules/zod/src/v3/benchmarks/index.ts +59 -0
  384. package/node_modules/zod/src/v3/benchmarks/ipv4.ts +57 -0
  385. package/node_modules/zod/src/v3/benchmarks/object.ts +69 -0
  386. package/node_modules/zod/src/v3/benchmarks/primitives.ts +162 -0
  387. package/node_modules/zod/src/v3/benchmarks/realworld.ts +63 -0
  388. package/node_modules/zod/src/v3/benchmarks/string.ts +55 -0
  389. package/node_modules/zod/src/v3/benchmarks/union.ts +80 -0
  390. package/node_modules/zod/src/v3/errors.ts +13 -0
  391. package/node_modules/zod/src/v3/external.ts +6 -0
  392. package/node_modules/zod/src/v3/helpers/enumUtil.ts +17 -0
  393. package/node_modules/zod/src/v3/helpers/errorUtil.ts +8 -0
  394. package/node_modules/zod/src/v3/helpers/parseUtil.ts +176 -0
  395. package/node_modules/zod/src/v3/helpers/partialUtil.ts +34 -0
  396. package/node_modules/zod/src/v3/helpers/typeAliases.ts +2 -0
  397. package/node_modules/zod/src/v3/helpers/util.ts +224 -0
  398. package/node_modules/zod/src/v3/index.ts +4 -0
  399. package/node_modules/zod/src/v3/locales/en.ts +124 -0
  400. package/node_modules/zod/src/v3/standard-schema.ts +113 -0
  401. package/node_modules/zod/src/v3/tests/Mocker.ts +54 -0
  402. package/node_modules/zod/src/v3/tests/all-errors.test.ts +157 -0
  403. package/node_modules/zod/src/v3/tests/anyunknown.test.ts +28 -0
  404. package/node_modules/zod/src/v3/tests/array.test.ts +71 -0
  405. package/node_modules/zod/src/v3/tests/async-parsing.test.ts +388 -0
  406. package/node_modules/zod/src/v3/tests/async-refinements.test.ts +46 -0
  407. package/node_modules/zod/src/v3/tests/base.test.ts +29 -0
  408. package/node_modules/zod/src/v3/tests/bigint.test.ts +55 -0
  409. package/node_modules/zod/src/v3/tests/branded.test.ts +53 -0
  410. package/node_modules/zod/src/v3/tests/catch.test.ts +220 -0
  411. package/node_modules/zod/src/v3/tests/coerce.test.ts +133 -0
  412. package/node_modules/zod/src/v3/tests/complex.test.ts +70 -0
  413. package/node_modules/zod/src/v3/tests/custom.test.ts +31 -0
  414. package/node_modules/zod/src/v3/tests/date.test.ts +32 -0
  415. package/node_modules/zod/src/v3/tests/deepmasking.test.ts +186 -0
  416. package/node_modules/zod/src/v3/tests/default.test.ts +112 -0
  417. package/node_modules/zod/src/v3/tests/description.test.ts +33 -0
  418. package/node_modules/zod/src/v3/tests/discriminated-unions.test.ts +315 -0
  419. package/node_modules/zod/src/v3/tests/enum.test.ts +80 -0
  420. package/node_modules/zod/src/v3/tests/error.test.ts +551 -0
  421. package/node_modules/zod/src/v3/tests/firstparty.test.ts +87 -0
  422. package/node_modules/zod/src/v3/tests/firstpartyschematypes.test.ts +21 -0
  423. package/node_modules/zod/src/v3/tests/function.test.ts +261 -0
  424. package/node_modules/zod/src/v3/tests/generics.test.ts +48 -0
  425. package/node_modules/zod/src/v3/tests/instanceof.test.ts +37 -0
  426. package/node_modules/zod/src/v3/tests/intersection.test.ts +110 -0
  427. package/node_modules/zod/src/v3/tests/language-server.source.ts +76 -0
  428. package/node_modules/zod/src/v3/tests/language-server.test.ts +207 -0
  429. package/node_modules/zod/src/v3/tests/literal.test.ts +36 -0
  430. package/node_modules/zod/src/v3/tests/map.test.ts +110 -0
  431. package/node_modules/zod/src/v3/tests/masking.test.ts +4 -0
  432. package/node_modules/zod/src/v3/tests/mocker.test.ts +19 -0
  433. package/node_modules/zod/src/v3/tests/nan.test.ts +24 -0
  434. package/node_modules/zod/src/v3/tests/nativeEnum.test.ts +87 -0
  435. package/node_modules/zod/src/v3/tests/nullable.test.ts +42 -0
  436. package/node_modules/zod/src/v3/tests/number.test.ts +176 -0
  437. package/node_modules/zod/src/v3/tests/object-augmentation.test.ts +29 -0
  438. package/node_modules/zod/src/v3/tests/object-in-es5-env.test.ts +29 -0
  439. package/node_modules/zod/src/v3/tests/object.test.ts +434 -0
  440. package/node_modules/zod/src/v3/tests/optional.test.ts +42 -0
  441. package/node_modules/zod/src/v3/tests/parseUtil.test.ts +23 -0
  442. package/node_modules/zod/src/v3/tests/parser.test.ts +41 -0
  443. package/node_modules/zod/src/v3/tests/partials.test.ts +243 -0
  444. package/node_modules/zod/src/v3/tests/pickomit.test.ts +111 -0
  445. package/node_modules/zod/src/v3/tests/pipeline.test.ts +29 -0
  446. package/node_modules/zod/src/v3/tests/preprocess.test.ts +186 -0
  447. package/node_modules/zod/src/v3/tests/primitive.test.ts +440 -0
  448. package/node_modules/zod/src/v3/tests/promise.test.ts +90 -0
  449. package/node_modules/zod/src/v3/tests/readonly.test.ts +194 -0
  450. package/node_modules/zod/src/v3/tests/record.test.ts +171 -0
  451. package/node_modules/zod/src/v3/tests/recursive.test.ts +197 -0
  452. package/node_modules/zod/src/v3/tests/refine.test.ts +313 -0
  453. package/node_modules/zod/src/v3/tests/safeparse.test.ts +27 -0
  454. package/node_modules/zod/src/v3/tests/set.test.ts +142 -0
  455. package/node_modules/zod/src/v3/tests/standard-schema.test.ts +83 -0
  456. package/node_modules/zod/src/v3/tests/string.test.ts +916 -0
  457. package/node_modules/zod/src/v3/tests/transformer.test.ts +233 -0
  458. package/node_modules/zod/src/v3/tests/tuple.test.ts +90 -0
  459. package/node_modules/zod/src/v3/tests/unions.test.ts +57 -0
  460. package/node_modules/zod/src/v3/tests/validations.test.ts +133 -0
  461. package/node_modules/zod/src/v3/tests/void.test.ts +15 -0
  462. package/node_modules/zod/src/v3/types.ts +5138 -0
  463. package/node_modules/zod/src/v4/classic/checks.ts +32 -0
  464. package/node_modules/zod/src/v4/classic/coerce.ts +27 -0
  465. package/node_modules/zod/src/v4/classic/compat.ts +70 -0
  466. package/node_modules/zod/src/v4/classic/errors.ts +82 -0
  467. package/node_modules/zod/src/v4/classic/external.ts +52 -0
  468. package/node_modules/zod/src/v4/classic/from-json-schema.ts +659 -0
  469. package/node_modules/zod/src/v4/classic/index.ts +5 -0
  470. package/node_modules/zod/src/v4/classic/iso.ts +90 -0
  471. package/node_modules/zod/src/v4/classic/parse.ts +82 -0
  472. package/node_modules/zod/src/v4/classic/schemas.ts +2672 -0
  473. package/node_modules/zod/src/v4/classic/tests/anyunknown.test.ts +26 -0
  474. package/node_modules/zod/src/v4/classic/tests/apply.test.ts +59 -0
  475. package/node_modules/zod/src/v4/classic/tests/array.test.ts +264 -0
  476. package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +216 -0
  477. package/node_modules/zod/src/v4/classic/tests/async-parsing.test.ts +381 -0
  478. package/node_modules/zod/src/v4/classic/tests/async-refinements.test.ts +68 -0
  479. package/node_modules/zod/src/v4/classic/tests/base.test.ts +7 -0
  480. package/node_modules/zod/src/v4/classic/tests/bigint.test.ts +54 -0
  481. package/node_modules/zod/src/v4/classic/tests/brand.test.ts +106 -0
  482. package/node_modules/zod/src/v4/classic/tests/catch.test.ts +326 -0
  483. package/node_modules/zod/src/v4/classic/tests/coalesce.test.ts +20 -0
  484. package/node_modules/zod/src/v4/classic/tests/codec-examples.test.ts +573 -0
  485. package/node_modules/zod/src/v4/classic/tests/codec.test.ts +703 -0
  486. package/node_modules/zod/src/v4/classic/tests/coerce.test.ts +160 -0
  487. package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +374 -0
  488. package/node_modules/zod/src/v4/classic/tests/custom.test.ts +40 -0
  489. package/node_modules/zod/src/v4/classic/tests/date.test.ts +62 -0
  490. package/node_modules/zod/src/v4/classic/tests/datetime.test.ts +302 -0
  491. package/node_modules/zod/src/v4/classic/tests/default.test.ts +409 -0
  492. package/node_modules/zod/src/v4/classic/tests/describe-meta-checks.test.ts +27 -0
  493. package/node_modules/zod/src/v4/classic/tests/description.test.ts +32 -0
  494. package/node_modules/zod/src/v4/classic/tests/detached-methods.test.ts +197 -0
  495. package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +694 -0
  496. package/node_modules/zod/src/v4/classic/tests/enum.test.ts +285 -0
  497. package/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +807 -0
  498. package/node_modules/zod/src/v4/classic/tests/error.test.ts +711 -0
  499. package/node_modules/zod/src/v4/classic/tests/file.test.ts +96 -0
  500. package/node_modules/zod/src/v4/classic/tests/firstparty.test.ts +179 -0
  501. package/node_modules/zod/src/v4/classic/tests/fix-json-issue.test.ts +26 -0
  502. package/node_modules/zod/src/v4/classic/tests/from-json-schema.test.ts +895 -0
  503. package/node_modules/zod/src/v4/classic/tests/function.test.ts +360 -0
  504. package/node_modules/zod/src/v4/classic/tests/generics.test.ts +72 -0
  505. package/node_modules/zod/src/v4/classic/tests/global-config.test.ts +39 -0
  506. package/node_modules/zod/src/v4/classic/tests/hash.test.ts +68 -0
  507. package/node_modules/zod/src/v4/classic/tests/index.test.ts +939 -0
  508. package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +60 -0
  509. package/node_modules/zod/src/v4/classic/tests/intersection.test.ts +198 -0
  510. package/node_modules/zod/src/v4/classic/tests/jitless-allows-eval.test.ts +46 -0
  511. package/node_modules/zod/src/v4/classic/tests/json.test.ts +109 -0
  512. package/node_modules/zod/src/v4/classic/tests/lazy.test.ts +227 -0
  513. package/node_modules/zod/src/v4/classic/tests/literal.test.ts +117 -0
  514. package/node_modules/zod/src/v4/classic/tests/locales_ka.test.ts +29 -0
  515. package/node_modules/zod/src/v4/classic/tests/locales_ro.test.ts +24 -0
  516. package/node_modules/zod/src/v4/classic/tests/map.test.ts +330 -0
  517. package/node_modules/zod/src/v4/classic/tests/nan.test.ts +21 -0
  518. package/node_modules/zod/src/v4/classic/tests/nested-refine.test.ts +168 -0
  519. package/node_modules/zod/src/v4/classic/tests/nonoptional.test.ts +101 -0
  520. package/node_modules/zod/src/v4/classic/tests/nullable.test.ts +22 -0
  521. package/node_modules/zod/src/v4/classic/tests/number.test.ts +325 -0
  522. package/node_modules/zod/src/v4/classic/tests/object.test.ts +717 -0
  523. package/node_modules/zod/src/v4/classic/tests/optional.test.ts +333 -0
  524. package/node_modules/zod/src/v4/classic/tests/partial.test.ts +450 -0
  525. package/node_modules/zod/src/v4/classic/tests/pickomit.test.ts +211 -0
  526. package/node_modules/zod/src/v4/classic/tests/pipe.test.ts +101 -0
  527. package/node_modules/zod/src/v4/classic/tests/prefault.test.ts +74 -0
  528. package/node_modules/zod/src/v4/classic/tests/preprocess-types.test.ts +26 -0
  529. package/node_modules/zod/src/v4/classic/tests/preprocess.test.ts +351 -0
  530. package/node_modules/zod/src/v4/classic/tests/primitive.test.ts +175 -0
  531. package/node_modules/zod/src/v4/classic/tests/promise.test.ts +81 -0
  532. package/node_modules/zod/src/v4/classic/tests/prototypes.test.ts +23 -0
  533. package/node_modules/zod/src/v4/classic/tests/readonly.test.ts +252 -0
  534. package/node_modules/zod/src/v4/classic/tests/record.test.ts +717 -0
  535. package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +631 -0
  536. package/node_modules/zod/src/v4/classic/tests/refine.test.ts +633 -0
  537. package/node_modules/zod/src/v4/classic/tests/registries.test.ts +243 -0
  538. package/node_modules/zod/src/v4/classic/tests/set.test.ts +181 -0
  539. package/node_modules/zod/src/v4/classic/tests/standard-schema.test.ts +134 -0
  540. package/node_modules/zod/src/v4/classic/tests/string-formats.test.ts +125 -0
  541. package/node_modules/zod/src/v4/classic/tests/string.test.ts +1224 -0
  542. package/node_modules/zod/src/v4/classic/tests/stringbool.test.ts +106 -0
  543. package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +771 -0
  544. package/node_modules/zod/src/v4/classic/tests/to-json-schema-methods.test.ts +438 -0
  545. package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +3125 -0
  546. package/node_modules/zod/src/v4/classic/tests/transform.test.ts +378 -0
  547. package/node_modules/zod/src/v4/classic/tests/tuple.test.ts +496 -0
  548. package/node_modules/zod/src/v4/classic/tests/union.test.ts +273 -0
  549. package/node_modules/zod/src/v4/classic/tests/url.test.ts +13 -0
  550. package/node_modules/zod/src/v4/classic/tests/validations.test.ts +283 -0
  551. package/node_modules/zod/src/v4/classic/tests/void.test.ts +12 -0
  552. package/node_modules/zod/src/v4/core/api.ts +1823 -0
  553. package/node_modules/zod/src/v4/core/checks.ts +1293 -0
  554. package/node_modules/zod/src/v4/core/config.ts +15 -0
  555. package/node_modules/zod/src/v4/core/core.ts +153 -0
  556. package/node_modules/zod/src/v4/core/doc.ts +44 -0
  557. package/node_modules/zod/src/v4/core/errors.ts +455 -0
  558. package/node_modules/zod/src/v4/core/index.ts +16 -0
  559. package/node_modules/zod/src/v4/core/json-schema-generator.ts +126 -0
  560. package/node_modules/zod/src/v4/core/json-schema-processors.ts +666 -0
  561. package/node_modules/zod/src/v4/core/json-schema.ts +147 -0
  562. package/node_modules/zod/src/v4/core/parse.ts +195 -0
  563. package/node_modules/zod/src/v4/core/regexes.ts +190 -0
  564. package/node_modules/zod/src/v4/core/registries.ts +105 -0
  565. package/node_modules/zod/src/v4/core/schemas.ts +4730 -0
  566. package/node_modules/zod/src/v4/core/standard-schema.ts +159 -0
  567. package/node_modules/zod/src/v4/core/tests/extend.test.ts +59 -0
  568. package/node_modules/zod/src/v4/core/tests/index.test.ts +46 -0
  569. package/node_modules/zod/src/v4/core/tests/locales/be.test.ts +124 -0
  570. package/node_modules/zod/src/v4/core/tests/locales/el.test.ts +215 -0
  571. package/node_modules/zod/src/v4/core/tests/locales/en.test.ts +22 -0
  572. package/node_modules/zod/src/v4/core/tests/locales/es.test.ts +181 -0
  573. package/node_modules/zod/src/v4/core/tests/locales/fr.test.ts +72 -0
  574. package/node_modules/zod/src/v4/core/tests/locales/he.test.ts +379 -0
  575. package/node_modules/zod/src/v4/core/tests/locales/hr.test.ts +163 -0
  576. package/node_modules/zod/src/v4/core/tests/locales/nl.test.ts +46 -0
  577. package/node_modules/zod/src/v4/core/tests/locales/ru.test.ts +128 -0
  578. package/node_modules/zod/src/v4/core/tests/locales/tr.test.ts +69 -0
  579. package/node_modules/zod/src/v4/core/tests/locales/uz.test.ts +105 -0
  580. package/node_modules/zod/src/v4/core/tests/record-constructor.test.ts +125 -0
  581. package/node_modules/zod/src/v4/core/tests/recursive-tuples.test.ts +45 -0
  582. package/node_modules/zod/src/v4/core/to-json-schema.ts +622 -0
  583. package/node_modules/zod/src/v4/core/util.ts +983 -0
  584. package/node_modules/zod/src/v4/core/versions.ts +5 -0
  585. package/node_modules/zod/src/v4/core/zsf.ts +323 -0
  586. package/node_modules/zod/src/v4/index.ts +4 -0
  587. package/node_modules/zod/src/v4/locales/ar.ts +115 -0
  588. package/node_modules/zod/src/v4/locales/az.ts +111 -0
  589. package/node_modules/zod/src/v4/locales/be.ts +176 -0
  590. package/node_modules/zod/src/v4/locales/bg.ts +128 -0
  591. package/node_modules/zod/src/v4/locales/ca.ts +116 -0
  592. package/node_modules/zod/src/v4/locales/cs.ts +118 -0
  593. package/node_modules/zod/src/v4/locales/da.ts +123 -0
  594. package/node_modules/zod/src/v4/locales/de.ts +116 -0
  595. package/node_modules/zod/src/v4/locales/el.ts +121 -0
  596. package/node_modules/zod/src/v4/locales/en.ts +123 -0
  597. package/node_modules/zod/src/v4/locales/eo.ts +118 -0
  598. package/node_modules/zod/src/v4/locales/es.ts +141 -0
  599. package/node_modules/zod/src/v4/locales/fa.ts +126 -0
  600. package/node_modules/zod/src/v4/locales/fi.ts +121 -0
  601. package/node_modules/zod/src/v4/locales/fr-CA.ts +116 -0
  602. package/node_modules/zod/src/v4/locales/fr.ts +132 -0
  603. package/node_modules/zod/src/v4/locales/he.ts +246 -0
  604. package/node_modules/zod/src/v4/locales/hr.ts +131 -0
  605. package/node_modules/zod/src/v4/locales/hu.ts +117 -0
  606. package/node_modules/zod/src/v4/locales/hy.ts +164 -0
  607. package/node_modules/zod/src/v4/locales/id.ts +115 -0
  608. package/node_modules/zod/src/v4/locales/index.ts +52 -0
  609. package/node_modules/zod/src/v4/locales/is.ts +119 -0
  610. package/node_modules/zod/src/v4/locales/it.ts +116 -0
  611. package/node_modules/zod/src/v4/locales/ja.ts +114 -0
  612. package/node_modules/zod/src/v4/locales/ka.ts +123 -0
  613. package/node_modules/zod/src/v4/locales/kh.ts +7 -0
  614. package/node_modules/zod/src/v4/locales/km.ts +119 -0
  615. package/node_modules/zod/src/v4/locales/ko.ts +121 -0
  616. package/node_modules/zod/src/v4/locales/lt.ts +239 -0
  617. package/node_modules/zod/src/v4/locales/mk.ts +118 -0
  618. package/node_modules/zod/src/v4/locales/ms.ts +115 -0
  619. package/node_modules/zod/src/v4/locales/nl.ts +121 -0
  620. package/node_modules/zod/src/v4/locales/no.ts +116 -0
  621. package/node_modules/zod/src/v4/locales/ota.ts +117 -0
  622. package/node_modules/zod/src/v4/locales/pl.ts +118 -0
  623. package/node_modules/zod/src/v4/locales/ps.ts +126 -0
  624. package/node_modules/zod/src/v4/locales/pt.ts +116 -0
  625. package/node_modules/zod/src/v4/locales/ro.ts +129 -0
  626. package/node_modules/zod/src/v4/locales/ru.ts +176 -0
  627. package/node_modules/zod/src/v4/locales/sl.ts +118 -0
  628. package/node_modules/zod/src/v4/locales/sv.ts +119 -0
  629. package/node_modules/zod/src/v4/locales/ta.ts +118 -0
  630. package/node_modules/zod/src/v4/locales/th.ts +119 -0
  631. package/node_modules/zod/src/v4/locales/tr.ts +111 -0
  632. package/node_modules/zod/src/v4/locales/ua.ts +7 -0
  633. package/node_modules/zod/src/v4/locales/uk.ts +117 -0
  634. package/node_modules/zod/src/v4/locales/ur.ts +119 -0
  635. package/node_modules/zod/src/v4/locales/uz.ts +117 -0
  636. package/node_modules/zod/src/v4/locales/vi.ts +117 -0
  637. package/node_modules/zod/src/v4/locales/yo.ts +124 -0
  638. package/node_modules/zod/src/v4/locales/zh-CN.ts +116 -0
  639. package/node_modules/zod/src/v4/locales/zh-TW.ts +115 -0
  640. package/node_modules/zod/src/v4/mini/checks.ts +32 -0
  641. package/node_modules/zod/src/v4/mini/coerce.ts +27 -0
  642. package/node_modules/zod/src/v4/mini/external.ts +41 -0
  643. package/node_modules/zod/src/v4/mini/index.ts +3 -0
  644. package/node_modules/zod/src/v4/mini/iso.ts +66 -0
  645. package/node_modules/zod/src/v4/mini/parse.ts +14 -0
  646. package/node_modules/zod/src/v4/mini/schemas.ts +1947 -0
  647. package/node_modules/zod/src/v4/mini/tests/apply.test.ts +24 -0
  648. package/node_modules/zod/src/v4/mini/tests/assignability.test.ts +129 -0
  649. package/node_modules/zod/src/v4/mini/tests/brand.test.ts +94 -0
  650. package/node_modules/zod/src/v4/mini/tests/checks.test.ts +144 -0
  651. package/node_modules/zod/src/v4/mini/tests/codec.test.ts +548 -0
  652. package/node_modules/zod/src/v4/mini/tests/computed.test.ts +36 -0
  653. package/node_modules/zod/src/v4/mini/tests/error.test.ts +22 -0
  654. package/node_modules/zod/src/v4/mini/tests/functions.test.ts +5 -0
  655. package/node_modules/zod/src/v4/mini/tests/index.test.ts +993 -0
  656. package/node_modules/zod/src/v4/mini/tests/number.test.ts +95 -0
  657. package/node_modules/zod/src/v4/mini/tests/object.test.ts +227 -0
  658. package/node_modules/zod/src/v4/mini/tests/prototypes.test.ts +43 -0
  659. package/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +325 -0
  660. package/node_modules/zod/src/v4/mini/tests/standard-schema.test.ts +50 -0
  661. package/node_modules/zod/src/v4/mini/tests/string.test.ts +352 -0
  662. package/node_modules/zod/src/v4-mini/index.ts +3 -0
  663. package/node_modules/zod/v3/ZodError.cjs +138 -0
  664. package/node_modules/zod/v3/ZodError.d.cts +164 -0
  665. package/node_modules/zod/v3/ZodError.d.ts +164 -0
  666. package/node_modules/zod/v3/ZodError.js +133 -0
  667. package/node_modules/zod/v3/errors.cjs +17 -0
  668. package/node_modules/zod/v3/errors.d.cts +5 -0
  669. package/node_modules/zod/v3/errors.d.ts +5 -0
  670. package/node_modules/zod/v3/errors.js +9 -0
  671. package/node_modules/zod/v3/external.cjs +22 -0
  672. package/node_modules/zod/v3/external.d.cts +6 -0
  673. package/node_modules/zod/v3/external.d.ts +6 -0
  674. package/node_modules/zod/v3/external.js +6 -0
  675. package/node_modules/zod/v3/helpers/enumUtil.cjs +2 -0
  676. package/node_modules/zod/v3/helpers/enumUtil.d.cts +8 -0
  677. package/node_modules/zod/v3/helpers/enumUtil.d.ts +8 -0
  678. package/node_modules/zod/v3/helpers/enumUtil.js +1 -0
  679. package/node_modules/zod/v3/helpers/errorUtil.cjs +9 -0
  680. package/node_modules/zod/v3/helpers/errorUtil.d.cts +9 -0
  681. package/node_modules/zod/v3/helpers/errorUtil.d.ts +9 -0
  682. package/node_modules/zod/v3/helpers/errorUtil.js +6 -0
  683. package/node_modules/zod/v3/helpers/parseUtil.cjs +124 -0
  684. package/node_modules/zod/v3/helpers/parseUtil.d.cts +78 -0
  685. package/node_modules/zod/v3/helpers/parseUtil.d.ts +78 -0
  686. package/node_modules/zod/v3/helpers/parseUtil.js +109 -0
  687. package/node_modules/zod/v3/helpers/partialUtil.cjs +2 -0
  688. package/node_modules/zod/v3/helpers/partialUtil.d.cts +8 -0
  689. package/node_modules/zod/v3/helpers/partialUtil.d.ts +8 -0
  690. package/node_modules/zod/v3/helpers/partialUtil.js +1 -0
  691. package/node_modules/zod/v3/helpers/typeAliases.cjs +2 -0
  692. package/node_modules/zod/v3/helpers/typeAliases.d.cts +2 -0
  693. package/node_modules/zod/v3/helpers/typeAliases.d.ts +2 -0
  694. package/node_modules/zod/v3/helpers/typeAliases.js +1 -0
  695. package/node_modules/zod/v3/helpers/util.cjs +137 -0
  696. package/node_modules/zod/v3/helpers/util.d.cts +85 -0
  697. package/node_modules/zod/v3/helpers/util.d.ts +85 -0
  698. package/node_modules/zod/v3/helpers/util.js +133 -0
  699. package/node_modules/zod/v3/index.cjs +33 -0
  700. package/node_modules/zod/v3/index.d.cts +4 -0
  701. package/node_modules/zod/v3/index.d.ts +4 -0
  702. package/node_modules/zod/v3/index.js +4 -0
  703. package/node_modules/zod/v3/locales/en.cjs +112 -0
  704. package/node_modules/zod/v3/locales/en.d.cts +3 -0
  705. package/node_modules/zod/v3/locales/en.d.ts +3 -0
  706. package/node_modules/zod/v3/locales/en.js +109 -0
  707. package/node_modules/zod/v3/package.json +7 -0
  708. package/node_modules/zod/v3/standard-schema.cjs +2 -0
  709. package/node_modules/zod/v3/standard-schema.d.cts +102 -0
  710. package/node_modules/zod/v3/standard-schema.d.ts +102 -0
  711. package/node_modules/zod/v3/standard-schema.js +1 -0
  712. package/node_modules/zod/v3/types.cjs +3777 -0
  713. package/node_modules/zod/v3/types.d.cts +1034 -0
  714. package/node_modules/zod/v3/types.d.ts +1034 -0
  715. package/node_modules/zod/v3/types.js +3695 -0
  716. package/node_modules/zod/v4/classic/checks.cjs +33 -0
  717. package/node_modules/zod/v4/classic/checks.d.cts +1 -0
  718. package/node_modules/zod/v4/classic/checks.d.ts +1 -0
  719. package/node_modules/zod/v4/classic/checks.js +1 -0
  720. package/node_modules/zod/v4/classic/coerce.cjs +47 -0
  721. package/node_modules/zod/v4/classic/coerce.d.cts +17 -0
  722. package/node_modules/zod/v4/classic/coerce.d.ts +17 -0
  723. package/node_modules/zod/v4/classic/coerce.js +17 -0
  724. package/node_modules/zod/v4/classic/compat.cjs +61 -0
  725. package/node_modules/zod/v4/classic/compat.d.cts +50 -0
  726. package/node_modules/zod/v4/classic/compat.d.ts +50 -0
  727. package/node_modules/zod/v4/classic/compat.js +31 -0
  728. package/node_modules/zod/v4/classic/errors.cjs +74 -0
  729. package/node_modules/zod/v4/classic/errors.d.cts +30 -0
  730. package/node_modules/zod/v4/classic/errors.d.ts +30 -0
  731. package/node_modules/zod/v4/classic/errors.js +48 -0
  732. package/node_modules/zod/v4/classic/external.cjs +73 -0
  733. package/node_modules/zod/v4/classic/external.d.cts +16 -0
  734. package/node_modules/zod/v4/classic/external.d.ts +16 -0
  735. package/node_modules/zod/v4/classic/external.js +20 -0
  736. package/node_modules/zod/v4/classic/from-json-schema.cjs +625 -0
  737. package/node_modules/zod/v4/classic/from-json-schema.d.cts +12 -0
  738. package/node_modules/zod/v4/classic/from-json-schema.d.ts +12 -0
  739. package/node_modules/zod/v4/classic/from-json-schema.js +599 -0
  740. package/node_modules/zod/v4/classic/index.cjs +33 -0
  741. package/node_modules/zod/v4/classic/index.d.cts +4 -0
  742. package/node_modules/zod/v4/classic/index.d.ts +4 -0
  743. package/node_modules/zod/v4/classic/index.js +4 -0
  744. package/node_modules/zod/v4/classic/iso.cjs +60 -0
  745. package/node_modules/zod/v4/classic/iso.d.cts +22 -0
  746. package/node_modules/zod/v4/classic/iso.d.ts +22 -0
  747. package/node_modules/zod/v4/classic/iso.js +30 -0
  748. package/node_modules/zod/v4/classic/package.json +7 -0
  749. package/node_modules/zod/v4/classic/parse.cjs +41 -0
  750. package/node_modules/zod/v4/classic/parse.d.cts +31 -0
  751. package/node_modules/zod/v4/classic/parse.d.ts +31 -0
  752. package/node_modules/zod/v4/classic/parse.js +15 -0
  753. package/node_modules/zod/v4/classic/schemas.cjs +1511 -0
  754. package/node_modules/zod/v4/classic/schemas.d.cts +767 -0
  755. package/node_modules/zod/v4/classic/schemas.d.ts +767 -0
  756. package/node_modules/zod/v4/classic/schemas.js +1395 -0
  757. package/node_modules/zod/v4/core/api.cjs +1227 -0
  758. package/node_modules/zod/v4/core/api.d.cts +325 -0
  759. package/node_modules/zod/v4/core/api.d.ts +325 -0
  760. package/node_modules/zod/v4/core/api.js +1087 -0
  761. package/node_modules/zod/v4/core/checks.cjs +601 -0
  762. package/node_modules/zod/v4/core/checks.d.cts +278 -0
  763. package/node_modules/zod/v4/core/checks.d.ts +278 -0
  764. package/node_modules/zod/v4/core/checks.js +575 -0
  765. package/node_modules/zod/v4/core/core.cjs +85 -0
  766. package/node_modules/zod/v4/core/core.d.cts +70 -0
  767. package/node_modules/zod/v4/core/core.d.ts +70 -0
  768. package/node_modules/zod/v4/core/core.js +78 -0
  769. package/node_modules/zod/v4/core/doc.cjs +39 -0
  770. package/node_modules/zod/v4/core/doc.d.cts +14 -0
  771. package/node_modules/zod/v4/core/doc.d.ts +14 -0
  772. package/node_modules/zod/v4/core/doc.js +35 -0
  773. package/node_modules/zod/v4/core/errors.cjs +216 -0
  774. package/node_modules/zod/v4/core/errors.d.cts +221 -0
  775. package/node_modules/zod/v4/core/errors.d.ts +221 -0
  776. package/node_modules/zod/v4/core/errors.js +185 -0
  777. package/node_modules/zod/v4/core/index.cjs +47 -0
  778. package/node_modules/zod/v4/core/index.d.cts +16 -0
  779. package/node_modules/zod/v4/core/index.d.ts +16 -0
  780. package/node_modules/zod/v4/core/index.js +16 -0
  781. package/node_modules/zod/v4/core/json-schema-generator.cjs +99 -0
  782. package/node_modules/zod/v4/core/json-schema-generator.d.cts +65 -0
  783. package/node_modules/zod/v4/core/json-schema-generator.d.ts +65 -0
  784. package/node_modules/zod/v4/core/json-schema-generator.js +95 -0
  785. package/node_modules/zod/v4/core/json-schema-processors.cjs +644 -0
  786. package/node_modules/zod/v4/core/json-schema-processors.d.cts +49 -0
  787. package/node_modules/zod/v4/core/json-schema-processors.d.ts +49 -0
  788. package/node_modules/zod/v4/core/json-schema-processors.js +601 -0
  789. package/node_modules/zod/v4/core/json-schema.cjs +2 -0
  790. package/node_modules/zod/v4/core/json-schema.d.cts +88 -0
  791. package/node_modules/zod/v4/core/json-schema.d.ts +88 -0
  792. package/node_modules/zod/v4/core/json-schema.js +1 -0
  793. package/node_modules/zod/v4/core/package.json +7 -0
  794. package/node_modules/zod/v4/core/parse.cjs +131 -0
  795. package/node_modules/zod/v4/core/parse.d.cts +49 -0
  796. package/node_modules/zod/v4/core/parse.d.ts +49 -0
  797. package/node_modules/zod/v4/core/parse.js +93 -0
  798. package/node_modules/zod/v4/core/regexes.cjs +172 -0
  799. package/node_modules/zod/v4/core/regexes.d.cts +85 -0
  800. package/node_modules/zod/v4/core/regexes.d.ts +85 -0
  801. package/node_modules/zod/v4/core/regexes.js +139 -0
  802. package/node_modules/zod/v4/core/registries.cjs +56 -0
  803. package/node_modules/zod/v4/core/registries.d.cts +35 -0
  804. package/node_modules/zod/v4/core/registries.d.ts +35 -0
  805. package/node_modules/zod/v4/core/registries.js +51 -0
  806. package/node_modules/zod/v4/core/schemas.cjs +2270 -0
  807. package/node_modules/zod/v4/core/schemas.d.cts +1184 -0
  808. package/node_modules/zod/v4/core/schemas.d.ts +1184 -0
  809. package/node_modules/zod/v4/core/schemas.js +2239 -0
  810. package/node_modules/zod/v4/core/standard-schema.cjs +2 -0
  811. package/node_modules/zod/v4/core/standard-schema.d.cts +126 -0
  812. package/node_modules/zod/v4/core/standard-schema.d.ts +126 -0
  813. package/node_modules/zod/v4/core/standard-schema.js +1 -0
  814. package/node_modules/zod/v4/core/to-json-schema.cjs +457 -0
  815. package/node_modules/zod/v4/core/to-json-schema.d.cts +114 -0
  816. package/node_modules/zod/v4/core/to-json-schema.d.ts +114 -0
  817. package/node_modules/zod/v4/core/to-json-schema.js +448 -0
  818. package/node_modules/zod/v4/core/util.cjs +734 -0
  819. package/node_modules/zod/v4/core/util.d.cts +200 -0
  820. package/node_modules/zod/v4/core/util.d.ts +200 -0
  821. package/node_modules/zod/v4/core/util.js +674 -0
  822. package/node_modules/zod/v4/core/versions.cjs +8 -0
  823. package/node_modules/zod/v4/core/versions.d.cts +5 -0
  824. package/node_modules/zod/v4/core/versions.d.ts +5 -0
  825. package/node_modules/zod/v4/core/versions.js +5 -0
  826. package/node_modules/zod/v4/index.cjs +22 -0
  827. package/node_modules/zod/v4/index.d.cts +3 -0
  828. package/node_modules/zod/v4/index.d.ts +3 -0
  829. package/node_modules/zod/v4/index.js +3 -0
  830. package/node_modules/zod/v4/locales/ar.cjs +133 -0
  831. package/node_modules/zod/v4/locales/ar.d.cts +5 -0
  832. package/node_modules/zod/v4/locales/ar.d.ts +4 -0
  833. package/node_modules/zod/v4/locales/ar.js +106 -0
  834. package/node_modules/zod/v4/locales/az.cjs +132 -0
  835. package/node_modules/zod/v4/locales/az.d.cts +5 -0
  836. package/node_modules/zod/v4/locales/az.d.ts +4 -0
  837. package/node_modules/zod/v4/locales/az.js +105 -0
  838. package/node_modules/zod/v4/locales/be.cjs +183 -0
  839. package/node_modules/zod/v4/locales/be.d.cts +5 -0
  840. package/node_modules/zod/v4/locales/be.d.ts +4 -0
  841. package/node_modules/zod/v4/locales/be.js +156 -0
  842. package/node_modules/zod/v4/locales/bg.cjs +147 -0
  843. package/node_modules/zod/v4/locales/bg.d.cts +5 -0
  844. package/node_modules/zod/v4/locales/bg.d.ts +4 -0
  845. package/node_modules/zod/v4/locales/bg.js +120 -0
  846. package/node_modules/zod/v4/locales/ca.cjs +134 -0
  847. package/node_modules/zod/v4/locales/ca.d.cts +5 -0
  848. package/node_modules/zod/v4/locales/ca.d.ts +4 -0
  849. package/node_modules/zod/v4/locales/ca.js +107 -0
  850. package/node_modules/zod/v4/locales/cs.cjs +138 -0
  851. package/node_modules/zod/v4/locales/cs.d.cts +5 -0
  852. package/node_modules/zod/v4/locales/cs.d.ts +4 -0
  853. package/node_modules/zod/v4/locales/cs.js +111 -0
  854. package/node_modules/zod/v4/locales/da.cjs +142 -0
  855. package/node_modules/zod/v4/locales/da.d.cts +5 -0
  856. package/node_modules/zod/v4/locales/da.d.ts +4 -0
  857. package/node_modules/zod/v4/locales/da.js +115 -0
  858. package/node_modules/zod/v4/locales/de.cjs +135 -0
  859. package/node_modules/zod/v4/locales/de.d.cts +5 -0
  860. package/node_modules/zod/v4/locales/de.d.ts +4 -0
  861. package/node_modules/zod/v4/locales/de.js +108 -0
  862. package/node_modules/zod/v4/locales/el.cjs +136 -0
  863. package/node_modules/zod/v4/locales/el.d.cts +5 -0
  864. package/node_modules/zod/v4/locales/el.d.ts +4 -0
  865. package/node_modules/zod/v4/locales/el.js +109 -0
  866. package/node_modules/zod/v4/locales/en.cjs +140 -0
  867. package/node_modules/zod/v4/locales/en.d.cts +5 -0
  868. package/node_modules/zod/v4/locales/en.d.ts +4 -0
  869. package/node_modules/zod/v4/locales/en.js +113 -0
  870. package/node_modules/zod/v4/locales/eo.cjs +136 -0
  871. package/node_modules/zod/v4/locales/eo.d.cts +5 -0
  872. package/node_modules/zod/v4/locales/eo.d.ts +4 -0
  873. package/node_modules/zod/v4/locales/eo.js +109 -0
  874. package/node_modules/zod/v4/locales/es.cjs +159 -0
  875. package/node_modules/zod/v4/locales/es.d.cts +5 -0
  876. package/node_modules/zod/v4/locales/es.d.ts +4 -0
  877. package/node_modules/zod/v4/locales/es.js +132 -0
  878. package/node_modules/zod/v4/locales/fa.cjs +141 -0
  879. package/node_modules/zod/v4/locales/fa.d.cts +5 -0
  880. package/node_modules/zod/v4/locales/fa.d.ts +4 -0
  881. package/node_modules/zod/v4/locales/fa.js +114 -0
  882. package/node_modules/zod/v4/locales/fi.cjs +139 -0
  883. package/node_modules/zod/v4/locales/fi.d.cts +5 -0
  884. package/node_modules/zod/v4/locales/fi.d.ts +4 -0
  885. package/node_modules/zod/v4/locales/fi.js +112 -0
  886. package/node_modules/zod/v4/locales/fr-CA.cjs +134 -0
  887. package/node_modules/zod/v4/locales/fr-CA.d.cts +5 -0
  888. package/node_modules/zod/v4/locales/fr-CA.d.ts +4 -0
  889. package/node_modules/zod/v4/locales/fr-CA.js +107 -0
  890. package/node_modules/zod/v4/locales/fr.cjs +152 -0
  891. package/node_modules/zod/v4/locales/fr.d.cts +5 -0
  892. package/node_modules/zod/v4/locales/fr.d.ts +4 -0
  893. package/node_modules/zod/v4/locales/fr.js +125 -0
  894. package/node_modules/zod/v4/locales/he.cjs +241 -0
  895. package/node_modules/zod/v4/locales/he.d.cts +5 -0
  896. package/node_modules/zod/v4/locales/he.d.ts +4 -0
  897. package/node_modules/zod/v4/locales/he.js +214 -0
  898. package/node_modules/zod/v4/locales/hr.cjs +149 -0
  899. package/node_modules/zod/v4/locales/hr.d.cts +5 -0
  900. package/node_modules/zod/v4/locales/hr.d.ts +4 -0
  901. package/node_modules/zod/v4/locales/hr.js +122 -0
  902. package/node_modules/zod/v4/locales/hu.cjs +135 -0
  903. package/node_modules/zod/v4/locales/hu.d.cts +5 -0
  904. package/node_modules/zod/v4/locales/hu.d.ts +4 -0
  905. package/node_modules/zod/v4/locales/hu.js +108 -0
  906. package/node_modules/zod/v4/locales/hy.cjs +174 -0
  907. package/node_modules/zod/v4/locales/hy.d.cts +5 -0
  908. package/node_modules/zod/v4/locales/hy.d.ts +4 -0
  909. package/node_modules/zod/v4/locales/hy.js +147 -0
  910. package/node_modules/zod/v4/locales/id.cjs +133 -0
  911. package/node_modules/zod/v4/locales/id.d.cts +5 -0
  912. package/node_modules/zod/v4/locales/id.d.ts +4 -0
  913. package/node_modules/zod/v4/locales/id.js +106 -0
  914. package/node_modules/zod/v4/locales/index.cjs +111 -0
  915. package/node_modules/zod/v4/locales/index.d.cts +52 -0
  916. package/node_modules/zod/v4/locales/index.d.ts +52 -0
  917. package/node_modules/zod/v4/locales/index.js +52 -0
  918. package/node_modules/zod/v4/locales/is.cjs +136 -0
  919. package/node_modules/zod/v4/locales/is.d.cts +5 -0
  920. package/node_modules/zod/v4/locales/is.d.ts +4 -0
  921. package/node_modules/zod/v4/locales/is.js +109 -0
  922. package/node_modules/zod/v4/locales/it.cjs +135 -0
  923. package/node_modules/zod/v4/locales/it.d.cts +5 -0
  924. package/node_modules/zod/v4/locales/it.d.ts +4 -0
  925. package/node_modules/zod/v4/locales/it.js +108 -0
  926. package/node_modules/zod/v4/locales/ja.cjs +134 -0
  927. package/node_modules/zod/v4/locales/ja.d.cts +5 -0
  928. package/node_modules/zod/v4/locales/ja.d.ts +4 -0
  929. package/node_modules/zod/v4/locales/ja.js +107 -0
  930. package/node_modules/zod/v4/locales/ka.cjs +139 -0
  931. package/node_modules/zod/v4/locales/ka.d.cts +5 -0
  932. package/node_modules/zod/v4/locales/ka.d.ts +4 -0
  933. package/node_modules/zod/v4/locales/ka.js +112 -0
  934. package/node_modules/zod/v4/locales/kh.cjs +12 -0
  935. package/node_modules/zod/v4/locales/kh.d.cts +5 -0
  936. package/node_modules/zod/v4/locales/kh.d.ts +5 -0
  937. package/node_modules/zod/v4/locales/kh.js +5 -0
  938. package/node_modules/zod/v4/locales/km.cjs +137 -0
  939. package/node_modules/zod/v4/locales/km.d.cts +5 -0
  940. package/node_modules/zod/v4/locales/km.d.ts +4 -0
  941. package/node_modules/zod/v4/locales/km.js +110 -0
  942. package/node_modules/zod/v4/locales/ko.cjs +138 -0
  943. package/node_modules/zod/v4/locales/ko.d.cts +5 -0
  944. package/node_modules/zod/v4/locales/ko.d.ts +4 -0
  945. package/node_modules/zod/v4/locales/ko.js +111 -0
  946. package/node_modules/zod/v4/locales/lt.cjs +230 -0
  947. package/node_modules/zod/v4/locales/lt.d.cts +5 -0
  948. package/node_modules/zod/v4/locales/lt.d.ts +4 -0
  949. package/node_modules/zod/v4/locales/lt.js +203 -0
  950. package/node_modules/zod/v4/locales/mk.cjs +136 -0
  951. package/node_modules/zod/v4/locales/mk.d.cts +5 -0
  952. package/node_modules/zod/v4/locales/mk.d.ts +4 -0
  953. package/node_modules/zod/v4/locales/mk.js +109 -0
  954. package/node_modules/zod/v4/locales/ms.cjs +134 -0
  955. package/node_modules/zod/v4/locales/ms.d.cts +5 -0
  956. package/node_modules/zod/v4/locales/ms.d.ts +4 -0
  957. package/node_modules/zod/v4/locales/ms.js +107 -0
  958. package/node_modules/zod/v4/locales/nl.cjs +137 -0
  959. package/node_modules/zod/v4/locales/nl.d.cts +5 -0
  960. package/node_modules/zod/v4/locales/nl.d.ts +4 -0
  961. package/node_modules/zod/v4/locales/nl.js +110 -0
  962. package/node_modules/zod/v4/locales/no.cjs +135 -0
  963. package/node_modules/zod/v4/locales/no.d.cts +5 -0
  964. package/node_modules/zod/v4/locales/no.d.ts +4 -0
  965. package/node_modules/zod/v4/locales/no.js +108 -0
  966. package/node_modules/zod/v4/locales/ota.cjs +136 -0
  967. package/node_modules/zod/v4/locales/ota.d.cts +5 -0
  968. package/node_modules/zod/v4/locales/ota.d.ts +4 -0
  969. package/node_modules/zod/v4/locales/ota.js +109 -0
  970. package/node_modules/zod/v4/locales/package.json +7 -0
  971. package/node_modules/zod/v4/locales/pl.cjs +136 -0
  972. package/node_modules/zod/v4/locales/pl.d.cts +5 -0
  973. package/node_modules/zod/v4/locales/pl.d.ts +4 -0
  974. package/node_modules/zod/v4/locales/pl.js +109 -0
  975. package/node_modules/zod/v4/locales/ps.cjs +141 -0
  976. package/node_modules/zod/v4/locales/ps.d.cts +5 -0
  977. package/node_modules/zod/v4/locales/ps.d.ts +4 -0
  978. package/node_modules/zod/v4/locales/ps.js +114 -0
  979. package/node_modules/zod/v4/locales/pt.cjs +135 -0
  980. package/node_modules/zod/v4/locales/pt.d.cts +5 -0
  981. package/node_modules/zod/v4/locales/pt.d.ts +4 -0
  982. package/node_modules/zod/v4/locales/pt.js +108 -0
  983. package/node_modules/zod/v4/locales/ro.cjs +146 -0
  984. package/node_modules/zod/v4/locales/ro.d.cts +5 -0
  985. package/node_modules/zod/v4/locales/ro.d.ts +4 -0
  986. package/node_modules/zod/v4/locales/ro.js +119 -0
  987. package/node_modules/zod/v4/locales/ru.cjs +183 -0
  988. package/node_modules/zod/v4/locales/ru.d.cts +5 -0
  989. package/node_modules/zod/v4/locales/ru.d.ts +4 -0
  990. package/node_modules/zod/v4/locales/ru.js +156 -0
  991. package/node_modules/zod/v4/locales/sl.cjs +136 -0
  992. package/node_modules/zod/v4/locales/sl.d.cts +5 -0
  993. package/node_modules/zod/v4/locales/sl.d.ts +4 -0
  994. package/node_modules/zod/v4/locales/sl.js +109 -0
  995. package/node_modules/zod/v4/locales/sv.cjs +137 -0
  996. package/node_modules/zod/v4/locales/sv.d.cts +5 -0
  997. package/node_modules/zod/v4/locales/sv.d.ts +4 -0
  998. package/node_modules/zod/v4/locales/sv.js +110 -0
  999. package/node_modules/zod/v4/locales/ta.cjs +137 -0
  1000. package/node_modules/zod/v4/locales/ta.d.cts +5 -0
  1001. package/node_modules/zod/v4/locales/ta.d.ts +4 -0
  1002. package/node_modules/zod/v4/locales/ta.js +110 -0
  1003. package/node_modules/zod/v4/locales/th.cjs +137 -0
  1004. package/node_modules/zod/v4/locales/th.d.cts +5 -0
  1005. package/node_modules/zod/v4/locales/th.d.ts +4 -0
  1006. package/node_modules/zod/v4/locales/th.js +110 -0
  1007. package/node_modules/zod/v4/locales/tr.cjs +132 -0
  1008. package/node_modules/zod/v4/locales/tr.d.cts +5 -0
  1009. package/node_modules/zod/v4/locales/tr.d.ts +4 -0
  1010. package/node_modules/zod/v4/locales/tr.js +105 -0
  1011. package/node_modules/zod/v4/locales/ua.cjs +12 -0
  1012. package/node_modules/zod/v4/locales/ua.d.cts +5 -0
  1013. package/node_modules/zod/v4/locales/ua.d.ts +5 -0
  1014. package/node_modules/zod/v4/locales/ua.js +5 -0
  1015. package/node_modules/zod/v4/locales/uk.cjs +135 -0
  1016. package/node_modules/zod/v4/locales/uk.d.cts +5 -0
  1017. package/node_modules/zod/v4/locales/uk.d.ts +4 -0
  1018. package/node_modules/zod/v4/locales/uk.js +108 -0
  1019. package/node_modules/zod/v4/locales/ur.cjs +137 -0
  1020. package/node_modules/zod/v4/locales/ur.d.cts +5 -0
  1021. package/node_modules/zod/v4/locales/ur.d.ts +4 -0
  1022. package/node_modules/zod/v4/locales/ur.js +110 -0
  1023. package/node_modules/zod/v4/locales/uz.cjs +137 -0
  1024. package/node_modules/zod/v4/locales/uz.d.cts +5 -0
  1025. package/node_modules/zod/v4/locales/uz.d.ts +4 -0
  1026. package/node_modules/zod/v4/locales/uz.js +110 -0
  1027. package/node_modules/zod/v4/locales/vi.cjs +135 -0
  1028. package/node_modules/zod/v4/locales/vi.d.cts +5 -0
  1029. package/node_modules/zod/v4/locales/vi.d.ts +4 -0
  1030. package/node_modules/zod/v4/locales/vi.js +108 -0
  1031. package/node_modules/zod/v4/locales/yo.cjs +134 -0
  1032. package/node_modules/zod/v4/locales/yo.d.cts +5 -0
  1033. package/node_modules/zod/v4/locales/yo.d.ts +4 -0
  1034. package/node_modules/zod/v4/locales/yo.js +107 -0
  1035. package/node_modules/zod/v4/locales/zh-CN.cjs +136 -0
  1036. package/node_modules/zod/v4/locales/zh-CN.d.cts +5 -0
  1037. package/node_modules/zod/v4/locales/zh-CN.d.ts +4 -0
  1038. package/node_modules/zod/v4/locales/zh-CN.js +109 -0
  1039. package/node_modules/zod/v4/locales/zh-TW.cjs +134 -0
  1040. package/node_modules/zod/v4/locales/zh-TW.d.cts +5 -0
  1041. package/node_modules/zod/v4/locales/zh-TW.d.ts +4 -0
  1042. package/node_modules/zod/v4/locales/zh-TW.js +107 -0
  1043. package/node_modules/zod/v4/mini/checks.cjs +34 -0
  1044. package/node_modules/zod/v4/mini/checks.d.cts +1 -0
  1045. package/node_modules/zod/v4/mini/checks.d.ts +1 -0
  1046. package/node_modules/zod/v4/mini/checks.js +1 -0
  1047. package/node_modules/zod/v4/mini/coerce.cjs +52 -0
  1048. package/node_modules/zod/v4/mini/coerce.d.cts +7 -0
  1049. package/node_modules/zod/v4/mini/coerce.d.ts +7 -0
  1050. package/node_modules/zod/v4/mini/coerce.js +22 -0
  1051. package/node_modules/zod/v4/mini/external.cjs +63 -0
  1052. package/node_modules/zod/v4/mini/external.d.cts +13 -0
  1053. package/node_modules/zod/v4/mini/external.d.ts +13 -0
  1054. package/node_modules/zod/v4/mini/external.js +14 -0
  1055. package/node_modules/zod/v4/mini/index.cjs +32 -0
  1056. package/node_modules/zod/v4/mini/index.d.cts +3 -0
  1057. package/node_modules/zod/v4/mini/index.d.ts +3 -0
  1058. package/node_modules/zod/v4/mini/index.js +3 -0
  1059. package/node_modules/zod/v4/mini/iso.cjs +64 -0
  1060. package/node_modules/zod/v4/mini/iso.d.cts +22 -0
  1061. package/node_modules/zod/v4/mini/iso.d.ts +22 -0
  1062. package/node_modules/zod/v4/mini/iso.js +34 -0
  1063. package/node_modules/zod/v4/mini/package.json +7 -0
  1064. package/node_modules/zod/v4/mini/parse.cjs +16 -0
  1065. package/node_modules/zod/v4/mini/parse.d.cts +1 -0
  1066. package/node_modules/zod/v4/mini/parse.d.ts +1 -0
  1067. package/node_modules/zod/v4/mini/parse.js +1 -0
  1068. package/node_modules/zod/v4/mini/schemas.cjs +1083 -0
  1069. package/node_modules/zod/v4/mini/schemas.d.cts +445 -0
  1070. package/node_modules/zod/v4/mini/schemas.d.ts +445 -0
  1071. package/node_modules/zod/v4/mini/schemas.js +961 -0
  1072. package/node_modules/zod/v4/package.json +7 -0
  1073. package/node_modules/zod/v4-mini/index.cjs +32 -0
  1074. package/node_modules/zod/v4-mini/index.d.cts +3 -0
  1075. package/node_modules/zod/v4-mini/index.d.ts +3 -0
  1076. package/node_modules/zod/v4-mini/index.js +3 -0
  1077. package/node_modules/zod/v4-mini/package.json +7 -0
  1078. package/package.json +49 -4
  1079. package/scripts/hooks/canon.mjs +45 -0
  1080. package/scripts/hooks/consent.mjs +728 -0
  1081. package/scripts/hooks/rarog-context.mjs +163 -0
  1082. package/scripts/hooks/rarog-pending.mjs +1498 -0
  1083. package/scripts/hooks/rarog-statusline.mjs +258 -0
  1084. package/scripts/hooks/tall-dialog.mjs +400 -0
  1085. package/scripts/hooks/work-area.mjs +138 -0
  1086. package/scripts/restart.sh +393 -0
  1087. package/server/src/auth/admin.js +272 -0
  1088. package/server/src/auth/consent-socket.js +89 -0
  1089. package/server/src/auth/device.js +81 -0
  1090. package/server/src/auth/devices-store.js +544 -0
  1091. package/server/src/auth/index.js +26 -0
  1092. package/server/src/auth/limiter.js +95 -0
  1093. package/server/src/auth/origin.js +13 -0
  1094. package/server/src/auth/pairing.js +201 -0
  1095. package/server/src/auth/principal.js +28 -0
  1096. package/server/src/auth/redact.js +78 -0
  1097. package/server/src/auth/unix-socket.js +156 -0
  1098. package/server/src/bootstrap/alive-sessions.js +22 -0
  1099. package/server/src/bootstrap/consent.js +453 -0
  1100. package/server/src/bootstrap/devices.js +43 -0
  1101. package/server/src/bootstrap/health.js +45 -0
  1102. package/server/src/bootstrap/herdr.js +25 -0
  1103. package/server/src/bootstrap/hook-files.js +97 -0
  1104. package/server/src/bootstrap/http.js +70 -0
  1105. package/server/src/bootstrap/inbox.js +54 -0
  1106. package/server/src/bootstrap/iroh.js +26 -0
  1107. package/server/src/bootstrap/manager.js +51 -0
  1108. package/server/src/bootstrap/pr-status.js +35 -0
  1109. package/server/src/bootstrap/push.js +88 -0
  1110. package/server/src/bootstrap/sse.js +32 -0
  1111. package/server/src/bootstrap/term.js +54 -0
  1112. package/server/src/bootstrap/versions.js +45 -0
  1113. package/server/src/cli/child-output.js +214 -0
  1114. package/server/src/cli/claude-settings.js +905 -0
  1115. package/server/src/cli/config-rewrite.js +147 -0
  1116. package/server/src/cli/devices.js +417 -0
  1117. package/server/src/cli/dialogs.js +212 -0
  1118. package/server/src/cli/dictation.js +87 -0
  1119. package/server/src/cli/doctor-no-hook.js +162 -0
  1120. package/server/src/cli/doctor-pr-status.js +77 -0
  1121. package/server/src/cli/doctor-write-block.js +65 -0
  1122. package/server/src/cli/doctor.js +1530 -0
  1123. package/server/src/cli/hooks.js +734 -0
  1124. package/server/src/cli/io.js +61 -0
  1125. package/server/src/cli/launchd-loaded.js +82 -0
  1126. package/server/src/cli/lock.js +170 -0
  1127. package/server/src/cli/main.js +129 -0
  1128. package/server/src/cli/restart.js +842 -0
  1129. package/server/src/cli/screen/ask.js +55 -0
  1130. package/server/src/cli/screen/log.js +136 -0
  1131. package/server/src/cli/screen/prose.js +74 -0
  1132. package/server/src/cli/screen/steps.js +528 -0
  1133. package/server/src/cli/screen/style.js +161 -0
  1134. package/server/src/cli/secret-input.js +212 -0
  1135. package/server/src/cli/secrets-file.js +288 -0
  1136. package/server/src/cli/serve.js +687 -0
  1137. package/server/src/cli/service.js +1375 -0
  1138. package/server/src/cli/setup-check.js +287 -0
  1139. package/server/src/cli/setup-config.js +192 -0
  1140. package/server/src/cli/setup-context.js +174 -0
  1141. package/server/src/cli/setup-herdr-agent.js +503 -0
  1142. package/server/src/cli/setup-herdr-unit.js +437 -0
  1143. package/server/src/cli/setup-plan.js +85 -0
  1144. package/server/src/cli/setup-screen.js +372 -0
  1145. package/server/src/cli/setup-secrets.js +179 -0
  1146. package/server/src/cli/setup-settings.js +305 -0
  1147. package/server/src/cli/setup-tailscale-add.js +235 -0
  1148. package/server/src/cli/setup-tailscale-only.js +81 -0
  1149. package/server/src/cli/setup-tailscale-port.js +276 -0
  1150. package/server/src/cli/setup-transport.js +417 -0
  1151. package/server/src/cli/setup-voice.js +174 -0
  1152. package/server/src/cli/setup.js +1191 -0
  1153. package/server/src/cli/systemd-unit.js +370 -0
  1154. package/server/src/cli/templates/herdr-agent.plist +34 -0
  1155. package/server/src/cli/templates/launchd.plist +35 -0
  1156. package/server/src/cli/templates/rarog.service +25 -0
  1157. package/server/src/cli/update-channel.js +100 -0
  1158. package/server/src/cli/update-lock.js +148 -0
  1159. package/server/src/cli/update-provenance.js +303 -0
  1160. package/server/src/cli/update-registry.js +628 -0
  1161. package/server/src/cli/update.js +451 -0
  1162. package/server/src/cli/voice-agent.js +235 -0
  1163. package/server/src/cli/voice-keys.js +71 -0
  1164. package/server/src/cli-store.js +38 -0
  1165. package/server/src/cli-version.js +442 -0
  1166. package/server/src/client-log.js +121 -0
  1167. package/server/src/companion/ask.js +165 -0
  1168. package/server/src/companion/asks-owner.js +205 -0
  1169. package/server/src/companion/catalog.js +22 -0
  1170. package/server/src/companion/cli-literals.js +84 -0
  1171. package/server/src/companion/cli.js +235 -0
  1172. package/server/src/companion/condense.js +274 -0
  1173. package/server/src/companion/conversation.js +21 -0
  1174. package/server/src/companion/index.js +46 -0
  1175. package/server/src/companion/mask.js +37 -0
  1176. package/server/src/companion/openai-token.js +129 -0
  1177. package/server/src/companion/prompt.js +102 -0
  1178. package/server/src/companion/turns-settle.js +33 -0
  1179. package/server/src/companion/turns.js +132 -0
  1180. package/server/src/config/claude-account.js +101 -0
  1181. package/server/src/config/clients.js +45 -0
  1182. package/server/src/config/demo.js +97 -0
  1183. package/server/src/config/files.js +32 -0
  1184. package/server/src/config/flags.js +152 -0
  1185. package/server/src/config/herdr.js +129 -0
  1186. package/server/src/config/listen.js +122 -0
  1187. package/server/src/config/protected-dirs.js +79 -0
  1188. package/server/src/config/push.js +72 -0
  1189. package/server/src/config/roots.js +259 -0
  1190. package/server/src/config/terminal.js +86 -0
  1191. package/server/src/config/voice.js +21 -0
  1192. package/server/src/config/work-area.js +168 -0
  1193. package/server/src/config-env.js +530 -0
  1194. package/server/src/config.js +749 -0
  1195. package/server/src/demo/content/en.js +673 -0
  1196. package/server/src/demo/content/index.js +16 -0
  1197. package/server/src/demo/content/named-set.js +59 -0
  1198. package/server/src/demo/content/pl.js +691 -0
  1199. package/server/src/demo/content/types.js +1 -0
  1200. package/server/src/demo/control.js +574 -0
  1201. package/server/src/demo/files.js +49 -0
  1202. package/server/src/demo/inbox.js +73 -0
  1203. package/server/src/demo/mac.js +20 -0
  1204. package/server/src/demo/mock-herdr.js +251 -0
  1205. package/server/src/demo/notes.js +60 -0
  1206. package/server/src/demo/review-routes.js +101 -0
  1207. package/server/src/demo/scenarios.js +338 -0
  1208. package/server/src/demo/seeds.js +480 -0
  1209. package/server/src/demo/usage.js +29 -0
  1210. package/server/src/demo/voice.js +24 -0
  1211. package/server/src/device-effects.js +39 -0
  1212. package/server/src/drivers/herdr/audit-fields.js +27 -0
  1213. package/server/src/drivers/herdr/cli-reserve.js +238 -0
  1214. package/server/src/drivers/herdr/command-dialog-settle.js +90 -0
  1215. package/server/src/drivers/herdr/commands.js +751 -0
  1216. package/server/src/drivers/herdr/consent-channel.js +231 -0
  1217. package/server/src/drivers/herdr/consent-no-hook-io.js +89 -0
  1218. package/server/src/drivers/herdr/consent-no-hook.js +316 -0
  1219. package/server/src/drivers/herdr/consent-registry-read.js +45 -0
  1220. package/server/src/drivers/herdr/form-reserve.js +203 -0
  1221. package/server/src/drivers/herdr/layer2-card.js +302 -0
  1222. package/server/src/drivers/herdr/layer2-step.js +199 -0
  1223. package/server/src/drivers/herdr/prompt-gates.js +118 -0
  1224. package/server/src/drivers/herdr/prompt-paste.js +106 -0
  1225. package/server/src/drivers/herdr/prompt-queue-store.js +284 -0
  1226. package/server/src/drivers/herdr/prompt-queue.js +921 -0
  1227. package/server/src/drivers/herdr/pull-request-poll.js +61 -0
  1228. package/server/src/drivers/herdr/queue-take-back.js +429 -0
  1229. package/server/src/drivers/herdr/refusals.js +226 -0
  1230. package/server/src/drivers/herdr/returned-prompt.js +172 -0
  1231. package/server/src/drivers/herdr/scheduled-task-poll.js +120 -0
  1232. package/server/src/drivers/herdr/stale-block.js +33 -0
  1233. package/server/src/drivers/herdr/take-back-field.js +311 -0
  1234. package/server/src/drivers/herdr/transcript.js +186 -0
  1235. package/server/src/drivers/herdr/turn-guard.js +328 -0
  1236. package/server/src/drivers/herdr-driver.js +4332 -0
  1237. package/server/src/drivers/mock-driver.js +541 -0
  1238. package/server/src/drivers/runtime.js +76 -0
  1239. package/server/src/drivers/tool-summary.js +95 -0
  1240. package/server/src/drivers/tool-text.js +206 -0
  1241. package/server/src/drivers/types.js +15 -0
  1242. package/server/src/files/file-index.js +246 -0
  1243. package/server/src/files/ignored.js +119 -0
  1244. package/server/src/files/listing.js +76 -0
  1245. package/server/src/files/path-rule.js +145 -0
  1246. package/server/src/files/refusals.js +36 -0
  1247. package/server/src/files/send-file.js +115 -0
  1248. package/server/src/files/session-download.js +51 -0
  1249. package/server/src/files/session-files.js +38 -0
  1250. package/server/src/files/session-gate.js +48 -0
  1251. package/server/src/fs-browse.js +268 -0
  1252. package/server/src/fs-mkdir-child.js +86 -0
  1253. package/server/src/fs-mkdir.js +161 -0
  1254. package/server/src/git-config-guard.js +72 -0
  1255. package/server/src/git-diff.js +356 -0
  1256. package/server/src/git-sandbox.js +100 -0
  1257. package/server/src/git-stats.js +61 -0
  1258. package/server/src/git-status.js +1073 -0
  1259. package/server/src/git-watch.js +299 -0
  1260. package/server/src/git-work-tree.js +33 -0
  1261. package/server/src/health.js +167 -0
  1262. package/server/src/herdr/answer-recheck.js +85 -0
  1263. package/server/src/herdr/argv.js +234 -0
  1264. package/server/src/herdr/audit.js +520 -0
  1265. package/server/src/herdr/background/agent-file.js +411 -0
  1266. package/server/src/herdr/background/artifacts.js +173 -0
  1267. package/server/src/herdr/background/cli-shapes.js +442 -0
  1268. package/server/src/herdr/background/ids.js +29 -0
  1269. package/server/src/herdr/background/incremental-read.js +70 -0
  1270. package/server/src/herdr/background/index.js +93 -0
  1271. package/server/src/herdr/background/jsonl-lines.js +68 -0
  1272. package/server/src/herdr/background/main-scan.js +229 -0
  1273. package/server/src/herdr/background/merge.js +336 -0
  1274. package/server/src/herdr/background/notice.js +110 -0
  1275. package/server/src/herdr/background/notification.js +267 -0
  1276. package/server/src/herdr/background/pull-request-files.js +257 -0
  1277. package/server/src/herdr/background/pull-requests.js +684 -0
  1278. package/server/src/herdr/background/queued-prompt.js +52 -0
  1279. package/server/src/herdr/background/reducer.js +682 -0
  1280. package/server/src/herdr/background/satellite.js +73 -0
  1281. package/server/src/herdr/background/scheduled-task-file.js +118 -0
  1282. package/server/src/herdr/background/scheduled-tasks.js +251 -0
  1283. package/server/src/herdr/background/work.js +134 -0
  1284. package/server/src/herdr/background/workflow-run.js +417 -0
  1285. package/server/src/herdr/client.js +894 -0
  1286. package/server/src/herdr/commands/catalog.js +179 -0
  1287. package/server/src/herdr/commands/discover.js +605 -0
  1288. package/server/src/herdr/commands/guard.js +192 -0
  1289. package/server/src/herdr/commands/index.js +35 -0
  1290. package/server/src/herdr/commands/registry.js +496 -0
  1291. package/server/src/herdr/commands/shape.js +240 -0
  1292. package/server/src/herdr/commands/transcript.js +261 -0
  1293. package/server/src/herdr/consent-evidence.js +592 -0
  1294. package/server/src/herdr/consent-step.js +44 -0
  1295. package/server/src/herdr/consent-subagent.js +423 -0
  1296. package/server/src/herdr/dialogs/cards/build.js +445 -0
  1297. package/server/src/herdr/dialogs/cards/ids.js +101 -0
  1298. package/server/src/herdr/dialogs/cards/roles.js +22 -0
  1299. package/server/src/herdr/dialogs/consent-gate.js +62 -0
  1300. package/server/src/herdr/dialogs/copy.js +97 -0
  1301. package/server/src/herdr/dialogs/cross-check.js +500 -0
  1302. package/server/src/herdr/dialogs/decide/decide.js +825 -0
  1303. package/server/src/herdr/dialogs/decide/input.js +1 -0
  1304. package/server/src/herdr/dialogs/decide/reasons.js +60 -0
  1305. package/server/src/herdr/dialogs/decide/sources.js +322 -0
  1306. package/server/src/herdr/dialogs/hook/answers.js +190 -0
  1307. package/server/src/herdr/dialogs/hook/canon.js +28 -0
  1308. package/server/src/herdr/dialogs/hook/contract.js +232 -0
  1309. package/server/src/herdr/dialogs/hook/dump.js +350 -0
  1310. package/server/src/herdr/dialogs/hook/suggestions.js +75 -0
  1311. package/server/src/herdr/dialogs/hook/target.js +99 -0
  1312. package/server/src/herdr/dialogs/index.js +208 -0
  1313. package/server/src/herdr/dialogs/layer1/always.js +71 -0
  1314. package/server/src/herdr/dialogs/layer1/bind.js +193 -0
  1315. package/server/src/herdr/dialogs/layer1/card.js +190 -0
  1316. package/server/src/herdr/dialogs/layer1/cards.js +37 -0
  1317. package/server/src/herdr/dialogs/layer1/contract.js +399 -0
  1318. package/server/src/herdr/dialogs/layer1/cycle.js +1746 -0
  1319. package/server/src/herdr/dialogs/layer1/desk-reason.js +119 -0
  1320. package/server/src/herdr/dialogs/layer1/desk.js +190 -0
  1321. package/server/src/herdr/dialogs/layer1/frames.js +118 -0
  1322. package/server/src/herdr/dialogs/layer1/hook-list/hook-list.js +1049 -0
  1323. package/server/src/herdr/dialogs/layer1/hook-list/session-facts.js +135 -0
  1324. package/server/src/herdr/dialogs/layer1/mode.js +93 -0
  1325. package/server/src/herdr/dialogs/layer1/observe.js +419 -0
  1326. package/server/src/herdr/dialogs/layer1/proof.js +454 -0
  1327. package/server/src/herdr/dialogs/layer1/receipt.js +71 -0
  1328. package/server/src/herdr/dialogs/layer1/records.js +236 -0
  1329. package/server/src/herdr/dialogs/layer1/registry.js +274 -0
  1330. package/server/src/herdr/dialogs/layer1/resume.js +178 -0
  1331. package/server/src/herdr/dialogs/layer1/sign.js +182 -0
  1332. package/server/src/herdr/dialogs/layer1/top.js +264 -0
  1333. package/server/src/herdr/dialogs/layer1/turns.js +251 -0
  1334. package/server/src/herdr/dialogs/layer1/version-gate.js +162 -0
  1335. package/server/src/herdr/dialogs/layer2/card.js +109 -0
  1336. package/server/src/herdr/dialogs/layer2/match.js +98 -0
  1337. package/server/src/herdr/dialogs/layer2/read-block.js +153 -0
  1338. package/server/src/herdr/dialogs/layer2/shapes.js +61 -0
  1339. package/server/src/herdr/dialogs/layer2/stability.js +104 -0
  1340. package/server/src/herdr/dialogs/layer2/verdict.js +282 -0
  1341. package/server/src/herdr/dialogs/no-hook.js +63 -0
  1342. package/server/src/herdr/dialogs/policy/consent.js +29 -0
  1343. package/server/src/herdr/dialogs/policy/escalation.js +115 -0
  1344. package/server/src/herdr/dialogs/policy/exit-tasks.js +34 -0
  1345. package/server/src/herdr/dialogs/policy/measured-consent.js +123 -0
  1346. package/server/src/herdr/dialogs/policy/option-policy.js +22 -0
  1347. package/server/src/herdr/dialogs/policy/options.js +79 -0
  1348. package/server/src/herdr/dialogs/policy/pause.js +18 -0
  1349. package/server/src/herdr/dialogs/policy/terminal.js +93 -0
  1350. package/server/src/herdr/dialogs/presence.js +49 -0
  1351. package/server/src/herdr/dialogs/refusals.js +271 -0
  1352. package/server/src/herdr/dialogs/router.js +137 -0
  1353. package/server/src/herdr/dialogs/screen/auto-deny.js +31 -0
  1354. package/server/src/herdr/dialogs/screen/bash-zone.js +161 -0
  1355. package/server/src/herdr/dialogs/screen/block-visible.js +60 -0
  1356. package/server/src/herdr/dialogs/screen/block.js +296 -0
  1357. package/server/src/herdr/dialogs/screen/confirm.js +83 -0
  1358. package/server/src/herdr/dialogs/screen/dialog-bottom.js +54 -0
  1359. package/server/src/herdr/dialogs/screen/edit-frame.js +391 -0
  1360. package/server/src/herdr/dialogs/screen/edit-zone.js +33 -0
  1361. package/server/src/herdr/dialogs/screen/excerpt.js +48 -0
  1362. package/server/src/herdr/dialogs/screen/file-dialog.js +38 -0
  1363. package/server/src/herdr/dialogs/screen/form.js +199 -0
  1364. package/server/src/herdr/dialogs/screen/identity.js +23 -0
  1365. package/server/src/herdr/dialogs/screen/kinds.js +39 -0
  1366. package/server/src/herdr/dialogs/screen/known.js +101 -0
  1367. package/server/src/herdr/dialogs/screen/mode-footer.js +90 -0
  1368. package/server/src/herdr/dialogs/screen/operation.js +196 -0
  1369. package/server/src/herdr/dialogs/screen/option-run.js +62 -0
  1370. package/server/src/herdr/dialogs/screen/options.js +534 -0
  1371. package/server/src/herdr/dialogs/screen/parse.js +368 -0
  1372. package/server/src/herdr/dialogs/screen/plan-file.js +53 -0
  1373. package/server/src/herdr/dialogs/screen/queue.js +59 -0
  1374. package/server/src/herdr/dialogs/screen/region.js +92 -0
  1375. package/server/src/herdr/dialogs/screen/resolve.js +305 -0
  1376. package/server/src/herdr/dialogs/screen/review.js +118 -0
  1377. package/server/src/herdr/dialogs/screen/signatures.js +1030 -0
  1378. package/server/src/herdr/dialogs/screen/snippet.js +49 -0
  1379. package/server/src/herdr/dialogs/screen/text.js +50 -0
  1380. package/server/src/herdr/dialogs/screen/trust-arrow.js +122 -0
  1381. package/server/src/herdr/dialogs/screen/write-zone.js +41 -0
  1382. package/server/src/herdr/dialogs/screen-unavailable.js +52 -0
  1383. package/server/src/herdr/dialogs/send/form-submit.js +72 -0
  1384. package/server/src/herdr/dialogs/send/key-row.js +29 -0
  1385. package/server/src/herdr/dialogs/send/keys.js +75 -0
  1386. package/server/src/herdr/dialogs/send/prompt-submit.js +35 -0
  1387. package/server/src/herdr/dialogs/send/take-back-keys.js +33 -0
  1388. package/server/src/herdr/dialogs/send/trust-step.js +52 -0
  1389. package/server/src/herdr/dialogs/shadow/alive-log.js +100 -0
  1390. package/server/src/herdr/dialogs/shadow/alive.js +211 -0
  1391. package/server/src/herdr/dialogs/shadow/atomic.js +55 -0
  1392. package/server/src/herdr/dialogs/shadow/channel.js +321 -0
  1393. package/server/src/herdr/dialogs/shadow/evidence.js +322 -0
  1394. package/server/src/herdr/dialogs/shadow/files.js +375 -0
  1395. package/server/src/herdr/dialogs/shadow/liveness.js +145 -0
  1396. package/server/src/herdr/dialogs/shadow/sweep.js +220 -0
  1397. package/server/src/herdr/dialogs/timing.js +88 -0
  1398. package/server/src/herdr/history-steps.js +190 -0
  1399. package/server/src/herdr/hook-commands.js +355 -0
  1400. package/server/src/herdr/hook-config.js +1468 -0
  1401. package/server/src/herdr/identity.js +277 -0
  1402. package/server/src/herdr/index.js +27 -0
  1403. package/server/src/herdr/input-segments.js +135 -0
  1404. package/server/src/herdr/jsonl-activity.js +122 -0
  1405. package/server/src/herdr/jsonl-follow.js +2358 -0
  1406. package/server/src/herdr/jsonl-pending.js +551 -0
  1407. package/server/src/herdr/jsonl-queue.js +133 -0
  1408. package/server/src/herdr/jsonl-usage.js +174 -0
  1409. package/server/src/herdr/launcher.js +574 -0
  1410. package/server/src/herdr/line-diff.js +104 -0
  1411. package/server/src/herdr/mode-cycle.js +78 -0
  1412. package/server/src/herdr/project-workspace.js +131 -0
  1413. package/server/src/herdr/provenance.js +204 -0
  1414. package/server/src/herdr/session-pulse.js +536 -0
  1415. package/server/src/herdr/socket.js +1003 -0
  1416. package/server/src/herdr/statusline.js +348 -0
  1417. package/server/src/herdr/supervisor.js +1934 -0
  1418. package/server/src/herdr/transcript-path.js +123 -0
  1419. package/server/src/herdr/trust.js +201 -0
  1420. package/server/src/herdr/types.js +163 -0
  1421. package/server/src/herdr/ultracode.js +132 -0
  1422. package/server/src/herdr/uploads-registry.js +173 -0
  1423. package/server/src/herdr/uploads.js +642 -0
  1424. package/server/src/herdr/workspace-resolver.js +219 -0
  1425. package/server/src/hidden-chars.js +52 -0
  1426. package/server/src/inbox/card.js +130 -0
  1427. package/server/src/inbox/dialogs.js +150 -0
  1428. package/server/src/inbox/heads.js +55 -0
  1429. package/server/src/inbox/inbox.js +440 -0
  1430. package/server/src/inbox/index.js +21 -0
  1431. package/server/src/inbox/removals.js +181 -0
  1432. package/server/src/inbox/segments.js +37 -0
  1433. package/server/src/index.js +800 -0
  1434. package/server/src/install/data-dir.js +103 -0
  1435. package/server/src/install/evidence.js +66 -0
  1436. package/server/src/install/mode.js +37 -0
  1437. package/server/src/install/repair.js +223 -0
  1438. package/server/src/install/sdk-lock.json +153 -0
  1439. package/server/src/install/sdk-package.json +7 -0
  1440. package/server/src/install/sdk-probe.js +18 -0
  1441. package/server/src/install/sdk.js +624 -0
  1442. package/server/src/install/service-target.js +106 -0
  1443. package/server/src/iroh/adapter.js +294 -0
  1444. package/server/src/iroh/duplex.js +169 -0
  1445. package/server/src/iroh/endpoint.js +17 -0
  1446. package/server/src/iroh/listener.js +422 -0
  1447. package/server/src/iroh/log-budget.js +70 -0
  1448. package/server/src/iroh/module-probe.js +17 -0
  1449. package/server/src/iroh/path-log.js +96 -0
  1450. package/server/src/iroh/socket.js +89 -0
  1451. package/server/src/live-sessions.js +162 -0
  1452. package/server/src/log-timestamps-install.js +8 -0
  1453. package/server/src/log-timestamps.js +63 -0
  1454. package/server/src/mac-stats.js +261 -0
  1455. package/server/src/notes/store.js +248 -0
  1456. package/server/src/notify/apns-channel.js +70 -0
  1457. package/server/src/notify/apns-devices.js +477 -0
  1458. package/server/src/notify/apns-payload.js +267 -0
  1459. package/server/src/notify/apns-sink.js +207 -0
  1460. package/server/src/notify/apns.js +307 -0
  1461. package/server/src/notify/consent-canary-push.js +163 -0
  1462. package/server/src/notify/content.js +328 -0
  1463. package/server/src/notify/fanout.js +44 -0
  1464. package/server/src/notify/index.js +505 -0
  1465. package/server/src/notify/live-activity-limits.js +126 -0
  1466. package/server/src/notify/live-activity-state.js +176 -0
  1467. package/server/src/notify/live-activity.js +581 -0
  1468. package/server/src/notify/policy.js +273 -0
  1469. package/server/src/notify/presence.js +176 -0
  1470. package/server/src/notify/push-crypto.js +95 -0
  1471. package/server/src/notify/relay-pass.js +487 -0
  1472. package/server/src/notify/relay-sender.js +206 -0
  1473. package/server/src/notify/sender.js +117 -0
  1474. package/server/src/notify/weekly-limit.js +204 -0
  1475. package/server/src/notify/workflow-phase.js +11 -0
  1476. package/server/src/permissions.js +239 -0
  1477. package/server/src/pr-status/gh.js +270 -0
  1478. package/server/src/pr-status/index.js +12 -0
  1479. package/server/src/pr-status/source.js +22 -0
  1480. package/server/src/pr-status/tracker.js +204 -0
  1481. package/server/src/risk.js +100 -0
  1482. package/server/src/router.js +603 -0
  1483. package/server/src/routes/context.js +8 -0
  1484. package/server/src/routes/devices.js +246 -0
  1485. package/server/src/routes/inbox.js +91 -0
  1486. package/server/src/routes/limits.js +41 -0
  1487. package/server/src/routes/notes.js +105 -0
  1488. package/server/src/routes/projects.js +189 -0
  1489. package/server/src/routes/push.js +252 -0
  1490. package/server/src/routes/sessions.js +878 -0
  1491. package/server/src/routes/system.js +275 -0
  1492. package/server/src/routes/terminal.js +140 -0
  1493. package/server/src/safe-read.js +203 -0
  1494. package/server/src/session-label.js +48 -0
  1495. package/server/src/session-list.js +166 -0
  1496. package/server/src/sessions/activity-clocks.js +47 -0
  1497. package/server/src/sessions/attach-slots.js +64 -0
  1498. package/server/src/sessions/claim-window.js +132 -0
  1499. package/server/src/sessions/cli-registry.js +233 -0
  1500. package/server/src/sessions/companion-scope.js +103 -0
  1501. package/server/src/sessions/consent-cards.js +509 -0
  1502. package/server/src/sessions/context-usage.js +23 -0
  1503. package/server/src/sessions/conversation-lists.js +68 -0
  1504. package/server/src/sessions/demo-modules.js +16 -0
  1505. package/server/src/sessions/dialog-timing.js +57 -0
  1506. package/server/src/sessions/diff-measure.js +30 -0
  1507. package/server/src/sessions/driver-events.js +282 -0
  1508. package/server/src/sessions/errors.js +64 -0
  1509. package/server/src/sessions/fallback-label.js +38 -0
  1510. package/server/src/sessions/held-echo.js +258 -0
  1511. package/server/src/sessions/herdr-lifecycle.js +453 -0
  1512. package/server/src/sessions/interrupt-windows.js +141 -0
  1513. package/server/src/sessions/launch-gate.js +299 -0
  1514. package/server/src/sessions/manager-api.js +1 -0
  1515. package/server/src/sessions/manager.js +3957 -0
  1516. package/server/src/sessions/pr-status-link.js +50 -0
  1517. package/server/src/sessions/project-scan.js +48 -0
  1518. package/server/src/sessions/question-card.js +137 -0
  1519. package/server/src/sessions/recent-projects.js +55 -0
  1520. package/server/src/sessions/ring-buffer.js +211 -0
  1521. package/server/src/sessions/seen-marks.js +434 -0
  1522. package/server/src/sessions/send-registry.js +275 -0
  1523. package/server/src/sessions/session-git.js +304 -0
  1524. package/server/src/sessions/session-restart.js +420 -0
  1525. package/server/src/sessions/session-scope.js +30 -0
  1526. package/server/src/sessions/session-take-back.js +118 -0
  1527. package/server/src/sessions/session.js +743 -0
  1528. package/server/src/sessions/state-machine.js +145 -0
  1529. package/server/src/sessions/state-sentences.js +642 -0
  1530. package/server/src/sessions/waiting-line.js +72 -0
  1531. package/server/src/shutdown.js +20 -0
  1532. package/server/src/sse.js +611 -0
  1533. package/server/src/tailnet.js +169 -0
  1534. package/server/src/term/backend.js +59 -0
  1535. package/server/src/term/herdr-backend.js +1649 -0
  1536. package/server/src/term/herdr-stream.js +109 -0
  1537. package/server/src/term/index.js +338 -0
  1538. package/server/src/term/lifecycle.js +182 -0
  1539. package/server/src/term/paste.js +139 -0
  1540. package/server/src/term/registry.js +1032 -0
  1541. package/server/src/term/ws.js +306 -0
  1542. package/server/src/text.js +102 -0
  1543. package/server/src/transcript-import.js +579 -0
  1544. package/server/src/usage.js +255 -0
  1545. package/server/src/version-watch.js +243 -0
  1546. package/server/src/version.js +102 -0
  1547. package/server/src/voice/soniox.js +301 -0
@@ -0,0 +1,1498 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Claude Code hook: dumps to a file WHAT the session is STOPPED on, so that Rarog can show a card with the full
4
+ * content on the phone.
5
+ *
6
+ * TWO events, two different roles:
7
+ * - `PermissionRequest`: fires when a permission request enters the dialog queue: with a single dialog that is the
8
+ * moment the dialog appears on screen. With a QUEUE ("1 of 2", two parallel calls that need permission) the hook
9
+ * fires for each request at once, so the second one's dump overwrites the first one's, although the screen shows the
10
+ * first (measured on CLI 2.1.302). It also covers `ExitPlanMode`: the payload then carries the full plan text. The
11
+ * dump key stays per SESSION, because `tool_use_id` is ABSENT in this event (the `/hooks` screen claims otherwise and
12
+ * is wrong: the payload counts).
13
+ * - `PreToolUse` ONLY for `AskUserQuestion`: the question content (header, option descriptions,
14
+ * `multiSelect`) sits in `tool_input` and nowhere else. This hook must finish
15
+ * AT ONCE: while `PreToolUse` waits, the form does NOT render in the terminal
16
+ * (measured). There is no dump for EVERY tool: it would give stale files and a write on every
17
+ * `Read`.
18
+ *
19
+ * WHY it does not decide PERMISSIONS by itself: both events may return a decision
20
+ * (`hookSpecificOutput`). This hook does not ALLOW a tool on its own judgement: a permission comes from a KEY
21
+ * on the screen or, in consent channel mode (section below), ONLY from Rarog's signed answer file
22
+ * after a human's decision on the device. Rarog interprets nothing. The contract for tools
23
+ * outside the guard and the channel: exit 0, stdout EMPTY; it waits in shadow mode and leaves it without a result.
24
+ * Every error (no HOME, full disk, a garbage payload) ends silently with exit 0: a hook
25
+ * plugged into EVERY Claude session on this Mac must not break anyone's work.
26
+ *
27
+ * CONSENT CHANNEL (layer 1): when `alive.json` carries mode `main` (a main-thread request, without `agent_id`)
28
+ * or `all`, is fresh, `send: true` and the session is on the list, a tool permission request skips the tall dialog
29
+ * guard and goes through the `consent.mjs` module: the secret on the socket `<dataDir>/run/consent.sock` BEFORE the
30
+ * per-call dump and before the log line with the key, then the dump, then waiting for the file
31
+ * `<dataDir>/consent/<session>/<key>.json`, which the hook first claims (`rename` to `.claimed`), and only
32
+ * then reads and verifies. A valid file gives `allow` (without `updatedInput`, except `ExitPlanMode`), a bare `deny`
33
+ * with an English text from the list in `consent.mjs`, or silence (`release`). An invalid file goes aside
34
+ * (`.rejected`), the wait goes on. A missing module, a refusal or the registration deadline, a mode lower than at
35
+ * registration and a new `bootId` in `alive.json` (outside a restart break, below) end the hook WITHOUT a decision:
36
+ * the dialog stays at the desk.
37
+ * A valid `allow` goes out only after the server's receipt (`POST /claim`, `consent.mjs`); without it the hook
38
+ * exits without a decision too. `deny` and `release` need no receipt.
39
+ *
40
+ * RESTART BREAK (`consent.mjs`, `waitThroughRestart`): a hook that starts on `stop` or `phase: "starting"` in
41
+ * `alive.json` waits (`pauza`) for the next server's channel before the marker and the route, then takes the usual
42
+ * path; past the break it exits after the per-session dump without a decision (`przerwa`). A registered hook pauses
43
+ * on such a break too and registers again with the same body (`waitResuming`): only `resumed` lets it wait on.
44
+ *
45
+ * PER-CALL DUMP AND SHADOW MODE (contract: `server/src/herdr/dialogs/hook/contract.ts`). On a
46
+ * `PermissionRequest` for a tool other than `AskUserQuestion` the hook writes, next to the per-session dump,
47
+ * the dump `pending/<session>/<key>.json` with the key `<prompt_id>-<nonce 16 B hex>`, the PID, the process start
48
+ * and the full sha256 of the canonical `tool_input` (`canon.mjs`). The dump lives as long as the process: the hook
49
+ * deletes it on every exit, also after SIGTERM. Then it reads `<dataDir>/alive.json` and WAITS only
50
+ * when all hold: the file is fresh (`ts` at most 30 s), mode `shadow`, `send: true`, the session on the `sessions`
51
+ * list, a request without `agent_id`, the dump not truncated. While waiting, at every poll it reads `alive.json` again
52
+ * (a condition that stopped holding ends the hook without a result), claims the shadow file
53
+ * `shadow/<session>/<key>.json` (`rename` to `<key>.claimed`) or sees `<key>.revoked`. Each
54
+ * of these exits is WITHOUT A RESULT: shadow mode checks the addressing of decisions, and the permission still comes
55
+ * from a key. No `alive.json` (the server does not write it) = mode `off` = behavior without shadow mode plus the
56
+ * per-call dump for the life of the process and the `shadow.jsonl` lines. The hook appends the whole cycle (start,
57
+ * waiting or not waiting with a reason, claim, signal, exit with a reason and time) to `<dataDir>/shadow.jsonl`,
58
+ * without the `tool_input` content. `czekam` and an exit on an `alive.json` veto carry `bootId` and `ts` of the file
59
+ * read (`aliveTs`), and `czekam` also the input digest: from them the shadow audit computes the time from a flag
60
+ * change to the exit.
61
+ *
62
+ * REQUEST MARKER (`HookMarkerFile` in the contract). For the same request, when `alive.json` has a valid shape and is
63
+ * fresh, the session is on the list, the mode is `main` or `all` and the `markers` field is literally `true`, the hook
64
+ * writes `<dataDir>/markers/<session>/<name>.json` (0600 in a 0700 directory, a temporary file and `rename`): after
65
+ * validating `session_id`, `cwd` and the roots and after the canon digest, BEFORE choosing the path, that is before the
66
+ * tall dialog guard, the consent channel, shadow mode, registration, truncation and every exit without waiting. The
67
+ * marker tells the server the request exists, also when the hook exited before the server saw its per-call dump. The
68
+ * hook draws the per-call key ONCE (`callKeyFor` in `main`), and the same key with the same nonce is carried by the
69
+ * marker name, the per-call dump and the consent channel registration. Without a key (`prompt_id` is not fit for a file
70
+ * name) the name is `anon-<pid>-<startedAt>`, and the `key` field is `null`. Fields as in the per-call dump, without
71
+ * `permissionMode`; `inputSha256` is `null` when `canon.mjs` did not load or threw. The hook NEVER deletes the marker
72
+ * (the server cleans up), and it swallows a write error. A server without the `markers` field (or with another value),
73
+ * mode `shadow` or `off`, a stale or broken file or one without this session = no marker, and the rest of the hook is
74
+ * unchanged to the byte; an older hook does not read the field. Nothing closes the window before the write: Node start,
75
+ * the `canon.mjs` import and the digest (a main-thread dialog stands from the hook's start), a signal before the write
76
+ * and a write error leave the request without a marker, as without this feature.
77
+ *
78
+ * TALL DIALOG GUARD: the hook's only decision without a human, and only a FORM REFUSAL: `PermissionRequest` for `Bash`,
79
+ * in a herdr session (`HERDR_ENV=1`), under Rarog's roots, when `roots.json` carries `tallDialogGuard: true`. If the
80
+ * permission dialog would be taller than the pane the session stands in (estimate in `tall-dialog.mjs`; geometry from
81
+ * `COLUMNS` and `LINES` of the hook's environment, at most the phone, without them the phone), the hook returns `deny`
82
+ * with the message "this is not a block, split into shorter calls, one after another". Reason: a tall dialog hides the
83
+ * title and the start of the command above the edge, and a subagent's permission then has no double proof: a card
84
+ * without buttons, a human cannot approve it from the phone. The refusal writes no dump to `pending/` (there will be no
85
+ * dialog, and an existing dump, e.g. of a standing question, stays untouched), refreshes `hook-seen.json` and appends a
86
+ * line to `<dataDir>/guard.jsonl` (time, session, whether a subagent, estimate, budget, budget source and pane
87
+ * geometry: no command content). A request LET THROUGH carries the budget source and the geometry in the dump, so that
88
+ * a later card without a decision has the pane size at the moment of the hook in the log. A module load error or an
89
+ * estimate error = behavior without the guard; a write error of the marker or the refusal log line does not stop
90
+ * anything (both are diagnostics, and the model sees the refusal in its transcript anyway).
91
+ *
92
+ * ONE EXCEPTION: THE ANSWER CHANNEL: `PermissionRequest` for `AskUserQuestion`. After dumping the question the hook
93
+ * WAITS (polling every 250 ms, up to `--answer-wait`) for the file `<dataDir>/answers/<session_id>/<key>.json` written
94
+ * by Rarog, and only then returns `allow` with `updatedInput.answers`. This is not a tool permission: `AskUserQuestion`
95
+ * executes nothing, and `answers` is LITERALLY the human's answer: the same one they would type as digits in the
96
+ * terminal. Measured (CLI 2.1.257): the form renders and accepts keys the whole time the hook sleeps, and a decision
97
+ * from the DESK wins the race both ways (on `Esc` the CLI kills the hook, on a digit it silently ignores the hook's
98
+ * late `allow`). The file can also carry the human's NOTES for the chosen option (`annotations`: `notes` and a literal
99
+ * option preview): part of the same answer, checked in `readAnnotations` before handing it to the CLI.
100
+ *
101
+ * The answer file KEY is `<prompt_id>-<sha256(tool_input.questions) to 16 characters>-<nonce>`.
102
+ * `prompt_id` alone is NOT ENOUGH: two `AskUserQuestion` in one turn of the main agent have it
103
+ * IDENTICAL and run in parallel, and the main-thread `PermissionRequest` payload carries neither
104
+ * `tool_use_id` nor `agent_id`. The only thing that tells these two questions apart is the
105
+ * `tool_input` content, and that is what goes into the key. The key also goes to the dump (`answerKey`), so that
106
+ * Rarog does not compute it a second time and a mismatch is impossible. A SUBAGENT's payload carries
107
+ * `agent_id` and `agent_type` (measured on CLI 2.1.302): the guard records only
108
+ * "subagent yes/no" from it, and the dump only `agentId`, solely for Rarog's log.
109
+ *
110
+ * NONCE: `prompt_id` + content digest do NOT tell apart two IDENTICAL calls of the same turn: a repeated question (the
111
+ * same content, the same `prompt_id`) would give exactly the same key without it. And the process of a hook resolved by
112
+ * a DIGIT at the desk lives on (the CLI does not kill it, only ignores its late `allow`, measured) and watches only its
113
+ * key, so it could eat the answer file meant for the NEXT call. Random 8 bytes make every key single-use: the old
114
+ * process waits for a file nobody will write any more, and after the dump is overwritten (`dumpStillMine` sees another
115
+ * `answerKey`) it ends silently. The command in the hooks block does NOT change, so `hooks:doctor` does not show
116
+ * `mismatch`.
117
+ *
118
+ * The `cwd` FILTER: the entry in `~/.claude/settings.json` covers all sessions on the account, also
119
+ * client repositories. We write ONLY for directories lying in Rarog's roots, read
120
+ * from `<dataDir>/roots.json` (the server keeps the file at start from `RAROG_HERDR_ROOTS`). No
121
+ * file or a `cwd` outside the roots = exit 0 without writing and without a trace. Fail-closed: when we do not know
122
+ * where we may write, we do not write.
123
+ * Work area: when `roots.json` has `exclude` (the macOS-protected folders of home), a `cwd` in a hidden entry
124
+ * of a root (`~/.cache/…` under the root `~`) or in an excluded folder that no root lies in counts as outside, checked
125
+ * on the path as given before any disk access and again on the resolved path. The path is resolved one segment at a
126
+ * time (`work-area.mjs`), which stops before an excluded folder: a link into `~/Desktop` or a root that is a symlink to
127
+ * home gets no read there. Without the field: roots only; a field that is not a list of absolute paths: no action.
128
+ *
129
+ * PROGRAMMATIC SESSIONS: `claude -p` and Agent SDK clients have no human at the screen, and Rarog does not serve them
130
+ * (the list of sessions to resume hides them too, `includeProgrammatic: false`). When `CLAUDE_CODE_ENTRYPOINT` is
131
+ * `sdk-cli`, `sdk-ts` or `sdk-py`, the hook exits right after reading stdin: exit 0, empty stdout, zero writes: no
132
+ * dump, `hook-seen.json`, `shadow.jsonl` or `guard.jsonl` lines, no waiting and no guard refusal. The trace is the same
133
+ * as for a `cwd` outside the roots, that is none. Any other value or no variable = unchanged behavior. We read stdin
134
+ * BEFORE the condition, so that the CLI does not get EPIPE when writing the payload. The variable is neither in the
135
+ * payload nor in the Claude Code docs; the hook inherits it from the CLI process. Measured on CLI 2.1.314: `claude -p`
136
+ * without the variable and with an inherited `cli` gives the hook `sdk-cli`, an interactive session `cli`, and an
137
+ * interactive session with an inherited `sdk-cli` keeps it. `sdk-ts` and `sdk-py` are not measured; the hook treats
138
+ * them as programmatic too, by their name. A known, accepted mistake: an interactive `claude` started
139
+ * with a programmatic session's environment loses Rarog's hooks: the card goes back to the screen, there is no wrong
140
+ * permission. Panes Rarog creates clear the variable (`DEFAULT_CLAUDE_ENV_CLEAR`).
141
+ *
142
+ * Plain Node, zero dependencies: the hook starts in someone else's process and cannot pull
143
+ * `node_modules` or wait for imports from the Rarog repo to resolve. Claude Code runs a
144
+ * COPY of this file from `~/.claude/hooks/rarog/` (made by `pnpm run hooks:install`, together
145
+ * with `tall-dialog.mjs`, `canon.mjs`, `consent.mjs` and `work-area.mjs`), so the imports are only `node:`,
146
+ * `./tall-dialog.mjs`, `./canon.mjs`, `./consent.mjs` and `./work-area.mjs`, all modules dynamically in `try`:
147
+ * `server/test/hook-granica-guard.test.ts` checks this.
148
+ */
149
+ import { createHash, randomBytes } from 'node:crypto';
150
+ import {
151
+ appendFileSync, lstatSync, mkdirSync, readFileSync, renameSync,
152
+ rmdirSync, statSync, unlinkSync, writeFileSync, writeSync,
153
+ } from 'node:fs';
154
+ import { homedir } from 'node:os';
155
+ import { basename, dirname, join, relative, sep } from 'node:path';
156
+ import { fileURLToPath } from 'node:url';
157
+
158
+ /** The same pattern as `ENGINE_SESSION_ID_PATTERN` on the server side (transcript-import.ts). */
159
+ const SESSION_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/;
160
+
161
+ /** The only tool we take `PreToolUse` for: see the header. */
162
+ const QUESTION_TOOL = 'AskUserQuestion';
163
+
164
+ /** Name of the file with Rarog's roots: MUST match `HOOK_ROOTS_FILENAME` in the server. */
165
+ const ROOTS_FILE = 'roots.json';
166
+
167
+ /** The "hook is alive" marker: MUST match `HOOK_SEEN_FILENAME` in the server. */
168
+ const SEEN_FILE = 'hook-seen.json';
169
+
170
+ /**
171
+ * Marker PER ENTRY FILE: `hook-seen.<file name without .mjs>.json` next to the shared one. The same code
172
+ * lies in the copy under both file names, so the server and doctor see which command Claude Code
173
+ * calls. The name shape MUST match `HOOK_SEEN_PER_FILE_RE` in the server; a file outside the pattern writes no
174
+ * per-file marker.
175
+ */
176
+ const SEEN_PER_FILE = (() => {
177
+ const stem = basename(fileURLToPath(import.meta.url)).replace(/\.mjs$/, '');
178
+ return /^[a-z][a-z0-9-]{0,63}$/.test(stem) ? `hook-seen.${stem}.json` : null;
179
+ })();
180
+
181
+ /** Directory of answer files: MUST match `HOOK_ANSWERS_DIRNAME` in the server. */
182
+ const ANSWERS_DIR = 'answers';
183
+
184
+ /** The event in which (and only in which) the hook waits for an answer from Rarog. */
185
+ const PERMISSION_REQUEST_EVENT = 'PermissionRequest';
186
+
187
+ /**
188
+ * Environment variable with the CLI session entry point: MUST match `HOOK_PROGRAMMATIC_ENTRYPOINT.env`
189
+ * in the contract. See the header, "PROGRAMMATIC SESSIONS".
190
+ */
191
+ const ENTRYPOINT_ENV = 'CLAUDE_CODE_ENTRYPOINT';
192
+
193
+ /** Programmatic session values at which the hook does nothing: `HOOK_PROGRAMMATIC_ENTRYPOINT.values`. */
194
+ const PROGRAMMATIC_ENTRYPOINTS = new Set(['sdk-cli', 'sdk-ts', 'sdk-py']);
195
+
196
+ /** The only tool whose dialog the tall dialog guard watches. */
197
+ const GUARD_TOOL = 'Bash';
198
+
199
+ /**
200
+ * Guard refusal log: MUST match `HOOK_GUARD_LOG_FILENAME` in the server. The hook only
201
+ * APPENDS; the server rotates it (`.1` at 1 MB) at start, in one process: two parallel
202
+ * hooks rotating the same file could overwrite `.1` with one entry.
203
+ */
204
+ const GUARD_LOG_FILE = 'guard.jsonl';
205
+
206
+ /**
207
+ * Poll interval of the answer file, the shadow file and `alive.json`: MUST match `HOOK_POLL_MS`
208
+ * in the contract. Shorter = more `stat` for nothing, longer = a sluggish card and a slower release.
209
+ */
210
+ const ANSWER_POLL_MS = 250;
211
+
212
+ /** Server life file: MUST match `HOOK_ALIVE_FILENAME` in the contract. The hook only reads it. */
213
+ const ALIVE_FILE = 'alive.json';
214
+
215
+ /** Age of `ts` in `alive.json` (both ways of the clock) above which the hook does not wait: `HOOK_ALIVE_MAX_AGE_MS`. */
216
+ const ALIVE_MAX_AGE_MS = 30000;
217
+
218
+ /** Consent channel modes from `alive.json`: MUST match `HOOK_ALIVE_MODES` in the contract. */
219
+ const MODE_OFF = 'off';
220
+ const MODE_SHADOW = 'shadow';
221
+ const MODE_MAIN = 'main';
222
+ const MODE_ALL = 'all';
223
+
224
+ /** All modes this hook version knows. Any other string in `mode` = `tryb-nieznany`. */
225
+ const ALIVE_MODES = new Set([MODE_OFF, MODE_SHADOW, MODE_MAIN, MODE_ALL]);
226
+
227
+ /** Directory of shadow files: MUST match `HOOK_SHADOW_DIRNAME` in the contract. The server writes them. */
228
+ const SHADOW_DIR = 'shadow';
229
+
230
+ /** Shadow file suffixes: claimed by the hook and revoked by the server (`HOOK_SHADOW_*_SUFFIX`). */
231
+ const CLAIMED_SUFFIX = '.claimed';
232
+ const REVOKED_SUFFIX = '.revoked';
233
+
234
+ /**
235
+ * Shadow mode cycle log: MUST match `HOOK_SHADOW_LOG_FILENAME` in the contract. The hook only
236
+ * APPENDS, like `guard.jsonl`; rotation belongs to the server.
237
+ */
238
+ const SHADOW_LOG_FILE = 'shadow.jsonl';
239
+
240
+ /** Per-call key nonce IN BYTES (32 hex characters): `HOOK_CALL_NONCE_BYTES` in the contract. */
241
+ const CALL_NONCE_BYTES = 16;
242
+
243
+ /**
244
+ * Directory of request markers (header, "REQUEST MARKER"): MUST match `HOOK_MARKERS_DIRNAME` in the contract.
245
+ * The hook only writes, never deletes; the server cleans up.
246
+ */
247
+ const MARKERS_DIR = 'markers';
248
+
249
+ /** Prefix of a marker name without a key, `anon-<pid>-<startedAt>`: `HOOK_MARKER_ANON_PREFIX` in the contract. */
250
+ const MARKER_ANON_PREFIX = 'anon-';
251
+
252
+ /** Tool name in a `shadow.jsonl` line: the same pattern as the server's dump reader, otherwise `?`. */
253
+ const TOOL_NAME_PATTERN = /^[A-Za-z][A-Za-z0-9_.:-]{0,127}$/;
254
+
255
+ /** Process start (epoch ms): with the PID in the per-call dump it tells this process from a reused PID. */
256
+ const PROCESS_STARTED_AT = Date.now() - Math.round(process.uptime() * 1000);
257
+
258
+ /**
259
+ * Cap on ONE value in `answers`: the third and last length gate of free text.
260
+ *
261
+ * Rarog cuts at `MAX_ANSWER_TEXT_CHARS` (2000 characters per value) in the body schema and in the manager;
262
+ * here the cap is looser, because a multiple choice joins several values with a comma, and the hook
263
+ * does not know how many there were. It follows the same principle as `TOOL_INPUT_MAX_BYTES`: a value that
264
+ * grew beyond any real case must not leave the hook for the model. Exceeding it =
265
+ * REJECTING the file (fail-closed), not cutting: a cut human answer is a different answer.
266
+ */
267
+ const ANSWER_VALUE_MAX_CHARS = 8 * 1024;
268
+
269
+ /**
270
+ * Cap on ONE note in `annotations`: Rarog's cap, unmeasured in the CLI. MUST match
271
+ * `MAX_ANSWER_NOTE_CHARS` from `shared/src/rest.ts`. Exceeding it = REJECTING the file, not
272
+ * cutting (as with `answers`).
273
+ */
274
+ const ANSWER_NOTE_MAX_CHARS = 8192;
275
+
276
+ /**
277
+ * Cap on the SUM of answers and notes in UTF-16 units (`string.length`): Rarog's cap,
278
+ * unmeasured in the CLI. MUST match `MAX_ANSWERS_TOTAL_CHARS` from `shared/src/rest.ts`.
279
+ */
280
+ const ANSWERS_TOTAL_MAX_CHARS = 32768;
281
+
282
+ /**
283
+ * Default wait cap IN SECONDS: used when the command has no `--answer-wait`.
284
+ *
285
+ * MUST match `HOOK_ANSWER_WAIT_S` from `server/src/herdr/hook-config.ts` (86 400 − 2, a day). The value
286
+ * from the registration takes precedence over this constant, so it comes as an argument: a hook waiting longer
287
+ * than its `timeout` allows is killed silently and has no way to report it.
288
+ */
289
+ const ANSWER_WAIT_DEFAULT_S = 86_398;
290
+
291
+ /**
292
+ * Ceiling of the serialized `tool_input` in UTF-8 bytes (`HOOK_TOOL_INPUT_MAX_BYTES` in the server's hook contract).
293
+ * A `Write` or `Edit` input can be a whole file and `ExitPlanMode` a whole plan. Over it every dump carries the
294
+ * truncation marker, never an exception: a card that says it shows a fragment beats no card.
295
+ */
296
+ const TOOL_INPUT_MAX_BYTES = 1024 * 1024;
297
+
298
+ /** Ceiling of the marker's `preview` in UTF-8 bytes: enough to show the card is a fragment, small on disk. */
299
+ const TRUNCATED_PREVIEW_MAX_BYTES = 64 * 1024;
300
+
301
+ /** Cap on the stdin payload alone: above it we give up, because it would be truncated anyway. */
302
+ const STDIN_MAX_BYTES = 4 * 1024 * 1024;
303
+
304
+ /** Entry kind by `lstat` (a symlink is NOT a directory); an error other than ENOENT propagates. */
305
+ function entryKind(target) {
306
+ let stats;
307
+ try {
308
+ stats = lstatSync(target);
309
+ } catch (err) {
310
+ if (err !== null && typeof err === 'object' && err.code === 'ENOENT') return 'missing';
311
+ throw err;
312
+ }
313
+ if (stats.isSymbolicLink()) return 'link';
314
+ if (stats.isDirectory()) return 'dir';
315
+ return 'other';
316
+ }
317
+
318
+ /**
319
+ * Data directory: MUST match the server's `dataDir`, because the reader (`server/src/herdr/pending-hook.ts`) looks
320
+ * exactly there. It is THE SAME rule as `resolveDataDir` from `shared/src/data-dir.mjs`,
321
+ * rewritten without an import: the hook serves every Claude session on this Mac, and a silent import error would
322
+ * disable all cards without a trace in `/health` (the same principle as for the tall dialog guard below). The parity
323
+ * test `server/test/data-dir.test.ts` checks the equality (this hook in a subprocess on the module's state matrix).
324
+ *
325
+ * Non-empty `RAROG_DATA_DIR` → that path; base = `XDG_DATA_HOME` or `~/.local/share`; `<base>/rarog` missing, a
326
+ * directory or a symlink to a directory → `<base>/rarog`. Any other state and any read error → `null`: the hook stays
327
+ * silent and WRITES NOTHING, because the server does not start in this state, and a write in a guessed directory
328
+ * would create it anew.
329
+ */
330
+ function dataDir() {
331
+ const explicit = process.env['RAROG_DATA_DIR'];
332
+ if (explicit !== undefined && explicit !== '') return explicit;
333
+ const xdg = process.env['XDG_DATA_HOME'];
334
+ try {
335
+ const base = xdg !== undefined && xdg !== '' ? xdg : join(homedir(), '.local', 'share');
336
+ const defaultDir = join(base, 'rarog');
337
+ const current = entryKind(defaultDir);
338
+ if (current === 'other') return null;
339
+ // The symlink must lead to a directory; no target = `null`, a loop throws (ELOOP) = `null`.
340
+ if (current === 'link' && !statSync(defaultDir, { throwIfNoEntry: false })?.isDirectory()) return null;
341
+ return defaultDir;
342
+ } catch {
343
+ return null;
344
+ }
345
+ }
346
+
347
+ /** Reads all of stdin. Returns `''` when there is no stream or it broke off with an error. */
348
+ async function readStdin() {
349
+ const chunks = [];
350
+ let size = 0;
351
+ try {
352
+ for await (const chunk of process.stdin) {
353
+ size += chunk.length;
354
+ if (size > STDIN_MAX_BYTES) return '';
355
+ chunks.push(chunk);
356
+ }
357
+ } catch {
358
+ return '';
359
+ }
360
+ return Buffer.concat(chunks).toString('utf8');
361
+ }
362
+
363
+ /**
364
+ * Rarog's roots from `<dataDir>/roots.json` (`{"roots": ["/abs/…"], "exclude"?: […], "tallDialogGuard"?: true}`).
365
+ *
366
+ * `null` means "unknown" and equals a write ban: there is no file (the server never
367
+ * started or writes to another `dataDir`), broken JSON, an empty list. `tallDialogGuard` is
368
+ * on ONLY with a literal `true`: the server writes the field from the `RAROG_TALL_DIALOG_GUARD` flag,
369
+ * and its absence (a server without the field, flag `0`) means "no guard".
370
+ * `exclude`: absent = a server from before, roots only. When present it must be a list of absolute paths;
371
+ * anything else (`null`, a string, one bad entry) gives `null` as well, because a broken field must not widen the area.
372
+ */
373
+ function rarogRoots(dir) {
374
+ let parsed;
375
+ try {
376
+ parsed = JSON.parse(readFileSync(join(dir, ROOTS_FILE), 'utf8'));
377
+ } catch {
378
+ return null;
379
+ }
380
+ if (parsed === null || typeof parsed !== 'object') return null;
381
+ const raw = parsed['roots'];
382
+ if (!Array.isArray(raw)) return null;
383
+ const roots = raw.filter((entry) => typeof entry === 'string' && entry !== '');
384
+ const hasExclude = Object.hasOwn(parsed, 'exclude');
385
+ const exclude = hasExclude ? parsed['exclude'] : null;
386
+ if (hasExclude && !(Array.isArray(exclude) && exclude.every((entry) => typeof entry === 'string'
387
+ && entry.startsWith(sep)))) return null;
388
+ return roots.length === 0 ? null : { roots, exclude, tallDialogGuard: parsed['tallDialogGuard'] === true };
389
+ }
390
+
391
+ /**
392
+ * The `cwd` filter of the header: `insideRoots` of `work-area.mjs`, loaded dynamically like the other
393
+ * modules of the copy. A missing or broken module means `false`, so the hook does nothing, as for a `cwd` outside.
394
+ */
395
+ async function insideRoots(cwd, config) {
396
+ try {
397
+ const area = await import(new URL('./work-area.mjs', import.meta.url).href);
398
+ return area.insideRoots(cwd, config.roots, config.exclude) === true;
399
+ } catch {
400
+ return false;
401
+ }
402
+ }
403
+
404
+ /**
405
+ * `tool_input` in a form fit for writing: either the original or a truncation marker.
406
+ *
407
+ * The marker is READABLE for a human (it goes to the card literally), not a silent cut:
408
+ * the user must see they are looking at a fragment.
409
+ */
410
+ function cappedToolInput(toolInput) {
411
+ let serialized;
412
+ try {
413
+ serialized = JSON.stringify(toolInput ?? null);
414
+ } catch {
415
+ // A cycle or a `toJSON` that throws: we have nothing to write, but the tool name stays.
416
+ return { rarogTruncated: true, preview: '' };
417
+ }
418
+ if (serialized === undefined) return { rarogTruncated: true, preview: '' };
419
+ if (Buffer.byteLength(serialized, 'utf8') <= TOOL_INPUT_MAX_BYTES) return toolInput ?? null;
420
+ return {
421
+ rarogTruncated: true,
422
+ /*
423
+ * Cut on BYTES, the measure of the ceilings. A cut on characters
424
+ * (`serialized.slice(0, TRUNCATED_PREVIEW_MAX_BYTES)`) would not keep the ceiling: in UTF-8 one character is
425
+ * 1–4 bytes, so a plan in Polish or a diff with emoji would grow to ~256 kB at a 64 kB ceiling.
426
+ *
427
+ * `TextDecoder` with `stream: true` HOLDS BACK a sequence cut at the end instead of turning
428
+ * it into `U+FFFD`: the replacement character takes 3 bytes, so a plain `toString` could
429
+ * go over the very ceiling we cut at.
430
+ */
431
+ preview: new TextDecoder('utf-8').decode(
432
+ Buffer.from(serialized, 'utf8').subarray(0, TRUNCATED_PREVIEW_MAX_BYTES), { stream: true },
433
+ ),
434
+ };
435
+ }
436
+
437
+ /**
438
+ * Data directory this process writes in (`main` sets it after reading the roots). The hook does NOT create it: the
439
+ * server does, and `roots.json` in it is the condition of every write.
440
+ */
441
+ let dataRoot = null;
442
+
443
+ /**
444
+ * Write directory under the data directory, WITHOUT `recursive`: the data directory itself must already exist, and
445
+ * the subdirectories (`pending/`, `pending/<session>/`) are created one segment at a time. A hook that read the roots
446
+ * before a `mv` of the data directory gets ENOENT and stays silent, instead of recreating the old directory next to
447
+ * the moved one. A directory outside the data directory is an error, not a write.
448
+ */
449
+ function ensureDir(dir) {
450
+ if (dataRoot === null) throw new Error('data directory not set');
451
+ const rel = relative(dataRoot, dir);
452
+ if (rel === '') return;
453
+ if (rel === '..' || rel.startsWith(`..${sep}`) || rel.startsWith(sep)) {
454
+ throw new Error('write directory outside the data directory');
455
+ }
456
+ let current = dataRoot;
457
+ for (const part of rel.split(sep)) {
458
+ current = join(current, part);
459
+ try {
460
+ mkdirSync(current, { mode: 0o700 });
461
+ } catch (err) {
462
+ if (err === null || typeof err !== 'object' || err.code !== 'EEXIST') throw err;
463
+ }
464
+ }
465
+ }
466
+
467
+ /** Atomic write: tmp in THE SAME directory + rename. The reader never sees half a file. */
468
+ function writeAtomic(dir, file, body) {
469
+ ensureDir(dir);
470
+ // Random suffix and `wx`: under a predictable name `<file>.<pid>.tmp` a symlink could redirect the write, and
471
+ // `rename` would put it in place of the dump. An existing name, symlink included, is an error, not a write through
472
+ // it.
473
+ const tmp = `${file}.${randomBytes(8).toString('hex')}.tmp`;
474
+ try {
475
+ writeFileSync(tmp, body, { mode: 0o600, flag: 'wx' });
476
+ renameSync(tmp, file);
477
+ } catch (err) {
478
+ try {
479
+ unlinkSync(tmp);
480
+ } catch {
481
+ // Best-effort cleanup: a tmp without rename is not seen by the reader anyway.
482
+ }
483
+ throw err;
484
+ }
485
+ }
486
+
487
+ /**
488
+ * The "hook is alive" marker: the only trace by which `/health` and `hooks:doctor` know that the hook
489
+ * is INSTALLED AND FIRES, not only listed in the settings file.
490
+ *
491
+ * A separate file, because the dump itself is DELETED after a decision from Rarog (`clearPendingHook`): counting
492
+ * the age from the content of `pending/` would say "never" in exactly those sessions where the hook
493
+ * works best.
494
+ *
495
+ * Next to the shared marker the same content goes to the per-entry-file marker ({@link SEEN_PER_FILE}).
496
+ */
497
+ function markSeen(dir, event, toolName) {
498
+ const body = `${JSON.stringify({ at: Date.now(), event, toolName })}\n`;
499
+ writeAtomic(dir, join(dir, SEEN_FILE), body);
500
+ if (SEEN_PER_FILE === null) return;
501
+ try {
502
+ writeAtomic(dir, join(dir, SEEN_PER_FILE), body);
503
+ } catch {
504
+ // The per-file marker is diagnostics: its error does not change the hook's course.
505
+ }
506
+ }
507
+
508
+ /** Guard budget sources: MUST match `BUDGET_SOURCES` from `tall-dialog.mjs` (a test checks). */
509
+ const BUDGET_SOURCES = new Set(['pane', 'phone', 'floor']);
510
+
511
+ /** Pane dimension in the log and dump field: a positive integer (the module caps it at 1000). */
512
+ const isDimension = (value) => Number.isInteger(value) && value > 0;
513
+
514
+ /**
515
+ * Guard fields for the log and the dump: the budget source and the pane geometry, when it was valid.
516
+ * `null` = the module's result does not have a shape we know (then as without the guard).
517
+ */
518
+ function guardFields(budget) {
519
+ if (budget === null || typeof budget !== 'object' || !BUDGET_SOURCES.has(budget.source)) return null;
520
+ const known = isDimension(budget.paneRows) && isDimension(budget.paneCols);
521
+ return {
522
+ budgetSource: budget.source,
523
+ ...(known ? { paneRows: budget.paneRows, paneCols: budget.paneCols } : {}),
524
+ };
525
+ }
526
+
527
+ /**
528
+ * Result of the tall dialog guard: the verdict (`null` = the dialog fits) and the fields for the log or the dump.
529
+ * The whole `null` means "behave as without the guard".
530
+ *
531
+ * We load the estimate module DYNAMICALLY and only here: a broken or missing `tall-dialog.mjs`
532
+ * must not knock over a hook that serves every Claude session on this Mac. Every exception
533
+ * (import, estimate, result shape) gives `null`. The module reads and checks the geometry (`COLUMNS`, `LINES`):
534
+ * the hook passes the raw strings from the environment, without a spawn and without the herdr socket.
535
+ */
536
+ async function tallDialogGuard(toolInput, columns, lines) {
537
+ try {
538
+ const guard = await import(new URL('./tall-dialog.mjs', import.meta.url).href);
539
+ const pane = guard.paneFromEnv(columns, lines);
540
+ const fields = guardFields(guard.dialogBudget(pane));
541
+ if (fields === null) return null;
542
+ const verdict = guard.tallDialogVerdict(toolInput, pane);
543
+ if (verdict === null) return { verdict: null, fields };
544
+ if (typeof verdict !== 'object') return null;
545
+ if (typeof verdict.message !== 'string' || verdict.message === '') return null;
546
+ return { verdict, fields };
547
+ } catch {
548
+ return null;
549
+ }
550
+ }
551
+
552
+ /**
553
+ * Guard log line: numbers, never the command or description content, so that the lines can be summed.
554
+ * One write with the `a` flag (`O_APPEND`): parallel hooks append short lines without overwriting
555
+ * each other. Best-effort: an exception goes back to the caller, which swallows it.
556
+ */
557
+ function appendGuardLog(dir, entry) {
558
+ ensureDir(dir);
559
+ appendFileSync(join(dir, GUARD_LOG_FILE), `${JSON.stringify(entry)}\n`, { mode: 0o600, flag: 'a' });
560
+ }
561
+
562
+ /**
563
+ * Nonce length IN BYTES (16 hex characters in the key): see the header, section NONCE.
564
+ *
565
+ * The key is a FILE NAME and enters `ANSWER_KEY_PATTERN` on Rarog's side (`server/src/herdr/answers.ts`, cap 192
566
+ * characters): `prompt_id` (up to 128) + `-` + 16 characters of digest + `-` + 16 characters of nonce is at most 162
567
+ * characters, so it fits with a margin. Hex, because only letters and digits: base64 would bring `/` and `+` into the
568
+ * file name.
569
+ */
570
+ const ANSWER_NONCE_BYTES = 8;
571
+
572
+ /**
573
+ * Answer file key: `<prompt_id>-<sha256(questions) to 16 characters>-<nonce>`: see the header.
574
+ *
575
+ * `null` means "this question cannot be addressed" (no `prompt_id`, a shape from somewhere
576
+ * else, a cycle in `tool_input`) and equals having no answer channel: the dump is made
577
+ * the usual way, the hook does not wait, the decision comes from a digit.
578
+ */
579
+ function answerKeyFor(promptId, toolInput) {
580
+ if (typeof promptId !== 'string' || !SESSION_ID_PATTERN.test(promptId)) return null;
581
+ const questions = toolInput === null || typeof toolInput !== 'object'
582
+ ? undefined
583
+ : toolInput['questions'];
584
+ let serialized;
585
+ try {
586
+ serialized = JSON.stringify(questions ?? null);
587
+ } catch {
588
+ return null;
589
+ }
590
+ if (serialized === undefined) return null;
591
+ const digest = createHash('sha256').update(serialized, 'utf8').digest('hex').slice(0, 16);
592
+ // Nonce computed ON EVERY hook call: two identical questions of one turn (and the same
593
+ // question repeated) have different keys, so the answer file reaches ONE process.
594
+ return `${promptId}-${digest}-${randomBytes(ANSWER_NONCE_BYTES).toString('hex')}`;
595
+ }
596
+
597
+ /**
598
+ * Answers from Rarog's file, or `null` (no file, it does not match, it is stale).
599
+ *
600
+ * There are three conditions and all must hold: the file is about THIS session, THIS key (that is this
601
+ * `prompt_id` and this question content), and it was made NO EARLIER than the dump it answers.
602
+ * The last condition cuts off an answer that stayed in the directory after the PREVIOUS question: Rarog
603
+ * deletes it itself, but its process could have vanished between the write and the cleanup.
604
+ *
605
+ * Values must be strings; the CLI does not validate them against `options[].label`,
606
+ * so free text goes literally to the model, and that is intended, but not ARBITRARILY long:
607
+ * a value over `ANSWER_VALUE_MAX_CHARS` rejects the WHOLE file, because the hook must not give the model
608
+ * an answer nobody measured (cutting would change the content, and that is a different answer).
609
+ *
610
+ * The file can carry NOTES (`annotations`): see {@link readAnnotations}. Any error in the
611
+ * notes rejects the WHOLE file: an answer without a note the human wrote would be a different
612
+ * answer, and Rarog then does not fall back to a digit (an explicit refusal on its side).
613
+ *
614
+ * @returns `{ answers, annotations }` (`annotations` = `null` when the file carries none) or `null`
615
+ */
616
+ function readAnswers(file, sessionId, key, notBefore, toolInput) {
617
+ let parsed;
618
+ try {
619
+ parsed = JSON.parse(readFileSync(file, 'utf8'));
620
+ } catch {
621
+ return null;
622
+ }
623
+ if (parsed === null || typeof parsed !== 'object') return null;
624
+ if (parsed['sessionId'] !== sessionId) return null;
625
+ if (parsed['key'] !== key) return null;
626
+ const at = parsed['at'];
627
+ if (typeof at !== 'number' || !Number.isFinite(at) || at < notBefore) return null;
628
+ const answers = parsed['answers'];
629
+ if (answers === null || typeof answers !== 'object' || Array.isArray(answers)) return null;
630
+ // Dictionaries WITHOUT a prototype: the key is the question text from the author, and `out['__proto__'] = …` on
631
+ // a plain object would reset the prototype instead of adding an answer.
632
+ const out = Object.create(null);
633
+ let total = 0;
634
+ for (const [question, value] of Object.entries(answers)) {
635
+ if (question === '' || typeof value !== 'string') return null;
636
+ if (value.length > ANSWER_VALUE_MAX_CHARS) return null;
637
+ out[question] = value;
638
+ total += value.length;
639
+ }
640
+ if (Object.keys(out).length === 0) return null;
641
+ const annotations = readAnnotations(parsed['annotations'], out, toolInput);
642
+ if (annotations === undefined) return null;
643
+ for (const entry of Object.values(annotations ?? {})) total += entry.notes?.length ?? 0;
644
+ if (total > ANSWERS_TOTAL_MAX_CHARS) return null;
645
+ return { answers: out, annotations };
646
+ }
647
+
648
+ /**
649
+ * Option previews of each question from `tool_input` (`question text → set of previews`).
650
+ * An empty set = a question without a preview; no key = there is no such question in the call.
651
+ */
652
+ function previewsByQuestion(toolInput) {
653
+ const out = new Map();
654
+ const questions = toolInput === null || typeof toolInput !== 'object'
655
+ ? undefined
656
+ : toolInput['questions'];
657
+ if (!Array.isArray(questions)) return out;
658
+ for (const item of questions) {
659
+ if (item === null || typeof item !== 'object' || typeof item['question'] !== 'string') continue;
660
+ const previews = new Set();
661
+ for (const option of Array.isArray(item['options']) ? item['options'] : []) {
662
+ const preview = option === null || typeof option !== 'object' ? undefined : option['preview'];
663
+ if (typeof preview === 'string' && preview !== '') previews.add(preview);
664
+ }
665
+ out.set(item['question'], previews);
666
+ }
667
+ return out;
668
+ }
669
+
670
+ /**
671
+ * NOTES to the answer: the `annotations` field of Rarog's file, handed to the CLI in
672
+ * `updatedInput.annotations`. We check the shape and caps HERE, because this is a file from outside the CLI process,
673
+ * and the CLI does not check the preview on the hook path (a cut preview passes):
674
+ *
675
+ * - the key is the LITERAL text of the question from `tool_input` the file answers;
676
+ * - the value has only `notes` (non-empty text ≤ `ANSWER_NOTE_MAX_CHARS`) and/or `preview`
677
+ * (LITERALLY one of the option previews of this question: the CLI gives it to the model as `selected preview`);
678
+ * - a question that already carries `annotations` in `tool_input` is rejected (Rarog does not overwrite a field it did
679
+ * not write).
680
+ *
681
+ * @returns `null` = the file carries no notes; an object = notes to hand over; `undefined` = the file is
682
+ * bad, reject it WHOLE (fail-closed)
683
+ */
684
+ function readAnnotations(raw, answers, toolInput) {
685
+ if (raw === undefined) return null;
686
+ if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) return undefined;
687
+ if (toolInput !== null && typeof toolInput === 'object' && Object.hasOwn(toolInput, 'annotations')) {
688
+ return undefined;
689
+ }
690
+ const previews = previewsByQuestion(toolInput);
691
+ const out = Object.create(null);
692
+ for (const [question, value] of Object.entries(raw)) {
693
+ if (!Object.hasOwn(answers, question)) return undefined;
694
+ const allowed = previews.get(question);
695
+ if (allowed === undefined) return undefined;
696
+ if (value === null || typeof value !== 'object' || Array.isArray(value)) return undefined;
697
+ if (Object.keys(value).some((field) => field !== 'notes' && field !== 'preview')) return undefined;
698
+ const entry = {};
699
+ if (Object.hasOwn(value, 'notes')) {
700
+ const notes = value['notes'];
701
+ if (typeof notes !== 'string' || notes === '' || notes.length > ANSWER_NOTE_MAX_CHARS) return undefined;
702
+ entry.notes = notes;
703
+ }
704
+ if (Object.hasOwn(value, 'preview')) {
705
+ const preview = value['preview'];
706
+ if (typeof preview !== 'string' || !allowed.has(preview)) return undefined;
707
+ entry.preview = preview;
708
+ }
709
+ if (Object.keys(entry).length === 0) return undefined;
710
+ out[question] = entry;
711
+ }
712
+ return Object.keys(out).length === 0 ? null : out;
713
+ }
714
+
715
+ /**
716
+ * Is the dump in `pending/` STILL our dialog?
717
+ *
718
+ * Without this condition the hook would wait up to the `--answer-wait` cap (a day) also when the question was settled
719
+ * long ago at the desk: the CLI then leaves the process alive and only ignores its late `allow`
720
+ * (measured on 2.1.314). The dump is the only signal the hook has access to: Rarog deletes it after
721
+ * the decision is sent, and the next dialog in this session overwrites it. Another key or no file =
722
+ * we end silently, exactly as after a timeout.
723
+ *
724
+ * Fail-OPEN on a read error (`true`): a single failed `read` must not take the answer channel
725
+ * from the human: the time cap is there for closing.
726
+ */
727
+ function dumpStillMine(dir, sessionId, key) {
728
+ let parsed;
729
+ try {
730
+ parsed = JSON.parse(readFileSync(join(dir, 'pending', `${sessionId}.json`), 'utf8'));
731
+ } catch (err) {
732
+ return err?.code !== 'ENOENT';
733
+ }
734
+ return parsed !== null && typeof parsed === 'object' && parsed['answerKey'] === key;
735
+ }
736
+
737
+ /** Wait cap in milliseconds: `--answer-wait=<seconds>` from the registration, or the default. */
738
+ function answerWaitMs(argv) {
739
+ const arg = argv.find((entry) => entry.startsWith('--answer-wait='));
740
+ const raw = arg === undefined ? Number.NaN : Number(arg.slice('--answer-wait='.length));
741
+ const seconds = Number.isFinite(raw) && raw >= 0 ? raw : ANSWER_WAIT_DEFAULT_S;
742
+ return Math.round(seconds * 1000);
743
+ }
744
+
745
+ /**
746
+ * Waits for an answer from Rarog and returns it (deleting the file), or `null` after the cap.
747
+ *
748
+ * We delete the file AFTER reading and before returning `allow`: if it stayed, it would act on the
749
+ * NEXT question of the same turn. A failed delete does not overturn the answer: Rarog
750
+ * cleans the directory independently (the reaper at server start).
751
+ */
752
+ async function waitForAnswers(dir, sessionId, key, notBefore, waitMs, toolInput) {
753
+ const file = join(dir, ANSWERS_DIR, sessionId, `${key}.json`);
754
+ const deadline = Date.now() + waitMs;
755
+ for (;;) {
756
+ const answers = readAnswers(file, sessionId, key, notBefore, toolInput);
757
+ if (answers !== null) {
758
+ try {
759
+ unlinkSync(file);
760
+ } catch {
761
+ // Best-effort cleanup: the answer is already read.
762
+ }
763
+ return answers;
764
+ }
765
+ if (Date.now() >= deadline) return null;
766
+ if (!dumpStillMine(dir, sessionId, key)) return null;
767
+ await new Promise((resolve) => setTimeout(resolve, ANSWER_POLL_MS));
768
+ }
769
+ }
770
+
771
+ /**
772
+ * State of ONE shadow mode cycle (process = one request, so one cycle per process): `null` outside a
773
+ * `PermissionRequest` for a tool. `finish` is the cycle's only exit: it cleans up the per-call dump
774
+ * and appends `wyjscie`, once.
775
+ */
776
+ let cycle = null;
777
+
778
+ /** Milliseconds since the hook process start (the `ms` field in `shadow.jsonl`). */
779
+ const elapsedMs = () => Math.max(0, Date.now() - PROCESS_STARTED_AT);
780
+
781
+ /**
782
+ * A `shadow.jsonl` line: identifiers, reasons and numbers, never the `tool_input` content. One write with the `a`
783
+ * flag (`O_APPEND`), like `guard.jsonl`. Best-effort: the log is diagnostics, a write error stops nothing.
784
+ */
785
+ function shadowLog(ev, fields = {}) {
786
+ if (cycle === null) return;
787
+ try {
788
+ ensureDir(cycle.dir);
789
+ appendFileSync(join(cycle.dir, SHADOW_LOG_FILE), `${JSON.stringify({
790
+ at: Date.now(), ev, pid: process.pid, sessionId: cycle.sessionId,
791
+ ...(cycle.key === null ? {} : { key: cycle.key }),
792
+ ...fields,
793
+ })}\n`, { mode: 0o600, flag: 'a' });
794
+ } catch {
795
+ // Diagnostics: the cycle goes on without the line.
796
+ }
797
+ }
798
+
799
+ /**
800
+ * Signal (SIGTERM on Esc in the main thread, on the hook timeout, on `ctrl+x ctrl+k`): a `sygnal` line,
801
+ * cleanup of the per-call dump, exit 0 without a result. Registered only for the shadow mode cycle, so
802
+ * the question's answer channel keeps its own reaction to a signal.
803
+ */
804
+ function onSignal(signal) {
805
+ if (cycle !== null && !cycle.done) {
806
+ shadowLog('sygnal', { sygnal: signal, ms: elapsedMs() });
807
+ finishCycle('sygnal');
808
+ }
809
+ process.exit(0);
810
+ }
811
+
812
+ function startCycle(dir, sessionId, fields) {
813
+ cycle = { dir, sessionId, key: null, dumpFile: null, waited: false, done: false };
814
+ for (const signal of ['SIGTERM', 'SIGINT', 'SIGHUP']) process.on(signal, () => { onSignal(signal); });
815
+ shadowLog('start', fields);
816
+ }
817
+
818
+ /**
819
+ * The cycle's only exit: the per-call dump disappears (best effort), `wyjscie` with the reason and time. Idempotent.
820
+ * `alive` = `{bootId, aliveTs}` of the file that gave the veto (shadow audit: time from a flag change to the exit).
821
+ */
822
+ function finishCycle(powod, alive = {}) {
823
+ if (cycle === null || cycle.done) return;
824
+ cycle.done = true;
825
+ removeCallDump(cycle.dumpFile);
826
+ shadowLog('wyjscie', { powod, ms: elapsedMs(), czekal: cycle.waited, ...alive });
827
+ }
828
+
829
+ /**
830
+ * Exit without waiting: `bez-czekania` with the reason (and the `extra` fields, e.g. `szczegol` of a registration
831
+ * refusal), then `wyjscie` with the same reason.
832
+ */
833
+ function skipWaiting(powod, alive = {}, extra = {}) {
834
+ shadowLog('bez-czekania', { powod, ...extra });
835
+ finishCycle(powod, alive);
836
+ }
837
+
838
+ /**
839
+ * Per-call key: `<prompt_id>-<nonce 16 B hex>`. The nonce is uninterpreted and drawn ON EVERY
840
+ * call, so two identical requests of one turn (the same `prompt_id`, the same input) have different keys.
841
+ * The hook calls this function ONCE, in {@link main}: the request marker, the per-call dump and the consent channel
842
+ * registration carry the same key. `null` = `prompt_id` is not fit for a file name: no per-call dump and no waiting.
843
+ */
844
+ function callKeyFor(promptId) {
845
+ if (typeof promptId !== 'string' || !SESSION_ID_PATTERN.test(promptId)) return null;
846
+ return `${promptId}-${randomBytes(CALL_NONCE_BYTES).toString('hex')}`;
847
+ }
848
+
849
+ /**
850
+ * Full sha256 of the canonical `tool_input`, or `null`. The module is loaded DYNAMICALLY, like the tall dialog guard:
851
+ * a missing or broken `canon.mjs` (a copy installed without it, an exception on a deep input) means "no per-call
852
+ * dump and no waiting", not a knocked-over hook.
853
+ */
854
+ async function inputDigest(toolInput) {
855
+ try {
856
+ const canon = await import(new URL('./canon.mjs', import.meta.url).href);
857
+ const digest = canon.canonicalSha256(toolInput ?? null);
858
+ return typeof digest === 'string' && /^[0-9a-f]{64}$/.test(digest) ? digest : null;
859
+ } catch {
860
+ return null;
861
+ }
862
+ }
863
+
864
+ /**
865
+ * Writes the per-call dump and the request marker. A parallel hook of this session deletes the empty directory
866
+ * `pending/<session>/` on exit (and the server may remove an empty `markers/<session>/`), so between `mkdir` and the
867
+ * write the directory may vanish (ENOENT): one retry.
868
+ */
869
+ function writeCallDump(dumpDir, file, body) {
870
+ try {
871
+ writeAtomic(dumpDir, file, body);
872
+ } catch (err) {
873
+ if (err === null || typeof err !== 'object' || err.code !== 'ENOENT') throw err;
874
+ writeAtomic(dumpDir, file, body);
875
+ }
876
+ }
877
+
878
+ /** Cleanup of the per-call dump and the empty session directory (one held by another dump stays). Best effort. */
879
+ function removeCallDump(file) {
880
+ if (file === null) return;
881
+ try {
882
+ unlinkSync(file);
883
+ } catch {
884
+ // No file or no permissions: the server sweeps orphaned dumps.
885
+ }
886
+ try {
887
+ rmdirSync(dirname(file));
888
+ } catch {
889
+ // The directory is not empty (another request of this session) or is already gone.
890
+ }
891
+ }
892
+
893
+ /**
894
+ * Reads `<dataDir>/alive.json`: `{veto: null, seen, alive}` for a file of valid shape with a fresh `ts`, or
895
+ * `{veto: reason, seen?}`, where `seen` = `{bootId, aliveTs}` of a file of valid shape (for the log), and `alive`
896
+ * = `{bootId, mode, send, sessions, markers}`. Fail-closed: no file, bad JSON, any required field missing, `ts`
897
+ * further than `ALIVE_MAX_AGE_MS` from the hook's clock (both ways): each of these is a veto. The
898
+ * `markers` field is optional and not part of the shape: `true` only with a literal `true`, any other value
899
+ * and absence are `false` (a server without markers), never `alive-zly`. `restart` = the raw `stop` and `phase` of a
900
+ * file of valid shape, also a stale one (the restart break, `consent.mjs`).
901
+ */
902
+ function readAlive(dir) {
903
+ let parsed;
904
+ try {
905
+ parsed = JSON.parse(readFileSync(join(dir, ALIVE_FILE), 'utf8'));
906
+ } catch (err) {
907
+ return { veto: err !== null && typeof err === 'object' && err.code === 'ENOENT' ? 'alive-brak' : 'alive-zly' };
908
+ }
909
+ if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) return { veto: 'alive-zly' };
910
+ const ts = parsed['ts'];
911
+ const bootId = parsed['bootId'];
912
+ const mode = parsed['mode'];
913
+ const send = parsed['send'];
914
+ const sessions = parsed['sessions'];
915
+ if (
916
+ typeof ts !== 'number' || !Number.isFinite(ts) || typeof bootId !== 'string' || bootId === ''
917
+ || typeof mode !== 'string' || typeof send !== 'boolean' || !Array.isArray(sessions)
918
+ ) {
919
+ return { veto: 'alive-zly' };
920
+ }
921
+ const seen = { bootId: bootId.slice(0, 64), aliveTs: ts };
922
+ const restart = { stop: parsed['stop'], phase: parsed['phase'] };
923
+ if (Math.abs(Date.now() - ts) > ALIVE_MAX_AGE_MS) return { veto: 'alive-ts', seen, restart };
924
+ return { veto: null, seen, restart, alive: { bootId, mode, send, sessions, markers: parsed['markers'] === true } };
925
+ }
926
+
927
+ /** `consent.mjs`, loaded dynamically (header, "CONSENT CHANNEL"); `null` = a missing or failing module, no channel. */
928
+ async function loadConsent() {
929
+ let consent;
930
+ try {
931
+ consent = await import(new URL('./consent.mjs', import.meta.url).href);
932
+ } catch {
933
+ return null;
934
+ }
935
+ return consent;
936
+ }
937
+
938
+ /** Whether `mode` opens the consent channel for a request with this `agent_id`: `all`, or `main` without it. */
939
+ const channelFor = (mode, agentId) => mode === MODE_ALL || (mode === MODE_MAIN && agentId === undefined);
940
+
941
+ /**
942
+ * Restart break (header, "RESTART BREAK"): `false` = it ended without the next server's channel, `true` = go on by
943
+ * `alive.json` as it is now (no break, the channel opened, a server settled without it, `consent.mjs` unusable).
944
+ */
945
+ async function restartBreak(dir, sessionId, agentId) {
946
+ const first = readAlive(dir);
947
+ if (first.restart?.stop === undefined && first.restart?.phase === undefined) return true;
948
+ const consent = await loadConsent();
949
+ if (typeof consent?.waitThroughRestart !== 'function') return true;
950
+ const exit = await consent.waitThroughRestart({
951
+ first, read: () => readAlive(dir), sessionId, channel: (alive) => channelFor(alive.mode, agentId),
952
+ pollMs: ANSWER_POLL_MS, onPause: (fields) => { shadowLog('pauza', { ...fields, ms: elapsedMs() }); },
953
+ });
954
+ return exit.outcome !== 'expired';
955
+ }
956
+
957
+ /**
958
+ * Request marker gate (header, "REQUEST MARKER"): `alive.json` of valid shape with a fresh `ts`
959
+ * ({@link readAlive}), the session on the list, mode `main` or `all` and `markers: true`. Any other state (no file,
960
+ * a server without the field, shadow, `off`, a session off the list) = no marker, and the rest of the hook runs as
961
+ * without markers. `send` and `agent_id` do not change the gate: the marker decides nothing, it only tells the server
962
+ * the request exists.
963
+ */
964
+ function markersOn(dir, sessionId) {
965
+ const read = readAlive(dir);
966
+ if (read.veto !== null) return false;
967
+ const { mode, sessions, markers } = read.alive;
968
+ return markers === true && (mode === MODE_MAIN || mode === MODE_ALL) && sessions.includes(sessionId);
969
+ }
970
+
971
+ /**
972
+ * Writes the request marker `markers/<session>/<name>.json` (`HookMarkerFile`): name = the per-call key or, without
973
+ * a key, `anon-<pid>-<startedAt>` with `key: null`. Fields as in the per-call dump (without `permissionMode`), with the
974
+ * same `tool_input` cap. Atomic write (0600, directories 0700, a temporary file and `rename`); we swallow an error,
975
+ * because a missing marker puts this request back to the behavior without markers. The hook deletes the marker at no
976
+ * exit.
977
+ */
978
+ function writeMarker(dir, request, key, inputSha256) {
979
+ const { sessionId, promptId, agentId, toolName, toolInput, cwd } = request;
980
+ const markerDir = join(dir, MARKERS_DIR, sessionId);
981
+ const name = key ?? `${MARKER_ANON_PREFIX}${String(process.pid)}-${String(PROCESS_STARTED_AT)}`;
982
+ try {
983
+ writeCallDump(markerDir, join(markerDir, `${name}.json`), `${JSON.stringify({
984
+ key,
985
+ sessionId,
986
+ promptId: key === null ? null : promptId,
987
+ pid: process.pid,
988
+ startedAt: PROCESS_STARTED_AT,
989
+ ...(typeof agentId === 'string' && agentId !== '' ? { agentId } : {}),
990
+ toolName,
991
+ toolInput: cappedToolInput(toolInput),
992
+ cwd,
993
+ at: Date.now(),
994
+ inputSha256,
995
+ })}\n`);
996
+ } catch {
997
+ // No marker = this request as without markers; the hook goes on.
998
+ }
999
+ }
1000
+
1001
+ /**
1002
+ * Whether waiting in shadow mode is allowed according to `alive.json` ({@link readAlive}): `{veto: null, seen}` or
1003
+ * `{veto: reason, seen?}`. Read at EVERY poll. Beyond the read veto: a mode other than `shadow`, `send` other
1004
+ * than `true`, a session off the list: each of these is a veto.
1005
+ */
1006
+ function aliveVeto(dir, sessionId) {
1007
+ const read = readAlive(dir);
1008
+ if (read.veto !== null) return { veto: read.veto, ...(read.seen === undefined ? {} : { seen: read.seen }) };
1009
+ const { seen } = read;
1010
+ const { mode, send, sessions } = read.alive;
1011
+ if (mode !== MODE_SHADOW) return { veto: mode === MODE_OFF ? 'tryb-off' : 'tryb-nieznany', seen };
1012
+ if (send !== true) return { veto: 'send', seen };
1013
+ if (!sessions.includes(sessionId)) return { veto: 'sesja', seen };
1014
+ return { veto: null, seen };
1015
+ }
1016
+
1017
+ /**
1018
+ * Whether the request goes through the consent channel (header, "CONSENT CHANNEL"): `{mode, seen}` or `null`, that is
1019
+ * the usual path unchanged to the byte (tall dialog guard, dump, shadow mode). Channel: `alive.json` of valid shape
1020
+ * with a fresh `ts`, `send: true`, the session on the list and mode `main` for a request without `agent_id`, or `all`.
1021
+ */
1022
+ function consentRoute(dir, sessionId, agentId) {
1023
+ const read = readAlive(dir);
1024
+ if (read.veto !== null) return null;
1025
+ const { mode, send, sessions } = read.alive;
1026
+ if (!channelFor(mode, agentId) || send !== true || !sessions.includes(sessionId)) return null;
1027
+ return { mode, seen: read.seen };
1028
+ }
1029
+
1030
+ /**
1031
+ * Wait veto in the consent channel from reading `alive.json` ({@link readAlive}), at EVERY poll: `{veto: null, seen,
1032
+ * mode}` or `{veto: reason, seen?}`, like {@link aliveVeto}. Beyond the read veto: a `bootId` other than in the
1033
+ * registration response (`restart`), a mode outside {@link ALIVE_MODES} (`tryb-nieznany`), a mode lower than the
1034
+ * channel for this request (`tryb-nizszy`), `send` other than `true`, a session off the list.
1035
+ */
1036
+ function consentVeto(read, sessionId, agentId, bootId) {
1037
+ if (read.veto !== null) return { veto: read.veto, ...(read.seen === undefined ? {} : { seen: read.seen }) };
1038
+ const { seen } = read;
1039
+ const { mode, send, sessions } = read.alive;
1040
+ if (read.alive.bootId !== bootId) return { veto: 'restart', seen };
1041
+ if (!ALIVE_MODES.has(mode)) return { veto: 'tryb-nieznany', seen };
1042
+ if (!channelFor(mode, agentId)) return { veto: 'tryb-nizszy', seen };
1043
+ if (send !== true) return { veto: 'send', seen };
1044
+ if (!sessions.includes(sessionId)) return { veto: 'sesja', seen };
1045
+ return { veto: null, seen, mode };
1046
+ }
1047
+
1048
+ /** Whether something lies at the path (`lstat`: a symlink too). */
1049
+ function present(path) {
1050
+ try {
1051
+ lstatSync(path);
1052
+ return true;
1053
+ } catch {
1054
+ return false;
1055
+ }
1056
+ }
1057
+
1058
+ /**
1059
+ * Claims a shadow file: `rename` `<key>.json` → `<key>.claimed` (whoever did the `rename` first won;
1060
+ * the server revokes with the same move to `.revoked`). `null` = there was no file. The content is read AFTER the
1061
+ * claim, only for the log: in shadow mode the file decides nothing.
1062
+ */
1063
+ function claimShadow(base) {
1064
+ const claimed = `${base}${CLAIMED_SUFFIX}`;
1065
+ try {
1066
+ renameSync(`${base}.json`, claimed);
1067
+ } catch {
1068
+ return null;
1069
+ }
1070
+ try {
1071
+ const parsed = JSON.parse(readFileSync(claimed, 'utf8'));
1072
+ return { body: parsed !== null && typeof parsed === 'object' ? parsed : null };
1073
+ } catch {
1074
+ return { body: null };
1075
+ }
1076
+ }
1077
+
1078
+ /**
1079
+ * Waits in shadow mode for the shadow file under this request's key. Returns `{powod, alive?}`: `odbior`, `odwolane`,
1080
+ * `sufit` (`--answer-wait`) or an `alive.json` veto from a poll (with `bootId` and `ts` of the file, when readable).
1081
+ * A signal ends the process separately ({@link onSignal}).
1082
+ */
1083
+ async function waitForShadow(dir, sessionId, key, inputSha256, waitMs) {
1084
+ const base = join(dir, SHADOW_DIR, sessionId, key);
1085
+ const deadline = Date.now() + waitMs;
1086
+ for (;;) {
1087
+ const claimed = claimShadow(base);
1088
+ if (claimed !== null) {
1089
+ const body = claimed.body;
1090
+ const decision = body === null ? undefined : body['decision'];
1091
+ shadowLog('odbior', {
1092
+ decyzja: decision === 'allow' || decision === 'deny' ? decision : '?',
1093
+ zgodny: body !== null && body['key'] === key && body['sessionId'] === sessionId
1094
+ && body['inputSha256'] === inputSha256,
1095
+ ms: elapsedMs(),
1096
+ });
1097
+ return { powod: 'odbior' };
1098
+ }
1099
+ if (present(`${base}${REVOKED_SUFFIX}`)) return { powod: 'odwolane' };
1100
+ if (Date.now() >= deadline) return { powod: 'sufit' };
1101
+ await new Promise((resolve) => setTimeout(resolve, ANSWER_POLL_MS));
1102
+ // Veto before the claim, as at the start: a server that does not allow waiting does not get a claim.
1103
+ const { veto, seen } = aliveVeto(dir, sessionId);
1104
+ if (veto !== null) return { powod: veto, alive: seen };
1105
+ }
1106
+ }
1107
+
1108
+ /**
1109
+ * Writes the per-call dump `pending/<session>/<key>.json` (`HookCallDump`); `false` = the write failed.
1110
+ * A successful write registers the file in the cycle, so {@link finishCycle} cleans it up.
1111
+ * `suggestions`: `permission_suggestions` as the consent channel carries them (`carriedSuggestions` in `consent.mjs`);
1112
+ * shadow mode passes none.
1113
+ */
1114
+ function writeKeyDump(dir, request, key, inputSha256, capped, suggestions) {
1115
+ const { sessionId, promptId, agentId, permissionMode, toolName, cwd } = request;
1116
+ const dumpDir = join(dir, 'pending', sessionId);
1117
+ const dumpFile = join(dumpDir, `${key}.json`);
1118
+ try {
1119
+ writeCallDump(dumpDir, dumpFile, `${JSON.stringify({
1120
+ key,
1121
+ sessionId,
1122
+ promptId,
1123
+ pid: process.pid,
1124
+ startedAt: PROCESS_STARTED_AT,
1125
+ ...(typeof agentId === 'string' && agentId !== '' ? { agentId } : {}),
1126
+ ...(typeof permissionMode === 'string' ? { permissionMode } : {}),
1127
+ toolName,
1128
+ toolInput: capped,
1129
+ ...(suggestions === undefined ? {} : { permissionSuggestions: suggestions }),
1130
+ cwd,
1131
+ at: Date.now(),
1132
+ inputSha256,
1133
+ })}\n`);
1134
+ } catch {
1135
+ return false;
1136
+ }
1137
+ cycle.dumpFile = dumpFile;
1138
+ return true;
1139
+ }
1140
+
1141
+ /**
1142
+ * Per-call dump and shadow mode for a tool permission (`PermissionRequest`, not `AskUserQuestion`), after
1143
+ * the per-session dump is written. `call` = `{key, inputSha256}` computed ONCE in {@link main} (the same key as
1144
+ * in the request marker). The order of conditions sets the reason in `shadow.jsonl`: key, digest, dump write,
1145
+ * truncation, subagent, `alive.json`. Every path ends with {@link finishCycle} and writes nothing to stdout.
1146
+ */
1147
+ async function shadowChannel(dir, request, call) {
1148
+ const { sessionId, agentId, toolInput } = request;
1149
+ const { key, inputSha256 } = call;
1150
+ if (key === null) return skipWaiting('klucz');
1151
+ cycle.key = key;
1152
+ if (inputSha256 === null) return skipWaiting('skrot');
1153
+
1154
+ const capped = cappedToolInput(toolInput);
1155
+ if (!writeKeyDump(dir, request, key, inputSha256, capped)) {
1156
+ return skipWaiting('zrzut');
1157
+ }
1158
+
1159
+ // `cappedToolInput` returns the original (or `null` for none) within the cap, and the marker above it.
1160
+ if (capped !== (toolInput ?? null)) return skipWaiting('obciety');
1161
+ if (agentId !== undefined) return skipWaiting('subagent');
1162
+ const alive = aliveVeto(dir, sessionId);
1163
+ if (alive.veto !== null) return skipWaiting(alive.veto, alive.seen);
1164
+
1165
+ cycle.waited = true;
1166
+ shadowLog('czekam', { ...alive.seen, inputSha256 });
1167
+ const exit = await waitForShadow(dir, sessionId, key, inputSha256, answerWaitMs(process.argv));
1168
+ finishCycle(exit.powod, exit.alive);
1169
+ }
1170
+
1171
+ /**
1172
+ * Consent channel (header, "CONSENT CHANNEL") for a request to which {@link consentRoute} gave a mode, after the
1173
+ * per-session dump is written. `call` = `{key, inputSha256}` computed ONCE in {@link main}: the registration, the
1174
+ * dump and the request marker carry the same key with the same nonce. The order sets the reason in `shadow.jsonl`:
1175
+ * module, key, digest, registration BEFORE the per-call dump and before the first log line with the key, dump,
1176
+ * truncation, waiting. Only a decision from a valid, claimed answer file goes to stdout; every other path ends with
1177
+ * {@link finishCycle} without a decision.
1178
+ */
1179
+ async function consentChannel(dir, request, route, call) {
1180
+ const { sessionId, promptId, agentId, permissionMode, toolName, toolInput, cwd } = request;
1181
+ const consent = await loadConsent();
1182
+ if (consent === null) return skipWaiting('modul');
1183
+ const { key, inputSha256 } = call;
1184
+ if (key === null) return skipWaiting('klucz');
1185
+ if (inputSha256 === null) return skipWaiting('skrot');
1186
+ let cardSha256;
1187
+ try {
1188
+ // The same fields as the server's card from the per-call dump: `agentId` only non-empty, the mode only a string.
1189
+ cardSha256 = consent.cardSha256({
1190
+ sessionId, toolName, toolInput: toolInput ?? null, cwd,
1191
+ agentId: typeof agentId === 'string' && agentId !== '' ? agentId : null,
1192
+ permissionMode: typeof permissionMode === 'string' ? permissionMode : null,
1193
+ });
1194
+ } catch {
1195
+ return skipWaiting('skrot');
1196
+ }
1197
+ if (typeof cardSha256 !== 'string' || !/^[0-9a-f]{64}$/.test(cardSha256)) return skipWaiting('skrot');
1198
+
1199
+ // The secret lives only in this function and in the registration body (never argv, env, dump, log, file, stdout).
1200
+ const secret = consent.newSecret();
1201
+ const registeredAt = Date.now();
1202
+ const suggestions = consent.carriedSuggestions(request.permissionSuggestions);
1203
+ // The same body goes again after a server restart (`waitResuming`).
1204
+ const register = (deadlineMs) => consent.registerConsent(consent.socketPathOf(dir), {
1205
+ key, sessionId, promptId, secret, inputSha256, cardSha256, pid: process.pid, startedAt: PROCESS_STARTED_AT,
1206
+ // Any presence of `agent_id` goes to the registry: a field with a bad shape is a refusal, not a main-thread
1207
+ // request.
1208
+ ...(agentId === undefined ? {} : { agentId }),
1209
+ // "Always" (`alwaysVersion`) only with suggestions: a request without them never has the option.
1210
+ ...(suggestions === undefined ? {} : { permissionSuggestions: suggestions, alwaysVersion: consent.ALWAYS_VERSION }),
1211
+ }, deadlineMs);
1212
+ const reply = await register();
1213
+ cycle.key = key;
1214
+ const capped = cappedToolInput(toolInput);
1215
+ if (!writeKeyDump(dir, request, key, inputSha256, capped, suggestions)) {
1216
+ return skipWaiting('zrzut');
1217
+ }
1218
+ if (reply.accepted !== true) {
1219
+ return skipWaiting('rejestracja', {}, { szczegol: String(reply.detail).slice(0, 64) });
1220
+ }
1221
+ if (capped !== (toolInput ?? null)) return skipWaiting('obciety');
1222
+
1223
+ cycle.waited = true;
1224
+ shadowLog('czekam', { ...route.seen, inputSha256, tryb: route.mode });
1225
+ let mode = route.mode;
1226
+ const exit = await consent.waitResuming({
1227
+ base: join(dir, consent.CONSENT_DIR, sessionId, key),
1228
+ expected: {
1229
+ secret, sessionId, key, inputSha256, cardSha256, notBefore: registeredAt - consent.NOT_BEFORE_MARGIN_MS,
1230
+ permissionsSha256: suggestions === undefined ? null : consent.alwaysDigest(suggestions),
1231
+ },
1232
+ pollMs: ANSWER_POLL_MS, deadline: Date.now() + answerWaitMs(process.argv), bootId: reply.bootId, sessionId,
1233
+ read: () => readAlive(dir), channel: (alive) => channelFor(alive.mode, agentId), register,
1234
+ onLine: (ev, f) => { shadowLog(ev, { ...f, ...(ev === 'czekam' ? { inputSha256 } : { ms: elapsedMs() }) }); },
1235
+ // Veto before every claim (after the `--answer-wait` cap): reading `alive.json` against the registration `bootId`.
1236
+ veto: (bootId, read) => {
1237
+ const alive = consentVeto(read, sessionId, agentId, bootId);
1238
+ if (alive.veto === null) {
1239
+ mode = alive.mode;
1240
+ return null;
1241
+ }
1242
+ return { powod: alive.veto, alive: alive.seen ?? {} };
1243
+ },
1244
+ onRejected: (reason, n) => {
1245
+ shadowLog('odrzucony', {
1246
+ powod: ['input', 'card', 'permissions'].includes(reason) ? 'karta-inna' : 'podpis', szczegol: reason, n,
1247
+ ms: elapsedMs(),
1248
+ });
1249
+ },
1250
+ });
1251
+ if (exit.outcome !== 'claimed') return finishCycle(exit.powod, exit.alive);
1252
+
1253
+ // ONLY the content of a claimed, verified file is executed; `allow` for `agent_id` only in mode `all`.
1254
+ const { file } = exit;
1255
+ shadowLog('odbior', { decyzja: file.decision, szczegol: file.reasonId, ms: elapsedMs() });
1256
+ const output = consent.consentOutput(file, {
1257
+ hookEventName: PERMISSION_REQUEST_EVENT, toolName, toolInput, allowed: agentId === undefined || mode === MODE_ALL,
1258
+ suggestions,
1259
+ });
1260
+ // `allow` only with the server's receipt: a copy of an old `allow` has a valid signature but is not the record's
1261
+ // live decision. No receipt (refusal, deadline, a server or module without `/claim`) = exit without a decision.
1262
+ if (output !== null && file.decision === 'allow') {
1263
+ const receipt = await confirmReceipt(consent, dir, { secret, sessionId, key, at: file.at });
1264
+ if (receipt.confirmed !== true) {
1265
+ return finishCycle('potwierdzenie', { szczegol: String(receipt.detail).slice(0, 64) });
1266
+ }
1267
+ }
1268
+ finishCycle(file.decision === 'release' ? 'release' : 'odbior');
1269
+ if (output !== null) writeSync(1, JSON.stringify(output));
1270
+ }
1271
+
1272
+ /** The receipt of a taken `allow` (`consent.mjs`, `confirmConsent`); a module without it or a throw = no receipt. */
1273
+ async function confirmReceipt(consent, dir, { secret, sessionId, key, at }) {
1274
+ if (typeof consent.confirmConsent !== 'function' || typeof consent.receiptMac !== 'function') {
1275
+ return { confirmed: false, detail: 'modul' };
1276
+ }
1277
+ try {
1278
+ const mac = consent.receiptMac(secret, { sessionId, key, at });
1279
+ return await consent.confirmConsent(consent.socketPathOf(dir), { key, at, mac });
1280
+ } catch {
1281
+ return { confirmed: false, detail: 'modul' };
1282
+ }
1283
+ }
1284
+
1285
+ async function main() {
1286
+ const raw = await readStdin();
1287
+ // Programmatic session (header, "PROGRAMMATIC SESSIONS"): end without a trace, right after reading stdin.
1288
+ if (PROGRAMMATIC_ENTRYPOINTS.has(process.env[ENTRYPOINT_ENV])) return;
1289
+ if (raw === '') return;
1290
+
1291
+ let payload;
1292
+ try {
1293
+ payload = JSON.parse(raw);
1294
+ } catch {
1295
+ return;
1296
+ }
1297
+ if (payload === null || typeof payload !== 'object') return;
1298
+
1299
+ const event = payload['hook_event_name'];
1300
+ // Events outside the contract (a `PreToolUse` registration for all tools, a `PostToolUse` added by hand) write
1301
+ // NOTHING: otherwise stale dumps come back.
1302
+ if (event !== 'PermissionRequest' && event !== 'PreToolUse') return;
1303
+
1304
+ const sessionId = payload['session_id'];
1305
+ const toolName = payload['tool_name'];
1306
+ // Validation BEFORE `join`: `session_id` goes into the file name, and `../../…` would write over
1307
+ // any file of the user's account.
1308
+ if (typeof sessionId !== 'string' || !SESSION_ID_PATTERN.test(sessionId)) return;
1309
+ if (typeof toolName !== 'string' || toolName === '') return;
1310
+ if (event === 'PreToolUse' && toolName !== QUESTION_TOOL) return;
1311
+
1312
+ const cwd = payload['cwd'];
1313
+ if (typeof cwd !== 'string' || cwd === '') return;
1314
+
1315
+ const dir = dataDir();
1316
+ if (dir === null) return;
1317
+ const config = rarogRoots(dir);
1318
+ if (config === null) return;
1319
+ dataRoot = dir;
1320
+ if (!(await insideRoots(cwd, config))) return;
1321
+
1322
+ const promptId = payload['prompt_id'];
1323
+ const permissionMode = payload['permission_mode'];
1324
+ const toolInput = payload['tool_input'];
1325
+ // Only a SUBAGENT's request carries `agent_id` (CLI 2.1.302). Rarog takes it to the log (`herdr-audit.log`), so that
1326
+ // subagent permissions count separately; in shadow mode and in the consent channel in mode `main` the mere PRESENCE
1327
+ // of the field means "do not wait".
1328
+ const agentId = payload['agent_id'];
1329
+
1330
+ /*
1331
+ * Shadow mode cycle (header, "PER-CALL DUMP AND SHADOW MODE"): only a tool permission:
1332
+ * a question has its own answer channel, which stays unchanged. From this moment every process exit
1333
+ * appends `wyjscie` to `shadow.jsonl` and cleans up the per-call dump.
1334
+ */
1335
+ if (event === PERMISSION_REQUEST_EVENT && toolName !== QUESTION_TOOL) {
1336
+ startCycle(dir, sessionId, {
1337
+ toolName: TOOL_NAME_PATTERN.test(toolName) ? toolName : '?',
1338
+ ...(typeof promptId === 'string' && SESSION_ID_PATTERN.test(promptId) ? { promptId } : {}),
1339
+ subagent: agentId !== undefined,
1340
+ ...(typeof permissionMode === 'string' ? { permissionMode: permissionMode.slice(0, 64) } : {}),
1341
+ });
1342
+ }
1343
+ // Data for the consent channel (the registration and the per-call dump); the hook decides nothing on it.
1344
+ const permissionSuggestions = payload['permission_suggestions'];
1345
+ const request = { sessionId, promptId, agentId, permissionMode, toolName, toolInput, cwd, permissionSuggestions };
1346
+ /*
1347
+ * Per-call key and canon digest ONCE per request, before choosing the path (header, "REQUEST MARKER"): the same
1348
+ * key goes to the marker, the per-call dump and the consent channel registration. The marker is made here, before
1349
+ * the tall dialog guard, the channel, shadow mode and every exit without waiting; the reasons of these exits keep
1350
+ * their order (module, key, digest…), because the paths check `call` themselves.
1351
+ */
1352
+ const call = cycle === null ? null : { key: callKeyFor(promptId), inputSha256: await inputDigest(toolInput) };
1353
+ // Restart break (header, "RESTART BREAK"): `false` = no successor in time, exit after the per-session dump.
1354
+ const successor = call === null || await restartBreak(dir, sessionId, agentId);
1355
+ if (call !== null && markersOn(dir, sessionId)) writeMarker(dir, request, call.key, call.inputSha256);
1356
+ // Consent channel (header, "CONSENT CHANNEL"): `null` = the usual path unchanged to the byte.
1357
+ const channel = cycle === null ? null : consentRoute(dir, sessionId, agentId);
1358
+
1359
+ /*
1360
+ * Tall dialog guard (pane geometry): see the header. Cheap conditions before importing the
1361
+ * module: event, tool, flag from `roots.json`, herdr session, command as a string. The guard fields
1362
+ * (budget source, geometry) go to the refusal log or to the dump of a request let through.
1363
+ */
1364
+ let guarded = {};
1365
+ // A consent channel request skips the guard: the card on the device shows the whole input, with no dialog row limit.
1366
+ if (
1367
+ channel === null
1368
+ && event === PERMISSION_REQUEST_EVENT && toolName === GUARD_TOOL && config.tallDialogGuard
1369
+ && process.env['HERDR_ENV'] === '1'
1370
+ && toolInput !== null && typeof toolInput === 'object' && typeof toolInput['command'] === 'string'
1371
+ ) {
1372
+ const outcome = await tallDialogGuard(toolInput, process.env['COLUMNS'], process.env['LINES']);
1373
+ if (outcome !== null) guarded = outcome.fields;
1374
+ const verdict = outcome?.verdict ?? null;
1375
+ if (verdict !== null) {
1376
+ try {
1377
+ markSeen(dir, event, toolName);
1378
+ } catch {
1379
+ // The marker is diagnostics: the form refusal goes anyway.
1380
+ }
1381
+ try {
1382
+ appendGuardLog(dir, {
1383
+ at: Date.now(),
1384
+ sessionId,
1385
+ subagent: typeof payload['agent_id'] === 'string' && payload['agent_id'] !== '',
1386
+ reason: verdict.reason,
1387
+ rows: verdict.rows,
1388
+ budget: verdict.budget,
1389
+ descriptionRows: verdict.descriptionRows,
1390
+ ...guarded,
1391
+ ...(typeof permissionMode === 'string' ? { permissionMode } : {}),
1392
+ });
1393
+ } catch {
1394
+ // The log is diagnostics: the model sees the refusal in its transcript.
1395
+ }
1396
+ // Form refusal: no per-call dump and no waiting, also in shadow mode.
1397
+ skipWaiting('straznik');
1398
+ // The response shape EXACTLY as measured on CLI 2.1.302 (main thread and a background subagent, modes default and
1399
+ // auto): no `interrupt`, whose default value does not interrupt the turn anyway: the model gets `message` as a
1400
+ // tool result with an error and splits the work.
1401
+ writeSync(1, JSON.stringify({
1402
+ hookSpecificOutput: {
1403
+ hookEventName: PERMISSION_REQUEST_EVENT,
1404
+ decision: { behavior: 'deny', message: verdict.message },
1405
+ },
1406
+ }));
1407
+ return;
1408
+ }
1409
+ }
1410
+
1411
+ const pending = join(dir, 'pending');
1412
+ // ONLY `PreToolUse` carries `tool_use_id` (measured: `PermissionRequest` does not have it,
1413
+ // even for the same tool in the same turn). It stays in the dump, because it gives the card
1414
+ // a stable call identity where it exists at all.
1415
+ const toolUseId = payload['tool_use_id'];
1416
+ /*
1417
+ * We compute the answer channel key ONLY for a standing question form, and the HOOK computes it,
1418
+ * not Rarog: so there is exactly one algorithm, not two that agree by chance.
1419
+ * The dump carries it, so Rarog addresses the answer file without knowing the payload.
1420
+ */
1421
+ const answerKey = event === PERMISSION_REQUEST_EVENT && toolName === QUESTION_TOOL
1422
+ ? answerKeyFor(promptId, toolInput)
1423
+ : null;
1424
+ const at = Date.now();
1425
+ const body = `${JSON.stringify({
1426
+ sessionId,
1427
+ toolName,
1428
+ ...(typeof toolUseId === 'string' ? { toolUseId } : {}),
1429
+ toolInput: cappedToolInput(toolInput),
1430
+ at,
1431
+ hookEventName: event,
1432
+ ...(typeof promptId === 'string' ? { promptId } : {}),
1433
+ ...(typeof permissionMode === 'string' ? { permissionMode } : {}),
1434
+ ...(answerKey === null ? {} : { answerKey }),
1435
+ // The per-call key of this request (the same as in the marker, the per-call dump and the channel registration):
1436
+ // the server ties a card built from this dump to the channel record of the same call, never by its content.
1437
+ ...(typeof call?.key === 'string' ? { callKey: call.key } : {}),
1438
+ ...(typeof agentId === 'string' && agentId !== '' ? { agentId } : {}),
1439
+ // The guard's budget source and pane geometry at the moment of the hook: only for a request
1440
+ // the guard assessed and let through; Rarog moves them to this card's `degrade` entry.
1441
+ ...guarded,
1442
+ cwd,
1443
+ })}\n`;
1444
+ writeAtomic(pending, join(pending, `${sessionId}.json`), body);
1445
+ markSeen(dir, event, toolName);
1446
+ if (call !== null) {
1447
+ if (!successor) skipWaiting('przerwa');
1448
+ else if (channel === null) await shadowChannel(dir, request, call);
1449
+ else await consentChannel(dir, request, channel, call);
1450
+ return;
1451
+ }
1452
+ if (answerKey === null) return;
1453
+
1454
+ const reply = await waitForAnswers(
1455
+ dir, sessionId, answerKey, at, answerWaitMs(process.argv), toolInput,
1456
+ );
1457
+ // Silence after a timeout is CORRECT and the only option: the CLI leaves no trace on the screen
1458
+ // that the hook was lost, so the form stays and waits for a digit.
1459
+ if (reply === null) return;
1460
+ /*
1461
+ * The `decision` shape is an OBJECT (`{behavior, updatedInput}`): hooks docs, "PermissionRequest decision control".
1462
+ * `updatedInput` replaces the whole tool input, so we give it back WHOLE with `answers` added (docs,
1463
+ * "AskUserQuestion"; measured), and with notes also `annotations`: a field CLI 2.1.288 and 2.1.293 accept (measured).
1464
+ * RAROG enforces the version threshold: it writes notes only for a process ≥ 2.1.288; a file without notes gives
1465
+ * `updatedInput` without `annotations`.
1466
+ *
1467
+ * `writeSync` instead of `process.stdout.write`: `process.exit(0)` follows right after, and an
1468
+ * asynchronous write to a pipe might not make it.
1469
+ */
1470
+ writeSync(1, JSON.stringify({
1471
+ hookSpecificOutput: {
1472
+ hookEventName: PERMISSION_REQUEST_EVENT,
1473
+ decision: {
1474
+ behavior: 'allow',
1475
+ updatedInput: {
1476
+ ...(toolInput === null || typeof toolInput !== 'object' ? {} : toolInput),
1477
+ answers: reply.answers,
1478
+ ...(reply.annotations === null ? {} : { annotations: reply.annotations }),
1479
+ },
1480
+ },
1481
+ },
1482
+ }));
1483
+ }
1484
+
1485
+ // The only exit from the process: exit 0, stdout empty or one decision (`allow` with an answer to a
1486
+ // question, the guard's `deny`, a consent channel decision). Without this `catch` a write exception would go
1487
+ // to stderr and (with exit ≠ 0) could be taken as a hook signal. A shadow mode cycle that no path
1488
+ // closed (an exception, e.g. a full disk at the per-session dump) ends here as `blad`.
1489
+ main().then(
1490
+ () => {
1491
+ finishCycle('blad');
1492
+ process.exit(0);
1493
+ },
1494
+ () => {
1495
+ finishCycle('blad');
1496
+ process.exit(0);
1497
+ },
1498
+ );