@opengeni/worker-bundle 2.0.1 → 2.0.2-canary.38789554071001

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 (379) hide show
  1. package/dist/activities/agent-run-admission.d.ts +1 -12
  2. package/dist/activities/agent-turn/admission.d.ts +88 -10
  3. package/dist/activities/agent-turn/agent-build.d.ts +14 -3
  4. package/dist/activities/agent-turn/claim.d.ts +4 -1
  5. package/dist/activities/agent-turn/claude-core.d.ts +195 -0
  6. package/dist/activities/agent-turn/code-search.d.ts +60 -0
  7. package/dist/activities/agent-turn/codex-capacity.d.ts +3 -0
  8. package/dist/activities/agent-turn/codex-core-capacity.d.ts +37 -0
  9. package/dist/activities/agent-turn/codex-core-claim.d.ts +40 -0
  10. package/dist/activities/agent-turn/codex-core-errors.d.ts +102 -0
  11. package/dist/activities/agent-turn/codex-core-failover.d.ts +15 -0
  12. package/dist/activities/agent-turn/codex-core-requests.d.ts +28 -0
  13. package/dist/activities/agent-turn/codex-core-settlement.d.ts +77 -0
  14. package/dist/activities/agent-turn/codex-credit-policy.d.ts +30 -0
  15. package/dist/activities/agent-turn/codex-plan-entitlement.d.ts +105 -0
  16. package/dist/activities/agent-turn/codex-usage-policy.d.ts +2 -0
  17. package/dist/activities/agent-turn/codex.d.ts +2 -19
  18. package/dist/activities/agent-turn/compaction-interruption.d.ts +32 -0
  19. package/dist/activities/agent-turn/compaction-prep.d.ts +30 -1
  20. package/dist/activities/agent-turn/credential-leases.d.ts +64 -37
  21. package/dist/activities/agent-turn/credential-restriction.d.ts +3 -0
  22. package/dist/activities/agent-turn/errors.d.ts +185 -26
  23. package/dist/activities/agent-turn/failure-settlement.d.ts +10 -43
  24. package/dist/activities/agent-turn/final-reply.d.ts +18 -0
  25. package/dist/activities/agent-turn/finalization-monitor.d.ts +7 -2
  26. package/dist/activities/agent-turn/finalization.d.ts +2 -0
  27. package/dist/activities/agent-turn/github-repository-bindings.d.ts +2 -0
  28. package/dist/activities/agent-turn/governance-model.d.ts +13 -1
  29. package/dist/activities/agent-turn/history-sink.d.ts +4 -1
  30. package/dist/activities/agent-turn/history.d.ts +2 -0
  31. package/dist/activities/agent-turn/input-wait-reply.d.ts +76 -0
  32. package/dist/activities/agent-turn/meaningful-output.d.ts +9 -0
  33. package/dist/activities/agent-turn/media-artifacts.d.ts +5 -3
  34. package/dist/activities/agent-turn/model-call-admission.d.ts +15 -0
  35. package/dist/activities/agent-turn/model-usage.d.ts +56 -14
  36. package/dist/activities/agent-turn/model-wire-dispatch.d.ts +15 -0
  37. package/dist/activities/agent-turn/optional-repositories.d.ts +59 -0
  38. package/dist/activities/agent-turn/prompt-tool-availability.d.ts +17 -0
  39. package/dist/activities/agent-turn/provider-dispatch-barrier.d.ts +12 -1
  40. package/dist/activities/agent-turn/provider-recovery-copy.d.ts +24 -0
  41. package/dist/activities/agent-turn/provider-recovery-metrics.d.ts +18 -0
  42. package/dist/activities/agent-turn/provider-recovery-policy.d.ts +6 -0
  43. package/dist/activities/agent-turn/quiescence.d.ts +6 -7
  44. package/dist/activities/agent-turn/recovery-warning.d.ts +6 -5
  45. package/dist/activities/agent-turn/refresh-credentials.d.ts +6 -0
  46. package/dist/activities/agent-turn/run-credentials.d.ts +9 -5
  47. package/dist/activities/agent-turn/run.d.ts +27 -2
  48. package/dist/activities/agent-turn/sandbox-establish.d.ts +1 -0
  49. package/dist/activities/agent-turn/sandbox-provision.d.ts +25 -1
  50. package/dist/activities/agent-turn/sandbox-route.d.ts +3 -0
  51. package/dist/activities/agent-turn/sandbox-runtime.d.ts +1 -1
  52. package/dist/activities/agent-turn/secret-resolver.d.ts +64 -0
  53. package/dist/activities/agent-turn/session-title.d.ts +60 -3
  54. package/dist/activities/agent-turn/session-usage-custody.d.ts +66 -0
  55. package/dist/activities/agent-turn/skill-checkout.d.ts +25 -6
  56. package/dist/activities/agent-turn/skill-read.d.ts +70 -2
  57. package/dist/activities/agent-turn/skill-search.d.ts +2 -0
  58. package/dist/activities/agent-turn/skill-tools.d.ts +41 -4
  59. package/dist/activities/agent-turn/skill-transfer.d.ts +18 -6
  60. package/dist/activities/agent-turn/stream-attempt.d.ts +6 -3
  61. package/dist/activities/agent-turn/subscription-capacity-arming.d.ts +41 -0
  62. package/dist/activities/agent-turn/subscription-core-capacity.d.ts +86 -0
  63. package/dist/activities/agent-turn/subscription-core-failover.d.ts +69 -0
  64. package/dist/activities/agent-turn/subscription-core-placed.d.ts +14 -0
  65. package/dist/activities/agent-turn/subscription-core-requests.d.ts +109 -0
  66. package/dist/activities/agent-turn/subscription-core-settlement.d.ts +112 -0
  67. package/dist/activities/agent-turn/subscription-lease.d.ts +44 -0
  68. package/dist/activities/agent-turn/subscription-serving-capacity.d.ts +6 -0
  69. package/dist/activities/agent-turn/subscription-serving-catalog.d.ts +13 -0
  70. package/dist/activities/agent-turn/subscription-serving-claim.d.ts +30 -0
  71. package/dist/activities/agent-turn/subscription-serving-providers.d.ts +2 -0
  72. package/dist/activities/agent-turn/tool-environment.d.ts +31 -6
  73. package/dist/activities/agent-turn/tool-policy.d.ts +55 -3
  74. package/dist/activities/agent-turn/turn-context.d.ts +104 -5
  75. package/dist/activities/agent-turn/web-search.d.ts +57 -0
  76. package/dist/activities/agent-turn/xai-core.d.ts +96 -0
  77. package/dist/activities/automations.d.ts +3 -1
  78. package/dist/activities/browser-deadline-checkpoint.d.ts +34 -0
  79. package/dist/activities/capabilities.d.ts +8 -20
  80. package/dist/activities/codemode-dispatcher.d.ts +20 -3
  81. package/dist/activities/codex-capacity.d.ts +1 -56
  82. package/dist/activities/codex-image-generation.d.ts +49 -3
  83. package/dist/activities/common.d.ts +3 -1
  84. package/dist/activities/context-compaction.d.ts +41 -2
  85. package/dist/activities/environment.d.ts +1 -19
  86. package/dist/activities/gmail-files.d.ts +50 -0
  87. package/dist/activities/goals.d.ts +1 -9
  88. package/dist/activities/incident-telemetry-authority.d.ts +5 -2
  89. package/dist/activities/incident-telemetry-preflight.d.ts +10 -3
  90. package/dist/activities/knowledge-indexing.d.ts +19 -0
  91. package/dist/activities/mcp-account-routes.d.ts +2 -21
  92. package/dist/activities/model-call-fact-reconciler.d.ts +34 -0
  93. package/dist/activities/open-suffix-resume.d.ts +15 -0
  94. package/dist/activities/parent-wake.d.ts +17 -12
  95. package/dist/activities/programmatic-approvals.d.ts +10 -0
  96. package/dist/activities/requester-unavailable-receipt.d.ts +8 -0
  97. package/dist/activities/retained-screenshots.d.ts +7 -2
  98. package/dist/activities/run-credential-renewal.d.ts +1 -0
  99. package/dist/activities/run-credentials.d.ts +16 -4
  100. package/dist/activities/run-input.d.ts +17 -0
  101. package/dist/activities/sandbox-lease.d.ts +132 -12
  102. package/dist/activities/scheduled-tasks.d.ts +4 -35
  103. package/dist/activities/session-archive.d.ts +58 -0
  104. package/dist/activities/session-state.d.ts +15 -3
  105. package/dist/activities/session-storage.d.ts +44 -0
  106. package/dist/activities/subscription-core-claude-waits.d.ts +2 -0
  107. package/dist/activities/subscription-core-codex-quota.d.ts +25 -0
  108. package/dist/activities/subscription-core-codex-waits.d.ts +153 -0
  109. package/dist/activities/subscription-core-image-operation.d.ts +29 -0
  110. package/dist/activities/subscription-core-usage-recheck.d.ts +49 -0
  111. package/dist/activities/subscription-core-wait-bindings.d.ts +3 -0
  112. package/dist/activities/subscription-core-xai-quota.d.ts +30 -0
  113. package/dist/activities/subscription-core-xai-waits.d.ts +2 -0
  114. package/dist/activities/types.d.ts +68 -5
  115. package/dist/activities/video-generation-admission.d.ts +2 -8
  116. package/dist/activities/video-generation-credential.d.ts +15 -12
  117. package/dist/activities/video-generation-subscription-core.d.ts +70 -0
  118. package/dist/activities/workspace-capture.d.ts +2 -0
  119. package/dist/activities/workspace-credential-provider.d.ts +47 -0
  120. package/dist/activities/xai-auth.d.ts +6 -18
  121. package/dist/activities/xai-image-generation.d.ts +22 -6
  122. package/dist/{activities-control-QA6OLRQY.js → activities-control-5IIVRXLA.js} +1569 -2883
  123. package/dist/activities-control-5IIVRXLA.js.map +1 -0
  124. package/dist/activities-control.d.ts +64 -4
  125. package/dist/{activities-turn-YVVKCGAK.js → activities-turn-FLYJOM54.js} +9300 -4403
  126. package/dist/activities-turn-FLYJOM54.js.map +1 -0
  127. package/dist/activities.d.ts +64 -4
  128. package/dist/artifact-materializer-entry.js +107 -36
  129. package/dist/artifact-materializer-entry.js.map +1 -1
  130. package/dist/artifact-outbox-entry.js +132 -61
  131. package/dist/artifact-outbox-entry.js.map +1 -1
  132. package/dist/browser-deadline-checkpoint-contract.d.ts +2 -0
  133. package/dist/{chunk-GDCLDKSH.js → chunk-24GP3BX5.js} +79 -72
  134. package/dist/chunk-24GP3BX5.js.map +1 -0
  135. package/dist/{chunk-RAMNYSAW.js → chunk-4ER3YXOT.js} +22 -4
  136. package/dist/chunk-4ER3YXOT.js.map +1 -0
  137. package/dist/{chunk-I7HKKMUJ.js → chunk-5NNS4327.js} +734 -58
  138. package/dist/chunk-5NNS4327.js.map +1 -0
  139. package/dist/chunk-MVESOYFC.js +3746 -0
  140. package/dist/chunk-MVESOYFC.js.map +1 -0
  141. package/dist/{chunk-M3NVMF2V.js → chunk-N57B3PJ5.js} +2307 -3951
  142. package/dist/chunk-N57B3PJ5.js.map +1 -0
  143. package/dist/chunk-NQDVJ6RI.js +2823 -0
  144. package/dist/chunk-NQDVJ6RI.js.map +1 -0
  145. package/dist/chunk-O7UPBWXK.js +79 -0
  146. package/dist/chunk-O7UPBWXK.js.map +1 -0
  147. package/dist/chunk-W2QSM5HR.js +414 -0
  148. package/dist/chunk-W2QSM5HR.js.map +1 -0
  149. package/dist/chunk-ZN3XJR33.js +227 -0
  150. package/dist/chunk-ZN3XJR33.js.map +1 -0
  151. package/dist/editable-artifact-outbox-dispatcher.d.ts +12 -1
  152. package/dist/editable-artifact-outbox-service.d.ts +3 -1
  153. package/dist/host-export-pump.d.ts +3 -1
  154. package/dist/host-export.d.ts +2 -2
  155. package/dist/host-export.js +1 -1
  156. package/dist/http.d.ts +1 -1
  157. package/dist/index.d.ts +49 -48
  158. package/dist/index.js +835 -256
  159. package/dist/index.js.map +1 -1
  160. package/dist/internal-maintenance.d.ts +63 -0
  161. package/dist/maintenance-cadence.d.ts +43 -0
  162. package/dist/observability-metrics.d.ts +293 -24
  163. package/dist/onepassword-vault-provider.d.ts +7 -0
  164. package/dist/parent-wake-PCLH7A3Y.js +24 -0
  165. package/dist/parent-wake-PCLH7A3Y.js.map +1 -0
  166. package/dist/personal-github-git-credentials.d.ts +1 -1
  167. package/dist/readiness-checks.d.ts +39 -0
  168. package/dist/retained-process-retry.d.ts +7 -0
  169. package/dist/sandbox-lease-BJYU72N3.js +84 -0
  170. package/dist/sandbox-lease-BJYU72N3.js.map +1 -0
  171. package/dist/sandbox-reaper-contract.d.ts +25 -0
  172. package/dist/sandbox-resume.d.ts +72 -4
  173. package/dist/sandbox-routing.d.ts +4 -2
  174. package/dist/session-event-fanout.d.ts +6 -0
  175. package/dist/site-auth-maintenance-WK3MR2PV.js +12 -0
  176. package/dist/site-auth-maintenance-WK3MR2PV.js.map +1 -0
  177. package/dist/telemetry-scheduler.d.ts +14 -0
  178. package/dist/temporal-runtime-logger.d.ts +22 -0
  179. package/dist/turn-task-queue-reader.d.ts +18 -0
  180. package/dist/turn-worker-activity-telemetry.d.ts +47 -0
  181. package/dist/worker-service-lifecycle.d.ts +12 -0
  182. package/dist/workflow-bundle.js +468 -71
  183. package/dist/workflows/activities.d.ts +1 -1
  184. package/dist/workflows/browser-deadline-checkpoint.d.ts +10 -0
  185. package/dist/workflows/sandbox-reaper.d.ts +10 -1
  186. package/dist/workflows/scheduled-tasks.d.ts +4 -0
  187. package/dist/workflows/session-storage.d.ts +2 -0
  188. package/dist/workflows/session.d.ts +36 -0
  189. package/dist/workflows/site-auth-maintenance.d.ts +2 -1
  190. package/dist/workflows/workflow-wake.d.ts +14 -3
  191. package/dist/workflows.d.ts +3 -1
  192. package/package.json +26 -20
  193. package/src/activities/agent-run-admission.ts +1 -82
  194. package/src/activities/agent-turn/admission.ts +175 -24
  195. package/src/activities/agent-turn/agent-build.ts +226 -145
  196. package/src/activities/agent-turn/claim.ts +363 -64
  197. package/src/activities/agent-turn/claude-core.ts +587 -0
  198. package/src/activities/agent-turn/code-search.ts +275 -0
  199. package/src/activities/agent-turn/codex-capacity.ts +30 -757
  200. package/src/activities/agent-turn/codex-core-capacity.ts +190 -0
  201. package/src/activities/agent-turn/codex-core-claim.ts +83 -0
  202. package/src/activities/agent-turn/codex-core-errors.ts +308 -0
  203. package/src/activities/agent-turn/codex-core-failover.ts +73 -0
  204. package/src/activities/agent-turn/codex-core-requests.ts +86 -0
  205. package/src/activities/agent-turn/codex-core-settlement.ts +263 -0
  206. package/src/activities/agent-turn/codex-credit-policy.ts +247 -0
  207. package/src/activities/agent-turn/codex-plan-entitlement.ts +254 -0
  208. package/src/activities/agent-turn/codex-usage-policy.ts +2 -0
  209. package/src/activities/agent-turn/codex.ts +8 -76
  210. package/src/activities/agent-turn/compaction-interruption.ts +56 -0
  211. package/src/activities/agent-turn/compaction-prep.ts +249 -36
  212. package/src/activities/agent-turn/credential-leases.ts +269 -214
  213. package/src/activities/agent-turn/credential-restriction.ts +14 -0
  214. package/src/activities/agent-turn/errors.ts +1152 -82
  215. package/src/activities/agent-turn/failure-settlement.ts +879 -886
  216. package/src/activities/agent-turn/final-reply.ts +46 -0
  217. package/src/activities/agent-turn/finalization-monitor.ts +17 -5
  218. package/src/activities/agent-turn/finalization.ts +107 -88
  219. package/src/activities/agent-turn/github-repository-bindings.ts +3 -1
  220. package/src/activities/agent-turn/governance-model.ts +90 -22
  221. package/src/activities/agent-turn/history-sink.ts +42 -12
  222. package/src/activities/agent-turn/history.ts +25 -5
  223. package/src/activities/agent-turn/input-wait-reply.ts +139 -0
  224. package/src/activities/agent-turn/knowledge-source-tools.ts +2 -0
  225. package/src/activities/agent-turn/meaningful-output.ts +44 -0
  226. package/src/activities/agent-turn/media-artifacts.ts +3 -1
  227. package/src/activities/agent-turn/model-call-admission.ts +114 -0
  228. package/src/activities/agent-turn/model-usage.ts +299 -233
  229. package/src/activities/agent-turn/model-wire-dispatch.ts +27 -0
  230. package/src/activities/agent-turn/optional-repositories.ts +224 -0
  231. package/src/activities/agent-turn/prompt-tool-availability.ts +27 -0
  232. package/src/activities/agent-turn/provider-dispatch-barrier.ts +22 -0
  233. package/src/activities/agent-turn/provider-recovery-copy.ts +76 -0
  234. package/src/activities/agent-turn/provider-recovery-metrics.ts +64 -0
  235. package/src/activities/agent-turn/provider-recovery-policy.ts +25 -0
  236. package/src/activities/agent-turn/quiescence.ts +7 -7
  237. package/src/activities/agent-turn/recovery-warning.ts +6 -8
  238. package/src/activities/agent-turn/refresh-credentials.ts +44 -0
  239. package/src/activities/agent-turn/run-credentials.ts +124 -76
  240. package/src/activities/agent-turn/run.ts +501 -112
  241. package/src/activities/agent-turn/sandbox-establish.ts +152 -75
  242. package/src/activities/agent-turn/sandbox-provision.ts +54 -1
  243. package/src/activities/agent-turn/sandbox-route.ts +4 -1
  244. package/src/activities/agent-turn/sandbox-runtime.ts +319 -11
  245. package/src/activities/agent-turn/secret-resolver.ts +155 -0
  246. package/src/activities/agent-turn/session-title.ts +177 -12
  247. package/src/activities/agent-turn/session-usage-custody.ts +170 -0
  248. package/src/activities/agent-turn/skill-checkout.ts +111 -24
  249. package/src/activities/agent-turn/skill-install.ts +1 -1
  250. package/src/activities/agent-turn/skill-read.ts +374 -28
  251. package/src/activities/agent-turn/skill-save.ts +35 -7
  252. package/src/activities/agent-turn/skill-search.ts +9 -0
  253. package/src/activities/agent-turn/skill-selection.ts +4 -0
  254. package/src/activities/agent-turn/skill-tools.ts +208 -21
  255. package/src/activities/agent-turn/skill-transfer.ts +68 -23
  256. package/src/activities/agent-turn/stream-attempt.ts +634 -111
  257. package/src/activities/agent-turn/subscription-capacity-arming.ts +81 -0
  258. package/src/activities/agent-turn/subscription-core-capacity.ts +439 -0
  259. package/src/activities/agent-turn/subscription-core-failover.ts +229 -0
  260. package/src/activities/agent-turn/subscription-core-placed.ts +37 -0
  261. package/src/activities/agent-turn/subscription-core-requests.ts +271 -0
  262. package/src/activities/agent-turn/subscription-core-settlement.ts +234 -0
  263. package/src/activities/agent-turn/subscription-lease.ts +140 -0
  264. package/src/activities/agent-turn/subscription-serving-capacity.ts +195 -0
  265. package/src/activities/agent-turn/subscription-serving-catalog.ts +71 -0
  266. package/src/activities/agent-turn/subscription-serving-claim.ts +178 -0
  267. package/src/activities/agent-turn/subscription-serving-providers.ts +15 -0
  268. package/src/activities/agent-turn/tool-environment.ts +384 -292
  269. package/src/activities/agent-turn/tool-policy.ts +104 -4
  270. package/src/activities/agent-turn/tool-result-spill.ts +1 -0
  271. package/src/activities/agent-turn/turn-context.ts +124 -8
  272. package/src/activities/agent-turn/web-search.ts +431 -0
  273. package/src/activities/agent-turn/xai-core.ts +301 -0
  274. package/src/activities/automations.ts +81 -6
  275. package/src/activities/browser-deadline-checkpoint.ts +297 -0
  276. package/src/activities/capabilities.ts +53 -213
  277. package/src/activities/codemode-dispatcher.ts +236 -14
  278. package/src/activities/codex-capacity.ts +27 -380
  279. package/src/activities/codex-image-generation.ts +252 -42
  280. package/src/activities/common.ts +12 -0
  281. package/src/activities/connector-attachments.ts +3 -1
  282. package/src/activities/context-compaction.ts +182 -21
  283. package/src/activities/environment.ts +18 -106
  284. package/src/activities/gmail-files.ts +108 -0
  285. package/src/activities/goals.ts +120 -204
  286. package/src/activities/image-generation-operation.ts +1 -1
  287. package/src/activities/incident-telemetry-authority.ts +80 -50
  288. package/src/activities/incident-telemetry-preflight.ts +27 -15
  289. package/src/activities/knowledge-indexing.ts +287 -17
  290. package/src/activities/knowledge-source-sync.ts +10 -0
  291. package/src/activities/mcp-account-routes.ts +2 -124
  292. package/src/activities/model-call-fact-reconciler.ts +112 -0
  293. package/src/activities/open-suffix-resume.ts +122 -88
  294. package/src/activities/parent-wake.ts +89 -21
  295. package/src/activities/programmatic-approvals.ts +26 -0
  296. package/src/activities/requester-unavailable-receipt.ts +14 -0
  297. package/src/activities/retained-screenshots.ts +135 -24
  298. package/src/activities/run-credential-renewal.ts +13 -1
  299. package/src/activities/run-credentials.ts +61 -19
  300. package/src/activities/run-input.ts +124 -9
  301. package/src/activities/sandbox-lease.ts +1615 -73
  302. package/src/activities/scheduled-tasks.ts +780 -147
  303. package/src/activities/session-archive.ts +382 -0
  304. package/src/activities/session-state.ts +219 -10
  305. package/src/activities/session-storage.ts +124 -0
  306. package/src/activities/site-auth-maintenance.ts +5 -2
  307. package/src/activities/subscription-core-claude-waits.ts +49 -0
  308. package/src/activities/subscription-core-codex-quota.ts +46 -0
  309. package/src/activities/subscription-core-codex-waits.ts +488 -0
  310. package/src/activities/subscription-core-image-operation.ts +126 -0
  311. package/src/activities/subscription-core-usage-recheck.ts +146 -0
  312. package/src/activities/subscription-core-wait-bindings.ts +12 -0
  313. package/src/activities/subscription-core-xai-quota.ts +85 -0
  314. package/src/activities/subscription-core-xai-waits.ts +48 -0
  315. package/src/activities/types.ts +85 -9
  316. package/src/activities/video-generation-admission.ts +1 -36
  317. package/src/activities/video-generation-credential.ts +38 -56
  318. package/src/activities/video-generation-reconciliation.ts +150 -131
  319. package/src/activities/video-generation-subscription-core.ts +180 -0
  320. package/src/activities/workspace-capture.ts +13 -2
  321. package/src/activities/workspace-credential-provider.ts +302 -0
  322. package/src/activities/xai-auth.ts +34 -112
  323. package/src/activities/xai-image-generation.ts +84 -36
  324. package/src/activities-control.ts +8 -0
  325. package/src/activities-turn.ts +5 -0
  326. package/src/activities.ts +17 -0
  327. package/src/activity-services.ts +29 -4
  328. package/src/browser-deadline-checkpoint-contract.ts +5 -0
  329. package/src/editable-artifact-hint-broker.ts +3 -0
  330. package/src/editable-artifact-materializer-service.ts +85 -39
  331. package/src/editable-artifact-materializer-subprocess.ts +47 -2
  332. package/src/editable-artifact-outbox-dispatcher.ts +107 -46
  333. package/src/editable-artifact-outbox-service.ts +55 -25
  334. package/src/github-rest-mcp.ts +1 -1
  335. package/src/host-export-pump.ts +26 -4
  336. package/src/host-export.ts +4 -1
  337. package/src/http.ts +4 -2
  338. package/src/index.ts +222 -282
  339. package/src/internal-maintenance.ts +347 -0
  340. package/src/maintenance-cadence.ts +156 -0
  341. package/src/observability-metrics.ts +1173 -73
  342. package/src/onepassword-vault-provider.ts +11 -0
  343. package/src/personal-github-git-credentials.ts +3 -1
  344. package/src/pr-review-credentials.ts +1 -1
  345. package/src/readiness-checks.ts +113 -0
  346. package/src/retained-process-retry.ts +36 -0
  347. package/src/sandbox-reaper-contract.ts +33 -0
  348. package/src/sandbox-resume.ts +444 -73
  349. package/src/sandbox-routing.ts +230 -75
  350. package/src/session-event-fanout.ts +23 -0
  351. package/src/telemetry-scheduler.ts +53 -0
  352. package/src/temporal-runtime-logger.ts +44 -0
  353. package/src/turn-task-queue-reader.ts +110 -0
  354. package/src/turn-worker-activity-telemetry.ts +209 -0
  355. package/src/worker-service-lifecycle.ts +54 -1
  356. package/src/workflows/activities.ts +16 -1
  357. package/src/workflows/browser-deadline-checkpoint.ts +55 -0
  358. package/src/workflows/file-upload-reaper.ts +2 -0
  359. package/src/workflows/sandbox-reaper.ts +88 -0
  360. package/src/workflows/scheduled-tasks.ts +26 -13
  361. package/src/workflows/session-storage.ts +19 -0
  362. package/src/workflows/session.ts +238 -33
  363. package/src/workflows/site-auth-maintenance.ts +2 -1
  364. package/src/workflows/workflow-wake.ts +26 -4
  365. package/src/workflows.ts +7 -0
  366. package/dist/activities/agent-turn/xai-capacity.d.ts +0 -2
  367. package/dist/activities/codex-fleet-shadow.d.ts +0 -74
  368. package/dist/activities/codex-rotation.d.ts +0 -200
  369. package/dist/activities/xai-quota.d.ts +0 -3
  370. package/dist/activities-control-QA6OLRQY.js.map +0 -1
  371. package/dist/activities-turn-YVVKCGAK.js.map +0 -1
  372. package/dist/chunk-GDCLDKSH.js.map +0 -1
  373. package/dist/chunk-I7HKKMUJ.js.map +0 -1
  374. package/dist/chunk-M3NVMF2V.js.map +0 -1
  375. package/dist/chunk-RAMNYSAW.js.map +0 -1
  376. package/src/activities/agent-turn/xai-capacity.ts +0 -257
  377. package/src/activities/codex-fleet-shadow.ts +0 -306
  378. package/src/activities/codex-rotation.ts +0 -685
  379. package/src/activities/xai-quota.ts +0 -35
