@schema-weaver/pg-connector 0.0.0-stage → 2.0.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 (1065) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/LICENSE +21 -0
  3. package/README.md +457 -2
  4. package/dist/cjs/audit/chain.d.ts +365 -0
  5. package/dist/cjs/audit/chain.d.ts.map +1 -0
  6. package/dist/cjs/audit/chain.js +959 -0
  7. package/dist/cjs/audit/chain.js.map +1 -0
  8. package/dist/cjs/audit/cloud-client.d.ts +142 -0
  9. package/dist/cjs/audit/cloud-client.d.ts.map +1 -0
  10. package/dist/cjs/audit/cloud-client.js +364 -0
  11. package/dist/cjs/audit/cloud-client.js.map +1 -0
  12. package/dist/cjs/audit/cloud-writer.d.ts +57 -0
  13. package/dist/cjs/audit/cloud-writer.d.ts.map +1 -0
  14. package/dist/cjs/audit/cloud-writer.js +95 -0
  15. package/dist/cjs/audit/cloud-writer.js.map +1 -0
  16. package/dist/cjs/audit/context.d.ts +51 -0
  17. package/dist/cjs/audit/context.d.ts.map +1 -0
  18. package/dist/cjs/audit/context.js +75 -0
  19. package/dist/cjs/audit/context.js.map +1 -0
  20. package/dist/cjs/audit/files.d.ts +111 -0
  21. package/dist/cjs/audit/files.d.ts.map +1 -0
  22. package/dist/cjs/audit/files.js +406 -0
  23. package/dist/cjs/audit/files.js.map +1 -0
  24. package/dist/cjs/audit/index.d.ts +9 -0
  25. package/dist/cjs/audit/index.d.ts.map +1 -0
  26. package/dist/cjs/audit/index.js +68 -0
  27. package/dist/cjs/audit/index.js.map +1 -0
  28. package/dist/cjs/audit/local-writer.d.ts +255 -0
  29. package/dist/cjs/audit/local-writer.d.ts.map +1 -0
  30. package/dist/cjs/audit/local-writer.js +829 -0
  31. package/dist/cjs/audit/local-writer.js.map +1 -0
  32. package/dist/cjs/audit/redact.d.ts +151 -0
  33. package/dist/cjs/audit/redact.d.ts.map +1 -0
  34. package/dist/cjs/audit/redact.js +549 -0
  35. package/dist/cjs/audit/redact.js.map +1 -0
  36. package/dist/cjs/audit/sanitize.d.ts +78 -0
  37. package/dist/cjs/audit/sanitize.d.ts.map +1 -0
  38. package/dist/cjs/audit/sanitize.js +315 -0
  39. package/dist/cjs/audit/sanitize.js.map +1 -0
  40. package/dist/cjs/audit/sink.d.ts +278 -0
  41. package/dist/cjs/audit/sink.d.ts.map +1 -0
  42. package/dist/cjs/audit/sink.js +819 -0
  43. package/dist/cjs/audit/sink.js.map +1 -0
  44. package/dist/cjs/audit/types.d.ts +226 -0
  45. package/dist/cjs/audit/types.d.ts.map +1 -0
  46. package/dist/cjs/audit/types.js +3 -0
  47. package/dist/cjs/audit/types.js.map +1 -0
  48. package/dist/cjs/audit/verify-cache.d.ts +127 -0
  49. package/dist/cjs/audit/verify-cache.d.ts.map +1 -0
  50. package/dist/cjs/audit/verify-cache.js +668 -0
  51. package/dist/cjs/audit/verify-cache.js.map +1 -0
  52. package/dist/cjs/channels/agent-session.d.ts +228 -0
  53. package/dist/cjs/channels/agent-session.d.ts.map +1 -0
  54. package/dist/cjs/channels/agent-session.js +604 -0
  55. package/dist/cjs/channels/agent-session.js.map +1 -0
  56. package/dist/cjs/channels/data-channel.d.ts +181 -0
  57. package/dist/cjs/channels/data-channel.d.ts.map +1 -0
  58. package/dist/cjs/channels/data-channel.js +607 -0
  59. package/dist/cjs/channels/data-channel.js.map +1 -0
  60. package/dist/cjs/channels/reconnect.d.ts +142 -0
  61. package/dist/cjs/channels/reconnect.d.ts.map +1 -0
  62. package/dist/cjs/channels/reconnect.js +247 -0
  63. package/dist/cjs/channels/reconnect.js.map +1 -0
  64. package/dist/cjs/channels/types.d.ts +112 -0
  65. package/dist/cjs/channels/types.d.ts.map +1 -0
  66. package/dist/cjs/channels/types.js +3 -0
  67. package/dist/cjs/channels/types.js.map +1 -0
  68. package/dist/cjs/channels/wake-channel.d.ts +232 -0
  69. package/dist/cjs/channels/wake-channel.d.ts.map +1 -0
  70. package/dist/cjs/channels/wake-channel.js +752 -0
  71. package/dist/cjs/channels/wake-channel.js.map +1 -0
  72. package/dist/cjs/cli/banner.d.ts +2 -0
  73. package/dist/cjs/cli/banner.d.ts.map +1 -0
  74. package/dist/cjs/cli/banner.js +150 -0
  75. package/dist/cjs/cli/banner.js.map +1 -0
  76. package/dist/cjs/cli/commands/agent.d.ts +30 -0
  77. package/dist/cjs/cli/commands/agent.d.ts.map +1 -0
  78. package/dist/cjs/cli/commands/agent.js +214 -0
  79. package/dist/cjs/cli/commands/agent.js.map +1 -0
  80. package/dist/cjs/cli/commands/audit-verify.d.ts +19 -0
  81. package/dist/cjs/cli/commands/audit-verify.d.ts.map +1 -0
  82. package/dist/cjs/cli/commands/audit-verify.js +382 -0
  83. package/dist/cjs/cli/commands/audit-verify.js.map +1 -0
  84. package/dist/cjs/cli/commands/clean.d.ts +23 -0
  85. package/dist/cjs/cli/commands/clean.d.ts.map +1 -0
  86. package/dist/cjs/cli/commands/clean.js +272 -0
  87. package/dist/cjs/cli/commands/clean.js.map +1 -0
  88. package/dist/cjs/cli/commands/config-show.d.ts +2 -0
  89. package/dist/cjs/cli/commands/config-show.d.ts.map +1 -0
  90. package/dist/cjs/cli/commands/config-show.js +10 -0
  91. package/dist/cjs/cli/commands/config-show.js.map +1 -0
  92. package/dist/cjs/cli/commands/config.d.ts +6 -0
  93. package/dist/cjs/cli/commands/config.d.ts.map +1 -0
  94. package/dist/cjs/cli/commands/config.js +266 -0
  95. package/dist/cjs/cli/commands/config.js.map +1 -0
  96. package/dist/cjs/cli/commands/db-add.d.ts +16 -0
  97. package/dist/cjs/cli/commands/db-add.d.ts.map +1 -0
  98. package/dist/cjs/cli/commands/db-add.js +613 -0
  99. package/dist/cjs/cli/commands/db-add.js.map +1 -0
  100. package/dist/cjs/cli/commands/db-edit.d.ts +2 -0
  101. package/dist/cjs/cli/commands/db-edit.d.ts.map +1 -0
  102. package/dist/cjs/cli/commands/db-edit.js +388 -0
  103. package/dist/cjs/cli/commands/db-edit.js.map +1 -0
  104. package/dist/cjs/cli/commands/db-logs.d.ts +3 -0
  105. package/dist/cjs/cli/commands/db-logs.d.ts.map +1 -0
  106. package/dist/cjs/cli/commands/db-logs.js +67 -0
  107. package/dist/cjs/cli/commands/db-logs.js.map +1 -0
  108. package/dist/cjs/cli/commands/db-ls.d.ts +2 -0
  109. package/dist/cjs/cli/commands/db-ls.d.ts.map +1 -0
  110. package/dist/cjs/cli/commands/db-ls.js +118 -0
  111. package/dist/cjs/cli/commands/db-ls.js.map +1 -0
  112. package/dist/cjs/cli/commands/db-query.d.ts +121 -0
  113. package/dist/cjs/cli/commands/db-query.d.ts.map +1 -0
  114. package/dist/cjs/cli/commands/db-query.js +802 -0
  115. package/dist/cjs/cli/commands/db-query.js.map +1 -0
  116. package/dist/cjs/cli/commands/db-remove.d.ts +2 -0
  117. package/dist/cjs/cli/commands/db-remove.d.ts.map +1 -0
  118. package/dist/cjs/cli/commands/db-remove.js +51 -0
  119. package/dist/cjs/cli/commands/db-remove.js.map +1 -0
  120. package/dist/cjs/cli/commands/db-show.d.ts +2 -0
  121. package/dist/cjs/cli/commands/db-show.d.ts.map +1 -0
  122. package/dist/cjs/cli/commands/db-show.js +134 -0
  123. package/dist/cjs/cli/commands/db-show.js.map +1 -0
  124. package/dist/cjs/cli/commands/db-test.d.ts +3 -0
  125. package/dist/cjs/cli/commands/db-test.d.ts.map +1 -0
  126. package/dist/cjs/cli/commands/db-test.js +311 -0
  127. package/dist/cjs/cli/commands/db-test.js.map +1 -0
  128. package/dist/cjs/cli/commands/db.d.ts +11 -0
  129. package/dist/cjs/cli/commands/db.d.ts.map +1 -0
  130. package/dist/cjs/cli/commands/db.js +90 -0
  131. package/dist/cjs/cli/commands/db.js.map +1 -0
  132. package/dist/cjs/cli/commands/debug.d.ts +2 -0
  133. package/dist/cjs/cli/commands/debug.d.ts.map +1 -0
  134. package/dist/cjs/cli/commands/debug.js +241 -0
  135. package/dist/cjs/cli/commands/debug.js.map +1 -0
  136. package/dist/cjs/cli/commands/doctor.d.ts +5 -0
  137. package/dist/cjs/cli/commands/doctor.d.ts.map +1 -0
  138. package/dist/cjs/cli/commands/doctor.js +117 -0
  139. package/dist/cjs/cli/commands/doctor.js.map +1 -0
  140. package/dist/cjs/cli/commands/index.d.ts +10 -0
  141. package/dist/cjs/cli/commands/index.d.ts.map +1 -0
  142. package/dist/cjs/cli/commands/index.js +30 -0
  143. package/dist/cjs/cli/commands/index.js.map +1 -0
  144. package/dist/cjs/cli/commands/init.d.ts +2 -0
  145. package/dist/cjs/cli/commands/init.d.ts.map +1 -0
  146. package/dist/cjs/cli/commands/init.js +199 -0
  147. package/dist/cjs/cli/commands/init.js.map +1 -0
  148. package/dist/cjs/cli/commands/link.d.ts +5 -0
  149. package/dist/cjs/cli/commands/link.d.ts.map +1 -0
  150. package/dist/cjs/cli/commands/link.js +44 -0
  151. package/dist/cjs/cli/commands/link.js.map +1 -0
  152. package/dist/cjs/cli/commands/logs.d.ts +17 -0
  153. package/dist/cjs/cli/commands/logs.d.ts.map +1 -0
  154. package/dist/cjs/cli/commands/logs.js +314 -0
  155. package/dist/cjs/cli/commands/logs.js.map +1 -0
  156. package/dist/cjs/cli/commands/project-show.d.ts +2 -0
  157. package/dist/cjs/cli/commands/project-show.d.ts.map +1 -0
  158. package/dist/cjs/cli/commands/project-show.js +105 -0
  159. package/dist/cjs/cli/commands/project-show.js.map +1 -0
  160. package/dist/cjs/cli/commands/project.d.ts +3 -0
  161. package/dist/cjs/cli/commands/project.d.ts.map +1 -0
  162. package/dist/cjs/cli/commands/project.js +64 -0
  163. package/dist/cjs/cli/commands/project.js.map +1 -0
  164. package/dist/cjs/cli/commands/service.d.ts +123 -0
  165. package/dist/cjs/cli/commands/service.d.ts.map +1 -0
  166. package/dist/cjs/cli/commands/service.js +554 -0
  167. package/dist/cjs/cli/commands/service.js.map +1 -0
  168. package/dist/cjs/cli/commands/start.d.ts +6 -0
  169. package/dist/cjs/cli/commands/start.d.ts.map +1 -0
  170. package/dist/cjs/cli/commands/start.js +308 -0
  171. package/dist/cjs/cli/commands/start.js.map +1 -0
  172. package/dist/cjs/cli/commands/status.d.ts +2 -0
  173. package/dist/cjs/cli/commands/status.d.ts.map +1 -0
  174. package/dist/cjs/cli/commands/status.js +225 -0
  175. package/dist/cjs/cli/commands/status.js.map +1 -0
  176. package/dist/cjs/cli/commands/stop.d.ts +6 -0
  177. package/dist/cjs/cli/commands/stop.d.ts.map +1 -0
  178. package/dist/cjs/cli/commands/stop.js +99 -0
  179. package/dist/cjs/cli/commands/stop.js.map +1 -0
  180. package/dist/cjs/cli/daemon/error-tracker.d.ts +119 -0
  181. package/dist/cjs/cli/daemon/error-tracker.d.ts.map +1 -0
  182. package/dist/cjs/cli/daemon/error-tracker.js +500 -0
  183. package/dist/cjs/cli/daemon/error-tracker.js.map +1 -0
  184. package/dist/cjs/cli/daemon/fault-shutdown.d.ts +144 -0
  185. package/dist/cjs/cli/daemon/fault-shutdown.d.ts.map +1 -0
  186. package/dist/cjs/cli/daemon/fault-shutdown.js +312 -0
  187. package/dist/cjs/cli/daemon/fault-shutdown.js.map +1 -0
  188. package/dist/cjs/cli/daemon/index.d.ts +12 -0
  189. package/dist/cjs/cli/daemon/index.d.ts.map +1 -0
  190. package/dist/cjs/cli/daemon/index.js +23 -0
  191. package/dist/cjs/cli/daemon/index.js.map +1 -0
  192. package/dist/cjs/cli/daemon/pid-file.d.ts +13 -0
  193. package/dist/cjs/cli/daemon/pid-file.d.ts.map +1 -0
  194. package/dist/cjs/cli/daemon/pid-file.js +90 -0
  195. package/dist/cjs/cli/daemon/pid-file.js.map +1 -0
  196. package/dist/cjs/cli/daemon/readiness.d.ts +30 -0
  197. package/dist/cjs/cli/daemon/readiness.d.ts.map +1 -0
  198. package/dist/cjs/cli/daemon/readiness.js +74 -0
  199. package/dist/cjs/cli/daemon/readiness.js.map +1 -0
  200. package/dist/cjs/cli/daemon/runtime.d.ts +366 -0
  201. package/dist/cjs/cli/daemon/runtime.d.ts.map +1 -0
  202. package/dist/cjs/cli/daemon/runtime.js +1343 -0
  203. package/dist/cjs/cli/daemon/runtime.js.map +1 -0
  204. package/dist/cjs/cli/daemon/shutdown.d.ts +7 -0
  205. package/dist/cjs/cli/daemon/shutdown.d.ts.map +1 -0
  206. package/dist/cjs/cli/daemon/shutdown.js +66 -0
  207. package/dist/cjs/cli/daemon/shutdown.js.map +1 -0
  208. package/dist/cjs/cli/daemon/signal-handlers.d.ts +3 -0
  209. package/dist/cjs/cli/daemon/signal-handlers.d.ts.map +1 -0
  210. package/dist/cjs/cli/daemon/signal-handlers.js +27 -0
  211. package/dist/cjs/cli/daemon/signal-handlers.js.map +1 -0
  212. package/dist/cjs/cli/daemon/state.d.ts +157 -0
  213. package/dist/cjs/cli/daemon/state.d.ts.map +1 -0
  214. package/dist/cjs/cli/daemon/state.js +397 -0
  215. package/dist/cjs/cli/daemon/state.js.map +1 -0
  216. package/dist/cjs/cli/daemon/status-file.d.ts +139 -0
  217. package/dist/cjs/cli/daemon/status-file.d.ts.map +1 -0
  218. package/dist/cjs/cli/daemon/status-file.js +88 -0
  219. package/dist/cjs/cli/daemon/status-file.js.map +1 -0
  220. package/dist/cjs/cli/doctor/checks.d.ts +133 -0
  221. package/dist/cjs/cli/doctor/checks.d.ts.map +1 -0
  222. package/dist/cjs/cli/doctor/checks.js +677 -0
  223. package/dist/cjs/cli/doctor/checks.js.map +1 -0
  224. package/dist/cjs/cli/doctor/fixes.d.ts +9 -0
  225. package/dist/cjs/cli/doctor/fixes.d.ts.map +1 -0
  226. package/dist/cjs/cli/doctor/fixes.js +199 -0
  227. package/dist/cjs/cli/doctor/fixes.js.map +1 -0
  228. package/dist/cjs/cli/doctor/index.d.ts +7 -0
  229. package/dist/cjs/cli/doctor/index.d.ts.map +1 -0
  230. package/dist/cjs/cli/doctor/index.js +27 -0
  231. package/dist/cjs/cli/doctor/index.js.map +1 -0
  232. package/dist/cjs/cli/index.d.ts +3 -0
  233. package/dist/cjs/cli/index.d.ts.map +1 -0
  234. package/dist/cjs/cli/index.js +336 -0
  235. package/dist/cjs/cli/index.js.map +1 -0
  236. package/dist/cjs/cli/interactive.d.ts +8 -0
  237. package/dist/cjs/cli/interactive.d.ts.map +1 -0
  238. package/dist/cjs/cli/interactive.js +670 -0
  239. package/dist/cjs/cli/interactive.js.map +1 -0
  240. package/dist/cjs/cli/logs/format.d.ts +13 -0
  241. package/dist/cjs/cli/logs/format.d.ts.map +1 -0
  242. package/dist/cjs/cli/logs/format.js +178 -0
  243. package/dist/cjs/cli/logs/format.js.map +1 -0
  244. package/dist/cjs/cli/logs/index.d.ts +3 -0
  245. package/dist/cjs/cli/logs/index.d.ts.map +1 -0
  246. package/dist/cjs/cli/logs/index.js +13 -0
  247. package/dist/cjs/cli/logs/index.js.map +1 -0
  248. package/dist/cjs/cli/logs/viewer.d.ts +41 -0
  249. package/dist/cjs/cli/logs/viewer.d.ts.map +1 -0
  250. package/dist/cjs/cli/logs/viewer.js +417 -0
  251. package/dist/cjs/cli/logs/viewer.js.map +1 -0
  252. package/dist/cjs/cli/ops/operation-logger.d.ts +63 -0
  253. package/dist/cjs/cli/ops/operation-logger.d.ts.map +1 -0
  254. package/dist/cjs/cli/ops/operation-logger.js +183 -0
  255. package/dist/cjs/cli/ops/operation-logger.js.map +1 -0
  256. package/dist/cjs/cli/palette.d.ts +11 -0
  257. package/dist/cjs/cli/palette.d.ts.map +1 -0
  258. package/dist/cjs/cli/palette.js +243 -0
  259. package/dist/cjs/cli/palette.js.map +1 -0
  260. package/dist/cjs/cli/prompt.d.ts +186 -0
  261. package/dist/cjs/cli/prompt.d.ts.map +1 -0
  262. package/dist/cjs/cli/prompt.js +541 -0
  263. package/dist/cjs/cli/prompt.js.map +1 -0
  264. package/dist/cjs/cli/ui/box.d.ts +21 -0
  265. package/dist/cjs/cli/ui/box.d.ts.map +1 -0
  266. package/dist/cjs/cli/ui/box.js +72 -0
  267. package/dist/cjs/cli/ui/box.js.map +1 -0
  268. package/dist/cjs/cli/ui/clipboard.d.ts +6 -0
  269. package/dist/cjs/cli/ui/clipboard.d.ts.map +1 -0
  270. package/dist/cjs/cli/ui/clipboard.js +78 -0
  271. package/dist/cjs/cli/ui/clipboard.js.map +1 -0
  272. package/dist/cjs/cli/ui/colors.d.ts +57 -0
  273. package/dist/cjs/cli/ui/colors.d.ts.map +1 -0
  274. package/dist/cjs/cli/ui/colors.js +151 -0
  275. package/dist/cjs/cli/ui/colors.js.map +1 -0
  276. package/dist/cjs/cli/ui/index.d.ts +9 -0
  277. package/dist/cjs/cli/ui/index.d.ts.map +1 -0
  278. package/dist/cjs/cli/ui/index.js +55 -0
  279. package/dist/cjs/cli/ui/index.js.map +1 -0
  280. package/dist/cjs/cli/ui/spinner.d.ts +12 -0
  281. package/dist/cjs/cli/ui/spinner.d.ts.map +1 -0
  282. package/dist/cjs/cli/ui/spinner.js +82 -0
  283. package/dist/cjs/cli/ui/spinner.js.map +1 -0
  284. package/dist/cjs/cli/ui/symbols.d.ts +47 -0
  285. package/dist/cjs/cli/ui/symbols.d.ts.map +1 -0
  286. package/dist/cjs/cli/ui/symbols.js +112 -0
  287. package/dist/cjs/cli/ui/symbols.js.map +1 -0
  288. package/dist/cjs/cli/ui/table.d.ts +23 -0
  289. package/dist/cjs/cli/ui/table.d.ts.map +1 -0
  290. package/dist/cjs/cli/ui/table.js +160 -0
  291. package/dist/cjs/cli/ui/table.js.map +1 -0
  292. package/dist/cjs/cli/ui/terminal.d.ts +7 -0
  293. package/dist/cjs/cli/ui/terminal.d.ts.map +1 -0
  294. package/dist/cjs/cli/ui/terminal.js +40 -0
  295. package/dist/cjs/cli/ui/terminal.js.map +1 -0
  296. package/dist/cjs/config/atomic-write.d.ts +69 -0
  297. package/dist/cjs/config/atomic-write.d.ts.map +1 -0
  298. package/dist/cjs/config/atomic-write.js +289 -0
  299. package/dist/cjs/config/atomic-write.js.map +1 -0
  300. package/dist/cjs/config/db-config.d.ts +134 -0
  301. package/dist/cjs/config/db-config.d.ts.map +1 -0
  302. package/dist/cjs/config/db-config.js +594 -0
  303. package/dist/cjs/config/db-config.js.map +1 -0
  304. package/dist/cjs/config/machine-config.d.ts +85 -0
  305. package/dist/cjs/config/machine-config.d.ts.map +1 -0
  306. package/dist/cjs/config/machine-config.js +232 -0
  307. package/dist/cjs/config/machine-config.js.map +1 -0
  308. package/dist/cjs/config/paths.d.ts +64 -0
  309. package/dist/cjs/config/paths.d.ts.map +1 -0
  310. package/dist/cjs/config/paths.js +155 -0
  311. package/dist/cjs/config/paths.js.map +1 -0
  312. package/dist/cjs/config/schema.d.ts +72 -0
  313. package/dist/cjs/config/schema.d.ts.map +1 -0
  314. package/dist/cjs/config/schema.js +197 -0
  315. package/dist/cjs/config/schema.js.map +1 -0
  316. package/dist/cjs/config/token.d.ts +63 -0
  317. package/dist/cjs/config/token.d.ts.map +1 -0
  318. package/dist/cjs/config/token.js +146 -0
  319. package/dist/cjs/config/token.js.map +1 -0
  320. package/dist/cjs/execution/canceller.d.ts +41 -0
  321. package/dist/cjs/execution/canceller.d.ts.map +1 -0
  322. package/dist/cjs/execution/canceller.js +209 -0
  323. package/dist/cjs/execution/canceller.js.map +1 -0
  324. package/dist/cjs/execution/database-lookup.d.ts +56 -0
  325. package/dist/cjs/execution/database-lookup.d.ts.map +1 -0
  326. package/dist/cjs/execution/database-lookup.js +43 -0
  327. package/dist/cjs/execution/database-lookup.js.map +1 -0
  328. package/dist/cjs/execution/dispatcher.d.ts +181 -0
  329. package/dist/cjs/execution/dispatcher.d.ts.map +1 -0
  330. package/dist/cjs/execution/dispatcher.js +1296 -0
  331. package/dist/cjs/execution/dispatcher.js.map +1 -0
  332. package/dist/cjs/execution/function-effects.d.ts +209 -0
  333. package/dist/cjs/execution/function-effects.d.ts.map +1 -0
  334. package/dist/cjs/execution/function-effects.js +596 -0
  335. package/dist/cjs/execution/function-effects.js.map +1 -0
  336. package/dist/cjs/execution/introspection.d.ts +76 -0
  337. package/dist/cjs/execution/introspection.d.ts.map +1 -0
  338. package/dist/cjs/execution/introspection.js +448 -0
  339. package/dist/cjs/execution/introspection.js.map +1 -0
  340. package/dist/cjs/execution/migration-runner.d.ts +128 -0
  341. package/dist/cjs/execution/migration-runner.d.ts.map +1 -0
  342. package/dist/cjs/execution/migration-runner.js +798 -0
  343. package/dist/cjs/execution/migration-runner.js.map +1 -0
  344. package/dist/cjs/execution/non-tx-detector.d.ts +23 -0
  345. package/dist/cjs/execution/non-tx-detector.d.ts.map +1 -0
  346. package/dist/cjs/execution/non-tx-detector.js +218 -0
  347. package/dist/cjs/execution/non-tx-detector.js.map +1 -0
  348. package/dist/cjs/execution/pool.d.ts +229 -0
  349. package/dist/cjs/execution/pool.d.ts.map +1 -0
  350. package/dist/cjs/execution/pool.js +738 -0
  351. package/dist/cjs/execution/pool.js.map +1 -0
  352. package/dist/cjs/execution/query-runner.d.ts +88 -0
  353. package/dist/cjs/execution/query-runner.d.ts.map +1 -0
  354. package/dist/cjs/execution/query-runner.js +751 -0
  355. package/dist/cjs/execution/query-runner.js.map +1 -0
  356. package/dist/cjs/execution/rate-limiter.d.ts +120 -0
  357. package/dist/cjs/execution/rate-limiter.d.ts.map +1 -0
  358. package/dist/cjs/execution/rate-limiter.js +273 -0
  359. package/dist/cjs/execution/rate-limiter.js.map +1 -0
  360. package/dist/cjs/execution/search-path.d.ts +161 -0
  361. package/dist/cjs/execution/search-path.d.ts.map +1 -0
  362. package/dist/cjs/execution/search-path.js +279 -0
  363. package/dist/cjs/execution/search-path.js.map +1 -0
  364. package/dist/cjs/execution/sql-parser.d.ts +195 -0
  365. package/dist/cjs/execution/sql-parser.d.ts.map +1 -0
  366. package/dist/cjs/execution/sql-parser.js +704 -0
  367. package/dist/cjs/execution/sql-parser.js.map +1 -0
  368. package/dist/cjs/execution/statement-classifier.d.ts +103 -0
  369. package/dist/cjs/execution/statement-classifier.d.ts.map +1 -0
  370. package/dist/cjs/execution/statement-classifier.js +535 -0
  371. package/dist/cjs/execution/statement-classifier.js.map +1 -0
  372. package/dist/cjs/execution/types.d.ts +189 -0
  373. package/dist/cjs/execution/types.d.ts.map +1 -0
  374. package/dist/cjs/execution/types.js +28 -0
  375. package/dist/cjs/execution/types.js.map +1 -0
  376. package/dist/cjs/index.d.ts +34 -0
  377. package/dist/cjs/index.d.ts.map +1 -0
  378. package/dist/cjs/index.js +98 -0
  379. package/dist/cjs/index.js.map +1 -0
  380. package/dist/cjs/permissions/auto-upgrade.d.ts +40 -0
  381. package/dist/cjs/permissions/auto-upgrade.d.ts.map +1 -0
  382. package/dist/cjs/permissions/auto-upgrade.js +168 -0
  383. package/dist/cjs/permissions/auto-upgrade.js.map +1 -0
  384. package/dist/cjs/permissions/checker.d.ts +53 -0
  385. package/dist/cjs/permissions/checker.d.ts.map +1 -0
  386. package/dist/cjs/permissions/checker.js +326 -0
  387. package/dist/cjs/permissions/checker.js.map +1 -0
  388. package/dist/cjs/permissions/manual-approval.d.ts +213 -0
  389. package/dist/cjs/permissions/manual-approval.d.ts.map +1 -0
  390. package/dist/cjs/permissions/manual-approval.js +541 -0
  391. package/dist/cjs/permissions/manual-approval.js.map +1 -0
  392. package/dist/cjs/permissions/plan-registry.d.ts +274 -0
  393. package/dist/cjs/permissions/plan-registry.d.ts.map +1 -0
  394. package/dist/cjs/permissions/plan-registry.js +454 -0
  395. package/dist/cjs/permissions/plan-registry.js.map +1 -0
  396. package/dist/cjs/permissions/role-policy.d.ts +217 -0
  397. package/dist/cjs/permissions/role-policy.d.ts.map +1 -0
  398. package/dist/cjs/permissions/role-policy.js +584 -0
  399. package/dist/cjs/permissions/role-policy.js.map +1 -0
  400. package/dist/cjs/permissions/types.d.ts +126 -0
  401. package/dist/cjs/permissions/types.d.ts.map +1 -0
  402. package/dist/cjs/permissions/types.js +3 -0
  403. package/dist/cjs/permissions/types.js.map +1 -0
  404. package/dist/cjs/protocol/constants.d.ts +72 -0
  405. package/dist/cjs/protocol/constants.d.ts.map +1 -0
  406. package/dist/cjs/protocol/constants.js +107 -0
  407. package/dist/cjs/protocol/constants.js.map +1 -0
  408. package/dist/cjs/protocol/envelope.d.ts +165 -0
  409. package/dist/cjs/protocol/envelope.d.ts.map +1 -0
  410. package/dist/cjs/protocol/envelope.js +309 -0
  411. package/dist/cjs/protocol/envelope.js.map +1 -0
  412. package/dist/cjs/protocol/errors.d.ts +33 -0
  413. package/dist/cjs/protocol/errors.d.ts.map +1 -0
  414. package/dist/cjs/protocol/errors.js +391 -0
  415. package/dist/cjs/protocol/errors.js.map +1 -0
  416. package/dist/cjs/protocol/messages.d.ts +327 -0
  417. package/dist/cjs/protocol/messages.d.ts.map +1 -0
  418. package/dist/cjs/protocol/messages.js +3 -0
  419. package/dist/cjs/protocol/messages.js.map +1 -0
  420. package/dist/cjs/protocol/serialize.d.ts +26 -0
  421. package/dist/cjs/protocol/serialize.d.ts.map +1 -0
  422. package/dist/cjs/protocol/serialize.js +71 -0
  423. package/dist/cjs/protocol/serialize.js.map +1 -0
  424. package/dist/cjs/protocol/validate.d.ts +135 -0
  425. package/dist/cjs/protocol/validate.d.ts.map +1 -0
  426. package/dist/cjs/protocol/validate.js +852 -0
  427. package/dist/cjs/protocol/validate.js.map +1 -0
  428. package/dist/esm/audit/chain.d.ts +365 -0
  429. package/dist/esm/audit/chain.d.ts.map +1 -0
  430. package/dist/esm/audit/chain.js +895 -0
  431. package/dist/esm/audit/chain.js.map +1 -0
  432. package/dist/esm/audit/cloud-client.d.ts +142 -0
  433. package/dist/esm/audit/cloud-client.d.ts.map +1 -0
  434. package/dist/esm/audit/cloud-client.js +326 -0
  435. package/dist/esm/audit/cloud-client.js.map +1 -0
  436. package/dist/esm/audit/cloud-writer.d.ts +57 -0
  437. package/dist/esm/audit/cloud-writer.d.ts.map +1 -0
  438. package/dist/esm/audit/cloud-writer.js +91 -0
  439. package/dist/esm/audit/cloud-writer.js.map +1 -0
  440. package/dist/esm/audit/context.d.ts +51 -0
  441. package/dist/esm/audit/context.d.ts.map +1 -0
  442. package/dist/esm/audit/context.js +69 -0
  443. package/dist/esm/audit/context.js.map +1 -0
  444. package/dist/esm/audit/files.d.ts +111 -0
  445. package/dist/esm/audit/files.d.ts.map +1 -0
  446. package/dist/esm/audit/files.js +361 -0
  447. package/dist/esm/audit/files.js.map +1 -0
  448. package/dist/esm/audit/index.d.ts +9 -0
  449. package/dist/esm/audit/index.d.ts.map +1 -0
  450. package/dist/esm/audit/index.js +8 -0
  451. package/dist/esm/audit/index.js.map +1 -0
  452. package/dist/esm/audit/local-writer.d.ts +255 -0
  453. package/dist/esm/audit/local-writer.d.ts.map +1 -0
  454. package/dist/esm/audit/local-writer.js +785 -0
  455. package/dist/esm/audit/local-writer.js.map +1 -0
  456. package/dist/esm/audit/redact.d.ts +151 -0
  457. package/dist/esm/audit/redact.d.ts.map +1 -0
  458. package/dist/esm/audit/redact.js +506 -0
  459. package/dist/esm/audit/redact.js.map +1 -0
  460. package/dist/esm/audit/sanitize.d.ts +78 -0
  461. package/dist/esm/audit/sanitize.d.ts.map +1 -0
  462. package/dist/esm/audit/sanitize.js +307 -0
  463. package/dist/esm/audit/sanitize.js.map +1 -0
  464. package/dist/esm/audit/sink.d.ts +278 -0
  465. package/dist/esm/audit/sink.d.ts.map +1 -0
  466. package/dist/esm/audit/sink.js +782 -0
  467. package/dist/esm/audit/sink.js.map +1 -0
  468. package/dist/esm/audit/types.d.ts +226 -0
  469. package/dist/esm/audit/types.d.ts.map +1 -0
  470. package/dist/esm/audit/types.js +2 -0
  471. package/dist/esm/audit/types.js.map +1 -0
  472. package/dist/esm/audit/verify-cache.d.ts +127 -0
  473. package/dist/esm/audit/verify-cache.d.ts.map +1 -0
  474. package/dist/esm/audit/verify-cache.js +628 -0
  475. package/dist/esm/audit/verify-cache.js.map +1 -0
  476. package/dist/esm/channels/agent-session.d.ts +228 -0
  477. package/dist/esm/channels/agent-session.d.ts.map +1 -0
  478. package/dist/esm/channels/agent-session.js +566 -0
  479. package/dist/esm/channels/agent-session.js.map +1 -0
  480. package/dist/esm/channels/data-channel.d.ts +181 -0
  481. package/dist/esm/channels/data-channel.d.ts.map +1 -0
  482. package/dist/esm/channels/data-channel.js +567 -0
  483. package/dist/esm/channels/data-channel.js.map +1 -0
  484. package/dist/esm/channels/reconnect.d.ts +142 -0
  485. package/dist/esm/channels/reconnect.d.ts.map +1 -0
  486. package/dist/esm/channels/reconnect.js +234 -0
  487. package/dist/esm/channels/reconnect.js.map +1 -0
  488. package/dist/esm/channels/types.d.ts +112 -0
  489. package/dist/esm/channels/types.d.ts.map +1 -0
  490. package/dist/esm/channels/types.js +2 -0
  491. package/dist/esm/channels/types.js.map +1 -0
  492. package/dist/esm/channels/wake-channel.d.ts +232 -0
  493. package/dist/esm/channels/wake-channel.d.ts.map +1 -0
  494. package/dist/esm/channels/wake-channel.js +715 -0
  495. package/dist/esm/channels/wake-channel.js.map +1 -0
  496. package/dist/esm/cli/banner.d.ts +2 -0
  497. package/dist/esm/cli/banner.d.ts.map +1 -0
  498. package/dist/esm/cli/banner.js +114 -0
  499. package/dist/esm/cli/banner.js.map +1 -0
  500. package/dist/esm/cli/commands/agent.d.ts +30 -0
  501. package/dist/esm/cli/commands/agent.d.ts.map +1 -0
  502. package/dist/esm/cli/commands/agent.js +204 -0
  503. package/dist/esm/cli/commands/agent.js.map +1 -0
  504. package/dist/esm/cli/commands/audit-verify.d.ts +19 -0
  505. package/dist/esm/cli/commands/audit-verify.d.ts.map +1 -0
  506. package/dist/esm/cli/commands/audit-verify.js +345 -0
  507. package/dist/esm/cli/commands/audit-verify.js.map +1 -0
  508. package/dist/esm/cli/commands/clean.d.ts +23 -0
  509. package/dist/esm/cli/commands/clean.d.ts.map +1 -0
  510. package/dist/esm/cli/commands/clean.js +235 -0
  511. package/dist/esm/cli/commands/clean.js.map +1 -0
  512. package/dist/esm/cli/commands/config-show.d.ts +2 -0
  513. package/dist/esm/cli/commands/config-show.d.ts.map +1 -0
  514. package/dist/esm/cli/commands/config-show.js +2 -0
  515. package/dist/esm/cli/commands/config-show.js.map +1 -0
  516. package/dist/esm/cli/commands/config.d.ts +6 -0
  517. package/dist/esm/cli/commands/config.d.ts.map +1 -0
  518. package/dist/esm/cli/commands/config.js +259 -0
  519. package/dist/esm/cli/commands/config.js.map +1 -0
  520. package/dist/esm/cli/commands/db-add.d.ts +16 -0
  521. package/dist/esm/cli/commands/db-add.d.ts.map +1 -0
  522. package/dist/esm/cli/commands/db-add.js +576 -0
  523. package/dist/esm/cli/commands/db-add.js.map +1 -0
  524. package/dist/esm/cli/commands/db-edit.d.ts +2 -0
  525. package/dist/esm/cli/commands/db-edit.d.ts.map +1 -0
  526. package/dist/esm/cli/commands/db-edit.js +352 -0
  527. package/dist/esm/cli/commands/db-edit.js.map +1 -0
  528. package/dist/esm/cli/commands/db-logs.d.ts +3 -0
  529. package/dist/esm/cli/commands/db-logs.d.ts.map +1 -0
  530. package/dist/esm/cli/commands/db-logs.js +64 -0
  531. package/dist/esm/cli/commands/db-logs.js.map +1 -0
  532. package/dist/esm/cli/commands/db-ls.d.ts +2 -0
  533. package/dist/esm/cli/commands/db-ls.d.ts.map +1 -0
  534. package/dist/esm/cli/commands/db-ls.js +115 -0
  535. package/dist/esm/cli/commands/db-ls.js.map +1 -0
  536. package/dist/esm/cli/commands/db-query.d.ts +121 -0
  537. package/dist/esm/cli/commands/db-query.d.ts.map +1 -0
  538. package/dist/esm/cli/commands/db-query.js +754 -0
  539. package/dist/esm/cli/commands/db-query.js.map +1 -0
  540. package/dist/esm/cli/commands/db-remove.d.ts +2 -0
  541. package/dist/esm/cli/commands/db-remove.d.ts.map +1 -0
  542. package/dist/esm/cli/commands/db-remove.js +48 -0
  543. package/dist/esm/cli/commands/db-remove.js.map +1 -0
  544. package/dist/esm/cli/commands/db-show.d.ts +2 -0
  545. package/dist/esm/cli/commands/db-show.d.ts.map +1 -0
  546. package/dist/esm/cli/commands/db-show.js +131 -0
  547. package/dist/esm/cli/commands/db-show.js.map +1 -0
  548. package/dist/esm/cli/commands/db-test.d.ts +3 -0
  549. package/dist/esm/cli/commands/db-test.d.ts.map +1 -0
  550. package/dist/esm/cli/commands/db-test.js +307 -0
  551. package/dist/esm/cli/commands/db-test.js.map +1 -0
  552. package/dist/esm/cli/commands/db.d.ts +11 -0
  553. package/dist/esm/cli/commands/db.d.ts.map +1 -0
  554. package/dist/esm/cli/commands/db.js +76 -0
  555. package/dist/esm/cli/commands/db.js.map +1 -0
  556. package/dist/esm/cli/commands/debug.d.ts +2 -0
  557. package/dist/esm/cli/commands/debug.d.ts.map +1 -0
  558. package/dist/esm/cli/commands/debug.js +205 -0
  559. package/dist/esm/cli/commands/debug.js.map +1 -0
  560. package/dist/esm/cli/commands/doctor.d.ts +5 -0
  561. package/dist/esm/cli/commands/doctor.d.ts.map +1 -0
  562. package/dist/esm/cli/commands/doctor.js +114 -0
  563. package/dist/esm/cli/commands/doctor.js.map +1 -0
  564. package/dist/esm/cli/commands/index.d.ts +10 -0
  565. package/dist/esm/cli/commands/index.d.ts.map +1 -0
  566. package/dist/esm/cli/commands/index.js +10 -0
  567. package/dist/esm/cli/commands/index.js.map +1 -0
  568. package/dist/esm/cli/commands/init.d.ts +2 -0
  569. package/dist/esm/cli/commands/init.d.ts.map +1 -0
  570. package/dist/esm/cli/commands/init.js +163 -0
  571. package/dist/esm/cli/commands/init.js.map +1 -0
  572. package/dist/esm/cli/commands/link.d.ts +5 -0
  573. package/dist/esm/cli/commands/link.d.ts.map +1 -0
  574. package/dist/esm/cli/commands/link.js +41 -0
  575. package/dist/esm/cli/commands/link.js.map +1 -0
  576. package/dist/esm/cli/commands/logs.d.ts +17 -0
  577. package/dist/esm/cli/commands/logs.d.ts.map +1 -0
  578. package/dist/esm/cli/commands/logs.js +278 -0
  579. package/dist/esm/cli/commands/logs.js.map +1 -0
  580. package/dist/esm/cli/commands/project-show.d.ts +2 -0
  581. package/dist/esm/cli/commands/project-show.d.ts.map +1 -0
  582. package/dist/esm/cli/commands/project-show.js +69 -0
  583. package/dist/esm/cli/commands/project-show.js.map +1 -0
  584. package/dist/esm/cli/commands/project.d.ts +3 -0
  585. package/dist/esm/cli/commands/project.d.ts.map +1 -0
  586. package/dist/esm/cli/commands/project.js +60 -0
  587. package/dist/esm/cli/commands/project.js.map +1 -0
  588. package/dist/esm/cli/commands/service.d.ts +123 -0
  589. package/dist/esm/cli/commands/service.d.ts.map +1 -0
  590. package/dist/esm/cli/commands/service.js +505 -0
  591. package/dist/esm/cli/commands/service.js.map +1 -0
  592. package/dist/esm/cli/commands/start.d.ts +6 -0
  593. package/dist/esm/cli/commands/start.d.ts.map +1 -0
  594. package/dist/esm/cli/commands/start.js +272 -0
  595. package/dist/esm/cli/commands/start.js.map +1 -0
  596. package/dist/esm/cli/commands/status.d.ts +2 -0
  597. package/dist/esm/cli/commands/status.d.ts.map +1 -0
  598. package/dist/esm/cli/commands/status.js +222 -0
  599. package/dist/esm/cli/commands/status.js.map +1 -0
  600. package/dist/esm/cli/commands/stop.d.ts +6 -0
  601. package/dist/esm/cli/commands/stop.d.ts.map +1 -0
  602. package/dist/esm/cli/commands/stop.js +96 -0
  603. package/dist/esm/cli/commands/stop.js.map +1 -0
  604. package/dist/esm/cli/daemon/error-tracker.d.ts +119 -0
  605. package/dist/esm/cli/daemon/error-tracker.d.ts.map +1 -0
  606. package/dist/esm/cli/daemon/error-tracker.js +451 -0
  607. package/dist/esm/cli/daemon/error-tracker.js.map +1 -0
  608. package/dist/esm/cli/daemon/fault-shutdown.d.ts +144 -0
  609. package/dist/esm/cli/daemon/fault-shutdown.d.ts.map +1 -0
  610. package/dist/esm/cli/daemon/fault-shutdown.js +273 -0
  611. package/dist/esm/cli/daemon/fault-shutdown.js.map +1 -0
  612. package/dist/esm/cli/daemon/index.d.ts +12 -0
  613. package/dist/esm/cli/daemon/index.d.ts.map +1 -0
  614. package/dist/esm/cli/daemon/index.js +7 -0
  615. package/dist/esm/cli/daemon/index.js.map +1 -0
  616. package/dist/esm/cli/daemon/pid-file.d.ts +13 -0
  617. package/dist/esm/cli/daemon/pid-file.d.ts.map +1 -0
  618. package/dist/esm/cli/daemon/pid-file.js +51 -0
  619. package/dist/esm/cli/daemon/pid-file.js.map +1 -0
  620. package/dist/esm/cli/daemon/readiness.d.ts +30 -0
  621. package/dist/esm/cli/daemon/readiness.d.ts.map +1 -0
  622. package/dist/esm/cli/daemon/readiness.js +70 -0
  623. package/dist/esm/cli/daemon/readiness.js.map +1 -0
  624. package/dist/esm/cli/daemon/runtime.d.ts +366 -0
  625. package/dist/esm/cli/daemon/runtime.d.ts.map +1 -0
  626. package/dist/esm/cli/daemon/runtime.js +1284 -0
  627. package/dist/esm/cli/daemon/runtime.js.map +1 -0
  628. package/dist/esm/cli/daemon/shutdown.d.ts +7 -0
  629. package/dist/esm/cli/daemon/shutdown.d.ts.map +1 -0
  630. package/dist/esm/cli/daemon/shutdown.js +63 -0
  631. package/dist/esm/cli/daemon/shutdown.js.map +1 -0
  632. package/dist/esm/cli/daemon/signal-handlers.d.ts +3 -0
  633. package/dist/esm/cli/daemon/signal-handlers.d.ts.map +1 -0
  634. package/dist/esm/cli/daemon/signal-handlers.js +24 -0
  635. package/dist/esm/cli/daemon/signal-handlers.js.map +1 -0
  636. package/dist/esm/cli/daemon/state.d.ts +157 -0
  637. package/dist/esm/cli/daemon/state.d.ts.map +1 -0
  638. package/dist/esm/cli/daemon/state.js +352 -0
  639. package/dist/esm/cli/daemon/state.js.map +1 -0
  640. package/dist/esm/cli/daemon/status-file.d.ts +139 -0
  641. package/dist/esm/cli/daemon/status-file.d.ts.map +1 -0
  642. package/dist/esm/cli/daemon/status-file.js +50 -0
  643. package/dist/esm/cli/daemon/status-file.js.map +1 -0
  644. package/dist/esm/cli/doctor/checks.d.ts +133 -0
  645. package/dist/esm/cli/doctor/checks.d.ts.map +1 -0
  646. package/dist/esm/cli/doctor/checks.js +624 -0
  647. package/dist/esm/cli/doctor/checks.js.map +1 -0
  648. package/dist/esm/cli/doctor/fixes.d.ts +9 -0
  649. package/dist/esm/cli/doctor/fixes.d.ts.map +1 -0
  650. package/dist/esm/cli/doctor/fixes.js +163 -0
  651. package/dist/esm/cli/doctor/fixes.js.map +1 -0
  652. package/dist/esm/cli/doctor/index.d.ts +7 -0
  653. package/dist/esm/cli/doctor/index.d.ts.map +1 -0
  654. package/dist/esm/cli/doctor/index.js +5 -0
  655. package/dist/esm/cli/doctor/index.js.map +1 -0
  656. package/dist/esm/cli/index.d.ts +3 -0
  657. package/dist/esm/cli/index.d.ts.map +1 -0
  658. package/dist/esm/cli/index.js +333 -0
  659. package/dist/esm/cli/index.js.map +1 -0
  660. package/dist/esm/cli/interactive.d.ts +8 -0
  661. package/dist/esm/cli/interactive.d.ts.map +1 -0
  662. package/dist/esm/cli/interactive.js +665 -0
  663. package/dist/esm/cli/interactive.js.map +1 -0
  664. package/dist/esm/cli/logs/format.d.ts +13 -0
  665. package/dist/esm/cli/logs/format.d.ts.map +1 -0
  666. package/dist/esm/cli/logs/format.js +169 -0
  667. package/dist/esm/cli/logs/format.js.map +1 -0
  668. package/dist/esm/cli/logs/index.d.ts +3 -0
  669. package/dist/esm/cli/logs/index.d.ts.map +1 -0
  670. package/dist/esm/cli/logs/index.js +3 -0
  671. package/dist/esm/cli/logs/index.js.map +1 -0
  672. package/dist/esm/cli/logs/viewer.d.ts +41 -0
  673. package/dist/esm/cli/logs/viewer.d.ts.map +1 -0
  674. package/dist/esm/cli/logs/viewer.js +412 -0
  675. package/dist/esm/cli/logs/viewer.js.map +1 -0
  676. package/dist/esm/cli/ops/operation-logger.d.ts +63 -0
  677. package/dist/esm/cli/ops/operation-logger.d.ts.map +1 -0
  678. package/dist/esm/cli/ops/operation-logger.js +142 -0
  679. package/dist/esm/cli/ops/operation-logger.js.map +1 -0
  680. package/dist/esm/cli/palette.d.ts +11 -0
  681. package/dist/esm/cli/palette.d.ts.map +1 -0
  682. package/dist/esm/cli/palette.js +240 -0
  683. package/dist/esm/cli/palette.js.map +1 -0
  684. package/dist/esm/cli/prompt.d.ts +186 -0
  685. package/dist/esm/cli/prompt.d.ts.map +1 -0
  686. package/dist/esm/cli/prompt.js +483 -0
  687. package/dist/esm/cli/prompt.js.map +1 -0
  688. package/dist/esm/cli/ui/box.d.ts +21 -0
  689. package/dist/esm/cli/ui/box.d.ts.map +1 -0
  690. package/dist/esm/cli/ui/box.js +60 -0
  691. package/dist/esm/cli/ui/box.js.map +1 -0
  692. package/dist/esm/cli/ui/clipboard.d.ts +6 -0
  693. package/dist/esm/cli/ui/clipboard.d.ts.map +1 -0
  694. package/dist/esm/cli/ui/clipboard.js +42 -0
  695. package/dist/esm/cli/ui/clipboard.js.map +1 -0
  696. package/dist/esm/cli/ui/colors.d.ts +57 -0
  697. package/dist/esm/cli/ui/colors.d.ts.map +1 -0
  698. package/dist/esm/cli/ui/colors.js +126 -0
  699. package/dist/esm/cli/ui/colors.js.map +1 -0
  700. package/dist/esm/cli/ui/index.d.ts +9 -0
  701. package/dist/esm/cli/ui/index.d.ts.map +1 -0
  702. package/dist/esm/cli/ui/index.js +7 -0
  703. package/dist/esm/cli/ui/index.js.map +1 -0
  704. package/dist/esm/cli/ui/spinner.d.ts +12 -0
  705. package/dist/esm/cli/ui/spinner.d.ts.map +1 -0
  706. package/dist/esm/cli/ui/spinner.js +78 -0
  707. package/dist/esm/cli/ui/spinner.js.map +1 -0
  708. package/dist/esm/cli/ui/symbols.d.ts +47 -0
  709. package/dist/esm/cli/ui/symbols.d.ts.map +1 -0
  710. package/dist/esm/cli/ui/symbols.js +109 -0
  711. package/dist/esm/cli/ui/symbols.js.map +1 -0
  712. package/dist/esm/cli/ui/table.d.ts +23 -0
  713. package/dist/esm/cli/ui/table.d.ts.map +1 -0
  714. package/dist/esm/cli/ui/table.js +156 -0
  715. package/dist/esm/cli/ui/table.js.map +1 -0
  716. package/dist/esm/cli/ui/terminal.d.ts +7 -0
  717. package/dist/esm/cli/ui/terminal.d.ts.map +1 -0
  718. package/dist/esm/cli/ui/terminal.js +32 -0
  719. package/dist/esm/cli/ui/terminal.js.map +1 -0
  720. package/dist/esm/config/atomic-write.d.ts +69 -0
  721. package/dist/esm/config/atomic-write.d.ts.map +1 -0
  722. package/dist/esm/config/atomic-write.js +246 -0
  723. package/dist/esm/config/atomic-write.js.map +1 -0
  724. package/dist/esm/config/db-config.d.ts +134 -0
  725. package/dist/esm/config/db-config.d.ts.map +1 -0
  726. package/dist/esm/config/db-config.js +542 -0
  727. package/dist/esm/config/db-config.js.map +1 -0
  728. package/dist/esm/config/machine-config.d.ts +85 -0
  729. package/dist/esm/config/machine-config.d.ts.map +1 -0
  730. package/dist/esm/config/machine-config.js +190 -0
  731. package/dist/esm/config/machine-config.js.map +1 -0
  732. package/dist/esm/config/paths.d.ts +64 -0
  733. package/dist/esm/config/paths.d.ts.map +1 -0
  734. package/dist/esm/config/paths.js +108 -0
  735. package/dist/esm/config/paths.js.map +1 -0
  736. package/dist/esm/config/schema.d.ts +72 -0
  737. package/dist/esm/config/schema.d.ts.map +1 -0
  738. package/dist/esm/config/schema.js +180 -0
  739. package/dist/esm/config/schema.js.map +1 -0
  740. package/dist/esm/config/token.d.ts +63 -0
  741. package/dist/esm/config/token.d.ts.map +1 -0
  742. package/dist/esm/config/token.js +104 -0
  743. package/dist/esm/config/token.js.map +1 -0
  744. package/dist/esm/execution/canceller.d.ts +41 -0
  745. package/dist/esm/execution/canceller.d.ts.map +1 -0
  746. package/dist/esm/execution/canceller.js +205 -0
  747. package/dist/esm/execution/canceller.js.map +1 -0
  748. package/dist/esm/execution/database-lookup.d.ts +56 -0
  749. package/dist/esm/execution/database-lookup.d.ts.map +1 -0
  750. package/dist/esm/execution/database-lookup.js +38 -0
  751. package/dist/esm/execution/database-lookup.js.map +1 -0
  752. package/dist/esm/execution/dispatcher.d.ts +181 -0
  753. package/dist/esm/execution/dispatcher.d.ts.map +1 -0
  754. package/dist/esm/execution/dispatcher.js +1258 -0
  755. package/dist/esm/execution/dispatcher.js.map +1 -0
  756. package/dist/esm/execution/function-effects.d.ts +209 -0
  757. package/dist/esm/execution/function-effects.d.ts.map +1 -0
  758. package/dist/esm/execution/function-effects.js +586 -0
  759. package/dist/esm/execution/function-effects.js.map +1 -0
  760. package/dist/esm/execution/introspection.d.ts +76 -0
  761. package/dist/esm/execution/introspection.d.ts.map +1 -0
  762. package/dist/esm/execution/introspection.js +442 -0
  763. package/dist/esm/execution/introspection.js.map +1 -0
  764. package/dist/esm/execution/migration-runner.d.ts +128 -0
  765. package/dist/esm/execution/migration-runner.d.ts.map +1 -0
  766. package/dist/esm/execution/migration-runner.js +754 -0
  767. package/dist/esm/execution/migration-runner.js.map +1 -0
  768. package/dist/esm/execution/non-tx-detector.d.ts +23 -0
  769. package/dist/esm/execution/non-tx-detector.d.ts.map +1 -0
  770. package/dist/esm/execution/non-tx-detector.js +215 -0
  771. package/dist/esm/execution/non-tx-detector.js.map +1 -0
  772. package/dist/esm/execution/pool.d.ts +229 -0
  773. package/dist/esm/execution/pool.d.ts.map +1 -0
  774. package/dist/esm/execution/pool.js +685 -0
  775. package/dist/esm/execution/pool.js.map +1 -0
  776. package/dist/esm/execution/query-runner.d.ts +88 -0
  777. package/dist/esm/execution/query-runner.d.ts.map +1 -0
  778. package/dist/esm/execution/query-runner.js +743 -0
  779. package/dist/esm/execution/query-runner.js.map +1 -0
  780. package/dist/esm/execution/rate-limiter.d.ts +120 -0
  781. package/dist/esm/execution/rate-limiter.d.ts.map +1 -0
  782. package/dist/esm/execution/rate-limiter.js +269 -0
  783. package/dist/esm/execution/rate-limiter.js.map +1 -0
  784. package/dist/esm/execution/search-path.d.ts +161 -0
  785. package/dist/esm/execution/search-path.d.ts.map +1 -0
  786. package/dist/esm/execution/search-path.js +270 -0
  787. package/dist/esm/execution/search-path.js.map +1 -0
  788. package/dist/esm/execution/sql-parser.d.ts +195 -0
  789. package/dist/esm/execution/sql-parser.d.ts.map +1 -0
  790. package/dist/esm/execution/sql-parser.js +683 -0
  791. package/dist/esm/execution/sql-parser.js.map +1 -0
  792. package/dist/esm/execution/statement-classifier.d.ts +103 -0
  793. package/dist/esm/execution/statement-classifier.d.ts.map +1 -0
  794. package/dist/esm/execution/statement-classifier.js +526 -0
  795. package/dist/esm/execution/statement-classifier.js.map +1 -0
  796. package/dist/esm/execution/types.d.ts +189 -0
  797. package/dist/esm/execution/types.d.ts.map +1 -0
  798. package/dist/esm/execution/types.js +22 -0
  799. package/dist/esm/execution/types.js.map +1 -0
  800. package/dist/esm/index.d.ts +34 -0
  801. package/dist/esm/index.d.ts.map +1 -0
  802. package/dist/esm/index.js +38 -0
  803. package/dist/esm/index.js.map +1 -0
  804. package/dist/esm/permissions/auto-upgrade.d.ts +40 -0
  805. package/dist/esm/permissions/auto-upgrade.d.ts.map +1 -0
  806. package/dist/esm/permissions/auto-upgrade.js +164 -0
  807. package/dist/esm/permissions/auto-upgrade.js.map +1 -0
  808. package/dist/esm/permissions/checker.d.ts +53 -0
  809. package/dist/esm/permissions/checker.d.ts.map +1 -0
  810. package/dist/esm/permissions/checker.js +322 -0
  811. package/dist/esm/permissions/checker.js.map +1 -0
  812. package/dist/esm/permissions/manual-approval.d.ts +213 -0
  813. package/dist/esm/permissions/manual-approval.d.ts.map +1 -0
  814. package/dist/esm/permissions/manual-approval.js +503 -0
  815. package/dist/esm/permissions/manual-approval.js.map +1 -0
  816. package/dist/esm/permissions/plan-registry.d.ts +274 -0
  817. package/dist/esm/permissions/plan-registry.d.ts.map +1 -0
  818. package/dist/esm/permissions/plan-registry.js +450 -0
  819. package/dist/esm/permissions/plan-registry.js.map +1 -0
  820. package/dist/esm/permissions/role-policy.d.ts +217 -0
  821. package/dist/esm/permissions/role-policy.d.ts.map +1 -0
  822. package/dist/esm/permissions/role-policy.js +570 -0
  823. package/dist/esm/permissions/role-policy.js.map +1 -0
  824. package/dist/esm/permissions/types.d.ts +126 -0
  825. package/dist/esm/permissions/types.d.ts.map +1 -0
  826. package/dist/esm/permissions/types.js +2 -0
  827. package/dist/esm/permissions/types.js.map +1 -0
  828. package/dist/esm/protocol/constants.d.ts +72 -0
  829. package/dist/esm/protocol/constants.d.ts.map +1 -0
  830. package/dist/esm/protocol/constants.js +104 -0
  831. package/dist/esm/protocol/constants.js.map +1 -0
  832. package/dist/esm/protocol/envelope.d.ts +165 -0
  833. package/dist/esm/protocol/envelope.d.ts.map +1 -0
  834. package/dist/esm/protocol/envelope.js +263 -0
  835. package/dist/esm/protocol/envelope.js.map +1 -0
  836. package/dist/esm/protocol/errors.d.ts +33 -0
  837. package/dist/esm/protocol/errors.d.ts.map +1 -0
  838. package/dist/esm/protocol/errors.js +384 -0
  839. package/dist/esm/protocol/errors.js.map +1 -0
  840. package/dist/esm/protocol/messages.d.ts +327 -0
  841. package/dist/esm/protocol/messages.d.ts.map +1 -0
  842. package/dist/esm/protocol/messages.js +2 -0
  843. package/dist/esm/protocol/messages.js.map +1 -0
  844. package/dist/esm/protocol/serialize.d.ts +26 -0
  845. package/dist/esm/protocol/serialize.d.ts.map +1 -0
  846. package/dist/esm/protocol/serialize.js +63 -0
  847. package/dist/esm/protocol/serialize.js.map +1 -0
  848. package/dist/esm/protocol/validate.d.ts +135 -0
  849. package/dist/esm/protocol/validate.d.ts.map +1 -0
  850. package/dist/esm/protocol/validate.js +830 -0
  851. package/dist/esm/protocol/validate.js.map +1 -0
  852. package/dist/types/audit/chain.d.ts +365 -0
  853. package/dist/types/audit/chain.d.ts.map +1 -0
  854. package/dist/types/audit/cloud-client.d.ts +142 -0
  855. package/dist/types/audit/cloud-client.d.ts.map +1 -0
  856. package/dist/types/audit/cloud-writer.d.ts +57 -0
  857. package/dist/types/audit/cloud-writer.d.ts.map +1 -0
  858. package/dist/types/audit/context.d.ts +51 -0
  859. package/dist/types/audit/context.d.ts.map +1 -0
  860. package/dist/types/audit/files.d.ts +111 -0
  861. package/dist/types/audit/files.d.ts.map +1 -0
  862. package/dist/types/audit/index.d.ts +9 -0
  863. package/dist/types/audit/index.d.ts.map +1 -0
  864. package/dist/types/audit/local-writer.d.ts +255 -0
  865. package/dist/types/audit/local-writer.d.ts.map +1 -0
  866. package/dist/types/audit/redact.d.ts +151 -0
  867. package/dist/types/audit/redact.d.ts.map +1 -0
  868. package/dist/types/audit/sanitize.d.ts +78 -0
  869. package/dist/types/audit/sanitize.d.ts.map +1 -0
  870. package/dist/types/audit/sink.d.ts +278 -0
  871. package/dist/types/audit/sink.d.ts.map +1 -0
  872. package/dist/types/audit/types.d.ts +226 -0
  873. package/dist/types/audit/types.d.ts.map +1 -0
  874. package/dist/types/audit/verify-cache.d.ts +127 -0
  875. package/dist/types/audit/verify-cache.d.ts.map +1 -0
  876. package/dist/types/channels/agent-session.d.ts +228 -0
  877. package/dist/types/channels/agent-session.d.ts.map +1 -0
  878. package/dist/types/channels/data-channel.d.ts +181 -0
  879. package/dist/types/channels/data-channel.d.ts.map +1 -0
  880. package/dist/types/channels/reconnect.d.ts +142 -0
  881. package/dist/types/channels/reconnect.d.ts.map +1 -0
  882. package/dist/types/channels/types.d.ts +112 -0
  883. package/dist/types/channels/types.d.ts.map +1 -0
  884. package/dist/types/channels/wake-channel.d.ts +232 -0
  885. package/dist/types/channels/wake-channel.d.ts.map +1 -0
  886. package/dist/types/cli/banner.d.ts +2 -0
  887. package/dist/types/cli/banner.d.ts.map +1 -0
  888. package/dist/types/cli/commands/agent.d.ts +30 -0
  889. package/dist/types/cli/commands/agent.d.ts.map +1 -0
  890. package/dist/types/cli/commands/audit-verify.d.ts +19 -0
  891. package/dist/types/cli/commands/audit-verify.d.ts.map +1 -0
  892. package/dist/types/cli/commands/clean.d.ts +23 -0
  893. package/dist/types/cli/commands/clean.d.ts.map +1 -0
  894. package/dist/types/cli/commands/config-show.d.ts +2 -0
  895. package/dist/types/cli/commands/config-show.d.ts.map +1 -0
  896. package/dist/types/cli/commands/config.d.ts +6 -0
  897. package/dist/types/cli/commands/config.d.ts.map +1 -0
  898. package/dist/types/cli/commands/db-add.d.ts +16 -0
  899. package/dist/types/cli/commands/db-add.d.ts.map +1 -0
  900. package/dist/types/cli/commands/db-edit.d.ts +2 -0
  901. package/dist/types/cli/commands/db-edit.d.ts.map +1 -0
  902. package/dist/types/cli/commands/db-logs.d.ts +3 -0
  903. package/dist/types/cli/commands/db-logs.d.ts.map +1 -0
  904. package/dist/types/cli/commands/db-ls.d.ts +2 -0
  905. package/dist/types/cli/commands/db-ls.d.ts.map +1 -0
  906. package/dist/types/cli/commands/db-query.d.ts +121 -0
  907. package/dist/types/cli/commands/db-query.d.ts.map +1 -0
  908. package/dist/types/cli/commands/db-remove.d.ts +2 -0
  909. package/dist/types/cli/commands/db-remove.d.ts.map +1 -0
  910. package/dist/types/cli/commands/db-show.d.ts +2 -0
  911. package/dist/types/cli/commands/db-show.d.ts.map +1 -0
  912. package/dist/types/cli/commands/db-test.d.ts +3 -0
  913. package/dist/types/cli/commands/db-test.d.ts.map +1 -0
  914. package/dist/types/cli/commands/db.d.ts +11 -0
  915. package/dist/types/cli/commands/db.d.ts.map +1 -0
  916. package/dist/types/cli/commands/debug.d.ts +2 -0
  917. package/dist/types/cli/commands/debug.d.ts.map +1 -0
  918. package/dist/types/cli/commands/doctor.d.ts +5 -0
  919. package/dist/types/cli/commands/doctor.d.ts.map +1 -0
  920. package/dist/types/cli/commands/index.d.ts +10 -0
  921. package/dist/types/cli/commands/index.d.ts.map +1 -0
  922. package/dist/types/cli/commands/init.d.ts +2 -0
  923. package/dist/types/cli/commands/init.d.ts.map +1 -0
  924. package/dist/types/cli/commands/link.d.ts +5 -0
  925. package/dist/types/cli/commands/link.d.ts.map +1 -0
  926. package/dist/types/cli/commands/logs.d.ts +17 -0
  927. package/dist/types/cli/commands/logs.d.ts.map +1 -0
  928. package/dist/types/cli/commands/project-show.d.ts +2 -0
  929. package/dist/types/cli/commands/project-show.d.ts.map +1 -0
  930. package/dist/types/cli/commands/project.d.ts +3 -0
  931. package/dist/types/cli/commands/project.d.ts.map +1 -0
  932. package/dist/types/cli/commands/service.d.ts +123 -0
  933. package/dist/types/cli/commands/service.d.ts.map +1 -0
  934. package/dist/types/cli/commands/start.d.ts +6 -0
  935. package/dist/types/cli/commands/start.d.ts.map +1 -0
  936. package/dist/types/cli/commands/status.d.ts +2 -0
  937. package/dist/types/cli/commands/status.d.ts.map +1 -0
  938. package/dist/types/cli/commands/stop.d.ts +6 -0
  939. package/dist/types/cli/commands/stop.d.ts.map +1 -0
  940. package/dist/types/cli/daemon/error-tracker.d.ts +119 -0
  941. package/dist/types/cli/daemon/error-tracker.d.ts.map +1 -0
  942. package/dist/types/cli/daemon/fault-shutdown.d.ts +144 -0
  943. package/dist/types/cli/daemon/fault-shutdown.d.ts.map +1 -0
  944. package/dist/types/cli/daemon/index.d.ts +12 -0
  945. package/dist/types/cli/daemon/index.d.ts.map +1 -0
  946. package/dist/types/cli/daemon/pid-file.d.ts +13 -0
  947. package/dist/types/cli/daemon/pid-file.d.ts.map +1 -0
  948. package/dist/types/cli/daemon/readiness.d.ts +30 -0
  949. package/dist/types/cli/daemon/readiness.d.ts.map +1 -0
  950. package/dist/types/cli/daemon/runtime.d.ts +366 -0
  951. package/dist/types/cli/daemon/runtime.d.ts.map +1 -0
  952. package/dist/types/cli/daemon/shutdown.d.ts +7 -0
  953. package/dist/types/cli/daemon/shutdown.d.ts.map +1 -0
  954. package/dist/types/cli/daemon/signal-handlers.d.ts +3 -0
  955. package/dist/types/cli/daemon/signal-handlers.d.ts.map +1 -0
  956. package/dist/types/cli/daemon/state.d.ts +157 -0
  957. package/dist/types/cli/daemon/state.d.ts.map +1 -0
  958. package/dist/types/cli/daemon/status-file.d.ts +139 -0
  959. package/dist/types/cli/daemon/status-file.d.ts.map +1 -0
  960. package/dist/types/cli/doctor/checks.d.ts +133 -0
  961. package/dist/types/cli/doctor/checks.d.ts.map +1 -0
  962. package/dist/types/cli/doctor/fixes.d.ts +9 -0
  963. package/dist/types/cli/doctor/fixes.d.ts.map +1 -0
  964. package/dist/types/cli/doctor/index.d.ts +7 -0
  965. package/dist/types/cli/doctor/index.d.ts.map +1 -0
  966. package/dist/types/cli/index.d.ts +3 -0
  967. package/dist/types/cli/index.d.ts.map +1 -0
  968. package/dist/types/cli/interactive.d.ts +8 -0
  969. package/dist/types/cli/interactive.d.ts.map +1 -0
  970. package/dist/types/cli/logs/format.d.ts +13 -0
  971. package/dist/types/cli/logs/format.d.ts.map +1 -0
  972. package/dist/types/cli/logs/index.d.ts +3 -0
  973. package/dist/types/cli/logs/index.d.ts.map +1 -0
  974. package/dist/types/cli/logs/viewer.d.ts +41 -0
  975. package/dist/types/cli/logs/viewer.d.ts.map +1 -0
  976. package/dist/types/cli/ops/operation-logger.d.ts +63 -0
  977. package/dist/types/cli/ops/operation-logger.d.ts.map +1 -0
  978. package/dist/types/cli/palette.d.ts +11 -0
  979. package/dist/types/cli/palette.d.ts.map +1 -0
  980. package/dist/types/cli/prompt.d.ts +186 -0
  981. package/dist/types/cli/prompt.d.ts.map +1 -0
  982. package/dist/types/cli/ui/box.d.ts +21 -0
  983. package/dist/types/cli/ui/box.d.ts.map +1 -0
  984. package/dist/types/cli/ui/clipboard.d.ts +6 -0
  985. package/dist/types/cli/ui/clipboard.d.ts.map +1 -0
  986. package/dist/types/cli/ui/colors.d.ts +57 -0
  987. package/dist/types/cli/ui/colors.d.ts.map +1 -0
  988. package/dist/types/cli/ui/index.d.ts +9 -0
  989. package/dist/types/cli/ui/index.d.ts.map +1 -0
  990. package/dist/types/cli/ui/spinner.d.ts +12 -0
  991. package/dist/types/cli/ui/spinner.d.ts.map +1 -0
  992. package/dist/types/cli/ui/symbols.d.ts +47 -0
  993. package/dist/types/cli/ui/symbols.d.ts.map +1 -0
  994. package/dist/types/cli/ui/table.d.ts +23 -0
  995. package/dist/types/cli/ui/table.d.ts.map +1 -0
  996. package/dist/types/cli/ui/terminal.d.ts +7 -0
  997. package/dist/types/cli/ui/terminal.d.ts.map +1 -0
  998. package/dist/types/config/atomic-write.d.ts +69 -0
  999. package/dist/types/config/atomic-write.d.ts.map +1 -0
  1000. package/dist/types/config/db-config.d.ts +134 -0
  1001. package/dist/types/config/db-config.d.ts.map +1 -0
  1002. package/dist/types/config/machine-config.d.ts +85 -0
  1003. package/dist/types/config/machine-config.d.ts.map +1 -0
  1004. package/dist/types/config/paths.d.ts +64 -0
  1005. package/dist/types/config/paths.d.ts.map +1 -0
  1006. package/dist/types/config/schema.d.ts +72 -0
  1007. package/dist/types/config/schema.d.ts.map +1 -0
  1008. package/dist/types/config/token.d.ts +63 -0
  1009. package/dist/types/config/token.d.ts.map +1 -0
  1010. package/dist/types/execution/canceller.d.ts +41 -0
  1011. package/dist/types/execution/canceller.d.ts.map +1 -0
  1012. package/dist/types/execution/database-lookup.d.ts +56 -0
  1013. package/dist/types/execution/database-lookup.d.ts.map +1 -0
  1014. package/dist/types/execution/dispatcher.d.ts +181 -0
  1015. package/dist/types/execution/dispatcher.d.ts.map +1 -0
  1016. package/dist/types/execution/function-effects.d.ts +209 -0
  1017. package/dist/types/execution/function-effects.d.ts.map +1 -0
  1018. package/dist/types/execution/introspection.d.ts +76 -0
  1019. package/dist/types/execution/introspection.d.ts.map +1 -0
  1020. package/dist/types/execution/migration-runner.d.ts +128 -0
  1021. package/dist/types/execution/migration-runner.d.ts.map +1 -0
  1022. package/dist/types/execution/non-tx-detector.d.ts +23 -0
  1023. package/dist/types/execution/non-tx-detector.d.ts.map +1 -0
  1024. package/dist/types/execution/pool.d.ts +229 -0
  1025. package/dist/types/execution/pool.d.ts.map +1 -0
  1026. package/dist/types/execution/query-runner.d.ts +88 -0
  1027. package/dist/types/execution/query-runner.d.ts.map +1 -0
  1028. package/dist/types/execution/rate-limiter.d.ts +120 -0
  1029. package/dist/types/execution/rate-limiter.d.ts.map +1 -0
  1030. package/dist/types/execution/search-path.d.ts +161 -0
  1031. package/dist/types/execution/search-path.d.ts.map +1 -0
  1032. package/dist/types/execution/sql-parser.d.ts +195 -0
  1033. package/dist/types/execution/sql-parser.d.ts.map +1 -0
  1034. package/dist/types/execution/statement-classifier.d.ts +103 -0
  1035. package/dist/types/execution/statement-classifier.d.ts.map +1 -0
  1036. package/dist/types/execution/types.d.ts +189 -0
  1037. package/dist/types/execution/types.d.ts.map +1 -0
  1038. package/dist/types/index.d.ts +34 -0
  1039. package/dist/types/index.d.ts.map +1 -0
  1040. package/dist/types/permissions/auto-upgrade.d.ts +40 -0
  1041. package/dist/types/permissions/auto-upgrade.d.ts.map +1 -0
  1042. package/dist/types/permissions/checker.d.ts +53 -0
  1043. package/dist/types/permissions/checker.d.ts.map +1 -0
  1044. package/dist/types/permissions/manual-approval.d.ts +213 -0
  1045. package/dist/types/permissions/manual-approval.d.ts.map +1 -0
  1046. package/dist/types/permissions/plan-registry.d.ts +274 -0
  1047. package/dist/types/permissions/plan-registry.d.ts.map +1 -0
  1048. package/dist/types/permissions/role-policy.d.ts +217 -0
  1049. package/dist/types/permissions/role-policy.d.ts.map +1 -0
  1050. package/dist/types/permissions/types.d.ts +126 -0
  1051. package/dist/types/permissions/types.d.ts.map +1 -0
  1052. package/dist/types/protocol/constants.d.ts +72 -0
  1053. package/dist/types/protocol/constants.d.ts.map +1 -0
  1054. package/dist/types/protocol/envelope.d.ts +165 -0
  1055. package/dist/types/protocol/envelope.d.ts.map +1 -0
  1056. package/dist/types/protocol/errors.d.ts +33 -0
  1057. package/dist/types/protocol/errors.d.ts.map +1 -0
  1058. package/dist/types/protocol/messages.d.ts +327 -0
  1059. package/dist/types/protocol/messages.d.ts.map +1 -0
  1060. package/dist/types/protocol/serialize.d.ts +26 -0
  1061. package/dist/types/protocol/serialize.d.ts.map +1 -0
  1062. package/dist/types/protocol/validate.d.ts +135 -0
  1063. package/dist/types/protocol/validate.d.ts.map +1 -0
  1064. package/package.json +116 -4
  1065. package/scripts/generate-systemd-service.mjs +117 -0
