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

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 +172 -28
  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 +3 -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 +30 -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-NTXZHYET.js} +1552 -2876
  123. package/dist/activities-control-NTXZHYET.js.map +1 -0
  124. package/dist/activities-control.d.ts +64 -4
  125. package/dist/{activities-turn-YVVKCGAK.js → activities-turn-RKRI5GY4.js} +9238 -4392
  126. package/dist/activities-turn-RKRI5GY4.js.map +1 -0
  127. package/dist/activities.d.ts +64 -4
  128. package/dist/artifact-materializer-entry.js +104 -35
  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-M3NVMF2V.js → chunk-7BIHFUGB.js} +2293 -3956
  140. package/dist/chunk-7BIHFUGB.js.map +1 -0
  141. package/dist/chunk-MVESOYFC.js +3746 -0
  142. package/dist/chunk-MVESOYFC.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 +1134 -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 +26 -4
  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 +94 -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 +599 -110
  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 +162 -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 +116 -9
  301. package/src/activities/sandbox-lease.ts +1615 -73
  302. package/src/activities/scheduled-tasks.ts +758 -141
  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 +79 -38
  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
@@ -1,18 +1,31 @@
1
1
  import type { AttemptToolDefinition } from "@opengeni/codemode";
2
- import type { GeneratedSessionTitle } from "@opengeni/runtime";
3
- import { type FirstPartyMcpToolName, type Permission, type ToolRef } from "@opengeni/contracts";
2
+ import { type ModelCapabilitiesV1 } from "@opengeni/config";
3
+ import type { GeneratedSessionTitle, GenerateSessionTitleOptions, OpenGeniRuntime } from "@opengeni/runtime";
4
+ import { ReasoningEffort, type FirstPartyMcpToolName, type Permission, type ResolvedAgentConfig, type ToolRef } from "@opengeni/contracts";
4
5
  export declare const SESSION_TITLE_MODEL_TOOL_NAME = "opengeni__set_session_title";
5
6
  export declare function shouldRequestMissingSessionTitle(input: {
6
7
  title: string | null;
7
8
  titleSource: "user" | "agent" | null;
9
+ agentConfig?: ResolvedAgentConfig | null;
8
10
  firstPartyMcpTools: readonly FirstPartyMcpToolName[];
9
11
  firstPartyMcpPermissions: readonly Permission[] | null;
10
12
  }): boolean;