@@ -0,0 +1,15 @@
1
+ import type { RunAgentTurnResult } from "../types.js";
2
+ import type { CodexCredentialFailure } from "./errors.js";
3
+ import type { TurnFailureDeps } from "./failure-settlement.js";
4
+ import type { CodexSubscriptionCoreTurn } from "./turn-context.js";
5
+ /** The shared per-turn refusal bound, under its M3 name. */
6
+ export declare const SUBSCRIPTION_CORE_CODEX_TURN_REFUSAL_LIMIT = 4;
7
+ /** Pure bound: fail over while under the limit, stop at it. */
8
+ export declare function coreCodexFailoverDisposition(refusals: number | null, limit?: number): "failover" | "exhausted" | "unrecorded";
9
+ /**
10
+ * Re-place the same turn after graceful source disappearance, without a
11
+ * refusal/quarantine budget, or settle a recorded refusal within its bound.
12
+ * A usage-verification refusal (`origin`) does not count toward the bound.
13
+ * Returns null when automatic replay is unsafe.
14
+ */
15
+ export declare function failOverCoreCodexTurn(deps: TurnFailureDeps, core: CodexSubscriptionCoreTurn, refusal: CodexCredentialFailure | "source_disconnected"): Promise<RunAgentTurnResult | null>;
@@ -0,0 +1,28 @@
1
+ import type { CodexProviderRequestIdentity, CodexProviderRequestSettlement } from "@opengeni/codex";
2
+ import { fetchCodexUsage } from "@opengeni/codex";
3
+ import { buildSubscriptionCoreCodexOperationFetch, type Database, type SubscriptionCoreTurnIdentity, type SubscriptionCoreCodexLeaseRef } from "@opengeni/db";
4
+ export { providerRequestIdPrefix } from "./subscription-core-requests.js";
5
+ /** The usage probe is a finite read, authorized by this attempt's chat lease. */
6
+ export declare function buildCoreCodexUsageReader(db: Database, identity: SubscriptionCoreTurnIdentity, ref: SubscriptionCoreCodexLeaseRef, execution: {
7
+ attemptId: string;
8
+ executionGeneration: number;
9
+ }, fetchImpl?: Parameters<typeof buildSubscriptionCoreCodexOperationFetch>[4]): typeof fetchCodexUsage;
10
+ /** One attempt's bounded Codex request custody (the shared custody, Codex errors). */
11
+ export declare function createCoreCodexRequests(deps: {
12
+ reserve: (request: CodexProviderRequestIdentity) => Promise<{
13
+ operationId: string;
14
+ }>;
15
+ settle: (request: {
16
+ operationId: string;
17
+ outcome: CodexProviderRequestSettlement["outcome"];
18
+ }) => Promise<void>;
19
+ }): {
20
+ reserve(request: import("./subscription-core-requests.js").SubscriptionCoreRequestIdentity): Promise<void>;
21
+ observe(request: import("./subscription-core-requests.js").SubscriptionCoreRequestSettlement): Promise<void>;
22
+ checkpoint(): Promise<void>;
23
+ canRecover(): boolean;
24
+ hasUnknownOutcome(): boolean;
25
+ unknownIsOwnAndSettled(): boolean;
26
+ admissionRefused(): boolean;
27
+ lastResponseReceivedAt(): Date | null;
28
+ };
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Failure, usage and quota bookkeeping for Codex turns placed by the shared
3
+ * subscription core (M3 PR 1, inventory EP-T06..T08). Every write is scoped
4
+ * to the exact accepted turn and its live lease, and is best effort: it can
5
+ * never change how the turn itself settles.
6
+ */
7
+ import type { CodexUsageHeaderSnapshot } from "@opengeni/codex";
8
+ import { type Database } from "@opengeni/db";
9
+ import type { SubscriptionQuota } from "@opengeni/subscriptions";
10
+ import { type CodexCredentialFailure } from "./errors.js";
11
+ import type { CodexTurnLease } from "./credential-leases.js";
12
+ import type { CodexSubscriptionCoreTurn, ProviderTurnState } from "./turn-context.js";
13
+ /** Record a Codex model call that produced a response (diagnostic phase `completed`). */
14
+ export declare function observeCodexResponseCompletion(providerTurn: Pick<ProviderTurnState, "lastCodexResponseCompletedAt">, event: {
15
+ phase: string;
16
+ }, now?: number): void;
17
+ /**
18
+ * When the binding's cache clock may advance: only after a model call that
19
+ * produced a response. A refused or failed call leaves no warm cache.
20
+ */
21
+ export declare function coreCodexModelCallCompletedAt(providerTurn: Pick<ProviderTurnState, "lastCodexResponseCompletedAt">): Date | null;
22
+ /** Codex usage response headers as a shared quota observation (design 2.2). */
23
+ export declare function codexUsageHeadersQuotaObservation(snapshot: CodexUsageHeaderSnapshot, observedRefreshGeneration: number): SubscriptionQuota;
24
+ /** A Codex quota or rate-limit refusal as a shared quota observation. */
25
+ export declare function codexRefusalQuotaObservation(failure: CodexCredentialFailure, observedRefreshGeneration: number, now: Date): SubscriptionQuota | null;
26
+ /**
27
+ * Record a definitive Codex refusal against the leased connection: always a
28
+ * (turn, connection) failure receipt, which also counts toward the per-turn
29
+ * failover bound, then the connection state that keeps placement away from
30
+ * it (M3 PR 2a):
31
+ *
32
+ * - quota and rate limits: a quota observation fenced on the refresh
33
+ * generation the refused bearer carried (exhausted until the reset);
34
+ * - a 401 that survived refresh: health `needs_relogin` (the refresh seam
35
+ * itself already marks a refused OAuth refresh);
36
+ * - a 403 that survived refresh: a time-bound health quarantine;
37
+ * - a plan-entitlement refusal: a cooldown of that model on the connection.
38
+ *
39
+ * A credit-policy refusal (`failure.origin`) is the worker's own refusal, not
40
+ * a provider usage reading, so it is recorded as a `refusal` observation: it
41
+ * keeps a stored exhausted window with a known future reset (for example the
42
+ * weekly `secondary` window) instead of replacing every window, and only a
43
+ * real usage reading replaces them all (design 2.2).
44
+ *
45
+ * Every write requires the exact accepted turn, the enabled gate and this
46
+ * turn's live lease. `receipt` reports whether the refusal was recorded.
47
+ */
48
+ export declare function recordCoreCodexRefusal(input: {
49
+ db: Database;
50
+ core: CodexSubscriptionCoreTurn;
51
+ lease: Pick<CodexTurnLease, "holderId" | "generation">;
52
+ failure: CodexCredentialFailure;
53
+ credentialVersion: number | null;
54
+ /** The refused model; required to keep a plan-entitlement refusal model-scoped. */
55
+ modelId?: string | null;
56
+ now?: Date;
57
+ }): Promise<{
58
+ receipt: boolean;
59
+ health: boolean;
60
+ }>;
61
+ /**
62
+ * Finalization for a core turn: the latest usage headers become a quota
63
+ * observation on the leased connection, and a completed model call moves
64
+ * the binding's cache-warmth clock. Both run before the lease is released.
65
+ * `capacityRecovered` reports an observation that ended a stored exhaustion,
66
+ * which the caller turns into a wake for the account's waiters.
67
+ */
68
+ export declare function finalizeCoreCodexUsage(input: {
69
+ db: Database;
70
+ core: CodexSubscriptionCoreTurn;
71
+ lease: Pick<CodexTurnLease, "holderId" | "generation">;
72
+ usage: CodexUsageHeaderSnapshot | null;
73
+ credentialVersion: number | null;
74
+ modelCallCompletedAt: Date | null;
75
+ }): Promise<{
76
+ capacityRecovered: boolean;
77
+ }>;
@@ -0,0 +1,30 @@
1
+ import { fetchCodexUsage, type CodexTokenSnapshot, type CodexUsageHeaderSnapshot, type CodexUsagePayload } from "@opengeni/codex";
2
+ /** Local admission decision, never a synthetic provider/transport error. */
3
+ export declare class CodexIncludedUsageExhaustedError extends Error {
4
+ readonly resetsInSeconds: number | null;
5
+ readonly code = "codex_included_usage_exhausted";
6
+ constructor(resetsInSeconds: number | null);
7
+ }
8
+ export declare class CodexIncludedUsageUnknownError extends Error {
9
+ readonly code = "codex_included_usage_unknown";
10
+ constructor();
11
+ }
12
+ export declare function findCodexCreditPolicyError(error: unknown): CodexIncludedUsageExhaustedError | CodexIncludedUsageUnknownError | null;
13
+ /** A model call can cross the provider's limit; the next call must be admitted again. */
14
+ export declare function createCodexCreditGuard(input: {
15
+ allowExtraCredits?: boolean;
16
+ /** Live accepted-pool admission, rechecked immediately before dispatch. */
17
+ canSpendCredits?: () => Promise<boolean>;
18
+ readUsage?: (token: CodexTokenSnapshot) => Promise<CodexUsagePayload>;
19
+ fetchUsage?: typeof fetchCodexUsage;
20
+ refreshToken?: () => Promise<CodexTokenSnapshot>;
21
+ now?: () => number;
22
+ onUsage?: (snapshot: CodexUsageHeaderSnapshot) => void;
23
+ }): {
24
+ setToken: (next: CodexTokenSnapshot) => void;
25
+ observe: (next: CodexUsageHeaderSnapshot) => void;
26
+ assertObservedUsageAllowsDispatch: () => Promise<void>;
27
+ assertCanDispatch: () => Promise<void>;
28
+ };
29
+ /** No awaited policy work may run after the final physical lease fence. */
30
+ export declare function assertCodexDispatchAdmission(assertCredits: () => Promise<void>, assertLease: () => Promise<void>): Promise<void>;
@@ -0,0 +1,105 @@
1
+ import { type CodexEntitlementRejection } from "@opengeni/codex";
2
+ import { type CodexCredentialPlanRecheck, type CodexPlanEntitlementExclusion } from "@opengeni/db";
3
+ export declare const CODEX_PLAN_ENTITLEMENT_CODE = "codex_plan_entitlement";
4
+ export declare const CODEX_REQUEST_REJECTED_CODE = "codex_request_rejected";
5
+ export type CodexPlanEntitlementFailurePayload = {
6
+ error: string;
7
+ code: typeof CODEX_PLAN_ENTITLEMENT_CODE;
8
+ retryable: false;
9
+ planType: string | null;
10
+ model: string | null;
11
+ detail?: string;
12
+ };
13
+ export type CodexRequestRejectedFailurePayload = {
14
+ error: string;
15
+ code: typeof CODEX_REQUEST_REJECTED_CODE;
16
+ retryable: false;
17
+ planType: string | null;
18
+ detail?: string;
19
+ };
20
+ /**
21
+ * The user-set label of one connected ChatGPT account. The account email is
22
+ * deliberately never used: this text lands in the durable `turn.failed` event
23
+ * that every session reader (including embedding-host end users) can see, and
24
+ * an inherited organization credential's email may be a member's personal
25
+ * address. Without a label the copy says "The connected ChatGPT account".
26
+ */
27
+ export declare function codexAccountDisplayLabel(account: {
28
+ label: string | null;
29
+ } | null | undefined): string | null;
30
+ /** Terminal copy when the serving account's plan does not include the model. */
31
+ export declare function codexPlanEntitlementFailurePayload(input: {
32
+ accountLabel: string | null;
33
+ planType: string | null;
34
+ planChanged: boolean;
35
+ modelId: string | null;
36
+ rejection?: CodexEntitlementRejection | null;
37
+ /** The same turn waits for another connected account instead of failing. */
38
+ waiting?: boolean;
39
+ }): CodexPlanEntitlementFailurePayload;
40
+ /**
41
+ * Terminal copy for an empty Codex rejection. With `planChecked`, the account's
42
+ * plan was re-read and did not explain it, so Opengeni kept the account.
43
+ */
44
+ export declare function codexRequestRejectedFailurePayload(input: {
45
+ accountLabel: string | null;
46
+ planType: string | null;
47
+ rejection: CodexEntitlementRejection;
48
+ planChecked?: boolean;
49
+ }): CodexRequestRejectedFailurePayload;
50
+ /**
51
+ * Admission-time refusal: the only accounts that could serve this turn were
52
+ * already proven not to include its model on their current plan.
53
+ */
54
+ export declare class CodexPlanEntitlementError extends Error {
55
+ readonly payload: CodexPlanEntitlementFailurePayload;
56
+ readonly code = "codex_plan_entitlement";
57
+ constructor(payload: CodexPlanEntitlementFailurePayload);
58
+ }
59
+ export type CodexPlanEntitlementAssessment = {
60
+ kind: "entitlement_lost";
61
+ /**
62
+ * Plan the exclusion binds to: the freshly observed plan, or the
63
+ * recorded plan when the provider reported none.
64
+ */
65
+ planType: string | null;
66
+ /** The provider reported the current plan during this re-check. */
67
+ planObserved: boolean;
68
+ /** The observed plan was reached by a recorded (non-upgrade) plan change. */
69
+ planChanged: boolean;
70
+ credentialVersion: number | null;
71
+ } | {
72
+ kind: "unexplained";
73
+ planType: string | null;
74
+ };
75
+ /** Pure decision over one plan re-check (see `codexPlanEntitlementLost`). */
76
+ export declare function assessCodexPlanEntitlement(rejection: CodexEntitlementRejection, recheck: CodexCredentialPlanRecheck, modelId: string | null): CodexPlanEntitlementAssessment;
77
+ type AdmissionAccount = {
78
+ id: string;
79
+ label: string | null;
80
+ planType: string | null;
81
+ allocatorEnabled: boolean;
82
+ allowedModelIds?: string[] | null;
83
+ planEntitlementExclusion?: CodexPlanEntitlementExclusion | null;
84
+ };
85
+ /**
86
+ * Pure admission check after credential selection found no account. Returns
87
+ * the plan-excluded accounts that alone explain it, or null when capacity,
88
+ * health, or policy (not plan entitlement) is the reason:
89
+ *
90
+ * - a manual pin (user intent) whose account's plan excludes the model;
91
+ * - with rotation off, the active account's plan excludes the model;
92
+ * - with rotation on, every allocatable account permitted for the model is
93
+ * plan-excluded.
94
+ */
95
+ export declare function codexPlanEntitlementAdmissionBlock<T extends AdmissionAccount>(input: {
96
+ accounts: readonly T[];
97
+ modelId: string;
98
+ credentialId: string | null;
99
+ rotationEnabled: boolean;
100
+ activeCredentialId: string | null;
101
+ pinnedCredentialId: string | null;
102
+ pinSource: "manual" | "policy" | null;
103
+ now: Date;
104
+ }): T[] | null;
105
+ export {};
@@ -0,0 +1,2 @@
1
+ /** A provider-reported usage percentage at or above this value is exhausted. */
2
+ export declare const CODEX_USAGE_EXHAUSTED_PCT = 100;
@@ -1,30 +1,13 @@
1
- import { type CodexAccountStatus } from "@opengeni/db";
2
- import { type ResolvedModelProvider, type Settings } from "@opengeni/config";
3
- import type { TurnActivityServices as ActivityServices } from "../types.js";
1
+ import { type ModelProviderApi, type ResolvedModelProvider } from "@opengeni/config";
4
2
  export declare function codexWorkspaceMetricKey(workspaceId: string): string;
