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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1065) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/LICENSE +21 -0
  3. package/README.md +457 -2
  4. package/dist/cjs/audit/chain.d.ts +365 -0
  5. package/dist/cjs/audit/chain.d.ts.map +1 -0
  6. package/dist/cjs/audit/chain.js +959 -0
  7. package/dist/cjs/audit/chain.js.map +1 -0
  8. package/dist/cjs/audit/cloud-client.d.ts +142 -0
  9. package/dist/cjs/audit/cloud-client.d.ts.map +1 -0
  10. package/dist/cjs/audit/cloud-client.js +364 -0
  11. package/dist/cjs/audit/cloud-client.js.map +1 -0
  12. package/dist/cjs/audit/cloud-writer.d.ts +57 -0
  13. package/dist/cjs/audit/cloud-writer.d.ts.map +1 -0
  14. package/dist/cjs/audit/cloud-writer.js +95 -0
  15. package/dist/cjs/audit/cloud-writer.js.map +1 -0
  16. package/dist/cjs/audit/context.d.ts +51 -0
  17. package/dist/cjs/audit/context.d.ts.map +1 -0
  18. package/dist/cjs/audit/context.js +75 -0
  19. package/dist/cjs/audit/context.js.map +1 -0
  20. package/dist/cjs/audit/files.d.ts +111 -0
  21. package/dist/cjs/audit/files.d.ts.map +1 -0
  22. package/dist/cjs/audit/files.js +406 -0
  23. package/dist/cjs/audit/files.js.map +1 -0
  24. package/dist/cjs/audit/index.d.ts +9 -0
  25. package/dist/cjs/audit/index.d.ts.map +1 -0
  26. package/dist/cjs/audit/index.js +68 -0
  27. package/dist/cjs/audit/index.js.map +1 -0
  28. package/dist/cjs/audit/local-writer.d.ts +255 -0
  29. package/dist/cjs/audit/local-writer.d.ts.map +1 -0
  30. package/dist/cjs/audit/local-writer.js +829 -0
  31. package/dist/cjs/audit/local-writer.js.map +1 -0
  32. package/dist/cjs/audit/redact.d.ts +151 -0
  33. package/dist/cjs/audit/redact.d.ts.map +1 -0
  34. package/dist/cjs/audit/redact.js +549 -0
  35. package/dist/cjs/audit/redact.js.map +1 -0
  36. package/dist/cjs/audit/sanitize.d.ts +78 -0
  37. package/dist/cjs/audit/sanitize.d.ts.map +1 -0
  38. package/dist/cjs/audit/sanitize.js +315 -0
  39. package/dist/cjs/audit/sanitize.js.map +1 -0
  40. package/dist/cjs/audit/sink.d.ts +278 -0
  41. package/dist/cjs/audit/sink.d.ts.map +1 -0
  42. package/dist/cjs/audit/sink.js +819 -0
  43. package/dist/cjs/audit/sink.js.map +1 -0
  44. package/dist/cjs/audit/types.d.ts +226 -0
  45. package/dist/cjs/audit/types.d.ts.map +1 -0
  46. package/dist/cjs/audit/types.js +3 -0
  47. package/dist/cjs/audit/types.js.map +1 -0
  48. package/dist/cjs/audit/verify-cache.d.ts +127 -0
  49. package/dist/cjs/audit/verify-cache.d.ts.map +1 -0
  50. package/dist/cjs/audit/verify-cache.js +668 -0
  51. package/dist/cjs/audit/verify-cache.js.map +1 -0
  52. package/dist/cjs/channels/agent-session.d.ts +228 -0
  53. package/dist/cjs/channels/agent-session.d.ts.map +1 -0
  54. package/dist/cjs/channels/agent-session.js +604 -0
  55. package/dist/cjs/channels/agent-session.js.map +1 -0
  56. package/dist/cjs/channels/data-channel.d.ts +181 -0
  57. package/dist/cjs/channels/data-channel.d.ts.map +1 -0
  58. package/dist/cjs/channels/data-channel.js +607 -0
  59. package/dist/cjs/channels/data-channel.js.map +1 -0
  60. package/dist/cjs/channels/reconnect.d.ts +142 -0
  61. package/dist/cjs/channels/reconnect.d.ts.map +1 -0
  62. package/dist/cjs/channels/reconnect.js +247 -0
  63. package/dist/cjs/channels/reconnect.js.map +1 -0
  64. package/dist/cjs/channels/types.d.ts +112 -0
  65. package/dist/cjs/channels/types.d.ts.map +1 -0
  66. package/dist/cjs/channels/types.js +3 -0
  67. package/dist/cjs/channels/types.js.map +1 -0
  68. package/dist/cjs/channels/wake-channel.d.ts +232 -0
  69. package/dist/cjs/channels/wake-channel.d.ts.map +1 -0
  70. package/dist/cjs/channels/wake-channel.js +752 -0
  71. package/dist/cjs/channels/wake-channel.js.map +1 -0
  72. package/dist/cjs/cli/banner.d.ts +2 -0
  73. package/dist/cjs/cli/banner.d.ts.map +1 -0
  74. package/dist/cjs/cli/banner.js +150 -0
  75. package/dist/cjs/cli/banner.js.map +1 -0
  76. package/dist/cjs/cli/commands/agent.d.ts +30 -0
  77. package/dist/cjs/cli/commands/agent.d.ts.map +1 -0
  78. package/dist/cjs/cli/commands/agent.js +214 -0
  79. package/dist/cjs/cli/commands/agent.js.map +1 -0
  80. package/dist/cjs/cli/commands/audit-verify.d.ts +19 -0
  81. package/dist/cjs/cli/commands/audit-verify.d.ts.map +1 -0
  82. package/dist/cjs/cli/commands/audit-verify.js +382 -0
  83. package/dist/cjs/cli/commands/audit-verify.js.map +1 -0
  84. package/dist/cjs/cli/commands/clean.d.ts +23 -0
  85. package/dist/cjs/cli/commands/clean.d.ts.map +1 -0
  86. package/dist/cjs/cli/commands/clean.js +272 -0
  87. package/dist/cjs/cli/commands/clean.js.map +1 -0
  88. package/dist/cjs/cli/commands/config-show.d.ts +2 -0
  89. package/dist/cjs/cli/commands/config-show.d.ts.map +1 -0
  90. package/dist/cjs/cli/commands/config-show.js +10 -0
  91. package/dist/cjs/cli/commands/config-show.js.map +1 -0
  92. package/dist/cjs/cli/commands/config.d.ts +6 -0
  93. package/dist/cjs/cli/commands/config.d.ts.map +1 -0
  94. package/dist/cjs/cli/commands/config.js +266 -0
  95. package/dist/cjs/cli/commands/config.js.map +1 -0
  96. package/dist/cjs/cli/commands/db-add.d.ts +16 -0
  97. package/dist/cjs/cli/commands/db-add.d.ts.map +1 -0
  98. package/dist/cjs/cli/commands/db-add.js +613 -0
  99. package/dist/cjs/cli/commands/db-add.js.map +1 -0
  100. package/dist/cjs/cli/commands/db-edit.d.ts +2 -0
  101. package/dist/cjs/cli/commands/db-edit.d.ts.map +1 -0
  102. package/dist/cjs/cli/commands/db-edit.js +388 -0
  103. package/dist/cjs/cli/commands/db-edit.js.map +1 -0
  104. package/dist/cjs/cli/commands/db-logs.d.ts +3 -0
  105. package/dist/cjs/cli/commands/db-logs.d.ts.map +1 -0
  106. package/dist/cjs/cli/commands/db-logs.js +67 -0
  107. package/dist/cjs/cli/commands/db-logs.js.map +1 -0
  108. package/dist/cjs/cli/commands/db-ls.d.ts +2 -0
  109. package/dist/cjs/cli/commands/db-ls.d.ts.map +1 -0
  110. package/dist/cjs/cli/commands/db-ls.js +118 -0
  111. package/dist/cjs/cli/commands/db-ls.js.map +1 -0
  112. package/dist/cjs/cli/commands/db-query.d.ts +121 -0
  113. package/dist/cjs/cli/commands/db-query.d.ts.map +1 -0
  114. package/dist/cjs/cli/commands/db-query.js +802 -0
  115. package/dist/cjs/cli/commands/db-query.js.map +1 -0
  116. package/dist/cjs/cli/commands/db-remove.d.ts +2 -0
  117. package/dist/cjs/cli/commands/db-remove.d.ts.map +1 -0
  118. package/dist/cjs/cli/commands/db-remove.js +51 -0
  119. package/dist/cjs/cli/commands/db-remove.js.map +1 -0
  120. package/dist/cjs/cli/commands/db-show.d.ts +2 -0
  121. package/dist/cjs/cli/commands/db-show.d.ts.map +1 -0
  122. package/dist/cjs/cli/commands/db-show.js +134 -0
  123. package/dist/cjs/cli/commands/db-show.js.map +1 -0
  124. package/dist/cjs/cli/commands/db-test.d.ts +3 -0
  125. package/dist/cjs/cli/commands/db-test.d.ts.map +1 -0
  126. package/dist/cjs/cli/commands/db-test.js +311 -0
  127. package/dist/cjs/cli/commands/db-test.js.map +1 -0
  128. package/dist/cjs/cli/commands/db.d.ts +11 -0
  129. package/dist/cjs/cli/commands/db.d.ts.map +1 -0
  130. package/dist/cjs/cli/commands/db.js +90 -0
  131. package/dist/cjs/cli/commands/db.js.map +1 -0
  132. package/dist/cjs/cli/commands/debug.d.ts +2 -0
  133. package/dist/cjs/cli/commands/debug.d.ts.map +1 -0
  134. package/dist/cjs/cli/commands/debug.js +241 -0
  135. package/dist/cjs/cli/commands/debug.js.map +1 -0
  136. package/dist/cjs/cli/commands/doctor.d.ts +5 -0
  137. package/dist/cjs/cli/commands/doctor.d.ts.map +1 -0
  138. package/dist/cjs/cli/commands/doctor.js +117 -0
  139. package/dist/cjs/cli/commands/doctor.js.map +1 -0
  140. package/dist/cjs/cli/commands/index.d.ts +10 -0
  141. package/dist/cjs/cli/commands/index.d.ts.map +1 -0
  142. package/dist/cjs/cli/commands/index.js +30 -0
  143. package/dist/cjs/cli/commands/index.js.map +1 -0
  144. package/dist/cjs/cli/commands/init.d.ts +2 -0
  145. package/dist/cjs/cli/commands/init.d.ts.map +1 -0
  146. package/dist/cjs/cli/commands/init.js +199 -0
  147. package/dist/cjs/cli/commands/init.js.map +1 -0
  148. package/dist/cjs/cli/commands/link.d.ts +5 -0
  149. package/dist/cjs/cli/commands/link.d.ts.map +1 -0
  150. package/dist/cjs/cli/commands/link.js +44 -0
  151. package/dist/cjs/cli/commands/link.js.map +1 -0
  152. package/dist/cjs/cli/commands/logs.d.ts +17 -0
  153. package/dist/cjs/cli/commands/logs.d.ts.map +1 -0
  154. package/dist/cjs/cli/commands/logs.js +314 -0
  155. package/dist/cjs/cli/commands/logs.js.map +1 -0
  156. package/dist/cjs/cli/commands/project-show.d.ts +2 -0
  157. package/dist/cjs/cli/commands/project-show.d.ts.map +1 -0
  158. package/dist/cjs/cli/commands/project-show.js +105 -0
  159. package/dist/cjs/cli/commands/project-show.js.map +1 -0
  160. package/dist/cjs/cli/commands/project.d.ts +3 -0
  161. package/dist/cjs/cli/commands/project.d.ts.map +1 -0
  162. package/dist/cjs/cli/commands/project.js +64 -0
  163. package/dist/cjs/cli/commands/project.js.map +1 -0
  164. package/dist/cjs/cli/commands/service.d.ts +123 -0
  165. package/dist/cjs/cli/commands/service.d.ts.map +1 -0
  166. package/dist/cjs/cli/commands/service.js +554 -0
  167. package/dist/cjs/cli/commands/service.js.map +1 -0
  168. package/dist/cjs/cli/commands/start.d.ts +6 -0
  169. package/dist/cjs/cli/commands/start.d.ts.map +1 -0
  170. package/dist/cjs/cli/commands/start.js +308 -0
  171. package/dist/cjs/cli/commands/start.js.map +1 -0
  172. package/dist/cjs/cli/commands/status.d.ts +2 -0
  173. package/dist/cjs/cli/commands/status.d.ts.map +1 -0
  174. package/dist/cjs/cli/commands/status.js +225 -0
  175. package/dist/cjs/cli/commands/status.js.map +1 -0
  176. package/dist/cjs/cli/commands/stop.d.ts +6 -0
  177. package/dist/cjs/cli/commands/stop.d.ts.map +1 -0
  178. package/dist/cjs/cli/commands/stop.js +99 -0
  179. package/dist/cjs/cli/commands/stop.js.map +1 -0
  180. package/dist/cjs/cli/daemon/error-tracker.d.ts +119 -0
  181. package/dist/cjs/cli/daemon/error-tracker.d.ts.map +1 -0
  182. package/dist/cjs/cli/daemon/error-tracker.js +500 -0
  183. package/dist/cjs/cli/daemon/error-tracker.js.map +1 -0
  184. package/dist/cjs/cli/daemon/fault-shutdown.d.ts +144 -0
  185. package/dist/cjs/cli/daemon/fault-shutdown.d.ts.map +1 -0
  186. package/dist/cjs/cli/daemon/fault-shutdown.js +312 -0
  187. package/dist/cjs/cli/daemon/fault-shutdown.js.map +1 -0
  188. package/dist/cjs/cli/daemon/index.d.ts +12 -0
  189. package/dist/cjs/cli/daemon/index.d.ts.map +1 -0
  190. package/dist/cjs/cli/daemon/index.js +23 -0
  191. package/dist/cjs/cli/daemon/index.js.map +1 -0
  192. package/dist/cjs/cli/daemon/pid-file.d.ts +13 -0
  193. package/dist/cjs/cli/daemon/pid-file.d.ts.map +1 -0
  194. package/dist/cjs/cli/daemon/pid-file.js +90 -0
  195. package/dist/cjs/cli/daemon/pid-file.js.map +1 -0
  196. package/dist/cjs/cli/daemon/readiness.d.ts +30 -0
  197. package/dist/cjs/cli/daemon/readiness.d.ts.map +1 -0
  198. package/dist/cjs/cli/daemon/readiness.js +74 -0
  199. package/dist/cjs/cli/daemon/readiness.js.map +1 -0
  200. package/dist/cjs/cli/daemon/runtime.d.ts +366 -0
  201. package/dist/cjs/cli/daemon/runtime.d.ts.map +1 -0
  202. package/dist/cjs/cli/daemon/runtime.js +1343 -0
  203. package/dist/cjs/cli/daemon/runtime.js.map +1 -0
  204. package/dist/cjs/cli/daemon/shutdown.d.ts +7 -0
  205. package/dist/cjs/cli/daemon/shutdown.d.ts.map +1 -0
  206. package/dist/cjs/cli/daemon/shutdown.js +66 -0
  207. package/dist/cjs/cli/daemon/shutdown.js.map +1 -0
  208. package/dist/cjs/cli/daemon/signal-handlers.d.ts +3 -0
  209. package/dist/cjs/cli/daemon/signal-handlers.d.ts.map +1 -0
  210. package/dist/cjs/cli/daemon/signal-handlers.js +27 -0
  211. package/dist/cjs/cli/daemon/signal-handlers.js.map +1 -0
  212. package/dist/cjs/cli/daemon/state.d.ts +157 -0
  213. package/dist/cjs/cli/daemon/state.d.ts.map +1 -0
  214. package/dist/cjs/cli/daemon/state.js +397 -0
  215. package/dist/cjs/cli/daemon/state.js.map +1 -0
  216. package/dist/cjs/cli/daemon/status-file.d.ts +139 -0
  217. package/dist/cjs/cli/daemon/status-file.d.ts.map +1 -0
  218. package/dist/cjs/cli/daemon/status-file.js +88 -0
  219. package/dist/cjs/cli/daemon/status-file.js.map +1 -0
  220. package/dist/cjs/cli/doctor/checks.d.ts +133 -0
  221. package/dist/cjs/cli/doctor/checks.d.ts.map +1 -0
  222. package/dist/cjs/cli/doctor/checks.js +677 -0
  223. package/dist/cjs/cli/doctor/checks.js.map +1 -0
  224. package/dist/cjs/cli/doctor/fixes.d.ts +9 -0
  225. package/dist/cjs/cli/doctor/fixes.d.ts.map +1 -0
  226. package/dist/cjs/cli/doctor/fixes.js +199 -0
  227. package/dist/cjs/cli/doctor/fixes.js.map +1 -0
  228. package/dist/cjs/cli/doctor/index.d.ts +7 -0
  229. package/dist/cjs/cli/doctor/index.d.ts.map +1 -0
  230. package/dist/cjs/cli/doctor/index.js +27 -0
  231. package/dist/cjs/cli/doctor/index.js.map +1 -0
  232. package/dist/cjs/cli/index.d.ts +3 -0
  233. package/dist/cjs/cli/index.d.ts.map +1 -0
  234. package/dist/cjs/cli/index.js +336 -0
  235. package/dist/cjs/cli/index.js.map +1 -0
  236. package/dist/cjs/cli/interactive.d.ts +8 -0
  237. package/dist/cjs/cli/interactive.d.ts.map +1 -0
  238. package/dist/cjs/cli/interactive.js +670 -0
  239. package/dist/cjs/cli/interactive.js.map +1 -0
  240. package/dist/cjs/cli/logs/format.d.ts +13 -0
  241. package/dist/cjs/cli/logs/format.d.ts.map +1 -0
  242. package/dist/cjs/cli/logs/format.js +178 -0
  243. package/dist/cjs/cli/logs/format.js.map +1 -0
  244. package/dist/cjs/cli/logs/index.d.ts +3 -0
  245. package/dist/cjs/cli/logs/index.d.ts.map +1 -0
  246. package/dist/cjs/cli/logs/index.js +13 -0
  247. package/dist/cjs/cli/logs/index.js.map +1 -0
  248. package/dist/cjs/cli/logs/viewer.d.ts +41 -0
  249. package/dist/cjs/cli/logs/viewer.d.ts.map +1 -0
  250. package/dist/cjs/cli/logs/viewer.js +417 -0
  251. package/dist/cjs/cli/logs/viewer.js.map +1 -0
  252. package/dist/cjs/cli/ops/operation-logger.d.ts +63 -0
  253. package/dist/cjs/cli/ops/operation-logger.d.ts.map +1 -0
  254. package/dist/cjs/cli/ops/operation-logger.js +183 -0
  255. package/dist/cjs/cli/ops/operation-logger.js.map +1 -0
  256. package/dist/cjs/cli/palette.d.ts +11 -0
  257. package/dist/cjs/cli/palette.d.ts.map +1 -0
  258. package/dist/cjs/cli/palette.js +243 -0
  259. package/dist/cjs/cli/palette.js.map +1 -0
  260. package/dist/cjs/cli/prompt.d.ts +186 -0
  261. package/dist/cjs/cli/prompt.d.ts.map +1 -0
  262. package/dist/cjs/cli/prompt.js +541 -0
  263. package/dist/cjs/cli/prompt.js.map +1 -0
  264. package/dist/cjs/cli/ui/box.d.ts +21 -0
  265. package/dist/cjs/cli/ui/box.d.ts.map +1 -0
  266. package/dist/cjs/cli/ui/box.js +72 -0
  267. package/dist/cjs/cli/ui/box.js.map +1 -0
  268. package/dist/cjs/cli/ui/clipboard.d.ts +6 -0
  269. package/dist/cjs/cli/ui/clipboard.d.ts.map +1 -0
  270. package/dist/cjs/cli/ui/clipboard.js +78 -0
  271. package/dist/cjs/cli/ui/clipboard.js.map +1 -0
  272. package/dist/cjs/cli/ui/colors.d.ts +57 -0
  273. package/dist/cjs/cli/ui/colors.d.ts.map +1 -0
  274. package/dist/cjs/cli/ui/colors.js +151 -0
  275. package/dist/cjs/cli/ui/colors.js.map +1 -0
  276. package/dist/cjs/cli/ui/index.d.ts +9 -0
  277. package/dist/cjs/cli/ui/index.d.ts.map +1 -0
  278. package/dist/cjs/cli/ui/index.js +55 -0
  279. package/dist/cjs/cli/ui/index.js.map +1 -0
  280. package/dist/cjs/cli/ui/spinner.d.ts +12 -0
  281. package/dist/cjs/cli/ui/spinner.d.ts.map +1 -0
  282. package/dist/cjs/cli/ui/spinner.js +82 -0
  283. package/dist/cjs/cli/ui/spinner.js.map +1 -0
  284. package/dist/cjs/cli/ui/symbols.d.ts +47 -0
  285. package/dist/cjs/cli/ui/symbols.d.ts.map +1 -0
  286. package/dist/cjs/cli/ui/symbols.js +112 -0
  287. package/dist/cjs/cli/ui/symbols.js.map +1 -0
  288. package/dist/cjs/cli/ui/table.d.ts +23 -0
  289. package/dist/cjs/cli/ui/table.d.ts.map +1 -0
  290. package/dist/cjs/cli/ui/table.js +160 -0
  291. package/dist/cjs/cli/ui/table.js.map +1 -0
  292. package/dist/cjs/cli/ui/terminal.d.ts +7 -0
  293. package/dist/cjs/cli/ui/terminal.d.ts.map +1 -0
  294. package/dist/cjs/cli/ui/terminal.js +40 -0
  295. package/dist/cjs/cli/ui/terminal.js.map +1 -0
  296. package/dist/cjs/config/atomic-write.d.ts +69 -0
  297. package/dist/cjs/config/atomic-write.d.ts.map +1 -0
  298. package/dist/cjs/config/atomic-write.js +289 -0
  299. package/dist/cjs/config/atomic-write.js.map +1 -0
  300. package/dist/cjs/config/db-config.d.ts +134 -0
  301. package/dist/cjs/config/db-config.d.ts.map +1 -0
  302. package/dist/cjs/config/db-config.js +594 -0
  303. package/dist/cjs/config/db-config.js.map +1 -0
  304. package/dist/cjs/config/machine-config.d.ts +85 -0
  305. package/dist/cjs/config/machine-config.d.ts.map +1 -0
  306. package/dist/cjs/config/machine-config.js +232 -0
  307. package/dist/cjs/config/machine-config.js.map +1 -0
  308. package/dist/cjs/config/paths.d.ts +64 -0
  309. package/dist/cjs/config/paths.d.ts.map +1 -0
  310. package/dist/cjs/config/paths.js +155 -0
  311. package/dist/cjs/config/paths.js.map +1 -0
  312. package/dist/cjs/config/schema.d.ts +72 -0
  313. package/dist/cjs/config/schema.d.ts.map +1 -0
  314. package/dist/cjs/config/schema.js +197 -0
  315. package/dist/cjs/config/schema.js.map +1 -0
  316. package/dist/cjs/config/token.d.ts +63 -0
  317. package/dist/cjs/config/token.d.ts.map +1 -0
  318. package/dist/cjs/config/token.js +146 -0
  319. package/dist/cjs/config/token.js.map +1 -0
  320. package/dist/cjs/execution/canceller.d.ts +41 -0
  321. package/dist/cjs/execution/canceller.d.ts.map +1 -0
  322. package/dist/cjs/execution/canceller.js +209 -0
  323. package/dist/cjs/execution/canceller.js.map +1 -0
  324. package/dist/cjs/execution/database-lookup.d.ts +56 -0
  325. package/dist/cjs/execution/database-lookup.d.ts.map +1 -0
  326. package/dist/cjs/execution/database-lookup.js +43 -0
  327. package/dist/cjs/execution/database-lookup.js.map +1 -0
  328. package/dist/cjs/execution/dispatcher.d.ts +181 -0
  329. package/dist/cjs/execution/dispatcher.d.ts.map +1 -0
  330. package/dist/cjs/execution/dispatcher.js +1296 -0
  331. package/dist/cjs/execution/dispatcher.js.map +1 -0
  332. package/dist/cjs/execution/function-effects.d.ts +209 -0
  333. package/dist/cjs/execution/function-effects.d.ts.map +1 -0
  334. package/dist/cjs/execution/function-effects.js +596 -0
  335. package/dist/cjs/execution/function-effects.js.map +1 -0
  336. package/dist/cjs/execution/introspection.d.ts +76 -0
  337. package/dist/cjs/execution/introspection.d.ts.map +1 -0
  338. package/dist/cjs/execution/introspection.js +448 -0
  339. package/dist/cjs/execution/introspection.js.map +1 -0
  340. package/dist/cjs/execution/migration-runner.d.ts +128 -0
  341. package/dist/cjs/execution/migration-runner.d.ts.map +1 -0
  342. package/dist/cjs/execution/migration-runner.js +798 -0
  343. package/dist/cjs/execution/migration-runner.js.map +1 -0
  344. package/dist/cjs/execution/non-tx-detector.d.ts +23 -0
  345. package/dist/cjs/execution/non-tx-detector.d.ts.map +1 -0
  346. package/dist/cjs/execution/non-tx-detector.js +218 -0
  347. package/dist/cjs/execution/non-tx-detector.js.map +1 -0
  348. package/dist/cjs/execution/pool.d.ts +229 -0
  349. package/dist/cjs/execution/pool.d.ts.map +1 -0
  350. package/dist/cjs/execution/pool.js +738 -0
  351. package/dist/cjs/execution/pool.js.map +1 -0
  352. package/dist/cjs/execution/query-runner.d.ts +88 -0
  353. package/dist/cjs/execution/query-runner.d.ts.map +1 -0
  354. package/dist/cjs/execution/query-runner.js +751 -0
  355. package/dist/cjs/execution/query-runner.js.map +1 -0
  356. package/dist/cjs/execution/rate-limiter.d.ts +120 -0
  357. package/dist/cjs/execution/rate-limiter.d.ts.map +1 -0
  358. package/dist/cjs/execution/rate-limiter.js +273 -0
  359. package/dist/cjs/execution/rate-limiter.js.map +1 -0
  360. package/dist/cjs/execution/search-path.d.ts +161 -0
  361. package/dist/cjs/execution/search-path.d.ts.map +1 -0
  362. package/dist/cjs/execution/search-path.js +279 -0
  363. package/dist/cjs/execution/search-path.js.map +1 -0
  364. package/dist/cjs/execution/sql-parser.d.ts +195 -0
  365. package/dist/cjs/execution/sql-parser.d.ts.map +1 -0
  366. package/dist/cjs/execution/sql-parser.js +704 -0
  367. package/dist/cjs/execution/sql-parser.js.map +1 -0
  368. package/dist/cjs/execution/statement-classifier.d.ts +103 -0
  369. package/dist/cjs/execution/statement-classifier.d.ts.map +1 -0
  370. package/dist/cjs/execution/statement-classifier.js +535 -0
  371. package/dist/cjs/execution/statement-classifier.js.map +1 -0
  372. package/dist/cjs/execution/types.d.ts +189 -0
  373. package/dist/cjs/execution/types.d.ts.map +1 -0
  374. package/dist/cjs/execution/types.js +28 -0
  375. package/dist/cjs/execution/types.js.map +1 -0
  376. package/dist/cjs/index.d.ts +34 -0
  377. package/dist/cjs/index.d.ts.map +1 -0
  378. package/dist/cjs/index.js +98 -0
  379. package/dist/cjs/index.js.map +1 -0
  380. package/dist/cjs/permissions/auto-upgrade.d.ts +40 -0
  381. package/dist/cjs/permissions/auto-upgrade.d.ts.map +1 -0
  382. package/dist/cjs/permissions/auto-upgrade.js +168 -0
  383. package/dist/cjs/permissions/auto-upgrade.js.map +1 -0
  384. package/dist/cjs/permissions/checker.d.ts +53 -0
  385. package/dist/cjs/permissions/checker.d.ts.map +1 -0
  386. package/dist/cjs/permissions/checker.js +326 -0
  387. package/dist/cjs/permissions/checker.js.map +1 -0
  388. package/dist/cjs/permissions/manual-approval.d.ts +213 -0
  389. package/dist/cjs/permissions/manual-approval.d.ts.map +1 -0
  390. package/dist/cjs/permissions/manual-approval.js +541 -0
  391. package/dist/cjs/permissions/manual-approval.js.map +1 -0
  392. package/dist/cjs/permissions/plan-registry.d.ts +274 -0
  393. package/dist/cjs/permissions/plan-registry.d.ts.map +1 -0
  394. package/dist/cjs/permissions/plan-registry.js +454 -0
  395. package/dist/cjs/permissions/plan-registry.js.map +1 -0
  396. package/dist/cjs/permissions/role-policy.d.ts +217 -0
  397. package/dist/cjs/permissions/role-policy.d.ts.map +1 -0
  398. package/dist/cjs/permissions/role-policy.js +584 -0
  399. package/dist/cjs/permissions/role-policy.js.map +1 -0
  400. package/dist/cjs/permissions/types.d.ts +126 -0
  401. package/dist/cjs/permissions/types.d.ts.map +1 -0
  402. package/dist/cjs/permissions/types.js +3 -0
  403. package/dist/cjs/permissions/types.js.map +1 -0
  404. package/dist/cjs/protocol/constants.d.ts +72 -0
  405. package/dist/cjs/protocol/constants.d.ts.map +1 -0
  406. package/dist/cjs/protocol/constants.js +107 -0
  407. package/dist/cjs/protocol/constants.js.map +1 -0
  408. package/dist/cjs/protocol/envelope.d.ts +165 -0
  409. package/dist/cjs/protocol/envelope.d.ts.map +1 -0
  410. package/dist/cjs/protocol/envelope.js +309 -0
  411. package/dist/cjs/protocol/envelope.js.map +1 -0
  412. package/dist/cjs/protocol/errors.d.ts +33 -0
  413. package/dist/cjs/protocol/errors.d.ts.map +1 -0
  414. package/dist/cjs/protocol/errors.js +391 -0
  415. package/dist/cjs/protocol/errors.js.map +1 -0
  416. package/dist/cjs/protocol/messages.d.ts +327 -0
  417. package/dist/cjs/protocol/messages.d.ts.map +1 -0
  418. package/dist/cjs/protocol/messages.js +3 -0
  419. package/dist/cjs/protocol/messages.js.map +1 -0
  420. package/dist/cjs/protocol/serialize.d.ts +26 -0
  421. package/dist/cjs/protocol/serialize.d.ts.map +1 -0
  422. package/dist/cjs/protocol/serialize.js +71 -0
  423. package/dist/cjs/protocol/serialize.js.map +1 -0
  424. package/dist/cjs/protocol/validate.d.ts +135 -0
  425. package/dist/cjs/protocol/validate.d.ts.map +1 -0
  426. package/dist/cjs/protocol/validate.js +852 -0
  427. package/dist/cjs/protocol/validate.js.map +1 -0
  428. package/dist/esm/audit/chain.d.ts +365 -0
  429. package/dist/esm/audit/chain.d.ts.map +1 -0
  430. package/dist/esm/audit/chain.js +895 -0
  431. package/dist/esm/audit/chain.js.map +1 -0
  432. package/dist/esm/audit/cloud-client.d.ts +142 -0
  433. package/dist/esm/audit/cloud-client.d.ts.map +1 -0
  434. package/dist/esm/audit/cloud-client.js +326 -0
  435. package/dist/esm/audit/cloud-client.js.map +1 -0
  436. package/dist/esm/audit/cloud-writer.d.ts +57 -0
  437. package/dist/esm/audit/cloud-writer.d.ts.map +1 -0
  438. package/dist/esm/audit/cloud-writer.js +91 -0
  439. package/dist/esm/audit/cloud-writer.js.map +1 -0
  440. package/dist/esm/audit/context.d.ts +51 -0
  441. package/dist/esm/audit/context.d.ts.map +1 -0
  442. package/dist/esm/audit/context.js +69 -0
  443. package/dist/esm/audit/context.js.map +1 -0
  444. package/dist/esm/audit/files.d.ts +111 -0
  445. package/dist/esm/audit/files.d.ts.map +1 -0
  446. package/dist/esm/audit/files.js +361 -0
  447. package/dist/esm/audit/files.js.map +1 -0
  448. package/dist/esm/audit/index.d.ts +9 -0
  449. package/dist/esm/audit/index.d.ts.map +1 -0
  450. package/dist/esm/audit/index.js +8 -0
  451. package/dist/esm/audit/index.js.map +1 -0
  452. package/dist/esm/audit/local-writer.d.ts +255 -0
  453. package/dist/esm/audit/local-writer.d.ts.map +1 -0
  454. package/dist/esm/audit/local-writer.js +785 -0
  455. package/dist/esm/audit/local-writer.js.map +1 -0
  456. package/dist/esm/audit/redact.d.ts +151 -0
  457. package/dist/esm/audit/redact.d.ts.map +1 -0
  458. package/dist/esm/audit/redact.js +506 -0
  459. package/dist/esm/audit/redact.js.map +1 -0
  460. package/dist/esm/audit/sanitize.d.ts +78 -0
  461. package/dist/esm/audit/sanitize.d.ts.map +1 -0
  462. package/dist/esm/audit/sanitize.js +307 -0
  463. package/dist/esm/audit/sanitize.js.map +1 -0
  464. package/dist/esm/audit/sink.d.ts +278 -0
  465. package/dist/esm/audit/sink.d.ts.map +1 -0
  466. package/dist/esm/audit/sink.js +782 -0
  467. package/dist/esm/audit/sink.js.map +1 -0
  468. package/dist/esm/audit/types.d.ts +226 -0
  469. package/dist/esm/audit/types.d.ts.map +1 -0
  470. package/dist/esm/audit/types.js +2 -0
  471. package/dist/esm/audit/types.js.map +1 -0
  472. package/dist/esm/audit/verify-cache.d.ts +127 -0
  473. package/dist/esm/audit/verify-cache.d.ts.map +1 -0
  474. package/dist/esm/audit/verify-cache.js +628 -0
  475. package/dist/esm/audit/verify-cache.js.map +1 -0
  476. package/dist/esm/channels/agent-session.d.ts +228 -0
  477. package/dist/esm/channels/agent-session.d.ts.map +1 -0
  478. package/dist/esm/channels/agent-session.js +566 -0
  479. package/dist/esm/channels/agent-session.js.map +1 -0
  480. package/dist/esm/channels/data-channel.d.ts +181 -0
  481. package/dist/esm/channels/data-channel.d.ts.map +1 -0
  482. package/dist/esm/channels/data-channel.js +567 -0
  483. package/dist/esm/channels/data-channel.js.map +1 -0
  484. package/dist/esm/channels/reconnect.d.ts +142 -0
  485. package/dist/esm/channels/reconnect.d.ts.map +1 -0
  486. package/dist/esm/channels/reconnect.js +234 -0
  487. package/dist/esm/channels/reconnect.js.map +1 -0
  488. package/dist/esm/channels/types.d.ts +112 -0
  489. package/dist/esm/channels/types.d.ts.map +1 -0
  490. package/dist/esm/channels/types.js +2 -0
  491. package/dist/esm/channels/types.js.map +1 -0
  492. package/dist/esm/channels/wake-channel.d.ts +232 -0
  493. package/dist/esm/channels/wake-channel.d.ts.map +1 -0
  494. package/dist/esm/channels/wake-channel.js +715 -0
  495. package/dist/esm/channels/wake-channel.js.map +1 -0
  496. package/dist/esm/cli/banner.d.ts +2 -0
  497. package/dist/esm/cli/banner.d.ts.map +1 -0
  498. package/dist/esm/cli/banner.js +114 -0
  499. package/dist/esm/cli/banner.js.map +1 -0
  500. package/dist/esm/cli/commands/agent.d.ts +30 -0
  501. package/dist/esm/cli/commands/agent.d.ts.map +1 -0
  502. package/dist/esm/cli/commands/agent.js +204 -0
  503. package/dist/esm/cli/commands/agent.js.map +1 -0
  504. package/dist/esm/cli/commands/audit-verify.d.ts +19 -0
  505. package/dist/esm/cli/commands/audit-verify.d.ts.map +1 -0
  506. package/dist/esm/cli/commands/audit-verify.js +345 -0
  507. package/dist/esm/cli/commands/audit-verify.js.map +1 -0
  508. package/dist/esm/cli/commands/clean.d.ts +23 -0
  509. package/dist/esm/cli/commands/clean.d.ts.map +1 -0
  510. package/dist/esm/cli/commands/clean.js +235 -0
  511. package/dist/esm/cli/commands/clean.js.map +1 -0
  512. package/dist/esm/cli/commands/config-show.d.ts +2 -0
  513. package/dist/esm/cli/commands/config-show.d.ts.map +1 -0
  514. package/dist/esm/cli/commands/config-show.js +2 -0
  515. package/dist/esm/cli/commands/config-show.js.map +1 -0
  516. package/dist/esm/cli/commands/config.d.ts +6 -0
  517. package/dist/esm/cli/commands/config.d.ts.map +1 -0
  518. package/dist/esm/cli/commands/config.js +259 -0
  519. package/dist/esm/cli/commands/config.js.map +1 -0
  520. package/dist/esm/cli/commands/db-add.d.ts +16 -0
  521. package/dist/esm/cli/commands/db-add.d.ts.map +1 -0
  522. package/dist/esm/cli/commands/db-add.js +576 -0
  523. package/dist/esm/cli/commands/db-add.js.map +1 -0
  524. package/dist/esm/cli/commands/db-edit.d.ts +2 -0
  525. package/dist/esm/cli/commands/db-edit.d.ts.map +1 -0
  526. package/dist/esm/cli/commands/db-edit.js +352 -0
  527. package/dist/esm/cli/commands/db-edit.js.map +1 -0
  528. package/dist/esm/cli/commands/db-logs.d.ts +3 -0
  529. package/dist/esm/cli/commands/db-logs.d.ts.map +1 -0
  530. package/dist/esm/cli/commands/db-logs.js +64 -0
  531. package/dist/esm/cli/commands/db-logs.js.map +1 -0
  532. package/dist/esm/cli/commands/db-ls.d.ts +2 -0
  533. package/dist/esm/cli/commands/db-ls.d.ts.map +1 -0
  534. package/dist/esm/cli/commands/db-ls.js +115 -0
  535. package/dist/esm/cli/commands/db-ls.js.map +1 -0
  536. package/dist/esm/cli/commands/db-query.d.ts +121 -0
  537. package/dist/esm/cli/commands/db-query.d.ts.map +1 -0
  538. package/dist/esm/cli/commands/db-query.js +754 -0
  539. package/dist/esm/cli/commands/db-query.js.map +1 -0
  540. package/dist/esm/cli/commands/db-remove.d.ts +2 -0
  541. package/dist/esm/cli/commands/db-remove.d.ts.map +1 -0
  542. package/dist/esm/cli/commands/db-remove.js +48 -0
  543. package/dist/esm/cli/commands/db-remove.js.map +1 -0
  544. package/dist/esm/cli/commands/db-show.d.ts +2 -0
  545. package/dist/esm/cli/commands/db-show.d.ts.map +1 -0
  546. package/dist/esm/cli/commands/db-show.js +131 -0
  547. package/dist/esm/cli/commands/db-show.js.map +1 -0
  548. package/dist/esm/cli/commands/db-test.d.ts +3 -0
  549. package/dist/esm/cli/commands/db-test.d.ts.map +1 -0
  550. package/dist/esm/cli/commands/db-test.js +307 -0
  551. package/dist/esm/cli/commands/db-test.js.map +1 -0
  552. package/dist/esm/cli/commands/db.d.ts +11 -0
  553. package/dist/esm/cli/commands/db.d.ts.map +1 -0
  554. package/dist/esm/cli/commands/db.js +76 -0
  555. package/dist/esm/cli/commands/db.js.map +1 -0
  556. package/dist/esm/cli/commands/debug.d.ts +2 -0
  557. package/dist/esm/cli/commands/debug.d.ts.map +1 -0
  558. package/dist/esm/cli/commands/debug.js +205 -0
  559. package/dist/esm/cli/commands/debug.js.map +1 -0
  560. package/dist/esm/cli/commands/doctor.d.ts +5 -0
  561. package/dist/esm/cli/commands/doctor.d.ts.map +1 -0
  562. package/dist/esm/cli/commands/doctor.js +114 -0
  563. package/dist/esm/cli/commands/doctor.js.map +1 -0
  564. package/dist/esm/cli/commands/index.d.ts +10 -0
  565. package/dist/esm/cli/commands/index.d.ts.map +1 -0
  566. package/dist/esm/cli/commands/index.js +10 -0
  567. package/dist/esm/cli/commands/index.js.map +1 -0
  568. package/dist/esm/cli/commands/init.d.ts +2 -0
  569. package/dist/esm/cli/commands/init.d.ts.map +1 -0
  570. package/dist/esm/cli/commands/init.js +163 -0
  571. package/dist/esm/cli/commands/init.js.map +1 -0
  572. package/dist/esm/cli/commands/link.d.ts +5 -0
  573. package/dist/esm/cli/commands/link.d.ts.map +1 -0
  574. package/dist/esm/cli/commands/link.js +41 -0
  575. package/dist/esm/cli/commands/link.js.map +1 -0
  576. package/dist/esm/cli/commands/logs.d.ts +17 -0
  577. package/dist/esm/cli/commands/logs.d.ts.map +1 -0
  578. package/dist/esm/cli/commands/logs.js +278 -0
  579. package/dist/esm/cli/commands/logs.js.map +1 -0
  580. package/dist/esm/cli/commands/project-show.d.ts +2 -0
  581. package/dist/esm/cli/commands/project-show.d.ts.map +1 -0
  582. package/dist/esm/cli/commands/project-show.js +69 -0
  583. package/dist/esm/cli/commands/project-show.js.map +1 -0
  584. package/dist/esm/cli/commands/project.d.ts +3 -0
  585. package/dist/esm/cli/commands/project.d.ts.map +1 -0
  586. package/dist/esm/cli/commands/project.js +60 -0
  587. package/dist/esm/cli/commands/project.js.map +1 -0
  588. package/dist/esm/cli/commands/service.d.ts +123 -0
  589. package/dist/esm/cli/commands/service.d.ts.map +1 -0
  590. package/dist/esm/cli/commands/service.js +505 -0
  591. package/dist/esm/cli/commands/service.js.map +1 -0
  592. package/dist/esm/cli/commands/start.d.ts +6 -0
  593. package/dist/esm/cli/commands/start.d.ts.map +1 -0
  594. package/dist/esm/cli/commands/start.js +272 -0
  595. package/dist/esm/cli/commands/start.js.map +1 -0
  596. package/dist/esm/cli/commands/status.d.ts +2 -0
  597. package/dist/esm/cli/commands/status.d.ts.map +1 -0
  598. package/dist/esm/cli/commands/status.js +222 -0
  599. package/dist/esm/cli/commands/status.js.map +1 -0
  600. package/dist/esm/cli/commands/stop.d.ts +6 -0
  601. package/dist/esm/cli/commands/stop.d.ts.map +1 -0
  602. package/dist/esm/cli/commands/stop.js +96 -0
  603. package/dist/esm/cli/commands/stop.js.map +1 -0
  604. package/dist/esm/cli/daemon/error-tracker.d.ts +119 -0
  605. package/dist/esm/cli/daemon/error-tracker.d.ts.map +1 -0
  606. package/dist/esm/cli/daemon/error-tracker.js +451 -0
  607. package/dist/esm/cli/daemon/error-tracker.js.map +1 -0
  608. package/dist/esm/cli/daemon/fault-shutdown.d.ts +144 -0
  609. package/dist/esm/cli/daemon/fault-shutdown.d.ts.map +1 -0
  610. package/dist/esm/cli/daemon/fault-shutdown.js +273 -0
  611. package/dist/esm/cli/daemon/fault-shutdown.js.map +1 -0
  612. package/dist/esm/cli/daemon/index.d.ts +12 -0
  613. package/dist/esm/cli/daemon/index.d.ts.map +1 -0
  614. package/dist/esm/cli/daemon/index.js +7 -0
  615. package/dist/esm/cli/daemon/index.js.map +1 -0
  616. package/dist/esm/cli/daemon/pid-file.d.ts +13 -0
  617. package/dist/esm/cli/daemon/pid-file.d.ts.map +1 -0
  618. package/dist/esm/cli/daemon/pid-file.js +51 -0
  619. package/dist/esm/cli/daemon/pid-file.js.map +1 -0
  620. package/dist/esm/cli/daemon/readiness.d.ts +30 -0
  621. package/dist/esm/cli/daemon/readiness.d.ts.map +1 -0
  622. package/dist/esm/cli/daemon/readiness.js +70 -0
  623. package/dist/esm/cli/daemon/readiness.js.map +1 -0
  624. package/dist/esm/cli/daemon/runtime.d.ts +366 -0
  625. package/dist/esm/cli/daemon/runtime.d.ts.map +1 -0
  626. package/dist/esm/cli/daemon/runtime.js +1284 -0
  627. package/dist/esm/cli/daemon/runtime.js.map +1 -0
  628. package/dist/esm/cli/daemon/shutdown.d.ts +7 -0
  629. package/dist/esm/cli/daemon/shutdown.d.ts.map +1 -0
  630. package/dist/esm/cli/daemon/shutdown.js +63 -0
  631. package/dist/esm/cli/daemon/shutdown.js.map +1 -0
  632. package/dist/esm/cli/daemon/signal-handlers.d.ts +3 -0
  633. package/dist/esm/cli/daemon/signal-handlers.d.ts.map +1 -0
  634. package/dist/esm/cli/daemon/signal-handlers.js +24 -0
  635. package/dist/esm/cli/daemon/signal-handlers.js.map +1 -0
  636. package/dist/esm/cli/daemon/state.d.ts +157 -0
  637. package/dist/esm/cli/daemon/state.d.ts.map +1 -0
  638. package/dist/esm/cli/daemon/state.js +352 -0
  639. package/dist/esm/cli/daemon/state.js.map +1 -0
  640. package/dist/esm/cli/daemon/status-file.d.ts +139 -0
  641. package/dist/esm/cli/daemon/status-file.d.ts.map +1 -0
  642. package/dist/esm/cli/daemon/status-file.js +50 -0
  643. package/dist/esm/cli/daemon/status-file.js.map +1 -0
  644. package/dist/esm/cli/doctor/checks.d.ts +133 -0
  645. package/dist/esm/cli/doctor/checks.d.ts.map +1 -0
  646. package/dist/esm/cli/doctor/checks.js +624 -0
  647. package/dist/esm/cli/doctor/checks.js.map +1 -0
  648. package/dist/esm/cli/doctor/fixes.d.ts +9 -0
  649. package/dist/esm/cli/doctor/fixes.d.ts.map +1 -0
  650. package/dist/esm/cli/doctor/fixes.js +163 -0
  651. package/dist/esm/cli/doctor/fixes.js.map +1 -0
  652. package/dist/esm/cli/doctor/index.d.ts +7 -0
  653. package/dist/esm/cli/doctor/index.d.ts.map +1 -0
  654. package/dist/esm/cli/doctor/index.js +5 -0
  655. package/dist/esm/cli/doctor/index.js.map +1 -0
  656. package/dist/esm/cli/index.d.ts +3 -0
  657. package/dist/esm/cli/index.d.ts.map +1 -0
  658. package/dist/esm/cli/index.js +333 -0
  659. package/dist/esm/cli/index.js.map +1 -0
  660. package/dist/esm/cli/interactive.d.ts +8 -0
  661. package/dist/esm/cli/interactive.d.ts.map +1 -0
  662. package/dist/esm/cli/interactive.js +665 -0
  663. package/dist/esm/cli/interactive.js.map +1 -0
  664. package/dist/esm/cli/logs/format.d.ts +13 -0
  665. package/dist/esm/cli/logs/format.d.ts.map +1 -0
  666. package/dist/esm/cli/logs/format.js +169 -0
  667. package/dist/esm/cli/logs/format.js.map +1 -0
  668. package/dist/esm/cli/logs/index.d.ts +3 -0
  669. package/dist/esm/cli/logs/index.d.ts.map +1 -0
  670. package/dist/esm/cli/logs/index.js +3 -0
  671. package/dist/esm/cli/logs/index.js.map +1 -0
  672. package/dist/esm/cli/logs/viewer.d.ts +41 -0
  673. package/dist/esm/cli/logs/viewer.d.ts.map +1 -0
  674. package/dist/esm/cli/logs/viewer.js +412 -0
  675. package/dist/esm/cli/logs/viewer.js.map +1 -0
  676. package/dist/esm/cli/ops/operation-logger.d.ts +63 -0
  677. package/dist/esm/cli/ops/operation-logger.d.ts.map +1 -0
  678. package/dist/esm/cli/ops/operation-logger.js +142 -0
  679. package/dist/esm/cli/ops/operation-logger.js.map +1 -0
  680. package/dist/esm/cli/palette.d.ts +11 -0
  681. package/dist/esm/cli/palette.d.ts.map +1 -0
  682. package/dist/esm/cli/palette.js +240 -0
  683. package/dist/esm/cli/palette.js.map +1 -0
  684. package/dist/esm/cli/prompt.d.ts +186 -0
  685. package/dist/esm/cli/prompt.d.ts.map +1 -0
  686. package/dist/esm/cli/prompt.js +483 -0
  687. package/dist/esm/cli/prompt.js.map +1 -0
  688. package/dist/esm/cli/ui/box.d.ts +21 -0
  689. package/dist/esm/cli/ui/box.d.ts.map +1 -0
  690. package/dist/esm/cli/ui/box.js +60 -0
  691. package/dist/esm/cli/ui/box.js.map +1 -0
  692. package/dist/esm/cli/ui/clipboard.d.ts +6 -0
  693. package/dist/esm/cli/ui/clipboard.d.ts.map +1 -0
  694. package/dist/esm/cli/ui/clipboard.js +42 -0
  695. package/dist/esm/cli/ui/clipboard.js.map +1 -0
  696. package/dist/esm/cli/ui/colors.d.ts +57 -0
  697. package/dist/esm/cli/ui/colors.d.ts.map +1 -0
  698. package/dist/esm/cli/ui/colors.js +126 -0
  699. package/dist/esm/cli/ui/colors.js.map +1 -0
  700. package/dist/esm/cli/ui/index.d.ts +9 -0
  701. package/dist/esm/cli/ui/index.d.ts.map +1 -0
  702. package/dist/esm/cli/ui/index.js +7 -0
  703. package/dist/esm/cli/ui/index.js.map +1 -0
  704. package/dist/esm/cli/ui/spinner.d.ts +12 -0
  705. package/dist/esm/cli/ui/spinner.d.ts.map +1 -0
  706. package/dist/esm/cli/ui/spinner.js +78 -0
  707. package/dist/esm/cli/ui/spinner.js.map +1 -0
  708. package/dist/esm/cli/ui/symbols.d.ts +47 -0
  709. package/dist/esm/cli/ui/symbols.d.ts.map +1 -0
  710. package/dist/esm/cli/ui/symbols.js +109 -0
  711. package/dist/esm/cli/ui/symbols.js.map +1 -0
  712. package/dist/esm/cli/ui/table.d.ts +23 -0
  713. package/dist/esm/cli/ui/table.d.ts.map +1 -0
  714. package/dist/esm/cli/ui/table.js +156 -0
  715. package/dist/esm/cli/ui/table.js.map +1 -0
  716. package/dist/esm/cli/ui/terminal.d.ts +7 -0
  717. package/dist/esm/cli/ui/terminal.d.ts.map +1 -0
  718. package/dist/esm/cli/ui/terminal.js +32 -0
  719. package/dist/esm/cli/ui/terminal.js.map +1 -0
  720. package/dist/esm/config/atomic-write.d.ts +69 -0
  721. package/dist/esm/config/atomic-write.d.ts.map +1 -0
  722. package/dist/esm/config/atomic-write.js +246 -0
  723. package/dist/esm/config/atomic-write.js.map +1 -0
  724. package/dist/esm/config/db-config.d.ts +134 -0
  725. package/dist/esm/config/db-config.d.ts.map +1 -0
  726. package/dist/esm/config/db-config.js +542 -0
  727. package/dist/esm/config/db-config.js.map +1 -0
  728. package/dist/esm/config/machine-config.d.ts +85 -0
  729. package/dist/esm/config/machine-config.d.ts.map +1 -0
  730. package/dist/esm/config/machine-config.js +190 -0
  731. package/dist/esm/config/machine-config.js.map +1 -0
  732. package/dist/esm/config/paths.d.ts +64 -0
  733. package/dist/esm/config/paths.d.ts.map +1 -0
  734. package/dist/esm/config/paths.js +108 -0
  735. package/dist/esm/config/paths.js.map +1 -0
  736. package/dist/esm/config/schema.d.ts +72 -0
  737. package/dist/esm/config/schema.d.ts.map +1 -0
  738. package/dist/esm/config/schema.js +180 -0
  739. package/dist/esm/config/schema.js.map +1 -0
  740. package/dist/esm/config/token.d.ts +63 -0
  741. package/dist/esm/config/token.d.ts.map +1 -0
  742. package/dist/esm/config/token.js +104 -0
  743. package/dist/esm/config/token.js.map +1 -0
  744. package/dist/esm/execution/canceller.d.ts +41 -0
  745. package/dist/esm/execution/canceller.d.ts.map +1 -0
  746. package/dist/esm/execution/canceller.js +205 -0
  747. package/dist/esm/execution/canceller.js.map +1 -0
  748. package/dist/esm/execution/database-lookup.d.ts +56 -0
  749. package/dist/esm/execution/database-lookup.d.ts.map +1 -0
  750. package/dist/esm/execution/database-lookup.js +38 -0
  751. package/dist/esm/execution/database-lookup.js.map +1 -0
  752. package/dist/esm/execution/dispatcher.d.ts +181 -0
  753. package/dist/esm/execution/dispatcher.d.ts.map +1 -0
  754. package/dist/esm/execution/dispatcher.js +1258 -0
  755. package/dist/esm/execution/dispatcher.js.map +1 -0
  756. package/dist/esm/execution/function-effects.d.ts +209 -0
  757. package/dist/esm/execution/function-effects.d.ts.map +1 -0
  758. package/dist/esm/execution/function-effects.js +586 -0
  759. package/dist/esm/execution/function-effects.js.map +1 -0
  760. package/dist/esm/execution/introspection.d.ts +76 -0
  761. package/dist/esm/execution/introspection.d.ts.map +1 -0
  762. package/dist/esm/execution/introspection.js +442 -0
  763. package/dist/esm/execution/introspection.js.map +1 -0
  764. package/dist/esm/execution/migration-runner.d.ts +128 -0
  765. package/dist/esm/execution/migration-runner.d.ts.map +1 -0
  766. package/dist/esm/execution/migration-runner.js +754 -0
  767. package/dist/esm/execution/migration-runner.js.map +1 -0
  768. package/dist/esm/execution/non-tx-detector.d.ts +23 -0
  769. package/dist/esm/execution/non-tx-detector.d.ts.map +1 -0
  770. package/dist/esm/execution/non-tx-detector.js +215 -0
  771. package/dist/esm/execution/non-tx-detector.js.map +1 -0
  772. package/dist/esm/execution/pool.d.ts +229 -0
  773. package/dist/esm/execution/pool.d.ts.map +1 -0
  774. package/dist/esm/execution/pool.js +685 -0
  775. package/dist/esm/execution/pool.js.map +1 -0
  776. package/dist/esm/execution/query-runner.d.ts +88 -0
  777. package/dist/esm/execution/query-runner.d.ts.map +1 -0
  778. package/dist/esm/execution/query-runner.js +743 -0
  779. package/dist/esm/execution/query-runner.js.map +1 -0
  780. package/dist/esm/execution/rate-limiter.d.ts +120 -0
  781. package/dist/esm/execution/rate-limiter.d.ts.map +1 -0
  782. package/dist/esm/execution/rate-limiter.js +269 -0
  783. package/dist/esm/execution/rate-limiter.js.map +1 -0
  784. package/dist/esm/execution/search-path.d.ts +161 -0
  785. package/dist/esm/execution/search-path.d.ts.map +1 -0
  786. package/dist/esm/execution/search-path.js +270 -0
  787. package/dist/esm/execution/search-path.js.map +1 -0
  788. package/dist/esm/execution/sql-parser.d.ts +195 -0
  789. package/dist/esm/execution/sql-parser.d.ts.map +1 -0
  790. package/dist/esm/execution/sql-parser.js +683 -0
  791. package/dist/esm/execution/sql-parser.js.map +1 -0
  792. package/dist/esm/execution/statement-classifier.d.ts +103 -0
  793. package/dist/esm/execution/statement-classifier.d.ts.map +1 -0
  794. package/dist/esm/execution/statement-classifier.js +526 -0
  795. package/dist/esm/execution/statement-classifier.js.map +1 -0
  796. package/dist/esm/execution/types.d.ts +189 -0
  797. package/dist/esm/execution/types.d.ts.map +1 -0
  798. package/dist/esm/execution/types.js +22 -0
  799. package/dist/esm/execution/types.js.map +1 -0
  800. package/dist/esm/index.d.ts +34 -0
  801. package/dist/esm/index.d.ts.map +1 -0
  802. package/dist/esm/index.js +38 -0
  803. package/dist/esm/index.js.map +1 -0
  804. package/dist/esm/permissions/auto-upgrade.d.ts +40 -0
  805. package/dist/esm/permissions/auto-upgrade.d.ts.map +1 -0
  806. package/dist/esm/permissions/auto-upgrade.js +164 -0
  807. package/dist/esm/permissions/auto-upgrade.js.map +1 -0
  808. package/dist/esm/permissions/checker.d.ts +53 -0
  809. package/dist/esm/permissions/checker.d.ts.map +1 -0
  810. package/dist/esm/permissions/checker.js +322 -0
  811. package/dist/esm/permissions/checker.js.map +1 -0
  812. package/dist/esm/permissions/manual-approval.d.ts +213 -0
  813. package/dist/esm/permissions/manual-approval.d.ts.map +1 -0
  814. package/dist/esm/permissions/manual-approval.js +503 -0
  815. package/dist/esm/permissions/manual-approval.js.map +1 -0
  816. package/dist/esm/permissions/plan-registry.d.ts +274 -0
  817. package/dist/esm/permissions/plan-registry.d.ts.map +1 -0
  818. package/dist/esm/permissions/plan-registry.js +450 -0
  819. package/dist/esm/permissions/plan-registry.js.map +1 -0
  820. package/dist/esm/permissions/role-policy.d.ts +217 -0
  821. package/dist/esm/permissions/role-policy.d.ts.map +1 -0
  822. package/dist/esm/permissions/role-policy.js +570 -0
  823. package/dist/esm/permissions/role-policy.js.map +1 -0
  824. package/dist/esm/permissions/types.d.ts +126 -0
  825. package/dist/esm/permissions/types.d.ts.map +1 -0
  826. package/dist/esm/permissions/types.js +2 -0
  827. package/dist/esm/permissions/types.js.map +1 -0
  828. package/dist/esm/protocol/constants.d.ts +72 -0
  829. package/dist/esm/protocol/constants.d.ts.map +1 -0
  830. package/dist/esm/protocol/constants.js +104 -0
  831. package/dist/esm/protocol/constants.js.map +1 -0
  832. package/dist/esm/protocol/envelope.d.ts +165 -0
  833. package/dist/esm/protocol/envelope.d.ts.map +1 -0
  834. package/dist/esm/protocol/envelope.js +263 -0
  835. package/dist/esm/protocol/envelope.js.map +1 -0
  836. package/dist/esm/protocol/errors.d.ts +33 -0
  837. package/dist/esm/protocol/errors.d.ts.map +1 -0
  838. package/dist/esm/protocol/errors.js +384 -0
  839. package/dist/esm/protocol/errors.js.map +1 -0
  840. package/dist/esm/protocol/messages.d.ts +327 -0
  841. package/dist/esm/protocol/messages.d.ts.map +1 -0
  842. package/dist/esm/protocol/messages.js +2 -0
  843. package/dist/esm/protocol/messages.js.map +1 -0
  844. package/dist/esm/protocol/serialize.d.ts +26 -0
  845. package/dist/esm/protocol/serialize.d.ts.map +1 -0
  846. package/dist/esm/protocol/serialize.js +63 -0
  847. package/dist/esm/protocol/serialize.js.map +1 -0
  848. package/dist/esm/protocol/validate.d.ts +135 -0
  849. package/dist/esm/protocol/validate.d.ts.map +1 -0
  850. package/dist/esm/protocol/validate.js +830 -0
  851. package/dist/esm/protocol/validate.js.map +1 -0
  852. package/dist/types/audit/chain.d.ts +365 -0
  853. package/dist/types/audit/chain.d.ts.map +1 -0
  854. package/dist/types/audit/cloud-client.d.ts +142 -0
  855. package/dist/types/audit/cloud-client.d.ts.map +1 -0
  856. package/dist/types/audit/cloud-writer.d.ts +57 -0
  857. package/dist/types/audit/cloud-writer.d.ts.map +1 -0
  858. package/dist/types/audit/context.d.ts +51 -0
  859. package/dist/types/audit/context.d.ts.map +1 -0
  860. package/dist/types/audit/files.d.ts +111 -0
  861. package/dist/types/audit/files.d.ts.map +1 -0
  862. package/dist/types/audit/index.d.ts +9 -0
  863. package/dist/types/audit/index.d.ts.map +1 -0
  864. package/dist/types/audit/local-writer.d.ts +255 -0
  865. package/dist/types/audit/local-writer.d.ts.map +1 -0
  866. package/dist/types/audit/redact.d.ts +151 -0
  867. package/dist/types/audit/redact.d.ts.map +1 -0
  868. package/dist/types/audit/sanitize.d.ts +78 -0
  869. package/dist/types/audit/sanitize.d.ts.map +1 -0
  870. package/dist/types/audit/sink.d.ts +278 -0
  871. package/dist/types/audit/sink.d.ts.map +1 -0
  872. package/dist/types/audit/types.d.ts +226 -0
  873. package/dist/types/audit/types.d.ts.map +1 -0
  874. package/dist/types/audit/verify-cache.d.ts +127 -0
  875. package/dist/types/audit/verify-cache.d.ts.map +1 -0
  876. package/dist/types/channels/agent-session.d.ts +228 -0
  877. package/dist/types/channels/agent-session.d.ts.map +1 -0
  878. package/dist/types/channels/data-channel.d.ts +181 -0
  879. package/dist/types/channels/data-channel.d.ts.map +1 -0
  880. package/dist/types/channels/reconnect.d.ts +142 -0
  881. package/dist/types/channels/reconnect.d.ts.map +1 -0
  882. package/dist/types/channels/types.d.ts +112 -0
  883. package/dist/types/channels/types.d.ts.map +1 -0
  884. package/dist/types/channels/wake-channel.d.ts +232 -0
  885. package/dist/types/channels/wake-channel.d.ts.map +1 -0
  886. package/dist/types/cli/banner.d.ts +2 -0
  887. package/dist/types/cli/banner.d.ts.map +1 -0
  888. package/dist/types/cli/commands/agent.d.ts +30 -0
  889. package/dist/types/cli/commands/agent.d.ts.map +1 -0
  890. package/dist/types/cli/commands/audit-verify.d.ts +19 -0
  891. package/dist/types/cli/commands/audit-verify.d.ts.map +1 -0
  892. package/dist/types/cli/commands/clean.d.ts +23 -0
  893. package/dist/types/cli/commands/clean.d.ts.map +1 -0
  894. package/dist/types/cli/commands/config-show.d.ts +2 -0
  895. package/dist/types/cli/commands/config-show.d.ts.map +1 -0
  896. package/dist/types/cli/commands/config.d.ts +6 -0
  897. package/dist/types/cli/commands/config.d.ts.map +1 -0
  898. package/dist/types/cli/commands/db-add.d.ts +16 -0
  899. package/dist/types/cli/commands/db-add.d.ts.map +1 -0
  900. package/dist/types/cli/commands/db-edit.d.ts +2 -0
  901. package/dist/types/cli/commands/db-edit.d.ts.map +1 -0
  902. package/dist/types/cli/commands/db-logs.d.ts +3 -0
  903. package/dist/types/cli/commands/db-logs.d.ts.map +1 -0
  904. package/dist/types/cli/commands/db-ls.d.ts +2 -0
  905. package/dist/types/cli/commands/db-ls.d.ts.map +1 -0
  906. package/dist/types/cli/commands/db-query.d.ts +121 -0
  907. package/dist/types/cli/commands/db-query.d.ts.map +1 -0
  908. package/dist/types/cli/commands/db-remove.d.ts +2 -0
  909. package/dist/types/cli/commands/db-remove.d.ts.map +1 -0
  910. package/dist/types/cli/commands/db-show.d.ts +2 -0
  911. package/dist/types/cli/commands/db-show.d.ts.map +1 -0
  912. package/dist/types/cli/commands/db-test.d.ts +3 -0
  913. package/dist/types/cli/commands/db-test.d.ts.map +1 -0
  914. package/dist/types/cli/commands/db.d.ts +11 -0
  915. package/dist/types/cli/commands/db.d.ts.map +1 -0
  916. package/dist/types/cli/commands/debug.d.ts +2 -0
  917. package/dist/types/cli/commands/debug.d.ts.map +1 -0
  918. package/dist/types/cli/commands/doctor.d.ts +5 -0
  919. package/dist/types/cli/commands/doctor.d.ts.map +1 -0
  920. package/dist/types/cli/commands/index.d.ts +10 -0
  921. package/dist/types/cli/commands/index.d.ts.map +1 -0
  922. package/dist/types/cli/commands/init.d.ts +2 -0
  923. package/dist/types/cli/commands/init.d.ts.map +1 -0
  924. package/dist/types/cli/commands/link.d.ts +5 -0
  925. package/dist/types/cli/commands/link.d.ts.map +1 -0
  926. package/dist/types/cli/commands/logs.d.ts +17 -0
  927. package/dist/types/cli/commands/logs.d.ts.map +1 -0
  928. package/dist/types/cli/commands/project-show.d.ts +2 -0
  929. package/dist/types/cli/commands/project-show.d.ts.map +1 -0
  930. package/dist/types/cli/commands/project.d.ts +3 -0
  931. package/dist/types/cli/commands/project.d.ts.map +1 -0
  932. package/dist/types/cli/commands/service.d.ts +123 -0
  933. package/dist/types/cli/commands/service.d.ts.map +1 -0
  934. package/dist/types/cli/commands/start.d.ts +6 -0
  935. package/dist/types/cli/commands/start.d.ts.map +1 -0
  936. package/dist/types/cli/commands/status.d.ts +2 -0
  937. package/dist/types/cli/commands/status.d.ts.map +1 -0
  938. package/dist/types/cli/commands/stop.d.ts +6 -0
  939. package/dist/types/cli/commands/stop.d.ts.map +1 -0
  940. package/dist/types/cli/daemon/error-tracker.d.ts +119 -0
  941. package/dist/types/cli/daemon/error-tracker.d.ts.map +1 -0
  942. package/dist/types/cli/daemon/fault-shutdown.d.ts +144 -0
  943. package/dist/types/cli/daemon/fault-shutdown.d.ts.map +1 -0
  944. package/dist/types/cli/daemon/index.d.ts +12 -0
  945. package/dist/types/cli/daemon/index.d.ts.map +1 -0
  946. package/dist/types/cli/daemon/pid-file.d.ts +13 -0
  947. package/dist/types/cli/daemon/pid-file.d.ts.map +1 -0
  948. package/dist/types/cli/daemon/readiness.d.ts +30 -0
  949. package/dist/types/cli/daemon/readiness.d.ts.map +1 -0
  950. package/dist/types/cli/daemon/runtime.d.ts +366 -0
  951. package/dist/types/cli/daemon/runtime.d.ts.map +1 -0
  952. package/dist/types/cli/daemon/shutdown.d.ts +7 -0
  953. package/dist/types/cli/daemon/shutdown.d.ts.map +1 -0
  954. package/dist/types/cli/daemon/signal-handlers.d.ts +3 -0
  955. package/dist/types/cli/daemon/signal-handlers.d.ts.map +1 -0
  956. package/dist/types/cli/daemon/state.d.ts +157 -0
  957. package/dist/types/cli/daemon/state.d.ts.map +1 -0
  958. package/dist/types/cli/daemon/status-file.d.ts +139 -0
  959. package/dist/types/cli/daemon/status-file.d.ts.map +1 -0
  960. package/dist/types/cli/doctor/checks.d.ts +133 -0
  961. package/dist/types/cli/doctor/checks.d.ts.map +1 -0
  962. package/dist/types/cli/doctor/fixes.d.ts +9 -0
  963. package/dist/types/cli/doctor/fixes.d.ts.map +1 -0
  964. package/dist/types/cli/doctor/index.d.ts +7 -0
  965. package/dist/types/cli/doctor/index.d.ts.map +1 -0
  966. package/dist/types/cli/index.d.ts +3 -0
  967. package/dist/types/cli/index.d.ts.map +1 -0
  968. package/dist/types/cli/interactive.d.ts +8 -0
  969. package/dist/types/cli/interactive.d.ts.map +1 -0
  970. package/dist/types/cli/logs/format.d.ts +13 -0
  971. package/dist/types/cli/logs/format.d.ts.map +1 -0
  972. package/dist/types/cli/logs/index.d.ts +3 -0
  973. package/dist/types/cli/logs/index.d.ts.map +1 -0
  974. package/dist/types/cli/logs/viewer.d.ts +41 -0
  975. package/dist/types/cli/logs/viewer.d.ts.map +1 -0
  976. package/dist/types/cli/ops/operation-logger.d.ts +63 -0
  977. package/dist/types/cli/ops/operation-logger.d.ts.map +1 -0
  978. package/dist/types/cli/palette.d.ts +11 -0
  979. package/dist/types/cli/palette.d.ts.map +1 -0
  980. package/dist/types/cli/prompt.d.ts +186 -0
  981. package/dist/types/cli/prompt.d.ts.map +1 -0
  982. package/dist/types/cli/ui/box.d.ts +21 -0
  983. package/dist/types/cli/ui/box.d.ts.map +1 -0
  984. package/dist/types/cli/ui/clipboard.d.ts +6 -0
  985. package/dist/types/cli/ui/clipboard.d.ts.map +1 -0
  986. package/dist/types/cli/ui/colors.d.ts +57 -0
  987. package/dist/types/cli/ui/colors.d.ts.map +1 -0
  988. package/dist/types/cli/ui/index.d.ts +9 -0
  989. package/dist/types/cli/ui/index.d.ts.map +1 -0
  990. package/dist/types/cli/ui/spinner.d.ts +12 -0
  991. package/dist/types/cli/ui/spinner.d.ts.map +1 -0
  992. package/dist/types/cli/ui/symbols.d.ts +47 -0
  993. package/dist/types/cli/ui/symbols.d.ts.map +1 -0
  994. package/dist/types/cli/ui/table.d.ts +23 -0
  995. package/dist/types/cli/ui/table.d.ts.map +1 -0
  996. package/dist/types/cli/ui/terminal.d.ts +7 -0
  997. package/dist/types/cli/ui/terminal.d.ts.map +1 -0
  998. package/dist/types/config/atomic-write.d.ts +69 -0
  999. package/dist/types/config/atomic-write.d.ts.map +1 -0
  1000. package/dist/types/config/db-config.d.ts +134 -0
  1001. package/dist/types/config/db-config.d.ts.map +1 -0
  1002. package/dist/types/config/machine-config.d.ts +85 -0
  1003. package/dist/types/config/machine-config.d.ts.map +1 -0
  1004. package/dist/types/config/paths.d.ts +64 -0
  1005. package/dist/types/config/paths.d.ts.map +1 -0
  1006. package/dist/types/config/schema.d.ts +72 -0
  1007. package/dist/types/config/schema.d.ts.map +1 -0
  1008. package/dist/types/config/token.d.ts +63 -0
  1009. package/dist/types/config/token.d.ts.map +1 -0
  1010. package/dist/types/execution/canceller.d.ts +41 -0
  1011. package/dist/types/execution/canceller.d.ts.map +1 -0
  1012. package/dist/types/execution/database-lookup.d.ts +56 -0
  1013. package/dist/types/execution/database-lookup.d.ts.map +1 -0
  1014. package/dist/types/execution/dispatcher.d.ts +181 -0
  1015. package/dist/types/execution/dispatcher.d.ts.map +1 -0
  1016. package/dist/types/execution/function-effects.d.ts +209 -0
  1017. package/dist/types/execution/function-effects.d.ts.map +1 -0
  1018. package/dist/types/execution/introspection.d.ts +76 -0
  1019. package/dist/types/execution/introspection.d.ts.map +1 -0
  1020. package/dist/types/execution/migration-runner.d.ts +128 -0
  1021. package/dist/types/execution/migration-runner.d.ts.map +1 -0
  1022. package/dist/types/execution/non-tx-detector.d.ts +23 -0
  1023. package/dist/types/execution/non-tx-detector.d.ts.map +1 -0
  1024. package/dist/types/execution/pool.d.ts +229 -0
  1025. package/dist/types/execution/pool.d.ts.map +1 -0
  1026. package/dist/types/execution/query-runner.d.ts +88 -0
  1027. package/dist/types/execution/query-runner.d.ts.map +1 -0
  1028. package/dist/types/execution/rate-limiter.d.ts +120 -0
  1029. package/dist/types/execution/rate-limiter.d.ts.map +1 -0
  1030. package/dist/types/execution/search-path.d.ts +161 -0
  1031. package/dist/types/execution/search-path.d.ts.map +1 -0
  1032. package/dist/types/execution/sql-parser.d.ts +195 -0
  1033. package/dist/types/execution/sql-parser.d.ts.map +1 -0
  1034. package/dist/types/execution/statement-classifier.d.ts +103 -0
  1035. package/dist/types/execution/statement-classifier.d.ts.map +1 -0
  1036. package/dist/types/execution/types.d.ts +189 -0
  1037. package/dist/types/execution/types.d.ts.map +1 -0
  1038. package/dist/types/index.d.ts +34 -0
  1039. package/dist/types/index.d.ts.map +1 -0
  1040. package/dist/types/permissions/auto-upgrade.d.ts +40 -0
  1041. package/dist/types/permissions/auto-upgrade.d.ts.map +1 -0
  1042. package/dist/types/permissions/checker.d.ts +53 -0
  1043. package/dist/types/permissions/checker.d.ts.map +1 -0
  1044. package/dist/types/permissions/manual-approval.d.ts +213 -0
  1045. package/dist/types/permissions/manual-approval.d.ts.map +1 -0
  1046. package/dist/types/permissions/plan-registry.d.ts +274 -0
  1047. package/dist/types/permissions/plan-registry.d.ts.map +1 -0
  1048. package/dist/types/permissions/role-policy.d.ts +217 -0
  1049. package/dist/types/permissions/role-policy.d.ts.map +1 -0
  1050. package/dist/types/permissions/types.d.ts +126 -0
  1051. package/dist/types/permissions/types.d.ts.map +1 -0
  1052. package/dist/types/protocol/constants.d.ts +72 -0
  1053. package/dist/types/protocol/constants.d.ts.map +1 -0
  1054. package/dist/types/protocol/envelope.d.ts +165 -0
  1055. package/dist/types/protocol/envelope.d.ts.map +1 -0
  1056. package/dist/types/protocol/errors.d.ts +33 -0
  1057. package/dist/types/protocol/errors.d.ts.map +1 -0
  1058. package/dist/types/protocol/messages.d.ts +327 -0
  1059. package/dist/types/protocol/messages.d.ts.map +1 -0
  1060. package/dist/types/protocol/serialize.d.ts +26 -0
  1061. package/dist/types/protocol/serialize.d.ts.map +1 -0
  1062. package/dist/types/protocol/validate.d.ts +135 -0
  1063. package/dist/types/protocol/validate.d.ts.map +1 -0
  1064. package/package.json +116 -4
  1065. package/scripts/generate-systemd-service.mjs +117 -0
