@smthrs/control 0.0.0-stage → 1.0.0-rc.4

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 (418) hide show
  1. package/CHANGELOG.md +194 -0
  2. package/LICENSE +21 -0
  3. package/README.md +168 -2
  4. package/dist/cjs/ApprovalAuthority.d.ts +73 -0
  5. package/dist/cjs/ApprovalAuthority.d.ts.map +1 -0
  6. package/dist/cjs/ApprovalAuthority.js +62 -0
  7. package/dist/cjs/ApprovalAuthority.js.map +7 -0
  8. package/dist/cjs/Cancellation.d.ts +107 -0
  9. package/dist/cjs/Cancellation.d.ts.map +1 -0
  10. package/dist/cjs/Cancellation.js +72 -0
  11. package/dist/cjs/Cancellation.js.map +7 -0
  12. package/dist/cjs/Channels.d.ts +170 -0
  13. package/dist/cjs/Channels.d.ts.map +1 -0
  14. package/dist/cjs/Channels.js +278 -0
  15. package/dist/cjs/Channels.js.map +7 -0
  16. package/dist/cjs/Control.d.ts +202 -0
  17. package/dist/cjs/Control.d.ts.map +1 -0
  18. package/dist/cjs/Control.js +47 -0
  19. package/dist/cjs/Control.js.map +7 -0
  20. package/dist/cjs/ControlClient.d.ts +52 -0
  21. package/dist/cjs/ControlClient.d.ts.map +1 -0
  22. package/dist/cjs/ControlClient.js +191 -0
  23. package/dist/cjs/ControlClient.js.map +7 -0
  24. package/dist/cjs/ControlError.d.ts +318 -0
  25. package/dist/cjs/ControlError.d.ts.map +1 -0
  26. package/dist/cjs/ControlError.js +249 -0
  27. package/dist/cjs/ControlError.js.map +7 -0
  28. package/dist/cjs/ControlExecutor.d.ts +372 -0
  29. package/dist/cjs/ControlExecutor.d.ts.map +1 -0
  30. package/dist/cjs/ControlExecutor.js +123 -0
  31. package/dist/cjs/ControlExecutor.js.map +7 -0
  32. package/dist/cjs/ControlFacts.d.ts +454 -0
  33. package/dist/cjs/ControlFacts.d.ts.map +1 -0
  34. package/dist/cjs/ControlFacts.js +261 -0
  35. package/dist/cjs/ControlFacts.js.map +7 -0
  36. package/dist/cjs/ControlLive.d.ts +23 -0
  37. package/dist/cjs/ControlLive.d.ts.map +1 -0
  38. package/dist/cjs/ControlLive.js +1293 -0
  39. package/dist/cjs/ControlLive.js.map +7 -0
  40. package/dist/cjs/ControlRpcs.d.ts +1204 -0
  41. package/dist/cjs/ControlRpcs.d.ts.map +1 -0
  42. package/dist/cjs/ControlRpcs.js +247 -0
  43. package/dist/cjs/ControlRpcs.js.map +7 -0
  44. package/dist/cjs/ControlRuntime.d.ts +635 -0
  45. package/dist/cjs/ControlRuntime.d.ts.map +1 -0
  46. package/dist/cjs/ControlRuntime.js +744 -0
  47. package/dist/cjs/ControlRuntime.js.map +7 -0
  48. package/dist/cjs/ControlSchema.d.ts +2642 -0
  49. package/dist/cjs/ControlSchema.d.ts.map +1 -0
  50. package/dist/cjs/ControlSchema.js +634 -0
  51. package/dist/cjs/ControlSchema.js.map +7 -0
  52. package/dist/cjs/ControlServer.d.ts +51 -0
  53. package/dist/cjs/ControlServer.d.ts.map +1 -0
  54. package/dist/cjs/ControlServer.js +121 -0
  55. package/dist/cjs/ControlServer.js.map +7 -0
  56. package/dist/cjs/Credential.d.ts +136 -0
  57. package/dist/cjs/Credential.d.ts.map +1 -0
  58. package/dist/cjs/Credential.js +168 -0
  59. package/dist/cjs/Credential.js.map +7 -0
  60. package/dist/cjs/CredentialCipher.d.ts +90 -0
  61. package/dist/cjs/CredentialCipher.d.ts.map +1 -0
  62. package/dist/cjs/CredentialCipher.js +45 -0
  63. package/dist/cjs/CredentialCipher.js.map +7 -0
  64. package/dist/cjs/CredentialStore.d.ts +97 -0
  65. package/dist/cjs/CredentialStore.d.ts.map +1 -0
  66. package/dist/cjs/CredentialStore.js +81 -0
  67. package/dist/cjs/CredentialStore.js.map +7 -0
  68. package/dist/cjs/DispatchReader.d.ts +112 -0
  69. package/dist/cjs/DispatchReader.d.ts.map +1 -0
  70. package/dist/cjs/DispatchReader.js +45 -0
  71. package/dist/cjs/DispatchReader.js.map +7 -0
  72. package/dist/cjs/Health.d.ts +333 -0
  73. package/dist/cjs/Health.d.ts.map +1 -0
  74. package/dist/cjs/Health.js +311 -0
  75. package/dist/cjs/Health.js.map +7 -0
  76. package/dist/cjs/JevSessionChecker.d.ts +57 -0
  77. package/dist/cjs/JevSessionChecker.d.ts.map +1 -0
  78. package/dist/cjs/JevSessionChecker.js +113 -0
  79. package/dist/cjs/JevSessionChecker.js.map +7 -0
  80. package/dist/cjs/Lineage.d.ts +131 -0
  81. package/dist/cjs/Lineage.d.ts.map +1 -0
  82. package/dist/cjs/Lineage.js +81 -0
  83. package/dist/cjs/Lineage.js.map +7 -0
  84. package/dist/cjs/Migrations.d.ts +34 -0
  85. package/dist/cjs/Migrations.d.ts.map +1 -0
  86. package/dist/cjs/Migrations.js +60 -0
  87. package/dist/cjs/Migrations.js.map +7 -0
  88. package/dist/cjs/Monitor.d.ts +282 -0
  89. package/dist/cjs/Monitor.d.ts.map +1 -0
  90. package/dist/cjs/Monitor.js +283 -0
  91. package/dist/cjs/Monitor.js.map +7 -0
  92. package/dist/cjs/ScopedToken.d.ts +193 -0
  93. package/dist/cjs/ScopedToken.d.ts.map +1 -0
  94. package/dist/cjs/ScopedToken.js +135 -0
  95. package/dist/cjs/ScopedToken.js.map +7 -0
  96. package/dist/cjs/SqlControlRuntime.d.ts +161 -0
  97. package/dist/cjs/SqlControlRuntime.d.ts.map +1 -0
  98. package/dist/cjs/SqlControlRuntime.js +1522 -0
  99. package/dist/cjs/SqlControlRuntime.js.map +7 -0
  100. package/dist/cjs/SqlCredentialStore.d.ts +43 -0
  101. package/dist/cjs/SqlCredentialStore.d.ts.map +1 -0
  102. package/dist/cjs/SqlCredentialStore.js +113 -0
  103. package/dist/cjs/SqlCredentialStore.js.map +7 -0
  104. package/dist/cjs/Steering.d.ts +69 -0
  105. package/dist/cjs/Steering.d.ts.map +1 -0
  106. package/dist/cjs/Steering.js +49 -0
  107. package/dist/cjs/Steering.js.map +7 -0
  108. package/dist/cjs/SystemFlows.d.ts +223 -0
  109. package/dist/cjs/SystemFlows.d.ts.map +1 -0
  110. package/dist/cjs/SystemFlows.js +195 -0
  111. package/dist/cjs/SystemFlows.js.map +7 -0
  112. package/dist/cjs/WebCryptoCipher.d.ts +49 -0
  113. package/dist/cjs/WebCryptoCipher.d.ts.map +1 -0
  114. package/dist/cjs/WebCryptoCipher.js +129 -0
  115. package/dist/cjs/WebCryptoCipher.js.map +7 -0
  116. package/dist/cjs/WebhookChannel.d.ts +113 -0
  117. package/dist/cjs/WebhookChannel.d.ts.map +1 -0
  118. package/dist/cjs/WebhookChannel.js +98 -0
  119. package/dist/cjs/WebhookChannel.js.map +7 -0
  120. package/dist/cjs/index.d.ts +160 -0
  121. package/dist/cjs/index.d.ts.map +1 -0
  122. package/dist/cjs/index.js +91 -0
  123. package/dist/cjs/index.js.map +7 -0
  124. package/dist/cjs/internal/MutationBoundary.d.ts +27 -0
  125. package/dist/cjs/internal/MutationBoundary.d.ts.map +1 -0
  126. package/dist/cjs/internal/MutationBoundary.js +50 -0
  127. package/dist/cjs/internal/MutationBoundary.js.map +7 -0
  128. package/dist/cjs/internal/activeFibers.d.ts +12 -0
  129. package/dist/cjs/internal/activeFibers.d.ts.map +1 -0
  130. package/dist/cjs/internal/activeFibers.js +30 -0
  131. package/dist/cjs/internal/activeFibers.js.map +7 -0
  132. package/dist/cjs/internal/issues.d.ts +28 -0
  133. package/dist/cjs/internal/issues.d.ts.map +1 -0
  134. package/dist/cjs/internal/issues.js +34 -0
  135. package/dist/cjs/internal/issues.js.map +7 -0
  136. package/dist/cjs/internal/planning.d.ts +347 -0
  137. package/dist/cjs/internal/planning.d.ts.map +1 -0
  138. package/dist/cjs/internal/planning.js +137 -0
  139. package/dist/cjs/internal/planning.js.map +7 -0
  140. package/dist/cjs/internal/sqlSchemaErrors.d.ts +18 -0
  141. package/dist/cjs/internal/sqlSchemaErrors.d.ts.map +1 -0
  142. package/dist/cjs/internal/sqlSchemaErrors.js +40 -0
  143. package/dist/cjs/internal/sqlSchemaErrors.js.map +7 -0
  144. package/dist/cjs/migrations/0001_control_tables.d.ts +18 -0
  145. package/dist/cjs/migrations/0001_control_tables.d.ts.map +1 -0
  146. package/dist/cjs/migrations/0001_control_tables.js +115 -0
  147. package/dist/cjs/migrations/0001_control_tables.js.map +7 -0
  148. package/dist/cjs/migrations/0002_run_keys.d.ts +15 -0
  149. package/dist/cjs/migrations/0002_run_keys.d.ts.map +1 -0
  150. package/dist/cjs/migrations/0002_run_keys.js +44 -0
  151. package/dist/cjs/migrations/0002_run_keys.js.map +7 -0
  152. package/dist/cjs/migrations/0003_signal_commands.d.ts +13 -0
  153. package/dist/cjs/migrations/0003_signal_commands.d.ts.map +1 -0
  154. package/dist/cjs/migrations/0003_signal_commands.js +50 -0
  155. package/dist/cjs/migrations/0003_signal_commands.js.map +7 -0
  156. package/dist/cjs/migrations/0004_approval_decisions.d.ts +13 -0
  157. package/dist/cjs/migrations/0004_approval_decisions.d.ts.map +1 -0
  158. package/dist/cjs/migrations/0004_approval_decisions.js +45 -0
  159. package/dist/cjs/migrations/0004_approval_decisions.js.map +7 -0
  160. package/dist/cjs/migrations/0005_signal_principals.d.ts +18 -0
  161. package/dist/cjs/migrations/0005_signal_principals.d.ts.map +1 -0
  162. package/dist/cjs/migrations/0005_signal_principals.js +45 -0
  163. package/dist/cjs/migrations/0005_signal_principals.js.map +7 -0
  164. package/dist/cjs/migrations/0006_run_principals.d.ts +18 -0
  165. package/dist/cjs/migrations/0006_run_principals.d.ts.map +1 -0
  166. package/dist/cjs/migrations/0006_run_principals.js +49 -0
  167. package/dist/cjs/migrations/0006_run_principals.js.map +7 -0
  168. package/dist/cjs/migrations/0007_resume_consent.d.ts +18 -0
  169. package/dist/cjs/migrations/0007_resume_consent.d.ts.map +1 -0
  170. package/dist/cjs/migrations/0007_resume_consent.js +46 -0
  171. package/dist/cjs/migrations/0007_resume_consent.js.map +7 -0
  172. package/dist/cjs/package.json +1 -0
  173. package/dist/cjs/test/TestControl.d.ts +19 -0
  174. package/dist/cjs/test/TestControl.d.ts.map +1 -0
  175. package/dist/cjs/test/TestControl.js +62 -0
  176. package/dist/cjs/test/TestControl.js.map +7 -0
  177. package/dist/esm/ApprovalAuthority.d.ts +73 -0
  178. package/dist/esm/ApprovalAuthority.d.ts.map +1 -0
  179. package/dist/esm/ApprovalAuthority.js +72 -0
  180. package/dist/esm/ApprovalAuthority.js.map +1 -0
  181. package/dist/esm/Cancellation.d.ts +107 -0
  182. package/dist/esm/Cancellation.d.ts.map +1 -0
  183. package/dist/esm/Cancellation.js +116 -0
  184. package/dist/esm/Cancellation.js.map +1 -0
  185. package/dist/esm/Channels.d.ts +170 -0
  186. package/dist/esm/Channels.d.ts.map +1 -0
  187. package/dist/esm/Channels.js +312 -0
  188. package/dist/esm/Channels.js.map +1 -0
  189. package/dist/esm/Control.d.ts +202 -0
  190. package/dist/esm/Control.d.ts.map +1 -0
  191. package/dist/esm/Control.js +42 -0
  192. package/dist/esm/Control.js.map +1 -0
  193. package/dist/esm/ControlClient.d.ts +52 -0
  194. package/dist/esm/ControlClient.d.ts.map +1 -0
  195. package/dist/esm/ControlClient.js +217 -0
  196. package/dist/esm/ControlClient.js.map +1 -0
  197. package/dist/esm/ControlError.d.ts +318 -0
  198. package/dist/esm/ControlError.d.ts.map +1 -0
  199. package/dist/esm/ControlError.js +359 -0
  200. package/dist/esm/ControlError.js.map +1 -0
  201. package/dist/esm/ControlExecutor.d.ts +372 -0
  202. package/dist/esm/ControlExecutor.d.ts.map +1 -0
  203. package/dist/esm/ControlExecutor.js +212 -0
  204. package/dist/esm/ControlExecutor.js.map +1 -0
  205. package/dist/esm/ControlFacts.d.ts +454 -0
  206. package/dist/esm/ControlFacts.d.ts.map +1 -0
  207. package/dist/esm/ControlFacts.js +324 -0
  208. package/dist/esm/ControlFacts.js.map +1 -0
  209. package/dist/esm/ControlLive.d.ts +23 -0
  210. package/dist/esm/ControlLive.d.ts.map +1 -0
  211. package/dist/esm/ControlLive.js +1589 -0
  212. package/dist/esm/ControlLive.js.map +1 -0
  213. package/dist/esm/ControlRpcs.d.ts +1204 -0
  214. package/dist/esm/ControlRpcs.d.ts.map +1 -0
  215. package/dist/esm/ControlRpcs.js +299 -0
  216. package/dist/esm/ControlRpcs.js.map +1 -0
  217. package/dist/esm/ControlRuntime.d.ts +635 -0
  218. package/dist/esm/ControlRuntime.d.ts.map +1 -0
  219. package/dist/esm/ControlRuntime.js +808 -0
  220. package/dist/esm/ControlRuntime.js.map +1 -0
  221. package/dist/esm/ControlSchema.d.ts +2642 -0
  222. package/dist/esm/ControlSchema.d.ts.map +1 -0
  223. package/dist/esm/ControlSchema.js +1030 -0
  224. package/dist/esm/ControlSchema.js.map +1 -0
  225. package/dist/esm/ControlServer.d.ts +51 -0
  226. package/dist/esm/ControlServer.d.ts.map +1 -0
  227. package/dist/esm/ControlServer.js +145 -0
  228. package/dist/esm/ControlServer.js.map +1 -0
  229. package/dist/esm/Credential.d.ts +136 -0
  230. package/dist/esm/Credential.d.ts.map +1 -0
  231. package/dist/esm/Credential.js +190 -0
  232. package/dist/esm/Credential.js.map +1 -0
  233. package/dist/esm/CredentialCipher.d.ts +90 -0
  234. package/dist/esm/CredentialCipher.d.ts.map +1 -0
  235. package/dist/esm/CredentialCipher.js +56 -0
  236. package/dist/esm/CredentialCipher.js.map +1 -0
  237. package/dist/esm/CredentialStore.d.ts +97 -0
  238. package/dist/esm/CredentialStore.d.ts.map +1 -0
  239. package/dist/esm/CredentialStore.js +101 -0
  240. package/dist/esm/CredentialStore.js.map +1 -0
  241. package/dist/esm/DispatchReader.d.ts +112 -0
  242. package/dist/esm/DispatchReader.d.ts.map +1 -0
  243. package/dist/esm/DispatchReader.js +76 -0
  244. package/dist/esm/DispatchReader.js.map +1 -0
  245. package/dist/esm/Health.d.ts +333 -0
  246. package/dist/esm/Health.d.ts.map +1 -0
  247. package/dist/esm/Health.js +400 -0
  248. package/dist/esm/Health.js.map +1 -0
  249. package/dist/esm/JevSessionChecker.d.ts +57 -0
  250. package/dist/esm/JevSessionChecker.d.ts.map +1 -0
  251. package/dist/esm/JevSessionChecker.js +108 -0
  252. package/dist/esm/JevSessionChecker.js.map +1 -0
  253. package/dist/esm/Lineage.d.ts +131 -0
  254. package/dist/esm/Lineage.d.ts.map +1 -0
  255. package/dist/esm/Lineage.js +174 -0
  256. package/dist/esm/Lineage.js.map +1 -0
  257. package/dist/esm/Migrations.d.ts +34 -0
  258. package/dist/esm/Migrations.d.ts.map +1 -0
  259. package/dist/esm/Migrations.js +53 -0
  260. package/dist/esm/Migrations.js.map +1 -0
  261. package/dist/esm/Monitor.d.ts +282 -0
  262. package/dist/esm/Monitor.d.ts.map +1 -0
  263. package/dist/esm/Monitor.js +415 -0
  264. package/dist/esm/Monitor.js.map +1 -0
  265. package/dist/esm/ScopedToken.d.ts +193 -0
  266. package/dist/esm/ScopedToken.d.ts.map +1 -0
  267. package/dist/esm/ScopedToken.js +224 -0
  268. package/dist/esm/ScopedToken.js.map +1 -0
  269. package/dist/esm/SqlControlRuntime.d.ts +161 -0
  270. package/dist/esm/SqlControlRuntime.d.ts.map +1 -0
  271. package/dist/esm/SqlControlRuntime.js +1756 -0
  272. package/dist/esm/SqlControlRuntime.js.map +1 -0
  273. package/dist/esm/SqlCredentialStore.d.ts +43 -0
  274. package/dist/esm/SqlCredentialStore.d.ts.map +1 -0
  275. package/dist/esm/SqlCredentialStore.js +97 -0
  276. package/dist/esm/SqlCredentialStore.js.map +1 -0
  277. package/dist/esm/Steering.d.ts +69 -0
  278. package/dist/esm/Steering.d.ts.map +1 -0
  279. package/dist/esm/Steering.js +89 -0
  280. package/dist/esm/Steering.js.map +1 -0
  281. package/dist/esm/SystemFlows.d.ts +223 -0
  282. package/dist/esm/SystemFlows.d.ts.map +1 -0
  283. package/dist/esm/SystemFlows.js +198 -0
  284. package/dist/esm/SystemFlows.js.map +1 -0
  285. package/dist/esm/WebCryptoCipher.d.ts +49 -0
  286. package/dist/esm/WebCryptoCipher.d.ts.map +1 -0
  287. package/dist/esm/WebCryptoCipher.js +123 -0
  288. package/dist/esm/WebCryptoCipher.js.map +1 -0
  289. package/dist/esm/WebhookChannel.d.ts +113 -0
  290. package/dist/esm/WebhookChannel.d.ts.map +1 -0
  291. package/dist/esm/WebhookChannel.js +109 -0
  292. package/dist/esm/WebhookChannel.js.map +1 -0
  293. package/dist/esm/index.d.ts +160 -0
  294. package/dist/esm/index.d.ts.map +1 -0
  295. package/dist/esm/index.js +160 -0
  296. package/dist/esm/index.js.map +1 -0
  297. package/dist/esm/internal/MutationBoundary.d.ts +27 -0
  298. package/dist/esm/internal/MutationBoundary.d.ts.map +1 -0
  299. package/dist/esm/internal/MutationBoundary.js +40 -0
  300. package/dist/esm/internal/MutationBoundary.js.map +1 -0
  301. package/dist/esm/internal/activeFibers.d.ts +12 -0
  302. package/dist/esm/internal/activeFibers.d.ts.map +1 -0
  303. package/dist/esm/internal/activeFibers.js +17 -0
  304. package/dist/esm/internal/activeFibers.js.map +1 -0
  305. package/dist/esm/internal/issues.d.ts +28 -0
  306. package/dist/esm/internal/issues.d.ts.map +1 -0
  307. package/dist/esm/internal/issues.js +35 -0
  308. package/dist/esm/internal/issues.js.map +1 -0
  309. package/dist/esm/internal/planning.d.ts +347 -0
  310. package/dist/esm/internal/planning.d.ts.map +1 -0
  311. package/dist/esm/internal/planning.js +199 -0
  312. package/dist/esm/internal/planning.js.map +1 -0
  313. package/dist/esm/internal/sqlSchemaErrors.d.ts +18 -0
  314. package/dist/esm/internal/sqlSchemaErrors.d.ts.map +1 -0
  315. package/dist/esm/internal/sqlSchemaErrors.js +38 -0
  316. package/dist/esm/internal/sqlSchemaErrors.js.map +1 -0
  317. package/dist/esm/migrations/0001_control_tables.d.ts +18 -0
  318. package/dist/esm/migrations/0001_control_tables.d.ts.map +1 -0
  319. package/dist/esm/migrations/0001_control_tables.js +96 -0
  320. package/dist/esm/migrations/0001_control_tables.js.map +1 -0
  321. package/dist/esm/migrations/0002_run_keys.d.ts +15 -0
  322. package/dist/esm/migrations/0002_run_keys.d.ts.map +1 -0
  323. package/dist/esm/migrations/0002_run_keys.js +22 -0
  324. package/dist/esm/migrations/0002_run_keys.js.map +1 -0
  325. package/dist/esm/migrations/0003_signal_commands.d.ts +13 -0
  326. package/dist/esm/migrations/0003_signal_commands.d.ts.map +1 -0
  327. package/dist/esm/migrations/0003_signal_commands.js +26 -0
  328. package/dist/esm/migrations/0003_signal_commands.js.map +1 -0
  329. package/dist/esm/migrations/0004_approval_decisions.d.ts +13 -0
  330. package/dist/esm/migrations/0004_approval_decisions.d.ts.map +1 -0
  331. package/dist/esm/migrations/0004_approval_decisions.js +25 -0
  332. package/dist/esm/migrations/0004_approval_decisions.js.map +1 -0
  333. package/dist/esm/migrations/0005_signal_principals.d.ts +18 -0
  334. package/dist/esm/migrations/0005_signal_principals.d.ts.map +1 -0
  335. package/dist/esm/migrations/0005_signal_principals.js +27 -0
  336. package/dist/esm/migrations/0005_signal_principals.js.map +1 -0
  337. package/dist/esm/migrations/0006_run_principals.d.ts +18 -0
  338. package/dist/esm/migrations/0006_run_principals.d.ts.map +1 -0
  339. package/dist/esm/migrations/0006_run_principals.js +30 -0
  340. package/dist/esm/migrations/0006_run_principals.js.map +1 -0
  341. package/dist/esm/migrations/0007_resume_consent.d.ts +18 -0
  342. package/dist/esm/migrations/0007_resume_consent.d.ts.map +1 -0
  343. package/dist/esm/migrations/0007_resume_consent.js +27 -0
  344. package/dist/esm/migrations/0007_resume_consent.js.map +1 -0
  345. package/dist/esm/test/TestControl.d.ts +19 -0
  346. package/dist/esm/test/TestControl.d.ts.map +1 -0
  347. package/dist/esm/test/TestControl.js +30 -0
  348. package/dist/esm/test/TestControl.js.map +1 -0
  349. package/docs/README.md +189 -0
  350. package/docs/api.md +982 -0
  351. package/docs/concepts/authority.md +109 -0
  352. package/docs/concepts/cancellation.md +129 -0
  353. package/docs/concepts/lineage.md +132 -0
  354. package/docs/concepts/ownership.md +139 -0
  355. package/docs/concepts/projections.md +203 -0
  356. package/docs/concepts/receipts.md +128 -0
  357. package/docs/guides/approvals.md +284 -0
  358. package/docs/guides/cancel-and-resume.md +162 -0
  359. package/docs/guides/durable-storage.md +147 -0
  360. package/docs/guides/implement-an-executor.md +173 -0
  361. package/docs/guides/ingest-a-webhook.md +177 -0
  362. package/docs/guides/list-runs.md +160 -0
  363. package/docs/guides/monitor-runs.md +176 -0
  364. package/docs/guides/observe-health.md +147 -0
  365. package/docs/guides/postgres-tests.md +7 -0
  366. package/docs/guides/serve-over-rpc.md +220 -0
  367. package/docs/guides/signal-a-run.md +53 -0
  368. package/docs/guides/steer-a-run.md +138 -0
  369. package/docs/guides/store-credentials.md +164 -0
  370. package/docs/guides/testing.md +139 -0
  371. package/docs/guides/watch-a-run.md +154 -0
  372. package/docs/installation.md +106 -0
  373. package/docs/quickstart.md +163 -0
  374. package/docs/troubleshooting.md +208 -0
  375. package/package.json +405 -3
  376. package/src/ApprovalAuthority.ts +114 -0
  377. package/src/Cancellation.ts +172 -0
  378. package/src/Channels.ts +493 -0
  379. package/src/Control.ts +337 -0
  380. package/src/ControlClient.ts +319 -0
  381. package/src/ControlError.ts +378 -0
  382. package/src/ControlExecutor.ts +490 -0
  383. package/src/ControlFacts.ts +383 -0
  384. package/src/ControlLive.ts +2127 -0
  385. package/src/ControlRpcs.ts +443 -0
  386. package/src/ControlRuntime.ts +1601 -0
  387. package/src/ControlSchema.ts +1380 -0
  388. package/src/ControlServer.ts +182 -0
  389. package/src/Credential.ts +310 -0
  390. package/src/CredentialCipher.ts +110 -0
  391. package/src/CredentialStore.ts +152 -0
  392. package/src/DispatchReader.ts +122 -0
  393. package/src/Health.ts +591 -0
  394. package/src/JevSessionChecker.ts +127 -0
  395. package/src/Lineage.ts +203 -0
  396. package/src/Migrations.ts +56 -0
  397. package/src/Monitor.ts +600 -0
  398. package/src/ScopedToken.ts +306 -0
  399. package/src/SqlControlRuntime.ts +2478 -0
  400. package/src/SqlCredentialStore.ts +148 -0
  401. package/src/Steering.ts +96 -0
  402. package/src/SystemFlows.ts +225 -0
  403. package/src/WebCryptoCipher.ts +169 -0
  404. package/src/WebhookChannel.ts +166 -0
  405. package/src/index.ts +188 -0
  406. package/src/internal/MutationBoundary.ts +46 -0
  407. package/src/internal/activeFibers.ts +22 -0
  408. package/src/internal/issues.ts +40 -0
  409. package/src/internal/planning.ts +262 -0
  410. package/src/internal/sqlSchemaErrors.ts +37 -0
  411. package/src/migrations/0001_control_tables.ts +99 -0
  412. package/src/migrations/0002_run_keys.ts +23 -0
  413. package/src/migrations/0003_signal_commands.ts +27 -0
  414. package/src/migrations/0004_approval_decisions.ts +25 -0
  415. package/src/migrations/0005_signal_principals.ts +27 -0
  416. package/src/migrations/0006_run_principals.ts +31 -0
  417. package/src/migrations/0007_resume_consent.ts +28 -0
  418. package/src/test/TestControl.ts +47 -0