5
3
  /** Stable public request identity across partial resumes and activity retries. */
6
4
  export declare function acceptsPromptCacheKeyForTurn(resolvedModel: {
7
5
  provider: {
8
6
  kind: ResolvedModelProvider["kind"];
9
7
  builtin?: boolean;
8
+ api?: ModelProviderApi;
10
9
  };
11
10
  } | null): boolean;
12
- /**
13
- * SELF-HEAL helper for the all-capped rotation idle (invariant 4: BOUNDED, no thrash).
14
- * The turn hot path never refreshes Codex usage — only the usage API route does — so a
15
- * window that has actually reset still reads OVER-threshold from the stale cache, which
16
- * would idle-loop forever. Before idling, refresh LIVE usage for every connected account
17
- * the cache marks exhausted (bounded to the account count), which re-writes the
18
- * cache columns, then return the re-read rows so the ranker can pick up a genuinely-reset
19
- * window THIS turn. Typed quota cooldowns are also refreshed because the provider may
20
- * replace an allowance cycle before its original reset; revision fencing makes that
21
- * repair safe. Generic backpressure and legacy-unknown cooldowns are never reconciled.
22
- * A refresh/read failure is swallowed (fall back to the pre-refresh rows + bounded idle).
23
- */
24
- export declare function refreshCappedCodexUsageRows(db: ActivityServices["db"], settings: Settings, workspaceId: string, accounts: Array<Pick<CodexAccountStatus, "id" | "status" | "primaryUsedPercent" | "secondaryUsedPercent" | "exhaustedUntil" | "exhaustedKind">>, capacitySignals: {
25
- signalCodexCapacityWorkflow?: ActivityServices["signalCodexCapacityWorkflow"] | undefined;
26
- wakeSessionWorkflow: ActivityServices["wakeSessionWorkflow"];
27
- }, acceptedTurnId?: string): Promise<Array<Pick<CodexAccountStatus, "id" | "status" | "primaryUsedPercent" | "secondaryUsedPercent" | "exhaustedUntil" | "exhaustedKind">>>;
28
11
  /**
29
12
  * True once the lifetime last confirmed by Postgres is no longer trustworthy.
30
13
  * A missing or malformed deadline fails closed for a holder that claims to be
@@ -0,0 +1,32 @@
1
+ import type { SessionEvent } from "@opengeni/contracts";
2
+ import type { Database } from "@opengeni/db";
3
+ /**
4
+ * Whether a context compaction ended because its own turn attempt was
5
+ * cancelled (graceful worker shutdown, Pause/Steer/Cancel delivery, or any
6
+ * other Temporal activity cancellation) rather than because the provider or
7
+ * summarizer failed.
8
+ *
9
+ * Structural only: the attempt's cancellation signal state or a typed
10
+ * cancellation error. Never classify by error message text.
11
+ */
12
+ export declare function isContextCompactionInterruption(error: unknown, cancellationSignal: AbortSignal | undefined): boolean;
13
+ /**
14
+ * Settle an already-started compaction landmark as `interrupted` so the
15
+ * timeline neither sticks on "Compacting…" nor reports a summarization
16
+ * failure that never happened. Best effort: the cancellation is the
17
+ * authoritative outcome and must keep propagating, so a landmark write that
18
+ * loses to a closing control or to a database fault is logged and dropped.
19
+ */
20
+ export declare function settleContextCompactionInterruption(db: Database, scope: {
21
+ accountId: string;
22
+ workspaceId: string;
23
+ sessionId: string;
24
+ turnId: string;
25
+ executionGeneration: number;
26
+ attemptId: string;
27
+ }, options: {
28
+ publishLiveEvents?: (events: SessionEvent[]) => Promise<void>;
29
+ observability?: {
30
+ warn(message: string, fields?: Record<string, unknown>): void;
31
+ };
32
+ }): Promise<void>;
@@ -1,4 +1,4 @@
1
- import { type Settings } from "@opengeni/config";
1
+ import { type ModelProviderApi, type Settings } from "@opengeni/config";
2
2
  import { maybeCompactContext } from "../context-compaction.js";