13
+ /**
14
+ * Whether the turn's route can afford a model request spent only on a title.
15
+ * The managed OpenRouter free route draws on one deployment-wide per-minute
16
+ * and per-day request quota that users' turns need, so an untitled session on
17
+ * it gets no title sidecar and no title tool (whose call would cost a
18
+ * follow-up request). Clients keep showing the prompt preview, and a later
19
+ * turn on another route titles the session.
20
+ */
21
+ export declare function routeAllowsSessionTitleRequests(resolvedModel: ReturnType<OpenGeniRuntime["resolveTurnModel"]>): boolean;
11
22
  export declare function sessionTitleToolPlan(input: {
12
23
  tools: readonly ToolRef[];
24
+ agentConfig?: ResolvedAgentConfig | null;
13
25
  selectedFirstPartyMcpTools: readonly FirstPartyMcpToolName[];
14
26
  shouldRequestTitle: boolean;
15
27
  parallelGenerationAvailable: boolean;
28
+ routeAllowsTitleRequests: boolean;
16
29
  }): {
17
30
  promoteTitleTool: boolean;
18
31
  generateTitleInParallel: boolean;
@@ -20,6 +33,48 @@ export declare function sessionTitleToolPlan(input: {
20
33
  preparationIndependentToolNames: string[];
21
34
  };
22
35
  export declare const PARALLEL_SESSION_TITLE_TIMEOUT_MS = 15000;
36
+ /** Codex subscription turns title on this fast model of the same account. */
37
+ export declare const CODEX_SESSION_TITLE_MODEL_ID = "codex/gpt-6-luna";
38
+ /** Claude subscription turns title on this fast model of the same account. */
39
+ export declare const CLAUDE_SESSION_TITLE_UPSTREAM_MODEL_ID = "claude-haiku-5-5";
40
+ export type SessionTitleRoute = {
41
+ resolvedModel: ReturnType<OpenGeniRuntime["resolveTurnModel"]>;
42
+ /** Upstream model name sent to the provider. */
43
+ modelName: string;
44
+ /** Product model id the title usage is recorded under, when it differs from the turn's. */
45
+ usageModelId: string | null;
46
+ };
47
+ /**
48
+ * The model for the auxiliary title request. A subscription turn titles on a
49
+ * fast model of the same subscription account and request context, so the
50
+ * title costs the subscription little and never another rail: Codex turns use
51
+ * Luna and Claude subscription turns use Haiku. Other turns, and a
52
+ * subscription whose catalog lacks the title model, title on the turn's model.
53
+ */
54
+ export declare function sessionTitleRoute(input: {
55
+ resolvedModel: ReturnType<OpenGeniRuntime["resolveTurnModel"]>;
56
+ modelName: string;
57
+ resolveTurnModel: (modelId: string) => ReturnType<OpenGeniRuntime["resolveTurnModel"]>;
58
+ }): SessionTitleRoute;
59
+ /**
60
+ * The lowest reasoning effort the resolved model can run, for the auxiliary
61
+ * title request only. A title needs no deliberation, and a provider default
62
+ * effort can use most of the output budget before any visible text. Returns
63
+ * undefined when the model declares no runnable reasoning control, so the
64
+ * request carries no reasoning parameter.
65
+ */
66
+ export declare function sessionTitleReasoningEffort(capabilities: Pick<ModelCapabilitiesV1, "reasoning"> | undefined): ReasoningEffort | undefined;
67
+ /**
68
+ * Options for the parallel title request. It uses the turn's resolved
69
+ * provider and credential authority, but its own lowest runnable reasoning
70
+ * effort rather than the turn's effort.
71
+ */
72
+ export declare function sessionTitleGenerationOptions(input: {
73
+ resolvedModel: ReturnType<OpenGeniRuntime["resolveTurnModel"]>;
74
+ modelName: string;
75
+ serviceTier: GenerateSessionTitleOptions["serviceTier"] | null | undefined;
76
+ signal: AbortSignal;
77
+ }): GenerateSessionTitleOptions;
23
78
  export type ParallelSessionTitleGeneration = {
24
79
  finish: () => Promise<GeneratedSessionTitle | null>;
25
80
  cancel: () => Promise<void>;
@@ -29,13 +84,15 @@ export type ParallelSessionTitleGeneration = {
29
84
  * stream. finish() waits for the already-running bounded request, so a quick
30
85
  * main response does not discard a valid title merely because it completed
31
86
  * first. cancel() aborts and joins exceptional/cancelled exits so no provider
32
- * work escapes the owning runAgentTurn activity.
87
+ * work escapes the owning runAgentTurn activity. Both exits settle an already
88
+ * completed result before returning, including its separate request custody.
33
89
  */
34
90
  export declare function startParallelSessionTitleGeneration(input: {
35
91
  generate: (signal: AbortSignal) => Promise<GeneratedSessionTitle>;
36
92
  signal?: AbortSignal;
37
93
  timeoutMs?: number;
38
94
  onError?: (error: unknown) => void;
95
+ onFinish?: (result: GeneratedSessionTitle | null) => Promise<void>;
39
96
  }): ParallelSessionTitleGeneration;
40
97
  export declare function createSessionTitleAttemptToolDefinition(input: {
41
98
  updateTitle: (title: string) => Promise<{
@@ -0,0 +1,66 @@
1
+ import type { HeldSessionUsageReceipt } from "@opengeni/core";
2
+ import type { TurnActivityServices as ActivityServices } from "../types.js";
3
+ /**
4
+ * Attempt-scoped custody for per-task usage receipts whose write failed after
5
+ * the provider response was received.
6
+ *
7
+ * The response is never lost or re-requested because of an accounting
8
+ * failure: settlement hands the content-free receipt here (original source
9
+ * identity, amount, pricing source) and the turn keeps the response. Before
10
+ * the next model request (every admission check) and before the turn
11
+ * completes, held receipts are written; if that still fails, the attempt
12
+ * stops for the workflow's DB-only recovery lane and carries the held
13
+ * receipts in its typed failure detail (durable in workflow history), which
14
+ * the lane writes before any replacement attempt. Writes are idempotent per
15
+ * source identity, so overlapping writers (the `agent.model.usage` event
16
+ * meter, a later flush and the recovery lane) record the call once.
17
+ */
18
+ type Scope = {
19
+ accountId: string;
20
+ workspaceId: string;
21
+ };
22
+ /** Bound on receipts carried through one recovery failure detail. */
23
+ export declare const MAX_RECOVERY_SESSION_USAGE_RECEIPTS = 64;
24
+ /** Recovery reason and detail code for a task whose earlier single-call receipt is still owed. */
25
+ export declare const SESSION_USAGE_CUSTODY_PENDING = "session_usage_custody_pending";
26
+ /**
27
+ * How long a parked turn waits before its replacement attempt re-checks
28
+ * admission (database reads only). An owner fills its receipt within
29
+ * seconds; a dead owner's marker is disclosed by maintenance after 30
30
+ * minutes, so a task waits at most about 60 rechecks.
31
+ */
32
+ export declare const SESSION_USAGE_CUSTODY_RECHECK_MS = 30000;
33
+ /** A fenced or overdue custody marker (not a database outage) refused the next model request. */
34
+ export declare function sessionUsageCustodyPending(error: unknown): boolean;
35
+ export declare function holdSessionUsageReceipt(scope: Scope, receipt: HeldSessionUsageReceipt): void;
36
+ /** Held receipts for one turn, bounded, for a post-claim recovery failure detail. */
37
+ export declare function heldSessionUsageReceiptsForTurn(turnId: string): HeldSessionUsageReceipt[];
38
+ export declare function heldSessionUsageReceiptCount(sessionId?: string): number;
39
+ /**
40
+ * The `agent.model.usage` event for a held receipt committed. Its appending
41
+ * transaction meters the same source identity through the database trigger
42
+ * (or, for a root still preparing, leaves the event for the bounded import),
43
+ * and a trigger failure would have rolled the event back. When the event
44
+ * carries exactly the held amount, the receipt is therefore durable and the
45
+ * hold is dropped, so completion does not stop for a write that is already
46
+ * done. A different or unknown event amount keeps the hold: only the direct
47
+ * write can record (or fill) that value.
48
+ */
49
+ export declare function releaseHeldSessionUsageReceiptMeteredByEvent(input: {
50
+ sessionId: string;
51
+ sourceId: string;
52
+ amountMicros: number | null;
53
+ pricingSource: string | null;
54
+ }): boolean;
55
+ /** Write receipts with their original identities; throws the last database error. */
56
+ export declare function writeSessionUsageReceipts(db: ActivityServices["db"], scope: Scope, receipts: readonly HeldSessionUsageReceipt[]): Promise<void>;
57
+ /**
58
+ * Write every receipt held for this session before another model request or
59
+ * turn completion. Retries briefly; a persistent failure rethrows the
60
+ * database error so the attempt enters post-claim DB recovery with the
61
+ * receipts still held for its failure detail.
62
+ */
63
+ export declare function flushHeldSessionUsageReceipts(db: ActivityServices["db"], sessionId: string): Promise<void>;
64
+ /** Test-only reset of process custody. */
65
+ export declare function resetSessionUsageReceiptCustodyForTests(): void;
66
+ export {};
@@ -1,8 +1,26 @@
1
1
  import type { AttemptToolDefinition } from "@opengeni/codemode";
2
- import type { SandboxChannelAService } from "@opengeni/runtime/sandbox";
3
- import type { SkillTextFile } from "@opengeni/runtime/skill-library";
2
+ import { type SkillTextFile } from "@opengeni/runtime/skill-library";
3
+ import { type SkillFileSystem } from "./skill-transfer.js";
4
4
  import type { SkillSaveReceipt, SkillSaveRequest } from "./skill-save.js";
5
- type SkillFileSystem = Pick<SandboxChannelAService, "fsList" | "fsRead" | "fsWrite" | "fsMkdir">;
5
+ export type SkillCheckoutOutcome = "written" | "unchanged" | "refused" | "failed";
6
+ /**
7
+ * Content-free timing of one skill_checkout call. `resolve` covers authority
8
+ * and the Skill read, `sandbox` acquiring the turn's filesystem handle, and
9
+ * `write` the batched filesystem write. On a lazily provisioned turn whose
10
+ * first sandbox use is this checkout, acquiring the handle starts the box, so
11
+ * box start is inside `sandbox`. A phase that did not run is null.
12
+ */
13
+ export type SkillCheckoutObservation = Readonly<{
14
+ outcome: SkillCheckoutOutcome;
15
+ selection: "all" | "paths";
16
+ files: number;
17
+ written: number;
18
+ unchanged: number;
19
+ resolveSeconds: number | null;
20
+ sandboxSeconds: number | null;
21
+ writeSeconds: number | null;
22
+ totalSeconds: number;
23
+ }>;
6
24
  export declare function createSkillCheckoutAttemptToolDefinition(input: {
7
25
  authorize: () => Promise<void>;
8
26
  load: (skill: string) => Promise<{
@@ -11,11 +29,12 @@ export declare function createSkillCheckoutAttemptToolDefinition(input: {
11
29
  scopeVersion: number | null;
12
30
  files: readonly SkillTextFile[];
13
31
  }>;
14
- filesystem: () => Promise<SkillFileSystem>;
32
+ filesystem: () => Promise<Pick<SkillFileSystem, "fsWriteFiles">>;
33
+ /** Telemetry only; a failure here never changes the result. */
34
+ observe?: (observation: SkillCheckoutObservation) => void;
15
35
  }): AttemptToolDefinition;
16
36
  export declare function createSkillPublishAttemptToolDefinition(input: {
17
37
  authorize: () => Promise<void>;
18
- filesystem: () => Promise<SkillFileSystem>;
38
+ filesystem: () => Promise<Pick<SkillFileSystem, "fsList" | "fsRead">>;
19
39
  save: (request: SkillSaveRequest) => Promise<SkillSaveReceipt>;
20
40
  }): AttemptToolDefinition;
21
- export {};
@@ -1,15 +1,83 @@
1
- import type { AttemptToolDefinition } from "@opengeni/codemode";
1
+ import type { AttemptToolDefinition, AttemptToolExecutionContext } from "@opengeni/codemode";
2
+ import { type SkillReadKind, type SkillUseSource } from "@opengeni/contracts";
2
3
  import { type SkillTextFile } from "@opengeni/runtime/skill-library";
3
4
  export declare const SKILL_READ_TOOL_NAME = "skill_read";
5
+ /** Content-free provenance of a resolved Skill. The caller never receives it. */
6
+ export type SkillReadOrigin = Readonly<{
7
+ id: string;
8
+ source: SkillUseSource;
9
+ /** Platform display label of a built-in; never user-authored text. */
10
+ label?: string;
11
+ /** Whole-artifact digest, for an artifact without a ledger revision. */
12
+ contentSha256?: string;
13
+ }>;
4
14
  export type SkillReadContent = Readonly<{
5
15
  files: readonly SkillTextFile[];
6
16
  skillId: string;
7
17
  revisionId: string;
8
18
  scopeVersion: number;
9
19
  installationVersion?: number;
20
+ origin?: SkillReadOrigin;
21
+ }>;
22
+ /** A selected built-in or session artifact: no ledger identity, and none is synthesized. */
23
+ export type SelectedSkillReadContent = Readonly<{
24
+ files: readonly SkillTextFile[];
25
+ origin: SkillReadOrigin;
26
+ }>;
27
+ export type SkillReadObservation = Readonly<{
28
+ caller: AttemptToolExecutionContext["caller"]["kind"];
29
+ kind: SkillReadKind;
30
+ /** Null when the read was refused before a Skill resolved. */
31
+ source: SkillUseSource | null;
32
+ /** The resolved Skill id, or the requested identifier when none resolved. */
33
+ skill: string;
34
+ }>;
35
+ /**
36
+ * Content-free read telemetry. It never changes what the caller receives: a
37
+ * model result gains only MCP `_meta`, which the model never sees and which
38
+ * only the tool-output event projection keeps.
39
+ */
40
+ export type SkillReadTelemetry = Readonly<{
41
+ /** Ids in the Skill index the model sees this turn; null until known. */
42
+ indexedSkillIds: () => ReadonlySet<string> | null;
43
+ /** Whether skill_search returned this id earlier in this turn attempt. */
44
+ searched: (id: string) => boolean;
45
+ observe: (observation: SkillReadObservation) => void;
46
+ }>;
47
+ export type SkillReadActiveHistory = Readonly<{
48
+ /** Earlier skill_read results still in this session's active model history. */
49
+ readResults: () => Promise<ReadonlyArray<Record<string, unknown>>>;
50
+ /**
51
+ * This turn's model tool-output bound. Rows are bounded when stored, but a
52
+ * later model with a lower bound receives a shorter copy than the row holds.
53
+ */
54
+ toolOutputTruncationTokens: () => number;
55
+ /** The lookup only saves tokens, so a failure returns the full text. */
56
+ onLookupFailed?: (error: unknown) => void;
57
+ }>;
58
+ export declare const SKILL_UNAVAILABLE_MESSAGE = "Skill is not available in this session.";
59
+ /** Bounds on the Skill list an unresolved identifier returns. */
60
+ export declare const SKILL_UNAVAILABLE_LIST_MAX_ENTRIES = 25;
61
+ export declare const SKILL_UNAVAILABLE_LIST_MAX_BYTES: number;
62
+ export type AvailableSkill = Readonly<{
63
+ id: string;
64
+ name: string;
10
65
  }>;
66
+ /**
67
+ * The error for an identifier that resolves to no Skill. It lists available
68
+ * Skills by id and name only, the descriptors the Skill index and skill_search
69
+ * already show the model, so the caller can retry instead of rediscovering
70
+ * the work from scratch. Entries resembling the requested identifier (shared
71
+ * prefix, suffix, or containment) come first, so a mistyped or spliced id
72
+ * keeps its likely targets inside the bound. The requested identifier is
73
+ * never echoed.
74
+ */
75
+ export declare function unavailableSkillError(requested: string, available: readonly AvailableSkill[]): Error;
11
76
  /** A first-party gateway definition, not a sandbox capability or second backend. */
12
77
  export declare function createSkillReadAttemptToolDefinition(input: {
13
78
  authorize: () => Promise<void>;
14
- load: (skill: string) => Promise<readonly SkillTextFile[] | SkillReadContent>;
79
+ load: (skill: string) => Promise<readonly SkillTextFile[] | SkillReadContent | SelectedSkillReadContent>;
80
+ /** Without it every read returns full text. */
81
+ activeHistory?: SkillReadActiveHistory;
82
+ telemetry?: SkillReadTelemetry;
15
83
  }): AttemptToolDefinition;
@@ -13,4 +13,6 @@ export declare function createSkillSearchAttemptToolDefinition(input: {
13
13
  authorize: () => Promise<void>;
14
14
  listWorkspace: () => Promise<readonly WorkspaceSkillSearchEntry[]>;
15
15
  publicSearch: PublicSkillSearchClient;
16
+ /** Ids of the readable Skills a search returned, for read telemetry only. */
17
+ onWorkspaceHits?: (ids: readonly string[]) => void;
16
18
  }): AttemptToolDefinition;
@@ -1,8 +1,20 @@
1
1
  import type { Settings } from "@opengeni/config";
2
2
  import { type SkillActor } from "@opengeni/contracts";
3
- import { type Database } from "@opengeni/db";
3
+ import { SkillLifecycleRefusedError, type Database } from "@opengeni/db";
4
4
  import type { RuntimeSkillArtifact } from "@opengeni/runtime";
5
- import type { SandboxChannelAService } from "@opengeni/runtime/sandbox";
5
+ import { type SkillReadObservation } from "./skill-read.js";
6
+ import { type SkillCheckoutObservation } from "./skill-checkout.js";
7
+ import type { SkillFileSystem } from "./skill-transfer.js";
8
+ import type { AttemptToolDefinition } from "@opengeni/codemode";
9
+ /** What a refused Skill change means for the agent, in words it can act on. */
10
+ export declare function skillRefusalMessage(error: SkillLifecycleRefusedError): string;
11
+ /**
12
+ * The check before a Skill write (save, install, publish, remove): the live
13
+ * attempt, and that no Site page started the agent. An agent started from a
14
+ * Site page reads Skills but never changes them: it does not learn. The
15
+ * refusal is definite (nothing was saved).
16
+ */
17
+ export declare function skillWriteAuthorizer(authorize: () => Promise<void>, siteClamped: () => Promise<boolean>): () => Promise<void>;
6
18
  export declare function createWorkspaceSkillTools(input: {
7
19
  db: Database;
8
20
  settings: Settings;
@@ -16,5 +28,30 @@ export declare function createWorkspaceSkillTools(input: {
16
28
  id: string;
17
29
  artifact: RuntimeSkillArtifact;
18
30
  }[];
19
- filesystem: () => Promise<Pick<SandboxChannelAService, "fsList" | "fsRead" | "fsWrite" | "fsMkdir">>;
20
- }): import("@opengeni/codemode").AttemptToolDefinition[];
31
+ filesystem: () => Promise<SkillFileSystem>;
32
+ /** Content-free skill_checkout timing; it never changes a result. */
33
+ observeSkillCheckout?: (observation: SkillCheckoutObservation) => void;
34
+ /** The resolved model's bound, which `settings` does not carry. */
35
+ modelToolOutputTruncationTokens: () => number;
36
+ onSkillReadHistoryLookupFailed?: (error: unknown) => void;
37
+ /** Content-free skill_read telemetry; it never changes a result. */
38
+ skillReadTelemetry?: {
39
+ /** Ids in the Skill index the model sees this turn; null until known. */
40
+ indexedSkillIds: () => ReadonlySet<string> | null;
41
+ observe: (observation: SkillReadObservation) => void;
42
+ };
43
+ }): AttemptToolDefinition[];
44
+ /**
45
+ * Names of the Skills a session carries itself. The session's creator chose
46
+ * that copy for this conversation, so it shadows a workspace Skill of the same
47
+ * name in the Skill index, skill_search and by-name reads; offering both lets
48
+ * the model pick either one.
49
+ */
50
+ export declare function sessionShadowedSkillNames(selected: readonly {
51
+ id: string;
52
+ artifact: Pick<RuntimeSkillArtifact, "name">;
53
+ }[]): ReadonlySet<string>;
54
+ /** Workspace Skill descriptors without the ones a session Skill shadows. */
55
+ export declare function withoutSessionShadowedSkills<T extends {
56
+ title: string;
57
+ }>(descriptors: readonly T[], shadowed: ReadonlySet<string>): T[];
@@ -1,26 +1,38 @@
1
1
  import type { SandboxChannelAService } from "@opengeni/runtime/sandbox";
2
2
  import { type SkillTextFile } from "@opengeni/runtime/skill-library";
3
- type SkillFileSystem = Pick<SandboxChannelAService, "fsList" | "fsRead" | "fsWrite" | "fsMkdir">;
3
+ export type SkillFileSystem = Pick<SandboxChannelAService, "fsList" | "fsRead" | "fsWriteFiles">;
4
4
  /** Reuse the host's cancellation and workspace-mutation authority for each filesystem operation. */
5
5
  export declare function guardSkillFilesystem(fs: SkillFileSystem, authority: {
6
6
  assertActive: () => void;
7
7
  runMutation: <T>(operation: () => Promise<T>) => Promise<T>;
8
8
  }): SkillFileSystem;
9
- /** Caller supplies an authorized live filesystem and a fresh workspace-relative target. */
10
- export declare function checkoutSkillDirectory(fs: SkillFileSystem, directory: string, files: readonly SkillTextFile[]): Promise<{
9
+ export type SkillCheckoutResult = {
11
10
  directory: string;
12
11
  fileCount: number;
13
- }>;
12
+ written: number;
13
+ unchanged: number;
14
+ /** This call created the directory, so it holds nothing but these files. */
15
+ createdDirectory: boolean;
16
+ };
17
+ /**
18
+ * Caller supplies an authorized live filesystem and a workspace-relative
19
+ * target. All missing files are created in one filesystem batch (normally a
20
+ * single sandbox command). Nothing is overwritten: files already holding the
21
+ * same bytes are kept, and any other existing entry fails before writing.
22
+ * `paths` selects exactly those Skill files, for example one script to run.
23
+ */
24
+ export declare function checkoutSkillDirectory(fs: Pick<SkillFileSystem, "fsWriteFiles">, directory: string, files: readonly SkillTextFile[], options?: {
25
+ paths?: readonly string[];
26
+ }): Promise<SkillCheckoutResult>;
14
27
  /**
15
28
  * Read a folder through existing structured filesystem services, never via model
16
29
  * arguments. The caller owns workspace confinement and the final governed save.
17
30
  * This operation does not execute scripts or activate the resulting artifact.
18
31
  */
19
- export declare function readSkillDirectory(fs: SkillFileSystem, directory: string): Promise<Readonly<{
32
+ export declare function readSkillDirectory(fs: Pick<SkillFileSystem, "fsList" | "fsRead">, directory: string): Promise<Readonly<{
20
33
  name: string;
21
34
  description: string;
22
35
  files: readonly import("@opengeni/runtime").SkillLibraryFile[];
23
36
  contentSha256: string;
24
37
  totalBytes: number;
25
38
  }>>;
26
- export {};
@@ -11,7 +11,7 @@ import { ToolResultSpill } from "./tool-result-spill.js";
11
11
  import { createTurnCredentialLeases } from "./credential-leases.js";
12
12
  import { createTurnMediaArtifacts } from "./media-artifacts.js";
13
13
  import { createTurnHistorySink } from "./history-sink.js";
14
- import { type SessionEvent } from "@opengeni/contracts";
14
+ import { type SessionEvent, type SessionTurn } from "@opengeni/contracts";
15
15
  import { createModelCheckpointMemoryCollector } from "../../model-checkpoint-memory-collector.js";
16
16
  import { TurnEventPublisher } from "./model-usage.js";
17
17
  import type { CompactionSummarizer } from "../context-compaction.js";
@@ -44,11 +44,12 @@ export type TurnStreamAttemptDeps = {
44
44
  providerTurn: ProviderTurnState;
45
45
  leases: ReturnType<typeof createTurnCredentialLeases>;
46
46
  historySink: ReturnType<typeof createTurnHistorySink>;
47
+ checkpointBeforeProviderDispatch: () => Promise<void>;
47
48
  media: ReturnType<typeof createTurnMediaArtifacts>;
48
49
  toolResultSpill: ToolResultSpill;
49
50
  claimedResult: ClaimedResult;
50
51
  flushRuntimeBatcher: () => Promise<void>;
51
- finalizeTurnOpStreamOps: () => Promise<void>;
52
+ finalizeTurnOpStreamOps: (toolCallIds?: readonly string[]) => Promise<void>;
52
53
  runWorkspaceMutationForSandbox: <T>(sandbox: ResumedTurnSandbox, operation: string, mutation: () => Promise<T>, observePhase?: (measurement: {
53
54
  phase: "admission" | "provider" | "settlement" | "snapshot_wait";
54
55
  outcome: "completed" | "failed";
@@ -79,7 +80,9 @@ export type TurnStreamAttemptDeps = {
79
80
  activeSandboxBackend: Settings["sandboxBackend"] | undefined;
80
81
  groupBoxBackend: Settings["sandboxBackend"];
81
82
  turnExecutionPolicy: TurnExecutionPolicyV1;
82
- turn: {
83
+ turn: Pick<SessionTurn, "initiator" | "initiatorContext"> & {
84
+ initiatingHumanSubjectId: string | null;
85
+ id: string;
83
86
  executionGeneration: number;
84
87
  model: string;
85
88
  source?: string;
@@ -0,0 +1,41 @@
1
+ export type SubscriptionCapacityArmingFailurePayload = {
2
+ error: string;
3
+ code: string;
4
+ retryable: true;
5
+ recovery: "user_message";
6
+ };
7
+ declare const PROVIDER_NAMES: {
8
+ readonly codex: "Codex";
9
+ readonly claude: "Claude";
10
+ readonly xai: "SuperGrok";
11
+ };
12
+ /**
13
+ * Translate a failure to arm a durable capacity wait into an explicit,
14
+ * user-visible turn failure instead of a generic activity failure.
15
+ *
16
+ * Returns null for structured database failures: those belong to the
17
+ * exact-attempt database recovery path and must be rethrown unchanged. The
18
+ * payload is secret-safe: it never includes the underlying error text, which
19
+ * can carry row identifiers or provider diagnostics.
20
+ *
21
+ * Every other failure, including a permanent database rejection such as an
22
+ * RLS/permission denial or a constraint violation, settles the turn as failed
23
+ * with the session idle. `retryable` means only that a new user message may
24
+ * try again; nothing retries automatically. Callers must report
25
+ * `subscriptionCapacityArmingDiagnostic` to operators so the underlying class
26
+ * and SQLSTATE are not lost behind the user-facing state.
27
+ */
28
+ export declare function subscriptionCapacityArmingFailure(provider: keyof typeof PROVIDER_NAMES, error: unknown): SubscriptionCapacityArmingFailurePayload | null;
29
+ export type SubscriptionCapacityArmingDiagnostic = {
30
+ errorClass: string;
31
+ errorCode: string;
32
+ origin: "database" | "worker";
33
+ sqlState?: string;
34
+ };
35
+ /**
36
+ * Operator-only facts about a wait that could not be armed: the error class
37
+ * and, for database rejections, the SQLSTATE. Never message text, so it is
38
+ * safe for worker logs; it must not enter the user-visible turn payload.
39
+ */
40
+ export declare function subscriptionCapacityArmingDiagnostic(provider: keyof typeof PROVIDER_NAMES, error: unknown): SubscriptionCapacityArmingDiagnostic;
41
+ export {};
@@ -0,0 +1,86 @@
1
+ import type { Database, SubscriptionCorePlacement, SubscriptionCorePlacementRequest, SubscriptionCoreTurnIdentity } from "@opengeni/db";
2
+ import type { CapacityPhaseDeps, CapacityPhaseOutcome } from "./codex-capacity.js";
3
+ import type { CoreSubscriptionTurnLease } from "./credential-leases.js";
4
+ import type { SubscriptionCoreTurn } from "./turn-context.js";
5
+ import { type CoreWaitBinding } from "../subscription-core-codex-waits.js";
6
+ type WaitPlacement = Extract<SubscriptionCorePlacement, {
7
+ kind: "wait";
8
+ }> & {
9
+ /** Fresh failover evaluation hints, never authority. */
10
+ candidateProviders?: readonly string[];
11
+ };
12
+ type RunPlacement = Extract<SubscriptionCorePlacement, {
13
+ kind: "run";
14
+ }>;
15
+ /** One provider's chat placement on the core, as the worker uses it. */
16
+ export type CoreTurnPlacementProvider = {
17
+ /** The provider id on the core. */
18
+ id: string;
19
+ /** The provider's name in failure copy. */
20
+ displayName: string;
21
+ /** The startup-phase metric's provider label. */
22
+ startupPhaseProvider: string;
23
+ leaseTtlMs: number;
24
+ /** The turn's lease for this provider. */
25
+ lease: (deps: CapacityPhaseDeps) => CoreSubscriptionTurnLease;
26
+ place: (db: Database, request: SubscriptionCorePlacementRequest) => Promise<SubscriptionCorePlacement>;
27
+ /** Quarantines that ran out return to service before placement reads the world. */
28
+ recoverHealth: (deps: CapacityPhaseDeps, identity: SubscriptionCoreTurnIdentity) => Promise<void>;
29
+ /** A provider-specific read before placement (Codex: plan entitlements). */
30
+ beforePlacement?: (deps: CapacityPhaseDeps, identity: SubscriptionCoreTurnIdentity) => Promise<void>;
31
+ /** Record the placement on the provider's turn fields. */
32
+ adopt: (deps: CapacityPhaseDeps, core: SubscriptionCoreTurn, placement: RunPlacement) => void;
33
+ /** The provider's selection receipt (events and metrics), if it records one. */
34
+ recordSelection?: (deps: CapacityPhaseDeps, placement: RunPlacement, turnId: string) => Promise<void>;
35
+ /**
36
+ * Park a chat turn on the durable core waiter. Without it a wait is a
37
+ * terminal capacity failure (fail closed; the session stays usable).
38
+ */
39
+ park?: (deps: CapacityPhaseDeps, wait: WaitPlacement) => Promise<CapacityPhaseOutcome>;
40
+ isSourceDisconnected: (db: Database, identity: SubscriptionCoreTurnIdentity, connectionId: string) => Promise<boolean>;
41
+ sourceDisconnectedError: () => Error;
42
+ /** The attempt-fence refusal the selection receipt raises. */
43
+ isAttemptFenced: (error: unknown) => boolean;
44
+ };
45
+ /**
46
+ * Whether an error (or a cause up to eight deep) is a core source disconnect
47
+ * of any provider: every provider's `sourceDisconnectedError` carries the
48
+ * shared code `subscription_core_source_disconnected`.
49
+ */
50
+ export declare function isCoreSourceDisconnectedError(error: unknown): boolean;
51
+ /** Lifecycle disappearance is not an auth refusal or an ordinary account pause. */
52
+ export declare function assertCoreSourceConnected(db: Database, provider: Pick<CoreTurnPlacementProvider, "isSourceDisconnected" | "sourceDisconnectedError">, core: Pick<SubscriptionCoreTurn, "identity" | "connectionId">): Promise<void>;
53
+ /**
54
+ * Wrap a core credential resolver for one attempt: every read and refresh
55
+ * rechecks the source and this attempt's live lease. A lost lease marks the
56
+ * local holder lost, so dispatch stops with the ordinary lease-loss error; a
57
+ * failure is reclassified as a disconnect only on proven lifecycle
58
+ * disconnect, never on an ordinary pause.
59
+ */
60
+ export declare function guardCoreTokenResolver<Snapshot>(db: Database, provider: Pick<CoreTurnPlacementProvider, "isSourceDisconnected" | "sourceDisconnectedError">, core: SubscriptionCoreTurn, lease: CoreSubscriptionTurnLease, resolver: {
61
+ getToken: () => Promise<Snapshot>;
62
+ refresh: () => Promise<Snapshot>;
63
+ }, isLeaseLost: (error: unknown) => boolean): {
64
+ getToken: () => Promise<Snapshot>;
65
+ refresh: () => Promise<Snapshot>;
66
+ };
67
+ /** The lease reference a core turn's credential reads and requests carry. */
68
+ export declare function coreLeaseRef(lease: CoreSubscriptionTurnLease, core: Pick<SubscriptionCoreTurn, "connectionId">, displayName: string): {
69
+ connectionId: string;
70
+ holderId: string;
71
+ generation: number;
72
+ };
73
+ export declare function selectCoreSubscriptionTurnCapacity(deps: CapacityPhaseDeps, provider: CoreTurnPlacementProvider): Promise<CapacityPhaseOutcome>;
74
+ /** The session's active goal fence for a capacity waiter. */
75
+ export declare function activeGoalFence(deps: Pick<CapacityPhaseDeps, "db" | "input">): Promise<{
76
+ goalId: string | null;
77
+ goalVersion: number | null;
78
+ }>;
79
+ /**
80
+ * Arm the session's core waiter for this attempt's turn and re-evaluate it at
81
+ * once: a capacity change that committed before the waiter existed could not
82
+ * wake it, so the arm closes that edge itself (as the legacy Codex arm does).
83
+ * Any provider: `waits` supplies its waiter entry points.
84
+ */
85
+ export declare function parkCoreSubscriptionTurn(deps: CapacityPhaseDeps, wait: WaitPlacement, waits: CoreWaitBinding, displayName: string): Promise<CapacityPhaseOutcome>;
86
+ export {};
@@ -0,0 +1,69 @@
1
+ /**
2
+ * In-turn re-placement after a definitive refusal on a chat turn placed by
3
+ * the shared subscription core, for any provider (generalized from the M3
4
+ * Codex failover, PR 2a; Codex binds it in `codex-core-failover.ts` under
5
+ * the names it shipped).
6
+ *
7
+ * The refusal was already recorded against the leased connection (failure
8
+ * receipt plus the state that keeps placement away from it). After a durable
9
+ * checkpoint the same accepted turn is recovered with a new attempt, whose
10
+ * placement chooses again under the core rules: another eligible account, or
11
+ * a durable wait when nothing can serve it. An explicit choice never fails
12
+ * over: its placement waits on the chosen account. The per-turn bound counts
13
+ * every refusal of the turn, by any account, so a turn cannot alternate
14
+ * between failing accounts forever; the refusal that reaches the bound fails
15
+ * the turn with typed copy and leaves the session usable.
16
+ */
17
+ import { type Database, type SubscriptionCoreTurnIdentity } from "@opengeni/db";
18
+ import type { RunAgentTurnResult } from "../types.js";
19
+ import type { CoreSubscriptionTurnLease } from "./credential-leases.js";
20
+ import type { TurnFailureDeps } from "./failure-settlement.js";
21
+ import type { SubscriptionCoreTurn } from "./turn-context.js";
22
+ /** One provider's failover inputs. */
23
+ export type CoreFailoverBinding = {
24
+ displayName: string;
25
+ lease: (deps: TurnFailureDeps) => CoreSubscriptionTurnLease;
26
+ countRefusals: (db: Database, identity: SubscriptionCoreTurnIdentity) => Promise<number | null>;
27
+ /** Refusals one turn may take before it stops. */
28
+ refusalLimit: number;
29
+ /** The in-turn recovery's reason and its detail's provider label. */
30
+ recoveryReason: string;
31
+ recoveryProvider: string;
32
+ metrics: {
33
+ checkpoints: {
34
+ name: string;
35
+ help: string;
36
+ };
37
+ settlements: {
38
+ name: string;
39
+ help: string;
40
+ };
41
+ labels: (deps: TurnFailureDeps) => Record<string, string>;
42
+ };
43
+ };
44
+ /** A recorded refusal (`unbounded`: it does not count toward the bound), or a graceful disconnect. */
45
+ export type CoreFailoverRefusal = {
46
+ kind: string;
47
+ unbounded: boolean;
48
+ } | "source_disconnected";
49
+ /**
50
+ * Refusals one turn may take before it stops: at most three in-turn switches
51
+ * (the contract and design require a bound but do not fix it; this is the
52
+ * small fixed bound chosen for M3, see design 5.1.1 "PR 2a").
53
+ */
54
+ export declare const SUBSCRIPTION_CORE_TURN_REFUSAL_LIMIT = 4;
55
+ /**
56
+ * The shared failover metrics, labelled by provider (Codex keeps its M3
57
+ * `opengeni_codex_failover_*` metrics with `workspace_key`).
58
+ */
59
+ export declare function subscriptionCoreFailoverMetrics(provider: string): CoreFailoverBinding["metrics"];
60
+ /** Pure bound: fail over while under the limit, stop at it. */
61
+ export declare function coreFailoverDisposition(refusals: number | null, limit: number): "failover" | "exhausted" | "unrecorded";
62
+ /**
63
+ * Re-place the same turn after graceful source disappearance, without a
64
+ * refusal budget, or settle a recorded refusal within its bound. Returns
65
+ * null when automatic replay is unsafe (the checkpoint did not become
66
+ * durable, or the bound could not be read): the caller then fails the turn
67
+ * with its typed copy instead.
68
+ */
69
+ export declare function failOverCoreSubscriptionTurn(deps: TurnFailureDeps, core: SubscriptionCoreTurn, refusal: CoreFailoverRefusal, binding: CoreFailoverBinding): Promise<RunAgentTurnResult | null>;