@schema-weaver/pg-connector 0.0.0-stage → 2.0.0

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,754 @@
1
+ import * as crypto from 'crypto';
2
+ import { LOCK_TIMEOUT_MS, MAX_STATEMENT_TIMEOUT_MS, markSessionDirty } from './pool';
3
+ import { loadMachineConfig } from '../config/machine-config';
4
+ import { runExtended } from './types';
5
+ import { detectNonTransactional } from './non-tx-detector';
6
+ import { assertSingleReadStatement } from './statement-classifier';
7
+ import { previewStatement } from '../audit/redact';
8
+ import { sanitizeErrorText } from '../audit/sanitize';
9
+ import { DEFAULTS, LIMITS } from '../protocol/constants';
10
+ export class MigrationInProgressError extends Error {
11
+ /** Error catalog code. Not a SQLSTATE: `safePgCode` requires exactly 5. */
12
+ code = 'migration_in_progress';
13
+ constructor(message) {
14
+ super(message);
15
+ this.name = 'MigrationInProgressError';
16
+ }
17
+ }
18
+ export class MigrationStrategyConflictError extends Error {
19
+ code = 'migration_strategy_conflict';
20
+ constructor(message) {
21
+ super(message);
22
+ this.name = 'MigrationStrategyConflictError';
23
+ }
24
+ }
25
+ /**
26
+ * The plan could not be verified: something in it does not parse, contains
27
+ * more than one statement, or is a statement form the agent cannot prove runs
28
+ * inside a transaction block. The run is refused rather than guessed at.
29
+ */
30
+ export class MigrationPlanUnsafeError extends Error {
31
+ code = 'migration_plan_unsafe';
32
+ constructor(message) {
33
+ super(message);
34
+ this.name = 'MigrationPlanUnsafeError';
35
+ }
36
+ }
37
+ /**
38
+ * The migration stopped partway with statements already committed.
39
+ *
40
+ * `MigrationRunner.run` never *resolves* with `status: 'partial'`: a caller
41
+ * that only inspects a returned value can therefore never mistake a
42
+ * half-applied schema for a success. The per-statement detail is on
43
+ * {@link MigrationPartiallyAppliedError.result} for a caller that wants to
44
+ * report it.
45
+ */
46
+ export class MigrationPartiallyAppliedError extends Error {
47
+ code = 'migration_partial';
48
+ result;
49
+ pg_error_code;
50
+ constructor(message, result) {
51
+ super(message);
52
+ this.name = 'MigrationPartiallyAppliedError';
53
+ this.result = result;
54
+ const failed = result.statements.find((s) => s.status === 'failed');
55
+ this.pg_error_code = failed?.pg_error_code;
56
+ }
57
+ }
58
+ /** The run exceeded its overall deadline and was abandoned. */
59
+ export class MigrationTimeoutError extends Error {
60
+ code = 'migration_timeout';
61
+ constructor(message) {
62
+ super(message);
63
+ this.name = 'MigrationTimeoutError';
64
+ }
65
+ }
66
+ /**
67
+ * Absolute ceiling on one migration statement, in milliseconds. A caller
68
+ * cannot raise it, and it can never exceed the agent-wide statement ceiling in
69
+ * `pool.ts` — nothing is allowed to turn `statement_timeout` off.
70
+ */
71
+ export const MAX_MIGRATION_STATEMENT_TIMEOUT_MS = Math.min(DEFAULTS.MIGRATION_TIMEOUT_MS, MAX_STATEMENT_TIMEOUT_MS);
72
+ /** Absolute ceiling on the whole migration run, in milliseconds. */
73
+ export const MAX_MIGRATION_DEADLINE_MS = DEFAULTS.MIGRATION_TIMEOUT_MS;
74
+ /** How long a migration statement may wait for a lock before it is cancelled. */
75
+ export const MIGRATION_LOCK_TIMEOUT_MS = LOCK_TIMEOUT_MS;
76
+ /** PostgreSQL's SQLSTATE for a statement cancelled by a timeout or a cancel request. */
77
+ const PG_QUERY_CANCELED = '57014';
78
+ /**
79
+ * Internal marker: the run was torn down by a cancellation or by the overall
80
+ * deadline. It never leaves this module — callers see {@link
81
+ * MigrationTimeoutError} or {@link MigrationPartiallyAppliedError}.
82
+ */
83
+ class RunInterrupted extends Error {
84
+ /** Which edge tore the run down. */
85
+ reason;
86
+ constructor(reason) {
87
+ super(`migration run interrupted: ${reason}`);
88
+ this.name = 'RunInterrupted';
89
+ this.reason = reason;
90
+ }
91
+ }
92
+ /**
93
+ * The exact integer that reaches `SET statement_timeout = …`.
94
+ *
95
+ * The value is interpolated into SQL, so it is re-validated where it is used
96
+ * instead of trusted from the caller: only a finite, positive, safe integer
97
+ * survives, and anything else becomes the server-owned ceiling. Nothing a remote
98
+ * caller can put in `timeout_ms` reaches the statement text verbatim, and a
99
+ * clamped value can never be `0` — which PostgreSQL reads as "no timeout".
100
+ */
101
+ function safeTimeoutMs(value, ceilingMs) {
102
+ if (!Number.isFinite(value) || !Number.isSafeInteger(value) || value <= 0) {
103
+ return ceilingMs;
104
+ }
105
+ return Math.min(value, ceilingMs);
106
+ }
107
+ /**
108
+ * Turn a caller-supplied `timeout_ms` into the three server-side budgets.
109
+ *
110
+ * The number is never trusted: it is floored to an integer, and clamped to
111
+ * {@link MAX_MIGRATION_STATEMENT_TIMEOUT_MS} / {@link MAX_MIGRATION_DEADLINE_MS}.
112
+ * `0`, a negative number, `NaN` and `Infinity` all mean "use the server
113
+ * default" — never "no timeout", which is how a remote caller would otherwise
114
+ * be able to remove the ceiling by asking for zero.
115
+ */
116
+ export function resolveMigrationBudget(requestedTimeoutMs) {
117
+ const requested = typeof requestedTimeoutMs === 'number' &&
118
+ Number.isFinite(requestedTimeoutMs) &&
119
+ requestedTimeoutMs > 0
120
+ ? Math.floor(requestedTimeoutMs)
121
+ : undefined;
122
+ const statementTimeoutMs = requested === undefined
123
+ ? MAX_MIGRATION_STATEMENT_TIMEOUT_MS
124
+ : Math.min(requested, MAX_MIGRATION_STATEMENT_TIMEOUT_MS);
125
+ const deadlineMs = requested === undefined
126
+ ? MAX_MIGRATION_DEADLINE_MS
127
+ : Math.min(requested, MAX_MIGRATION_DEADLINE_MS);
128
+ return {
129
+ statementTimeoutMs,
130
+ deadlineMs,
131
+ lockTimeoutMs: Math.min(MIGRATION_LOCK_TIMEOUT_MS, statementTimeoutMs),
132
+ };
133
+ }
134
+ /**
135
+ * Refuse a plan whose entries are not exactly one statement each.
136
+ *
137
+ * node-postgres takes the simple query protocol whenever `values` is falsy, and
138
+ * that protocol executes *every* semicolon-separated statement in one round
139
+ * trip. `SELECT 1; DROP TABLE users` is therefore two commands to PostgreSQL and
140
+ * one string to everything above it — the C-01 mechanism, reachable through the
141
+ * migration path.
142
+ *
143
+ * The verdict comes from the PostgreSQL parse tree, so a `;` inside a string
144
+ * literal, a dollar-quoted body, a quoted identifier or a comment cannot trip
145
+ * it, a single trailing terminator is not a second statement, and a real second
146
+ * statement always is. Anything that does not parse exactly once is refused,
147
+ * which also covers a plan written for a PostgreSQL version this agent cannot
148
+ * parse: an unverifiable entry is never executed.
149
+ */
150
+ async function assertOneStatementPerEntry(statements) {
151
+ const offenders = [];
152
+ for (let i = 0; i < statements.length; i++) {
153
+ try {
154
+ await assertSingleReadStatement(statements[i]);
155
+ }
156
+ catch {
157
+ offenders.push(i);
158
+ }
159
+ }
160
+ if (offenders.length === 0)
161
+ return;
162
+ throw new MigrationPlanUnsafeError(`Migration plan contains entries that are not exactly one statement ` +
163
+ `(index ${offenders.map((i) => i + 1).join(', ')}). Refusing the plan: an entry that ` +
164
+ 'hides a second command behind a semicolon would be executed as two commands, and ' +
165
+ 'one the agent could not parse cannot be verified.');
166
+ }
167
+ /**
168
+ * Read the `locked` column of a `pg_try_advisory_*_lock` result.
169
+ *
170
+ * Only an explicit `true` counts as taken: a missing or non-boolean answer fails
171
+ * closed, because a run that proceeded while believing it held the lock would
172
+ * have no mutual exclusion at all.
173
+ */
174
+ function lockTaken(res) {
175
+ return res.rows[0]?.locked === true;
176
+ }
177
+ /**
178
+ * Advisory lock key for SW migrations.
179
+ *
180
+ * Keyed with HMAC-SHA256 over a per-installation secret. The previous version
181
+ * hashed the project name with a bare MD5, so anybody who could guess (or was
182
+ * told) a project name could compute the lock key, take the lock from another
183
+ * session, and deny migrations for that project indefinitely. A keyed MAC is
184
+ * not derivable by a third party with database access, because the secret never
185
+ * reaches the database.
186
+ */
187
+ export function advisoryLockKey(projectName, secret) {
188
+ const mac = crypto
189
+ .createHmac('sha256', secret)
190
+ .update(`schema-weaver:migration-lock:v1:${projectName}`)
191
+ .digest();
192
+ const key1 = mac.readInt32BE(0);
193
+ let key2 = mac.readInt32BE(4);
194
+ if (key1 === key2) {
195
+ key2 = key1 === 0x7fffffff ? key1 - 1 : key1 + 1;
196
+ }
197
+ return { key1, key2 };
198
+ }
199
+ export class MigrationRunner {
200
+ poolManager;
201
+ injectedLockSecret;
202
+ resolvedLockSecret = null;
203
+ constructor(opts) {
204
+ this.poolManager = opts.poolManager;
205
+ this.injectedLockSecret = opts.lockSecret;
206
+ }
207
+ /**
208
+ * The installation secret the lock key is keyed with.
209
+ *
210
+ * An explicit option wins (tests, embedders). Otherwise the agent token from
211
+ * the machine config is used: it is per-installation, secret, and stable
212
+ * across processes, which is exactly what mutual exclusion between two agents
213
+ * needs. If the machine config cannot be read the fallback is a random
214
+ * per-process secret — still unguessable from outside, so the lock key cannot
215
+ * be pre-taken by anyone with database access.
216
+ */
217
+ lockSecret() {
218
+ if (this.injectedLockSecret && this.injectedLockSecret.length > 0) {
219
+ return this.injectedLockSecret;
220
+ }
221
+ if (this.resolvedLockSecret !== null)
222
+ return this.resolvedLockSecret;
223
+ try {
224
+ this.resolvedLockSecret = loadMachineConfig().agent_token;
225
+ }
226
+ catch {
227
+ this.resolvedLockSecret = crypto.randomBytes(32).toString('hex');
228
+ }
229
+ return this.resolvedLockSecret;
230
+ }
231
+ async run(payload, ctx) {
232
+ const startTime = Date.now();
233
+ // Step 1: Validate
234
+ if (payload.statements.length === 0) {
235
+ if (payload.dry_run) {
236
+ return {
237
+ plan_id: payload.plan_id,
238
+ status: 'dry_run_ok',
239
+ statements: [],
240
+ total_ms: Date.now() - startTime,
241
+ rolled_back_indices: [],
242
+ };
243
+ }
244
+ throw new Error('Migration run payload contains no statements');
245
+ }
246
+ if (payload.statements.length > LIMITS.MAX_STATEMENT_COUNT_PER_MIGRATION) {
247
+ throw new Error(`Migration statement count exceeds maximum limit (${LIMITS.MAX_STATEMENT_COUNT_PER_MIGRATION})`);
248
+ }
249
+ for (const stmt of payload.statements) {
250
+ if (!stmt.trim()) {
251
+ throw new Error('Migration payload contains an empty statement');
252
+ }
253
+ if (Buffer.byteLength(stmt, 'utf8') > LIMITS.MAX_STATEMENT_LENGTH) {
254
+ throw new Error(`Statement length exceeds maximum allowed limit (${LIMITS.MAX_STATEMENT_LENGTH})`);
255
+ }
256
+ }
257
+ // Step 2: Verify the plan before a connection or a lock is taken. Two
258
+ // independent checks, both driven by the PostgreSQL parse tree and both
259
+ // failing closed: every entry must be EXACTLY ONE statement, and every
260
+ // entry must be one whose transactionality the agent can prove.
261
+ await assertOneStatementPerEntry(payload.statements);
262
+ const nonTxCheck = await detectNonTransactional(payload.statements);
263
+ if (nonTxCheck.unparseable_indices.length > 0) {
264
+ throw new MigrationPlanUnsafeError(`Migration plan contains statements that PostgreSQL cannot parse ` +
265
+ `(index ${nonTxCheck.unparseable_indices.map((i) => i + 1).join(', ')}). ` +
266
+ 'Refusing to run an unverified plan.');
267
+ }
268
+ if (nonTxCheck.ambiguous_indices.length > 0) {
269
+ throw new MigrationPlanUnsafeError(`Migration plan contains statements that cannot be verified as transactional ` +
270
+ `(index ${nonTxCheck.ambiguous_indices.map((i) => i + 1).join(', ')}): ` +
271
+ `${nonTxCheck.summary}. Refusing to run an unverified plan.`);
272
+ }
273
+ const strategy = payload.strategy;
274
+ // Step 3: Dry run (parse only, no execution, no connection)
275
+ if (payload.dry_run) {
276
+ const statementResults = [];
277
+ const conflictIndices = new Set(strategy === 'single_tx' ? nonTxCheck.non_tx_indices : []);
278
+ let allPassed = true;
279
+ for (let i = 0; i < payload.statements.length; i++) {
280
+ const stmt = payload.statements[i];
281
+ const stmtStart = Date.now();
282
+ if (conflictIndices.has(i)) {
283
+ allPassed = false;
284
+ statementResults.push({
285
+ index: i,
286
+ status: 'failed',
287
+ ms: Date.now() - stmtStart,
288
+ rows_affected: 0,
289
+ error: `${nonTxCheck.summary} — strategy='single_tx' cannot run this plan`,
290
+ });
291
+ continue;
292
+ }
293
+ try {
294
+ // Parse-only validation. The previous implementation executed
295
+ // transactional DDL inside BEGIN/ROLLBACK against the production
296
+ // database during a "dry run"; anything the classifier wrongly
297
+ // called transactional really ran.
298
+ await assertSingleReadStatement(stmt);
299
+ statementResults.push({
300
+ index: i,
301
+ status: 'success',
302
+ ms: Date.now() - stmtStart,
303
+ rows_affected: 0,
304
+ });
305
+ }
306
+ catch (err) {
307
+ allPassed = false;
308
+ statementResults.push({
309
+ index: i,
310
+ status: 'failed',
311
+ ms: Date.now() - stmtStart,
312
+ rows_affected: 0,
313
+ error: err instanceof Error ? err.message : String(err),
314
+ pg_error_code: err && typeof err === 'object' && 'code' in err
315
+ ? String(err.code)
316
+ : undefined,
317
+ });
318
+ }
319
+ }
320
+ return {
321
+ plan_id: payload.plan_id,
322
+ status: allPassed ? 'dry_run_ok' : 'dry_run_failed',
323
+ statements: statementResults,
324
+ total_ms: Date.now() - startTime,
325
+ rolled_back_indices: [],
326
+ };
327
+ }
328
+ // Previously the runner silently rewrote a caller-requested single_tx
329
+ // migration into per_statement, which turns an all-or-nothing migration
330
+ // into a sequence of individually-committed statements. A partial
331
+ // migration leaves the schema half-applied and was reported as a success.
332
+ // Now the conflict is an explicit error the caller must resolve. A dry run
333
+ // reports it in the result instead of throwing, because that is what the
334
+ // caller asked dry runs for.
335
+ if (nonTxCheck.has_non_transactional && strategy === 'single_tx') {
336
+ throw new MigrationStrategyConflictError(`Migration requested single_tx but contains statements that cannot run inside a ` +
337
+ `transaction (${nonTxCheck.summary}). Re-submit with strategy='per_statement' ` +
338
+ 'if partial application is acceptable.');
339
+ }
340
+ // Step 4: Budgets. Every statement runs under a server-controlled
341
+ // statement_timeout and lock_timeout, and the run's own wall-clock deadline
342
+ // is raced against each in-flight statement below, so the run cannot outlive
343
+ // its deadline even if a single statement is slow. `timeout_ms` from the
344
+ // caller is honoured but never trusted: `resolveMigrationBudget` clamps it.
345
+ const budget = resolveMigrationBudget(payload.timeout_ms);
346
+ // Step 5: Acquire a connection and take the advisory lock
347
+ const { client, release, pid } = await this.poolManager.acquire(ctx.dbEntry);
348
+ // A migration always leaves state that `release()` cannot undo: an open
349
+ // transaction, session-level GUCs, a session-scoped advisory lock. Declaring
350
+ // the session dirty HERE, before the first statement that can change it,
351
+ // means the pool destroys the connection on every exit path — including an
352
+ // exception thrown between BEGIN and the `finally` below — instead of
353
+ // handing a half-used session to the next request. The cost is one
354
+ // reconnect per migration.
355
+ markSessionDirty(client);
356
+ // The overall deadline starts once the backend is in hand: connection
357
+ // setup is already bounded by the pool's connectionTimeoutMillis, and the
358
+ // lock is taken with pg_try_advisory_* so it never blocks either.
359
+ const deadlineAt = Date.now() + budget.deadlineMs;
360
+ /**
361
+ * Why the run was torn down early, if it was. `null` while it is healthy.
362
+ * First cause wins: a deadline that expires while a cancellation is already
363
+ * unwinding the run must not overwrite the reason its caller is waiting on.
364
+ */
365
+ let interruption = null;
366
+ let rejectInterrupt = () => undefined;
367
+ /**
368
+ * Rejects the instant the run is torn down. Every in-flight statement is
369
+ * raced against it, which is what makes the deadline a bound on the run's
370
+ * wall clock and not merely a check between statements: without the race a
371
+ * single statement that outlives the budget is still waited out in full,
372
+ * holding the advisory lock the whole time.
373
+ */
374
+ const interrupted = new Promise((_resolve, reject) => {
375
+ rejectInterrupt = reject;
376
+ });
377
+ // A run is usually torn down between statements, when nothing is racing
378
+ // this promise, and a rejection nobody awaits is an unhandled rejection at
379
+ // process level. Marking it handled here does not stop `Promise.race` from
380
+ // seeing it later.
381
+ void interrupted.catch(() => undefined);
382
+ const interrupt = (cause) => {
383
+ if (interruption !== null)
384
+ return;
385
+ interruption = cause;
386
+ rejectInterrupt(new RunInterrupted(cause));
387
+ };
388
+ const deadlineTimer = setTimeout(() => {
389
+ interrupt('deadline');
390
+ }, budget.deadlineMs);
391
+ const abortController = new AbortController();
392
+ const inFlightReq = {
393
+ request_id: ctx.request_id,
394
+ db_alias: ctx.dbEntry.db_alias,
395
+ pid,
396
+ started_at: Date.now(),
397
+ abort: abortController,
398
+ is_streaming: false,
399
+ };
400
+ // The listener is attached BEFORE the request is registered, and a signal
401
+ // that is already aborted is honoured immediately. An `abort` event that
402
+ // fired before `addEventListener` never fires again, so a canceller that
403
+ // aborts during registration (or a caller that hands in an aborted signal)
404
+ // would otherwise be ignored and the run would execute in full and take the
405
+ // advisory lock for a request nobody is waiting for.
406
+ const onAbort = () => {
407
+ // Abort whichever controller the canceller can reach: `registerInFlight`
408
+ // hands it `inFlightRequest.abort`, and the dispatcher substitutes its own
409
+ // controller there. Leaving that one unaborted would report
410
+ // `local_abort: false` for a cancellation the runner did act on.
411
+ if (!abortController.signal.aborted)
412
+ abortController.abort();
413
+ if (!inFlightReq.abort.signal.aborted)
414
+ inFlightReq.abort.abort();
415
+ interrupt('aborted');
416
+ };
417
+ if (ctx.abortSignal) {
418
+ ctx.abortSignal.addEventListener('abort', onAbort);
419
+ }
420
+ if (ctx.abortSignal?.aborted) {
421
+ onAbort();
422
+ }
423
+ // The canceller can only ever fire `InFlightRequest.abort`. It is observed
424
+ // here as well, so a caller that keeps this runner's own controller instead
425
+ // of substituting its own still stops the run instead of letting a
426
+ // cancelled migration carry on to its commit.
427
+ abortController.signal.addEventListener('abort', onAbort);
428
+ if (ctx.registerInFlight) {
429
+ ctx.registerInFlight(inFlightReq);
430
+ }
431
+ // `registerInFlight` can abort synchronously — the canceller, or a harness
432
+ // standing in for it — and `signal.aborted` is the only trace that leaves,
433
+ // so the state of both controllers is re-read after registration rather than
434
+ // trusted to have produced an event.
435
+ if (inFlightReq.abort.signal.aborted || ctx.abortSignal?.aborted === true) {
436
+ interrupt('aborted');
437
+ }
438
+ const { key1, key2 } = advisoryLockKey(ctx.project, this.lockSecret());
439
+ const statementResults = [];
440
+ const rolledBackIndices = [];
441
+ let migrationStatus = 'committed';
442
+ const outcome = () => migrationStatus;
443
+ let transactionOpen = false;
444
+ let sessionLockHeld = false;
445
+ let abandonedForDeadline = false;
446
+ /**
447
+ * A statement was still running on the backend when the run was torn down,
448
+ * so the session may have state nobody can see. It is destroyed rather than
449
+ * recycled, and the explicit unlock is skipped because it would be queued
450
+ * behind the very statement that overran.
451
+ */
452
+ let statementAbandonedInFlight = false;
453
+ let appliedStatementTimeout = null;
454
+ /**
455
+ * Topology that must not appear in anything this run puts on the wire.
456
+ * Every error PostgreSQL raises quotes the row, the literal or the value it
457
+ * choked on (`invalid input syntax for type integer: "alice@corp.com"`), and
458
+ * a connection failure names the host, port, user and database.
459
+ */
460
+ const topology = {
461
+ host: ctx.dbEntry.host,
462
+ port: ctx.dbEntry.port,
463
+ user: ctx.dbEntry.user,
464
+ database: ctx.dbEntry.database,
465
+ project: ctx.project,
466
+ };
467
+ /**
468
+ * Progress event for one statement.
469
+ *
470
+ * The preview is redacted and the error text is scrubbed, because both leave
471
+ * the process: a `migration_progress` event is a WebSocket frame bound for the
472
+ * cloud and the browser. The verbatim message is still recorded on
473
+ * {@link StatementResult.error} for the local audit log.
474
+ */
475
+ const emitProgress = (index, stmt, status, extra) => {
476
+ if (!ctx.onProgress)
477
+ return;
478
+ void ctx.onProgress({
479
+ v: 1,
480
+ id: crypto.randomUUID(),
481
+ type: 'event',
482
+ project: ctx.project,
483
+ user: ctx.user,
484
+ db_alias: ctx.db_alias,
485
+ ts: Date.now(),
486
+ payload: {
487
+ kind: 'migration_progress',
488
+ data: {
489
+ plan_id: payload.plan_id,
490
+ statement_index: index,
491
+ statement_sql_preview: previewStatement(stmt),
492
+ status,
493
+ ...(extra?.ms !== undefined ? { ms: extra.ms } : {}),
494
+ ...(extra?.error !== undefined
495
+ ? { error: sanitizeErrorText(extra.error, { topology }) }
496
+ : {}),
497
+ },
498
+ },
499
+ });
500
+ };
501
+ /**
502
+ * Apply the timeouts for the next statement. Inside `single_tx` this is
503
+ * `SET LOCAL`, which PostgreSQL reverts at COMMIT/ROLLBACK; in
504
+ * `per_statement` each statement is its own implicit transaction, so the
505
+ * session form is the only one that takes effect — `SET LOCAL` outside a
506
+ * transaction block is a silent no-op (H-07), which is how migrations used
507
+ * to run with no timeout at all.
508
+ *
509
+ * The value is exactly the clamped budget, NOT the wall clock still left in
510
+ * the run. Capping it by the remaining budget made the number PostgreSQL was
511
+ * asked to enforce drift down by however long the run had already spent
512
+ * taking its lock, so a caller that asked for 60000 got 59999 and every
513
+ * statement of a long run got a different timeout than the one that was
514
+ * requested and audited. The overall deadline is enforced by the runner
515
+ * itself (`interrupted` above), which is what bounds the run — not by
516
+ * shaving the server-side timeout.
517
+ *
518
+ * Both values are re-validated by {@link safeTimeoutMs} and the `LOCAL`
519
+ * prefix is one of two literals, so this text cannot carry SQL. It still
520
+ * goes over the extended protocol like every other statement, so no code
521
+ * path in this file can silently acquire the simple protocol.
522
+ */
523
+ const applyBudget = async () => {
524
+ const statementTimeoutMs = safeTimeoutMs(budget.statementTimeoutMs, MAX_MIGRATION_STATEMENT_TIMEOUT_MS);
525
+ const lockTimeoutMs = safeTimeoutMs(budget.lockTimeoutMs, MIGRATION_LOCK_TIMEOUT_MS);
526
+ const local = transactionOpen ? 'LOCAL ' : '';
527
+ if (appliedStatementTimeout !== statementTimeoutMs) {
528
+ await runExtended(client, `SET ${local}statement_timeout = ${statementTimeoutMs}`);
529
+ await runExtended(client, `SET ${local}lock_timeout = ${lockTimeoutMs}`);
530
+ appliedStatementTimeout = statementTimeoutMs;
531
+ }
532
+ };
533
+ const markRolledBack = (upToIndex) => {
534
+ for (let j = 0; j < upToIndex; j++) {
535
+ rolledBackIndices.push(j);
536
+ }
537
+ };
538
+ const endTransaction = async () => {
539
+ if (!transactionOpen)
540
+ return;
541
+ try {
542
+ await runExtended(client, 'ROLLBACK');
543
+ }
544
+ catch {
545
+ // The transaction state is unknown. `markSessionDirty` above means this
546
+ // connection is destroyed rather than recycled, which is the only way
547
+ // the next request is guaranteed not to inherit it.
548
+ }
549
+ transactionOpen = false;
550
+ };
551
+ const abandonRun = async (index, timedOut) => {
552
+ if (timedOut)
553
+ abandonedForDeadline = true;
554
+ if (strategy === 'single_tx') {
555
+ migrationStatus = 'rolled_back';
556
+ await endTransaction();
557
+ markRolledBack(index);
558
+ }
559
+ else {
560
+ migrationStatus = 'partial';
561
+ }
562
+ };
563
+ try {
564
+ if (strategy === 'single_tx') {
565
+ await runExtended(client, 'BEGIN');
566
+ transactionOpen = true;
567
+ // Transaction-scoped lock: PostgreSQL releases it at COMMIT/ROLLBACK,
568
+ // including when the connection dies mid-migration, so it cannot leak
569
+ // onto a pooled session.
570
+ const lockRes = await runExtended(client, 'SELECT pg_try_advisory_xact_lock($1, $2) AS locked', [key1, key2]);
571
+ if (!lockTaken(lockRes)) {
572
+ await endTransaction();
573
+ throw new MigrationInProgressError('Database migration is currently in progress for this project.');
574
+ }
575
+ }
576
+ else {
577
+ // No wrapping transaction in per_statement mode, so the lock is
578
+ // session-scoped and the `finally` below is the only thing that
579
+ // releases it. That is why the client is destroyed, never recycled.
580
+ const lockRes = await runExtended(client, 'SELECT pg_try_advisory_lock($1, $2) AS locked', [
581
+ key1,
582
+ key2,
583
+ ]);
584
+ if (!lockTaken(lockRes)) {
585
+ throw new MigrationInProgressError('Database migration is currently in progress for this project.');
586
+ }
587
+ sessionLockHeld = true;
588
+ }
589
+ // Step 6: Execute loop
590
+ for (let i = 0; i < payload.statements.length; i++) {
591
+ const stmt = payload.statements[i];
592
+ // Cooperative checkpoint. A cancellation or an expired deadline stops the
593
+ // run here, before the next statement is ever sent.
594
+ if (interruption !== null) {
595
+ await abandonRun(i, interruption === 'deadline');
596
+ break;
597
+ }
598
+ if (deadlineAt - Date.now() <= 0) {
599
+ interrupt('deadline');
600
+ await abandonRun(i, true);
601
+ break;
602
+ }
603
+ await applyBudget();
604
+ const stmtStart = Date.now();
605
+ emitProgress(i, stmt, 'running');
606
+ try {
607
+ // Extended query protocol: node-postgres only takes the simple
608
+ // protocol (which executes every semicolon-separated command in one
609
+ // round trip) when `values` is falsy, so this pins the statement
610
+ // count to the one the plan declared. PostgreSQL answers a second
611
+ // command in the same Parse with `42601`.
612
+ //
613
+ // Raced against `interrupted`, so a run that is cancelled or runs out
614
+ // of deadline stops waiting on a statement the backend may still be
615
+ // executing. The abandoned query is left to the server-side
616
+ // `statement_timeout` above and to the cancellation the canceller
617
+ // issues with `pg_cancel_backend`, both of which surface as `57014`.
618
+ const runRes = await Promise.race([runExtended(client, stmt), interrupted]);
619
+ const duration = Date.now() - stmtStart;
620
+ statementResults.push({
621
+ index: i,
622
+ status: 'success',
623
+ ms: duration,
624
+ rows_affected: runRes.rowCount || 0,
625
+ });
626
+ emitProgress(i, stmt, 'success', { ms: duration });
627
+ }
628
+ catch (err) {
629
+ const duration = Date.now() - stmtStart;
630
+ const wasInterrupted = err instanceof RunInterrupted;
631
+ const message = wasInterrupted
632
+ ? err.reason === 'deadline'
633
+ ? `Migration exceeded its overall deadline of ${budget.deadlineMs}ms ` +
634
+ `while statement ${i + 1} was still running; the run was abandoned.`
635
+ : `Migration was cancelled by the caller while statement ${i + 1} was still running.`
636
+ : err instanceof Error
637
+ ? err.message
638
+ : String(err);
639
+ statementResults.push({
640
+ index: i,
641
+ status: 'failed',
642
+ ms: duration,
643
+ rows_affected: 0,
644
+ error: message,
645
+ // A statement torn down locally has the same SQLSTATE PostgreSQL
646
+ // would have produced: `57014`, query_canceled.
647
+ pg_error_code: wasInterrupted
648
+ ? PG_QUERY_CANCELED
649
+ : err && typeof err === 'object' && 'code' in err
650
+ ? String(err.code)
651
+ : undefined,
652
+ });
653
+ emitProgress(i, stmt, 'failed', { ms: duration, error: message });
654
+ if (wasInterrupted) {
655
+ // The backend may still be running that statement, so nothing about
656
+ // this session can be proven: the next request must not inherit it.
657
+ // `markSessionDirty` destroys the connection, and terminating the
658
+ // backend is what actually stops the statement and releases the
659
+ // advisory lock.
660
+ statementAbandonedInFlight = true;
661
+ }
662
+ await abandonRun(i, wasInterrupted && err.reason === 'deadline');
663
+ break;
664
+ }
665
+ }
666
+ if (transactionOpen) {
667
+ // An interrupted run is never committed. In `single_tx` that is the whole
668
+ // difference between a migration that applied and one that did not, so
669
+ // the COMMIT is gated on the run still being healthy — not only on the
670
+ // statements having all succeeded.
671
+ if (interruption === null && outcome() === 'committed') {
672
+ await runExtended(client, 'COMMIT');
673
+ transactionOpen = false;
674
+ }
675
+ else {
676
+ if (interruption !== null && strategy === 'single_tx') {
677
+ // The deadline or a cancellation landed after the last statement
678
+ // succeeded. Rolling back is the only outcome that matches what the
679
+ // database did, so the status must not stay `committed`.
680
+ migrationStatus = 'rolled_back';
681
+ }
682
+ await endTransaction();
683
+ markRolledBack(payload.statements.length);
684
+ }
685
+ }
686
+ const result = {
687
+ plan_id: payload.plan_id,
688
+ status: outcome(),
689
+ statements: statementResults,
690
+ total_ms: Date.now() - startTime,
691
+ rolled_back_indices: rolledBackIndices,
692
+ };
693
+ if (outcome() === 'partial') {
694
+ // Name the cause, because "partial" alone does not tell a caller whether
695
+ // it should retry the plan or ask for a bigger budget — and do not claim
696
+ // work is committed when the run was abandoned before any of it landed.
697
+ const appliedCount = result.statements.filter((s) => s.status === 'success').length;
698
+ const cause = interruption === 'deadline'
699
+ ? `Migration exceeded its overall deadline of ${budget.deadlineMs}ms and was abandoned`
700
+ : interruption === 'aborted'
701
+ ? 'Migration was cancelled by the caller and was abandoned'
702
+ : 'Migration stopped partway';
703
+ const consequence = appliedCount === 0
704
+ ? 'Nothing was committed, but the run did not complete.'
705
+ : `${appliedCount} earlier statement(s) are already committed and were not rolled ` +
706
+ 'back. Verify the applied schema before retrying.';
707
+ throw new MigrationPartiallyAppliedError(`${cause}: ${consequence}`, result);
708
+ }
709
+ if (abandonedForDeadline) {
710
+ throw new MigrationTimeoutError(`Migration exceeded its overall deadline of ${budget.deadlineMs}ms and was abandoned. ` +
711
+ 'Every statement was rolled back.');
712
+ }
713
+ return result;
714
+ }
715
+ catch (err) {
716
+ await endTransaction();
717
+ throw err;
718
+ }
719
+ finally {
720
+ clearTimeout(deadlineTimer);
721
+ // Release the advisory lock on every exit path. Without this a single
722
+ // failed migration left the lock held on a pooled connection, blocking
723
+ // every later migration for this project until the pool recycled it.
724
+ // `markSessionDirty` above already guarantees the connection is destroyed
725
+ // either way, so a failed unlock needs no separate handling here.
726
+ if (sessionLockHeld) {
727
+ // A statement abandoned in flight may still be executing on the backend,
728
+ // and node-postgres queues everything behind an in-flight query — this
729
+ // unlock included — so sending it would wait out the statement the
730
+ // deadline just gave up on. It is not needed either way: PostgreSQL
731
+ // releases a session-scoped advisory lock when the backend goes away,
732
+ // and the connection is destroyed on this path.
733
+ if (!statementAbandonedInFlight) {
734
+ try {
735
+ await runExtended(client, 'SELECT pg_advisory_unlock($1, $2)', [key1, key2]);
736
+ }
737
+ catch {
738
+ // The lock may survive on a backend that is about to be destroyed.
739
+ }
740
+ }
741
+ sessionLockHeld = false;
742
+ }
743
+ if (ctx.abortSignal) {
744
+ ctx.abortSignal.removeEventListener('abort', onAbort);
745
+ }
746
+ abortController.signal.removeEventListener('abort', onAbort);
747
+ if (ctx.unregisterInFlight) {
748
+ ctx.unregisterInFlight(ctx.request_id);
749
+ }
750
+ release();
751
+ }
752
+ }
753
+ }
754
+ //# sourceMappingURL=migration-runner.js.map