@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
@@ -3,11 +3,19 @@ import { modelResponseServiceTierFromSdkEvent, modelTerminalResponseFromSdkEvent
3
3
  import { type ModelUsageInput, type ModelProviderApi, type Settings } from "@opengeni/config";
4
4
  import type { TurnActivityServices as ActivityServices } from "../types.js";
5
5
  import { type LatencyMode, type ModelContextContributionSummary, type SessionEvent } from "@opengeni/contracts";
6
+ import { sanitizedModelUsageInput, type ModelUsageBillingRecord } from "@opengeni/core";
6
7
  export declare function modelUsageSourceKey(input: {
7
8
  responseId?: string | null | undefined;
8
9
  dispatchId: string | null;
9
10
  positionalKey: string;
10
11
  }): string;
12
+ /** Legacy aggregate usage may only debit a policy shared by its completed calls. */
13
+ export declare function aggregateCreditPolicyRevision(input: {
14
+ responseRevisions: ReadonlySet<number | undefined>;
15
+ lastAdmittedRevision: number | undefined;
16
+ chargesOpenGeniCredits: boolean;
17
+ totalTokens: number | null;
18
+ }): number | undefined;
11
19
  export declare function providerContextTokens(usage: {
12
20
  inputTokens?: number;
13
21
  outputTokens?: number;
@@ -45,6 +53,14 @@ export type CompactionModelUsageEventState = {
45
53
  usageCount: number;
46
54
  claimedSourceKeys: Set<string>;
47
55
  };
56
+ /**
57
+ * Why the worker made a model call. The durable `agent.model.usage` payload
58
+ * records it so a reader can tell the turn's own inference (`main`, including
59
+ * the aggregate billing fallback) from the auxiliary context summarizer and
60
+ * session-title calls. Only the worker sets it, at the call site; it changes no
61
+ * source key, billing, credit, idempotency or metric label.
62
+ */
63
+ export type ModelCallPurpose = "main" | "compaction" | "session-title";
48
64
  export declare function createModelResponseEventState(claimedSourceKeys?: Set<string>): ModelResponseEventState;
49
65
  export declare function createCompactionModelUsageEventState(claimedSourceKeys?: Set<string>): CompactionModelUsageEventState;
50
66
  export declare const createSessionTitleModelUsageEventState: typeof createCompactionModelUsageEventState;
@@ -92,8 +108,11 @@ export declare function processModelResponseTerminalEvent(input: {
92
108
  externallyBilled: boolean;
93
109
  chargesOpenGeniCredits?: boolean;
94
110
  countsTowardTokenCap?: boolean;
111
+ creditPolicyRevision?: number | undefined;
95
112
  servingCredentialId: string | null;
96
113
  priorSessionCredentialId: string | null;
114
+ /** The shared-core subscription connection that served the call (billing attribution). */
115
+ subscriptionConnectionId?: string | null;
97
116
  emittedSourceKeys: Set<string>;
98
117
  renewLease: () => Promise<void>;
99
118
  leaseLost: () => boolean;
@@ -121,7 +140,7 @@ export declare function processModelResponseTerminalEvent(input: {
121
140
  export declare function processCompactionModelUsageEvent(input: {
122
141
  usage: ModelResponseUsage;
123
142
  state: CompactionModelUsageEventState;
124
- sourceKind?: "compaction" | "session-title";
143
+ sourceKind?: Exclude<ModelCallPurpose, "main">;
125
144
  dispatchId: string | null;
126
145
  settings: Settings;
127
146
  db: ActivityServices["db"];
@@ -138,8 +157,11 @@ export declare function processCompactionModelUsageEvent(input: {
138
157
  externallyBilled: boolean;
139
158
  chargesOpenGeniCredits?: boolean;
140
159
  countsTowardTokenCap?: boolean;
160
+ creditPolicyRevision?: number | undefined;
141
161
  servingCredentialId: string | null;
142
162
  priorSessionCredentialId: string | null;
163
+ /** The shared-core subscription connection that served the call (billing attribution). */
164
+ subscriptionConnectionId?: string | null;
143
165
  emittedSourceKeys: Set<string>;
144
166
  renewLease: () => Promise<void>;
145
167
  leaseLost: () => boolean;
@@ -164,6 +186,8 @@ export declare function emitModelCallUsage(input: {
164
186
  provider: string;
165
187
  providerApi: ModelProviderApi;
166
188
  model: string;
189
+ /** Why the worker made this call; durable event and log line only, never a metric label. */
190
+ purpose: ModelCallPurpose;
167
191
  sourceKey: string;
168
192
  usage: ModelResponseUsage | {
169
193
  usage?: unknown | null;
@@ -171,6 +195,8 @@ export declare function emitModelCallUsage(input: {
171
195
  normalizedUsage?: ModelCallUsageNormalization;
172
196
  /** Accepted billing authority persisted for Insights repair after a soft fact-write failure. */
173
197
  billingPath?: ModelUsageBillingRecord["billingPath"];
198
+ /** Accepted comparisons are frozen with the event, not repriced during fact repair. */
199
+ billingSnapshot?: Pick<ModelUsageBillingRecord, "pricedCostMicros" | "estimatedProviderCostMicros" | "equivalentCreditCostMicros" | "pricingSource" | "listByClassMicros" | "listByClassApprox">;
174
200
  /** Validated Gateway endpoint provider persisted for exact Insights repair. */
175
201
  upstreamProvider?: string;
176
202
  servingAccountHash?: string;
@@ -183,18 +209,8 @@ export declare function emitModelCallUsage(input: {
183
209
  * owns idempotency; this helper must never receive raw provider values.
184
210
  */
185
211
  export declare function applyCodexCacheTelemetry(observability: ActivityServices["observability"], provider: string, normalizedUsage: ModelCallUsageNormalization): void;
186
- export type ModelUsageBillingRecord = {
187
- billingPath: "opengeni_credits" | "external";
188
- /** Same quantity written to usage_events.model.cost when present; else 0. */
189
- pricedCostMicros: number;
190
- /** Hypothetical provider-rate USD micros; never an OpenGeni charge. */
191
- estimatedProviderCostMicros: number | null;
192
- /** Hypothetical OpenGeni credit price at the captured rate; never a debit. */
193
- equivalentCreditCostMicros: number | null;
194
- pricingSource: "configured_list_price" | "gateway_reported" | null;
195
- normalizedUsage: ModelCallUsageNormalization;
196
- upstreamProvider?: string;
197
- };
212
+ export type { ModelUsageBillingRecord };
213
+ export { sanitizedModelUsageInput };
198
214
  export declare function recordModelUsageAndDebitCredits(settings: Settings, db: ActivityServices["db"], input: {
199
215
  accountId: string;
200
216
  workspaceId: string;
@@ -205,13 +221,38 @@ export declare function recordModelUsageAndDebitCredits(settings: Settings, db:
205
221
  externallyBilled: boolean;
206
222
  chargesOpenGeniCredits?: boolean;
207
223
  countsTowardTokenCap?: boolean;
224
+ creditPolicyRevision?: number | undefined;
208
225
  gatewayBilling?: ModelResponseUsage["gatewayBilling"];
209
226
  usage?: ModelUsageInput | ModelCallUsageInput | null;
210
227
  normalizedUsage?: ModelCallUsageNormalization;
211
228
  sourceKey: string;
212
229
  latencyMode?: LatencyMode;
213
230
  observability?: ActivityServices["observability"];
231
+ /** Configured provider id for metric labels; never billing authority. */
232
+ metricProvider?: string;
214
233
  }): Promise<ModelUsageBillingRecord | null>;
234
+ /**
235
+ * The bounded `model` metric label: the deployment catalog product id for a
236
+ * catalog model, or `custom` for a workspace-owned model (workspace gateway or
237
+ * a customer-key provider) and for anything the deployment catalog does not
238
+ * list. Metrics only; never billing or routing authority.
239
+ */
240
+ export declare function modelMetricProductId(settings: Settings, provider: string | undefined, model: string): string;
241
+ /**
242
+ * Per-model usage and estimated provider cost for one authoritative response.
243
+ * Call only after the durable usage event was accepted as current (the same
244
+ * fence as the Insights fact). Best-effort: never throws.
245
+ */
246
+ export declare function recordAuthoritativeModelUsageMetrics(input: {
247
+ observability: ActivityServices["observability"];
248
+ settings: Settings;
249
+ provider: string;
250
+ model: string;
251
+ externallyBilled: boolean;
252
+ billing: ModelUsageBillingRecord;
253
+ /** Provider-run web searches this response billed, when the provider reports them. */
254
+ webSearchRequests?: number | undefined;
255
+ }): void;
215
256
  /** Soft-fail Insights fact write — never throws into the billing/emit path. */
216
257
  export declare function recordAuthoritativeModelCallFact(input: {
217
258
  db: ActivityServices["db"];
@@ -226,7 +267,8 @@ export declare function recordAuthoritativeModelCallFact(input: {
226
267
  providerApi: ModelProviderApi;
227
268
  model: string;
228
269
  billing: ModelUsageBillingRecord;
270
+ /** The shared-core subscription connection that served the call, if any. */
271
+ subscriptionConnectionId?: string | null;
229
272
  contextContributions?: readonly ModelContextContributionSummary[] | null;
230
273
  }): Promise<void>;
231
- export declare function sanitizedModelUsageInput(normalized: ModelCallUsageNormalization): ModelUsageInput;
232
274
  export declare function startOfUtcMonth(): Date;
@@ -0,0 +1,15 @@
1
+ import type { ModelTransportDispatchClock } from "@opengeni/runtime";
2
+ type DispatchIdentity = {
3
+ provider: string;
4
+ dispatchId: string;
5
+ };
6
+ /** One immutable physical fetch-entry observation per worker attempt. Generic
7
+ * fallback events already carry that attempt's dispatch/execution identity. */
8
+ export declare class InitialModelWireDispatchClock {
9
+ private initial;
10
+ record(identity: DispatchIdentity, clock: ModelTransportDispatchClock): void;
11
+ payload(identity: DispatchIdentity): {
12
+ initialWireDispatchedAt?: string;
13
+ };
14
+ }
15
+ export {};
@@ -0,0 +1,59 @@
1
+ import type { Settings } from "@opengeni/config";
2
+ import { type ResourceRef } from "@opengeni/contracts";
3
+ import { type Database } from "@opengeni/db";
4
+ /**
5
+ * Turn-time access check for automatically attached (`optional: true`) GitHub
6
+ * App repositories.
7
+ *
8
+ * A Slack-started session attaches the caller's recently used repositories as
9
+ * optional resources. The per-turn workspace-allowlist recheck and the
10
+ * installation-token mint both cover every GitHub repository of the session in
11
+ * one request, so one optional repository that loses access after the session
12
+ * started (an admin removes it from the allowlist, or it is deleted or removed
13
+ * from the App on GitHub) would fail every later turn. Before those checks, this
14
+ * drops each optional repository that is no longer allowlisted or no longer
15
+ * reachable through its installation, for this turn only, and reports it the
16
+ * same way a skipped optional clone is reported. It only ever removes
17
+ * repositories: a remaining repository still passes the unchanged strict
18
+ * allowlist recheck and mint, and an explicitly attached repository is never
19
+ * dropped, so it keeps failing the turn when its access is gone.
20
+ */
21
+ export declare const OPTIONAL_REPOSITORY_ACCESS_OPERATION = "optional-repository-access";
22
+ export type OptionalRepositoryDropReason = "not_allowlisted" | "inaccessible" | "unverified";
23
+ export type DropUnavailableOptionalRepositoriesInput = {
24
+ db: Database;
25
+ settings: Settings;
26
+ workspaceId: string;
27
+ activeSandboxBackend: Settings["sandboxBackend"] | undefined;
28
+ /**
29
+ * True when a host `gitCredentials` port mints the Git tokens: the host may
30
+ * use another GitHub App, so this deployment's App is not asked.
31
+ */
32
+ hostMintsGitCredentials: boolean;
33
+ turnResources: readonly ResourceRef[];
34
+ runtimeResources: readonly ResourceRef[];
35
+ /** Publishes one attempt-fenced session event batch. */
36
+ publish: (events: Array<{
37
+ type: "sandbox.operation.completed";
38
+ payload: {
39
+ name: typeof OPTIONAL_REPOSITORY_ACCESS_OPERATION;
40
+ repositoryCount: number;
41
+ skippedOptionalRepositories: string[];
42
+ };
43
+ }>) => Promise<void>;
44
+ /** Operational log line; counts only, never repository names. */
45
+ warn: (message: string, fields: Record<string, string>) => void;
46
+ /** Test seam; defaults to the workspace allowlist under RLS. */
47
+ isAllowlisted?: (installationId: number, repositoryId: number) => Promise<boolean>;
48
+ /** Test seam; defaults to a live GitHub App token-mint probe. */
49
+ findInaccessible?: (installationId: number, repositoryIds: number[]) => Promise<number[]>;
50
+ };
51
+ export declare function dropUnavailableOptionalRepositories(input: DropUnavailableOptionalRepositoriesInput): Promise<{
52
+ turnResources: ResourceRef[];
53
+ runtimeResources: ResourceRef[];
54
+ /**
55
+ * The same decision for another view of this turn's resources (the GitHub
56
+ * REST tool surface is built from the unbound session resources).
57
+ */
58
+ retainsResource: (resource: ResourceRef) => boolean;
59
+ }>;
@@ -0,0 +1,17 @@
1
+ import { type AgentPromptToolAvailability } from "@opengeni/runtime";
2
+ import type { FirstPartyMcpToolName, Permission, ResolvedAgentConfig } from "@opengeni/contracts";
3
+ /**
4
+ * The frozen clause-availability view for one attempt's modular instructions.
5
+ * Derived from the same accepted first-party selection and permission ceiling
6
+ * the worker signs into the delegated token and hands to in-process adapters,
7
+ * so it can only describe tools the executable catalog already excludes. It is
8
+ * a rendering input, never authority.
9
+ *
10
+ * Sessions without an agent configuration keep the legacy composition, which
11
+ * does not read availability; they receive undefined so nothing changes.
12
+ */
13
+ export declare function promptToolAvailabilityForTurn(input: {
14
+ agentConfig: ResolvedAgentConfig | null | undefined;
15
+ selectedFirstPartyMcpTools: readonly FirstPartyMcpToolName[];
16
+ firstPartyPermissions: readonly Permission[] | null | undefined;
17
+ }): AgentPromptToolAvailability | undefined;
@@ -1,8 +1,19 @@
1
1
  import type { TurnHistorySink } from "./history-sink.js";
2
+ import type { Settings } from "@opengeni/config";
3
+ export declare class SandboxCapabilitiesChangedError extends Error {
4
+ readonly code = "native_capabilities_changed_this_attempt";
5
+ constructor();
6
+ }
2
7
  /**
3
8
  * Persist the SDK's complete prior model/tool history before another provider
4
9
  * request can start. The first request has no prior model/tool rows to append.
5
10
  * Follow-up requests run only after the preceding complete call/result batch is
6
11
  * replay-safe.
7
12
  */
8
- export declare function checkpointHistoryBeforeProviderDispatch(historySink: Pick<TurnHistorySink, "reconcileConversationTruth">): Promise<void>;
13
+ export declare function checkpointHistoryBeforeProviderDispatch(historySink: Pick<TurnHistorySink, "reconcileConversationTruth">, route?: {
14
+ effectiveSandboxBackend: Settings["sandboxBackend"];
15
+ routingEnabled: boolean;
16
+ readActiveSandbox: () => Promise<{
17
+ activeSandboxId: string | null;
18
+ } | null>;
19
+ }): Promise<void>;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Person-facing copy for finite same-turn provider recovery. Presentation only:
3
+ * retry authority, pacing and the recovery budget stay in `errors.ts`.
4
+ *
5
+ * `@opengeni/react` (`lib/provider-recovery.ts`) composes the same sentences
6
+ * from the structured event fields, so live retry status and historical
7
+ * failures read identically in every surface. Keep the two in step.
8
+ */
9
+ /** Closed provider condition recorded on model-provider recovery payloads. */
10
+ export type ProviderCondition = "overloaded" | "unavailable" | "unresponsive" | "rate_limited";
11
+ /** Failure codes whose transient condition belongs to the turn's model route. */
12
+ export declare const MODEL_PROVIDER_RECOVERY_CODES: ReadonlySet<string>;
13
+ export type ProviderRecoveryCopyInput = {
14
+ code?: string | null | undefined;
15
+ providerCondition?: ProviderCondition | null | undefined;
16
+ modelLabel?: string | null | undefined;
17
+ providerLabel?: string | null | undefined;
18
+ };
19
+ /** One present-tense clause naming what is unavailable, without a trailing period. */
20
+ export declare function providerRecoverySubject(input: ProviderRecoveryCopyInput): string;
21
+ /** Terminal copy once the finite automatic recovery budget is spent. */
22
+ export declare function providerRecoveryExhaustedMessage(input: ProviderRecoveryCopyInput & {
23
+ providerRecoveryCount: number;
24
+ }): string;
@@ -0,0 +1,18 @@
1
+ import type { Observability } from "@opengeni/observability";
2
+ export type ProviderRecoveryObservation = {
3
+ startedAt: number;
4
+ cause: "rate_limited" | "unavailable" | "connectivity";
5
+ };
6
+ export declare function providerRecoveryCause(code: unknown): ProviderRecoveryObservation["cause"] | null;
7
+ export declare function readProviderRecoveryObservation(metadata: Record<string, unknown>): ProviderRecoveryObservation | undefined;
8
+ /** Operational observations only; never retry authority, billing or diagnostics. */
9
+ export declare function recordProviderRecoveryOutcome(observability: Observability, input: {
10
+ route?: {
11
+ provider: string;
12
+ model: string;
13
+ } | undefined;
14
+ cause: ProviderRecoveryObservation["cause"];
15
+ outcome: "scheduled" | "recovered" | "exhausted";
16
+ delayMs?: number;
17
+ elapsedMs?: number;
18
+ }): void;
@@ -0,0 +1,6 @@
1
+ /** Closed policy facts shared with the workflow's content-free recovery wire. */
2
+ export declare const PROVIDER_OVERLOAD_RECOVERY_CODE = "provider_overloaded";
3
+ export declare const MAX_AUTOMATIC_PROVIDER_OVERLOAD_RECOVERIES = 15;
4
+ export declare const PROVIDER_OVERLOAD_RECOVERY_WINDOW_MS: number;
5
+ export declare function validProviderOverloadRecoveryDelay(code: unknown, delay: unknown): boolean;
6
+ export declare function readProviderRecoveryStartedAt(metadata: Record<string, unknown>): number | undefined;
@@ -49,10 +49,9 @@ export declare const QUIESCENCE_PROOF_SIGNAL_INITIAL_RETRY_MS = 250;
49
49
  export declare const QUIESCENCE_PROOF_SIGNAL_MAX_RETRY_MS = 5000;
50
50
  export declare const TURN_QUIESCENCE_WATCHDOG_MS: number;
51
51
  export declare const TURN_FINALIZER_STEP_TIMEOUT_MS = 30000;
52
- /** A fenced activity must never heartbeat forever while its physical writer
53
- * drain is stuck. The last-resort worker exit stops every in-process writer;
54
- * Kubernetes replaces the pod and the workflow's heartbeat-lease reconciler
55
- * then commits the exact quiescence receipt. */
52
+ /** A fenced activity must never heartbeat forever while physical cleanup is
53
+ * stuck. The callback requests host-owned containment, which drains peer turns
54
+ * before applying its final exit policy. A timeout is never quiescence proof. */
56
55
  export declare function armTurnQuiescenceWatchdog(input: {
57
56
  enabled: boolean;
58
57
  timeoutMs?: number;
@@ -176,7 +175,7 @@ export declare class MandatoryHistoryPersistenceError extends Error {
176
175
  }
177
176
  export declare function runMandatoryHistoryPersistenceStep<T>(stage: MandatoryHistoryPersistenceStage, operation: () => Promise<T>): Promise<T>;
178
177
  export type OpStreamFinalizer = {
179
- finalizeOpStreamOps(): Promise<void>;
178
+ finalizeOpStreamOps(toolCallIds?: readonly string[]): Promise<void>;
180
179
  };
181
- /** Release retained Connected Machine output only after the turn is durable. */
182
- export declare function finalizeDurableTurnOpStreams(sessions: readonly unknown[], fallback: OpStreamFinalizer | null): Promise<void>;
180
+ /** Release only durably recorded tool results, or the complete durable turn. */
181
+ export declare function finalizeDurableTurnOpStreams(sessions: readonly unknown[], fallback: OpStreamFinalizer | null, toolCallIds?: readonly string[]): Promise<void>;
@@ -1,8 +1,9 @@
1
- import { type Database } from "@opengeni/db";
2
- /** Opt-in belongs to this warning-aware worker implementation, not the DB
3
- * client, role defaults or deployment configuration. Claim stamps it locally. */
4
- export declare const FILESYSTEM_DISCONTINUITY_PROTOCOL: 1;
1
+ import { getSandboxRecoveryDiscontinuity, type Database } from "@opengeni/db";
2
+ /** v2 also recognizes system-selected checkpoint fallback receipts, and v3
3
+ * the empty-workspace continuation receipts. A worker below the version a
4
+ * session's receipts require cannot claim it (migrations 0526 and 0548). */
5
+ export declare const FILESYSTEM_DISCONTINUITY_PROTOCOL: 3;
5
6
  export declare function recoveryAwareSessionInstructions(db: Database, workspaceId: string, session: {
6
7
  id: string;
7
8
  instructions?: string | null;
8
- }): Promise<string>;
9
+ }, readDiscontinuity?: typeof getSandboxRecoveryDiscontinuity): Promise<string>;
@@ -0,0 +1,6 @@
1
+ import type { AttemptToolDefinition } from "@opengeni/codemode";
2
+ export declare const REFRESH_CREDENTIALS_TOOL_NAME = "refresh_credentials";
3
+ export declare const REFRESH_CREDENTIALS_TOOL_DESCRIPTION = "Fetch fresh host-managed credentials for this sandbox now. Use it when a command fails because a token or credential file provided by the workspace has expired or been revoked. The environment variables and credential files that the host manages are replaced for the next command; commands that are already running keep what they started with.";
4
+ export declare function createRefreshCredentialsAttemptToolDefinition(input: {
5
+ refresh: () => Promise<"completed" | "auth_needed" | "error" | "not_provisioned">;
6
+ }): AttemptToolDefinition;
@@ -1,7 +1,8 @@
1
- import { type GitCredentialTokenWriterSession, type NormalizedRunCredentialMaterial, type RunCredentialCommandSession, type CodemodeTokenWriterSession } from "@opengeni/runtime";
1
+ import { type GitCredentialTokenWriterSession, type NormalizedRunCredentialMaterial, type RunCredentialCommandSession, type CodemodeTokenWriterSession, RunMcpCredentials } from "@opengeni/runtime";
2
2
  import { type Settings } from "@opengeni/config";
3
- import { type GitHubTokenMintAuthorization, type MintedRunGitCredentials, type loadWorkspaceEnvironmentForRunWithCredentials } from "../environment.js";
3
+ import { type GitHubTokenMintAuthorization, type MintedRunGitCredentials } from "../environment.js";
4
4
  import type { mergeResourceRefs } from "../common.js";
5
+ import type { withFirstPartyTools } from "../goals.js";
5
6
  import type { TurnActivityServices as ActivityServices, RunAgentTurnInput } from "../types.js";
6
7
  import { type ResumedTurnSandbox } from "../../sandbox-resume.js";
7
8
  import type { ClaimTurnOk } from "./claim.js";
@@ -9,6 +10,8 @@ import type { GovernanceModelOk } from "./governance-model.js";
9
10
  import type { SandboxTurnRuntime } from "./sandbox-runtime.js";
10
11
  import type { AttemptIdentityState, EventingState, RenewalState, SandboxRuntimeState } from "./turn-context.js";
11
12
  export type PrepareRunCredentialsDeps = {
13
+ localMcpServerIds?: readonly string[];
14
+ turnTools: ReturnType<typeof withFirstPartyTools>;
12
15
  input: RunAgentTurnInput;
13
16
  settings: Settings;
14
17
  db: ActivityServices["db"];
@@ -23,9 +26,9 @@ export type PrepareRunCredentialsDeps = {
23
26
  sandboxRuntime: SandboxTurnRuntime;
24
27
  turn: ClaimTurnOk["turn"];
25
28
  session: ClaimTurnOk["session"];
29
+ turnExecutionPolicy: ClaimTurnOk["turnExecutionPolicy"];
26
30
  fileAuthoritySubjectId: ClaimTurnOk["fileAuthoritySubjectId"];
27
31
  runSettings: GovernanceModelOk["runSettings"];
28
- workspaceVariableSet: Awaited<ReturnType<typeof loadWorkspaceEnvironmentForRunWithCredentials>>;
29
32
  turnResources: ReturnType<typeof mergeResourceRefs>;
30
33
  requiredGeneratedVideoFiles: Array<{
31
34
  operationId: string;
@@ -41,7 +44,6 @@ export type PrepareRunCredentialsDeps = {
41
44
  groupBoxBackend: Settings["sandboxBackend"];
42
45
  sandboxCreationBackend: Settings["sandboxBackend"];
43
46
  effectiveRunCredentialBackend: Settings["sandboxBackend"];
44
- sandboxWorkspaceEnvironmentValues: Record<string, string>;
45
47
  connectionScope: {
46
48
  accountId: string;
47
49
  workspaceId: string;
@@ -49,6 +51,7 @@ export type PrepareRunCredentialsDeps = {
49
51
  runWorkspaceMutationForSandbox: SandboxTurnRuntime["runWorkspaceMutationForSandbox"];
50
52
  };
51
53
  export declare function prepareRunCredentials(deps: PrepareRunCredentialsDeps): Promise<{
54
+ runMcpCredentials: RunMcpCredentials;
52
55
  runCredentialResolver: import("../run-credentials.js").BoundRunCredentialResolver | null;
53
56
  establishPolicy: "eager" | "on-demand";
54
57
  initialRunCredentialMaterial: NormalizedRunCredentialMaterial | null;
@@ -60,6 +63,7 @@ export declare function prepareRunCredentials(deps: PrepareRunCredentialsDeps):
60
63
  turnId: string;
61
64
  attemptId: string;
62
65
  executionGeneration: number;
66
+ credentialRestriction?: "developer_setup";
63
67
  };
64
68
  sandboxArtifactRuntime: Readonly<{
65
69
  available: boolean;
@@ -78,6 +82,6 @@ export declare function prepareRunCredentials(deps: PrepareRunCredentialsDeps):
78
82
  startRunGitCredentialsMint: () => Promise<MintedRunGitCredentials | undefined>;
79
83
  attachGitCredentialRenewal: (tokenSession: GitCredentialTokenWriterSession, initial: MintedRunGitCredentials | undefined, initialSandbox?: ResumedTurnSandbox) => Promise<void>;
80
84
  attachCodemodeTokenRenewal: (tokenSession?: CodemodeTokenWriterSession, initialExpiresAt?: Date | undefined, initialSandbox?: ResumedTurnSandbox) => Promise<void>;
81
- attachRunCredentialRenewal: (credentialSession: RunCredentialCommandSession, initialMaterial: NormalizedRunCredentialMaterial | null, initialSandbox?: ResumedTurnSandbox) => Promise<void>;
85
+ attachRunCredentialRenewal: (credentialSession: RunCredentialCommandSession | undefined, initialMaterial: NormalizedRunCredentialMaterial | null, initialSandbox?: ResumedTurnSandbox) => Promise<void>;
82
86
  }>;
83
87
  export type PrepareRunCredentialsOk = Awaited<ReturnType<typeof prepareRunCredentials>>;
@@ -1,12 +1,37 @@
1
1
  import { type CodexRequestContext } from "@opengeni/codex";
2
2
  import { type XaiSubscriptionRequestContext } from "@opengeni/xai-subscription";
3
3
  import type { TurnActivityServices as ActivityServices, RunAgentTurnInput, RunAgentTurnResult } from "../types.js";
4
+ import { createCoreCodexRequests } from "./codex-core-requests.js";
5
+ import type { CoreSubscriptionRequests } from "./subscription-core-requests.js";
4
6
  /**
5
7
  * Retain subscription credential/account authority for the title sidecar
6
8
  * without sharing main-stream recovery, startup, audit, or opaque-artifact
7
9
  * callbacks. Title usage is returned by the runtime and metered separately.
8
10
  */
9
- export declare function sessionTitleCodexRequestContext(context: CodexRequestContext, nextRequestId: () => string): CodexRequestContext;
10
- export declare function sessionTitleXaiRequestContext(context: XaiSubscriptionRequestContext, nextRequestId: () => string): XaiSubscriptionRequestContext;
11
+ export declare function sessionTitleCodexRequestContext(context: CodexRequestContext, nextRequestId: () => string, requests?: ReturnType<typeof createCoreCodexRequests>): CodexRequestContext;
12
+ /**
13
+ * The durable `agent.model.request` payload of a SuperGrok request event. It
14
+ * carries every transport field, including `meaningfulOutput` on `completed`,
15
+ * which the shared false-resumption breaker resets on.
16
+ */
17
+ export declare function xaiModelRequestEventPayload<Event extends object>(event: Event, ids: {
18
+ turnId: string;
19
+ attemptId: string;
20
+ dispatchId: string | undefined;
21
+ executionGeneration: number | null | undefined;
22
+ }): Event & {
23
+ provider: "supergrok-subscription";
24
+ } & typeof ids;
25
+ export declare function sessionTitleXaiRequestContext(context: XaiSubscriptionRequestContext, nextRequestId: () => string,
26
+ /**
27
+ * On the shared core: the turn's dispatch fence, the title custody lane and
28
+ * the title lane's bearer (which never moves the main lane's refusal fence).
29
+ */
30
+ core?: {
31
+ assertDispatch: () => Promise<void>;
32
+ requests: CoreSubscriptionRequests;
33
+ getToken: XaiSubscriptionRequestContext["getToken"];
34
+ refresh: XaiSubscriptionRequestContext["refresh"];
35
+ }): XaiSubscriptionRequestContext;
11
36
  /** Lifecycle orchestrator: claim → capacity → governance → sandbox → tools → stream. */
12
37
  export declare function createRunAgentTurnActivity(services: () => Promise<ActivityServices>): (input: RunAgentTurnInput) => Promise<RunAgentTurnResult>;
@@ -35,6 +35,7 @@ export type SandboxRouteOk = {
35
35
  machinePrimary: boolean;
36
36
  groupBoxBackend: Settings["sandboxBackend"];
37
37
  groupBoxImage: ReturnType<typeof rigProviderImageSourceImage>;
38
+ groupBoxImagePolicy: "new_creates_only";
38
39
  sandboxCreationBackend: Settings["sandboxBackend"];
39
40
  effectiveRunCredentialBackend: Settings["sandboxBackend"];
40
41
  };
@@ -48,6 +48,28 @@ export declare class SandboxDeadlineRotationError extends Error {
48
48
  export declare function turnOperationCancellationFailure(error: unknown): CancelledFailure | null;
49
49
  export declare function throwIfTurnOperationCancelled(signal: AbortSignal | undefined): void;
50
50
  export declare function waitForTurnOperation<T>(operation: Promise<T>, signal: AbortSignal | undefined, disposeLateResult: ((result: T) => Promise<void> | void) | undefined): Promise<T>;
51
+ /**
52
+ * Upper bound for joining a cancelled attempt's in-flight provider establish.
53
+ * Worker shutdown cancels activities 5s after SIGTERM and force-stops 100s
54
+ * after it; this leaves room for the remaining finalization steps.
55
+ */
56
+ export declare const PHYSICAL_SANDBOX_RESUME_DRAIN_TIMEOUT_MS = 60000;
57
+ /** Register the PHYSICAL lease acquire/provider establish promise, not the
58
+ * cancellable wrapper awaiting it. */
59
+ export declare function trackPhysicalSandboxResume<T>(inFlight: Set<Promise<unknown>>, operation: Promise<T>): Promise<T>;
60
+ /**
61
+ * Join every lease acquire/provider establish this attempt started, even after
62
+ * the turn-facing wrapper rejected on cancellation. An establish has no
63
+ * portable abort: after cancellation it still finishes its own exact cleanup
64
+ * (terminate an unpublished box and roll warming back to cold, or keep a
65
+ * published box and drop its holder). If the activity returned first, a
66
+ * shutting-down worker exited mid-cleanup and stranded a warming lease naming a
67
+ * terminated box; the replacement attempt then waited out the warming TTL and
68
+ * inherited a lost-workspace verdict. This wait is deliberately independent of
69
+ * the finalizer cancellation signal (cancellation is what started it) and is
70
+ * bounded so an uncooperative provider call cannot pin the activity.
71
+ */
72
+ export declare function drainPhysicalSandboxResumes(inFlight: Set<Promise<unknown>>, timeoutMs?: number): Promise<"none" | "settled" | "timed_out">;
51
73
  export declare function sleep(ms: number): Promise<void>;
52
74
  export declare function sandboxProvisionErrorChain(error: unknown): unknown[];
53
75
  export declare function firstProvisionError<T>(chain: readonly unknown[], constructor: abstract new (...args: never[]) => T): T | null;
@@ -81,8 +103,10 @@ export declare function createTurnSandboxProvisioner<T>(establish: () => Promise
81
103
  * - legacy/built-in OpenAI or Azure Responses fallback (resolvedModel null);
82
104
  * - resolved built-in OpenAI/Azure providers;
83
105
  * - ChatGPT/Codex subscription backend (its strict allowlist permits the field).
106
+ * - native Anthropic Messages (maps the internal key to Claude session identity;
107
+ * the OpenAI field is never sent on that wire).
84
108
  *
85
- * Registry API-key providers are intentionally excluded. Fireworks' prompt-cache
109
+ * Other registry API-key providers are intentionally excluded. Fireworks' prompt-cache
86
110
  * docs prescribe `user` or `x-session-affinity`, not `prompt_cache_key`; Z.AI/GLM
87
111
  * documents automatic context caching plus `user_id`. Sending OpenAI-only fields
88
112
  * to unknown OpenAI-compatible providers risks unsupported-parameter 400s.
@@ -60,6 +60,9 @@ export declare function shouldPrefetchManagedSandbox(input: {
60
60
  machinePrimary: boolean;
61
61
  groupBoxBackend: Settings["sandboxBackend"];
62
62
  hasRepositoryResources: boolean;
63
+ /** A committed automatic post-loss recovery decision still awaits its box.
64
+ * Rematerialize now instead of leaving the group pinned until a tool call. */
65
+ automaticRecoveryPending?: boolean;
63
66
  }): boolean;
64
67
  /**
65
68
  * Classify a persisted active-sandbox pointer for TURN-START RECONCILE (issue #341
@@ -36,7 +36,7 @@ export declare function preemptSandboxTurnForDeadlineRotation(input: {
36
36
  export declare function createSandboxTurnRuntime(deps: SandboxTurnRuntimeDeps): {
37
37
  releaseLateSandbox: (sandbox: ResumedTurnSandbox) => Promise<void>;
38
38
  requireResolvedSandboxForMutation: (message: string) => ResumedTurnSandbox;
39
- finalizeTurnOpStreamOps: () => Promise<void>;
39
+ finalizeTurnOpStreamOps: (toolCallIds?: readonly string[]) => Promise<void>;
40
40
  onHomeSandboxRebound: (rebound: {
41
41
  established: EstablishedSandboxSession;
42
42
  leaseEpoch: number;
@@ -0,0 +1,64 @@
1
+ /**
2
+ * The attempt's secret resolver: `{{secret:…}}` references in tool calls
3
+ * resolve with this exact live attempt's vault reach (§10B.2). With the
4
+ * `secrets` capability off the resolver is disabled and every surface passes
5
+ * references through literally (AG-4).
6
+ */
7
+ import { type Settings } from "@opengeni/config";
8
+ import { type ResolvedAgentConfig, type SecretResolver } from "@opengeni/contracts";
9
+ import { type OnePasswordVaultProviderFactory } from "@opengeni/core";
10
+ import { type Database } from "@opengeni/db";
11
+ import { type ProviderCallBudget, type VaultProvider, type VaultProviderRegistry } from "@opengeni/vaults";
12
+ /**
13
+ * Q-17: a frozen configuration without the key reads `from === "all"` (the
14
+ * contracts parse fills it); legacy null-config sessions get secrets on.
15
+ */
16
+ export declare function secretsCapabilityEnabled(agentConfig: ResolvedAgentConfig | null | undefined): boolean;
17
+ /**
18
+ * Connected-vault access for one attempt: the provider registry (1Password
19
+ * tokens load for the acting human, host vaults use the embedder port) and a
20
+ * single read budget shared by every resolver of the attempt (Q-18).
21
+ */
22
+ export type AttemptVaultAccess = {
23
+ providers: VaultProviderRegistry;
24
+ attemptBudget: ProviderCallBudget;
25
+ };
26
+ export declare function createAttemptVaultAccess(input: {
27
+ db: Database;
28
+ settings: Settings;
29
+ workspaceId: string;
30
+ subjectId: string | null;
31
+ hostVaultProvider: VaultProvider | null | undefined;
32
+ onePasswordVaultProvider: OnePasswordVaultProviderFactory | null | undefined;
33
+ }): AttemptVaultAccess;
34
+ type AttemptSecretInput = {
35
+ db: Database;
36
+ settings: Settings;
37
+ agentConfig: ResolvedAgentConfig | null | undefined;
38
+ vaultAccess?: AttemptVaultAccess | undefined;
39
+ accountId: string;
40
+ workspaceId: string;
41
+ sessionId: string;
42
+ turnId: string;
43
+ attemptId: string;
44
+ executionGeneration: number;
45
+ };
46
+ export declare function attemptSecretResolver(input: AttemptSecretInput): SecretResolver;
47
+ /**
48
+ * Ask-card vault check (Q-05): a named vault must be reachable by this
49
+ * attempt, belong to the chosen saveTo scope, and be a writable Opengeni vault.
50
+ * Returns a model-facing reason, or null when the vault can take the answer.
51
+ */
52
+ export declare function attemptQuestionVaultValidator(input: Omit<AttemptSecretInput, "settings" | "agentConfig" | "vaultAccess">): ({ vault, saveTo, }: {
53
+ vault: string;
54
+ saveTo: "user" | "task" | "workspace";
55
+ }) => Promise<string | null>;
56
+ /**
57
+ * Exec-boundary resolver (W1 delivery). Same attempt principal and capability
58
+ * gate as every other surface; kept as a named entry point for the sandbox
59
+ * tool wiring in agent-build.
60
+ */
61
+ export declare function createAttemptSecretResolver(input: Omit<AttemptSecretInput, "agentConfig"> & {
62
+ agent: ResolvedAgentConfig | null | undefined;
63
+ }): SecretResolver;
64
+ export {};