clinkx 1.2.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (371) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/README.md +17 -8
  3. package/clinkx-workflows/dist/architecture-arena/admission.d.ts +16 -0
  4. package/clinkx-workflows/dist/architecture-arena/admission.js +107 -0
  5. package/clinkx-workflows/dist/architecture-arena/admission.js.map +1 -0
  6. package/clinkx-workflows/dist/architecture-arena/contract.d.ts +1368 -0
  7. package/clinkx-workflows/dist/architecture-arena/contract.js +254 -0
  8. package/clinkx-workflows/dist/architecture-arena/contract.js.map +1 -0
  9. package/clinkx-workflows/dist/architecture-arena/runtime.d.ts +53 -0
  10. package/clinkx-workflows/dist/architecture-arena/runtime.js +511 -0
  11. package/clinkx-workflows/dist/architecture-arena/runtime.js.map +1 -0
  12. package/clinkx-workflows/dist/architecture-comparison/admission.d.ts +17 -1
  13. package/clinkx-workflows/dist/architecture-comparison/admission.js +27 -4
  14. package/clinkx-workflows/dist/architecture-comparison/admission.js.map +1 -1
  15. package/clinkx-workflows/dist/architecture-comparison/contract.d.ts +59 -62
  16. package/clinkx-workflows/dist/architecture-comparison/contract.js +4 -21
  17. package/clinkx-workflows/dist/architecture-comparison/contract.js.map +1 -1
  18. package/clinkx-workflows/dist/architecture-comparison/runtime.d.ts +4 -3
  19. package/clinkx-workflows/dist/architecture-comparison/runtime.js +22 -67
  20. package/clinkx-workflows/dist/architecture-comparison/runtime.js.map +1 -1
  21. package/clinkx-workflows/dist/artifacts.d.ts +19 -4
  22. package/clinkx-workflows/dist/artifacts.js +16 -7
  23. package/clinkx-workflows/dist/artifacts.js.map +1 -1
  24. package/clinkx-workflows/dist/backend.d.ts +30 -0
  25. package/clinkx-workflows/dist/child-env.d.ts +3 -0
  26. package/clinkx-workflows/dist/child-env.js +11 -0
  27. package/clinkx-workflows/dist/child-env.js.map +1 -1
  28. package/clinkx-workflows/dist/clink-client.d.ts +8 -2
  29. package/clinkx-workflows/dist/clink-client.js +4 -2
  30. package/clinkx-workflows/dist/clink-client.js.map +1 -1
  31. package/clinkx-workflows/dist/context-preflight.d.ts +6 -0
  32. package/clinkx-workflows/dist/context-preflight.js.map +1 -1
  33. package/clinkx-workflows/dist/council-execution-policy.d.ts +3 -1
  34. package/clinkx-workflows/dist/council-execution-policy.js +4 -0
  35. package/clinkx-workflows/dist/council-execution-policy.js.map +1 -1
  36. package/clinkx-workflows/dist/dashboard/api-routes.d.ts +21 -0
  37. package/clinkx-workflows/dist/dashboard/api-routes.js +27 -0
  38. package/clinkx-workflows/dist/dashboard/api-routes.js.map +1 -1
  39. package/clinkx-workflows/dist/dashboard/auth/challenge-store.d.ts +13 -0
  40. package/clinkx-workflows/dist/dashboard/auth/challenge-store.js.map +1 -1
  41. package/clinkx-workflows/dist/dashboard/auth/controller.d.ts +27 -0
  42. package/clinkx-workflows/dist/dashboard/auth/controller.js +262 -23
  43. package/clinkx-workflows/dist/dashboard/auth/controller.js.map +1 -1
  44. package/clinkx-workflows/dist/dashboard/auth/settings-step-up.d.ts +62 -0
  45. package/clinkx-workflows/dist/dashboard/auth/settings-step-up.js +70 -0
  46. package/clinkx-workflows/dist/dashboard/auth/settings-step-up.js.map +1 -0
  47. package/clinkx-workflows/dist/dashboard/contracts.d.ts +586 -586
  48. package/clinkx-workflows/dist/dashboard/progress-report-contract.d.ts +28 -28
  49. package/clinkx-workflows/dist/dashboard/request-admission.d.ts +6 -0
  50. package/clinkx-workflows/dist/dashboard/request-admission.js +9 -0
  51. package/clinkx-workflows/dist/dashboard/request-admission.js.map +1 -1
  52. package/clinkx-workflows/dist/dashboard/server-factory.js +15 -1
  53. package/clinkx-workflows/dist/dashboard/server-factory.js.map +1 -1
  54. package/clinkx-workflows/dist/dashboard/session-log-contract.d.ts +32 -32
  55. package/clinkx-workflows/dist/dashboard/settings-contract.d.ts +1806 -0
  56. package/clinkx-workflows/dist/dashboard/settings-contract.js +630 -0
  57. package/clinkx-workflows/dist/dashboard/settings-contract.js.map +1 -0
  58. package/clinkx-workflows/dist/dashboard/settings-process-reader.d.ts +48 -0
  59. package/clinkx-workflows/dist/dashboard/settings-process-reader.js +195 -0
  60. package/clinkx-workflows/dist/dashboard/settings-process-reader.js.map +1 -0
  61. package/clinkx-workflows/dist/dashboard/settings-routes.d.ts +87 -0
  62. package/clinkx-workflows/dist/dashboard/settings-routes.js +690 -0
  63. package/clinkx-workflows/dist/dashboard/settings-routes.js.map +1 -0
  64. package/clinkx-workflows/dist/dashboard-ui/assets/index-DSOtuS0p.js +122 -0
  65. package/clinkx-workflows/dist/dashboard-ui/assets/style-C5guUjwN.css +1 -0
  66. package/clinkx-workflows/dist/dashboard-ui/index.html +2 -2
  67. package/clinkx-workflows/dist/delegate-signature.d.ts +4 -3
  68. package/clinkx-workflows/dist/delegate-signature.js +4 -3
  69. package/clinkx-workflows/dist/delegate-signature.js.map +1 -1
  70. package/clinkx-workflows/dist/durable-file-core.d.ts +76 -0
  71. package/clinkx-workflows/dist/durable-file-core.js +146 -0
  72. package/clinkx-workflows/dist/durable-file-core.js.map +1 -0
  73. package/clinkx-workflows/dist/durable-file.d.ts +13 -0
  74. package/clinkx-workflows/dist/durable-file.js +22 -0
  75. package/clinkx-workflows/dist/durable-file.js.map +1 -0
  76. package/clinkx-workflows/dist/engine.d.ts +42 -7
  77. package/clinkx-workflows/dist/engine.js +196 -24
  78. package/clinkx-workflows/dist/engine.js.map +1 -1
  79. package/clinkx-workflows/dist/index.js +68 -2
  80. package/clinkx-workflows/dist/index.js.map +1 -1
  81. package/clinkx-workflows/dist/ping-pong/admission.d.ts +127 -0
  82. package/clinkx-workflows/dist/ping-pong/admission.js +522 -0
  83. package/clinkx-workflows/dist/ping-pong/admission.js.map +1 -0
  84. package/clinkx-workflows/dist/ping-pong/contract.d.ts +2539 -0
  85. package/clinkx-workflows/dist/ping-pong/contract.js +819 -0
  86. package/clinkx-workflows/dist/ping-pong/contract.js.map +1 -0
  87. package/clinkx-workflows/dist/ping-pong/control.d.ts +67 -0
  88. package/clinkx-workflows/dist/ping-pong/control.js +12 -0
  89. package/clinkx-workflows/dist/ping-pong/control.js.map +1 -0
  90. package/clinkx-workflows/dist/ping-pong/runtime-handle.d.ts +24 -0
  91. package/clinkx-workflows/dist/ping-pong/runtime-handle.js +55 -0
  92. package/clinkx-workflows/dist/ping-pong/runtime-handle.js.map +1 -0
  93. package/clinkx-workflows/dist/ping-pong/runtime.d.ts +235 -0
  94. package/clinkx-workflows/dist/ping-pong/runtime.js +1183 -0
  95. package/clinkx-workflows/dist/ping-pong/runtime.js.map +1 -0
  96. package/clinkx-workflows/dist/ping-pong/settle.d.ts +57 -0
  97. package/clinkx-workflows/dist/ping-pong/settle.js +58 -0
  98. package/clinkx-workflows/dist/ping-pong/settle.js.map +1 -0
  99. package/clinkx-workflows/dist/ping-pong/sidecar.d.ts +65 -0
  100. package/clinkx-workflows/dist/ping-pong/sidecar.js +138 -0
  101. package/clinkx-workflows/dist/ping-pong/sidecar.js.map +1 -0
  102. package/clinkx-workflows/dist/plan-review/publication.d.ts +2 -1
  103. package/clinkx-workflows/dist/plan-review/publication.js +5 -6
  104. package/clinkx-workflows/dist/plan-review/publication.js.map +1 -1
  105. package/clinkx-workflows/dist/plan-review/snapshot.d.ts +3 -2
  106. package/clinkx-workflows/dist/plan-review/snapshot.js +8 -8
  107. package/clinkx-workflows/dist/plan-review/snapshot.js.map +1 -1
  108. package/clinkx-workflows/dist/recipe-host.d.ts +315 -0
  109. package/clinkx-workflows/dist/recipe-host.js +183 -0
  110. package/clinkx-workflows/dist/recipe-host.js.map +1 -0
  111. package/clinkx-workflows/dist/recipe-seats.d.ts +96 -0
  112. package/clinkx-workflows/dist/recipe-seats.js +163 -0
  113. package/clinkx-workflows/dist/recipe-seats.js.map +1 -0
  114. package/clinkx-workflows/dist/recipe-shared/evidence.d.ts +67 -0
  115. package/clinkx-workflows/dist/recipe-shared/evidence.js +111 -0
  116. package/clinkx-workflows/dist/recipe-shared/evidence.js.map +1 -0
  117. package/clinkx-workflows/dist/reducers/index.d.ts +9 -1
  118. package/clinkx-workflows/dist/reducers/index.js +30 -0
  119. package/clinkx-workflows/dist/reducers/index.js.map +1 -1
  120. package/clinkx-workflows/dist/run-lock-reclaim.d.ts +44 -0
  121. package/clinkx-workflows/dist/run-lock-reclaim.js +86 -0
  122. package/clinkx-workflows/dist/run-lock-reclaim.js.map +1 -0
  123. package/clinkx-workflows/dist/settings/audit.d.ts +101 -0
  124. package/clinkx-workflows/dist/settings/audit.js +318 -0
  125. package/clinkx-workflows/dist/settings/audit.js.map +1 -0
  126. package/clinkx-workflows/dist/settings/bootstrap.d.ts +35 -0
  127. package/clinkx-workflows/dist/settings/bootstrap.js +52 -0
  128. package/clinkx-workflows/dist/settings/bootstrap.js.map +1 -0
  129. package/clinkx-workflows/dist/settings/codec.d.ts +51 -0
  130. package/clinkx-workflows/dist/settings/codec.js +410 -0
  131. package/clinkx-workflows/dist/settings/codec.js.map +1 -0
  132. package/clinkx-workflows/dist/settings/durable-write.d.ts +48 -0
  133. package/clinkx-workflows/dist/settings/durable-write.js +31 -0
  134. package/clinkx-workflows/dist/settings/durable-write.js.map +1 -0
  135. package/clinkx-workflows/dist/settings/index.d.ts +20 -0
  136. package/clinkx-workflows/dist/settings/index.js +23 -0
  137. package/clinkx-workflows/dist/settings/index.js.map +1 -0
  138. package/clinkx-workflows/dist/settings/loader.d.ts +80 -0
  139. package/clinkx-workflows/dist/settings/loader.js +577 -0
  140. package/clinkx-workflows/dist/settings/loader.js.map +1 -0
  141. package/clinkx-workflows/dist/settings/lock.d.ts +108 -0
  142. package/clinkx-workflows/dist/settings/lock.js +344 -0
  143. package/clinkx-workflows/dist/settings/lock.js.map +1 -0
  144. package/clinkx-workflows/dist/settings/paths.d.ts +65 -0
  145. package/clinkx-workflows/dist/settings/paths.js +173 -0
  146. package/clinkx-workflows/dist/settings/paths.js.map +1 -0
  147. package/clinkx-workflows/dist/settings/process-heartbeat.d.ts +47 -0
  148. package/clinkx-workflows/dist/settings/process-heartbeat.js +305 -0
  149. package/clinkx-workflows/dist/settings/process-heartbeat.js.map +1 -0
  150. package/clinkx-workflows/dist/settings/registry.d.ts +178 -0
  151. package/clinkx-workflows/dist/settings/registry.js +1285 -0
  152. package/clinkx-workflows/dist/settings/registry.js.map +1 -0
  153. package/clinkx-workflows/dist/settings/schema.d.ts +404 -0
  154. package/clinkx-workflows/dist/settings/schema.js +415 -0
  155. package/clinkx-workflows/dist/settings/schema.js.map +1 -0
  156. package/clinkx-workflows/dist/settings/store.d.ts +157 -0
  157. package/clinkx-workflows/dist/settings/store.js +842 -0
  158. package/clinkx-workflows/dist/settings/store.js.map +1 -0
  159. package/clinkx-workflows/dist/state-schema.d.ts +11 -0
  160. package/clinkx-workflows/dist/state-schema.js +4 -1
  161. package/clinkx-workflows/dist/state-schema.js.map +1 -1
  162. package/clinkx-workflows/dist/state.d.ts +178 -3
  163. package/clinkx-workflows/dist/state.js +618 -83
  164. package/clinkx-workflows/dist/state.js.map +1 -1
  165. package/clinkx-workflows/dist/stdio-entry.d.ts +2 -0
  166. package/clinkx-workflows/dist/stdio-entry.js +52 -0
  167. package/clinkx-workflows/dist/stdio-entry.js.map +1 -0
  168. package/clinkx-workflows/dist/transport.d.ts +2 -1
  169. package/clinkx-workflows/dist/transport.js +5 -0
  170. package/clinkx-workflows/dist/transport.js.map +1 -1
  171. package/clinkx-workflows/dist/validators/architecture-arena.d.ts +6 -0
  172. package/clinkx-workflows/dist/validators/architecture-arena.js +16 -0
  173. package/clinkx-workflows/dist/validators/architecture-arena.js.map +1 -0
  174. package/clinkx-workflows/dist/validators/index.js +4 -0
  175. package/clinkx-workflows/dist/validators/index.js.map +1 -1
  176. package/clinkx-workflows/dist/validators/ping-pong.d.ts +6 -0
  177. package/clinkx-workflows/dist/validators/ping-pong.js +10 -0
  178. package/clinkx-workflows/dist/validators/ping-pong.js.map +1 -0
  179. package/clinkx-workflows/dist/workflow-tools.d.ts +51 -5
  180. package/clinkx-workflows/dist/workflow-tools.js +785 -34
  181. package/clinkx-workflows/dist/workflow-tools.js.map +1 -1
  182. package/clinkx-workflows/dist/workflow-verification-contract.d.ts +4 -4
  183. package/clinkx-workflows/templates/architecture-arena/candidate.txt +39 -0
  184. package/clinkx-workflows/templates/architecture-arena/judge.txt +34 -0
  185. package/clinkx-workflows/templates/ping-pong/implement.txt +14 -0
  186. package/clinkx-workflows/templates/ping-pong/remediate.txt +14 -0
  187. package/clinkx-workflows/templates/ping-pong/review.txt +27 -0
  188. package/clinkx-workflows/workflows/architecture-arena.yaml +127 -0
  189. package/clinkx-workflows/workflows/ping-pong.yaml +158 -0
  190. package/dist/context-builder/bundle.js +4 -3
  191. package/dist/context-builder/bundle.js.map +1 -1
  192. package/dist/context-builder/delegate-packet.d.ts +1 -0
  193. package/dist/context-builder/delegate-packet.js +66 -7
  194. package/dist/context-builder/delegate-packet.js.map +1 -1
  195. package/dist/context-builder/delegate-validation.d.ts +12 -3
  196. package/dist/context-builder/delegate-validation.js +23 -13
  197. package/dist/context-builder/delegate-validation.js.map +1 -1
  198. package/dist/context-builder/external-gaps.d.ts +14 -3
  199. package/dist/context-builder/external-gaps.js +124 -18
  200. package/dist/context-builder/external-gaps.js.map +1 -1
  201. package/dist/context-builder/handler.js +108 -191
  202. package/dist/context-builder/handler.js.map +1 -1
  203. package/dist/context-builder/review-coverage.js +27 -1
  204. package/dist/context-builder/review-coverage.js.map +1 -1
  205. package/dist/context-builder/secrets.js +1 -1
  206. package/dist/context-builder/secrets.js.map +1 -1
  207. package/dist/context-builder/versions.d.ts +10 -4
  208. package/dist/context-builder/versions.js +10 -4
  209. package/dist/context-builder/versions.js.map +1 -1
  210. package/dist/context-builder/workflow-runner.js +33 -24
  211. package/dist/context-builder/workflow-runner.js.map +1 -1
  212. package/dist/dashboard-cli.d.ts +2 -0
  213. package/dist/dashboard-cli.js +197 -58
  214. package/dist/dashboard-cli.js.map +1 -1
  215. package/dist/dashboard-companion/client.d.ts +10 -0
  216. package/dist/dashboard-companion/client.js +43 -1
  217. package/dist/dashboard-companion/client.js.map +1 -1
  218. package/dist/dashboard-companion/config.d.ts +19 -1
  219. package/dist/dashboard-companion/config.js +104 -3
  220. package/dist/dashboard-companion/config.js.map +1 -1
  221. package/dist/dashboard-companion/protocol.d.ts +16 -0
  222. package/dist/dashboard-companion/protocol.js +55 -1
  223. package/dist/dashboard-companion/protocol.js.map +1 -1
  224. package/dist/dashboard-companion/workstation-binding.d.ts +69 -0
  225. package/dist/dashboard-companion/workstation-binding.js +192 -0
  226. package/dist/dashboard-companion/workstation-binding.js.map +1 -0
  227. package/dist/dashboard-gateway/admin-cli.d.ts +10 -0
  228. package/dist/dashboard-gateway/admin-cli.js +266 -0
  229. package/dist/dashboard-gateway/admin-cli.js.map +1 -0
  230. package/dist/dashboard-gateway/config.d.ts +50 -0
  231. package/dist/dashboard-gateway/config.js +235 -1
  232. package/dist/dashboard-gateway/config.js.map +1 -1
  233. package/dist/dashboard-gateway/connection-registry.d.ts +100 -0
  234. package/dist/dashboard-gateway/connection-registry.js +228 -0
  235. package/dist/dashboard-gateway/connection-registry.js.map +1 -0
  236. package/dist/dashboard-gateway/control-plane/account-auth.d.ts +78 -0
  237. package/dist/dashboard-gateway/control-plane/account-auth.js +198 -0
  238. package/dist/dashboard-gateway/control-plane/account-auth.js.map +1 -0
  239. package/dist/dashboard-gateway/control-plane/billing.d.ts +264 -0
  240. package/dist/dashboard-gateway/control-plane/billing.js +787 -0
  241. package/dist/dashboard-gateway/control-plane/billing.js.map +1 -0
  242. package/dist/dashboard-gateway/control-plane/contracts.d.ts +1293 -0
  243. package/dist/dashboard-gateway/control-plane/contracts.js +280 -0
  244. package/dist/dashboard-gateway/control-plane/contracts.js.map +1 -0
  245. package/dist/dashboard-gateway/control-plane/cookies.d.ts +13 -0
  246. package/dist/dashboard-gateway/control-plane/cookies.js +46 -0
  247. package/dist/dashboard-gateway/control-plane/cookies.js.map +1 -0
  248. package/dist/dashboard-gateway/control-plane/credentials.d.ts +63 -0
  249. package/dist/dashboard-gateway/control-plane/credentials.js +66 -0
  250. package/dist/dashboard-gateway/control-plane/credentials.js.map +1 -0
  251. package/dist/dashboard-gateway/control-plane/entitlements.d.ts +118 -0
  252. package/dist/dashboard-gateway/control-plane/entitlements.js +329 -0
  253. package/dist/dashboard-gateway/control-plane/entitlements.js.map +1 -0
  254. package/dist/dashboard-gateway/control-plane/errors.d.ts +17 -0
  255. package/dist/dashboard-gateway/control-plane/errors.js +23 -0
  256. package/dist/dashboard-gateway/control-plane/errors.js.map +1 -0
  257. package/dist/dashboard-gateway/control-plane/hosts.d.ts +6 -0
  258. package/dist/dashboard-gateway/control-plane/hosts.js +16 -0
  259. package/dist/dashboard-gateway/control-plane/hosts.js.map +1 -0
  260. package/dist/dashboard-gateway/control-plane/http.d.ts +34 -0
  261. package/dist/dashboard-gateway/control-plane/http.js +331 -0
  262. package/dist/dashboard-gateway/control-plane/http.js.map +1 -0
  263. package/dist/dashboard-gateway/control-plane/schema.d.ts +9 -0
  264. package/dist/dashboard-gateway/control-plane/schema.js +247 -0
  265. package/dist/dashboard-gateway/control-plane/schema.js.map +1 -0
  266. package/dist/dashboard-gateway/control-plane/secrets.d.ts +20 -0
  267. package/dist/dashboard-gateway/control-plane/secrets.js +39 -0
  268. package/dist/dashboard-gateway/control-plane/secrets.js.map +1 -0
  269. package/dist/dashboard-gateway/control-plane/store.d.ts +579 -0
  270. package/dist/dashboard-gateway/control-plane/store.js +1115 -0
  271. package/dist/dashboard-gateway/control-plane/store.js.map +1 -0
  272. package/dist/dashboard-gateway/cookie-boundary.d.ts +60 -0
  273. package/dist/dashboard-gateway/cookie-boundary.js +205 -0
  274. package/dist/dashboard-gateway/cookie-boundary.js.map +1 -0
  275. package/dist/dashboard-gateway/index.js +271 -494
  276. package/dist/dashboard-gateway/index.js.map +1 -1
  277. package/dist/dashboard-gateway/main.js +7 -2
  278. package/dist/dashboard-gateway/main.js.map +1 -1
  279. package/dist/dashboard-gateway/routing.d.ts +43 -0
  280. package/dist/dashboard-gateway/routing.js +65 -0
  281. package/dist/dashboard-gateway/routing.js.map +1 -0
  282. package/dist/dashboard-gateway/tenant-gateway.d.ts +56 -0
  283. package/dist/dashboard-gateway/tenant-gateway.js +989 -0
  284. package/dist/dashboard-gateway/tenant-gateway.js.map +1 -0
  285. package/dist/dashboard-gateway/tenant-main.d.ts +41 -0
  286. package/dist/dashboard-gateway/tenant-main.js +303 -0
  287. package/dist/dashboard-gateway/tenant-main.js.map +1 -0
  288. package/dist/dashboard-gateway/tunnel-errors.d.ts +16 -0
  289. package/dist/dashboard-gateway/tunnel-errors.js +22 -0
  290. package/dist/dashboard-gateway/tunnel-errors.js.map +1 -0
  291. package/dist/dashboard-gateway/tunnel-http.d.ts +21 -0
  292. package/dist/dashboard-gateway/tunnel-http.js +195 -0
  293. package/dist/dashboard-gateway/tunnel-http.js.map +1 -0
  294. package/dist/elaris/config.d.ts +10 -0
  295. package/dist/elaris/config.js +27 -1
  296. package/dist/elaris/config.js.map +1 -1
  297. package/dist/elaris/tools.js +4 -1
  298. package/dist/elaris/tools.js.map +1 -1
  299. package/dist/handler.d.ts +6 -0
  300. package/dist/handler.js +17 -1
  301. package/dist/handler.js.map +1 -1
  302. package/dist/index.d.ts +0 -31
  303. package/dist/index.js +41 -404
  304. package/dist/index.js.map +1 -1
  305. package/dist/lib.d.ts +17 -0
  306. package/dist/lib.js +17 -0
  307. package/dist/lib.js.map +1 -0
  308. package/dist/local-clink-backend.d.ts +2 -1
  309. package/dist/local-clink-backend.js +28 -4
  310. package/dist/local-clink-backend.js.map +1 -1
  311. package/dist/parsers/extract.d.ts +19 -1
  312. package/dist/parsers/extract.js +68 -3
  313. package/dist/parsers/extract.js.map +1 -1
  314. package/dist/pipeline.d.ts +17 -1
  315. package/dist/pipeline.js +34 -6
  316. package/dist/pipeline.js.map +1 -1
  317. package/dist/process-group.d.ts +65 -0
  318. package/dist/process-group.js +153 -0
  319. package/dist/process-group.js.map +1 -0
  320. package/dist/progress-report/lock.d.ts +17 -59
  321. package/dist/progress-report/lock.js +25 -329
  322. package/dist/progress-report/lock.js.map +1 -1
  323. package/dist/progress-report/schema.d.ts +23 -23
  324. package/dist/project-verification/files.js +1 -1
  325. package/dist/project-verification/files.js.map +1 -1
  326. package/dist/project-verification/process.js +23 -44
  327. package/dist/project-verification/process.js.map +1 -1
  328. package/dist/project-verification/service.js +9 -1
  329. package/dist/project-verification/service.js.map +1 -1
  330. package/dist/prompt.d.ts +7 -0
  331. package/dist/prompt.js +18 -1
  332. package/dist/prompt.js.map +1 -1
  333. package/dist/recipe-host/git-trust.d.ts +43 -0
  334. package/dist/recipe-host/git-trust.js +360 -0
  335. package/dist/recipe-host/git-trust.js.map +1 -0
  336. package/dist/recipe-host/git.d.ts +42 -0
  337. package/dist/recipe-host/git.js +207 -0
  338. package/dist/recipe-host/git.js.map +1 -0
  339. package/dist/recipe-host/native-recipe-host.d.ts +127 -0
  340. package/dist/recipe-host/native-recipe-host.js +880 -0
  341. package/dist/recipe-host/native-recipe-host.js.map +1 -0
  342. package/dist/recipe-host/seat-cwd.d.ts +16 -0
  343. package/dist/recipe-host/seat-cwd.js +170 -0
  344. package/dist/recipe-host/seat-cwd.js.map +1 -0
  345. package/dist/runner.d.ts +43 -1
  346. package/dist/runner.js +234 -35
  347. package/dist/runner.js.map +1 -1
  348. package/dist/server.js +84 -5
  349. package/dist/server.js.map +1 -1
  350. package/dist/settings-cli/clients.d.ts +137 -0
  351. package/dist/settings-cli/clients.js +1124 -0
  352. package/dist/settings-cli/clients.js.map +1 -0
  353. package/dist/settings-cli/commands.d.ts +67 -0
  354. package/dist/settings-cli/commands.js +726 -0
  355. package/dist/settings-cli/commands.js.map +1 -0
  356. package/dist/settings-cli/format.d.ts +34 -0
  357. package/dist/settings-cli/format.js +40 -0
  358. package/dist/settings-cli/format.js.map +1 -0
  359. package/dist/settings-cli/main.d.ts +18 -0
  360. package/dist/settings-cli/main.js +256 -0
  361. package/dist/settings-cli/main.js.map +1 -0
  362. package/dist/stdio-main.d.ts +73 -0
  363. package/dist/stdio-main.js +455 -0
  364. package/dist/stdio-main.js.map +1 -0
  365. package/docs/configuration.md +362 -40
  366. package/docs/engineering-recipes.md +291 -0
  367. package/docs/security.md +234 -6
  368. package/docs/verification/project-checks.md +24 -2
  369. package/package.json +6 -2
  370. package/clinkx-workflows/dist/dashboard-ui/assets/index-BdpmbPps.js +0 -115
  371. package/clinkx-workflows/dist/dashboard-ui/assets/style-Im5i1iAs.css +0 -1
