@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,12 +1,24 @@
1
- import { type CompactionProviderRejection, type MaterializationVerificationDiagnostic } from "@opengeni/runtime";
1
+ import { type CompactionProviderRejection, type MaterializationVerificationDiagnostic, type ProviderQuotaExhaustion, type ProviderQuotaScope, type AnthropicRequestSize } from "@opengeni/runtime";
2
2
  import { type McpTransportRequestFailureDiagnostic } from "@opengeni/runtime/mcp-network";
3
3
  import { ApplicationFailure } from "@temporalio/activity";
4
+ import type { ProviderErrorOutcome } from "@opengeni/subscriptions";
4
5
  import type { CodexAccountStatus } from "@opengeni/db";
5
6
  import type { EscapedMcpTimeoutRecoveryDetail } from "../types.js";
6
7
  import { type MandatoryHistoryPersistenceStage } from "./quiescence.js";
8
+ import { type ProviderCondition } from "./provider-recovery-copy.js";
9
+ export { PROVIDER_OVERLOAD_RECOVERY_CODE, MAX_AUTOMATIC_PROVIDER_OVERLOAD_RECOVERIES, PROVIDER_OVERLOAD_RECOVERY_WINDOW_MS, } from "./provider-recovery-policy.js";
7
10
  export declare const PROVIDER_BACKPRESSURE_DELAY_MS = 60000;
8
11
  export declare const PROVIDER_CONNECTIVITY_BACKOFF_MS: readonly [2000, 5000, 15000, 30000, 60000];
9
12
  export declare const MAX_AUTOMATIC_PROVIDER_RECOVERIES: 5;
13
+ export declare function providerRecoveryLimit(failureCode: unknown): number;
14
+ /**
15
+ * Minimum wait per rate-limited recovery. Providers such as Azure OpenAI often
16
+ * answer a per-minute token limit with a `retry-after` of about a second, which
17
+ * alone would spend every automatic recovery before the window resets.
18
+ */
19
+ export declare const PROVIDER_RATE_LIMIT_BACKOFF_MS: readonly [10000, 20000, 40000, 60000, 120000];
20
+ /** Positive-only spread: never shorten the provider's minimum delay. */
21
+ export declare function providerRecoveryJitterMs(delayMs: number, sample: number): number;
10
22
  export declare const POST_COMPACTION_CONTINUATION_EMPTY_CODE = "post_compaction_continuation_empty";