@@ -0,0 +1,798 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.MigrationRunner = exports.MIGRATION_LOCK_TIMEOUT_MS = exports.MAX_MIGRATION_DEADLINE_MS = exports.MAX_MIGRATION_STATEMENT_TIMEOUT_MS = exports.MigrationTimeoutError = exports.MigrationPartiallyAppliedError = exports.MigrationPlanUnsafeError = exports.MigrationStrategyConflictError = exports.MigrationInProgressError = void 0;
37
+ exports.resolveMigrationBudget = resolveMigrationBudget;
38
+ exports.advisoryLockKey = advisoryLockKey;
39
+ const crypto = __importStar(require("crypto"));
40
+ const pool_1 = require("./pool");
41
+ const machine_config_1 = require("../config/machine-config");
42
+ const types_1 = require("./types");
43
+ const non_tx_detector_1 = require("./non-tx-detector");
44
+ const statement_classifier_1 = require("./statement-classifier");
45
+ const redact_1 = require("../audit/redact");
46
+ const sanitize_1 = require("../audit/sanitize");
47
+ const constants_1 = require("../protocol/constants");
48
+ class MigrationInProgressError extends Error {
49
+ /** Error catalog code. Not a SQLSTATE: `safePgCode` requires exactly 5. */
50
+ code = 'migration_in_progress';
51
+ constructor(message) {
52
+ super(message);
53
+ this.name = 'MigrationInProgressError';
54
+ }
55
+ }
56
+ exports.MigrationInProgressError = MigrationInProgressError;
57
+ class MigrationStrategyConflictError extends Error {
58
+ code = 'migration_strategy_conflict';
59
+ constructor(message) {
60
+ super(message);
61
+ this.name = 'MigrationStrategyConflictError';
62
+ }
63
+ }
64
+ exports.MigrationStrategyConflictError = MigrationStrategyConflictError;
65
+ /**
66
+ * The plan could not be verified: something in it does not parse, contains
67
+ * more than one statement, or is a statement form the agent cannot prove runs
68
+ * inside a transaction block. The run is refused rather than guessed at.
69
+ */
70
+ class MigrationPlanUnsafeError extends Error {
71
+ code = 'migration_plan_unsafe';
72
+ constructor(message) {
73
+ super(message);
74
+ this.name = 'MigrationPlanUnsafeError';
75
+ }
76
+ }
77
+ exports.MigrationPlanUnsafeError = MigrationPlanUnsafeError;
78
+ /**
79
+ * The migration stopped partway with statements already committed.
80
+ *
81
+ * `MigrationRunner.run` never *resolves* with `status: 'partial'`: a caller
82
+ * that only inspects a returned value can therefore never mistake a
83
+ * half-applied schema for a success. The per-statement detail is on
84
+ * {@link MigrationPartiallyAppliedError.result} for a caller that wants to
85
+ * report it.
86
+ */
87
+ class MigrationPartiallyAppliedError extends Error {
88
+ code = 'migration_partial';
89
+ result;
90
+ pg_error_code;
91
+ constructor(message, result) {
92
+ super(message);
93
+ this.name = 'MigrationPartiallyAppliedError';
94
+ this.result = result;
95
+ const failed = result.statements.find((s) => s.status === 'failed');
96
+ this.pg_error_code = failed?.pg_error_code;
97
+ }
98
+ }
99
+ exports.MigrationPartiallyAppliedError = MigrationPartiallyAppliedError;
100
+ /** The run exceeded its overall deadline and was abandoned. */
101
+ class MigrationTimeoutError extends Error {
102
+ code = 'migration_timeout';
103
+ constructor(message) {
104
+ super(message);
105
+ this.name = 'MigrationTimeoutError';
106
+ }
107
+ }
108
+ exports.MigrationTimeoutError = MigrationTimeoutError;
109
+ /**
110
+ * Absolute ceiling on one migration statement, in milliseconds. A caller
111
+ * cannot raise it, and it can never exceed the agent-wide statement ceiling in
112
+ * `pool.ts` — nothing is allowed to turn `statement_timeout` off.
113
+ */
114
+ exports.MAX_MIGRATION_STATEMENT_TIMEOUT_MS = Math.min(constants_1.DEFAULTS.MIGRATION_TIMEOUT_MS, pool_1.MAX_STATEMENT_TIMEOUT_MS);
115
+ /** Absolute ceiling on the whole migration run, in milliseconds. */
116
+ exports.MAX_MIGRATION_DEADLINE_MS = constants_1.DEFAULTS.MIGRATION_TIMEOUT_MS;
117
+ /** How long a migration statement may wait for a lock before it is cancelled. */
118
+ exports.MIGRATION_LOCK_TIMEOUT_MS = pool_1.LOCK_TIMEOUT_MS;
119
+ /** PostgreSQL's SQLSTATE for a statement cancelled by a timeout or a cancel request. */
120
+ const PG_QUERY_CANCELED = '57014';
121
+ /**
122
+ * Internal marker: the run was torn down by a cancellation or by the overall
123
+ * deadline. It never leaves this module — callers see {@link
124
+ * MigrationTimeoutError} or {@link MigrationPartiallyAppliedError}.
125
+ */
126
+ class RunInterrupted extends Error {
127
+ /** Which edge tore the run down. */
128
+ reason;
129
+ constructor(reason) {
130
+ super(`migration run interrupted: ${reason}`);
131
+ this.name = 'RunInterrupted';
132
+ this.reason = reason;
133
+ }
134
+ }
135
+ /**
136
+ * The exact integer that reaches `SET statement_timeout = …`.
137
+ *
138
+ * The value is interpolated into SQL, so it is re-validated where it is used
139
+ * instead of trusted from the caller: only a finite, positive, safe integer
140
+ * survives, and anything else becomes the server-owned ceiling. Nothing a remote
141
+ * caller can put in `timeout_ms` reaches the statement text verbatim, and a
142
+ * clamped value can never be `0` — which PostgreSQL reads as "no timeout".
143
+ */
144
+ function safeTimeoutMs(value, ceilingMs) {
145
+ if (!Number.isFinite(value) || !Number.isSafeInteger(value) || value <= 0) {
146
+ return ceilingMs;
147
+ }
148
+ return Math.min(value, ceilingMs);
149
+ }
150
+ /**
151
+ * Turn a caller-supplied `timeout_ms` into the three server-side budgets.
152
+ *
153
+ * The number is never trusted: it is floored to an integer, and clamped to
154
+ * {@link MAX_MIGRATION_STATEMENT_TIMEOUT_MS} / {@link MAX_MIGRATION_DEADLINE_MS}.
155
+ * `0`, a negative number, `NaN` and `Infinity` all mean "use the server
156
+ * default" — never "no timeout", which is how a remote caller would otherwise
157
+ * be able to remove the ceiling by asking for zero.
158
+ */
159
+ function resolveMigrationBudget(requestedTimeoutMs) {
160
+ const requested = typeof requestedTimeoutMs === 'number' &&
161
+ Number.isFinite(requestedTimeoutMs) &&
162
+ requestedTimeoutMs > 0
163
+ ? Math.floor(requestedTimeoutMs)
164
+ : undefined;
165
+ const statementTimeoutMs = requested === undefined
166
+ ? exports.MAX_MIGRATION_STATEMENT_TIMEOUT_MS
167
+ : Math.min(requested, exports.MAX_MIGRATION_STATEMENT_TIMEOUT_MS);
168
+ const deadlineMs = requested === undefined
169
+ ? exports.MAX_MIGRATION_DEADLINE_MS
170
+ : Math.min(requested, exports.MAX_MIGRATION_DEADLINE_MS);
171
+ return {
172
+ statementTimeoutMs,
173
+ deadlineMs,
174
+ lockTimeoutMs: Math.min(exports.MIGRATION_LOCK_TIMEOUT_MS, statementTimeoutMs),
175
+ };
176
+ }
177
+ /**
178
+ * Refuse a plan whose entries are not exactly one statement each.
179
+ *
180
+ * node-postgres takes the simple query protocol whenever `values` is falsy, and
181
+ * that protocol executes *every* semicolon-separated statement in one round
182
+ * trip. `SELECT 1; DROP TABLE users` is therefore two commands to PostgreSQL and
183
+ * one string to everything above it — the C-01 mechanism, reachable through the
184
+ * migration path.
185
+ *
186
+ * The verdict comes from the PostgreSQL parse tree, so a `;` inside a string
187
+ * literal, a dollar-quoted body, a quoted identifier or a comment cannot trip
188
+ * it, a single trailing terminator is not a second statement, and a real second
189
+ * statement always is. Anything that does not parse exactly once is refused,
190
+ * which also covers a plan written for a PostgreSQL version this agent cannot
191
+ * parse: an unverifiable entry is never executed.
192
+ */
193
+ async function assertOneStatementPerEntry(statements) {
194
+ const offenders = [];
195
+ for (let i = 0; i < statements.length; i++) {
196
+ try {
197
+ await (0, statement_classifier_1.assertSingleReadStatement)(statements[i]);
198
+ }
199
+ catch {
200
+ offenders.push(i);
201
+ }
202
+ }
203
+ if (offenders.length === 0)
204
+ return;
205
+ throw new MigrationPlanUnsafeError(`Migration plan contains entries that are not exactly one statement ` +
206
+ `(index ${offenders.map((i) => i + 1).join(', ')}). Refusing the plan: an entry that ` +
207
+ 'hides a second command behind a semicolon would be executed as two commands, and ' +
208
+ 'one the agent could not parse cannot be verified.');
209
+ }
210
+ /**
211
+ * Read the `locked` column of a `pg_try_advisory_*_lock` result.
212
+ *
213
+ * Only an explicit `true` counts as taken: a missing or non-boolean answer fails
214
+ * closed, because a run that proceeded while believing it held the lock would
215
+ * have no mutual exclusion at all.
216
+ */
217
+ function lockTaken(res) {
218
+ return res.rows[0]?.locked === true;
219
+ }
220
+ /**
221
+ * Advisory lock key for SW migrations.
222
+ *
223
+ * Keyed with HMAC-SHA256 over a per-installation secret. The previous version
224
+ * hashed the project name with a bare MD5, so anybody who could guess (or was
225
+ * told) a project name could compute the lock key, take the lock from another
226
+ * session, and deny migrations for that project indefinitely. A keyed MAC is
227
+ * not derivable by a third party with database access, because the secret never
228
+ * reaches the database.
229
+ */
230
+ function advisoryLockKey(projectName, secret) {
231
+ const mac = crypto
232
+ .createHmac('sha256', secret)
233
+ .update(`schema-weaver:migration-lock:v1:${projectName}`)
234
+ .digest();
235
+ const key1 = mac.readInt32BE(0);
236
+ let key2 = mac.readInt32BE(4);
237
+ if (key1 === key2) {
238
+ key2 = key1 === 0x7fffffff ? key1 - 1 : key1 + 1;
239
+ }
240
+ return { key1, key2 };
241
+ }
242
+ class MigrationRunner {
243
+ poolManager;
244
+ injectedLockSecret;
245
+ resolvedLockSecret = null;
246
+ constructor(opts) {
247
+ this.poolManager = opts.poolManager;
248
+ this.injectedLockSecret = opts.lockSecret;
249
+ }
250
+ /**
251
+ * The installation secret the lock key is keyed with.
252
+ *
253
+ * An explicit option wins (tests, embedders). Otherwise the agent token from
254
+ * the machine config is used: it is per-installation, secret, and stable
255
+ * across processes, which is exactly what mutual exclusion between two agents
256
+ * needs. If the machine config cannot be read the fallback is a random
257
+ * per-process secret — still unguessable from outside, so the lock key cannot
258
+ * be pre-taken by anyone with database access.
259
+ */
260
+ lockSecret() {
261
+ if (this.injectedLockSecret && this.injectedLockSecret.length > 0) {
262
+ return this.injectedLockSecret;
263
+ }
264
+ if (this.resolvedLockSecret !== null)
265
+ return this.resolvedLockSecret;
266
+ try {
267
+ this.resolvedLockSecret = (0, machine_config_1.loadMachineConfig)().agent_token;
268
+ }
269
+ catch {
270
+ this.resolvedLockSecret = crypto.randomBytes(32).toString('hex');
271
+ }
272
+ return this.resolvedLockSecret;
273
+ }
274
+ async run(payload, ctx) {
275
+ const startTime = Date.now();
276
+ // Step 1: Validate
277
+ if (payload.statements.length === 0) {
278
+ if (payload.dry_run) {
279
+ return {
280
+ plan_id: payload.plan_id,
281
+ status: 'dry_run_ok',
282
+ statements: [],
283
+ total_ms: Date.now() - startTime,
284
+ rolled_back_indices: [],
285
+ };
286
+ }
287
+ throw new Error('Migration run payload contains no statements');
288
+ }
289
+ if (payload.statements.length > constants_1.LIMITS.MAX_STATEMENT_COUNT_PER_MIGRATION) {
290
+ throw new Error(`Migration statement count exceeds maximum limit (${constants_1.LIMITS.MAX_STATEMENT_COUNT_PER_MIGRATION})`);
291
+ }
292
+ for (const stmt of payload.statements) {
293
+ if (!stmt.trim()) {
294
+ throw new Error('Migration payload contains an empty statement');
295
+ }
296
+ if (Buffer.byteLength(stmt, 'utf8') > constants_1.LIMITS.MAX_STATEMENT_LENGTH) {
297
+ throw new Error(`Statement length exceeds maximum allowed limit (${constants_1.LIMITS.MAX_STATEMENT_LENGTH})`);
298
+ }
299
+ }
300
+ // Step 2: Verify the plan before a connection or a lock is taken. Two
301
+ // independent checks, both driven by the PostgreSQL parse tree and both
302
+ // failing closed: every entry must be EXACTLY ONE statement, and every
303
+ // entry must be one whose transactionality the agent can prove.
304
+ await assertOneStatementPerEntry(payload.statements);
305
+ const nonTxCheck = await (0, non_tx_detector_1.detectNonTransactional)(payload.statements);
306
+ if (nonTxCheck.unparseable_indices.length > 0) {
307
+ throw new MigrationPlanUnsafeError(`Migration plan contains statements that PostgreSQL cannot parse ` +
308
+ `(index ${nonTxCheck.unparseable_indices.map((i) => i + 1).join(', ')}). ` +
309
+ 'Refusing to run an unverified plan.');
310
+ }
311
+ if (nonTxCheck.ambiguous_indices.length > 0) {
312
+ throw new MigrationPlanUnsafeError(`Migration plan contains statements that cannot be verified as transactional ` +
313
+ `(index ${nonTxCheck.ambiguous_indices.map((i) => i + 1).join(', ')}): ` +
314
+ `${nonTxCheck.summary}. Refusing to run an unverified plan.`);
315
+ }
316
+ const strategy = payload.strategy;
317
+ // Step 3: Dry run (parse only, no execution, no connection)
318
+ if (payload.dry_run) {
319
+ const statementResults = [];
320
+ const conflictIndices = new Set(strategy === 'single_tx' ? nonTxCheck.non_tx_indices : []);
321
+ let allPassed = true;
322
+ for (let i = 0; i < payload.statements.length; i++) {
323
+ const stmt = payload.statements[i];
324
+ const stmtStart = Date.now();
325
+ if (conflictIndices.has(i)) {
326
+ allPassed = false;
327
+ statementResults.push({
328
+ index: i,
329
+ status: 'failed',
330
+ ms: Date.now() - stmtStart,
331
+ rows_affected: 0,
332
+ error: `${nonTxCheck.summary} — strategy='single_tx' cannot run this plan`,
333
+ });
334
+ continue;
335
+ }
336
+ try {
337
+ // Parse-only validation. The previous implementation executed
338
+ // transactional DDL inside BEGIN/ROLLBACK against the production
339
+ // database during a "dry run"; anything the classifier wrongly
340
+ // called transactional really ran.
341
+ await (0, statement_classifier_1.assertSingleReadStatement)(stmt);
342
+ statementResults.push({
343
+ index: i,
344
+ status: 'success',
345
+ ms: Date.now() - stmtStart,
346
+ rows_affected: 0,
347
+ });
348
+ }
349
+ catch (err) {
350
+ allPassed = false;
351
+ statementResults.push({
352
+ index: i,
353
+ status: 'failed',
354
+ ms: Date.now() - stmtStart,
355
+ rows_affected: 0,
356
+ error: err instanceof Error ? err.message : String(err),
357
+ pg_error_code: err && typeof err === 'object' && 'code' in err
358
+ ? String(err.code)
359
+ : undefined,
360
+ });
361
+ }
362
+ }
363
+ return {
364
+ plan_id: payload.plan_id,
365
+ status: allPassed ? 'dry_run_ok' : 'dry_run_failed',
366
+ statements: statementResults,
367
+ total_ms: Date.now() - startTime,
368
+ rolled_back_indices: [],
369
+ };
370
+ }
371
+ // Previously the runner silently rewrote a caller-requested single_tx
372
+ // migration into per_statement, which turns an all-or-nothing migration
373
+ // into a sequence of individually-committed statements. A partial
374
+ // migration leaves the schema half-applied and was reported as a success.
375
+ // Now the conflict is an explicit error the caller must resolve. A dry run
376
+ // reports it in the result instead of throwing, because that is what the
377
+ // caller asked dry runs for.
378
+ if (nonTxCheck.has_non_transactional && strategy === 'single_tx') {
379
+ throw new MigrationStrategyConflictError(`Migration requested single_tx but contains statements that cannot run inside a ` +
380
+ `transaction (${nonTxCheck.summary}). Re-submit with strategy='per_statement' ` +
381
+ 'if partial application is acceptable.');
382
+ }
383
+ // Step 4: Budgets. Every statement runs under a server-controlled
384
+ // statement_timeout and lock_timeout, and the run's own wall-clock deadline
385
+ // is raced against each in-flight statement below, so the run cannot outlive
386
+ // its deadline even if a single statement is slow. `timeout_ms` from the
387
+ // caller is honoured but never trusted: `resolveMigrationBudget` clamps it.
388
+ const budget = resolveMigrationBudget(payload.timeout_ms);
389
+ // Step 5: Acquire a connection and take the advisory lock
390
+ const { client, release, pid } = await this.poolManager.acquire(ctx.dbEntry);
391
+ // A migration always leaves state that `release()` cannot undo: an open
392
+ // transaction, session-level GUCs, a session-scoped advisory lock. Declaring
393
+ // the session dirty HERE, before the first statement that can change it,
394
+ // means the pool destroys the connection on every exit path — including an
395
+ // exception thrown between BEGIN and the `finally` below — instead of
396
+ // handing a half-used session to the next request. The cost is one
397
+ // reconnect per migration.
398
+ (0, pool_1.markSessionDirty)(client);
399
+ // The overall deadline starts once the backend is in hand: connection
400
+ // setup is already bounded by the pool's connectionTimeoutMillis, and the
401
+ // lock is taken with pg_try_advisory_* so it never blocks either.
402
+ const deadlineAt = Date.now() + budget.deadlineMs;
403
+ /**
404
+ * Why the run was torn down early, if it was. `null` while it is healthy.
405
+ * First cause wins: a deadline that expires while a cancellation is already
406
+ * unwinding the run must not overwrite the reason its caller is waiting on.
407
+ */
408
+ let interruption = null;
409
+ let rejectInterrupt = () => undefined;
410
+ /**
411
+ * Rejects the instant the run is torn down. Every in-flight statement is
412
+ * raced against it, which is what makes the deadline a bound on the run's
413
+ * wall clock and not merely a check between statements: without the race a
414
+ * single statement that outlives the budget is still waited out in full,
415
+ * holding the advisory lock the whole time.
416
+ */
417
+ const interrupted = new Promise((_resolve, reject) => {
418
+ rejectInterrupt = reject;
419
+ });
420
+ // A run is usually torn down between statements, when nothing is racing
421
+ // this promise, and a rejection nobody awaits is an unhandled rejection at
422
+ // process level. Marking it handled here does not stop `Promise.race` from
423
+ // seeing it later.
424
+ void interrupted.catch(() => undefined);
425
+ const interrupt = (cause) => {
426
+ if (interruption !== null)
427
+ return;
428
+ interruption = cause;
429
+ rejectInterrupt(new RunInterrupted(cause));
430
+ };
431
+ const deadlineTimer = setTimeout(() => {
432
+ interrupt('deadline');
433
+ }, budget.deadlineMs);
434
+ const abortController = new AbortController();
435
+ const inFlightReq = {
436
+ request_id: ctx.request_id,
437
+ db_alias: ctx.dbEntry.db_alias,
438
+ pid,
439
+ started_at: Date.now(),
440
+ abort: abortController,
441
+ is_streaming: false,
442
+ };
443
+ // The listener is attached BEFORE the request is registered, and a signal
444
+ // that is already aborted is honoured immediately. An `abort` event that
445
+ // fired before `addEventListener` never fires again, so a canceller that
446
+ // aborts during registration (or a caller that hands in an aborted signal)
447
+ // would otherwise be ignored and the run would execute in full and take the
448
+ // advisory lock for a request nobody is waiting for.
449
+ const onAbort = () => {
450
+ // Abort whichever controller the canceller can reach: `registerInFlight`
451
+ // hands it `inFlightRequest.abort`, and the dispatcher substitutes its own
452
+ // controller there. Leaving that one unaborted would report
453
+ // `local_abort: false` for a cancellation the runner did act on.
454
+ if (!abortController.signal.aborted)
455
+ abortController.abort();
456
+ if (!inFlightReq.abort.signal.aborted)
457
+ inFlightReq.abort.abort();
458
+ interrupt('aborted');
459
+ };
460
+ if (ctx.abortSignal) {
461
+ ctx.abortSignal.addEventListener('abort', onAbort);
462
+ }
463
+ if (ctx.abortSignal?.aborted) {
464
+ onAbort();
465
+ }
466
+ // The canceller can only ever fire `InFlightRequest.abort`. It is observed
467
+ // here as well, so a caller that keeps this runner's own controller instead
468
+ // of substituting its own still stops the run instead of letting a
469
+ // cancelled migration carry on to its commit.
470
+ abortController.signal.addEventListener('abort', onAbort);
471
+ if (ctx.registerInFlight) {
472
+ ctx.registerInFlight(inFlightReq);
473
+ }
474
+ // `registerInFlight` can abort synchronously — the canceller, or a harness
475
+ // standing in for it — and `signal.aborted` is the only trace that leaves,
476
+ // so the state of both controllers is re-read after registration rather than
477
+ // trusted to have produced an event.
478
+ if (inFlightReq.abort.signal.aborted || ctx.abortSignal?.aborted === true) {
479
+ interrupt('aborted');
480
+ }
481
+ const { key1, key2 } = advisoryLockKey(ctx.project, this.lockSecret());
482
+ const statementResults = [];
483
+ const rolledBackIndices = [];
484
+ let migrationStatus = 'committed';
485
+ const outcome = () => migrationStatus;
486
+ let transactionOpen = false;
487
+ let sessionLockHeld = false;
488
+ let abandonedForDeadline = false;
489
+ /**
490
+ * A statement was still running on the backend when the run was torn down,
491
+ * so the session may have state nobody can see. It is destroyed rather than
492
+ * recycled, and the explicit unlock is skipped because it would be queued
493
+ * behind the very statement that overran.
494
+ */
495
+ let statementAbandonedInFlight = false;
496
+ let appliedStatementTimeout = null;
497
+ /**
498
+ * Topology that must not appear in anything this run puts on the wire.
499
+ * Every error PostgreSQL raises quotes the row, the literal or the value it
500
+ * choked on (`invalid input syntax for type integer: "alice@corp.com"`), and
501
+ * a connection failure names the host, port, user and database.
502
+ */
503
+ const topology = {
504
+ host: ctx.dbEntry.host,
505
+ port: ctx.dbEntry.port,
506
+ user: ctx.dbEntry.user,
507
+ database: ctx.dbEntry.database,
508
+ project: ctx.project,
509
+ };
510
+ /**
511
+ * Progress event for one statement.
512
+ *
513
+ * The preview is redacted and the error text is scrubbed, because both leave
514
+ * the process: a `migration_progress` event is a WebSocket frame bound for the
515
+ * cloud and the browser. The verbatim message is still recorded on
516
+ * {@link StatementResult.error} for the local audit log.
517
+ */
518
+ const emitProgress = (index, stmt, status, extra) => {
519
+ if (!ctx.onProgress)
520
+ return;
521
+ void ctx.onProgress({
522
+ v: 1,
523
+ id: crypto.randomUUID(),
524
+ type: 'event',
525
+ project: ctx.project,
526
+ user: ctx.user,
527
+ db_alias: ctx.db_alias,
528
+ ts: Date.now(),
529
+ payload: {
530
+ kind: 'migration_progress',
531
+ data: {
532
+ plan_id: payload.plan_id,
533
+ statement_index: index,
534
+ statement_sql_preview: (0, redact_1.previewStatement)(stmt),
535
+ status,
536
+ ...(extra?.ms !== undefined ? { ms: extra.ms } : {}),
537
+ ...(extra?.error !== undefined
538
+ ? { error: (0, sanitize_1.sanitizeErrorText)(extra.error, { topology }) }
539
+ : {}),
540
+ },
541
+ },
542
+ });
543
+ };
544
+ /**
545
+ * Apply the timeouts for the next statement. Inside `single_tx` this is
546
+ * `SET LOCAL`, which PostgreSQL reverts at COMMIT/ROLLBACK; in
547
+ * `per_statement` each statement is its own implicit transaction, so the
548
+ * session form is the only one that takes effect — `SET LOCAL` outside a
549
+ * transaction block is a silent no-op (H-07), which is how migrations used
550
+ * to run with no timeout at all.
551
+ *
552
+ * The value is exactly the clamped budget, NOT the wall clock still left in
553
+ * the run. Capping it by the remaining budget made the number PostgreSQL was
554
+ * asked to enforce drift down by however long the run had already spent
555
+ * taking its lock, so a caller that asked for 60000 got 59999 and every
556
+ * statement of a long run got a different timeout than the one that was
557
+ * requested and audited. The overall deadline is enforced by the runner
558
+ * itself (`interrupted` above), which is what bounds the run — not by
559
+ * shaving the server-side timeout.
560
+ *
561
+ * Both values are re-validated by {@link safeTimeoutMs} and the `LOCAL`
562
+ * prefix is one of two literals, so this text cannot carry SQL. It still
563
+ * goes over the extended protocol like every other statement, so no code
564
+ * path in this file can silently acquire the simple protocol.
565
+ */
566
+ const applyBudget = async () => {
567
+ const statementTimeoutMs = safeTimeoutMs(budget.statementTimeoutMs, exports.MAX_MIGRATION_STATEMENT_TIMEOUT_MS);
568
+ const lockTimeoutMs = safeTimeoutMs(budget.lockTimeoutMs, exports.MIGRATION_LOCK_TIMEOUT_MS);
569
+ const local = transactionOpen ? 'LOCAL ' : '';
570
+ if (appliedStatementTimeout !== statementTimeoutMs) {
571
+ await (0, types_1.runExtended)(client, `SET ${local}statement_timeout = ${statementTimeoutMs}`);
572
+ await (0, types_1.runExtended)(client, `SET ${local}lock_timeout = ${lockTimeoutMs}`);
573
+ appliedStatementTimeout = statementTimeoutMs;
574
+ }
575
+ };
576
+ const markRolledBack = (upToIndex) => {
577
+ for (let j = 0; j < upToIndex; j++) {
578
+ rolledBackIndices.push(j);
579
+ }
580
+ };
581
+ const endTransaction = async () => {
582
+ if (!transactionOpen)
583
+ return;
584
+ try {
585
+ await (0, types_1.runExtended)(client, 'ROLLBACK');
586
+ }
587
+ catch {
588
+ // The transaction state is unknown. `markSessionDirty` above means this
589
+ // connection is destroyed rather than recycled, which is the only way
590
+ // the next request is guaranteed not to inherit it.
591
+ }
592
+ transactionOpen = false;
593
+ };
594
+ const abandonRun = async (index, timedOut) => {
595
+ if (timedOut)
596
+ abandonedForDeadline = true;
597
+ if (strategy === 'single_tx') {
598
+ migrationStatus = 'rolled_back';
599
+ await endTransaction();
600
+ markRolledBack(index);
601
+ }
602
+ else {
603
+ migrationStatus = 'partial';
604
+ }
605
+ };
606
+ try {
607
+ if (strategy === 'single_tx') {
608
+ await (0, types_1.runExtended)(client, 'BEGIN');
609
+ transactionOpen = true;
610
+ // Transaction-scoped lock: PostgreSQL releases it at COMMIT/ROLLBACK,
611
+ // including when the connection dies mid-migration, so it cannot leak
612
+ // onto a pooled session.
613
+ const lockRes = await (0, types_1.runExtended)(client, 'SELECT pg_try_advisory_xact_lock($1, $2) AS locked', [key1, key2]);
614
+ if (!lockTaken(lockRes)) {
615
+ await endTransaction();
616
+ throw new MigrationInProgressError('Database migration is currently in progress for this project.');
617
+ }
618
+ }
619
+ else {
620
+ // No wrapping transaction in per_statement mode, so the lock is
621
+ // session-scoped and the `finally` below is the only thing that
622
+ // releases it. That is why the client is destroyed, never recycled.
623
+ const lockRes = await (0, types_1.runExtended)(client, 'SELECT pg_try_advisory_lock($1, $2) AS locked', [
624
+ key1,
625
+ key2,
626
+ ]);
627
+ if (!lockTaken(lockRes)) {
628
+ throw new MigrationInProgressError('Database migration is currently in progress for this project.');
629
+ }
630
+ sessionLockHeld = true;
631
+ }
632
+ // Step 6: Execute loop
633
+ for (let i = 0; i < payload.statements.length; i++) {
634
+ const stmt = payload.statements[i];
635
+ // Cooperative checkpoint. A cancellation or an expired deadline stops the
636
+ // run here, before the next statement is ever sent.
637
+ if (interruption !== null) {
638
+ await abandonRun(i, interruption === 'deadline');
639
+ break;
640
+ }
641
+ if (deadlineAt - Date.now() <= 0) {
642
+ interrupt('deadline');
643
+ await abandonRun(i, true);
644
+ break;
645
+ }
646
+ await applyBudget();
647
+ const stmtStart = Date.now();
648
+ emitProgress(i, stmt, 'running');
649
+ try {
650
+ // Extended query protocol: node-postgres only takes the simple
651
+ // protocol (which executes every semicolon-separated command in one
652
+ // round trip) when `values` is falsy, so this pins the statement
653
+ // count to the one the plan declared. PostgreSQL answers a second
654
+ // command in the same Parse with `42601`.
655
+ //
656
+ // Raced against `interrupted`, so a run that is cancelled or runs out
657
+ // of deadline stops waiting on a statement the backend may still be
658
+ // executing. The abandoned query is left to the server-side
659
+ // `statement_timeout` above and to the cancellation the canceller
660
+ // issues with `pg_cancel_backend`, both of which surface as `57014`.
661
+ const runRes = await Promise.race([(0, types_1.runExtended)(client, stmt), interrupted]);
662
+ const duration = Date.now() - stmtStart;
663
+ statementResults.push({
664
+ index: i,
665
+ status: 'success',
666
+ ms: duration,
667
+ rows_affected: runRes.rowCount || 0,
668
+ });
669
+ emitProgress(i, stmt, 'success', { ms: duration });
670
+ }
671
+ catch (err) {
672
+ const duration = Date.now() - stmtStart;
673
+ const wasInterrupted = err instanceof RunInterrupted;
674
+ const message = wasInterrupted
675
+ ? err.reason === 'deadline'
676
+ ? `Migration exceeded its overall deadline of ${budget.deadlineMs}ms ` +
677
+ `while statement ${i + 1} was still running; the run was abandoned.`
678
+ : `Migration was cancelled by the caller while statement ${i + 1} was still running.`
679
+ : err instanceof Error
680
+ ? err.message
681
+ : String(err);
682
+ statementResults.push({
683
+ index: i,
684
+ status: 'failed',
685
+ ms: duration,
686
+ rows_affected: 0,
687
+ error: message,
688
+ // A statement torn down locally has the same SQLSTATE PostgreSQL
689
+ // would have produced: `57014`, query_canceled.
690
+ pg_error_code: wasInterrupted
691
+ ? PG_QUERY_CANCELED
692
+ : err && typeof err === 'object' && 'code' in err
693
+ ? String(err.code)
694
+ : undefined,
695
+ });
696
+ emitProgress(i, stmt, 'failed', { ms: duration, error: message });
697
+ if (wasInterrupted) {
698
+ // The backend may still be running that statement, so nothing about
699
+ // this session can be proven: the next request must not inherit it.
700
+ // `markSessionDirty` destroys the connection, and terminating the
701
+ // backend is what actually stops the statement and releases the
702
+ // advisory lock.
703
+ statementAbandonedInFlight = true;
704
+ }
705
+ await abandonRun(i, wasInterrupted && err.reason === 'deadline');
706
+ break;
707
+ }
708
+ }
709
+ if (transactionOpen) {
710
+ // An interrupted run is never committed. In `single_tx` that is the whole
711
+ // difference between a migration that applied and one that did not, so
712
+ // the COMMIT is gated on the run still being healthy — not only on the
713
+ // statements having all succeeded.
714
+ if (interruption === null && outcome() === 'committed') {
715
+ await (0, types_1.runExtended)(client, 'COMMIT');
716
+ transactionOpen = false;
717
+ }
718
+ else {
719
+ if (interruption !== null && strategy === 'single_tx') {
720
+ // The deadline or a cancellation landed after the last statement
721
+ // succeeded. Rolling back is the only outcome that matches what the
722
+ // database did, so the status must not stay `committed`.
723
+ migrationStatus = 'rolled_back';
724
+ }
725
+ await endTransaction();
726
+ markRolledBack(payload.statements.length);
727
+ }
728
+ }
729
+ const result = {
730
+ plan_id: payload.plan_id,
731
+ status: outcome(),
732
+ statements: statementResults,
733
+ total_ms: Date.now() - startTime,
734
+ rolled_back_indices: rolledBackIndices,
735
+ };
736
+ if (outcome() === 'partial') {
737
+ // Name the cause, because "partial" alone does not tell a caller whether
738
+ // it should retry the plan or ask for a bigger budget — and do not claim
739
+ // work is committed when the run was abandoned before any of it landed.
740
+ const appliedCount = result.statements.filter((s) => s.status === 'success').length;
741
+ const cause = interruption === 'deadline'
742
+ ? `Migration exceeded its overall deadline of ${budget.deadlineMs}ms and was abandoned`
743
+ : interruption === 'aborted'
744
+ ? 'Migration was cancelled by the caller and was abandoned'
745
+ : 'Migration stopped partway';
746
+ const consequence = appliedCount === 0
747
+ ? 'Nothing was committed, but the run did not complete.'
748
+ : `${appliedCount} earlier statement(s) are already committed and were not rolled ` +
749
+ 'back. Verify the applied schema before retrying.';
750
+ throw new MigrationPartiallyAppliedError(`${cause}: ${consequence}`, result);
751
+ }
752
+ if (abandonedForDeadline) {
753
+ throw new MigrationTimeoutError(`Migration exceeded its overall deadline of ${budget.deadlineMs}ms and was abandoned. ` +
754
+ 'Every statement was rolled back.');
755
+ }
756
+ return result;
757
+ }
758
+ catch (err) {
759
+ await endTransaction();
760
+ throw err;
761
+ }
762
+ finally {
763
+ clearTimeout(deadlineTimer);
764
+ // Release the advisory lock on every exit path. Without this a single
765
+ // failed migration left the lock held on a pooled connection, blocking
766
+ // every later migration for this project until the pool recycled it.
767
+ // `markSessionDirty` above already guarantees the connection is destroyed
768
+ // either way, so a failed unlock needs no separate handling here.
769
+ if (sessionLockHeld) {
770
+ // A statement abandoned in flight may still be executing on the backend,
771
+ // and node-postgres queues everything behind an in-flight query — this
772
+ // unlock included — so sending it would wait out the statement the
773
+ // deadline just gave up on. It is not needed either way: PostgreSQL
774
+ // releases a session-scoped advisory lock when the backend goes away,
775
+ // and the connection is destroyed on this path.
776
+ if (!statementAbandonedInFlight) {
777
+ try {
778
+ await (0, types_1.runExtended)(client, 'SELECT pg_advisory_unlock($1, $2)', [key1, key2]);
779
+ }
780
+ catch {
781
+ // The lock may survive on a backend that is about to be destroyed.
782
+ }
783
+ }
784
+ sessionLockHeld = false;
785
+ }
786
+ if (ctx.abortSignal) {
787
+ ctx.abortSignal.removeEventListener('abort', onAbort);
788
+ }
789
+ abortController.signal.removeEventListener('abort', onAbort);
790
+ if (ctx.unregisterInFlight) {
791
+ ctx.unregisterInFlight(ctx.request_id);
792
+ }
793
+ release();
794
+ }
795
+ }
796
+ }
797
+ exports.MigrationRunner = MigrationRunner;
798
+ //# sourceMappingURL=migration-runner.js.map