@@ -0,0 +1,280 @@
1
+ import { z } from "zod";
2
+ export const CONTROL_PATH_PREFIX = "/api/control/";
3
+ /** One subscription covers at most this many live workstations. */
4
+ export const MAX_WORKSTATIONS = 2;
5
+ const OPAQUE_SECRET_BODY = "[A-Za-z0-9_-]{43}";
6
+ function opaqueSecret(prefix) {
7
+ return z.string().regex(new RegExp(`^${prefix}_${OPAQUE_SECRET_BODY}$`));
8
+ }
9
+ /** A workstation API key: the companion's static device credential. */
10
+ export const DeviceCredentialSchema = opaqueSecret("clxd");
11
+ function prefixedId(prefix) {
12
+ return z.string().regex(new RegExp(`^${prefix}_[A-Za-z0-9_-]{16,64}$`));
13
+ }
14
+ export const AccountIdSchema = prefixedId("acc");
15
+ export const TenantIdSchema = prefixedId("ten");
16
+ export const CompanionIdSchema = prefixedId("cmp");
17
+ export const CredentialIdSchema = prefixedId("cred");
18
+ export const UtcTimestampSchema = z.string().datetime();
19
+ function secureUrl(protocols) {
20
+ return z.string().max(4096).refine((value) => {
21
+ let parsed;
22
+ try {
23
+ parsed = new URL(value);
24
+ }
25
+ catch {
26
+ return false;
27
+ }
28
+ return protocols.includes(parsed.protocol) && parsed.username === "" && parsed.password === "";
29
+ }, { message: "must be an absolute URL without credentials" });
30
+ }
31
+ export const HttpsUrlSchema = secureUrl(["https:"]);
32
+ export const ControlErrorCodeSchema = z.enum([
33
+ "unauthenticated",
34
+ "auth_failed",
35
+ "forbidden",
36
+ "not_member",
37
+ "not_found",
38
+ "method_not_allowed",
39
+ "misdirected_request",
40
+ "credential_revoked",
41
+ "entitlement_inactive",
42
+ "context_mismatch",
43
+ "not_active",
44
+ "workstation_limit",
45
+ "workstation_not_found",
46
+ "workstation_required",
47
+ "subscription_active",
48
+ "payload_too_large",
49
+ "invalid_request",
50
+ "webhook_signature_invalid",
51
+ "rate_limited",
52
+ "outcome_unknown",
53
+ "store_unavailable",
54
+ "provider_unavailable",
55
+ "companion_offline",
56
+ ]);
57
+ export const CONTROL_ERROR_HTTP_STATUS = {
58
+ unauthenticated: 401,
59
+ auth_failed: 401,
60
+ forbidden: 403,
61
+ not_member: 403,
62
+ not_found: 404,
63
+ method_not_allowed: 405,
64
+ misdirected_request: 421,
65
+ credential_revoked: 401,
66
+ entitlement_inactive: 402,
67
+ context_mismatch: 409,
68
+ not_active: 409,
69
+ workstation_limit: 409,
70
+ workstation_not_found: 404,
71
+ workstation_required: 400,
72
+ subscription_active: 409,
73
+ payload_too_large: 413,
74
+ invalid_request: 400,
75
+ webhook_signature_invalid: 400,
76
+ rate_limited: 429,
77
+ outcome_unknown: 502,
78
+ store_unavailable: 503,
79
+ provider_unavailable: 503,
80
+ companion_offline: 503,
81
+ };
82
+ export const ControlErrorResponseSchema = z
83
+ .object({
84
+ error: z
85
+ .object({
86
+ code: ControlErrorCodeSchema,
87
+ message: z.string().min(1).max(500).optional(),
88
+ })
89
+ .strict(),
90
+ })
91
+ .strict();
92
+ const EmptyBodySchema = z.object({}).strict();
93
+ export const WorkspaceSummarySchema = z.object({ id: TenantIdSchema }).strict();
94
+ export const MembershipRoleSchema = z.enum(["owner"]);
95
+ export const AccountSummarySchema = z
96
+ .object({ id: AccountIdSchema, display_name: z.string().min(1).max(200).nullable() })
97
+ .strict();
98
+ export const AuthStartRequestSchema = EmptyBodySchema;
99
+ export const AuthStartResponseSchema = z.object({ authorization_url: HttpsUrlSchema }).strict();
100
+ // The provider authors this query and may append parameters (iss, session_state, ...);
101
+ // unknown keys are dropped rather than trusted, and openid-client re-validates the full URL.
102
+ export const AuthCallbackQuerySchema = z
103
+ .object({
104
+ state: z.string().min(1).max(512),
105
+ code: z.string().min(1).max(4096).optional(),
106
+ error: z.string().min(1).max(256).optional(),
107
+ error_description: z.string().max(1024).optional(),
108
+ })
109
+ .strip()
110
+ .refine((value) => (value.code === undefined) !== (value.error === undefined), {
111
+ message: "exactly one of code or error is required",
112
+ });
113
+ export const AuthLogoutRequestSchema = EmptyBodySchema;
114
+ export const AuthLogoutResponseSchema = z.object({ logged_out: z.literal(true) }).strict();
115
+ export const AuthSessionResponseSchema = z
116
+ .object({ account: AccountSummarySchema, expires_at: UtcTimestampSchema })
117
+ .strict();
118
+ export const SubscriptionStateSchema = z.enum([
119
+ "none",
120
+ "active",
121
+ "trialing",
122
+ "past_due",
123
+ "incomplete",
124
+ "incomplete_expired",
125
+ "unpaid",
126
+ "canceled",
127
+ "paused",
128
+ "unknown",
129
+ ]);
130
+ export const AccessReasonSchema = z.enum([
131
+ "paid_period",
132
+ "past_due_grace",
133
+ "period_ended",
134
+ "grace_expired",
135
+ "no_purchase",
136
+ "payment_pending",
137
+ "subscription_inactive",
138
+ "unknown_state",
139
+ "suspended",
140
+ "operator_grant",
141
+ ]);
142
+ export const EntitlementStatusSchema = z
143
+ .object({
144
+ access: z.enum(["granted", "denied"]),
145
+ reason: AccessReasonSchema,
146
+ subscription_state: SubscriptionStateSchema,
147
+ access_until: UtcTimestampSchema.nullable(),
148
+ grace_deadline: UtcTimestampSchema.nullable(),
149
+ suspended: z.boolean(),
150
+ /** The unexpired operator grant's cutoff, else `null`. */
151
+ grant_until: UtcTimestampSchema.nullable(),
152
+ last_reconciled_at: UtcTimestampSchema.nullable(),
153
+ stale: z.boolean(),
154
+ })
155
+ .strict()
156
+ .refine((value) => value.access === "denied" || value.access_until !== null, {
157
+ message: "granted access requires a stored cutoff",
158
+ path: ["access_until"],
159
+ })
160
+ .refine((value) => !value.suspended || value.access === "denied", {
161
+ message: "suspension always denies access",
162
+ path: ["access"],
163
+ });
164
+ export const WorkstationLabelSchema = z.string().min(1).max(64).regex(/^[\x20-\x7e]+$/);
165
+ export const WorkstationConnectionSchema = z
166
+ .object({
167
+ state: z.enum(["offline", "online"]),
168
+ connection_generation: z.number().int().nonnegative().nullable(),
169
+ })
170
+ .strict()
171
+ .refine((value) => (value.state === "online") === (value.connection_generation !== null), {
172
+ message: "an online workstation has a connection generation and an offline one has none",
173
+ path: ["connection_generation"],
174
+ });
175
+ export const WorkstationSummarySchema = z
176
+ .object({
177
+ companion_id: CompanionIdSchema,
178
+ label: WorkstationLabelSchema,
179
+ created_at: UtcTimestampSchema,
180
+ key_issued_at: UtcTimestampSchema.nullable(),
181
+ connection: WorkstationConnectionSchema,
182
+ })
183
+ .strict();
184
+ export const WorkspaceReadResponseSchema = z
185
+ .object({
186
+ workspace: WorkspaceSummarySchema,
187
+ role: MembershipRoleSchema,
188
+ entitlement: EntitlementStatusSchema,
189
+ /** `false`: the billing routes do not exist and access comes only from operator grants. */
190
+ billing_enabled: z.boolean(),
191
+ max_workstations: z.literal(MAX_WORKSTATIONS),
192
+ workstations: z.array(WorkstationSummarySchema).max(MAX_WORKSTATIONS),
193
+ })
194
+ .strict();
195
+ export const WorkstationCreateRequestSchema = z.object({ label: WorkstationLabelSchema }).strict();
196
+ /** The API key is returned exactly once, here or on rotation; no read route ever returns it. */
197
+ export const WorkstationCreateResponseSchema = z
198
+ .object({ workstation: WorkstationSummarySchema, api_key: DeviceCredentialSchema })
199
+ .strict();
200
+ export const WorkstationRotateRequestSchema = z.object({ companion_id: CompanionIdSchema }).strict();
201
+ export const WorkstationRotateResponseSchema = z
202
+ .object({
203
+ companion_id: CompanionIdSchema,
204
+ api_key: DeviceCredentialSchema,
205
+ revoked_credential_id: CredentialIdSchema.nullable(),
206
+ closed_connections: z.number().int().nonnegative(),
207
+ })
208
+ .strict();
209
+ export const WorkstationRevokeRequestSchema = z.object({ companion_id: CompanionIdSchema }).strict();
210
+ export const WorkstationRevokeResponseSchema = z
211
+ .object({
212
+ companion_id: CompanionIdSchema,
213
+ revoked_at: UtcTimestampSchema,
214
+ closed_connections: z.number().int().nonnegative(),
215
+ })
216
+ .strict();
217
+ export const BillingStatusResponseSchema = z.object({ entitlement: EntitlementStatusSchema }).strict();
218
+ export const CheckoutSessionRequestSchema = EmptyBodySchema;
219
+ export const CheckoutSessionResponseSchema = z.object({ checkout_url: HttpsUrlSchema }).strict();
220
+ export const PortalSessionRequestSchema = EmptyBodySchema;
221
+ export const PortalSessionResponseSchema = z.object({ portal_url: HttpsUrlSchema }).strict();
222
+ export const StripeWebhookAckSchema = z
223
+ .object({
224
+ received: z.literal(true),
225
+ event_id: z.string().regex(/^evt_[A-Za-z0-9]{1,255}$/),
226
+ duplicate: z.boolean(),
227
+ })
228
+ .strict();
229
+ /** Every control route, on the single public origin. */
230
+ export const CONTROL_ROUTES = {
231
+ authStart: {
232
+ method: "POST", path: "/api/control/auth/start", authority: "none",
233
+ request: AuthStartRequestSchema, response: AuthStartResponseSchema,
234
+ },
235
+ authCallback: {
236
+ method: "GET", path: "/api/control/auth/callback", authority: "oidc_state",
237
+ request: AuthCallbackQuerySchema, response: null,
238
+ },
239
+ authLogout: {
240
+ method: "POST", path: "/api/control/auth/logout", authority: "account_session",
241
+ request: AuthLogoutRequestSchema, response: AuthLogoutResponseSchema,
242
+ },
243
+ authSession: {
244
+ method: "GET", path: "/api/control/auth/session", authority: "account_session",
245
+ request: null, response: AuthSessionResponseSchema,
246
+ },
247
+ workspaceRead: {
248
+ method: "GET", path: "/api/control/workspace", authority: "workspace_owner",
249
+ request: null, response: WorkspaceReadResponseSchema,
250
+ },
251
+ workstationCreate: {
252
+ method: "POST", path: "/api/control/workstations", authority: "workspace_owner",
253
+ request: WorkstationCreateRequestSchema, response: WorkstationCreateResponseSchema,
254
+ },
255
+ workstationRotate: {
256
+ method: "POST", path: "/api/control/workstations/rotate", authority: "workspace_owner",
257
+ request: WorkstationRotateRequestSchema, response: WorkstationRotateResponseSchema,
258
+ },
259
+ workstationRevoke: {
260
+ method: "POST", path: "/api/control/workstations/revoke", authority: "workspace_owner",
261
+ request: WorkstationRevokeRequestSchema, response: WorkstationRevokeResponseSchema,
262
+ },
263
+ billingStatus: {
264
+ method: "GET", path: "/api/control/billing/status", authority: "workspace_owner",
265
+ request: null, response: BillingStatusResponseSchema,
266
+ },
267
+ billingCheckout: {
268
+ method: "POST", path: "/api/control/billing/checkout", authority: "workspace_owner",
269
+ request: CheckoutSessionRequestSchema, response: CheckoutSessionResponseSchema,
270
+ },
271
+ billingPortal: {
272
+ method: "POST", path: "/api/control/billing/portal", authority: "workspace_owner",
273
+ request: PortalSessionRequestSchema, response: PortalSessionResponseSchema,
274
+ },
275
+ stripeWebhook: {
276
+ method: "POST", path: "/api/control/billing/webhook", authority: "stripe_signature",
277
+ request: null, response: StripeWebhookAckSchema,
278
+ },
279
+ };
280
+ //# sourceMappingURL=contracts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../../src/dashboard-gateway/control-plane/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,mBAAmB,GAAG,eAAe,CAAC;AAEnD,mEAAmE;AACnE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAElC,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AAE/C,SAAS,YAAY,CAAC,MAAc;IAClC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,IAAI,MAAM,IAAI,kBAAkB,GAAG,CAAC,CAAC,CAAC;AAC3E,CAAC;AAED,uEAAuE;AACvE,MAAM,CAAC,MAAM,sBAAsB,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;AAE3D,SAAS,UAAU,CAAC,MAAc;IAChC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,IA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F,OAAO,EAAE,8BAA8B,EAAE,QAAQ,EAAE,+BAA+B;KACnF;IACD,aAAa,EAAE;QACb,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,6BAA6B,EAAE,SAAS,EAAE,iBAAiB;QAChF,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,2BAA2B;KACrD;IACD,eAAe,EAAE;QACf,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,+BAA+B,EAAE,SAAS,EAAE,iBAAiB;QACnF,OAAO,EAAE,4BAA4B,EAAE,QAAQ,EAAE,6BAA6B;KAC/E;IACD,aAAa,EAAE;QACb,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,6BAA6B,EAAE,SAAS,EAAE,iBAAiB;QACjF,OAAO,EAAE,0BAA0B,EAAE,QAAQ,EAAE,2BAA2B;KAC3E;IACD,aAAa,EAAE;QACb,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,8BAA8B,EAAE,SAAS,EAAE,kBAAkB;QACnF,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,sBAAsB;KAChD;CAC8C,CAAC"}
@@ -0,0 +1,13 @@
1
+ export declare const ACCOUNT_SESSION_COOKIE = "__Host-clinkx-account";
2
+ /** Binds a pending OIDC login to the browser that started it (login CSRF). */
3
+ export declare const LOGIN_BINDING_COOKIE = "__Host-clinkx-login";
4
+ /** Every cloud cookie name. None of them may cross the companion tunnel in either direction. */
5
+ export declare const CLOUD_COOKIE_NAMES: readonly ["__Host-clinkx-cloud", "__Host-clinkx-account", "__Host-clinkx-handoff", "__Host-clinkx-login"];
6
+ export declare function serializeHostCookie(name: string, value: string, maxAgeSeconds: number): string;
7
+ export declare function clearHostCookie(name: string): string;
8
+ /**
9
+ * Read one cookie value. A repeated name is ambiguous (a sibling-domain cookie
10
+ * can sit next to the host-only one), so it reads as absent and the request is
11
+ * treated as unauthenticated rather than picking either value.
12
+ */
13
+ export declare function readSingleCookie(header: string | undefined, name: string): string | null;
@@ -0,0 +1,46 @@
1
+ export const ACCOUNT_SESSION_COOKIE = "__Host-clinkx-account";
2
+ /** Binds a pending OIDC login to the browser that started it (login CSRF). */
3
+ export const LOGIN_BINDING_COOKIE = "__Host-clinkx-login";
4
+ /** Names of the retired subdomain model. No longer issued, but still never allowed across the tunnel. */
5
+ const RETIRED_CLOUD_COOKIE_NAMES = ["__Host-clinkx-cloud", "__Host-clinkx-handoff"];
6
+ /** Every cloud cookie name. None of them may cross the companion tunnel in either direction. */
7
+ export const CLOUD_COOKIE_NAMES = Object.freeze([
8
+ RETIRED_CLOUD_COOKIE_NAMES[0],
9
+ ACCOUNT_SESSION_COOKIE,
10
+ RETIRED_CLOUD_COOKIE_NAMES[1],
11
+ LOGIN_BINDING_COOKIE,
12
+ ]);
13
+ const COOKIE_VALUE = /^[A-Za-z0-9_-]{1,512}$/;
14
+ export function serializeHostCookie(name, value, maxAgeSeconds) {
15
+ if (!COOKIE_VALUE.test(value))
16
+ throw new Error("cookie value must be base64url");
17
+ const maxAge = Math.max(0, Math.floor(maxAgeSeconds));
18
+ return `${name}=${value}; Path=/; Max-Age=${maxAge}; Secure; HttpOnly; SameSite=Lax`;
19
+ }
20
+ export function clearHostCookie(name) {
21
+ return `${name}=; Path=/; Max-Age=0; Secure; HttpOnly; SameSite=Lax`;
22
+ }
23
+ /**
24
+ * Read one cookie value. A repeated name is ambiguous (a sibling-domain cookie
25
+ * can sit next to the host-only one), so it reads as absent and the request is
26
+ * treated as unauthenticated rather than picking either value.
27
+ */
28
+ export function readSingleCookie(header, name) {
29
+ if (header === undefined || header.length === 0 || header.length > 16 * 1024)
30
+ return null;
31
+ let found = null;
32
+ let seen = 0;
33
+ for (const pair of header.split(";")) {
34
+ const separator = pair.indexOf("=");
35
+ if (separator === -1)
36
+ continue;
37
+ if (pair.slice(0, separator).trim() !== name)
38
+ continue;
39
+ seen += 1;
40
+ found = pair.slice(separator + 1).trim();
41
+ }
42
+ if (seen !== 1 || found === null || !COOKIE_VALUE.test(found))
43
+ return null;
44
+ return found;
45
+ }
46
+ //# sourceMappingURL=cookies.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cookies.js","sourceRoot":"","sources":["../../../src/dashboard-gateway/control-plane/cookies.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG,uBAAuB,CAAC;AAC9D,8EAA8E;AAC9E,MAAM,CAAC,MAAM,oBAAoB,GAAG,qBAAqB,CAAC;AAE1D,yGAAyG;AACzG,MAAM,0BAA0B,GAAG,CAAC,qBAAqB,EAAE,uBAAuB,CAAU,CAAC;AAE7F,gGAAgG;AAChG,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC9C,0BAA0B,CAAC,CAAC,CAAC;IAC7B,sBAAsB;IACtB,0BAA0B,CAAC,CAAC,CAAC;IAC7B,oBAAoB;CACZ,CAAC,CAAC;AAEZ,MAAM,YAAY,GAAG,wBAAwB,CAAC;AAE9C,MAAM,UAAU,mBAAmB,CAAC,IAAY,EAAE,KAAa,EAAE,aAAqB;IACpF,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACjF,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;IACtD,OAAO,GAAG,IAAI,IAAI,KAAK,qBAAqB,MAAM,kCAAkC,CAAC;AACvF,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,OAAO,GAAG,IAAI,sDAAsD,CAAC;AACvE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAA0B,EAAE,IAAY;IACvE,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,GAAG,EAAE,GAAG,IAAI;QAAE,OAAO,IAAI,CAAC;IAC1F,IAAI,KAAK,GAAkB,IAAI,CAAC;IAChC,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACrC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACpC,IAAI,SAAS,KAAK,CAAC,CAAC;YAAE,SAAS;QAC/B,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,IAAI,EAAE,KAAK,IAAI;YAAE,SAAS;QACvD,IAAI,IAAI,CAAC,CAAC;QACV,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC3C,CAAC;IACD,IAAI,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAC3E,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,63 @@
1
+ import type { ControlPlaneStore, SessionActor, TenantRecord, WorkstationRecord } from "./store.js";
2
+ export interface DeviceCredentialAuthorityOptions {
3
+ readonly store: ControlPlaneStore;
4
+ }
5
+ export interface IssuedWorkstation {
6
+ readonly workstation: WorkstationRecord;
7
+ /** Shown once. Only its verifier is stored. */
8
+ readonly apiKey: string;
9
+ }
10
+ export interface WorkstationKeyRotation {
11
+ readonly companionId: string;
12
+ /** Shown once. Only its verifier is stored. */
13
+ readonly apiKey: string;
14
+ readonly revokedCredentialId: string | null;
15
+ }
16
+ export interface WorkstationRevocation {
17
+ readonly companionId: string;
18
+ readonly revokedAt: number;
19
+ }
20
+ export type DeviceCredentialCheck = {
21
+ readonly ok: true;
22
+ readonly tenant: TenantRecord;
23
+ readonly credentialId: string;
24
+ readonly companionId: string;
25
+ } | {
26
+ readonly ok: false;
27
+ readonly code: "unauthenticated" | "credential_revoked";
28
+ };
29
+ /**
30
+ * Workstation API keys: owner-issued device credentials, one per workstation.
31
+ * They are a distinct secret type with their own verifier purpose and table,
32
+ * so a key can never resolve as a browser session and a session never as a key.
33
+ * A key never expires: it lives until it is rotated or its workstation is revoked.
34
+ */
35
+ export declare class DeviceCredentialAuthority {
36
+ private readonly store;
37
+ constructor(options: DeviceCredentialAuthorityOptions);
38
+ private newKey;
39
+ createWorkstation(input: {
40
+ tenantId: string;
41
+ actor: SessionActor;
42
+ label: string;
43
+ }): IssuedWorkstation;
44
+ rotateWorkstationKey(input: {
45
+ tenantId: string;
46
+ companionId: string;
47
+ actor: SessionActor;
48
+ }): WorkstationKeyRotation;
49
+ revokeWorkstation(input: {
50
+ tenantId: string;
51
+ companionId: string;
52
+ actor: SessionActor;
53
+ }): WorkstationRevocation;
54
+ listWorkstations(tenantId: string): WorkstationRecord[];
55
+ /** A live workstation of this tenant, or `null`. Never resolves another tenant's companion. */
56
+ findLiveWorkstation(tenantId: string, companionId: string): WorkstationRecord | null;
57
+ /**
58
+ * Authenticate a companion presenting its API key (the `/agent` upgrade).
59
+ * The tenant comes from the credential record, never from the caller. Store
60
+ * failures throw `ControlStoreUnavailableError`; callers deny.
61
+ */
62
+ verifyDeviceCredential(secret: string | null): DeviceCredentialCheck;
63
+ }
@@ -0,0 +1,66 @@
1
+ import { ControlError } from "./errors.js";
2
+ import { SECRET_PREFIX, deriveVerifier, generateOpaqueSecret, isOpaqueSecret } from "./secrets.js";
3
+ /**
4
+ * Workstation API keys: owner-issued device credentials, one per workstation.
5
+ * They are a distinct secret type with their own verifier purpose and table,
6
+ * so a key can never resolve as a browser session and a session never as a key.
7
+ * A key never expires: it lives until it is rotated or its workstation is revoked.
8
+ */
9
+ export class DeviceCredentialAuthority {
10
+ store;
11
+ constructor(options) {
12
+ this.store = options.store;
13
+ }
14
+ newKey() {
15
+ const apiKey = generateOpaqueSecret(SECRET_PREFIX.deviceCredential);
16
+ return { apiKey, credential: { verifier: deriveVerifier("device_credential", apiKey) } };
17
+ }
18
+ createWorkstation(input) {
19
+ const { apiKey, credential } = this.newKey();
20
+ const result = this.store.createWorkstation({ ...input, credential });
21
+ if (result.status !== "ok") {
22
+ throw new ControlError(result.status === "unauthorized" ? "unauthenticated" : result.status);
23
+ }
24
+ return { workstation: result.workstation, apiKey };
25
+ }
26
+ rotateWorkstationKey(input) {
27
+ const { apiKey, credential } = this.newKey();
28
+ const result = this.store.rotateWorkstationKey({ ...input, credential });
29
+ if (result.status !== "ok") {
30
+ if (result.status === "not_active")
31
+ throw new ControlError("not_active", "workstation is revoked");
32
+ throw new ControlError(result.status === "unauthorized" ? "unauthenticated" : "workstation_not_found");
33
+ }
34
+ return { companionId: input.companionId, apiKey, revokedCredentialId: result.revokedCredentialId };
35
+ }
36
+ revokeWorkstation(input) {
37
+ const result = this.store.revokeWorkstation(input);
38
+ if (result.status !== "ok") {
39
+ throw new ControlError(result.status === "unauthorized" ? "unauthenticated" : "workstation_not_found");
40
+ }
41
+ return { companionId: input.companionId, revokedAt: result.revokedAt };
42
+ }
43
+ listWorkstations(tenantId) {
44
+ return this.store.listWorkstations(tenantId);
45
+ }
46
+ /** A live workstation of this tenant, or `null`. Never resolves another tenant's companion. */
47
+ findLiveWorkstation(tenantId, companionId) {
48
+ return this.store.findLiveWorkstation(tenantId, companionId);
49
+ }
50
+ /**
51
+ * Authenticate a companion presenting its API key (the `/agent` upgrade).
52
+ * The tenant comes from the credential record, never from the caller. Store
53
+ * failures throw `ControlStoreUnavailableError`; callers deny.
54
+ */
55
+ verifyDeviceCredential(secret) {
56
+ if (secret === null || !isOpaqueSecret(SECRET_PREFIX.deviceCredential, secret)) {
57
+ return { ok: false, code: "unauthenticated" };
58
+ }
59
+ const result = this.store.verifyDeviceCredential(deriveVerifier("device_credential", secret));
60
+ if (result.status === "ok") {
61
+ return { ok: true, tenant: result.tenant, credentialId: result.credentialId, companionId: result.companionId };
62
+ }
63
+ return { ok: false, code: result.status === "unknown" ? "unauthenticated" : "credential_revoked" };
64
+ }
65
+ }
66
+ //# sourceMappingURL=credentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials.js","sourceRoot":"","sources":["../../../src/dashboard-gateway/control-plane/credentials.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAkCnG;;;;;GAKG;AACH,MAAM,OAAO,yBAAyB;IACnB,KAAK,CAAoB;IAE1C,YAAY,OAAyC;QACnD,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAC7B,CAAC;IAEO,MAAM;QACZ,MAAM,MAAM,GAAG,oBAAoB,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;QACpE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,QAAQ,EAAE,cAAc,CAAC,mBAAmB,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC;IAC3F,CAAC;IAED,iBAAiB,CAAC,KAA+D;QAC/E,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE,GAAG,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;QACtE,IAAI,MAAM,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC;YAC3B,MAAM,IAAI,YAAY,CAAC,MAAM,CAAC,MAAM,KAAK,cAAc,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC/F,CAAC;QACD,OAAO,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC;IACrD,CAAC;IAED,oBAAoB,CAAC,KAAqE;QACxF,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,G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AAC;IAED;;;;OAIG;IACH,sBAAsB,CAAC,MAAqB;QAC1C,IAAI,MAAM,KAAK,IAAI,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,gBAAgB,EAAE,MAAM,CAAC,EAAE,CAAC;YAC/E,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC;QAChD,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,sBAAsB,CAAC,cAAc,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC,CAAC;QAC9F,IAAI,MAAM,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC;YAC3B,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,CAAC,YAAY,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC;QACjH,CAAC;QACD,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,oBAAoB,EAAE,CAAC;IACrG,CAAC;CACF"}
@@ -0,0 +1,118 @@
1
+ import type { EntitlementStatus } from "./contracts.js";
2
+ import type { ApplyPastDueResult, CompletePurchaseBinding, ControlPlaneStore, EntitlementRecord, OpenInvoiceObligation } from "./store.js";
3
+ export type AccessReason = EntitlementStatus["reason"];
4
+ export interface AccessDecision {
5
+ readonly allowed: boolean;
6
+ readonly reason: AccessReason;
7
+ /** UTC milliseconds at which granted access ends; `null` when access is denied. */
8
+ readonly nextDeadline: number | null;
9
+ }
10
+ export type EntitlementAccessFacts = Pick<EntitlementRecord, "subscriptionState" | "currentPeriodEnd" | "graceDeadline" | "suspendedAt" | "grantExpiresAt">;
11
+ /** The operator grant's cutoff while it still allows access, else `null`. */
12
+ export declare function activeGrantUntil(entitlement: Pick<EntitlementAccessFacts, "grantExpiresAt"> | null, now: number): number | null;
13
+ /**
14
+ * The access predicate over stored state and UTC deadlines only. Access ends
15
+ * exactly at the stored cutoff; a missing cutoff is a denial, never perpetual
16
+ * access. Suspension is checked first and nothing in billing state or an
17
+ * operator grant overrides it. An unexpired operator grant allows access on
18
+ * its own; when a purchase also allows, the purchase reason is reported and the
19
+ * later cutoff applies. Device credential revocation is a separate check on the device path.
20
+ */
21
+ export declare function evaluateEntitlementAccess(entitlement: EntitlementAccessFacts | null, now: number): AccessDecision;
22
+ /**
23
+ * Whether a bound purchase is due for reconciliation. Informational only: it
24
+ * never grants, extends, or cuts access.
25
+ */
26
+ export declare function isEntitlementStale(entitlement: Pick<EntitlementRecord, "stripeCustomerId" | "lastReconciledAt"> | null, now: number, maxStalenessMs: number): boolean;
27
+ /** `maxStalenessMs` is `null` when billing is off: nothing reconciles, so nothing is reported stale. */
28
+ export declare function describeEntitlement(entitlement: EntitlementRecord | null, now: number, maxStalenessMs: number | null): EntitlementStatus;
29
+ export type TenantAccessCheck = {
30
+ readonly ok: true;
31
+ } | {
32
+ readonly ok: false;
33
+ readonly code: "entitlement_inactive" | "store_unavailable" | "credential_revoked";
34
+ };
35
+ export interface TenantAccessBillingConfig {
36
+ /** `null` when billing is off: no purchase is ever stale and past-due writes are refused. */
37
+ readonly billing: {
38
+ readonly graceSeconds: number;
39
+ readonly maxStalenessSeconds: number;
40
+ } | null;
41
+ }
42
+ export interface TenantAccessAuthorityOptions {
43
+ readonly store: ControlPlaneStore;
44
+ readonly config: TenantAccessBillingConfig;
45
+ /** Diagnostics for a check that failed closed. */
46
+ readonly onError?: (error: unknown) => void;
47
+ }
48
+ export interface TenantAccessAuthority {
49
+ /** Current entitlement for protected tenant access. Any store failure denies. */
50
+ checkTenantAccess(tenantId: string): Promise<TenantAccessCheck>;
51
+ /** The full decision. Throws `ControlStoreUnavailableError` when the store fails. */
52
+ decideTenantAccess(tenantId: string): AccessDecision;
53
+ /** Wire status for the owner's billing view. Throws when the store fails. */
54
+ entitlementStatus(tenantId: string): EntitlementStatus;
55
+ /** Apply a past-due purchase with the configured grace duration; see `ControlPlaneStore.applyPastDue`. */
56
+ applyPastDue(input: {
57
+ tenantId: string;
58
+ expected: {
59
+ revision: number;
60
+ binding: CompletePurchaseBinding;
61
+ };
62
+ openInvoices: readonly OpenInvoiceObligation[];
63
+ currentPeriodEnd: number | null;
64
+ }): ApplyPastDueResult;
65
+ }
66
+ export declare function createTenantAccessAuthority(options: TenantAccessAuthorityOptions): TenantAccessAuthority;
67
+ /** Node clamps `setTimeout` delays above this to 1 ms. */
68
+ export declare const MAX_TIMER_DELAY_MS = 2147483647;
69
+ export declare const DEFAULT_SCHEDULER_RETRY_MS = 5000;
70
+ /** How often the gateway re-reads every entitlement to observe writes made by another process, such as the admin CLI. */
71
+ export declare const ENTITLEMENT_RESCAN_INTERVAL_MS = 60000;
72
+ export interface SchedulerTimers {
73
+ setTimeout(callback: () => void, delayMs: number): unknown;
74
+ clearTimeout(handle: unknown): void;
75
+ }
76
+ export interface EntitlementDeadlineSchedulerOptions {
77
+ readonly store: ControlPlaneStore;
78
+ /**
79
+ * Called after each change of a tenant's `allowed` value, and for a denial
80
+ * observed at a new entitlement revision; the gateway closes sockets on a denial.
81
+ */
82
+ readonly onAccessChange: (tenantId: string, decision: AccessDecision) => void;
83
+ readonly onError?: (error: unknown) => void;
84
+ /** Clock for timer delays and for expiring known deadlines while the store is unreadable. */
85
+ readonly now?: () => number;
86
+ readonly timers?: SchedulerTimers;
87
+ readonly retryDelayMs?: number;
88
+ /**
89
+ * Full rescan period. In-process writes notify the scheduler directly; a
90
+ * write by another process is only seen by a rescan. `null` (default): none.
91
+ */
92
+ readonly rescanIntervalMs?: number | null;
93
+ }
94
+ export interface EntitlementDeadlineScheduler {
95
+ /** Subscribe to entitlement writes, run the startup expiry scan, and arm the first deadline. */
96
+ start(): void;
97
+ stop(): void;
98
+ /** Re-evaluate every tenant now. */
99
+ rescan(): void;
100
+ /** Re-evaluate one tenant now. Entitlement writes through the store call this automatically. */
101
+ refresh(tenantId: string): void;
102
+ /** UTC milliseconds of the armed wake-up, or `null` when nothing is armed. */
103
+ readonly nextWakeAt: number | null;
104
+ }
105
+ /**
106
+ * One in-process timer for the earliest upcoming access deadline. Stored
107
+ * deadlines stop access without any webhook: the timer re-scans the store when
108
+ * the earliest deadline arrives, and if the store cannot be read then, every
109
+ * known deadline that has passed is still enforced from memory.
110
+ *
111
+ * The startup scan reports every tenant without access, so a gateway that
112
+ * admitted connections before the scan, or a deadline that passed while the
113
+ * process was down, still results in a cutoff. After that a changed `allowed`
114
+ * is reported, and so is a denial read at a different revision than the last
115
+ * observation: between two rescans another process can grant access, let a
116
+ * companion connect, and deny it again, which no change of `allowed` reveals.
117
+ */
118
+ export declare function createEntitlementDeadlineScheduler(options: EntitlementDeadlineSchedulerOptions): EntitlementDeadlineScheduler;