@paperclipai/server 2026.817.0 → 2026.818.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (548) hide show
  1. package/dist/adapters/hermes-gateway-doc.d.ts +1 -1
  2. package/dist/adapters/hermes-gateway-doc.d.ts.map +1 -1
  3. package/dist/adapters/hermes-gateway-doc.js +1 -1
  4. package/dist/adapters/plugin-loader.d.ts.map +1 -1
  5. package/dist/adapters/plugin-loader.js +3 -2
  6. package/dist/adapters/plugin-loader.js.map +1 -1
  7. package/dist/agent-auth-jwt.d.ts.map +1 -1
  8. package/dist/agent-auth-jwt.js +8 -2
  9. package/dist/agent-auth-jwt.js.map +1 -1
  10. package/dist/app.d.ts +5 -1
  11. package/dist/app.d.ts.map +1 -1
  12. package/dist/app.js +202 -15
  13. package/dist/app.js.map +1 -1
  14. package/dist/built-ins/agents/summarizer/AGENTS.md +2 -2
  15. package/dist/built-ins/agents/summarizer/routines/refresh-stale-summaries.md +1 -0
  16. package/dist/db-errors.d.ts +9 -0
  17. package/dist/db-errors.d.ts.map +1 -1
  18. package/dist/db-errors.js +19 -0
  19. package/dist/db-errors.js.map +1 -1
  20. package/dist/errors.d.ts +1 -1
  21. package/dist/errors.d.ts.map +1 -1
  22. package/dist/errors.js +2 -2
  23. package/dist/errors.js.map +1 -1
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +162 -38
  26. package/dist/index.js.map +1 -1
  27. package/dist/lib/request-promise-memo.d.ts +6 -0
  28. package/dist/lib/request-promise-memo.d.ts.map +1 -0
  29. package/dist/lib/request-promise-memo.js +25 -0
  30. package/dist/lib/request-promise-memo.js.map +1 -0
  31. package/dist/lib/request-promise-memo.test.d.ts +2 -0
  32. package/dist/lib/request-promise-memo.test.d.ts.map +1 -0
  33. package/dist/lib/request-promise-memo.test.js +74 -0
  34. package/dist/lib/request-promise-memo.test.js.map +1 -0
  35. package/dist/middleware/auth.d.ts +13 -1
  36. package/dist/middleware/auth.d.ts.map +1 -1
  37. package/dist/middleware/auth.js +92 -41
  38. package/dist/middleware/auth.js.map +1 -1
  39. package/dist/middleware/cloud-tenant-actor.test.js +26 -1
  40. package/dist/middleware/cloud-tenant-actor.test.js.map +1 -1
  41. package/dist/middleware/error-handler.d.ts.map +1 -1
  42. package/dist/middleware/error-handler.js +11 -2
  43. package/dist/middleware/error-handler.js.map +1 -1
  44. package/dist/middleware/logger.d.ts.map +1 -1
  45. package/dist/middleware/logger.js +7 -33
  46. package/dist/middleware/logger.js.map +1 -1
  47. package/dist/middleware/private-hostname-guard.d.ts.map +1 -1
  48. package/dist/middleware/private-hostname-guard.js +11 -6
  49. package/dist/middleware/private-hostname-guard.js.map +1 -1
  50. package/dist/middleware/private-json-etag.d.ts +3 -0
  51. package/dist/middleware/private-json-etag.d.ts.map +1 -0
  52. package/dist/middleware/private-json-etag.js +37 -0
  53. package/dist/middleware/private-json-etag.js.map +1 -0
  54. package/dist/middleware/redact-sensitive.d.ts.map +1 -1
  55. package/dist/middleware/redact-sensitive.js +11 -0
  56. package/dist/middleware/redact-sensitive.js.map +1 -1
  57. package/dist/realtime/live-events-ws.d.ts +12 -0
  58. package/dist/realtime/live-events-ws.d.ts.map +1 -1
  59. package/dist/realtime/live-events-ws.js +20 -0
  60. package/dist/realtime/live-events-ws.js.map +1 -1
  61. package/dist/redaction.js +1 -1
  62. package/dist/redaction.js.map +1 -1
  63. package/dist/routes/access.d.ts +2 -0
  64. package/dist/routes/access.d.ts.map +1 -1
  65. package/dist/routes/access.js +21 -10
  66. package/dist/routes/access.js.map +1 -1
  67. package/dist/routes/agents.d.ts +42 -0
  68. package/dist/routes/agents.d.ts.map +1 -1
  69. package/dist/routes/agents.js +875 -8
  70. package/dist/routes/agents.js.map +1 -1
  71. package/dist/routes/companies.d.ts +5 -1
  72. package/dist/routes/companies.d.ts.map +1 -1
  73. package/dist/routes/companies.js +467 -30
  74. package/dist/routes/companies.js.map +1 -1
  75. package/dist/routes/environments.d.ts +12 -3
  76. package/dist/routes/environments.d.ts.map +1 -1
  77. package/dist/routes/environments.js +139 -23
  78. package/dist/routes/environments.js.map +1 -1
  79. package/dist/routes/execution-workspaces.d.ts.map +1 -1
  80. package/dist/routes/execution-workspaces.js +240 -70
  81. package/dist/routes/execution-workspaces.js.map +1 -1
  82. package/dist/routes/file-resources.d.ts +14 -1
  83. package/dist/routes/file-resources.d.ts.map +1 -1
  84. package/dist/routes/file-resources.js +182 -3
  85. package/dist/routes/file-resources.js.map +1 -1
  86. package/dist/routes/index.d.ts +2 -1
  87. package/dist/routes/index.d.ts.map +1 -1
  88. package/dist/routes/index.js +2 -1
  89. package/dist/routes/index.js.map +1 -1
  90. package/dist/routes/instance-settings.d.ts.map +1 -1
  91. package/dist/routes/instance-settings.js +20 -1
  92. package/dist/routes/instance-settings.js.map +1 -1
  93. package/dist/routes/issues.d.ts.map +1 -1
  94. package/dist/routes/issues.js +750 -235
  95. package/dist/routes/issues.js.map +1 -1
  96. package/dist/routes/onboarding-seed.d.ts +27 -0
  97. package/dist/routes/onboarding-seed.d.ts.map +1 -0
  98. package/dist/routes/onboarding-seed.js +56 -0
  99. package/dist/routes/onboarding-seed.js.map +1 -0
  100. package/dist/routes/openapi.d.ts.map +1 -1
  101. package/dist/routes/openapi.js +316 -2
  102. package/dist/routes/openapi.js.map +1 -1
  103. package/dist/routes/secrets.d.ts.map +1 -1
  104. package/dist/routes/secrets.js +11 -1
  105. package/dist/routes/secrets.js.map +1 -1
  106. package/dist/routes/setup-token-route.test.d.ts +2 -0
  107. package/dist/routes/setup-token-route.test.d.ts.map +1 -0
  108. package/dist/routes/setup-token-route.test.js +896 -0
  109. package/dist/routes/setup-token-route.test.js.map +1 -0
  110. package/dist/routes/tool-access.d.ts.map +1 -1
  111. package/dist/routes/tool-access.js +87 -52
  112. package/dist/routes/tool-access.js.map +1 -1
  113. package/dist/routes/workspace-runtime-service-authz.d.ts +11 -1
  114. package/dist/routes/workspace-runtime-service-authz.d.ts.map +1 -1
  115. package/dist/routes/workspace-runtime-service-authz.js +18 -16
  116. package/dist/routes/workspace-runtime-service-authz.js.map +1 -1
  117. package/dist/services/access.d.ts.map +1 -1
  118. package/dist/services/activity.d.ts +1 -1
  119. package/dist/services/agents.d.ts +21 -0
  120. package/dist/services/agents.d.ts.map +1 -1
  121. package/dist/services/agents.js +121 -1
  122. package/dist/services/agents.js.map +1 -1
  123. package/dist/services/attention-resolver-audience.test.d.ts +2 -0
  124. package/dist/services/attention-resolver-audience.test.d.ts.map +1 -0
  125. package/dist/services/attention-resolver-audience.test.js +81 -0
  126. package/dist/services/attention-resolver-audience.test.js.map +1 -0
  127. package/dist/services/attention.d.ts +20 -1
  128. package/dist/services/attention.d.ts.map +1 -1
  129. package/dist/services/attention.js +45 -1
  130. package/dist/services/attention.js.map +1 -1
  131. package/dist/services/authorization.d.ts +2 -2
  132. package/dist/services/authorization.d.ts.map +1 -1
  133. package/dist/services/authorization.js +89 -46
  134. package/dist/services/authorization.js.map +1 -1
  135. package/dist/services/board-auth.d.ts.map +1 -1
  136. package/dist/services/board-auth.js +40 -1
  137. package/dist/services/board-auth.js.map +1 -1
  138. package/dist/services/board-auth.test.d.ts +2 -0
  139. package/dist/services/board-auth.test.d.ts.map +1 -0
  140. package/dist/services/board-auth.test.js +34 -0
  141. package/dist/services/board-auth.test.js.map +1 -0
  142. package/dist/services/built-in-agents.d.ts.map +1 -1
  143. package/dist/services/built-in-agents.js +20 -4
  144. package/dist/services/built-in-agents.js.map +1 -1
  145. package/dist/services/bundled-plugins.d.ts +11 -1
  146. package/dist/services/bundled-plugins.d.ts.map +1 -1
  147. package/dist/services/bundled-plugins.js +46 -1
  148. package/dist/services/bundled-plugins.js.map +1 -1
  149. package/dist/services/codex-device-login-reaper.d.ts +61 -0
  150. package/dist/services/codex-device-login-reaper.d.ts.map +1 -0
  151. package/dist/services/codex-device-login-reaper.js +219 -0
  152. package/dist/services/codex-device-login-reaper.js.map +1 -0
  153. package/dist/services/codex-device-login-service.d.ts +355 -0
  154. package/dist/services/codex-device-login-service.d.ts.map +1 -0
  155. package/dist/services/codex-device-login-service.js +775 -0
  156. package/dist/services/codex-device-login-service.js.map +1 -0
  157. package/dist/services/companies.d.ts.map +1 -1
  158. package/dist/services/companies.js +7 -0
  159. package/dist/services/companies.js.map +1 -1
  160. package/dist/services/company-export-readme.js +1 -1
  161. package/dist/services/company-export-readme.js.map +1 -1
  162. package/dist/services/company-import-transfers.d.ts +55 -0
  163. package/dist/services/company-import-transfers.d.ts.map +1 -0
  164. package/dist/services/company-import-transfers.js +151 -0
  165. package/dist/services/company-import-transfers.js.map +1 -0
  166. package/dist/services/company-portability.d.ts.map +1 -1
  167. package/dist/services/company-portability.js +128 -3
  168. package/dist/services/company-portability.js.map +1 -1
  169. package/dist/services/company-transfer-runs.d.ts +136 -0
  170. package/dist/services/company-transfer-runs.d.ts.map +1 -0
  171. package/dist/services/company-transfer-runs.js +243 -0
  172. package/dist/services/company-transfer-runs.js.map +1 -0
  173. package/dist/services/cross-issue-influence-limit.d.ts +7 -1
  174. package/dist/services/cross-issue-influence-limit.d.ts.map +1 -1
  175. package/dist/services/cross-issue-influence-limit.js.map +1 -1
  176. package/dist/services/environment-config.d.ts +15 -0
  177. package/dist/services/environment-config.d.ts.map +1 -1
  178. package/dist/services/environment-config.js +56 -10
  179. package/dist/services/environment-config.js.map +1 -1
  180. package/dist/services/environment-execution-target.d.ts.map +1 -1
  181. package/dist/services/environment-execution-target.js +61 -11
  182. package/dist/services/environment-execution-target.js.map +1 -1
  183. package/dist/services/environment-run-orchestrator.d.ts +16 -1
  184. package/dist/services/environment-run-orchestrator.d.ts.map +1 -1
  185. package/dist/services/environment-run-orchestrator.js +1 -1
  186. package/dist/services/environment-run-orchestrator.js.map +1 -1
  187. package/dist/services/environment-runtime.d.ts +178 -2
  188. package/dist/services/environment-runtime.d.ts.map +1 -1
  189. package/dist/services/environment-runtime.js +1035 -96
  190. package/dist/services/environment-runtime.js.map +1 -1
  191. package/dist/services/environments.d.ts +75 -0
  192. package/dist/services/environments.d.ts.map +1 -1
  193. package/dist/services/environments.js +199 -8
  194. package/dist/services/environments.js.map +1 -1
  195. package/dist/services/execution-allowlist.d.ts +16 -4
  196. package/dist/services/execution-allowlist.d.ts.map +1 -1
  197. package/dist/services/execution-allowlist.js +35 -16
  198. package/dist/services/execution-allowlist.js.map +1 -1
  199. package/dist/services/execution-allowlist.test.js +33 -0
  200. package/dist/services/execution-allowlist.test.js.map +1 -1
  201. package/dist/services/execution-workspace-policy.d.ts +14 -1
  202. package/dist/services/execution-workspace-policy.d.ts.map +1 -1
  203. package/dist/services/execution-workspace-policy.js +29 -12
  204. package/dist/services/execution-workspace-policy.js.map +1 -1
  205. package/dist/services/execution-workspaces.d.ts +89 -0
  206. package/dist/services/execution-workspaces.d.ts.map +1 -1
  207. package/dist/services/execution-workspaces.js +997 -125
  208. package/dist/services/execution-workspaces.js.map +1 -1
  209. package/dist/services/heartbeat-run-summary.d.ts +1 -0
  210. package/dist/services/heartbeat-run-summary.d.ts.map +1 -1
  211. package/dist/services/heartbeat-run-summary.js +19 -3
  212. package/dist/services/heartbeat-run-summary.js.map +1 -1
  213. package/dist/services/heartbeat.d.ts +18 -2
  214. package/dist/services/heartbeat.d.ts.map +1 -1
  215. package/dist/services/heartbeat.js +369 -16
  216. package/dist/services/heartbeat.js.map +1 -1
  217. package/dist/services/import-write-types.d.ts +12 -0
  218. package/dist/services/import-write-types.d.ts.map +1 -1
  219. package/dist/services/index.d.ts +2 -0
  220. package/dist/services/index.d.ts.map +1 -1
  221. package/dist/services/index.js +2 -0
  222. package/dist/services/index.js.map +1 -1
  223. package/dist/services/instance-settings.d.ts +10 -1
  224. package/dist/services/instance-settings.d.ts.map +1 -1
  225. package/dist/services/instance-settings.js +16 -9
  226. package/dist/services/instance-settings.js.map +1 -1
  227. package/dist/services/issue-review-policy.d.ts +4 -0
  228. package/dist/services/issue-review-policy.d.ts.map +1 -1
  229. package/dist/services/issue-review-policy.js +18 -7
  230. package/dist/services/issue-review-policy.js.map +1 -1
  231. package/dist/services/issue-thread-interaction-resolution.d.ts +92 -0
  232. package/dist/services/issue-thread-interaction-resolution.d.ts.map +1 -0
  233. package/dist/services/issue-thread-interaction-resolution.js +198 -0
  234. package/dist/services/issue-thread-interaction-resolution.js.map +1 -0
  235. package/dist/services/issue-thread-interaction-resolution.test.d.ts +2 -0
  236. package/dist/services/issue-thread-interaction-resolution.test.d.ts.map +1 -0
  237. package/dist/services/issue-thread-interaction-resolution.test.js +152 -0
  238. package/dist/services/issue-thread-interaction-resolution.test.js.map +1 -0
  239. package/dist/services/issue-thread-interactions.d.ts +24 -4
  240. package/dist/services/issue-thread-interactions.d.ts.map +1 -1
  241. package/dist/services/issue-thread-interactions.js +360 -145
  242. package/dist/services/issue-thread-interactions.js.map +1 -1
  243. package/dist/services/issue-thread-interactions.test.js +18 -11
  244. package/dist/services/issue-thread-interactions.test.js.map +1 -1
  245. package/dist/services/issues.d.ts +3 -0
  246. package/dist/services/issues.d.ts.map +1 -1
  247. package/dist/services/issues.js +157 -33
  248. package/dist/services/issues.js.map +1 -1
  249. package/dist/services/local-service-supervisor.d.ts +2 -0
  250. package/dist/services/local-service-supervisor.d.ts.map +1 -1
  251. package/dist/services/local-service-supervisor.js +53 -3
  252. package/dist/services/local-service-supervisor.js.map +1 -1
  253. package/dist/services/managed-environments.d.ts +4 -1
  254. package/dist/services/managed-environments.d.ts.map +1 -1
  255. package/dist/services/managed-environments.js +86 -2
  256. package/dist/services/managed-environments.js.map +1 -1
  257. package/dist/services/managed-environments.test.js +164 -0
  258. package/dist/services/managed-environments.test.js.map +1 -1
  259. package/dist/services/onboarding-greeting.d.ts +7 -0
  260. package/dist/services/onboarding-greeting.d.ts.map +1 -0
  261. package/dist/services/onboarding-greeting.js +27 -0
  262. package/dist/services/onboarding-greeting.js.map +1 -0
  263. package/dist/services/onboarding-greeting.test.d.ts +2 -0
  264. package/dist/services/onboarding-greeting.test.d.ts.map +1 -0
  265. package/dist/services/onboarding-greeting.test.js +32 -0
  266. package/dist/services/onboarding-greeting.test.js.map +1 -0
  267. package/dist/services/onboarding-seed.d.ts +57 -0
  268. package/dist/services/onboarding-seed.d.ts.map +1 -0
  269. package/dist/services/onboarding-seed.js +344 -0
  270. package/dist/services/onboarding-seed.js.map +1 -0
  271. package/dist/services/plan-review-context.d.ts +9 -1
  272. package/dist/services/plan-review-context.d.ts.map +1 -1
  273. package/dist/services/plan-review-context.js +192 -0
  274. package/dist/services/plan-review-context.js.map +1 -1
  275. package/dist/services/plugin-environment-driver.d.ts +46 -0
  276. package/dist/services/plugin-environment-driver.d.ts.map +1 -1
  277. package/dist/services/plugin-environment-driver.js +50 -0
  278. package/dist/services/plugin-environment-driver.js.map +1 -1
  279. package/dist/services/plugin-host-services.d.ts +1 -0
  280. package/dist/services/plugin-host-services.d.ts.map +1 -1
  281. package/dist/services/plugin-host-services.js +51 -28
  282. package/dist/services/plugin-host-services.js.map +1 -1
  283. package/dist/services/plugin-loader.d.ts +10 -1
  284. package/dist/services/plugin-loader.d.ts.map +1 -1
  285. package/dist/services/plugin-loader.js +43 -2
  286. package/dist/services/plugin-loader.js.map +1 -1
  287. package/dist/services/plugin-worker-manager.d.ts +61 -0
  288. package/dist/services/plugin-worker-manager.d.ts.map +1 -1
  289. package/dist/services/plugin-worker-manager.js +248 -1
  290. package/dist/services/plugin-worker-manager.js.map +1 -1
  291. package/dist/services/productivity-review.d.ts.map +1 -1
  292. package/dist/services/productivity-review.js +5 -0
  293. package/dist/services/productivity-review.js.map +1 -1
  294. package/dist/services/recovery/service.d.ts.map +1 -1
  295. package/dist/services/recovery/service.js +5 -1
  296. package/dist/services/recovery/service.js.map +1 -1
  297. package/dist/services/recovery/successful-run-handoff.d.ts +16 -1
  298. package/dist/services/recovery/successful-run-handoff.d.ts.map +1 -1
  299. package/dist/services/recovery/successful-run-handoff.js +32 -0
  300. package/dist/services/recovery/successful-run-handoff.js.map +1 -1
  301. package/dist/services/recovery/successful-run-handoff.test.js +51 -1
  302. package/dist/services/recovery/successful-run-handoff.test.js.map +1 -1
  303. package/dist/services/routines.d.ts.map +1 -1
  304. package/dist/services/routines.js +48 -4
  305. package/dist/services/routines.js.map +1 -1
  306. package/dist/services/runtime-exposure/broker-client.d.ts +88 -0
  307. package/dist/services/runtime-exposure/broker-client.d.ts.map +1 -0
  308. package/dist/services/runtime-exposure/broker-client.js +217 -0
  309. package/dist/services/runtime-exposure/broker-client.js.map +1 -0
  310. package/dist/services/runtime-exposure/broker-client.test.d.ts +2 -0
  311. package/dist/services/runtime-exposure/broker-client.test.d.ts.map +1 -0
  312. package/dist/services/runtime-exposure/broker-client.test.js +185 -0
  313. package/dist/services/runtime-exposure/broker-client.test.js.map +1 -0
  314. package/dist/services/runtime-exposure/exposure-manager.d.ts +135 -0
  315. package/dist/services/runtime-exposure/exposure-manager.d.ts.map +1 -0
  316. package/dist/services/runtime-exposure/exposure-manager.js +247 -0
  317. package/dist/services/runtime-exposure/exposure-manager.js.map +1 -0
  318. package/dist/services/runtime-exposure/exposure-manager.test.d.ts +2 -0
  319. package/dist/services/runtime-exposure/exposure-manager.test.d.ts.map +1 -0
  320. package/dist/services/runtime-exposure/exposure-manager.test.js +384 -0
  321. package/dist/services/runtime-exposure/exposure-manager.test.js.map +1 -0
  322. package/dist/services/runtime-exposure/loopback-listener.d.ts +33 -0
  323. package/dist/services/runtime-exposure/loopback-listener.d.ts.map +1 -0
  324. package/dist/services/runtime-exposure/loopback-listener.js +146 -0
  325. package/dist/services/runtime-exposure/loopback-listener.js.map +1 -0
  326. package/dist/services/runtime-exposure/loopback-listener.test.d.ts +2 -0
  327. package/dist/services/runtime-exposure/loopback-listener.test.d.ts.map +1 -0
  328. package/dist/services/runtime-exposure/loopback-listener.test.js +116 -0
  329. package/dist/services/runtime-exposure/loopback-listener.test.js.map +1 -0
  330. package/dist/services/runtime-exposure/port-pair.d.ts +47 -0
  331. package/dist/services/runtime-exposure/port-pair.d.ts.map +1 -0
  332. package/dist/services/runtime-exposure/port-pair.js +57 -0
  333. package/dist/services/runtime-exposure/port-pair.js.map +1 -0
  334. package/dist/services/runtime-exposure/port-pair.test.d.ts +2 -0
  335. package/dist/services/runtime-exposure/port-pair.test.d.ts.map +1 -0
  336. package/dist/services/runtime-exposure/port-pair.test.js +92 -0
  337. package/dist/services/runtime-exposure/port-pair.test.js.map +1 -0
  338. package/dist/services/runtime-exposure/port-reservation.d.ts +211 -0
  339. package/dist/services/runtime-exposure/port-reservation.d.ts.map +1 -0
  340. package/dist/services/runtime-exposure/port-reservation.js +380 -0
  341. package/dist/services/runtime-exposure/port-reservation.js.map +1 -0
  342. package/dist/services/runtime-exposure/port-reservation.test.d.ts +2 -0
  343. package/dist/services/runtime-exposure/port-reservation.test.d.ts.map +1 -0
  344. package/dist/services/runtime-exposure/port-reservation.test.js +456 -0
  345. package/dist/services/runtime-exposure/port-reservation.test.js.map +1 -0
  346. package/dist/services/runtime-exposure/tailscale-hostname.d.ts +11 -0
  347. package/dist/services/runtime-exposure/tailscale-hostname.d.ts.map +1 -0
  348. package/dist/services/runtime-exposure/tailscale-hostname.js +36 -0
  349. package/dist/services/runtime-exposure/tailscale-hostname.js.map +1 -0
  350. package/dist/services/runtime-exposure/tailscale-hostname.test.d.ts +2 -0
  351. package/dist/services/runtime-exposure/tailscale-hostname.test.d.ts.map +1 -0
  352. package/dist/services/runtime-exposure/tailscale-hostname.test.js +14 -0
  353. package/dist/services/runtime-exposure/tailscale-hostname.test.js.map +1 -0
  354. package/dist/services/sandbox-orphan-cleanup-spool.d.ts +64 -0
  355. package/dist/services/sandbox-orphan-cleanup-spool.d.ts.map +1 -0
  356. package/dist/services/sandbox-orphan-cleanup-spool.js +134 -0
  357. package/dist/services/sandbox-orphan-cleanup-spool.js.map +1 -0
  358. package/dist/services/sandbox-provider-runtime.d.ts +15 -0
  359. package/dist/services/sandbox-provider-runtime.d.ts.map +1 -1
  360. package/dist/services/sandbox-provider-runtime.js +1 -0
  361. package/dist/services/sandbox-provider-runtime.js.map +1 -1
  362. package/dist/services/secrets.d.ts +103 -0
  363. package/dist/services/secrets.d.ts.map +1 -1
  364. package/dist/services/secrets.js +432 -10
  365. package/dist/services/secrets.js.map +1 -1
  366. package/dist/services/setup-token-session.d.ts +630 -0
  367. package/dist/services/setup-token-session.d.ts.map +1 -0
  368. package/dist/services/setup-token-session.js +1005 -0
  369. package/dist/services/setup-token-session.js.map +1 -0
  370. package/dist/services/setup-token-session.test.d.ts +2 -0
  371. package/dist/services/setup-token-session.test.d.ts.map +1 -0
  372. package/dist/services/setup-token-session.test.js +1143 -0
  373. package/dist/services/setup-token-session.test.js.map +1 -0
  374. package/dist/services/setup-token-transport-binding.d.ts +202 -0
  375. package/dist/services/setup-token-transport-binding.d.ts.map +1 -0
  376. package/dist/services/setup-token-transport-binding.js +386 -0
  377. package/dist/services/setup-token-transport-binding.js.map +1 -0
  378. package/dist/services/setup-token-transport-binding.test.d.ts +2 -0
  379. package/dist/services/setup-token-transport-binding.test.d.ts.map +1 -0
  380. package/dist/services/setup-token-transport-binding.test.js +761 -0
  381. package/dist/services/setup-token-transport-binding.test.js.map +1 -0
  382. package/dist/services/summary-slots.d.ts.map +1 -1
  383. package/dist/services/summary-slots.js +40 -6
  384. package/dist/services/summary-slots.js.map +1 -1
  385. package/dist/services/task-watchdogs.js +2 -2
  386. package/dist/services/task-watchdogs.js.map +1 -1
  387. package/dist/services/tool-access-policy.d.ts +1 -1
  388. package/dist/services/tool-access.d.ts.map +1 -1
  389. package/dist/services/tool-access.js +29 -11
  390. package/dist/services/tool-access.js.map +1 -1
  391. package/dist/services/tool-gateway.d.ts +1 -1
  392. package/dist/services/tool-gateway.d.ts.map +1 -1
  393. package/dist/services/tool-gateway.js +56 -5
  394. package/dist/services/tool-gateway.js.map +1 -1
  395. package/dist/services/workspace-file-resources.d.ts +10 -1
  396. package/dist/services/workspace-file-resources.d.ts.map +1 -1
  397. package/dist/services/workspace-file-resources.js +258 -6
  398. package/dist/services/workspace-file-resources.js.map +1 -1
  399. package/dist/services/workspace-git-operation-scheduler.d.ts +135 -0
  400. package/dist/services/workspace-git-operation-scheduler.d.ts.map +1 -0
  401. package/dist/services/workspace-git-operation-scheduler.js +655 -0
  402. package/dist/services/workspace-git-operation-scheduler.js.map +1 -0
  403. package/dist/services/workspace-git-operation-scheduler.test.d.ts +2 -0
  404. package/dist/services/workspace-git-operation-scheduler.test.d.ts.map +1 -0
  405. package/dist/services/workspace-git-operation-scheduler.test.js +367 -0
  406. package/dist/services/workspace-git-operation-scheduler.test.js.map +1 -0
  407. package/dist/services/workspace-operations.d.ts +60 -0
  408. package/dist/services/workspace-operations.d.ts.map +1 -1
  409. package/dist/services/workspace-operations.js +384 -19
  410. package/dist/services/workspace-operations.js.map +1 -1
  411. package/dist/services/workspace-runtime-exposure-backfill.test.d.ts +2 -0
  412. package/dist/services/workspace-runtime-exposure-backfill.test.d.ts.map +1 -0
  413. package/dist/services/workspace-runtime-exposure-backfill.test.js +149 -0
  414. package/dist/services/workspace-runtime-exposure-backfill.test.js.map +1 -0
  415. package/dist/services/workspace-runtime-exposure.test.d.ts +2 -0
  416. package/dist/services/workspace-runtime-exposure.test.d.ts.map +1 -0
  417. package/dist/services/workspace-runtime-exposure.test.js +517 -0
  418. package/dist/services/workspace-runtime-exposure.test.js.map +1 -0
  419. package/dist/services/workspace-runtime-leases.d.ts +90 -0
  420. package/dist/services/workspace-runtime-leases.d.ts.map +1 -0
  421. package/dist/services/workspace-runtime-leases.js +252 -0
  422. package/dist/services/workspace-runtime-leases.js.map +1 -0
  423. package/dist/services/workspace-runtime-read-model.d.ts +12 -0
  424. package/dist/services/workspace-runtime-read-model.d.ts.map +1 -1
  425. package/dist/services/workspace-runtime-read-model.test.js +3 -0
  426. package/dist/services/workspace-runtime-read-model.test.js.map +1 -1
  427. package/dist/services/workspace-runtime-ready-comment.test.js +1 -0
  428. package/dist/services/workspace-runtime-ready-comment.test.js.map +1 -1
  429. package/dist/services/workspace-runtime.d.ts +160 -2
  430. package/dist/services/workspace-runtime.d.ts.map +1 -1
  431. package/dist/services/workspace-runtime.js +1693 -141
  432. package/dist/services/workspace-runtime.js.map +1 -1
  433. package/dist/shutdown.d.ts +24 -0
  434. package/dist/shutdown.d.ts.map +1 -1
  435. package/dist/shutdown.js +37 -0
  436. package/dist/shutdown.js.map +1 -1
  437. package/dist/shutdown.test.js +113 -1
  438. package/dist/shutdown.test.js.map +1 -1
  439. package/dist/startup-banner.js +1 -1
  440. package/dist/startup-banner.js.map +1 -1
  441. package/dist/url-utils.d.ts +26 -0
  442. package/dist/url-utils.d.ts.map +1 -0
  443. package/dist/url-utils.js +59 -0
  444. package/dist/url-utils.js.map +1 -0
  445. package/dist/url-utils.test.d.ts +2 -0
  446. package/dist/url-utils.test.d.ts.map +1 -0
  447. package/dist/url-utils.test.js +55 -0
  448. package/dist/url-utils.test.js.map +1 -0
  449. package/dist/worktree-config.d.ts.map +1 -1
  450. package/dist/worktree-config.js +3 -17
  451. package/dist/worktree-config.js.map +1 -1
  452. package/package.json +20 -20
  453. package/skills/paperclip/SKILL.md +16 -11
  454. package/skills/paperclip/references/api-reference.md +8 -5
  455. package/skills/paperclip-board/SKILL.md +1 -1
  456. package/ui-dist/assets/{abnfDiagram-VRR7QNED-wvSnvD6-.js → abnfDiagram-N423BO3Z-BvgoV-u5.js} +1 -1
  457. package/ui-dist/assets/{arc-Bx0V1JsN.js → arc-BInnUBUU.js} +1 -1
  458. package/ui-dist/assets/architectureDiagram-T3A2C74G-Dg4MziOm.js +36 -0
  459. package/ui-dist/assets/{blockDiagram-677ZJIJ3-BROcLaUk.js → blockDiagram-VBNYF7ZC-D9kzAkLN.js} +1 -1
  460. package/ui-dist/assets/{c4Diagram-LMCZKHZV-D-V3kgju.js → c4Diagram-5PPSVZJV-BwzsgV_0.js} +1 -1
  461. package/ui-dist/assets/channel-qoSYbCn0.js +1 -0
  462. package/ui-dist/assets/{chunk-32BRIVSS-qillH3H6.js → chunk-2GRJ4B5K-D2EQ9vrl.js} +1 -1
  463. package/ui-dist/assets/{chunk-2Q5K7J3B-D19cVnii.js → chunk-2Q5K7J3B-DOA_8fSd.js} +1 -1
  464. package/ui-dist/assets/{chunk-EX3LRPZG-CLUswrZg.js → chunk-5RXB4S5H-CT5ukRiT.js} +1 -1
  465. package/ui-dist/assets/{chunk-5VM5RSS4-Cwlp02Lx.js → chunk-5VM5RSS4-D2gOlkyB.js} +1 -1
  466. package/ui-dist/assets/{chunk-MOJQB5TN-yKciyq6E.js → chunk-6Q2QTUOP-DUb6aG8c.js} +1 -1
  467. package/ui-dist/assets/{chunk-V7JOEXUC-DjJ75g0_.js → chunk-GF5L2VYU-BPabG3Cx.js} +1 -1
  468. package/ui-dist/assets/{chunk-JWPE2WC7-BjepyzEb.js → chunk-JWPE2WC7-scNfhlZz.js} +1 -1
  469. package/ui-dist/assets/{chunk-VR4S4FIN-CiEmy8-R.js → chunk-KBJHAD2P-BcRAzRpq.js} +1 -1
  470. package/ui-dist/assets/{chunk-RYQCIY6F-ed7mQM9j.js → chunk-RYQCIY6F-BiZ0-EGh.js} +1 -1
  471. package/ui-dist/assets/{chunk-XXDRQBXY-BiI83zoO.js → chunk-XXDRQBXY-lJULxFIE.js} +1 -1
  472. package/ui-dist/assets/classDiagram-JCYQIIEL-B24u1REs.js +1 -0
  473. package/ui-dist/assets/classDiagram-v2-OCEON4UE-B24u1REs.js +1 -0
  474. package/ui-dist/assets/{cose-bilkent-JH36ORCC-DIdQf5ta.js → cose-bilkent-JH36ORCC-Do8pe8JB.js} +1 -1
  475. package/ui-dist/assets/{cynefin-VYW2F7L2-B2m9xxh8.js → cynefin-VYW2F7L2-B34jJY1x.js} +1 -1
  476. package/ui-dist/assets/{cynefinDiagram-TSTJHNR4-CGVdB0kX.js → cynefinDiagram-MW4NZA55-DQ8QK8JK.js} +1 -1
  477. package/ui-dist/assets/cytoscape.esm-DShqj__B.js +321 -0
  478. package/ui-dist/assets/{dagre-VKFMJZFB-CskKiZwJ.js → dagre-VZM6K2ZE-B7lSKgxH.js} +1 -1
  479. package/ui-dist/assets/{diagram-OA4YK3LP-D2cn5eIN.js → diagram-7IWD3JNH-B3hLAFGE.js} +1 -1
  480. package/ui-dist/assets/{diagram-FQU43EPY-oa5Zu0XG.js → diagram-B4RE2ZJO-CH9Ro9e0.js} +1 -1
  481. package/ui-dist/assets/{diagram-NH7WQ7WH-fymti5Js.js → diagram-LBJQPF4R-DdPVMii7.js} +1 -1
  482. package/ui-dist/assets/{diagram-G47NLZAW-BWF2ZCsw.js → diagram-Q27KOJAE-f5VXswjc.js} +1 -1
  483. package/ui-dist/assets/diagram-UB23O5K3-DGqxixsR.js +41 -0
  484. package/ui-dist/assets/{ebnfDiagram-CCIWWBDH-CJ1d3D5q.js → ebnfDiagram-BXEA7PRR-C-1klg_w.js} +1 -1
  485. package/ui-dist/assets/{erDiagram-Q63AITRT-BJCPa7kK.js → erDiagram-JOGREHBK-Dt4qK4gv.js} +1 -1
  486. package/ui-dist/assets/{flowDiagram-23GEKE2U-BWjWuz6r.js → flowDiagram-UKHOOZJN-9ZlrTuET.js} +5 -5
  487. package/ui-dist/assets/{ganttDiagram-NO4QXBWP-Dv1KKjoM.js → ganttDiagram-PKOTCBZU-CE3lyvFq.js} +1 -1
  488. package/ui-dist/assets/{gitGraphDiagram-IHSO6WYX-9X7vgL0A.js → gitGraphDiagram-DS77QQ5N-HH2fSgad.js} +1 -1
  489. package/ui-dist/assets/{index-CpaK48ok.js → index-B61ORkIb.js} +1 -1
  490. package/ui-dist/assets/index-BHiUiToL.css +1 -0
  491. package/ui-dist/assets/{index-D2YCrA-D.js → index-BY5ITKmG.js} +1 -1
  492. package/ui-dist/assets/{index-9JMDmXc5.js → index-BbAhzCq8.js} +1 -1
  493. package/ui-dist/assets/{index-C5qHatpp.js → index-Bc9g6q63.js} +1 -1
  494. package/ui-dist/assets/{index-DuI6e5mP.js → index-Bf7tyGxE.js} +1 -1
  495. package/ui-dist/assets/{index-BahRsj0s.js → index-BvFx-4KW.js} +1 -1
  496. package/ui-dist/assets/{index-DKlsEDV7.js → index-C1mpWCcn.js} +1 -1
  497. package/ui-dist/assets/{index-DIXaXZrW.js → index-CHXG4GPL.js} +1 -1
  498. package/ui-dist/assets/{index-DcfO6NoY.js → index-CLu3Tfpv.js} +1 -1
  499. package/ui-dist/assets/{index-Cfz6P0Qq.js → index-CQhaM6qd.js} +1 -1
  500. package/ui-dist/assets/{index-D9d3sl6K.js → index-CVTL3aAL.js} +1 -1
  501. package/ui-dist/assets/{index-BexA3NAl.js → index-CcRTJ93J.js} +1 -1
  502. package/ui-dist/assets/{index-CnBrDwGT.js → index-Cm6iEYPt.js} +247 -223
  503. package/ui-dist/assets/{index-ByGcu-MB.js → index-DQIrrn2L.js} +1 -1
  504. package/ui-dist/assets/{index-DKEzHO7c.js → index-DU4U1fuv.js} +1 -1
  505. package/ui-dist/assets/{index-pqJO8FsV.js → index-DV2FOgyD.js} +1 -1
  506. package/ui-dist/assets/{index-tDuieU3u.js → index-DceuCrr8.js} +1 -1
  507. package/ui-dist/assets/{index-CjN2lm_w.js → index-DlVBBF8o.js} +1 -1
  508. package/ui-dist/assets/{index-0yJtUsFh.js → index-DsdVneqe.js} +1 -1
  509. package/ui-dist/assets/{index-C2a4_IKU.js → index-DvFUXI-Q.js} +1 -1
  510. package/ui-dist/assets/{index-BTMiDMYv.js → index-FHzrJ7iQ.js} +1 -1
  511. package/ui-dist/assets/{index-cUQXJtLK.js → index-diFs0CNC.js} +1 -1
  512. package/ui-dist/assets/{index-C96LHV1A.js → index-hkanj4t6.js} +1 -1
  513. package/ui-dist/assets/{index-rDI1Q4r9.js → index-yRJnh4vx.js} +1 -1
  514. package/ui-dist/assets/{infoDiagram-FWYZ7A6U-CHIhutSb.js → infoDiagram-6WML65LV-2jai2fw-.js} +1 -1
  515. package/ui-dist/assets/{ishikawaDiagram-FXEZZL3T-ChaD7-5_.js → ishikawaDiagram-WSZJBQD7-CUmGhmEb.js} +1 -1
  516. package/ui-dist/assets/{journeyDiagram-5HDEW3XC-M5T2sMgn.js → journeyDiagram-NVQOT4AX-CGQuPDO1.js} +1 -1
  517. package/ui-dist/assets/{kanban-definition-HUTT4EX6-B8H6R_Wc.js → kanban-definition-27J2QSJJ-zgEPcbHl.js} +1 -1
  518. package/ui-dist/assets/{linear-cpPKlVCq.js → linear-BVf5VtLS.js} +1 -1
  519. package/ui-dist/assets/mermaid.core-D2TFkGfI.js +308 -0
  520. package/ui-dist/assets/{mindmap-definition-LN4V7U3C-Bf6POzvm.js → mindmap-definition-FAOFIHXS-xoAQ0Lb_.js} +1 -1
  521. package/ui-dist/assets/{pegDiagram-2B236MQR-BJbGktAV.js → pegDiagram-VL7TDLO6-CBR1PWLr.js} +1 -1
  522. package/ui-dist/assets/{pieDiagram-ENE6RG2P-BmSN9Bio.js → pieDiagram-7S7Q4E2Y-BMPnzK_e.js} +1 -1
  523. package/ui-dist/assets/{quadrantDiagram-ABIIQ3AL-JUpqQCx_.js → quadrantDiagram-CIZ2JOQS-CPtVUPkR.js} +1 -1
  524. package/ui-dist/assets/{railroadDiagram-RFXS5EU6-B8k8T4-2.js → railroadDiagram-AXF67PYL-DC0lsZV1.js} +1 -1
  525. package/ui-dist/assets/{requirementDiagram-TGXJPOKE-b32heq7Q.js → requirementDiagram-LRYGKXZP-BF6k05SB.js} +1 -1
  526. package/ui-dist/assets/{sankeyDiagram-HTMAVEWB-DC3s-xgf.js → sankeyDiagram-W5VNT64P-CRN0ibiP.js} +1 -1
  527. package/ui-dist/assets/{sequenceDiagram-DBY2YBRQ-BsCFyv_E.js → sequenceDiagram-SI44F4Z6-CQtTiPWm.js} +1 -1
  528. package/ui-dist/assets/{sizeCapture-X5ZJPWSS-S7xeCud3.js → sizeCapture-X5ZJPWSS-BdjuGZd1.js} +1 -1
  529. package/ui-dist/assets/{stateDiagram-2N3HPSRC-58O3ofoS.js → stateDiagram-OKZ733FA-B99onxyh.js} +1 -1
  530. package/ui-dist/assets/stateDiagram-v2-UEYNNEHI-bzFlYBZ1.js +1 -0
  531. package/ui-dist/assets/{swimlanes-5IMT3BWC-DFCVG0iF.js → swimlanes-SLNWSIFB-BIByPbrL.js} +2 -2
  532. package/ui-dist/assets/swimlanesDiagram-ULZ7WXOC-DgdkBnuK.js +8 -0
  533. package/ui-dist/assets/{timeline-definition-FHXFAJF6-C0c0SkQu.js → timeline-definition-Z64GVDOM-I1NgOcn9.js} +1 -1
  534. package/ui-dist/assets/{vennDiagram-L72KCM5P-B1cEx8GQ.js → vennDiagram-T6HMQDX7-D6t2Njcl.js} +1 -1
  535. package/ui-dist/assets/{wardleyDiagram-EHGQE667-BQhDkOx9.js → wardleyDiagram-T6FBY63Y-BiYKm9gh.js} +1 -1
  536. package/ui-dist/assets/{xychartDiagram-FW5EYKEG-YSQp1N0i.js → xychartDiagram-ELKLHX3M-BhwXKWIa.js} +4 -4
  537. package/ui-dist/index.html +3 -3
  538. package/ui-dist/sw.js +8 -3
  539. package/ui-dist/assets/architectureDiagram-ZJ3FMSHR-BcJt8Ia1.js +0 -36
  540. package/ui-dist/assets/channel-ZRpjyNiZ.js +0 -1
  541. package/ui-dist/assets/classDiagram-OUVF2IWQ-CCzzzCgk.js +0 -1
  542. package/ui-dist/assets/classDiagram-v2-EOCWNBFH-CCzzzCgk.js +0 -1
  543. package/ui-dist/assets/cytoscape.esm-D8joxN9f.js +0 -321
  544. package/ui-dist/assets/diagram-WEI45ONY-M3WOC2tK.js +0 -41
  545. package/ui-dist/assets/index-BqfqfoQX.css +0 -1
  546. package/ui-dist/assets/mermaid.core-MCazc_od.js +0 -308
  547. package/ui-dist/assets/stateDiagram-v2-6OUMAXLB-_VY5dpDG.js +0 -1
  548. package/ui-dist/assets/swimlanesDiagram-G3AALYLV-BJhUjfns.js +0 -8