@@ -0,0 +1,895 @@
1
+ import * as crypto from 'crypto';
2
+ import * as fs from 'fs';
3
+ import * as os from 'os';
4
+ import * as path from 'path';
5
+ import { getAgentHome } from '../config/paths';
6
+ /** The hash the first record of a chain chains from. */
7
+ export const GENESIS_HASH = '0'.repeat(64);
8
+ /** HMAC-SHA256 key length. 32 bytes = 256 bits. */
9
+ export const AUDIT_KEY_BYTES = 32;
10
+ /** Operator-supplied key (hex or base64). Used by tests and managed deployments. */
11
+ export const AUDIT_KEY_ENV = 'SW_AGENT_AUDIT_KEY';
12
+ /** Machine-local key file, relative to the agent home (`~/.sw-agent/audit.key`). */
13
+ export const AUDIT_KEY_FILENAME = 'audit.key';
14
+ /** Anchored chain head, relative to the audit directory. */
15
+ export const AUDIT_HEAD_FILENAME = 'head.json';
16
+ /**
17
+ * Suffix of the monotonic floor anchor. It is appended to the audit directory's
18
+ * own name, so `<home>/audit` is anchored by `<home>/audit.floor.json`.
19
+ *
20
+ * The file holds the highest sequence number any writer has ever anchored. It is
21
+ * the second, independent claim about the same chain: `head.json` lives with the
22
+ * log, so anyone able to rewrite the log can rewrite the head too, and a matching
23
+ * pair of rolled-back files verifies as a self-consistent chain. This file is
24
+ * what makes that rollback visible (finding C-05, recommended fixes 2a and 3).
25
+ */
26
+ export const AUDIT_FLOOR_SUFFIX = '.floor.json';
27
+ const KEY_FILE_MODE = 0o600;
28
+ const KEY_DIR_MODE = 0o700;
29
+ const HEAD_FILE_MODE = 0o600;
30
+ const FLOOR_FILE_MODE = 0o600;
31
+ const CHAIN_ID_BYTES = 16;
32
+ const HASH_HEX = /^[0-9a-f]{64}$/;
33
+ const HEX_KEY = /^[0-9a-fA-F]{64}$/;
34
+ const BASE64_KEY = /^[A-Za-z0-9+/]{43}=$/;
35
+ export class AuditKeyError extends Error {
36
+ code;
37
+ constructor(code, message) {
38
+ super(message);
39
+ this.name = 'AuditKeyError';
40
+ this.code = code;
41
+ }
42
+ }
43
+ export function isHash64(value) {
44
+ return typeof value === 'string' && HASH_HEX.test(value);
45
+ }
46
+ /** True when `value` is a whole, non-negative, safe integer. */
47
+ function isSeq(value) {
48
+ return (typeof value === 'number' &&
49
+ Number.isInteger(value) &&
50
+ value >= 0 &&
51
+ Number.isSafeInteger(value));
52
+ }
53
+ /* ------------------------------------------------------------------ */
54
+ /* Key establishment */
55
+ /* ------------------------------------------------------------------ */
56
+ /**
57
+ * Decodes operator-supplied key material: 64 hex characters, or 44 characters
58
+ * of standard base64. Anything else is rejected rather than coerced — a
59
+ * mistyped key must not silently produce a different key than intended.
60
+ */
61
+ export function decodeKeyMaterial(raw) {
62
+ const trimmed = raw.trim();
63
+ if (trimmed.length === 0) {
64
+ throw new AuditKeyError('bad_key', `${AUDIT_KEY_ENV} is set but empty`);
65
+ }
66
+ if (HEX_KEY.test(trimmed)) {
67
+ const buf = Buffer.from(trimmed, 'hex');
68
+ if (buf.length !== AUDIT_KEY_BYTES) {
69
+ throw new AuditKeyError('bad_key', `${AUDIT_KEY_ENV} must decode to ${AUDIT_KEY_BYTES} bytes`);
70
+ }
71
+ return buf;
72
+ }
73
+ if (BASE64_KEY.test(trimmed)) {
74
+ const buf = Buffer.from(trimmed, 'base64');
75
+ if (buf.length !== AUDIT_KEY_BYTES) {
76
+ throw new AuditKeyError('bad_key', `${AUDIT_KEY_ENV} must decode to ${AUDIT_KEY_BYTES} bytes`);
77
+ }
78
+ return buf;
79
+ }
80
+ throw new AuditKeyError('bad_key', `${AUDIT_KEY_ENV} must be ${AUDIT_KEY_BYTES} bytes as hex (${AUDIT_KEY_BYTES * 2} chars) or base64`);
81
+ }
82
+ /**
83
+ * Deterministic chain id for a key supplied out of band (no key file to carry
84
+ * one). Derived with the key itself, so it is stable across restarts and reveals
85
+ * nothing without the key.
86
+ */
87
+ export function deriveChainId(key) {
88
+ return crypto
89
+ .createHmac('sha256', key)
90
+ .update('sw-agent/audit-chain-id/v1', 'utf8')
91
+ .digest('hex')
92
+ .slice(0, 32);
93
+ }
94
+ export function newChainId() {
95
+ return crypto.randomBytes(CHAIN_ID_BYTES).toString('hex');
96
+ }
97
+ function defaultKeyPath(dir) {
98
+ const base = dir ?? safeAgentHome();
99
+ return path.join(base, AUDIT_KEY_FILENAME);
100
+ }
101
+ function safeAgentHome() {
102
+ try {
103
+ return getAgentHome();
104
+ }
105
+ catch {
106
+ return path.join(os.homedir(), '.sw-agent');
107
+ }
108
+ }
109
+ function readKeyFile(keyPath) {
110
+ let raw;
111
+ try {
112
+ raw = fs.readFileSync(keyPath, 'utf8');
113
+ }
114
+ catch (err) {
115
+ const code = err.code;
116
+ if (code === 'ENOENT')
117
+ return null;
118
+ throw new AuditKeyError('key_io', `cannot read audit key file ${keyPath}: ${String(err)}`);
119
+ }
120
+ let parsed;
121
+ try {
122
+ parsed = JSON.parse(raw);
123
+ }
124
+ catch {
125
+ throw new AuditKeyError('bad_key', `audit key file ${keyPath} is not valid JSON — refusing to fall back to an unkeyed chain`);
126
+ }
127
+ if (typeof parsed !== 'object' || parsed === null) {
128
+ throw new AuditKeyError('bad_key', `audit key file ${keyPath} is malformed`);
129
+ }
130
+ const rec = parsed;
131
+ if (typeof rec.key !== 'string' || typeof rec.chain_id !== 'string') {
132
+ throw new AuditKeyError('bad_key', `audit key file ${keyPath} is missing key/chain_id`);
133
+ }
134
+ let key;
135
+ try {
136
+ key = Buffer.from(rec.key, 'base64');
137
+ }
138
+ catch {
139
+ throw new AuditKeyError('bad_key', `audit key file ${keyPath} has undecodable key material`);
140
+ }
141
+ if (key.length !== AUDIT_KEY_BYTES) {
142
+ throw new AuditKeyError('bad_key', `audit key file ${keyPath} does not hold a ${AUDIT_KEY_BYTES}-byte key`);
143
+ }
144
+ return { key, chain_id: rec.chain_id, source: 'keyfile', origin: keyPath };
145
+ }
146
+ function createKeyFile(keyPath) {
147
+ const key = crypto.randomBytes(AUDIT_KEY_BYTES);
148
+ const chain_id = newChainId();
149
+ const contents = {
150
+ v: 1,
151
+ chain_id,
152
+ key: key.toString('base64'),
153
+ created_at: new Date().toISOString(),
154
+ };
155
+ const dir = path.dirname(keyPath);
156
+ fs.mkdirSync(dir, { recursive: true, mode: KEY_DIR_MODE });
157
+ const tmp = `${keyPath}.${process.pid}.${crypto.randomBytes(4).toString('hex')}.tmp`;
158
+ try {
159
+ // Create with restrictive mode from the start; never briefly world-readable.
160
+ const fd = fs.openSync(tmp, 'wx', KEY_FILE_MODE);
161
+ try {
162
+ fs.writeFileSync(fd, JSON.stringify(contents, null, 2) + '\n', 'utf8');
163
+ fs.fsyncSync(fd);
164
+ }
165
+ finally {
166
+ fs.closeSync(fd);
167
+ }
168
+ fs.chmodSync(tmp, KEY_FILE_MODE);
169
+ fs.renameSync(tmp, keyPath);
170
+ fsyncDir(dir);
171
+ }
172
+ catch (err) {
173
+ // eslint-disable-next-line no-empty
174
+ try {
175
+ fs.unlinkSync(tmp);
176
+ }
177
+ catch { }
178
+ throw new AuditKeyError('key_io', `cannot create audit key file ${keyPath}: ${String(err)}`);
179
+ }
180
+ return { key, chain_id, source: 'keyfile', origin: keyPath };
181
+ }
182
+ /**
183
+ * Establishes the chain signing key, or throws.
184
+ *
185
+ * There is deliberately no unkeyed fallback. An audit chain that verifies
186
+ * against a public algorithm proves only internal consistency, which an
187
+ * attacker with write access can reproduce (audit finding C-05); silently
188
+ * degrading to that construction is worse than refusing to run.
189
+ *
190
+ * Precedence: `SW_AGENT_AUDIT_KEY` (operator override) → `audit.key`.
191
+ *
192
+ * `create: false` is read-only: an existing key file is still loaded. It only
193
+ * refuses to mint one, so verification paths can resolve the key without being
194
+ * able to establish a new chain.
195
+ */
196
+ export function loadAuditKey(opts = {}) {
197
+ const env = opts.env ?? process.env;
198
+ const keyPath = opts.keyPath ?? defaultKeyPath(opts.dir);
199
+ // Always *read* the file when present; `create` governs minting, not reading.
200
+ const fromFile = readKeyFile(keyPath);
201
+ const raw = env[AUDIT_KEY_ENV];
202
+ if (typeof raw === 'string' && raw.trim().length > 0) {
203
+ const key = decodeKeyMaterial(raw);
204
+ const chain_id = opts.chainId ?? fromFile?.chain_id ?? deriveChainId(key);
205
+ return { key, chain_id, source: 'env', origin: AUDIT_KEY_ENV };
206
+ }
207
+ if (fromFile)
208
+ return fromFile;
209
+ if (opts.create === false) {
210
+ throw new AuditKeyError('no_key', `no audit key: set ${AUDIT_KEY_ENV} or create ${keyPath}. Refusing to verify an unkeyed audit chain.`);
211
+ }
212
+ return createKeyFile(keyPath);
213
+ }
214
+ /** Non-throwing variant for read-only verification paths. */
215
+ export function tryLoadAuditKey(opts = {}) {
216
+ try {
217
+ return loadAuditKey(opts);
218
+ }
219
+ catch {
220
+ return null;
221
+ }
222
+ }
223
+ /** Normalises key material supplied directly by a caller. */
224
+ export function requireKeyBytes(key) {
225
+ if (Buffer.isBuffer(key) && key.length === AUDIT_KEY_BYTES)
226
+ return key;
227
+ if (typeof key === 'string' && key.length > 0)
228
+ return decodeKeyMaterial(key);
229
+ throw new AuditKeyError('no_key', `a ${AUDIT_KEY_BYTES}-byte audit key is required; an unkeyed chain is not offered`);
230
+ }
231
+ /* ------------------------------------------------------------------ */
232
+ /* Head anchor */
233
+ /* ------------------------------------------------------------------ */
234
+ export function headPathFor(dir) {
235
+ return path.join(dir, AUDIT_HEAD_FILENAME);
236
+ }
237
+ /**
238
+ * Reads the anchored head. A missing or malformed head is reported as `null`
239
+ * (not as a pass): without an anchor, a log cannot be shown to be complete.
240
+ */
241
+ export function readHead(dir) {
242
+ return readHeadFile(headPathFor(dir));
243
+ }
244
+ /** Reads and validates one anchor file. Never throws. */
245
+ function readHeadFile(target) {
246
+ let raw;
247
+ try {
248
+ raw = fs.readFileSync(target, 'utf8');
249
+ }
250
+ catch {
251
+ return null;
252
+ }
253
+ try {
254
+ const parsed = JSON.parse(raw);
255
+ return normalizeHead(parsed);
256
+ }
257
+ catch {
258
+ return null;
259
+ }
260
+ }
261
+ /**
262
+ * Absolute path of the monotonic floor anchor for an audit directory.
263
+ *
264
+ * It is a sibling of the audit directory, named after it, rather than a file
265
+ * inside it: anyone who can rewrite the log can rewrite an anchor that lives
266
+ * beside it, so the second claim has to sit outside the directory it vouches for.
267
+ * Deriving the name from the audit directory also keeps two audit directories that
268
+ * share a parent (two installations under one home) from sharing a floor.
269
+ *
270
+ * Because the name follows the directory, moving or renaming an audit directory
271
+ * orphans its floor: the moved log then has no second anchor and a rollback of it
272
+ * plus `head.json` is only caught if the operator still holds a copy of the head.
273
+ */
274
+ export function floorPathFor(auditDir) {
275
+ const resolved = path.resolve(auditDir);
276
+ return path.join(path.dirname(resolved), `${path.basename(resolved)}${AUDIT_FLOOR_SUFFIX}`);
277
+ }
278
+ /**
279
+ * Reads the monotonic floor anchor, or `null` when there is none. It is a lower
280
+ * bound on the end of the log, not a second head: it may legitimately lag the log
281
+ * after a crash, but it must never be ahead of it.
282
+ */
283
+ export function readHeadFloor(auditDir) {
284
+ return readHeadFile(floorPathFor(auditDir));
285
+ }
286
+ export function normalizeHead(value) {
287
+ if (typeof value !== 'object' || value === null)
288
+ return null;
289
+ const rec = value;
290
+ if (typeof rec.chain_id !== 'string' || rec.chain_id.length === 0)
291
+ return null;
292
+ if (!isSeq(rec.seq))
293
+ return null;
294
+ if (!isHash64(rec.last_hash))
295
+ return null;
296
+ if (typeof rec.written_at !== 'string')
297
+ return null;
298
+ const head = {
299
+ v: 1,
300
+ chain_id: rec.chain_id,
301
+ seq: rec.seq,
302
+ last_hash: rec.last_hash,
303
+ written_at: rec.written_at,
304
+ };
305
+ // Absent means "the whole log is retained" — the pre-rotation case.
306
+ if (rec.retained_from_seq === undefined || rec.retained_from_seq === null)
307
+ return head;
308
+ if (!isSeq(rec.retained_from_seq) || rec.retained_from_seq < 1)
309
+ return null;
310
+ return { ...head, retained_from_seq: rec.retained_from_seq };
311
+ }
312
+ export function makeHead(seq, lastHash, chainId, retainedFromSeq) {
313
+ const head = {
314
+ v: 1,
315
+ chain_id: chainId,
316
+ seq,
317
+ last_hash: lastHash,
318
+ written_at: new Date().toISOString(),
319
+ };
320
+ if (typeof retainedFromSeq === 'number' &&
321
+ Number.isInteger(retainedFromSeq) &&
322
+ retainedFromSeq >= 1) {
323
+ head.retained_from_seq = retainedFromSeq;
324
+ }
325
+ return head;
326
+ }
327
+ /**
328
+ * Persists the head atomically: write a private temp file, rename over the old
329
+ * head. A reader therefore never observes a half-written head.
330
+ *
331
+ * The head is written *after* the record it describes. A crash in between
332
+ * leaves the head behind the log, which recovery detects and repairs; the
333
+ * reverse order would look exactly like a truncation.
334
+ */
335
+ export function writeHead(dir, head, opts = {}) {
336
+ fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
337
+ writeJsonAtomic(headPathFor(dir), head, HEAD_FILE_MODE, opts.sync !== false, true);
338
+ }
339
+ /**
340
+ * Advances the floor anchor, and only ever upwards.
341
+ *
342
+ * A floor that went backwards would withdraw a claim the log has already made,
343
+ * which is precisely the truncation this exists to detect. The write happens
344
+ * after `writeHead`, so a crash can only leave the floor *behind* the log — which
345
+ * costs detection of nothing — never ahead of it.
346
+ *
347
+ * Refuses to write over another chain's floor: that is a key rotation or a
348
+ * re-initialisation, and silently discarding the old chain's claim would make
349
+ * the audit trail of the previous chain unverifiable.
350
+ *
351
+ * @returns true when the floor moved.
352
+ */
353
+ export function writeHeadFloor(auditDir, head, opts = {}) {
354
+ if (!isSeq(head.seq) || head.seq < 1)
355
+ return false;
356
+ const target = floorPathFor(auditDir);
357
+ const current = readHeadFile(target);
358
+ if (current) {
359
+ if (current.chain_id !== head.chain_id) {
360
+ throw new Error(`${target} anchors chain ${current.chain_id} at seq ${current.seq}, but this installation signs ` +
361
+ `chain ${head.chain_id}. Refusing to discard another chain's anchor: restore that chain, or ` +
362
+ `delete ${target} if the key was rotated deliberately and the old log is being abandoned.`);
363
+ }
364
+ if (current.seq >= head.seq)
365
+ return false;
366
+ }
367
+ writeJsonAtomic(target, head, FLOOR_FILE_MODE, opts.sync !== false, false);
368
+ return true;
369
+ }
370
+ /**
371
+ * Writes one anchor file atomically: a private temp file, then a rename over the
372
+ * old one, so a reader never observes a half-written anchor.
373
+ */
374
+ function writeJsonAtomic(target, value, mode, sync, fsyncParent) {
375
+ const dir = path.dirname(target);
376
+ const tmp = `${target}.${process.pid}.${crypto.randomBytes(4).toString('hex')}.tmp`;
377
+ let fd = null;
378
+ try {
379
+ fd = fs.openSync(tmp, 'wx', mode);
380
+ fs.writeFileSync(fd, JSON.stringify(value) + '\n', 'utf8');
381
+ if (sync)
382
+ fs.fsyncSync(fd);
383
+ }
384
+ catch (err) {
385
+ if (fd !== null) {
386
+ // eslint-disable-next-line no-empty
387
+ try {
388
+ fs.closeSync(fd);
389
+ }
390
+ catch { }
391
+ }
392
+ // eslint-disable-next-line no-empty
393
+ try {
394
+ fs.unlinkSync(tmp);
395
+ }
396
+ catch { }
397
+ throw err;
398
+ }
399
+ if (fd !== null)
400
+ fs.closeSync(fd);
401
+ fs.chmodSync(tmp, mode);
402
+ fs.renameSync(tmp, target);
403
+ if (sync && fsyncParent)
404
+ fsyncDir(dir);
405
+ }
406
+ /** fsync a directory so a rename is durable. Best effort: not supported everywhere. */
407
+ export function fsyncDir(dir) {
408
+ let dfd = null;
409
+ try {
410
+ dfd = fs.openSync(dir, 'r');
411
+ fs.fsyncSync(dfd);
412
+ }
413
+ catch {
414
+ // Directory fsync is unsupported on some platforms; the rename is still atomic.
415
+ }
416
+ finally {
417
+ if (dfd !== null) {
418
+ // eslint-disable-next-line no-empty
419
+ try {
420
+ fs.closeSync(dfd);
421
+ }
422
+ catch { }
423
+ }
424
+ }
425
+ }
426
+ /**
427
+ * Combines every available claim about the end of the chain.
428
+ *
429
+ * Two claims at the same `seq` that disagree on `chain_id` or `last_hash` are a
430
+ * contradiction, not a tie to break: the caller must fail closed rather than pick
431
+ * one. Different sequence numbers are not a contradiction — an older anchor is
432
+ * simply a weaker claim — but the retention floor is carried over from whichever
433
+ * claim has one, because it says where the log starts, not where it ends.
434
+ */
435
+ export function resolveAnchor(claims) {
436
+ let anchor = null;
437
+ let anchorSource = null;
438
+ let conflict = null;
439
+ const sources = [];
440
+ for (const { head, source } of claims) {
441
+ if (!head)
442
+ continue;
443
+ sources.push(source);
444
+ const current = anchor;
445
+ const floor = retentionFloorOf(current);
446
+ if (current !== null &&
447
+ head.seq === current.seq &&
448
+ (head.chain_id !== current.chain_id || head.last_hash !== current.last_hash)) {
449
+ conflict =
450
+ conflict ??
451
+ `anchors disagree at seq ${head.seq}: ${source} holds ${head.last_hash} but the chain was already ` +
452
+ `anchored at ${current.last_hash}`;
453
+ continue;
454
+ }
455
+ if (current === null || head.seq > current.seq) {
456
+ anchor = withRetentionFloor(head, floor);
457
+ anchorSource = source;
458
+ }
459
+ else if (floor === undefined && head.retained_from_seq !== undefined) {
460
+ anchor = withRetentionFloor(current, head.retained_from_seq);
461
+ }
462
+ }
463
+ return { anchor, anchorSource, conflict, sources };
464
+ }
465
+ function retentionFloorOf(head) {
466
+ return head === null ? undefined : head.retained_from_seq;
467
+ }
468
+ function withRetentionFloor(head, floor) {
469
+ return floor === undefined ? { ...head } : { ...head, retained_from_seq: floor };
470
+ }
471
+ /* ------------------------------------------------------------------ */
472
+ /* Record MAC */
473
+ /* ------------------------------------------------------------------ */
474
+ /**
475
+ * Marker for a value `JSON.stringify` has no representation for at all. It is
476
+ * not an encoded value: a property holding it is dropped, an array element
477
+ * holding it becomes `null`, exactly as the transport does.
478
+ */
479
+ const OMITTED = Symbol('audit.canonical.omitted');
480
+ /** Applies `toJSON` once, as `JSON.stringify` does, before any other test. */
481
+ function jsonViewOf(value, key) {
482
+ const toJSON = value.toJSON;
483
+ return typeof toJSON === 'function' ? toJSON.call(value, key) : value;
484
+ }
485
+ /**
486
+ * One level of the canonical encoding, keyed by the property name (or the
487
+ * decimal array index) so a `toJSON` that reads its key behaves as it will on
488
+ * disk. Returns {@link OMITTED} for a value the transport cannot carry.
489
+ */
490
+ function canonicalEncode(value, key) {
491
+ const json = value !== null && typeof value === 'object' ? jsonViewOf(value, key) : value;
492
+ if (json === undefined || typeof json === 'function' || typeof json === 'symbol')
493
+ return OMITTED;
494
+ if (json === null)
495
+ return 'null';
496
+ if (typeof json !== 'object')
497
+ return JSON.stringify(json);
498
+ if (Array.isArray(json)) {
499
+ const items = [];
500
+ for (let i = 0; i < json.length; i++) {
501
+ const encoded = canonicalEncode(json[i], String(i));
502
+ items.push(encoded === OMITTED ? 'null' : encoded);
503
+ }
504
+ return '[' + items.join(',') + ']';
505
+ }
506
+ const record = json;
507
+ const pairs = [];
508
+ for (const k of Object.keys(record).sort()) {
509
+ const encoded = canonicalEncode(record[k], k);
510
+ if (encoded === OMITTED)
511
+ continue;
512
+ pairs.push(JSON.stringify(k) + ':' + encoded);
513
+ }
514
+ return '{' + pairs.join(',') + '}';
515
+ }
516
+ /**
517
+ * Deterministic canonical JSON encoding used as MAC input.
518
+ *
519
+ * Determinism is required — writer and verifier must agree byte for byte — and
520
+ * it is also why naive recomputation of a chain is trivial: the algorithm is
521
+ * public and the input is public. That is precisely why the *key*, not this
522
+ * encoding, is the control. This function makes a record reproducible by a key
523
+ * holder and unforgeable for anyone else.
524
+ *
525
+ * The invariant this encoding exists to hold:
526
+ *
527
+ * > the bytes MACed are exactly the bytes that will be read back
528
+ *
529
+ * The log file is the transport, so wherever the canonical form and
530
+ * `JSON.stringify` disagreed the disagreement was resolved in favour of
531
+ * `JSON.stringify`:
532
+ * - a property whose value is `undefined` (or a function or a symbol) is
533
+ * **omitted**, not encoded as `''` — the key never reaches the file, so
534
+ * re-canonicalising the parsed record must not invent one
535
+ * - `undefined` in an array becomes `null`, holes included
536
+ * - an explicit `null` is kept, because it is a meaningful audit value and
537
+ * stays distinguishable from the field being absent
538
+ * - `toJSON` is honoured, so a `Date` encodes as the ISO string the file
539
+ * will hold
540
+ *
541
+ * The first two are not cosmetic. Encoding `undefined` as `''` MACs a record
542
+ * the JSON round trip cannot reproduce, so a correctly chained log is reported
543
+ * as `mac_mismatch` — a genuine artifact called tampered, which destroys the
544
+ * evidentiary value of the only control that says the agent did what it claims.
545
+ *
546
+ * Normalising here rather than stripping `undefined` at the call sites is what
547
+ * makes the invariant structural rather than a convention: {@link computeMac}
548
+ * is the sole producer of MAC input and it calls this function, so the writer
549
+ * and every verifier — including one reading an existing file — run the same
550
+ * code and cannot drift. A value JSON cannot represent even in principle (a
551
+ * `BigInt`) throws here exactly as it throws on the write path.
552
+ */
553
+ export function canonicalStringify(value) {
554
+ const encoded = canonicalEncode(value, '');
555
+ // Only reachable when called at the top level; inside a container the value
556
+ // is omitted from its parent rather than encoded on its own.
557
+ return encoded === OMITTED ? '' : encoded;
558
+ }
559
+ /**
560
+ * Strips the MAC fields so the remaining record can be canonicalised.
561
+ *
562
+ * `mac` and `hash` are the only fields removed here, and they are top-level by
563
+ * construction, so this copy is enough. Fields whose value is `undefined` are
564
+ * deliberately **left in place**: {@link canonicalStringify} omits them, which is
565
+ * the same rule `JSON.stringify` applies to the bytes on disk, so keeping them
566
+ * here cannot make the MAC disagree with what a verifier reads back.
567
+ */
568
+ export function macInputOf(event) {
569
+ const rest = { ...event };
570
+ delete rest.mac;
571
+ delete rest.hash;
572
+ return rest;
573
+ }
574
+ /**
575
+ * `HMAC-SHA256(key, canonical(record) || prev_hash)`.
576
+ *
577
+ * Requires the installation key; there is no unkeyed variant.
578
+ */
579
+ export function computeMac(event, key) {
580
+ const k = requireKeyBytes(key);
581
+ const input = canonicalStringify(macInputOf(event)) + event.prev_hash;
582
+ return crypto.createHmac('sha256', k).update(input, 'utf8').digest('hex');
583
+ }
584
+ /**
585
+ * Backwards-compatible alias of {@link computeMac}. Retained because it is part
586
+ * of the published package API. The key argument is required: there is no
587
+ * unkeyed fallback.
588
+ */
589
+ export function computeHash(event, key) {
590
+ return computeMac(event, key);
591
+ }
592
+ /** Verifies one record in place. Returns null when it verifies, else the reason. */
593
+ export function verifyEventMac(event, key) {
594
+ if (!isHash64(event.mac) && typeof event.mac !== 'string')
595
+ return 'record has no mac';
596
+ if (event.hash !== event.mac)
597
+ return 'hash/mac alias mismatch';
598
+ if (!isSeq(event.seq))
599
+ return 'record has no usable seq';
600
+ if (typeof event.chain_id !== 'string' || event.chain_id.length === 0)
601
+ return 'record has no chain_id';
602
+ if (!isHash64(event.prev_hash))
603
+ return 'record has no prev_hash';
604
+ const expected = computeMac(macInputOf(event), key);
605
+ return expected === event.mac ? null : 'mac does not match';
606
+ }
607
+ function fail(reason, events, extra = {}) {
608
+ return {
609
+ intact: false,
610
+ reason,
611
+ events,
612
+ detail: extra.detail,
613
+ brokenAt: extra.brokenAt,
614
+ observed: extra.observed,
615
+ verified_from_seq: extra.verifiedFromSeq,
616
+ };
617
+ }
618
+ function resolveKey(opts) {
619
+ if (opts.key !== undefined && opts.key !== null) {
620
+ return requireKeyBytes(opts.key);
621
+ }
622
+ const found = tryLoadAuditKey({ dir: opts.dir, create: false });
623
+ return found ? found.key : null;
624
+ }
625
+ /**
626
+ * Incremental, early-exit chain verifier. Holds only the previous record's
627
+ * mac/seq, so memory is O(1) regardless of log size (audit finding M-06).
628
+ */
629
+ export class ChainVerifier {
630
+ key;
631
+ prev;
632
+ expectedSeq;
633
+ count = 0;
634
+ failure = null;
635
+ chainId;
636
+ lastSeq = 0;
637
+ lastMac = GENESIS_HASH;
638
+ /** Sequence number of the first record in the window; 1 means from genesis. */
639
+ windowStartSeq;
640
+ /**
641
+ * True when the window starts after seq 1 and no explicit `expectedPrevHash`
642
+ * was supplied, so the first record's own `prev_hash` has to be adopted. The
643
+ * evicted prefix is gone, so its linkage cannot be re-checked — but the first
644
+ * record's MAC covers its own `prev_hash`, so nothing inside the window is
645
+ * left unverified.
646
+ */
647
+ adoptFirstPrevHash;
648
+ constructor(key, opts = {}) {
649
+ this.key = requireKeyBytes(key);
650
+ this.prev = opts.expectedPrevHash ?? GENESIS_HASH;
651
+ this.expectedSeq = opts.expectedSeq ?? 1;
652
+ this.windowStartSeq = this.expectedSeq;
653
+ this.adoptFirstPrevHash = opts.expectedPrevHash === undefined && this.expectedSeq > 1;
654
+ this.chainId = opts.chainId ?? null;
655
+ }
656
+ /** Records pushed so far. */
657
+ get events() {
658
+ return this.count;
659
+ }
660
+ /** True once any record has failed verification. */
661
+ get failed() {
662
+ return this.failure !== null;
663
+ }
664
+ /** Adds a record. Records after the first failure are ignored. */
665
+ push(event) {
666
+ if (this.failure)
667
+ return;
668
+ const at = this.count;
669
+ this.count++;
670
+ if (typeof event !== 'object' || event === null || Array.isArray(event)) {
671
+ this.failure = fail('malformed', this.count, {
672
+ brokenAt: at,
673
+ detail: 'record is not an object',
674
+ });
675
+ return;
676
+ }
677
+ const ev = event;
678
+ if (!isHash64(ev.prev_hash)) {
679
+ this.failure = fail('malformed', this.count, {
680
+ brokenAt: at,
681
+ detail: 'record has no prev_hash',
682
+ });
683
+ return;
684
+ }
685
+ if (typeof ev.seq !== 'number' || !isSeq(ev.seq) || ev.seq < 1) {
686
+ this.failure = fail('malformed', this.count, {
687
+ brokenAt: at,
688
+ detail: 'record has no usable seq',
689
+ });
690
+ return;
691
+ }
692
+ if (typeof ev.chain_id !== 'string' || ev.chain_id.length === 0) {
693
+ this.failure = fail('malformed', this.count, {
694
+ brokenAt: at,
695
+ detail: 'record has no chain_id',
696
+ });
697
+ return;
698
+ }
699
+ if (this.chainId === null) {
700
+ this.chainId = ev.chain_id;
701
+ }
702
+ else if (ev.chain_id !== this.chainId) {
703
+ this.failure = fail('chain_id_mismatch', this.count, {
704
+ brokenAt: at,
705
+ detail: `record ${at} belongs to chain ${ev.chain_id}, expected ${this.chainId}`,
706
+ });
707
+ return;
708
+ }
709
+ if (ev.seq !== this.expectedSeq) {
710
+ const belowWindow = ev.seq < this.windowStartSeq;
711
+ const regressed = belowWindow || ev.seq < this.lastSeq;
712
+ const reason = regressed
713
+ ? ev.seq === this.lastSeq
714
+ ? 'seq_duplicate'
715
+ : 'seq_regression'
716
+ : ev.seq < this.lastSeq
717
+ ? 'seq_regression'
718
+ : 'seq_gap';
719
+ this.failure = fail(reason, this.count, {
720
+ brokenAt: at,
721
+ detail: `record ${at} carries seq ${ev.seq}, expected ${this.expectedSeq}`,
722
+ verifiedFromSeq: this.windowStartSeq,
723
+ });
724
+ return;
725
+ }
726
+ if (this.adoptFirstPrevHash && at === 0) {
727
+ // Retention window: the record before this one has been evicted on purpose.
728
+ this.prev = ev.prev_hash;
729
+ }
730
+ else if (ev.prev_hash !== this.prev) {
731
+ this.failure = fail('prev_hash_mismatch', this.count, {
732
+ brokenAt: at,
733
+ detail: `record ${at} does not chain from the previous record`,
734
+ verifiedFromSeq: this.windowStartSeq,
735
+ });
736
+ return;
737
+ }
738
+ if (typeof ev.mac !== 'string' || !isHash64(ev.mac)) {
739
+ this.failure = fail('malformed', this.count, { brokenAt: at, detail: 'record has no mac' });
740
+ return;
741
+ }
742
+ if (ev.hash !== ev.mac) {
743
+ this.failure = fail('malformed', this.count, {
744
+ brokenAt: at,
745
+ detail: 'legacy hash alias disagrees with mac',
746
+ });
747
+ return;
748
+ }
749
+ let expected;
750
+ try {
751
+ expected = computeMac(macInputOf(ev), this.key);
752
+ }
753
+ catch (err) {
754
+ this.failure = fail('malformed', this.count, {
755
+ brokenAt: at,
756
+ detail: `record ${at} could not be verified: ${String(err)}`,
757
+ });
758
+ return;
759
+ }
760
+ if (expected !== ev.mac) {
761
+ this.failure = fail('mac_mismatch', this.count, {
762
+ brokenAt: at,
763
+ detail: `record ${at} does not match its mac`,
764
+ });
765
+ return;
766
+ }
767
+ this.prev = ev.mac;
768
+ this.lastSeq = ev.seq;
769
+ this.lastMac = ev.mac;
770
+ this.expectedSeq = ev.seq + 1;
771
+ }
772
+ /** The head observed so far, or `null` when nothing has been verified. */
773
+ observedHead() {
774
+ if (this.failure || this.chainId === null || this.lastSeq === 0)
775
+ return null;
776
+ return {
777
+ v: 1,
778
+ chain_id: this.chainId,
779
+ seq: this.lastSeq,
780
+ last_hash: this.lastMac,
781
+ written_at: '',
782
+ };
783
+ }
784
+ /**
785
+ * Final result. When `expectedHead` is supplied the observed head must match
786
+ * it exactly, which is what makes truncation, deletion and rollback visible.
787
+ */
788
+ result(expectedHead) {
789
+ if (this.failure)
790
+ return this.failure;
791
+ if (this.count === 0) {
792
+ return fail('empty', 0, { detail: 'no records to verify' });
793
+ }
794
+ const observed = this.observedHead();
795
+ const from = this.windowStartSeq > 1 ? this.windowStartSeq : undefined;
796
+ if (!expectedHead) {
797
+ return { intact: true, events: this.count, observed, verified_from_seq: from };
798
+ }
799
+ if (expectedHead.chain_id !== observed.chain_id) {
800
+ return fail('head_mismatch', this.count, {
801
+ detail: `head belongs to chain ${expectedHead.chain_id}, log holds ${observed.chain_id}`,
802
+ observed,
803
+ verifiedFromSeq: from,
804
+ });
805
+ }
806
+ if (expectedHead.seq > observed.seq) {
807
+ return fail('seq_regression', this.count, {
808
+ detail: `head expects at least seq ${expectedHead.seq} but the log ends at seq ${observed.seq}`,
809
+ observed,
810
+ verifiedFromSeq: from,
811
+ });
812
+ }
813
+ if (expectedHead.seq < observed.seq) {
814
+ return fail('head_mismatch', this.count, {
815
+ detail: `log ends at seq ${observed.seq}, ahead of the anchored head at ${expectedHead.seq}`,
816
+ observed,
817
+ verifiedFromSeq: from,
818
+ });
819
+ }
820
+ if (expectedHead.last_hash !== observed.last_hash) {
821
+ return fail('head_mismatch', this.count, {
822
+ detail: `record at seq ${observed.seq} does not match the anchored head`,
823
+ observed,
824
+ verifiedFromSeq: from,
825
+ });
826
+ }
827
+ return { intact: true, events: this.count, observed, verified_from_seq: from };
828
+ }
829
+ }
830
+ /**
831
+ * Verifies an ordered window of records across the whole log, in chronological
832
+ * order — never per rotated file with a fresh genesis, which is what made
833
+ * routine rotation look like tampering (audit finding H-13).
834
+ *
835
+ * What an intact result proves, and only this:
836
+ * - no record in the window was modified, inserted, removed or reordered
837
+ * without the installation key
838
+ * - the sequence numbers are contiguous, so nothing was dropped in the middle
839
+ * - the tail matches the supplied head, so the log was not truncated, deleted
840
+ * or rolled back past the anchor
841
+ *
842
+ * What it does **not** prove:
843
+ * - that this agent wrote the records: there is a MAC, not a signature, so any
844
+ * process holding the key can produce a verifying chain
845
+ * - legal attribution — there is no signing identity and no third-party time
846
+ * source, so a record cannot be tied to a person in a dispute
847
+ * - anything against an attacker who can write the log *and* both anchors (and
848
+ * who does not hold the key). Keep a copy of the head you cannot rewrite, and
849
+ * keep the key out of reach of the log.
850
+ *
851
+ * An empty window is **never** intact: "nothing to check" is not "verified".
852
+ */
853
+ export function verifyChain(events, opts = {}) {
854
+ if (!Array.isArray(events) || events.length === 0) {
855
+ return fail('empty', 0, { detail: 'no records to verify' });
856
+ }
857
+ let key;
858
+ try {
859
+ key = resolveKey(opts);
860
+ }
861
+ catch (err) {
862
+ return fail('key_unavailable', events.length, { detail: String(err) });
863
+ }
864
+ if (!key) {
865
+ return fail('key_unavailable', events.length, {
866
+ detail: `no audit key available (${AUDIT_KEY_ENV} or ${AUDIT_KEY_FILENAME}); cannot verify`,
867
+ });
868
+ }
869
+ const verifier = new ChainVerifier(key, {
870
+ chainId: opts.chainId,
871
+ expectedSeq: opts.expectedSeq ?? opts.head?.retained_from_seq ?? 1,
872
+ expectedPrevHash: opts.expectedPrevHash,
873
+ });
874
+ for (const event of events) {
875
+ verifier.push(event);
876
+ if (verifier.failed)
877
+ break;
878
+ }
879
+ return verifier.result(opts.head ?? null);
880
+ }
881
+ /**
882
+ * Verifies the log against the head the operator expects (from `head.json`).
883
+ * Thin wrapper over {@link verifyChain} that makes the anchor mandatory in the
884
+ * type signature, so a caller cannot accidentally verify a log against itself.
885
+ */
886
+ export function verifyChainAgainstHead(events, head, opts = {}) {
887
+ if (!head) {
888
+ return fail('head_missing', Array.isArray(events) ? events.length : 0, {
889
+ detail: `no head anchor available (${AUDIT_HEAD_FILENAME}); truncation and rollback cannot be detected`,
890
+ });
891
+ }
892
+ return verifyChain(events, { ...opts, head });
893
+ }
894
+ export { verifyChain as verifyHashChain, computeMac as computeEventMac, computeMac as computeEventHash, };
895
+ //# sourceMappingURL=chain.js.map