@@ -0,0 +1,1380 @@
1
+ /**
2
+ * Serializable control-plane values shared by local and RPC projections.
3
+ *
4
+ * @since 0.1.0
5
+ */
6
+
7
+ import { EngineEvent, ExecutionFact } from "@smthrs/journal"
8
+ import { Attribution } from "@smthrs/notifications/Notification"
9
+ import * as SteerPayload from "@smthrs/notifications/SteerPayload"
10
+ import * as PersistedPlan from "@smthrs/plan/Plan"
11
+ import { BudgetOnExceeded, DiscoveryWarning } from "@smthrs/registry/Descriptor"
12
+ import { Schema } from "effect"
13
+ import { Origin } from "./Lineage.ts"
14
+
15
+ /**
16
+ * A durable control-plane run identifier.
17
+ *
18
+ * @since 0.1.0
19
+ * @category models
20
+ */
21
+ export const RunId = Schema.String
22
+
23
+ /**
24
+ * A durable control-plane run identifier.
25
+ *
26
+ * @since 0.1.0
27
+ * @category models
28
+ */
29
+ export type RunId = typeof RunId.Type
30
+
31
+ /**
32
+ * A registry flow identifier.
33
+ *
34
+ * @since 0.1.0
35
+ * @category models
36
+ */
37
+ export const FlowId = Schema.String
38
+
39
+ /**
40
+ * A registry flow identifier.
41
+ *
42
+ * @since 0.1.0
43
+ * @category models
44
+ */
45
+ export type FlowId = typeof FlowId.Type
46
+
47
+ /**
48
+ * A caller-supplied key that makes a control mutation idempotent.
49
+ *
50
+ * @since 0.1.0
51
+ * @category models
52
+ */
53
+ export const IdempotencyKey = Schema.String
54
+
55
+ /**
56
+ * A caller-supplied key that makes a control mutation idempotent.
57
+ *
58
+ * @since 0.1.0
59
+ * @category models
60
+ */
61
+ export type IdempotencyKey = typeof IdempotencyKey.Type
62
+
63
+ /**
64
+ * A server-authenticated identity stamped at the control boundary.
65
+ *
66
+ * @since 0.1.0
67
+ * @category models
68
+ */
69
+ export const Principal = Schema.Struct({
70
+ id: Schema.String,
71
+ kind: Schema.String,
72
+ stampedAt: Schema.Number
73
+ })
74
+
75
+ /**
76
+ * A server-authenticated identity stamped at the control boundary.
77
+ *
78
+ * @since 0.1.0
79
+ * @category models
80
+ */
81
+ export type Principal = typeof Principal.Type
82
+
83
+ /**
84
+ * The capabilities, flows, budget, and placement approved for a plan.
85
+ *
86
+ * `budget` holds the run's approved ceilings: `tokens`, `milliseconds` of
87
+ * active time, and `usd` in dollars, and its `deadline`: milliseconds of
88
+ * wall-clock time counted from the run's first start, shared by every round
89
+ * of the run. An absent ceiling or deadline is none.
90
+ *
91
+ * @since 0.1.0
92
+ * @category models
93
+ */
94
+ export const Envelope = Schema.Struct({
95
+ capabilities: Schema.Array(Schema.String),
96
+ /** Unrestricted builtin/addon/package imports, outside the guarded capability ceiling. */
97
+ hostImports: Schema.optional(Schema.Array(Schema.String)),
98
+ flows: Schema.Array(Schema.String),
99
+ budget: Schema.Struct({
100
+ tokens: Schema.optional(Schema.Number),
101
+ milliseconds: Schema.optional(Schema.Number),
102
+ usd: Schema.optional(Schema.Number),
103
+ onExceeded: Schema.optional(BudgetOnExceeded),
104
+ deadline: Schema.optional(Schema.Int.check(Schema.isGreaterThan(0)))
105
+ }),
106
+ host: Schema.optional(Schema.String)
107
+ })
108
+
109
+ /**
110
+ * The capabilities, flows, budget, and placement approved for a plan.
111
+ *
112
+ * @since 0.1.0
113
+ * @category models
114
+ */
115
+ export type Envelope = typeof Envelope.Type
116
+
117
+ /**
118
+ * The durability selected for an approval grant.
119
+ *
120
+ * @since 0.1.0
121
+ * @category models
122
+ */
123
+ export const GrantScope = Schema.Literals(["once", "run", "remembered"])
124
+
125
+ /**
126
+ * The durability selected for an approval grant.
127
+ *
128
+ * @since 0.1.0
129
+ * @category models
130
+ */
131
+ export type GrantScope = typeof GrantScope.Type
132
+
133
+ /**
134
+ * A plan or in-run approval target. The digest and full envelope are submitted
135
+ * with the target so the server can verify exactly what the caller reviewed.
136
+ *
137
+ * @since 0.1.0
138
+ * @category models
139
+ */
140
+ export const ApprovalTarget = Schema.Union([
141
+ Schema.TaggedStruct("Plan", {
142
+ planId: Schema.String,
143
+ digest: Schema.String,
144
+ envelope: Envelope
145
+ }),
146
+ Schema.TaggedStruct("Node", {
147
+ runId: RunId,
148
+ requestId: Schema.String,
149
+ digest: Schema.String,
150
+ envelope: Envelope
151
+ })
152
+ ])
153
+
154
+ /**
155
+ * A plan or in-run approval target.
156
+ *
157
+ * @since 0.1.0
158
+ * @category models
159
+ */
160
+ export type ApprovalTarget = typeof ApprovalTarget.Type
161
+
162
+ /**
163
+ * The complete, reviewable payload emitted by planning and submitted unchanged
164
+ * when an approval decision is made.
165
+ *
166
+ * @since 0.1.0
167
+ * @category models
168
+ */
169
+ export const ApprovalPayload = Schema.Struct({
170
+ target: ApprovalTarget,
171
+ scope: GrantScope,
172
+ idempotencyKey: IdempotencyKey
173
+ })
174
+
175
+ /**
176
+ * The complete, reviewable payload emitted by planning.
177
+ *
178
+ * @since 0.1.0
179
+ * @category models
180
+ */
181
+ export type ApprovalPayload = typeof ApprovalPayload.Type
182
+
183
+ /**
184
+ * What `smithers plan` reports for one node before anything runs.
185
+ *
186
+ * The two outcomes fall out of step keys for free — a key either hits the
187
+ * step cache or it does not — which is why they are reported here rather than
188
+ * discovered during execution. The third outcome, `release`, belongs to
189
+ * orphan reconciliation and is deliberately not part of a plan card.
190
+ *
191
+ * @since 0.1.0
192
+ * @category models
193
+ */
194
+ export const PlanNodeStatus = Schema.Literals(["cached", "run"])
195
+
196
+ /**
197
+ * What `smithers plan` reports for one node before anything runs.
198
+ *
199
+ * @since 0.1.0
200
+ * @category models
201
+ */
202
+ export type PlanNodeStatus = typeof PlanNodeStatus.Type
203
+
204
+ /**
205
+ * One keyed node of the plan an approval is being taken on.
206
+ *
207
+ * `key` is an `@smthrs/keys` `Key` produced by `@smthrs/plan`'s step-key
208
+ * compiler, so a node named here and a node recorded in the persisted plan are
209
+ * the same node. Ids are lookup addresses and are never hashed.
210
+ *
211
+ * @since 0.1.0
212
+ * @category models
213
+ */
214
+ export const PlanNode = Schema.Struct({
215
+ ...PersistedPlan.PlanNode.fields,
216
+ status: PlanNodeStatus
217
+ })
218
+
219
+ /**
220
+ * One keyed node of the plan an approval is being taken on.
221
+ *
222
+ * @since 0.1.0
223
+ * @category models
224
+ */
225
+ export type PlanNode = typeof PlanNode.Type
226
+
227
+ /**
228
+ * Why one node of a plan waits for another.
229
+ *
230
+ * These are the reasons the two shipped graph builders already record.
231
+ * `value` consumes an upstream result and `continuation` is the sequencing
232
+ * edge of a builder or a branch arm, from both. `failure` is `@smthrs/flow`'s
233
+ * recovery arm; `conflict` is the ordering edge `@smthrs/core`'s
234
+ * write-conflict pass adds, and `lane-merge` orders laned writers with their
235
+ * merge. A host reports the vocabulary of the builder it graphs with.
236
+ *
237
+ * @since 0.1.0
238
+ * @category models
239
+ */
240
+ export const PlanEdgeReason = Schema.Literals(["value", "continuation", "failure", "conflict", "lane-merge"])
241
+
242
+ /**
243
+ * Why one node of a plan waits for another.
244
+ *
245
+ * @since 0.1.0
246
+ * @category models
247
+ */
248
+ export type PlanEdgeReason = typeof PlanEdgeReason.Type
249
+
250
+ /**
251
+ * One labelled edge of the graph a plan was built from.
252
+ *
253
+ * @since 0.1.0
254
+ * @category models
255
+ */
256
+ export const PlanEdge = Schema.Struct({
257
+ from: Schema.NonEmptyString,
258
+ to: Schema.NonEmptyString,
259
+ reason: PlanEdgeReason
260
+ })
261
+
262
+ /**
263
+ * One labelled edge of the graph a plan was built from.
264
+ *
265
+ * @since 0.1.0
266
+ * @category models
267
+ */
268
+ export type PlanEdge = typeof PlanEdge.Type
269
+
270
+ /**
271
+ * One node of the built graph, as the reader of a plan drills into it.
272
+ *
273
+ * It carries the address and the declaration site, and nothing else: the
274
+ * keyed node beside it (`PlanNode`) already says what the node is and what it
275
+ * would do, and this is the one fact about it the key material deliberately
276
+ * does not hold. `declaredAt` is the journal's own schema, so a plan card and
277
+ * a run's records state a declaration site the same way and under the same
278
+ * refusal of an absolute path; a host that cannot make a path relative to its
279
+ * own root omits it.
280
+ *
281
+ * @since 0.1.0
282
+ * @category models
283
+ */
284
+ export const PlanGraphNode = Schema.Struct({
285
+ id: Schema.NonEmptyString,
286
+ declaredAt: Schema.optionalKey(EngineEvent.DeclaredAt)
287
+ })
288
+
289
+ /**
290
+ * One node of the built graph, as the reader of a plan drills into it.
291
+ *
292
+ * @since 0.1.0
293
+ * @category models
294
+ */
295
+ export type PlanGraphNode = typeof PlanGraphNode.Type
296
+
297
+ /**
298
+ * The shape of the graph a plan was built from, for a reader that draws it.
299
+ *
300
+ * A `PlanNode` carries `dependsOn`, which is one unlabelled edge set: it
301
+ * cannot tell a value dependency from a `catch` arm or from an ordering edge
302
+ * a write conflict added. The graph builder knows which is which, so a host
303
+ * that graphs a flow reports the reasons here rather than making every reader
304
+ * guess them back.
305
+ *
306
+ * `nodes` is the same statement about provenance: the builder observed where
307
+ * each node was declared and the key material deliberately does not carry it,
308
+ * so it travels here, beside the edges and outside the digest. A host that
309
+ * reports none is a host whose reader cannot open the code, not a host whose
310
+ * plan is wrong.
311
+ *
312
+ * @since 0.1.0
313
+ * @category models
314
+ */
315
+ export const PlanGraph = Schema.Struct({
316
+ edges: Schema.Array(PlanEdge),
317
+ nodes: Schema.optional(Schema.Array(PlanGraphNode)),
318
+ /**
319
+ * The revision of the workspace those declaration sites were read out of.
320
+ *
321
+ * A site is a path and a line, and neither says which bytes were there: a
322
+ * host's working tree moves, so the same path after an edit or a branch
323
+ * switch is a different file. This is the immutable name of the tree the
324
+ * host loaded the flow from — a jj working-copy commit id, or a git commit
325
+ * for a tree that still matches one — and a reader asks the content route
326
+ * for the file AT this revision rather than for whatever is on disk now.
327
+ *
328
+ * A host that cannot name one reports nothing, and a reader that has
329
+ * nothing shows no code at all rather than code it cannot bind (D-068).
330
+ *
331
+ * Exactly the forty lowercase hex digits the only producer emits
332
+ * (`SourceRevision.objectId`), because the app puts this value straight
333
+ * into a contents route's `?ref=` and a route that spawns jj or git from it
334
+ * should never see anything else.
335
+ */
336
+ sourceRevision: Schema.optional(
337
+ Schema.NonEmptyString.check(Schema.makeFilter((value) => /^[0-9a-f]{40}$/.test(value)))
338
+ )
339
+ })
340
+
341
+ /**
342
+ * The shape of the graph a plan was built from, for a reader that draws it.
343
+ *
344
+ * @since 0.1.0
345
+ * @category models
346
+ */
347
+ export type PlanGraph = typeof PlanGraph.Type
348
+
349
+ /**
350
+ * The reviewable, signed payload returned by planning and resubmitted to
351
+ * approval without reconstructing authority client-side.
352
+ *
353
+ * `nodes` is the keyed node graph the plan phase produced. It is part of the
354
+ * card, and part of the digest an approval binds to, because "approve this
355
+ * flow with this input" and "approve this graph of keyed work" are different
356
+ * promises: a change that re-keys a node changes what will run, and an
357
+ * approval taken against the old graph must not authorize the new one. A host
358
+ * that has not built a graph reports an empty one and loses nothing.
359
+ *
360
+ * @since 0.1.0
361
+ * @category models
362
+ */
363
+ export const PlanCard = Schema.Struct({
364
+ planId: Schema.String,
365
+ flowId: FlowId,
366
+ digest: Schema.String,
367
+ inputSummary: Schema.String,
368
+ /** Discovery diagnostics for the selected flow; outside the approval identity. */
369
+ warnings: Schema.optional(Schema.Array(DiscoveryWarning)),
370
+ envelope: Envelope,
371
+ deployClass: Schema.Boolean,
372
+ /** Executable source/metadata identity supplied by a discovery-based host. */
373
+ executionDigest: Schema.optional(Schema.String),
374
+ plan: Schema.optional(PersistedPlan.Plan),
375
+ nodes: Schema.Array(PlanNode),
376
+ /**
377
+ * The labelled edges of the graph this plan was built from, and where its
378
+ * nodes were declared.
379
+ *
380
+ * Deliberately OUTSIDE the digest an approval binds to: the edges and the
381
+ * declaration sites describe the plan a reader draws, and nothing here
382
+ * changes what will run. The
383
+ * persisted plan's own digest already covers keys, edges, effects,
384
+ * conflicts, priorities and generations, so a host that starts reporting
385
+ * this field re-plans to the digest it planned to before and every parked
386
+ * approval still validates.
387
+ */
388
+ graph: Schema.optional(PlanGraph),
389
+ approval: ApprovalPayload
390
+ })
391
+
392
+ /**
393
+ * The reviewable, signed payload returned by planning and resubmitted to
394
+ * approval without reconstructing authority client-side.
395
+ *
396
+ * @since 0.1.0
397
+ * @category models
398
+ */
399
+ export type PlanCard = typeof PlanCard.Type
400
+
401
+ /**
402
+ * Stable statuses projected for a durable run.
403
+ *
404
+ * @since 0.1.0
405
+ * @category models
406
+ */
407
+ export const RunStatus = Schema.Literals([
408
+ "accepted",
409
+ "running",
410
+ "parked",
411
+ "waiting-approval",
412
+ "cancelled",
413
+ "completed",
414
+ "failed"
415
+ ])
416
+
417
+ /**
418
+ * Stable statuses projected for a durable run.
419
+ *
420
+ * @since 0.1.0
421
+ * @category models
422
+ */
423
+ export type RunStatus = typeof RunStatus.Type
424
+
425
+ /**
426
+ * How a run came to exist, when it did not start on its own.
427
+ *
428
+ * Defined by `@smthrs/control/Lineage` and re-exported here so a serializable
429
+ * projection needs one import.
430
+ *
431
+ * @since 0.1.0
432
+ * @category models
433
+ */
434
+ export const RunOrigin = Origin
435
+
436
+ /**
437
+ * How a run came to exist, when it did not start on its own.
438
+ *
439
+ * @since 0.1.0
440
+ * @category models
441
+ */
442
+ export type RunOrigin = typeof RunOrigin.Type
443
+
444
+ /**
445
+ * Where a cancellation came from.
446
+ *
447
+ * `control` is an operator asking through this plane, and it is the only
448
+ * source that can name a principal. `cascade` is a run swept up in an
449
+ * ancestor's cancellation. `engine` is everything the runtime decided on its
450
+ * own account: a lease expiry, a budget, a supervisor.
451
+ *
452
+ * @since 0.1.0
453
+ * @category models
454
+ */
455
+ export const CancelSource = Schema.Literals(["control", "engine", "cascade"])
456
+
457
+ /**
458
+ * Where a cancellation came from.
459
+ *
460
+ * @since 0.1.0
461
+ * @category models
462
+ */
463
+ export type CancelSource = typeof CancelSource.Type
464
+
465
+ /**
466
+ * Who cancelled a run, why, and on whose behalf.
467
+ *
468
+ * A durable cancellation is anonymous on its own: the run row records that
469
+ * somebody asked and when, and nothing else. This is the attribution the
470
+ * journal adds back. `principal` and `reason` are present exactly when a
471
+ * request named them, which a cascade inherits from the request that started
472
+ * it and an engine-decided cancellation never has.
473
+ *
474
+ * @since 0.1.0
475
+ * @category models
476
+ */
477
+ export const Cancellation = Schema.Struct({
478
+ requestedAt: Schema.Number,
479
+ source: CancelSource,
480
+ principal: Schema.optional(Principal),
481
+ reason: Schema.optional(Schema.String),
482
+ /** The cancelled ancestor this run was swept up with, on a cascade. */
483
+ cascadedFrom: Schema.optional(RunId)
484
+ })
485
+
486
+ /**
487
+ * Who cancelled a run, why, and on whose behalf.
488
+ *
489
+ * @since 0.1.0
490
+ * @category models
491
+ */
492
+ export type Cancellation = typeof Cancellation.Type
493
+
494
+ /**
495
+ * One open wait in a run tree that a person or named signal can end.
496
+ *
497
+ * A run that calls another flow parks the CHILD execution, not the run an
498
+ * operator named. `run-3` of `coding/request` sat at `waiting-reason: event`
499
+ * while the question a person owed an answer to — `coding-clarification` —
500
+ * was parked three executions below it on `coding/PreparePlan`. Every reader
501
+ * that asked the named run what it was waiting on was therefore told "an
502
+ * event", which is true of that one row and false of the run tree: nothing
503
+ * was going to arrive, because the run was waiting on a human.
504
+ *
505
+ * This is the wait as the ROOT of the tree reports it. `runId` is the
506
+ * execution actually holding it, which is what a decision has to be routed
507
+ * to; `token` is the durable wait address, submitted back unchanged;
508
+ * `request` is what the wait declared about itself, which for a `HumanTask`
509
+ * is `{kind, name, prompt, attempt, maxAttempts}`.
510
+ *
511
+ * @since 1.0.0
512
+ * @category models
513
+ */
514
+ export const PendingWait = Schema.Struct({
515
+ /** The execution parked on this wait, which may be the root run itself. */
516
+ runId: RunId,
517
+ /** The flow that execution is running. */
518
+ flowId: Schema.optional(FlowId),
519
+ /** The supervisor vocabulary: `approval` for people or `event` for a named signal. */
520
+ reason: Schema.String,
521
+ /** The durable wait address a decision is routed to. */
522
+ token: Schema.String,
523
+ /** Digest used to join replayed display facts to this current operational address. */
524
+ tokenDigest: Schema.optional(Schema.String),
525
+ /** The wait point's own name, when the token addresses a named one. */
526
+ name: Schema.optional(Schema.String),
527
+ /** Which attempt of a re-asked question this is, counting from 1. */
528
+ attempt: Schema.optional(Schema.Number),
529
+ /** What the wait declared about itself, absent when it declared nothing. */
530
+ request: Schema.optional(Schema.Json),
531
+ /** When the execution holding this wait was created. */
532
+ createdAt: Schema.Number
533
+ })
534
+
535
+ /**
536
+ * One open wait in a run tree that a person or named signal can end.
537
+ *
538
+ * @since 1.0.0
539
+ * @category models
540
+ */
541
+ export type PendingWait = typeof PendingWait.Type
542
+
543
+ /**
544
+ * A compact summary for run listings and status projections.
545
+ *
546
+ * @since 0.1.0
547
+ * @category models
548
+ */
549
+ export const RunSummary = Schema.Struct({
550
+ /** Whether lifecycle fields were observed in the engine or no engine row was visible. */
551
+ executionObservation: Schema.optional(Schema.Literals(["observed", "missing"])),
552
+ /** Exact native semantic observation; never a control-stream fact. */
553
+ executionView: Schema.optional(ExecutionFact.View),
554
+ runId: RunId,
555
+ flowId: FlowId,
556
+ status: RunStatus,
557
+ planId: Schema.optional(Schema.String),
558
+ planDigest: Schema.optional(Schema.String),
559
+ /** The flow's executable identity when the run started; resume refuses a different one. */
560
+ executionDigest: Schema.optional(Schema.String),
561
+ /** The engine version that started the run. */
562
+ engineVersion: Schema.optional(Schema.String),
563
+ /**
564
+ * How the code that would resume this run differs from the code it
565
+ * recorded. Computed by an exact run lookup, never stored; absent when
566
+ * nothing changed or the run is terminal.
567
+ */
568
+ codeDrift: Schema.optional(Schema.Struct({
569
+ recorded: Schema.optional(Schema.String),
570
+ current: Schema.optional(Schema.String),
571
+ recordedEngine: Schema.optional(Schema.String),
572
+ currentEngine: Schema.optional(Schema.String)
573
+ })),
574
+ ownerId: Schema.optional(Schema.String),
575
+ /**
576
+ * The authenticated principal that launched this run through the control
577
+ * plane. A reader that does not see every run sees only the runs its own
578
+ * principal launched. Absent on a run the engine created (a child, a fork,
579
+ * a later trampoline round) and on a run launched before it was recorded;
580
+ * only a reader that sees every run sees those.
581
+ */
582
+ launchedBy: Schema.optional(Schema.Struct({ id: Schema.String, kind: Schema.String })),
583
+ /**
584
+ * The run this one branched from: the spawning run, the forked-from run, or
585
+ * the previous trampoline round. Absent on a run with no ancestor.
586
+ */
587
+ parentRunId: Schema.optional(RunId),
588
+ /**
589
+ * The trampoline lineage this run is a round of, and which round it is.
590
+ * Both absent means a lineage of one, read as round 0 of itself.
591
+ */
592
+ lineageId: Schema.optional(Schema.String),
593
+ roundOrdinal: Schema.optional(Schema.Number),
594
+ origin: Schema.optional(RunOrigin),
595
+ /**
596
+ * What a parked run is holding on: `approval`, `event`, `timer`, `quota`, or
597
+ * a reason a plugin declared. Absent on a run that is not parked, and on a
598
+ * park whose owner released the run without declaring one.
599
+ *
600
+ * The CLI's `ps` and `status` listings also render `executor` here for a run
601
+ * that has sat at `accepted` with no owner process past the launch handoff
602
+ * window. That value is computed at render time and never stored, so a
603
+ * reader going through the control RPC, the gateway projection, or a plugin
604
+ * sees the field absent on the same run.
605
+ */
606
+ waitingReason: Schema.optional(Schema.String),
607
+ /** What has been steered to this run and not yet delivered. */
608
+ steering: Schema.optional(Schema.Struct({ pending: Schema.Number })),
609
+ /**
610
+ * A resume this run has been told to take and no host has taken up yet.
611
+ *
612
+ * A decision on an in-run approval restarts the run server-side, and the
613
+ * process that decides is usually not the process that hosts the execution:
614
+ * an operator's `smithers approve`, a gateway, a second CLI. The intent is
615
+ * therefore recorded durably here, and the host that owns the execution
616
+ * takes it up on its next tick and clears it. The number is the durable
617
+ * sequence of the request, so an operator can tell a delegation that is
618
+ * still outstanding from one that has been taken up. Absent means nothing
619
+ * is waiting to be taken up.
620
+ */
621
+ pendingResume: Schema.optional(Schema.Number),
622
+ /**
623
+ * The executor claim this run was parked under.
624
+ *
625
+ * A parked execution releases its owner columns — that is what makes it
626
+ * resumable at all — so after a park nothing on the row says which process
627
+ * is hosting it. Every process that shares the databases can therefore see
628
+ * the parked execution and resume it, including a short-lived `smithers
629
+ * approve` that would drive the run and then exit. The fence the park was
630
+ * written under is recorded here instead, so the host that parked the run
631
+ * recognizes its own park and every other composition can tell that the
632
+ * execution is not its to take up (triage B-15). Absent on a run that is not
633
+ * parked, and on a park written by something that held no fence.
634
+ */
635
+ parkedBy: Schema.optional(Schema.String),
636
+ /** Who cancelled this run, why, and on whose behalf. Absent until one did. */
637
+ cancellation: Schema.optional(Cancellation),
638
+ /**
639
+ * Open human waits anywhere in this run's tree, nearest execution first.
640
+ *
641
+ * Present only when there is at least one, so a run nobody owes an answer
642
+ * carries no field rather than an empty array. `status` rolls up with it:
643
+ * a run any of whose descendants is parked on `approval` reports
644
+ * `waiting-approval`, which is what the existing inbox filters select on.
645
+ */
646
+ pendingWaits: Schema.optional(Schema.Array(PendingWait)),
647
+ /**
648
+ * When the run's approved deadline passes: its `createdAt` plus the
649
+ * envelope's `budget.deadline`, which is the instant the run is failed with
650
+ * `deadline_exceeded` if it has not settled. Absent on a run approved with
651
+ * no deadline.
652
+ */
653
+ deadlineAt: Schema.optional(Schema.Number),
654
+ createdAt: Schema.Number,
655
+ updatedAt: Schema.Number
656
+ })
657
+
658
+ /**
659
+ * A compact summary for run listings and status projections.
660
+ *
661
+ * @since 0.1.0
662
+ * @category models
663
+ */
664
+ export type RunSummary = typeof RunSummary.Type
665
+
666
+ /**
667
+ * The bookkeeping every steer variant carries.
668
+ *
669
+ * `principal` stays here even though `CancelInput` argues a wire principal is
670
+ * a client naming someone else, and the difference is who the callers are. A
671
+ * cancel is only ever an operator command, so the server can be its sole
672
+ * source of identity. A steer is not: `agent/send` steers a child run and
673
+ * attributes the message to the parent flow, which is an identity no
674
+ * authenticator knows and no operator issued. Dropping the field would erase
675
+ * that attribution, so the field remains and `ControlServer` overwrites it
676
+ * with the authenticated principal on every steer that arrives over RPC. An
677
+ * in-process caller keeps naming its own.
678
+ */
679
+ const steerEnvelope = {
680
+ messageId: Schema.String,
681
+ /**
682
+ * The run this message is for. `Control.steer` refuses a message whose
683
+ * `runId` disagrees with the one the call names: the notification would be
684
+ * admitted to the call's run while the stored message claimed another, and an
685
+ * operator reading it later would be told it belongs somewhere it was never
686
+ * delivered.
687
+ */
688
+ runId: RunId,
689
+ principal: Principal,
690
+ // Producer labels are data, distinct from principal. Public RPC strips
691
+ // these; a trusted product bridge may relay its already-authorized sender.
692
+ attribution: Schema.optional(Attribution),
693
+ /**
694
+ * When the caller says it wrote the message. It is the caller's own
695
+ * statement, recorded on `control.steer.enqueued` and never used to decide
696
+ * anything. Over RPC the server's own clock is already on
697
+ * `principal.stampedAt`, which is the time a decision may be replayed
698
+ * against.
699
+ */
700
+ createdAt: Schema.Number
701
+ }
702
+
703
+ /**
704
+ * An operator message inserted into the transcript at the next turn boundary.
705
+ *
706
+ * `kind` is optional here and required on every other variant, which is what
707
+ * keeps a steer written before the vocabulary widened readable: a body and no
708
+ * kind is a message, and always was.
709
+ *
710
+ * @since 0.1.0
711
+ * @category models
712
+ */
713
+ export const MessageSteer = Schema.Struct({
714
+ ...steerEnvelope,
715
+ kind: Schema.optional(Schema.Literal("Message")),
716
+ body: Schema.String
717
+ })
718
+
719
+ /**
720
+ * A model-seat change that applies from the next turn on.
721
+ *
722
+ * @since 0.1.0
723
+ * @category models
724
+ */
725
+ export const SeatSteer = Schema.Struct({ ...steerEnvelope, ...SteerPayload.SeatPayload.fields })
726
+
727
+ /**
728
+ * A thinking-level change that applies from the next turn on.
729
+ *
730
+ * @since 0.1.0
731
+ * @category models
732
+ */
733
+ export const ThinkingSteer = Schema.Struct({ ...steerEnvelope, ...SteerPayload.ThinkingPayload.fields })
734
+
735
+ /**
736
+ * Tools added to the active set for future turns.
737
+ *
738
+ * @since 0.1.0
739
+ * @category models
740
+ */
741
+ export const ToolsSteer = Schema.Struct({ ...steerEnvelope, ...SteerPayload.ToolsPayload.fields })
742
+
743
+ /**
744
+ * A durable operator steer delivered at an execution turn boundary.
745
+ *
746
+ * An operator steers a run for four different reasons, and only one of them is
747
+ * something to tell the model. Saying "your seat changed" would spend a turn on
748
+ * bookkeeping; changing the seat is what was asked for. So the four are one
749
+ * union rather than four free-text conventions the harness would have to
750
+ * parse.
751
+ *
752
+ * @since 0.1.0
753
+ * @category models
754
+ */
755
+ export const SteerMessage = Schema.Union([MessageSteer, SeatSteer, ThinkingSteer, ToolsSteer])
756
+
757
+ /**
758
+ * A durable operator steer delivered at an execution turn boundary.
759
+ *
760
+ * @since 0.1.0
761
+ * @category models
762
+ */
763
+ export type SteerMessage = typeof SteerMessage.Type
764
+
765
+ /**
766
+ * The stored steering item one steer carries.
767
+ *
768
+ * The envelope — who asked, when, for which run — is control-plane
769
+ * bookkeeping. What crosses into the notification queue is the item alone, in
770
+ * the vocabulary `@smthrs/notifications` defines and the harness reads back.
771
+ *
772
+ * @param message the steer
773
+ * @since 0.1.0
774
+ * @category conversions
775
+ */
776
+ export const steerItem = (message: SteerMessage): SteerPayload.SteerPayload => {
777
+ switch (message.kind) {
778
+ case undefined:
779
+ case "Message":
780
+ return { kind: "Message", body: message.body }
781
+ case "Seat":
782
+ return { kind: "Seat", seat: message.seat }
783
+ case "Thinking":
784
+ return { kind: "Thinking", thinking: message.thinking }
785
+ case "Tools":
786
+ return { kind: "Tools", toolNames: message.toolNames }
787
+ }
788
+ }
789
+
790
+ /**
791
+ * A durable, named signal delivered to a waiting run.
792
+ *
793
+ * @since 0.1.0
794
+ * @category models
795
+ */
796
+ export const SignalPayload = Schema.Struct({
797
+ name: Schema.String,
798
+ payload: Schema.Json
799
+ })
800
+
801
+ /**
802
+ * A durable, named signal delivered to a waiting run.
803
+ *
804
+ * @since 0.1.0
805
+ * @category models
806
+ */
807
+ export type SignalPayload = typeof SignalPayload.Type
808
+
809
+ /**
810
+ * The RPC request schema for planning.
811
+ *
812
+ * The wire accepts JSON because an RPC request must be serializable. The local
813
+ * `Control.PlanInput` keeps `input` as `unknown` so a runtime can decode its
814
+ * flow's own input schema before anything crosses a transport.
815
+ *
816
+ * @since 0.1.0
817
+ * @category models
818
+ */
819
+ export const PlanInputSchema = Schema.Struct({
820
+ flowId: FlowId,
821
+ input: Schema.Json,
822
+ idempotencyKey: Schema.optional(IdempotencyKey),
823
+ budget: Schema.optional(Envelope.fields.budget)
824
+ })
825
+
826
+ /**
827
+ * The RPC request schema for starting a plan or resuming a run.
828
+ *
829
+ * @since 0.1.0
830
+ * @category models
831
+ */
832
+ export const RunInputSchema = Schema.Union([
833
+ Schema.TaggedStruct("Plan", {
834
+ planId: Schema.String,
835
+ digest: Schema.String,
836
+ envelope: Envelope,
837
+ idempotencyKey: IdempotencyKey
838
+ }),
839
+ Schema.TaggedStruct("Resume", {
840
+ runId: RunId,
841
+ idempotencyKey: IdempotencyKey,
842
+ allowCodeDrift: Schema.optional(Schema.Boolean)
843
+ })
844
+ ])
845
+
846
+ /**
847
+ * The RPC request schema for an approval decision.
848
+ *
849
+ * The authenticated server supplies the principal, so a client cannot name a
850
+ * different identity on the wire.
851
+ *
852
+ * @since 0.1.0
853
+ * @category models
854
+ */
855
+ export const ApprovalInputSchema = ApprovalPayload
856
+
857
+ /**
858
+ * The RPC request schema for steering a run.
859
+ *
860
+ * @since 0.1.0
861
+ * @category models
862
+ */
863
+ export const SteerInputSchema = Schema.Struct({
864
+ version: Schema.optional(Schema.Number),
865
+ runId: RunId,
866
+ message: SteerMessage,
867
+ idempotencyKey: IdempotencyKey
868
+ })
869
+
870
+ /**
871
+ * The RPC request schema for signaling a run.
872
+ *
873
+ * @since 0.1.0
874
+ * @category models
875
+ */
876
+ export const SignalInputSchema = Schema.Struct({
877
+ runId: RunId,
878
+ signal: SignalPayload,
879
+ idempotencyKey: IdempotencyKey
880
+ })
881
+
882
+ /**
883
+ * The shared fields of an RPC run mutation request.
884
+ *
885
+ * @since 0.1.0
886
+ * @category models
887
+ */
888
+ export const RunMutationInputSchema = Schema.Struct({ runId: RunId, idempotencyKey: IdempotencyKey })
889
+
890
+ /**
891
+ * The RPC request schema for a lifecycle mutation that records a reason.
892
+ *
893
+ * The reason is on the wire because the server records it with the decision.
894
+ * The principal is absent because the authenticated server stamps it.
895
+ *
896
+ * @since 0.1.0
897
+ * @category models
898
+ */
899
+ export const ReasonedMutationInputSchema = Schema.Struct({
900
+ ...RunMutationInputSchema.fields,
901
+ reason: Schema.optional(Schema.String)
902
+ })
903
+
904
+ /**
905
+ * The RPC request schema for cancellation.
906
+ *
907
+ * Cancellation currently has the same wire shape as every reasoned lifecycle
908
+ * mutation. This named alias keeps the operation's public contract explicit.
909
+ *
910
+ * @since 0.1.0
911
+ * @category models
912
+ */
913
+ export const CancelInputSchema = ReasonedMutationInputSchema
914
+
915
+ /**
916
+ * The RPC request schema for resume: a reasoned mutation that may accept a
917
+ * changed flow.
918
+ *
919
+ * @since 1.0.0
920
+ * @category models
921
+ */
922
+ export const ResumeInputSchema = Schema.Struct({
923
+ ...ReasonedMutationInputSchema.fields,
924
+ allowCodeDrift: Schema.optional(Schema.Boolean)
925
+ })
926
+
927
+ /**
928
+ * A checkpoint in one journal entry's expansion. Without `offset`, the whole
929
+ * entry is consumed. With it, only members through that zero-based index are
930
+ * consumed. Pass the cursor back unchanged with the same run id.
931
+ *
932
+ * @since 0.1.0
933
+ * @category models
934
+ */
935
+ export const WatchCursor = Schema.Struct({
936
+ sequence: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0), Schema.isLessThan(Number.MAX_SAFE_INTEGER)),
937
+ offset: Schema.optional(
938
+ Schema.Int.check(Schema.isGreaterThanOrEqualTo(0), Schema.isLessThan(Number.MAX_SAFE_INTEGER))
939
+ )
940
+ })
941
+
942
+ /**
943
+ * A checkpoint in one journal entry's expansion.
944
+ *
945
+ * @since 0.1.0
946
+ * @category models
947
+ */
948
+ export type WatchCursor = typeof WatchCursor.Type
949
+
950
+ /**
951
+ * A journal-projection cursor, optional run restriction, and delivery mode.
952
+ * Omitting `follow` preserves the live-stream behavior; `false` requests a
953
+ * finite snapshot of entries durable when the request is handled.
954
+ *
955
+ * @since 0.1.0
956
+ * @category models
957
+ */
958
+ export const WatchFilter = Schema.Struct({
959
+ runId: Schema.optional(RunId),
960
+ /** Resume after a fully consumed source entry, including all its deltas. Requires `runId`. */
961
+ afterSequence: Schema.optional(Schema.Number),
962
+ /** Resume after one emitted event, even inside an expansion. Requires `runId`. Cannot be combined with `afterSequence`. */
963
+ afterCursor: Schema.optional(WatchCursor),
964
+ follow: Schema.optional(Schema.Boolean)
965
+ })
966
+
967
+ /**
968
+ * A resumable journal-projection watch cursor and optional run restriction.
969
+ *
970
+ * @since 0.1.0
971
+ * @category models
972
+ */
973
+ export type WatchFilter = typeof WatchFilter.Type
974
+
975
+ /**
976
+ * One ordered journal-projection delta streamed by `watch`.
977
+ *
978
+ * @since 0.1.0
979
+ * @category models
980
+ */
981
+ export const ControlEvent = Schema.Struct({
982
+ /** Present on `ControlLive.watch` events; absent on raw projections and older providers. */
983
+ cursor: Schema.optional(WatchCursor),
984
+ sequence: Schema.Number,
985
+ kind: Schema.String,
986
+ runId: Schema.optional(RunId),
987
+ occurredAt: Schema.Number,
988
+ payload: Schema.Json
989
+ })
990
+
991
+ /**
992
+ * One ordered journal-projection delta streamed by `watch`.
993
+ *
994
+ * @since 0.1.0
995
+ * @category models
996
+ */
997
+ export type ControlEvent = typeof ControlEvent.Type
998
+
999
+ /**
1000
+ * How many items a listing returns when the caller names no `limit`.
1001
+ *
1002
+ * A listing with no bound returned the whole collection and paid one pending
1003
+ * steer query per run, so `smithers ps` on a busy project grew without bound.
1004
+ * A default is the smallest fix that keeps every caller working: a client that
1005
+ * wants more walks `nextCursor`.
1006
+ *
1007
+ * @since 0.1.0
1008
+ * @category models
1009
+ */
1010
+ export const defaultPageSize = 100
1011
+
1012
+ /**
1013
+ * The largest `limit` a listing accepts.
1014
+ *
1015
+ * The cap is the resource bound: a remote bearer holder cannot ask one request
1016
+ * to project an unbounded number of rows.
1017
+ *
1018
+ * @since 0.1.0
1019
+ * @category models
1020
+ */
1021
+ export const maxPageSize = 500
1022
+
1023
+ /**
1024
+ * A page size a listing can actually make progress on.
1025
+ *
1026
+ * `0`, a negative size, a fraction, `NaN`, and `Infinity` are all refused. A
1027
+ * zero-sized page used to answer `{ items: [], nextCursor: "0" }`, which is a
1028
+ * cursor a client loops on forever.
1029
+ *
1030
+ * @since 0.1.0
1031
+ * @category models
1032
+ */
1033
+ export const PageLimit = Schema.Int.check(
1034
+ Schema.isGreaterThanOrEqualTo(1),
1035
+ Schema.isLessThanOrEqualTo(maxPageSize)
1036
+ )
1037
+
1038
+ /**
1039
+ * How a claimed trigger occurrence ended.
1040
+ *
1041
+ * The same six words `@smthrs/triggers` records in its fire ledger. They are
1042
+ * declared here rather than imported because the triggers package depends on
1043
+ * this one (its scheduler launches runs through `Control`), so the vocabulary
1044
+ * has to live on the control side of that edge.
1045
+ *
1046
+ * @since 1.0.0
1047
+ * @category models
1048
+ */
1049
+ export const FireOutcome = Schema.Literals(["launched", "completed", "skipped", "buffered", "superseded", "failed"])
1050
+
1051
+ /**
1052
+ * How a claimed trigger occurrence ended.
1053
+ *
1054
+ * @since 1.0.0
1055
+ * @category models
1056
+ */
1057
+ export type FireOutcome = typeof FireOutcome.Type
1058
+
1059
+ /**
1060
+ * One registered trigger as a listing reports it.
1061
+ *
1062
+ * `nextOccurrencesMs` is the store clock's view of the next fires, computed at
1063
+ * read time, so an operator sees when a schedule will next run without
1064
+ * evaluating the cron expression client-side. `schedulerLastTickMs` is the
1065
+ * last poll the scheduler recorded; absent means no scheduler has ticked on
1066
+ * this host, so an enabled trigger is not going to fire. `activeRunId` names
1067
+ * the run the trigger is currently holding, and is absent while the trigger
1068
+ * holds a reservation rather than a launched run.
1069
+ *
1070
+ * @since 1.0.0
1071
+ * @category models
1072
+ */
1073
+ export const TriggerSummary = Schema.Struct({
1074
+ triggerId: Schema.String,
1075
+ flowId: FlowId,
1076
+ input: Schema.Json,
1077
+ cron: Schema.String,
1078
+ timezone: Schema.optional(Schema.String),
1079
+ overlap: Schema.Literals(["skip", "buffer-one", "supersede"]),
1080
+ catchUp: Schema.Literals(["none", "one", "all"]),
1081
+ maxCatchUp: Schema.optional(Schema.Number),
1082
+ enabled: Schema.Boolean,
1083
+ revision: Schema.Number,
1084
+ lastFiredAtMs: Schema.optional(Schema.Number),
1085
+ pendingAtMs: Schema.optional(Schema.Number),
1086
+ activeRunId: Schema.optional(RunId),
1087
+ nextOccurrencesMs: Schema.Array(Schema.Number),
1088
+ schedulerLastTickMs: Schema.optional(Schema.Number)
1089
+ })
1090
+
1091
+ /**
1092
+ * One registered trigger as a listing reports it.
1093
+ *
1094
+ * @since 1.0.0
1095
+ * @category models
1096
+ */
1097
+ export type TriggerSummary = typeof TriggerSummary.Type
1098
+
1099
+ /**
1100
+ * One claimed trigger occurrence and what became of it.
1101
+ *
1102
+ * `outcome` is `null` while the occurrence is claimed and not yet reported,
1103
+ * which is the window between a claim and its `recordResult`. `waiting` names
1104
+ * what a launched run is parked on when the ledger can see it.
1105
+ *
1106
+ * @since 1.0.0
1107
+ * @category models
1108
+ */
1109
+ export const FireSummary = Schema.Struct({
1110
+ triggerId: Schema.String,
1111
+ occurrenceAtMs: Schema.Number,
1112
+ outcome: Schema.NullOr(FireOutcome),
1113
+ runId: Schema.optional(RunId),
1114
+ error: Schema.optional(Schema.String),
1115
+ waiting: Schema.optional(Schema.Literal("approval"))
1116
+ })
1117
+
1118
+ /**
1119
+ * One claimed trigger occurrence and what became of it.
1120
+ *
1121
+ * @since 1.0.0
1122
+ * @category models
1123
+ */
1124
+ export type FireSummary = typeof FireSummary.Type
1125
+
1126
+ /**
1127
+ * An operator's decision on a stored plan.
1128
+ *
1129
+ * @since 1.0.0
1130
+ * @category models
1131
+ */
1132
+ export const PlanDecision = Schema.Literals(["pending", "approved", "denied"])
1133
+
1134
+ /**
1135
+ * An operator's decision on a stored plan.
1136
+ *
1137
+ * @since 1.0.0
1138
+ * @category models
1139
+ */
1140
+ export type PlanDecision = typeof PlanDecision.Type
1141
+
1142
+ /**
1143
+ * One stored plan as a listing reports it: the card an approval submits
1144
+ * (`card.approval`), the decoded input it was planned with, and its decision.
1145
+ *
1146
+ * @since 1.0.0
1147
+ * @category models
1148
+ */
1149
+ export const PlanSummary = Schema.Struct({
1150
+ card: PlanCard,
1151
+ input: Schema.Json,
1152
+ decision: PlanDecision
1153
+ })
1154
+
1155
+ /**
1156
+ * One stored plan as a listing reports it.
1157
+ *
1158
+ * @since 1.0.0
1159
+ * @category models
1160
+ */
1161
+ export type PlanSummary = typeof PlanSummary.Type
1162
+
1163
+ /** Exact native observations, including unavailable evidence rather than a guessed lifecycle.
1164
+ * @category schemas
1165
+ * @since 1.0.0
1166
+ */
1167
+ export const ExecutionBatch = Schema.Struct({
1168
+ source: Schema.NullOr(Schema.String),
1169
+ revision: Schema.NullOr(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0))),
1170
+ snapshots: Schema.Array(Schema.Union([
1171
+ Schema.TaggedStruct("Observed", {
1172
+ executionId: RunId,
1173
+ source: Schema.String,
1174
+ revision: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
1175
+ observation: ExecutionFact.Observation
1176
+ }),
1177
+ Schema.TaggedStruct("Missing", {
1178
+ executionId: RunId,
1179
+ source: Schema.String,
1180
+ revision: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
1181
+ deleted: Schema.Boolean
1182
+ }),
1183
+ Schema.TaggedStruct("Unavailable", {
1184
+ executionId: RunId,
1185
+ reason: Schema.Literals(["unsupported", "outside-run", "ancestry-unavailable"])
1186
+ })
1187
+ ]))
1188
+ })
1189
+ /** Native execution observations with their source watermark.
1190
+ * @category models
1191
+ * @since 1.0.0
1192
+ */
1193
+ export type ExecutionBatch = typeof ExecutionBatch.Type
1194
+
1195
+ /**
1196
+ * A typed listing request for discovered flows, durable runs, registered
1197
+ * triggers, the trigger fire ledger, or stored plans.
1198
+ *
1199
+ * `plans` lists stored plans oldest first, narrowed by flow and decision, so an
1200
+ * operator can find what is waiting for approval: a build target declaring
1201
+ * `approval: "required"` leaves a pending `system/target` plan. Plans are an
1202
+ * operator's to read; a restricted reader lists none.
1203
+ *
1204
+ * `principalId` selects the runs whose `launchedBy.id` it names. It narrows a
1205
+ * listing; it is not an authorization boundary. The server restricts a reader
1206
+ * that does not see every run to the runs its own principal launched, whatever
1207
+ * filter it sends.
1208
+ *
1209
+ * @since 0.1.0
1210
+ * @category models
1211
+ */
1212
+ export const ListRequest = Schema.Union([
1213
+ Schema.TaggedStruct("executions", {
1214
+ runId: RunId,
1215
+ executionIds: Schema.Array(Schema.NonEmptyString).check(Schema.isMaxLength(200))
1216
+ }),
1217
+ Schema.TaggedStruct("flows", {
1218
+ filters: Schema.optional(Schema.Json),
1219
+ cursor: Schema.optional(Schema.String),
1220
+ limit: Schema.optional(PageLimit)
1221
+ }),
1222
+ Schema.TaggedStruct("runs", {
1223
+ filters: Schema.optional(Schema.Struct({
1224
+ runId: Schema.optional(RunId),
1225
+ flowId: Schema.optional(FlowId),
1226
+ status: Schema.optional(RunStatus),
1227
+ terminal: Schema.optional(Schema.Boolean),
1228
+ principalId: Schema.optional(Schema.String),
1229
+ parentRunId: Schema.optional(RunId),
1230
+ lineageId: Schema.optional(Schema.String),
1231
+ /** Runs created at or after this epoch millisecond. */
1232
+ since: Schema.optional(Schema.Number),
1233
+ /** Runs created before this epoch millisecond. */
1234
+ until: Schema.optional(Schema.Number),
1235
+ /** Runs a fire of this trigger started. */
1236
+ triggerId: Schema.optional(Schema.String)
1237
+ })),
1238
+ /** Creation time, newest or oldest first; omitted preserves the historical listing order. */
1239
+ order: Schema.optional(Schema.Literals(["newest", "oldest"])),
1240
+ cursor: Schema.optional(Schema.String),
1241
+ limit: Schema.optional(PageLimit)
1242
+ }),
1243
+ Schema.TaggedStruct("triggers", {
1244
+ filters: Schema.optional(Schema.Struct({
1245
+ triggerId: Schema.optional(Schema.String),
1246
+ flowId: Schema.optional(FlowId),
1247
+ enabled: Schema.optional(Schema.Boolean)
1248
+ })),
1249
+ cursor: Schema.optional(Schema.String),
1250
+ limit: Schema.optional(PageLimit)
1251
+ }),
1252
+ Schema.TaggedStruct("fires", {
1253
+ filters: Schema.optional(Schema.Struct({
1254
+ triggerId: Schema.optional(Schema.String),
1255
+ runId: Schema.optional(RunId),
1256
+ outcome: Schema.optional(FireOutcome)
1257
+ })),
1258
+ cursor: Schema.optional(Schema.String),
1259
+ limit: Schema.optional(PageLimit)
1260
+ }),
1261
+ Schema.TaggedStruct("plans", {
1262
+ filters: Schema.optional(Schema.Struct({
1263
+ flowId: Schema.optional(FlowId),
1264
+ decision: Schema.optional(PlanDecision)
1265
+ })),
1266
+ cursor: Schema.optional(Schema.String),
1267
+ limit: Schema.optional(PageLimit)
1268
+ })
1269
+ ])
1270
+
1271
+ /**
1272
+ * A typed listing request for discovered flows, durable runs, registered
1273
+ * triggers, the trigger fire ledger, or stored plans.
1274
+ *
1275
+ * @since 0.1.0
1276
+ * @category models
1277
+ */
1278
+ export type ListRequest = typeof ListRequest.Type
1279
+
1280
+ /**
1281
+ * A typed page returned for a flow, run, trigger, fire, or plan listing.
1282
+ *
1283
+ * @since 0.1.0
1284
+ * @category models
1285
+ */
1286
+ export const ListResponse = Schema.Union([
1287
+ Schema.TaggedStruct("executions", {
1288
+ source: ExecutionBatch.fields.source,
1289
+ revision: ExecutionBatch.fields.revision,
1290
+ items: ExecutionBatch.fields.snapshots,
1291
+ nextCursor: Schema.optional(Schema.Never)
1292
+ }),
1293
+ Schema.TaggedStruct("flows", {
1294
+ items: Schema.Array(
1295
+ Schema.Struct({ flowId: FlowId, description: Schema.String, inputSchema: Schema.optional(Schema.Json) })
1296
+ ),
1297
+ warnings: Schema.optional(Schema.Array(DiscoveryWarning)),
1298
+ nextCursor: Schema.optional(Schema.String)
1299
+ }),
1300
+ Schema.TaggedStruct("runs", {
1301
+ items: Schema.Array(RunSummary),
1302
+ nextCursor: Schema.optional(Schema.String)
1303
+ }),
1304
+ Schema.TaggedStruct("triggers", {
1305
+ items: Schema.Array(TriggerSummary),
1306
+ nextCursor: Schema.optional(Schema.String)
1307
+ }),
1308
+ Schema.TaggedStruct("fires", {
1309
+ items: Schema.Array(FireSummary),
1310
+ nextCursor: Schema.optional(Schema.String)
1311
+ }),
1312
+ Schema.TaggedStruct("plans", {
1313
+ items: Schema.Array(PlanSummary),
1314
+ nextCursor: Schema.optional(Schema.String)
1315
+ })
1316
+ ])
1317
+
1318
+ /**
1319
+ * A typed page returned for a flow, run, trigger, fire, or plan listing.
1320
+ *
1321
+ * @since 0.1.0
1322
+ * @category models
1323
+ */
1324
+ export type ListResponse = typeof ListResponse.Type
1325
+
1326
+ /**
1327
+ * A live process that hosts a run: its machine and process id.
1328
+ *
1329
+ * @since 1.0.0
1330
+ * @category models
1331
+ */
1332
+ export const RunHost = Schema.Struct({ hostId: Schema.String, pid: Schema.Number })
1333
+
1334
+ /**
1335
+ * A live process that hosts a run: its machine and process id.
1336
+ *
1337
+ * @since 1.0.0
1338
+ * @category models
1339
+ */
1340
+ export type RunHost = typeof RunHost.Type
1341
+
1342
+ /**
1343
+ * The idempotent outcome returned by every control mutation.
1344
+ *
1345
+ * An `Accepted` resume with `handedTo` was not claimed by the caller: the live
1346
+ * process that parked the run takes it up and drives it.
1347
+ *
1348
+ * @since 0.1.0
1349
+ * @category models
1350
+ */
1351
+ export const Receipt = Schema.Union([
1352
+ Schema.TaggedStruct("Accepted", {
1353
+ inputConsumed: Schema.optional(Schema.Boolean),
1354
+ inputBody: Schema.optional(Schema.String),
1355
+ receiptId: Schema.String,
1356
+ runId: Schema.optional(RunId),
1357
+ handedTo: Schema.optional(RunHost)
1358
+ }),
1359
+ Schema.TaggedStruct("AlreadyApplied", {
1360
+ receiptId: Schema.String,
1361
+ runId: Schema.optional(RunId),
1362
+ inputConsumed: Schema.optional(Schema.Boolean),
1363
+ inputBody: Schema.optional(Schema.String)
1364
+ }),
1365
+ Schema.TaggedStruct("Parked", {
1366
+ receiptId: Schema.String,
1367
+ planId: Schema.String,
1368
+ status: Schema.Literal("waiting-approval")
1369
+ }),
1370
+ Schema.TaggedStruct("Conflict", { message: Schema.String }),
1371
+ Schema.TaggedStruct("Terminal", { runId: RunId, status: RunStatus })
1372
+ ])
1373
+
1374
+ /**
1375
+ * The idempotent outcome returned by every control mutation.
1376
+ *
1377
+ * @since 0.1.0
1378
+ * @category models
1379
+ */
1380
+ export type Receipt = typeof Receipt.Type