@@ -0,0 +1,630 @@
1
+ import type { Db } from "@paperclipai/db";
2
+ /**
3
+ * The session states. The four terminal states end the login. The `stored`
4
+ * state is not terminal: a session enters `stored` after a successful
5
+ * owner-bound secret write, and the durable row then persists as a one-time
6
+ * claim. The create path consumes the claim, or the reaper removes the row after
7
+ * the deadline.
8
+ */
9
+ export type SetupTokenSessionState = "starting" | "awaiting_code" | "submitting" | "stored" | "completed" | "failed" | "timed_out" | "cancelled";
10
+ /** The four terminal states. Cleanup runs once when a session reaches one. */
11
+ export declare const SETUP_TOKEN_TERMINAL_STATES: readonly SetupTokenSessionState[];
12
+ export declare function isTerminalSessionState(state: SetupTokenSessionState): boolean;
13
+ /**
14
+ * The immutable owner scope of a session. Every operation verifies all five
15
+ * fields against the stored scope. The service builds the scope once at start
16
+ * and never changes it.
17
+ *
18
+ * The `targetAgentId` is null for a company-and-environment login. That login
19
+ * has no agent id: a hire flow starts one session before an agent exists. The
20
+ * agent-scoped login sets `targetAgentId` to the agent id. The full-scope match
21
+ * treats null as one immutable value, so a company login and an agent login
22
+ * never resolve one another.
23
+ */
24
+ export interface SetupTokenSessionScope {
25
+ companyId: string;
26
+ ownerUserId: string;
27
+ targetAgentId: string | null;
28
+ adapterType: string;
29
+ environmentId: string;
30
+ confirmedOverwrite?: {
31
+ expectedSecretId: string;
32
+ expectedLatestVersion: number;
33
+ } | null;
34
+ }
35
+ /** The terminal outcome of the live login process. */
36
+ export type SetupTokenLoginOutcome = "success" | "failure" | "timeout" | "cancelled";
37
+ /**
38
+ * The live login process the service drives for one session. A production
39
+ * factory binds this to the setup-token runner over a sandbox pseudo-terminal.
40
+ * A unit test binds it to a fake. The process holds the flow state in memory.
41
+ */
42
+ export interface SetupTokenLoginProcess {
43
+ /** Resolves with the terminal outcome when the login process ends. */
44
+ readonly done: Promise<SetupTokenLoginOutcome>;
45
+ /**
46
+ * Forwards the one browser code to the live process. The service calls it one
47
+ * time, only after the single `awaiting_code` to `submitting` transition wins.
48
+ */
49
+ submitCode(code: string): void;
50
+ /**
51
+ * Stops the direct child process. The service calls it before it releases the
52
+ * lease. The method must be safe to call more than one time.
53
+ */
54
+ stop(): void;
55
+ }
56
+ /** The prompt sink the factory calls one time when it surfaces the sign-in URL. */
57
+ export type SetupTokenPromptSink = (prompt: {
58
+ url: string;
59
+ }) => void;
60
+ /**
61
+ * The credential sink the factory calls one time when the login binds the minted
62
+ * token from the success record. The sink is asynchronous: it awaits the
63
+ * owner-bound secret write and rejects on a storage failure. The factory (or the
64
+ * runner it wraps) awaits this sink before it reports success, so a storage
65
+ * failure ends the login as a failure. The sink never logs the token and never
66
+ * returns it.
67
+ */
68
+ export type SetupTokenCredentialSink = (token: string) => Promise<void>;
69
+ /**
70
+ * The atomic credential-claim writer. The service awaits it one time with the
71
+ * minted token, the owner scope, and the durable session id. It runs one
72
+ * control-plane transaction that first transitions the exact durable row to
73
+ * `stored` with a full-scope conditional update, then performs the owner-bound
74
+ * secret compare-and-set on the same transaction handle. The commit establishes
75
+ * the encrypted secret and the `stored` claim together. It resolves on a
76
+ * successful commit. It rejects and rolls back the whole transaction on a
77
+ * zero-row transition or on a storage failure, so neither the secret nor the
78
+ * claim commits. The service holds the token only for this call; it never stores
79
+ * it.
80
+ */
81
+ export type SetupTokenSecretWriter = (input: {
82
+ scope: SetupTokenSessionScope;
83
+ sessionId: string;
84
+ token: string;
85
+ }) => Promise<void>;
86
+ /**
87
+ * Builds the live login process for one session. The factory receives the
88
+ * prompt sink, the credential sink, the host timeout, and an abort signal that
89
+ * the service aborts on cancel and on expiry. The factory awaits the credential
90
+ * sink one time before it reports success.
91
+ */
92
+ export type SetupTokenLoginProcessFactory = (params: {
93
+ scope: SetupTokenSessionScope;
94
+ onPrompt: SetupTokenPromptSink;
95
+ onCredential: SetupTokenCredentialSink;
96
+ timeoutMs: number;
97
+ signal: AbortSignal;
98
+ }) => SetupTokenLoginProcess;
99
+ /** An opaque sandbox lease handle. The service holds one per session. */
100
+ export interface SetupTokenLease {
101
+ id: string;
102
+ }
103
+ /**
104
+ * Acquires and releases the sandbox lease for a login session. The production
105
+ * manager wraps the environment runtime. The service sets an external lease
106
+ * expiry no later than the session deadline through the `deadline` field.
107
+ */
108
+ export interface SetupTokenLeaseManager {
109
+ acquire(input: {
110
+ scope: SetupTokenSessionScope;
111
+ deadline: number;
112
+ }): Promise<SetupTokenLease>;
113
+ release(lease: SetupTokenLease): Promise<void>;
114
+ /** Releases a lease by id. The startup reaper uses this after a restart. */
115
+ releaseById(leaseId: string): Promise<void>;
116
+ }
117
+ /**
118
+ * The non-secret cleanup record. It holds only ids, the deadline, the claim
119
+ * marker, and the state. It never holds a URL, a code, a token, or a raw process
120
+ * chunk. The service persists it at start so a restart can reap the
121
+ * lease. The record keys on the company, the owner, the adapter, and the
122
+ * environment, not the agent id, so a hire flow with no agent still resolves it.
123
+ */
124
+ export interface SetupTokenCleanupRecord {
125
+ sessionId: string;
126
+ companyId: string;
127
+ ownerUserId: string;
128
+ adapterType: string;
129
+ environmentId: string;
130
+ leaseId: string;
131
+ deadline: number;
132
+ state: SetupTokenSessionState;
133
+ boundAt: number | null;
134
+ }
135
+ /**
136
+ * The immutable identity of a cleanup record. It is the full owner scope plus
137
+ * the session id. Every durable write matches on all five fields, so a write
138
+ * never updates a row by session id alone.
139
+ */
140
+ export interface SetupTokenCleanupIdentity {
141
+ sessionId: string;
142
+ companyId: string;
143
+ ownerUserId: string;
144
+ adapterType: string;
145
+ environmentId: string;
146
+ }
147
+ /**
148
+ * The durable store for the non-secret cleanup record. A restart reads the
149
+ * store and reaps a lease whose session is terminal, past its deadline, or
150
+ * already consumed. The store persists no secret.
151
+ */
152
+ export interface SetupTokenCleanupStore {
153
+ record(record: SetupTokenCleanupRecord): Promise<void>;
154
+ /**
155
+ * Marks the state only when the full owner scope and the session id match. The
156
+ * write never updates a row by the session id alone.
157
+ */
158
+ markState(identity: SetupTokenCleanupIdentity, state: SetupTokenSessionState): Promise<void>;
159
+ /**
160
+ * Deletes the record only when the full owner scope and the session id match.
161
+ * The delete never removes a row by the session id alone, so a cross-scope
162
+ * caller cannot delete a foreign row.
163
+ */
164
+ remove(identity: SetupTokenCleanupIdentity): Promise<void>;
165
+ /**
166
+ * Returns each record whose session is terminal, whose deadline is past, or
167
+ * whose claim is already consumed.
168
+ */
169
+ listReapable(now: number): Promise<SetupTokenCleanupRecord[]>;
170
+ /**
171
+ * Consumes a `stored` claim with one conditional write. The predicate carries
172
+ * the full owner scope, the session id, `state = stored`, an unexpired
173
+ * deadline that it checks with `clock_timestamp()`, and an unconsumed marker.
174
+ * The write sets `bound_at` one time and returns the row on a valid consume.
175
+ * It returns null for a missing, foreign-scope, expired, non-`stored`, or
176
+ * already-consumed claim. It never reads the state or the expiry in a separate
177
+ * step. The agent-service transaction calls this method.
178
+ */
179
+ consumeStoredClaim(identity: SetupTokenCleanupIdentity): Promise<SetupTokenCleanupRecord | null>;
180
+ }
181
+ /** A per-key start rate limiter. It matches the invite-rate-limit shape. */
182
+ export interface SetupTokenRateLimiter {
183
+ consume(key: string): {
184
+ allowed: boolean;
185
+ retryAfterSeconds: number;
186
+ };
187
+ }
188
+ export interface SetupTokenSessionCaps {
189
+ perOwner: number;
190
+ perAgent: number;
191
+ perCompany: number;
192
+ }
193
+ export declare const DEFAULT_SETUP_TOKEN_SESSION_CAPS: SetupTokenSessionCaps;
194
+ /** The default host timeout for one login session. */
195
+ export declare const DEFAULT_SETUP_TOKEN_SESSION_TTL_MS: number;
196
+ /**
197
+ * The default retention window for a completed token. The service releases the
198
+ * sandbox lease at once on success, but it keeps the token in memory for this
199
+ * window, so the authorized owner can receive it one time. A short window bounds
200
+ * how long the service holds the secret if the owner never receives it (SR-4).
201
+ */
202
+ export declare const DEFAULT_SETUP_TOKEN_RETENTION_MS = 60000;
203
+ export declare const SETUP_TOKEN_SESSION_NOT_FOUND = "Setup-token login session not found.";
204
+ export declare const SETUP_TOKEN_SUBMIT_CONFLICT = "The setup-token login session cannot accept this code.";
205
+ export declare const SETUP_TOKEN_RATE_LIMITED = "Too many setup-token login attempts. Try again later.";
206
+ export declare const SETUP_TOKEN_CAP_EXCEEDED = "Too many active setup-token login sessions.";
207
+ export declare const SETUP_TOKEN_TOKEN_UNAVAILABLE = "The setup-token is not available for this session.";
208
+ export declare const SETUP_TOKEN_START_FAILED = "The setup-token login session could not start.";
209
+ export declare const SETUP_TOKEN_PROVIDER_UNSUPPORTED = "The sandbox provider does not support the Claude setup-token login.";
210
+ export declare const SETUP_TOKEN_PROVIDER_UNSUPPORTED_CODE = "setup_token_provider_unsupported";
211
+ export declare const SETUP_TOKEN_STORAGE_FAILED = "The setup-token login could not store the credential.";
212
+ /** A typed error the route maps to a fixed status and the fixed text above. */
213
+ export declare class SetupTokenSessionError extends Error {
214
+ readonly status: number;
215
+ constructor(status: number, message: string);
216
+ }
217
+ /**
218
+ * Builds the sanitized login-URL form for every non-owner sink (SR-5). The
219
+ * function removes the query, the fragment, and the credentials, so no OAuth
220
+ * parameter and no secret reaches a log, an activity detail, an error, a trace,
221
+ * or client telemetry. It keeps the origin and the path for a useful diagnostic.
222
+ * It returns a fixed placeholder for a value it cannot parse, so it never falls
223
+ * back to the raw input.
224
+ */
225
+ export declare function toSanitizedLoginUrl(rawUrl: string): string;
226
+ /**
227
+ * The startup transport configuration for the confidential responses. The
228
+ * server resolves it once at startup. `trustedProxies` is the dedicated,
229
+ * explicit proxy IP or CIDR allowlist for the confidential routes. The global
230
+ * `TRUST_PROXY` setting does not appear here, so `TRUST_PROXY=true` and a
231
+ * hop-count value never satisfy the guard (SR-7).
232
+ */
233
+ export interface ConfidentialTransportConfig {
234
+ deploymentMode: "local_trusted" | "authenticated";
235
+ trustedProxies: string[];
236
+ /**
237
+ * The explicit operator declaration that every client request reaches this
238
+ * server through a platform edge that terminates TLS (a managed PaaS such as
239
+ * Railway, Render, or Fly, where the app socket is always plain HTTP and the
240
+ * edge-proxy peer addresses are not operator-visible, so `trustedProxies`
241
+ * cannot express them). Unlike the global `TRUST_PROXY` setting, which the
242
+ * guard deliberately never reads (SR-7), this is a dedicated, single-purpose
243
+ * statement about the confidential login routes only. When declared, a
244
+ * request is confidential unless the edge itself labels the client hop as
245
+ * plain `http` in `X-Forwarded-Proto`. Defaults to false.
246
+ */
247
+ edgeTlsTerminated?: boolean;
248
+ }
249
+ /** The per-request transport signals the guard reads from the raw socket. */
250
+ export interface ConfidentialTransportRequest {
251
+ /** The raw TLS bit on the immediate socket. It ignores `trust proxy`. */
252
+ socketEncrypted: boolean;
253
+ /** The immediate peer address. It ignores `trust proxy`. */
254
+ remoteAddress: string | undefined;
255
+ /** The `X-Forwarded-Proto` header value. The guard reads its first hop only. */
256
+ forwardedProto: string | undefined;
257
+ }
258
+ export interface ConfidentialTransportDecision {
259
+ allowed: boolean;
260
+ reason: string;
261
+ }
262
+ /**
263
+ * Decides whether the request may receive a confidential response (the full
264
+ * login URL or the token). The guard fails closed. It never trusts a
265
+ * client-supplied header for the TLS decision unless the immediate peer is on
266
+ * the dedicated proxy allowlist. It never reads the global `trust proxy`
267
+ * setting.
268
+ *
269
+ * The guard allows a confidential response only in these cases:
270
+ * 1. The immediate socket is TLS. A direct TLS request is always valid (SR-6).
271
+ * 2. The deployment is `local_trusted` and the peer is loopback. This is the
272
+ * only local exception (SR-6).
273
+ * 3. The operator declared platform edge TLS termination
274
+ * (`edgeTlsTerminated`) and the edge does not label the client hop as
275
+ * plain `http`. The declaration is a deliberate, single-purpose operator
276
+ * statement about these routes; it is never derived from `TRUST_PROXY`
277
+ * (SR-7).
278
+ * 4. The peer is on the dedicated proxy allowlist and the forwarded protocol's
279
+ * first hop is `https`. A `TRUST_PROXY=true` or hop-count value does not
280
+ * reach this branch, because the guard never reads it (SR-7).
281
+ *
282
+ * Every other request fails closed and the route returns the fixed no-secret
283
+ * error.
284
+ */
285
+ export declare function evaluateConfidentialTransport(config: ConfidentialTransportConfig, request: ConfidentialTransportRequest): ConfidentialTransportDecision;
286
+ /**
287
+ * Assesses the confidential transport at startup (SR-7). The server disables
288
+ * proxy-forwarded confidential responses when the dedicated allowlist is empty
289
+ * and the operator has not declared platform edge TLS termination.
290
+ * A direct TLS request and a `local_trusted` loopback request still pass at
291
+ * runtime, because the runtime guard checks them first. The server logs the
292
+ * returned reason so an operator can see why forwarded requests fail closed.
293
+ */
294
+ export declare function assessConfidentialStartup(config: ConfidentialTransportConfig): {
295
+ proxyForwardingEnabled: boolean;
296
+ reason: string;
297
+ };
298
+ /** The public read view of a session prompt. */
299
+ export interface SetupTokenPromptView {
300
+ state: SetupTokenSessionState;
301
+ /** The full login URL, present only when the prompt has surfaced (SR-5). */
302
+ loginUrl: string | null;
303
+ }
304
+ /**
305
+ * The owner descriptor of a session. The company-and-environment routes read it
306
+ * to build the response contract. It carries the immutable environment and the
307
+ * session deadline, plus the current state and the full login URL. The route
308
+ * projects it: the public status response drops the login URL; the owner prompt
309
+ * response returns the login URL through the confidential transport guard.
310
+ */
311
+ export interface SetupTokenSessionDescriptor {
312
+ sessionId: string;
313
+ state: SetupTokenSessionState;
314
+ environmentId: string;
315
+ /** The session deadline in epoch milliseconds. */
316
+ deadline: number;
317
+ /** The full login URL, present only after the prompt surfaces. */
318
+ loginUrl: string | null;
319
+ }
320
+ /**
321
+ * The completion contract for the authorized owner. It carries the non-secret
322
+ * `storedSessionId` claim and no token. The `storedSessionId` is the
323
+ * durable session id; the agent-create transaction consumes it as the one-time
324
+ * stored-session claim.
325
+ */
326
+ export interface SetupTokenCompletionView {
327
+ storedSessionId: string;
328
+ }
329
+ export interface SetupTokenSessionServiceOptions {
330
+ factory: SetupTokenLoginProcessFactory;
331
+ leases: SetupTokenLeaseManager;
332
+ store: SetupTokenCleanupStore;
333
+ /**
334
+ * The owner-bound secret writer. The service awaits it one time when the login
335
+ * binds the token. It performs the compare-and-set. The service fails
336
+ * closed on a rejection.
337
+ */
338
+ completeCredential: SetupTokenSecretWriter;
339
+ rateLimiter: SetupTokenRateLimiter;
340
+ caps?: SetupTokenSessionCaps;
341
+ ttlMs?: number;
342
+ /** The retention window for a completed token. Defaults to the constant. */
343
+ tokenRetentionMs?: number;
344
+ now?: () => number;
345
+ /** Returns an opaque, cryptographically random session id. */
346
+ generateSessionId?: () => string;
347
+ /** A non-leaking diagnostic sink. It receives only fixed status lines. */
348
+ log?: (line: string) => void;
349
+ }
350
+ /**
351
+ * The setup-token login session service. It holds every live session in memory
352
+ * and persists a non-secret cleanup record for each. It bounds active sessions
353
+ * per owner, per agent, and per company, and it rate-limits the start path.
354
+ */
355
+ export declare class SetupTokenSessionService {
356
+ private readonly sessions;
357
+ private readonly reservedByOwner;
358
+ private readonly reservedByAgent;
359
+ private readonly reservedByCompany;
360
+ private readonly factory;
361
+ private readonly leases;
362
+ private readonly store;
363
+ private readonly completeCredential;
364
+ private readonly rateLimiter;
365
+ private readonly caps;
366
+ private readonly ttlMs;
367
+ private readonly tokenRetentionMs;
368
+ private readonly now;
369
+ private readonly generateSessionId;
370
+ private readonly log;
371
+ constructor(options: SetupTokenSessionServiceOptions);
372
+ /**
373
+ * Builds the durable-record identity for a session. The store matches every
374
+ * write on the full owner scope and the session id, so no write updates a row
375
+ * by the session id alone.
376
+ */
377
+ private identityOf;
378
+ /**
379
+ * Runs `fn` under the per-session lock. The lock serializes the owner-bound
380
+ * secret write against a cancel, an expiry, and the process-done transition, so
381
+ * a terminal transition and the write never interleave (complete mediation).
382
+ * The caller inside `fn` must not call another locked method, or it deadlocks;
383
+ * the failure path of {@link onCredential} calls {@link terminateLocked}, the
384
+ * lock-free variant, for this reason.
385
+ */
386
+ private withSessionLock;
387
+ private countActive;
388
+ private static incrementCount;
389
+ private static decrementCount;
390
+ /**
391
+ * Reserves the capacity for one start under every enforced cap. The method is
392
+ * synchronous, so it runs to completion before the first `await` in
393
+ * {@link start}. Two concurrent starts for one owner cannot interleave inside
394
+ * it: the first reserves the owner slot, and the second reads the incremented
395
+ * count and fails closed with the fixed 429 cap error. The method holds the
396
+ * per-owner, per-agent, and per-company semantics: it counts the agent slot
397
+ * only for an agent-scoped login, because a null agent id is not a shared key
398
+ * across owners. It increments no counter on a rejection, so a rejected start
399
+ * reserves nothing.
400
+ */
401
+ private reserveCapacity;
402
+ /**
403
+ * Releases a capacity reservation exactly one time. The `released` flag makes
404
+ * the release idempotent, so an early start failure and the terminal cleanup
405
+ * never double-release one reservation. The method decrements the same counters
406
+ * that {@link reserveCapacity} incremented, and it drops the agent counter only
407
+ * for an agent-scoped login.
408
+ */
409
+ private releaseReservation;
410
+ /**
411
+ * Starts a login session. It rate-limits the start, enforces the caps,
412
+ * acquires the lease with an external expiry no later than the deadline,
413
+ * persists the non-secret cleanup record, and starts the one live process.
414
+ * It returns the opaque session id and no token.
415
+ */
416
+ start(scope: SetupTokenSessionScope): Promise<{
417
+ sessionId: string;
418
+ state: SetupTokenSessionState;
419
+ }>;
420
+ private onPrompt;
421
+ /**
422
+ * Receives the minted token from the login process and writes it to the
423
+ * owner-bound secret. The service awaits the compare-and-set. The
424
+ * service never stores the token: it passes the token to the writer, then it
425
+ * drops the reference.
426
+ *
427
+ * The service runs the whole sink under the per-session lock, so a cancel or an
428
+ * expiry cannot interleave with the write. A cancel or an expiry that wins the
429
+ * lock first sets a terminal state; the service then writes no secret and fails
430
+ * closed with the fixed, non-secret error. This is complete mediation: a
431
+ * terminal session never commits a secret write.
432
+ *
433
+ * The writer runs one control-plane transaction. Inside it, the writer first
434
+ * transitions the exact durable row to `stored` with a full-scope conditional
435
+ * update, then writes or rotates the secret on the same transaction handle. The
436
+ * commit establishes the encrypted secret and the `stored` claim together, so a
437
+ * crash between the two steps cannot leave a stored token with no valid claim.
438
+ * The service does not mark the durable row separately; the writer owns the
439
+ * transition.
440
+ *
441
+ * On a successful write the service records the non-secret `secretStored`
442
+ * marker. The process outcome then moves the session to `completed`. A cancel or
443
+ * an expiry that arrives after the write committed sees the `secretStored`
444
+ * marker and reports the completed state; it does not erase the claim (see
445
+ * {@link terminateLocked}).
446
+ *
447
+ * On a zero-row transition or on a storage failure the writer rolls back the
448
+ * whole transaction and rejects. The service then fails closed: it moves the
449
+ * session to `failed`, keeps no secret and no claim, and rejects with a fixed,
450
+ * non-secret error. The factory (or the runner it wraps) awaits this sink, so
451
+ * the rejection ends the login as a failure and the process never reports
452
+ * success.
453
+ */
454
+ private onCredential;
455
+ /**
456
+ * Resolves a session for an operation. It returns the session only when the
457
+ * id exists and the stored scope equals the caller scope in all five fields:
458
+ * the company, the owner, the agent, the adapter, and the environment. A
459
+ * missing session and a cross-scope session both throw the same not-found
460
+ * error, so a caller cannot tell them apart. The full-scope match makes
461
+ * a cross-adapter and a cross-environment session return the same not-found
462
+ * error as a missing session.
463
+ */
464
+ private resolveOwned;
465
+ /**
466
+ * Resolves the immutable scope of a company-and-environment session. The
467
+ * caller provides the company, the owner, and the adapter it derived from the
468
+ * request; the route path gives the company, the actor gives the owner, and
469
+ * the route fixes the adapter. The lookup matches these three fields and the
470
+ * agentless marker, then returns the full scope, including the intrinsic
471
+ * environment.
472
+ *
473
+ * A caller never supplies the environment on a read, a submit, a cancel, or a
474
+ * completion. The environment is intrinsic to the session, so a foreign
475
+ * environment cannot address the session. A missing session and a
476
+ * cross-company, cross-owner, or cross-adapter session all throw the same
477
+ * not-found error. The agentless marker rejects an
478
+ * agent-scoped session, so a company route never resolves an agent session.
479
+ */
480
+ resolveCompanyScope(sessionId: string, key: {
481
+ companyId: string;
482
+ ownerUserId: string;
483
+ adapterType: string;
484
+ }): SetupTokenSessionScope;
485
+ /**
486
+ * Returns the owner descriptor for a session. The company-and-environment
487
+ * routes read it to build the response contract. The scope check runs first,
488
+ * so a cross-scope caller gets the same not-found error. The route
489
+ * projects the descriptor: the public status response drops the login URL; the
490
+ * owner prompt response returns the login URL behind the transport guard.
491
+ */
492
+ describeOwned(sessionId: string, scope: SetupTokenSessionScope): SetupTokenSessionDescriptor;
493
+ /**
494
+ * Returns the prompt view for the authorized owner. The full login URL rides
495
+ * only in this response (SR-5). The route sets `Cache-Control: no-store` and
496
+ * applies the confidential transport guard before it calls this method.
497
+ */
498
+ readPrompt(sessionId: string, scope: SetupTokenSessionScope): SetupTokenPromptView;
499
+ /**
500
+ * Submits the one browser code. It performs the single compare-and-set from
501
+ * `awaiting_code` to `submitting`, then forwards the code to the live process
502
+ * one time. It rejects every later submit, including one after an
503
+ * invalid-code retry (SR-3).
504
+ */
505
+ submitCode(sessionId: string, scope: SetupTokenSessionScope, code: string): {
506
+ state: SetupTokenSessionState;
507
+ };
508
+ /**
509
+ * Cancels a session. It stops the direct child before it releases the lease.
510
+ * It is idempotent: a cancel on a terminal session returns the terminal state.
511
+ */
512
+ cancel(sessionId: string, scope: SetupTokenSessionScope): Promise<{
513
+ state: SetupTokenSessionState;
514
+ }>;
515
+ /**
516
+ * Expires a session on a timeout. It stops the direct child before it releases
517
+ * the lease. The harness can call it, and the deadline timer calls the same
518
+ * path internally.
519
+ */
520
+ expire(sessionId: string, scope: SetupTokenSessionScope): Promise<{
521
+ state: SetupTokenSessionState;
522
+ }>;
523
+ private expireInternal;
524
+ /**
525
+ * Returns the completion contract for the authorized owner. It returns the
526
+ * non-secret `storedSessionId` claim only from a completed session whose
527
+ * owner-bound secret write succeeded. It returns no token. It
528
+ * returns the fixed unavailable error when the session is not completed with a
529
+ * stored secret. The scope check runs first, so a cross-scope caller gets the
530
+ * same not-found error, not the unavailable error.
531
+ *
532
+ * The read leaves the durable row in place as the one-time stored-session
533
+ * claim; the agent-create transaction consumes it. The route sets
534
+ * `Cache-Control: no-store` before it calls this method.
535
+ */
536
+ completeSession(sessionId: string, scope: SetupTokenSessionScope): SetupTokenCompletionView;
537
+ /**
538
+ * Stops the direct child, then runs the idempotent cleanup under the
539
+ * per-session lock. The lock serializes the terminal transition against the
540
+ * owner-bound secret write, so a cancel or an expiry never interleaves with the
541
+ * write (complete mediation). The order stops the child before the lease
542
+ * release on every terminal path.
543
+ */
544
+ private terminate;
545
+ /**
546
+ * The lock-free terminal transition. The caller must already hold the
547
+ * per-session lock. The failure path of {@link onCredential} calls it directly,
548
+ * because that path already holds the lock.
549
+ *
550
+ * If the owner-bound secret write already committed, the delivery won the
551
+ * serialized ordering. The service completes the session and keeps the stored
552
+ * claim; it does not cancel, expire, or erase the claim. This makes the
553
+ * terminal API report the completed state after a successful write, rather than
554
+ * erase it.
555
+ */
556
+ private terminateLocked;
557
+ /**
558
+ * Maps the live process outcome to the terminal state and runs the cleanup
559
+ * under the per-session lock. A cancel or an expire already set the state, so
560
+ * this call is a no-op then.
561
+ */
562
+ private onProcessDone;
563
+ /**
564
+ * Runs the idempotent cleanup for a terminal session: clear the timer, mark
565
+ * the durable record terminal, release the lease, and drop the in-memory
566
+ * session. It clears the in-memory login URL reference promptly (SR-3, SR-5).
567
+ * A cleanup failure stays retryable and records no process output (SR-4).
568
+ *
569
+ * A completed session with a stored secret keeps its durable row as the
570
+ * one-time stored-session claim: the cleanup marks no terminal state and does
571
+ * not remove the row. The agent-create transaction consumes the claim, or the
572
+ * reaper removes the row after the deadline. The cleanup still releases the
573
+ * sandbox lease at once. It retains the in-memory session for the retention
574
+ * window, so the owner can read the completion once.
575
+ */
576
+ private runCleanup;
577
+ /**
578
+ * Purges a retained completed session from memory. It clears the retention
579
+ * timer and drops the in-memory session. The durable stored-session claim
580
+ * stays in the store for the create flow or the reaper.
581
+ */
582
+ private purgeRetained;
583
+ private releaseLeaseSafely;
584
+ /**
585
+ * The startup reaper. It reads the durable store and releases any lease whose
586
+ * session is terminal or past its deadline. It runs after a restart, so it
587
+ * frees a lease that a crash left behind (SR-4). A release failure stays
588
+ * retryable: the reaper leaves the record for a later run.
589
+ */
590
+ reap(now?: number): Promise<{
591
+ released: number;
592
+ failed: number;
593
+ }>;
594
+ /**
595
+ * The graceful-shutdown cleanup. It cancels every live session, so the server
596
+ * stops each direct child before it releases each lease (SR-4).
597
+ */
598
+ shutdown(): Promise<void>;
599
+ /** Returns the count of live sessions. The route and the tests use it. */
600
+ activeSessionCount(): number;
601
+ }
602
+ /**
603
+ * The live pre-`stored` states a session may hold when the credential arrives.
604
+ * The atomic claim writer transitions a row to `stored` only from one of these
605
+ * states. It never transitions a terminal, an already-`stored`, or a foreign row.
606
+ */
607
+ export declare const SETUP_TOKEN_STORED_PREDECESSOR_STATES: readonly SetupTokenSessionState[];
608
+ /**
609
+ * Transitions the exact session row to `stored` with one conditional update. The
610
+ * predicate matches the full owner scope and the session id, an allowed
611
+ * predecessor state, an unexpired deadline against `clock_timestamp()`, and an
612
+ * unconsumed `bound_at`. It uses `UPDATE … RETURNING` and returns true only when
613
+ * exactly one row transitions.
614
+ *
615
+ * The atomic claim writer runs this update on the same transaction handle as the
616
+ * secret write, so the commit establishes the `stored` claim and the encrypted
617
+ * secret together. A zero-row result rolls back the whole transaction, so a
618
+ * stale, expired, terminal, foreign-scope, or already-bound row writes no
619
+ * secret.
620
+ */
621
+ export declare function transitionSetupTokenSessionToStored(executor: Db, identity: SetupTokenCleanupIdentity): Promise<boolean>;
622
+ /**
623
+ * Builds the durable, database-backed cleanup store. It persists only the
624
+ * non-secret record. Every write matches the full owner scope and the session
625
+ * id, so no write updates a row by the session id alone. The
626
+ * claim-consumption write folds the state check, the deadline check, and the
627
+ * consumption into one conditional write.
628
+ */
629
+ export declare function createDbSetupTokenCleanupStore(db: Db): SetupTokenCleanupStore;
630
+ //# sourceMappingURL=setup-token-session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup-token-session.d.ts","sourceRoot":"","sources":["../../src/services/setup-token-session.ts"],"names":[],"mappings":"AAoCA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAI1C;;;;;;GAMG;AACH,MAAM,MAAM,sBAAsB,GAC9B,UAAU,GACV,eAAe,GACf,YAAY,GACZ,QAAQ,GACR,WAAW,GACX,QAAQ,GACR,WAAW,GACX,WAAW,CAAC;AAEhB,8EAA8E;AAC9E,eAAO,MAAM,2BAA2B,EAAE,SAAS,sBAAsB,EAKxE,CAAC;AAEF,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAE7E;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,GAAG,IAAI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