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