11
23
  export declare class PostCompactionContinuationEmptyError extends Error {
12
24
  readonly code = "post_compaction_continuation_empty";
@@ -15,16 +27,44 @@ export declare class PostCompactionContinuationEmptyError extends Error {
15
27
  export type ProviderRecoveryResult = {
16
28
  status: "recovering";
17
29
  continueDelayMs: number;
30
+ maxProviderRecoveryCount?: number;
18
31
  } | {
19
32
  status: "exhausted";
20
33
  providerRecoveryCount: number;
21
34
  maxProviderRecoveryCount: number;
35
+ providerRecoveryExhaustedReason?: "deadline" | "retry_limit" | "invalid_clock";
22
36
  };
23
37
  export declare function providerRecoveryResult(input: {
24
38
  failureCode: string | undefined;
25
39
  attemptNumber: number;
26
40
  retryAfterMs?: number | null;
41
+ jitterSample?: number;
42
+ /** Durable first-failure clock, never a new clock on each replacement attempt. */
43
+ recoveryStartedAt?: number | undefined;
44
+ now?: number;
27
45
  }): ProviderRecoveryResult;
46
+ /** A timer/queue delay cannot authorize a provider call after the recovery window. */
47
+ export declare class ProviderOverloadRecoveryExpiredError extends Error {
48
+ readonly failure: {
49
+ error: string;
50
+ code: string;
51
+ providerCondition: "overloaded";
52
+ } & {
53
+ retryable: false;
54
+ recoveryExhausted: true;
55
+ providerRecoveryCount: number;
56
+ maxProviderRecoveryCount: number;
57
+ lastRetryableError: string;
58
+ providerRecoveryExhaustedReason?: "deadline" | "retry_limit" | "invalid_clock";
59
+ };
60
+ constructor(count: number, reason: "deadline" | "retry_limit" | "invalid_clock");
61
+ }
62
+ export declare function assertProviderOverloadRecoveryActive(input: {
63
+ failureCode: unknown;
64
+ providerRecoveryCount: number;
65
+ recoveryStartedAt?: number | undefined;
66
+ now?: number;
67
+ }): void;
28
68
  export declare function providerRecoveryExhaustedFailure<T extends Record<string, unknown> & {
29
69
  error: string;
30
70
  }>(failure: T, recovery: Extract<ProviderRecoveryResult, {
@@ -35,6 +75,36 @@ export declare function providerRecoveryExhaustedFailure<T extends Record<string
35
75
  providerRecoveryCount: number;
36
76
  maxProviderRecoveryCount: number;
37
77
  lastRetryableError: string;
78
+ providerRecoveryExhaustedReason?: "deadline" | "retry_limit" | "invalid_clock";
79
+ };
80
+ /**
81
+ * A retryable failure whose automatic same-turn recovery was not authorized
82
+ * (for example, request custody could not be checkpointed). The classifier's
83
+ * "will retry" sentence would be false on a terminal record, so name the
84
+ * condition and the person's options instead.
85
+ */
86
+ export declare function automaticRecoveryUnavailableFailure<T extends Record<string, unknown> & {
87
+ error: string;
88
+ }>(failure: T): T & {
89
+ retryable: false;
90
+ automaticRecovery: "unavailable";
91
+ lastRetryableError: string;
92
+ };
93
+ /**
94
+ * Name the exact accepted model route on model-provider recovery evidence so a
95
+ * person learns which model is affected. Display labels only: the route's
96
+ * credentials, base URL and upstream ids never enter the event.
97
+ */
98
+ export declare function withModelRoutePresentation<T extends {
99
+ code?: string | undefined;
100
+ }>(failure: T, route: {
101
+ model: string;
102
+ modelLabel: string;
103
+ providerLabel: string;
104
+ } | undefined): T & {
105
+ model?: string;
106
+ modelLabel?: string;
107
+ providerLabel?: string;
38
108
  };
39
109
  export declare function providerRecoveryCountFromMetadata(metadata: Record<string, unknown>): number;
40
110
  export declare function providerRecoveryCountAfterModelRequestPhase(currentCount: number, phase: string): number;
@@ -74,18 +144,30 @@ export declare function escapedMcpTimeoutRecoveryFailure(input: {
74
144
  */
75
145
  export declare function preClaimAdmissionFailure(error: unknown): ApplicationFailure;
76
146
  /**
77
- * Carry one exact claimed-but-not-started attempt into the workflow's DB-only
78
- * recovery lane. Permanent database/state failures remain terminal; only the
79
- * same operational outage classes that are safe before claim are admitted.
147
+ * True when an error is a structured database failure that the exact-attempt
148
+ * database recovery path owns. Callers that translate other failures into
149
+ * user-visible states must rethrow these unchanged.
150
+ */
151
+ export declare function isPostClaimDatabaseRecoveryCandidate(error: unknown): boolean;
152
+ /**
153
+ * Carry one exact claimed attempt into the workflow's DB-only
154
+ * recovery lane. Permanent database/state failures remain terminal. The
155
+ * running-turn lane additionally requires a closed own-client outage class;
156
+ * existing pre-execution recovery classifications are unchanged.
80
157
  */
81
158
  export declare function postClaimDatabaseRecoveryFailure(input: {
82
159
  error: unknown;
83
160
  turnId: string;
84
161
  triggerEventId: string;
85
162
  executionGeneration: number;
163
+ /** Require an actual own-client boundary and the closed running-turn allowlist. */
164
+ requireDatabaseProvenance?: boolean;
165
+ sandboxSetupOutcomeUnknown?: true;
166
+ sandboxSetupRecoveryExhausted?: true;
86
167
  providerRecovery?: {
87
168
  failureCode: string;
88
169
  providerRecoveryCount: number;
170
+ continueDelayMs?: number;
89
171
  };
90
172
  }): ApplicationFailure | null;
91
173
  /**
@@ -108,19 +190,16 @@ export type SandboxLifecycleTransitionDiagnostic = {
108
190
  * cross-package error object is accepted.
109
191
  */
110
192
  export declare function sandboxLifecycleTransitionDiagnostic(error: unknown): SandboxLifecycleTransitionDiagnostic | null;
111
- /**
112
- * Recognize the one active-route transition that cannot finish inside its
113
- * originating attempt. A Modal-home session may start on a Connected Machine
114
- * without creating or leasing its managed home box. When an explicit attach
115
- * clears the active pointer back to home, the pointer commit is authoritative,
116
- * but this attempt has no home session to serve the next sandbox operation.
117
- *
118
- * The Agents SDK may retain the typed routing error directly, through `cause`,
119
- * or inside an AggregateError from a parallel function-tool batch. Traverse
120
- * only those structural error links with a strict bound; never classify from
121
- * message text, which could originate in model or tool content.
122
- */
123
- export declare function sandboxRouteTransitionCode(error: unknown): "home_unavailable_this_turn" | "workspace_root_changed_this_turn" | null;
193
+ export declare function modelPreparationFailureEventPayload(error: unknown, durationMs: number): {
194
+ phase: string;
195
+ durationMs: number;
196
+ expectedTransition: boolean;
197
+ failureCategory?: string;
198
+ failureStage?: string;
199
+ failureCode?: "capture_in_progress" | "provider_recovery_in_progress" | "rotation_in_progress";
200
+ retryable?: boolean;
201
+ };
202
+ export declare function sandboxRouteTransitionCode(error: unknown): "home_unavailable_this_turn" | "workspace_root_changed_this_turn" | "native_capabilities_changed_this_attempt" | "home_backend_recovery_pending" | null;
124
203
  export declare function isSandboxRouteTransitionError(error: unknown): boolean;
125
204
  /** Backward-compatible name for callers/tests that only exercised the original
126
205
  * machine-to-home transition. */
@@ -168,6 +247,7 @@ export declare function compactionFailureTurnEventPayload(error: unknown, overri
168
247
  recovery: "user_message";
169
248
  compacted: false;
170
249
  providerRejection?: CompactionProviderRejection;
250
+ quotaScope?: ProviderQuotaScope;
171
251
  };
172
252
  export declare function isCompactionSummaryFailure(error: unknown): boolean;
173
253
  export declare function shouldRecoverCompactionProviderFailure(error: unknown): boolean;
@@ -233,22 +313,53 @@ export declare function collectErrorStrings(value: unknown, seen?: WeakSet<objec
233
313
  * same-execution retry.
234
314
  */
235
315
  export declare const STATUSLESS_UPSTREAM_CONNECTIVITY_MESSAGE = "unable to connect. is the computer able to access the url?";
316
+ /** Bun's exact fetch text when an upstream drops an open connection. */
317
+ export declare const STATUSLESS_UPSTREAM_SOCKET_CLOSED_MESSAGE = "the socket connection was closed unexpectedly. for more information, pass `verbose: true` in the second argument to fetch()";
236
318
  export declare function isExactStatuslessUpstreamConnectivityMessage(message: string): boolean;
319
+ /**
320
+ * A fetch-layer timeout: the runtime's DOMException `TimeoutError` (message
321
+ * "The operation timed out."), possibly wrapped by SDK/runner `cause` chains.
322
+ * Explicit cancellation (`AbortError`) is deliberately not matched.
323
+ */
324
+ export declare function isTransportTimeoutError(error: unknown): boolean;
237
325
  export declare function isTransientProviderError(error: unknown): boolean;
238
- export type XaiCredentialFailure = {
239
- kind: "auth" | "forbidden" | "rate_limit";
240
- cooldownMs: number | null;
241
- };
242
326
  /**
243
- * Only definitive SuperGrok account refusals may move the same logical turn to
244
- * another credential. A marked HTTP 401/403/429, or an HTTP 200 SSE terminal
245
- * that is a rate-limit/capacity diagnostic, proves inference was refused
246
- * without an accepted model response; refresh relogin is equally definitive.
327
+ * Recognize an exhausted API-key provider quota (a daily or monthly allowance,
328
+ * a free-tier day cap, or an account out of credits) as distinct from an
329
+ * ordinary per-minute rate limit. Retrying within the bounded same-turn budget
330
+ * cannot succeed, so the turn fails promptly instead. Subscription transports
331
+ * own their quota semantics through credential rotation and durable capacity
332
+ * waits, so a Codex, SuperGrok or Claude subscription transport error never
333
+ * classifies here.
247
334
  */
248
- export declare function classifyXaiCredentialFailure(error: unknown): XaiCredentialFailure | null;
335
+ export declare function classifyProviderQuotaExhaustionError(error: unknown): ProviderQuotaExhaustion | null;
336
+ /** A refusal raised by a Claude subscription (OAuth) transport, at any wrapper depth. */
337
+ export declare function isClaudeSubscriptionTransportError(error: unknown): boolean;
338
+ /**
339
+ * SuperGrok's classification of a failed model request as a shared provider
340
+ * outcome (the adapter's `classifyError`, SuperGrok track X1b): a refresh
341
+ * relogin or a marked 401 is `unauthorized`, a marked 403 `forbidden`, and a
342
+ * marked 429 or HTTP 200 SSE capacity terminal `rate_limited` with the
343
+ * provider's retry time (null when it gave none: the adapter's fallback
344
+ * applies). Anything else, a provider safety refusal included, is null: not
345
+ * a refusal of the account.
346
+ */
347
+ export declare function classifyXaiProviderError(error: unknown): ProviderErrorOutcome | null;
249
348
  export declare function agentRunFailurePayload(error: unknown, options?: {
250
349
  isCodexTurn?: boolean;
251
350
  }): ReturnType<typeof baseAgentRunFailurePayload>;
351
+ /** HTTP 529, Anthropic `overloaded_error`, or explicit provider "overloaded" wording. */
352
+ export declare function isProviderOverloadError(error: unknown, failure?: {
353
+ error?: string;
354
+ detail?: string;
355
+ }): boolean;
356
+ /** Retry authority must not depend on the looser presentation-only overload label. */
357
+ export declare function providerRecoveryCode(error: unknown, failure: {
358
+ code?: string;
359
+ retryable?: boolean;
360
+ }): string | undefined;
361
+ /** Keep Anthropic provider text on terminal failures, never recovery events. */
362
+ export declare function agentRunRecoveryFailurePayload(error: unknown, failure: ReturnType<typeof agentRunFailurePayload>): ReturnType<typeof agentRunFailurePayload>;
252
363
  declare function baseAgentRunFailurePayload(error: unknown, options?: {
253
364
  isCodexTurn?: boolean;
254
365
  }): {
@@ -271,10 +382,31 @@ declare function baseAgentRunFailurePayload(error: unknown, options?: {
271
382
  historyPersistenceStage?: MandatoryHistoryPersistenceStage;
272
383
  mcpTransportDiagnostic?: McpTransportRequestFailureDiagnostic;
273
384
  materializationDiagnostic?: MaterializationVerificationDiagnostic;
385
+ requestSize?: AnthropicRequestSize;
386
+ quotaScope?: ProviderQuotaScope;
387
+ /** Closed Codex plan key on `codex_plan_entitlement` / `codex_request_rejected`. */
388
+ planType?: string | null;
389
+ /** Product model id a `codex_plan_entitlement` or model-provider recovery failure refers to. */
390
+ model?: string | null;
391
+ /** Display label of the turn's model on model-provider recovery evidence. */
392
+ modelLabel?: string;
393
+ /** Display label of the serving provider on model-provider recovery evidence. */
394
+ providerLabel?: string;
395
+ /** Closed transient provider condition on `provider_unavailable` / `provider_rate_limited`. */
396
+ providerCondition?: ProviderCondition;
397
+ recoveryExhausted?: boolean;
398
+ providerRecoveryCount?: number;
399
+ maxProviderRecoveryCount?: number;
400
+ providerRecoveryExhaustedReason?: "deadline" | "retry_limit" | "invalid_clock";
274
401
  };
275
402
  export type CodexCredentialFailure = {
276
- kind: "auth" | "forbidden" | "rate_limit" | "quota";
403
+ /**
404
+ * `plan_entitlement` is produced only after a plan re-check proves the
405
+ * serving account's current plan does not include the requested model.
406
+ */
407
+ kind: "auth" | "forbidden" | "rate_limit" | "quota" | "plan_entitlement";
277
408
  cooldownSeconds: number | null;
409
+ origin?: "included_usage_policy" | "usage_verification_policy";
278
410
  };
279
411
  export declare const CODEX_ALLOWANCE_FALLBACK_MS: number;
280
412
  /**
@@ -310,4 +442,16 @@ export declare function codexUsageLimitFailurePayload(info: {
310
442
  detail?: string;
311
443
  };
312
444
  export declare const CODEX_USAGE_LIMIT_MAX_RESUME_MS: number;
313
- export {};
445
+ /**
446
+ * Claude's classification of a failed model request as a shared provider
447
+ * outcome (the adapter's `classifyError`, Claude track C1b), for a request
448
+ * of the Claude subscription transport only: a reconnect-required refresh or
449
+ * HTTP 401 is `unauthorized` (the transport already ran the turn's one
450
+ * forced refresh); 429 is `rate_limited` for the turn's model `modelId`, with
451
+ * the provider's retry time (null: the adapter's fallback applies); 529 or
452
+ * `overloaded_error` is `overloaded`, which never moves the turn to another
453
+ * account; 403 is `fatal`, which never rotates or quarantines the account.
454
+ * Anything else, a provider safety refusal included, is null: not a refusal
455
+ * of the account.
456
+ */
457
+ export declare function classifyClaudeProviderError(error: unknown, modelId?: string): ProviderErrorOutcome | null;
@@ -1,8 +1,9 @@
1
- import type { Settings } from "@opengeni/config";
1
+ import { type Settings } from "@opengeni/config";
2
2
  import type { TurnActivityServices as ActivityServices, RunAgentTurnInput, RunAgentTurnResult } from "../types.js";
3
3
  import { createTurnCredentialLeases } from "./credential-leases.js";
4
4
  import { createTurnHistorySink } from "./history-sink.js";
5
- import type { AttemptIdentityState, BillingState, EventingState, ProviderTurnState, TurnControlState } from "./turn-context.js";
5
+ import { agentRunFailurePayload } from "./errors.js";
6
+ import type { AttemptIdentityState, BillingState, CodexSubscriptionCoreTurn, EventingState, ProviderTurnState, TurnControlState } from "./turn-context.js";
6
7
  export type TurnFailureDeps = {
7
8
  error: unknown;
8
9
  input: RunAgentTurnInput;
@@ -11,6 +12,8 @@ export type TurnFailureDeps = {
11
12
  bus: ActivityServices["bus"];
12
13
  observability: ActivityServices["observability"];
13
14
  wakeSessionWorkflow: ActivityServices["wakeSessionWorkflow"];
15
+ /** Typed capacity-wake signals of core waiters (a refusal's joined observations may wake them). */
16
+ signalCodexCapacityWorkflow?: ActivityServices["signalCodexCapacityWorkflow"];
14
17
  cancellationSignal: AbortSignal | undefined;
15
18
  sandboxRotationController: AbortController;
16
19
  noteCancellationRequested: () => void;
@@ -30,46 +33,10 @@ export type TurnFailureDeps = {
30
33
  acknowledgeRecoveryQuiescence: () => void;
31
34
  };
32
35
  export type CodexDefinitiveFailureDisposition = "failover" | "wait" | "terminal";
33
- type CodexCapacityWaitFailurePayload = {
34
- error: string;
35
- code: string;
36
- detail?: string;
37
- retryable: false;
38
- };
39
- /**
40
- * Pure policy for a definitive serving-credential refusal. A policy-constrained
41
- * account and an all-unavailable pool wait for the same selected capacity to
42
- * recover; only a truly empty/non-allocatable pool makes an auth/forbidden
43
- * failure terminal. A different eligible account under rotation-on policy may
44
- * recover the same durable turn immediately.
45
- */
46
- export declare function codexDefinitiveFailureDisposition(input: {
47
- failureKind: "auth" | "forbidden" | "rate_limit" | "quota";
48
- rotationEnabled: boolean;
49
- pinDisposition: "manual" | "sharded" | "clearStale" | "unpinned";
50
- decisionKind: "active" | "allCapped" | "none";
51
- decisionCredentialId: string | null;
52
- servingCredentialId: string;
53
- }): CodexDefinitiveFailureDisposition;
36
+ export declare function settleTurnFailure(deps: TurnFailureDeps): Promise<RunAgentTurnResult>;
54
37
  /**
55
- * Bound one turn to the alternate credentials that policy actually permits.
56
- * The effective account list is already workspace/organization scoped;
57
- * allocator-disabled rows must not enlarge the retry budget. The database
58
- * requires a positive bound even though one-account paths never fail over.
38
+ * Classify a Codex failure whose only replay obstacle is this attempt's own
39
+ * interrupted request. Returns the retryable failure the bounded provider
40
+ * recovery should use, or null when the unknown outcome must stay terminal.
59
41
  */
60
- export declare function codexCredentialFailoverLimit(accounts: ReadonlyArray<{
61
- id: string;
62
- allocatorEnabled: boolean;
63
- }>, servingCredentialId: string): number;
64
- /** Build the durable waiter payload without collapsing quota refusals into 403. */
65
- export declare function codexCapacityWaitFailurePayload(input: {
66
- failureKind: "auth" | "forbidden" | "rate_limit" | "quota";
67
- usageLimit: {
68
- resetsInSeconds: number | null;
69
- } | null;
70
- cooldownSeconds: number | null;
71
- detail: string;
72
- allAccounts: boolean;
73
- }): CodexCapacityWaitFailurePayload;
74
- export declare function settleTurnFailure(deps: TurnFailureDeps): Promise<RunAgentTurnResult>;
75
- export {};
42
+ export declare function ownInterruptedCodexRequestRecovery(error: unknown, core: Pick<CodexSubscriptionCoreTurn, "requests">, isCodexTurn: boolean): ReturnType<typeof agentRunFailurePayload> | null;
@@ -0,0 +1,18 @@
1
+ /** One durable, same-logical-turn handoff, not a retry of model/tool effects. */
2
+ export declare function finalReplyNudge(turnId: string): {
3
+ type: "message";
4
+ role: "developer";
5
+ content: {
6
+ type: "input_text";
7
+ text: string;
8
+ }[];
9
+ };
10
+ export declare function hasFinalReplyNudge(history: readonly unknown[], turnId: string): boolean;
11
+ export declare function needsFinalReply(input: {
12
+ output: unknown;
13
+ inputWaitYielded: boolean;
14
+ interrupted: boolean;
15
+ maintenance: boolean;
16
+ toolsExecuted: boolean;
17
+ completedGoal: boolean;
18
+ }): boolean;
@@ -1,4 +1,4 @@
1
- import type { Observability } from "@opengeni/observability";
1
+ import { type Observability } from "@opengeni/observability";
2
2
  import type { TurnHeartbeatDetails } from "../../op-journal.js";
3
3
  export declare const TURN_FINALIZATION_STAGES: readonly ["tool_writers", "credential_renewals", "credential_cleanup", "quiescence_receipt", "event_flush", "provider_leases", "workspace_capture", "tool_close", "sandbox_provisioning", "sandbox_rotation", "workspace_snapshot", "sandbox_release"];
4
4
  export type TurnFinalizationStage = (typeof TURN_FINALIZATION_STAGES)[number];
@@ -8,7 +8,12 @@ export declare function startTurnFinalizationMonitor(input: {
8
8
  observability: Observability;
9
9
  details: TurnHeartbeatDetails;
10
10
  heartbeat: (details: TurnHeartbeatDetails) => void;
11
- terminateWorker: () => void;
11
+ requestWorkerDrain: () => void;
12
+ execution?: {
13
+ workspaceId: string;
14
+ sessionId: string;
15
+ attemptId: string;
16
+ };
12
17
  timeoutMs?: number;
13
18
  slowAfterMs?: number;
14
19
  }): {
@@ -16,6 +16,8 @@ export type TurnFinalizationDeps = {
16
16
  wakeSessionWorkflow: ActivityServices["wakeSessionWorkflow"];
17
17
  signalSessionAttemptQuiesced: ActivityServices["signalSessionAttemptQuiesced"];
18
18
  signalCodexCapacityWorkflow: ActivityServices["signalCodexCapacityWorkflow"];
19
+ requestWorkerDrain: ActivityServices["requestWorkerDrain"];
20
+ turnFinalizationTimeoutMs: ActivityServices["turnFinalizationTimeoutMs"];
19
21
  cancellationSignal: AbortSignal | undefined;
20
22
  sandboxResumeController: AbortController;
21
23
  activityContext: ReturnType<typeof currentActivityContext>;
@@ -76,6 +76,8 @@ export type ApplyTurnGitHubRepositoryBindingsInput = {
76
76
  workspaceId: string;
77
77
  sessionId: string;
78
78
  activeSandboxBackend: Settings["sandboxBackend"] | undefined;
79
+ /** Product-owned credentials take precedence over inferred platform bindings. */
80
+ hasCredentialProvider?: boolean;
79
81
  claimedTurnResources: readonly ResourceRef[];
80
82
  claimedRuntimeResources: readonly ResourceRef[];
81
83
  /** Publishes one attempt-fenced session event batch. */
@@ -1,4 +1,4 @@
1
- import { materializeRigVersionForAttempt } from "@opengeni/db";
1
+ import { materializeRigVersionForAttempt, freezeAgentLearningPolicy } from "@opengeni/db";
2
2
  import { renderWorkspaceGovernanceContext, type OpenGeniRuntime } from "@opengeni/runtime";
3
3
  import { type Settings } from "@opengeni/config";
4
4
  import { createModelHistoryAttachmentProjector } from "../run-input.js";
@@ -9,8 +9,10 @@ import { lazyToolTransportForTurn, openAiHostedImageProviderBindingForTurn, mode
9
9
  import type { ClaimTurnOk } from "./claim.js";
10
10
  import type { EventingState, WorkspaceRefState } from "./turn-context.js";
11
11
  export type GovernanceModelDeps = {
12
+ learningPolicy: Awaited<ReturnType<typeof freezeAgentLearningPolicy>>;
12
13
  input: RunAgentTurnInput;
13
14
  db: ActivityServices["db"];
15
+ observability: ActivityServices["observability"];
14
16
  runtime: ActivityServices["runtime"];
15
17
  objectStorage: ActivityServices["objectStorage"];
16
18
  eventing: EventingState;
@@ -37,9 +39,19 @@ export type GovernanceModelOk = {
37
39
  rigVersion: NonNullable<Awaited<ReturnType<typeof materializeRigVersionForAttempt>>>["version"] | null;
38
40
  rigName: string | null;
39
41
  agentHumanInputEnabled: boolean;
42
+ /** Deployment and workspace allow the Jev-backed code_search tool. */
43
+ codeSearchEnabled: boolean;
40
44
  workspaceAgentInstructions: string | null | undefined;
45
+ /**
46
+ * Modular composer identity tier: the explicit workspace default identity,
47
+ * else the frozen legacy persona without `{{core}}`. Never dropped by
48
+ * instruction policies (only read for sessions with an agent configuration).
49
+ */
50
+ workspaceAgentIdentity: string | null;
41
51
  workspaceGovernance: ReturnType<typeof renderWorkspaceGovernanceContext>;
42
52
  structuredWorkspacePolicyActive: boolean;
53
+ /** False when the workspace turned Opengeni credits off (model policy). */
54
+ workspaceCreditModelsAllowed: boolean;
43
55
  workspaceMemory: string | null | undefined;
44
56
  buildCompanyBrainContributionReceiptFor: (skillCatalogText: string) => ReturnType<typeof buildCompanyBrainContributionReceipt>;
45
57
  logicalSandboxSettings: Settings;
@@ -1,5 +1,5 @@
1
1
  import { type OpenGeniRuntime } from "@opengeni/runtime";
2
- import type { Settings } from "@opengeni/config";
2
+ import { type Settings } from "@opengeni/config";
3
3
  import type { SharedActivityServices } from "../types.js";
4
4
  import type { turnInput } from "../run-input.js";
5
5
  import type { TurnMediaArtifacts } from "./media-artifacts.js";
@@ -41,6 +41,7 @@ export type TurnHistorySinkDeps = {
41
41
  export declare class TurnHistorySink {
42
42
  private readonly deps;
43
43
  private readonly prefix;
44
+ private checkpointTail;
44
45
  seedHistory(input: string | readonly unknown[] | {
45
46
  readonly history: unknown[];
46
47
  }, count: number): void;
@@ -52,5 +53,6 @@ export declare class TurnHistorySink {
52
53
  skipInputOnlyRows?: boolean;
53
54
  requireDurable?: boolean;
54
55
  }) => Promise<void>;
56
+ private reconcile;
55
57
  }
56
58
  export declare function createTurnHistorySink(deps: TurnHistorySinkDeps): TurnHistorySink;
@@ -49,6 +49,8 @@ export declare function pendingToolCallFromSdkEvent(event: unknown): {
49
49
  } | null;
50
50
  /** Tools whose intentional visual result must survive inline-media sanitization. */
51
51
  export declare function toolCallProducesRetainableSessionImage(name: string | null): boolean;
52
+ /** Browser interactions can carry an image block, including opt-in observe frames. */
53
+ export declare function retainableBrowserScreenshotToolCall(name: string | null): boolean;
52
54
  export declare function completedToolCallFromSdkEvent(event: unknown): {
53
55
  callId: string;
54
56
  resultItem: Record<string, unknown>;
@@ -0,0 +1,76 @@
1
+ import { type Database } from "@opengeni/db";
2
+ import type { TurnInitiator, TurnInitiatorContext } from "@opengeni/contracts";
3
+ type ReplyTurn = {
4
+ source?: string | undefined;
5
+ initiator: TurnInitiator;
6
+ initiatorContext: TurnInitiatorContext;
7
+ };
8
+ /**
9
+ * Whether a turn answers a message a person sent, directly or through an API
10
+ * caller that relays one (an embedding host, a realtime delegation). The
11
+ * source alone is not enough: every session's first turn is `user`, including
12
+ * a child an agent spawned and a session a scheduled task created.
13
+ */
14
+ export declare function turnAnswersMessage(turn: ReplyTurn): boolean;
15
+ /**
16
+ * The reply `turn.completed` records when a turn ends through `wait_for_input`
17
+ * (read back with `turnCompletedReply` in `@opengeni/contracts`).
18
+ *
19
+ * Such a turn settles with an empty `output`: the wait, not an answer, ended
20
+ * it. When the turn answers a person's message, its latest assistant message
21
+ * is still that message's answer, for example a status reply given before
22
+ * waiting again on work in flight. That message shares its model response with
23
+ * the wait call, so it streams as commentary, which is activity everywhere
24
+ * else. Recording it lets unread attention and Slack treat it as the answer
25
+ * without relabelling the provider's phase in stored history. Turns that
26
+ * machine input, an agent or a worker-owned producer started only narrate
27
+ * progress and record nothing.
28
+ *
29
+ * The message this activity completed last is the newest. An activity that
30
+ * resumed the turn (after an approval, a human-input answer or a recovery) and
31
+ * completed none reads the turn's latest durable message instead.
32
+ */
33
+ export declare function inputWaitReply(input: {
34
+ inputWaitYielded: boolean;
35
+ turn: ReplyTurn;
36
+ latestAssistantMessageText: string | null;
37
+ readLatestDurableTurnMessage: () => Promise<string | null>;
38
+ }): Promise<string | null>;
39
+ /**
40
+ * Text of the newest current `agent.message.completed` this turn persisted,
41
+ * or null when the session's newest completion belongs to another turn.
42
+ */
43
+ export declare function latestDurableTurnMessageText(db: Database, input: {
44
+ workspaceId: string;
45
+ sessionId: string;
46
+ turnId: string;
47
+ }): Promise<string | null>;
48
+ /**
49
+ * Tool error the model receives when it waits before answering a person.
50
+ *
51
+ * Models with extended thinking often draft the reply inside their thinking
52
+ * and believe it was sent, then retry the wait unchanged and conclude that a
53
+ * wait cannot be armed at all. The text therefore names thinking explicitly and
54
+ * says the reply may share the wait call's response.
55
+ */
56
+ export declare const INPUT_WAIT_REPLY_REFUSAL = "wait_for_input was not registered: this turn answers a person's message and you have not written a visible reply yet. Your reasoning is not shown to them: text inside a thinking or reasoning block does not count, even when it is written as an answer. Write your answer to their message as a normal assistant text block (it may be in the same response, before the wait_for_input call), then call wait_for_input again. If an earlier wait is still armed, pass the time remaining on its deadline rather than a fresh timeout.";
57
+ /**
58
+ * Refusals per turn attempt (one worker activity); a resumed or retried
59
+ * attempt starts again. After that the wait proceeds rather than looping.
60
+ */
61
+ export declare const MAX_INPUT_WAIT_REPLY_REFUSALS = 2;
62
+ /**
63
+ * Why `wait_for_input` must not end this turn yet, or null.
64
+ *
65
+ * A wait ends the turn at the tool boundary, so no message can follow it. When
66
+ * the turn answers a person's message and has no visible assistant text, the
67
+ * person would get no answer at all (the model may have drafted one only in its
68
+ * reasoning). Refusing the wait as a tool error gives the model one more step
69
+ * to write the reply; the wait is registered on its next call.
70
+ */
71
+ export declare function inputWaitReplyRefusal(input: {
72
+ turn: ReplyTurn;
73
+ refusalsSoFar: number;
74
+ hasVisibleReply: () => Promise<boolean>;
75
+ }): Promise<string | null>;
76
+ export {};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Conservative progress evidence for a model response that reaches the worker
3
+ * as an SDK `response_done` event (providers without their own request
4
+ * events): completed assistant text or a complete function call. Reasoning,
5
+ * usage, an incomplete message and empty bookkeeping are not work. The shared
6
+ * false-resumption breaker of core waiters reads this through
7
+ * `agent.model.request` `meaningfulOutput`.
8
+ */
9
+ export declare function sdkResponseHasMeaningfulOutput(event: unknown): boolean;
@@ -1,5 +1,6 @@
1
1
  import { type CodemodeTokenWriterSession, type RetainableSessionImageOutputHook, type TurnToolCancellationFence } from "@opengeni/runtime";
2
2
  import type { Settings } from "@opengeni/config";
3
+ import type { RetainedSessionScreenshotKind } from "@opengeni/contracts";
3
4
  import type { ResumedTurnSandbox } from "../../sandbox-resume.js";
4
5
  import type { SharedActivityServices } from "../types.js";
5
6
  import { type GeneratedImageOutput, type GeneratedImageReceipt } from "../generated-images.js";
@@ -35,7 +36,7 @@ export declare class TurnMediaArtifacts {
35
36
  readonly retainedScreenshotReceiptsByCallId: Map<string, {
36
37
  available: true;
37
38
  artifactId: string;
38
- kind: "assistant_completion" | "computer_screenshot" | "event_media" | "file" | "generated_image" | "generated_video" | "internal_update" | "tool_result";
39
+ kind: "assistant_completion" | "browser_screenshot" | "computer_screenshot" | "event_media" | "file" | "generated_image" | "generated_video" | "internal_update" | "tool_result";
39
40
  contentType: string;
40
41
  originalBytes: number;
41
42
  sha256: string;
@@ -68,7 +69,7 @@ export declare class TurnMediaArtifacts {
68
69
  artifact: {
69
70
  available: true;
70
71
  artifactId: string;
71
- kind: "assistant_completion" | "computer_screenshot" | "event_media" | "file" | "generated_image" | "generated_video" | "internal_update" | "tool_result";
72
+ kind: "assistant_completion" | "browser_screenshot" | "computer_screenshot" | "event_media" | "file" | "generated_image" | "generated_video" | "internal_update" | "tool_result";
72
73
  contentType: string;
73
74
  originalBytes: number;
74
75
  sha256: string;
@@ -98,7 +99,7 @@ export declare class TurnMediaArtifacts {
98
99
  artifact: {
99
100
  available: true;
100
101
  artifactId: string;
101
- kind: "assistant_completion" | "computer_screenshot" | "event_media" | "file" | "generated_image" | "generated_video" | "internal_update" | "tool_result";
102
+ kind: "assistant_completion" | "browser_screenshot" | "computer_screenshot" | "event_media" | "file" | "generated_image" | "generated_video" | "internal_update" | "tool_result";
102
103
  contentType: string;
103
104
  originalBytes: number;
104
105
  sha256: string;
@@ -128,6 +129,7 @@ export declare class TurnMediaArtifacts {
128
129
  sandboxFileDownloadBackend: Settings["sandboxBackend"];
129
130
  nativeImageGenerationRetention: NativeImageGenerationRetention | null;
130
131
  readonly retainedSessionImageCallIds: Set<string>;
132
+ readonly retainedSessionImageKindsByCallId: Map<string, RetainedSessionScreenshotKind>;
131
133
  constructor(deps: TurnMediaArtifactDeps);
132
134
  rememberGeneratedImageCreatedThisTurn: (receipt: GeneratedImageReceipt) => void;
133
135
  private prepareGeneratedImageDownload;
@@ -0,0 +1,15 @@
1
+ import type { StreamEvent } from "@openai/agents";
2
+ /** SDK producer/consumer rendezvous. Usage stays on the sole consumer writer. */
3
+ export declare function createModelCallAdmission(input: {
4
+ signal: AbortSignal;
5
+ admit: () => Promise<void>;
6
+ }): {
7
+ beforeModelRequest: () => Promise<void>;
8
+ onModelResponse: (event: StreamEvent) => Promise<void>;
9
+ settle: (event: {
10
+ type: string;
11
+ data?: unknown;
12
+ }) => void;
13
+ fail: (error: unknown) => void;
14
+ close: () => void;
15
+ };