3
3
  import type { CompactionSummarizer, RemoteCompactionV2Requester } from "../context-compaction.js";
4
4
  import type { TurnActivityServices as ActivityServices, RunAgentTurnInput, RunAgentTurnResult } from "../types.js";
@@ -11,10 +11,19 @@ import type { AttemptIdentityState, BillingState, ClaimedResult, EventingState,
11
11
  export type RemoteCompactionPrefix = {
12
12
  agent: ReturnType<ActivityServices["runtime"]["buildAgent"]> | null;
13
13
  };
14
+ /**
15
+ * Portable compaction on these wire APIs waits for the ordinary request this
16
+ * agent prepares (tools, instructions and settings) and summarizes on exactly
17
+ * that prefix, so the checkpoint call reads the warm prompt cache instead of
18
+ * rewriting the whole conversation. Chat Completions providers keep the
19
+ * standalone summary request.
20
+ */
21
+ export declare function portableCompactionUsesPreparedPrefix(api: ModelProviderApi | undefined): boolean;
14
22
  export type CompactionPrepDeps = {
15
23
  input: RunAgentTurnInput;
16
24
  settings: Settings;
17
25
  db: ActivityServices["db"];
26
+ entitlements?: ActivityServices["entitlements"];
18
27
  bus: ActivityServices["bus"];
19
28
  observability: ActivityServices["observability"];
20
29
  cancellationSignal: AbortSignal | undefined;
@@ -37,6 +46,7 @@ export type CompactionPrepDeps = {
37
46
  turnExecutionPolicy: ClaimTurnOk["turnExecutionPolicy"];
38
47
  resolvedModel: GovernanceModelOk["resolvedModel"];
39
48
  workspaceAgentInstructions: GovernanceModelOk["workspaceAgentInstructions"];
49
+ workspaceAgentIdentity: GovernanceModelOk["workspaceAgentIdentity"];
40
50
  workspaceGovernance: GovernanceModelOk["workspaceGovernance"];
41
51
  structuredWorkspacePolicyActive: GovernanceModelOk["structuredWorkspacePolicyActive"];
42
52
  workspaceMemory: GovernanceModelOk["workspaceMemory"];
@@ -82,5 +92,24 @@ export type PostAgentCompactionOutcome = {
82
92
  } | {
83
93
  ok: PostAgentCompactionOk;
84
94
  };
95
+ /**
96
+ * System instructions for the standalone (chat-provider) compaction request.
97
+ * A session with an agent configuration uses the same modular composer and
98
+ * module selection as its turns; a legacy session keeps the historical
99
+ * persona + CORE + governance + session + memory string byte-for-byte.
100
+ */
101
+ export declare function standaloneCompactionInstructions(input: {
102
+ settings: Settings;
103
+ session: Pick<ClaimTurnOk["session"], "agent" | "instructions" | "resources">;
104
+ workspaceAgentInstructions: string | null | undefined;
105
+ workspaceAgentIdentity: string | null;
106
+ workspaceGovernance: string | null | undefined;
107
+ structuredWorkspacePolicyActive: boolean;
108
+ workspaceMemory: string | null | undefined;
109
+ rig: {
110
+ name: string;
111
+ version: number;
112
+ } | undefined;
113
+ }): string;
85
114
  export declare function prepareCompaction(deps: CompactionPrepDeps): Promise<CompactionPrepOutcome>;
86
115
  export declare function runPostAgentCompaction(deps: PostAgentCompactionDeps): Promise<PostAgentCompactionOutcome>;
@@ -1,11 +1,16 @@
1
1
  import type { SharedActivityServices } from "../types.js";
2
- export type LeaseRenewReason = "timer" | "runtime_event" | "model_usage";
3
- export type LeaseLossReason = "deadline" | "not_found";
2
+ import { SubscriptionTurnLease, type LeaseRenewReason, type LeaseLossReason, type SubscriptionLeaseDeps } from "./subscription-lease.js";
3
+ export type { LeaseRenewReason, LeaseLossReason } from "./subscription-lease.js";
4
4
  export declare class CodexCredentialLeaseLostError extends Error {
5
5
  readonly reason: LeaseLossReason;
6
6
  readonly code = "codex_credential_lease_lost";
7
7
  constructor(reason: LeaseLossReason);
8
8
  }
9
+ /** Core service actor for one exact accepted turn (see subscriptionCoreTurnActor). */
10
+ export type CoreLeaseActor = {
11
+ subjectId: string;
12
+ initiatingHumanSubjectId: string | null;
13
+ };
9
14
  export type TurnCredentialLeaseDeps = {
10
15
  db: SharedActivityServices["db"];
11
16
  observability: SharedActivityServices["observability"];
@@ -13,51 +18,73 @@ export type TurnCredentialLeaseDeps = {
13
18
  workspaceId: string;
14
19
  codexWorkspaceKey: string;
15
20
  getTurnId: () => string | undefined;
21
+ getSessionId?: () => string | undefined;
16
22
  };
23
+ type LeaseCallbacks = Pick<SubscriptionLeaseDeps, "onLost" | "onRenewed" | "onError" | "lostError">;
24
+ /**
25
+ * A turn's serving-credential holder that can hold a shared-core lease, for
26
+ * any provider (generalized from the M3 Codex lease). After core placement
27
+ * (`useSubscriptionCoreLease`) heartbeat renewal, the dispatch fence and
28
+ * release go to the canonical per-turn `subscription_leases` row of this
29
+ * provider; before placement, a holder cannot renew. The DB row is the
30
+ * cross-replica fairness primitive; the
31
+ * heartbeat here only extends its short TTL. A killed worker stops
32
+ * heartbeating and the holder self-expires.
33
+ */
34
+ export declare class CoreSubscriptionTurnLease extends SubscriptionTurnLease {
35
+ private readonly coreDeps;
36
+ private readonly coreProvider;
37
+ private subscriptionCoreConnectionId;
38
+ private subscriptionCoreActor;
39
+ constructor(deps: TurnCredentialLeaseDeps, provider: {
40
+ /** The provider id on the core (`subscription_leases.provider`). */
41
+ id: string;
42
+ displayName: string;
43
+ ttlMs: number;
44
+ }, callbacks: LeaseCallbacks);
45
+ /**
46
+ * Route heartbeat renewal, dispatch fencing and release to the canonical
47
+ * per-turn lease after core placement. The actor is the core service actor
48
+ * for the exact accepted turn, so the lease row's session isolation does
49
+ * not depend on whatever ambient actor the caller happens to run under.
50
+ */
51
+ useSubscriptionCoreLease(connectionId: string, actor?: CoreLeaseActor): void;
52
+ /** The core connection this lease holds, or null before placement. */
53
+ get subscriptionCoreConnection(): string | null;
54
+ private inCoreScope;
55
+ /** Recheck the canonical lease at the last boundary before provider network I/O. */
56
+ assertCurrentForDispatch(): Promise<void>;
57
+ /** Release the core lease that this turn's placement acquired (false without one). */
58
+ releaseCurrent(): Promise<boolean>;
59
+ }
60
+ /**
61
+ * The Codex credential holder for one running turn: the core turn lease with
62
+ * Codex's lost error, metrics and log texts (Codex has no legacy lease).
63
+ */
64
+ export declare class CodexTurnLease extends CoreSubscriptionTurnLease {
65
+ constructor(deps: TurnCredentialLeaseDeps);
66
+ }
17
67
  /**
18
- * The Codex credential holder for one running turn. The DB row is the
19
- * cross-replica fairness primitive; the heartbeat here only extends its short
20
- * TTL. A killed worker stops heartbeating and the holder self-expires.
68
+ * The SuperGrok credential holder: the core turn lease (provider `xai`),
69
+ * held only after core placement (SuperGrok has no legacy lease after its
70
+ * cutover). It keeps the legacy lost error code and warnings.
21
71
  */
22
- export declare class CodexTurnLease {
23
- private readonly deps;
24
- held: boolean;
25
- lost: boolean;
26
- lossReason: LeaseLossReason | null;
27
- holderId: string | null;
28
- generation: number | null;
29
- confirmedUntilMs: number | null;
30
- private heartbeatInFlight;
31
- private heartbeatTimer;
72
+ export declare class XaiTurnLease extends CoreSubscriptionTurnLease {
32
73
  constructor(deps: TurnCredentialLeaseDeps);
33
- markLost: (reason: LeaseLossReason) => void;
34
- /** Fail closed at the last worker-confirmed lease deadline before dispatch. */
35
- assertUsable: () => void;
36
- renew: (reason: LeaseRenewReason) => Promise<void>;
37
- startHeartbeat: () => void;
38
- stopHeartbeat: () => void;
39
74
  }
40
- /** The xAI/SuperGrok credential holder for one running turn; same shape. */
41
- export declare class XaiTurnLease {
42
- private readonly deps;
43
- held: boolean;
44
- lost: boolean;
45
- subjectId: string | null;
46
- holderId: string | null;
47
- generation: number | null;
48
- confirmedUntilMs: number | null;
49
- private heartbeatInFlight;
50
- private heartbeatTimer;
75
+ /**
76
+ * The Claude credential holder: the core turn lease (provider `claude`),
77
+ * held only after core placement (the legacy Claude lease is deleted). It
78
+ * keeps the legacy lost error code and warnings.
79
+ */
80
+ export declare class ClaudeTurnLease extends CoreSubscriptionTurnLease {
51
81
  constructor(deps: TurnCredentialLeaseDeps);
52
- markLost: (reason: LeaseLossReason) => void;
53
- renew: () => Promise<void>;
54
- startHeartbeat: () => void;
55
- stopHeartbeat: () => void;
56
82
  }
57
- /** Both serving-credential leases for one turn attempt plus their composite views. */
83
+ /** Serving-credential leases for one turn attempt plus their composite views. */
58
84
  export type TurnCredentialLeases = {
59
85
  codex: CodexTurnLease;
60
86
  xai: XaiTurnLease;
87
+ claude: ClaudeTurnLease;
61
88
  renewServing: (reason: LeaseRenewReason) => Promise<void>;
62
89
  servingLost: () => boolean;
63
90
  };
@@ -0,0 +1,3 @@
1
+ import { type TurnExecutionPolicyV1 } from "@opengeni/contracts";
2
+ /** Only accepted policies establish the ceiling; ordinary metadata is not authority. */
3
+ export declare function turnCredentialRestriction(acceptedPolicy: TurnExecutionPolicyV1, initialSessionMetadata: unknown): "developer_setup" | undefined;