@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,11 +1,22 @@
1
1
  import { hasPermission } from "@opengeni/core";
2
2
  import type { AttemptToolDefinition } from "@opengeni/codemode";
3
- import type { GeneratedSessionTitle } from "@opengeni/runtime";
3
+ import {
4
+ claudeNativeModelProfile,
5
+ isManagedOpenRouterFreeRoute,
6
+ type ModelCapabilitiesV1,
7
+ } from "@opengeni/config";
8
+ import type {
9
+ GeneratedSessionTitle,
10
+ GenerateSessionTitleOptions,
11
+ OpenGeniRuntime,
12
+ } from "@opengeni/runtime";
4
13
  import {
5
14
  AUTOMATIC_SESSION_TITLE_FALLBACK,
6
15
  DEFAULT_FIRST_PARTY_MCP_PERMISSIONS,
16
+ ReasoningEffort,
7
17
  type FirstPartyMcpToolName,
8
18
  type Permission,
19
+ type ResolvedAgentConfig,
9
20
  type ToolRef,
10
21
  } from "@opengeni/contracts";
11
22
 
@@ -17,6 +28,7 @@ const SESSION_TITLE_DESCRIPTION =
17
28
  export function shouldRequestMissingSessionTitle(input: {
18
29
  title: string | null;
19
30
  titleSource: "user" | "agent" | null;
31
+ agentConfig?: ResolvedAgentConfig | null;
20
32
  firstPartyMcpTools: readonly FirstPartyMcpToolName[];
21
33
  firstPartyMcpPermissions: readonly Permission[] | null;
22
34
  }): boolean {
@@ -24,16 +36,34 @@ export function shouldRequestMissingSessionTitle(input: {
24
36
  const needsSemanticTitle =
25
37
  input.titleSource !== "user" && (!title || title === AUTOMATIC_SESSION_TITLE_FALLBACK);
26
38
  if (!needsSemanticTitle) return false;
27
- if (!input.firstPartyMcpTools.includes("set_session_title")) return false;
39
+ // Configured sessions title through the runtime, not an opted-in capability.
40
+ // Legacy sessions keep their exact selected-tool and permission admission.
41
+ if (!input.agentConfig && !input.firstPartyMcpTools.includes("set_session_title")) return false;
28
42
  const permissions = input.firstPartyMcpPermissions ?? DEFAULT_FIRST_PARTY_MCP_PERMISSIONS;
29
43
  return hasPermission([...permissions], "sessions:control");
30
44
  }
31
45
 
46
+ /**
47
+ * Whether the turn's route can afford a model request spent only on a title.
48
+ * The managed OpenRouter free route draws on one deployment-wide per-minute
49
+ * and per-day request quota that users' turns need, so an untitled session on
50
+ * it gets no title sidecar and no title tool (whose call would cost a
51
+ * follow-up request). Clients keep showing the prompt preview, and a later
52
+ * turn on another route titles the session.
53
+ */
54
+ export function routeAllowsSessionTitleRequests(
55
+ resolvedModel: ReturnType<OpenGeniRuntime["resolveTurnModel"]>,
56
+ ): boolean {
57
+ return !resolvedModel || !isManagedOpenRouterFreeRoute(resolvedModel);
58
+ }
59
+
32
60
  export function sessionTitleToolPlan(input: {
33
61
  tools: readonly ToolRef[];
62
+ agentConfig?: ResolvedAgentConfig | null;
34
63
  selectedFirstPartyMcpTools: readonly FirstPartyMcpToolName[];
35
64
  shouldRequestTitle: boolean;
36
65
  parallelGenerationAvailable: boolean;
66
+ routeAllowsTitleRequests: boolean;
37
67
  }): {
38
68
  promoteTitleTool: boolean;
39
69
  generateTitleInParallel: boolean;
@@ -42,9 +72,11 @@ export function sessionTitleToolPlan(input: {
42
72
  } {
43
73
  const titleToolAvailable =
44
74
  input.shouldRequestTitle &&
45
- input.tools.some((tool) => tool.kind === "mcp" && tool.id === "opengeni");
46
- const generateTitleInParallel = titleToolAvailable && input.parallelGenerationAvailable;
47
- const promoteTitleTool = titleToolAvailable && !generateTitleInParallel;
75
+ (input.agentConfig != null ||
76
+ input.tools.some((tool) => tool.kind === "mcp" && tool.id === "opengeni"));
77
+ const titleRequestAllowed = titleToolAvailable && input.routeAllowsTitleRequests;
78
+ const generateTitleInParallel = titleRequestAllowed && input.parallelGenerationAvailable;
79
+ const promoteTitleTool = titleRequestAllowed && !generateTitleInParallel;
48
80
  return {
49
81
  promoteTitleTool,
50
82
  generateTitleInParallel,
@@ -57,6 +89,130 @@ export function sessionTitleToolPlan(input: {
57
89
 
58
90
  export const PARALLEL_SESSION_TITLE_TIMEOUT_MS = 15_000;
59
91
 
92
+ /** Codex subscription turns title on this fast model of the same account. */
93
+ export const CODEX_SESSION_TITLE_MODEL_ID = "codex/gpt-6-luna";
94
+ /** Claude subscription turns title on this fast model of the same account. */
95
+ export const CLAUDE_SESSION_TITLE_UPSTREAM_MODEL_ID = "claude-haiku-5-5";
96
+
97
+ type ResolvedTitleModel = NonNullable<ReturnType<OpenGeniRuntime["resolveTurnModel"]>>;
98
+
99
+ export type SessionTitleRoute = {
100
+ resolvedModel: ReturnType<OpenGeniRuntime["resolveTurnModel"]>;
101
+ /** Upstream model name sent to the provider. */
102
+ modelName: string;
103
+ /** Product model id the title usage is recorded under, when it differs from the turn's. */
104
+ usageModelId: string | null;
105
+ };
106
+
107
+ /**
108
+ * The model for the auxiliary title request. A subscription turn titles on a
109
+ * fast model of the same subscription account and request context, so the
110
+ * title costs the subscription little and never another rail: Codex turns use
111
+ * Luna and Claude subscription turns use Haiku. Other turns, and a
112
+ * subscription whose catalog lacks the title model, title on the turn's model.
113
+ */
114
+ export function sessionTitleRoute(input: {
115
+ resolvedModel: ReturnType<OpenGeniRuntime["resolveTurnModel"]>;
116
+ modelName: string;
117
+ resolveTurnModel: (modelId: string) => ReturnType<OpenGeniRuntime["resolveTurnModel"]>;
118
+ }): SessionTitleRoute {
119
+ const turnRoute = {
120
+ resolvedModel: input.resolvedModel,
121
+ modelName: input.modelName,
122
+ usageModelId: null,
123
+ };
124
+ const turn = input.resolvedModel;
125
+ if (!turn) return turnRoute;
126
+ const sameAccount = (title: ResolvedTitleModel): SessionTitleRoute => ({
127
+ // The turn's client and provider carry its account and credential binding.
128
+ resolvedModel: { ...title, client: turn.client, provider: turn.provider },
129
+ modelName: title.configured.upstreamModelId,
130
+ usageModelId: title.configured.id,
131
+ });
132
+ if (turn.provider.kind === "codex-subscription") {
133
+ if (turn.configured.id === CODEX_SESSION_TITLE_MODEL_ID) return turnRoute;
134
+ const title = input.resolveTurnModel(CODEX_SESSION_TITLE_MODEL_ID);
135
+ return title && title.provider.id === turn.provider.id ? sameAccount(title) : turnRoute;
136
+ }
137
+ if (turn.provider.kind?.startsWith("claude-subscription-")) {
138
+ if (turn.configured.upstreamModelId === CLAUDE_SESSION_TITLE_UPSTREAM_MODEL_ID)
139
+ return turnRoute;
140
+ const titleModelId = `${turn.provider.id}/${CLAUDE_SESSION_TITLE_UPSTREAM_MODEL_ID}`;
141
+ const listed = input.resolveTurnModel(titleModelId);
142
+ if (listed && listed.provider.id === turn.provider.id) return sameAccount(listed);
143
+ // Every Claude subscription can serve Haiku even when the connection's
144
+ // picker list omits it; the native profile supplies its reasoning range.
145
+ const profile = claudeNativeModelProfile(CLAUDE_SESSION_TITLE_UPSTREAM_MODEL_ID);
146
+ if (!profile) return turnRoute;
147
+ return sameAccount({
148
+ ...turn,
149
+ configured: {
150
+ ...turn.configured,
151
+ id: titleModelId,
152
+ upstreamModelId: CLAUDE_SESSION_TITLE_UPSTREAM_MODEL_ID,
153
+ capabilities: {
154
+ ...turn.configured.capabilities,
155
+ reasoning: {
156
+ ...turn.configured.capabilities.reasoning,
157
+ runnable: profile.efforts.length > 0,
158
+ efforts: [...profile.efforts],
159
+ defaultEffort: profile.defaultEffort,
160
+ },
161
+ },
162
+ },
163
+ });
164
+ }
165
+ return turnRoute;
166
+ }
167
+
168
+ /**
169
+ * The lowest reasoning effort the resolved model can run, for the auxiliary
170
+ * title request only. A title needs no deliberation, and a provider default
171
+ * effort can use most of the output budget before any visible text. Returns
172
+ * undefined when the model declares no runnable reasoning control, so the
173
+ * request carries no reasoning parameter.
174
+ */
175
+ export function sessionTitleReasoningEffort(
176
+ capabilities: Pick<ModelCapabilitiesV1, "reasoning"> | undefined,
177
+ ): ReasoningEffort | undefined {
178
+ const reasoning = capabilities?.reasoning;
179
+ if (!reasoning?.runnable) return undefined;
180
+ const order = ReasoningEffort.options;
181
+ let lowest: ReasoningEffort | undefined;
182
+ for (const effort of reasoning.efforts) {
183
+ if (!lowest || order.indexOf(effort) < order.indexOf(lowest)) lowest = effort;
184
+ }
185
+ return lowest;
186
+ }
187
+
188
+ /**
189
+ * Options for the parallel title request. It uses the turn's resolved
190
+ * provider and credential authority, but its own lowest runnable reasoning
191
+ * effort rather than the turn's effort.
192
+ */
193
+ export function sessionTitleGenerationOptions(input: {
194
+ resolvedModel: ReturnType<OpenGeniRuntime["resolveTurnModel"]>;
195
+ modelName: string;
196
+ serviceTier: GenerateSessionTitleOptions["serviceTier"] | null | undefined;
197
+ signal: AbortSignal;
198
+ }): GenerateSessionTitleOptions {
199
+ const { resolvedModel, serviceTier } = input;
200
+ const reasoningEffort = sessionTitleReasoningEffort(resolvedModel?.configured.capabilities);
201
+ return {
202
+ ...(resolvedModel
203
+ ? {
204
+ client: resolvedModel.client,
205
+ provider: resolvedModel.provider,
206
+ model: resolvedModel.model,
207
+ }
208
+ : {}),
209
+ modelName: input.modelName,
210
+ ...(serviceTier ? { serviceTier } : {}),
211
+ ...(reasoningEffort ? { reasoningEffort } : {}),
212
+ signal: input.signal,
213
+ };
214
+ }
215
+
60
216
  export type ParallelSessionTitleGeneration = {
61
217
  finish: () => Promise<GeneratedSessionTitle | null>;
62
218
  cancel: () => Promise<void>;
@@ -67,13 +223,15 @@ export type ParallelSessionTitleGeneration = {
67
223
  * stream. finish() waits for the already-running bounded request, so a quick
68
224
  * main response does not discard a valid title merely because it completed
69
225
  * first. cancel() aborts and joins exceptional/cancelled exits so no provider
70
- * work escapes the owning runAgentTurn activity.
226
+ * work escapes the owning runAgentTurn activity. Both exits settle an already
227
+ * completed result before returning, including its separate request custody.
71
228
  */
72
229
  export function startParallelSessionTitleGeneration(input: {
73
230
  generate: (signal: AbortSignal) => Promise<GeneratedSessionTitle>;
74
231
  signal?: AbortSignal;
75
232
  timeoutMs?: number;
76
233
  onError?: (error: unknown) => void;
234
+ onFinish?: (result: GeneratedSessionTitle | null) => Promise<void>;
77
235
  }): ParallelSessionTitleGeneration {
78
236
  const cancellationController = new AbortController();
79
237
  const timeoutSignal = AbortSignal.timeout(input.timeoutMs ?? PARALLEL_SESSION_TITLE_TIMEOUT_MS);
@@ -89,15 +247,22 @@ export function startParallelSessionTitleGeneration(input: {
89
247
  });
90
248
  let finished: Promise<GeneratedSessionTitle | null> | null = null;
91
249
 
250
+ const finish = (): Promise<GeneratedSessionTitle | null> => {
251
+ finished ??= generation.then(async (result) => {
252
+ await input.onFinish?.(result);
253
+ return result;
254
+ });
255
+ return finished;
256
+ };
257
+
92
258
  return {
93
- finish: () => {
94
- if (finished) return finished;
95
- finished = generation;
96
- return finished;
97
- },
259
+ finish,
98
260
  cancel: async () => {
261
+ // Let an already-resolved generation deliver its queued result before
262
+ // aborting. A request still pending at this boundary remains cancelled.
263
+ await Promise.resolve();
99
264
  cancellationController.abort();
100
- await generation;
265
+ await finish();
101
266
  },
102
267
  };
103
268
  }
@@ -0,0 +1,170 @@
1
+ import type { HeldSessionUsageReceipt } from "@opengeni/core";
2
+ import { settleSessionUsageReceipt, SessionUsageLimitUnavailableError } from "@opengeni/db";
3
+ import type { TurnActivityServices as ActivityServices } from "../types";
4
+
5
+ /**
6
+ * Attempt-scoped custody for per-task usage receipts whose write failed after
7
+ * the provider response was received.
8
+ *
9
+ * The response is never lost or re-requested because of an accounting
10
+ * failure: settlement hands the content-free receipt here (original source
11
+ * identity, amount, pricing source) and the turn keeps the response. Before
12
+ * the next model request (every admission check) and before the turn
13
+ * completes, held receipts are written; if that still fails, the attempt
14
+ * stops for the workflow's DB-only recovery lane and carries the held
15
+ * receipts in its typed failure detail (durable in workflow history), which
16
+ * the lane writes before any replacement attempt. Writes are idempotent per
17
+ * source identity, so overlapping writers (the `agent.model.usage` event
18
+ * meter, a later flush and the recovery lane) record the call once.
19
+ */
20
+
21
+ type Scope = { accountId: string; workspaceId: string };
22
+ type Entry = Scope & { receipts: Map<string, HeldSessionUsageReceipt> };
23
+
24
+ /** Bound on receipts carried through one recovery failure detail. */
25
+ export const MAX_RECOVERY_SESSION_USAGE_RECEIPTS = 64;
26
+ const MAX_HELD_SESSIONS = 4096;
27
+ const FLUSH_DELAYS_MS = [0, 250, 1_000];
28
+
29
+ const held = new Map<string, Entry>();
30
+
31
+ /** Recovery reason and detail code for a task whose earlier single-call receipt is still owed. */
32
+ export const SESSION_USAGE_CUSTODY_PENDING = "session_usage_custody_pending";
33
+ /**
34
+ * How long a parked turn waits before its replacement attempt re-checks
35
+ * admission (database reads only). An owner fills its receipt within
36
+ * seconds; a dead owner's marker is disclosed by maintenance after 30
37
+ * minutes, so a task waits at most about 60 rechecks.
38
+ */
39
+ export const SESSION_USAGE_CUSTODY_RECHECK_MS = 30_000;
40
+
41
+ /** A fenced or overdue custody marker (not a database outage) refused the next model request. */
42
+ export function sessionUsageCustodyPending(error: unknown): boolean {
43
+ let current = error;
44
+ for (let depth = 0; depth < 6 && current && typeof current === "object"; depth += 1) {
45
+ if (current instanceof SessionUsageLimitUnavailableError) {
46
+ return current.reason === "custody_pending";
47
+ }
48
+ current = (current as { cause?: unknown }).cause;
49
+ }
50
+ return false;
51
+ }
52
+
53
+ export function holdSessionUsageReceipt(scope: Scope, receipt: HeldSessionUsageReceipt): void {
54
+ let entry = held.get(receipt.sessionId);
55
+ if (!entry) {
56
+ if (held.size >= MAX_HELD_SESSIONS) {
57
+ // Oldest sessions only: their receipts already travelled with a
58
+ // recovery failure or will be re-imported from durable usage events.
59
+ const oldest = held.keys().next().value;
60
+ if (oldest !== undefined) held.delete(oldest);
61
+ }
62
+ entry = { accountId: scope.accountId, workspaceId: scope.workspaceId, receipts: new Map() };
63
+ held.set(receipt.sessionId, entry);
64
+ }
65
+ entry.receipts.set(receipt.sourceId, receipt);
66
+ }
67
+
68
+ /** Held receipts for one turn, bounded, for a post-claim recovery failure detail. */
69
+ export function heldSessionUsageReceiptsForTurn(turnId: string): HeldSessionUsageReceipt[] {
70
+ const receipts: HeldSessionUsageReceipt[] = [];
71
+ for (const entry of held.values()) {
72
+ for (const receipt of entry.receipts.values()) {
73
+ if (receipt.turnId === turnId) receipts.push(receipt);
74
+ if (receipts.length >= MAX_RECOVERY_SESSION_USAGE_RECEIPTS) return receipts;
75
+ }
76
+ }
77
+ return receipts;
78
+ }
79
+
80
+ export function heldSessionUsageReceiptCount(sessionId?: string): number {
81
+ if (sessionId !== undefined) return held.get(sessionId)?.receipts.size ?? 0;
82
+ let count = 0;
83
+ for (const entry of held.values()) count += entry.receipts.size;
84
+ return count;
85
+ }
86
+
87
+ /**
88
+ * The `agent.model.usage` event for a held receipt committed. Its appending
89
+ * transaction meters the same source identity through the database trigger
90
+ * (or, for a root still preparing, leaves the event for the bounded import),
91
+ * and a trigger failure would have rolled the event back. When the event
92
+ * carries exactly the held amount, the receipt is therefore durable and the
93
+ * hold is dropped, so completion does not stop for a write that is already
94
+ * done. A different or unknown event amount keeps the hold: only the direct
95
+ * write can record (or fill) that value.
96
+ */
97
+ export function releaseHeldSessionUsageReceiptMeteredByEvent(input: {
98
+ sessionId: string;
99
+ sourceId: string;
100
+ amountMicros: number | null;
101
+ pricingSource: string | null;
102
+ }): boolean {
103
+ const entry = held.get(input.sessionId);
104
+ const receipt = entry?.receipts.get(input.sourceId);
105
+ if (!entry || !receipt) return false;
106
+ if (receipt.amountMicros !== input.amountMicros) return false;
107
+ if (receipt.amountMicros !== null && receipt.pricingSource !== input.pricingSource) return false;
108
+ entry.receipts.delete(input.sourceId);
109
+ if (entry.receipts.size === 0 && held.get(input.sessionId) === entry) {
110
+ held.delete(input.sessionId);
111
+ }
112
+ return true;
113
+ }
114
+
115
+ /** Write receipts with their original identities; throws the last database error. */
116
+ export async function writeSessionUsageReceipts(
117
+ db: ActivityServices["db"],
118
+ scope: Scope,
119
+ receipts: readonly HeldSessionUsageReceipt[],
120
+ ): Promise<void> {
121
+ for (const receipt of receipts) {
122
+ await settleSessionUsageReceipt(db, {
123
+ accountId: scope.accountId,
124
+ workspaceId: scope.workspaceId,
125
+ sessionId: receipt.sessionId,
126
+ sourceId: receipt.sourceId,
127
+ turnId: receipt.turnId,
128
+ amountMicros: receipt.amountMicros,
129
+ pricingSource: receipt.amountMicros === null ? null : receipt.pricingSource,
130
+ model: receipt.model,
131
+ });
132
+ }
133
+ }
134
+
135
+ /**
136
+ * Write every receipt held for this session before another model request or
137
+ * turn completion. Retries briefly; a persistent failure rethrows the
138
+ * database error so the attempt enters post-claim DB recovery with the
139
+ * receipts still held for its failure detail.
140
+ */
141
+ export async function flushHeldSessionUsageReceipts(
142
+ db: ActivityServices["db"],
143
+ sessionId: string,
144
+ ): Promise<void> {
145
+ const entry = held.get(sessionId);
146
+ if (!entry || entry.receipts.size === 0) return;
147
+ let lastError: unknown;
148
+ for (const delay of FLUSH_DELAYS_MS) {
149
+ if (delay > 0) await new Promise((resolve) => setTimeout(resolve, delay));
150
+ try {
151
+ // A parallel call (session title) may hold another receipt meanwhile.
152
+ while (entry.receipts.size > 0) {
153
+ for (const [sourceId, receipt] of [...entry.receipts]) {
154
+ await writeSessionUsageReceipts(db, entry, [receipt]);
155
+ entry.receipts.delete(sourceId);
156
+ }
157
+ }
158
+ if (entry.receipts.size === 0 && held.get(sessionId) === entry) held.delete(sessionId);
159
+ return;
160
+ } catch (error) {
161
+ lastError = error;
162
+ }
163
+ }
164
+ throw lastError;
165
+ }
166
+
167
+ /** Test-only reset of process custody. */
168
+ export function resetSessionUsageReceiptCustodyForTests(): void {
169
+ held.clear();
170
+ }
@@ -1,10 +1,28 @@
1
1
  import type { AttemptToolDefinition } from "@opengeni/codemode";
2
- import type { SandboxChannelAService } from "@opengeni/runtime/sandbox";
3
- import type { SkillTextFile } from "@opengeni/runtime/skill-library";
4
- import { checkoutSkillDirectory, readSkillDirectory } from "./skill-transfer";
2
+ import { SKILL_READ_MAX_PATHS, type SkillTextFile } from "@opengeni/runtime/skill-library";
3
+ import { checkoutSkillDirectory, readSkillDirectory, type SkillFileSystem } from "./skill-transfer";
5
4
  import type { SkillSaveReceipt, SkillSaveRequest } from "./skill-save";
6
5
 
7
- type SkillFileSystem = Pick<SandboxChannelAService, "fsList" | "fsRead" | "fsWrite" | "fsMkdir">;
6
+ export type SkillCheckoutOutcome = "written" | "unchanged" | "refused" | "failed";
7
+
8
+ /**
9
+ * Content-free timing of one skill_checkout call. `resolve` covers authority
10
+ * and the Skill read, `sandbox` acquiring the turn's filesystem handle, and
11
+ * `write` the batched filesystem write. On a lazily provisioned turn whose
12
+ * first sandbox use is this checkout, acquiring the handle starts the box, so
13
+ * box start is inside `sandbox`. A phase that did not run is null.
14
+ */
15
+ export type SkillCheckoutObservation = Readonly<{
16
+ outcome: SkillCheckoutOutcome;
17
+ selection: "all" | "paths";
18
+ files: number;
19
+ written: number;
20
+ unchanged: number;
21
+ resolveSeconds: number | null;
22
+ sandboxSeconds: number | null;
23
+ writeSeconds: number | null;
24
+ totalSeconds: number;
25
+ }>;
8
26
 
9
27
  export function createSkillCheckoutAttemptToolDefinition(input: {
10
28
  authorize: () => Promise<void>;
@@ -14,7 +32,9 @@ export function createSkillCheckoutAttemptToolDefinition(input: {
14
32
  scopeVersion: number | null;
15
33
  files: readonly SkillTextFile[];
16
34
  }>;
17
- filesystem: () => Promise<SkillFileSystem>;
35
+ filesystem: () => Promise<Pick<SkillFileSystem, "fsWriteFiles">>;
36
+ /** Telemetry only; a failure here never changes the result. */
37
+ observe?: (observation: SkillCheckoutObservation) => void;
18
38
  }): AttemptToolDefinition {
19
39
  return {
20
40
  identity: { serverId: "opengeni", toolName: "skill_checkout" },
@@ -22,12 +42,19 @@ export function createSkillCheckoutAttemptToolDefinition(input: {
22
42
  codemodePath: ["opengeni", "skill_checkout"],
23
43
  title: "Check out Skill files",
24
44
  description:
25
- "Copy a Skill to a fresh sandbox-relative directory for execution or larger edits. Starts the sandbox if needed. Never overwrites an existing directory and does not publish changes. Retain the returned revision and scope version for skill_publish. Use skill_read for ordinary reading without a sandbox.",
45
+ "Copy Skill files into a sandbox-relative directory to run scripts or make larger edits. Starts the sandbox if needed. Writes all missing files in one step and never overwrites: files that already hold the same content are kept, and a different existing file fails the call, so repeating a checkout into the same directory is fast. Pass paths to copy only those files, for example one script to run. Only a complete copy that creates a new directory returns revisionId and scopeVersion for skill_publish. Does not publish changes. Use skill_read for reading without a sandbox.",
26
46
  inputSchema: {
27
47
  type: "object",
28
48
  properties: {
29
49
  skill: { type: "string", minLength: 1, maxLength: 512 },
30
50
  directory: { type: "string", minLength: 1, maxLength: 1024 },
51
+ paths: {
52
+ type: "array",
53
+ minItems: 1,
54
+ maxItems: SKILL_READ_MAX_PATHS,
55
+ uniqueItems: true,
56
+ items: { type: "string", minLength: 1, maxLength: 1024 },
57
+ },
31
58
  },
32
59
  required: ["skill", "directory"],
33
60
  additionalProperties: false,
@@ -35,37 +62,97 @@ export function createSkillCheckoutAttemptToolDefinition(input: {
35
62
  annotations: {
36
63
  readOnlyHint: false,
37
64
  destructiveHint: false,
38
- idempotentHint: false,
65
+ idempotentHint: true,
39
66
  openWorldHint: false,
40
67
  },
41
68
  source: "opengeni",
42
69
  approval: "none",
43
70
  execute: async (args) => {
44
- await input.authorize();
45
- const skill = await input.load(args.skill as string);
46
- const copied = await checkoutSkillDirectory(
47
- await input.filesystem(),
48
- args.directory as string,
49
- skill.files,
50
- );
51
- const output = {
52
- ...copied,
53
- skillId: skill.skillId,
54
- revisionId: skill.revisionId,
55
- scopeVersion: skill.scopeVersion,
71
+ if (
72
+ typeof args.skill !== "string" ||
73
+ typeof args.directory !== "string" ||
74
+ (args.paths !== undefined &&
75
+ (!Array.isArray(args.paths) || args.paths.some((path) => typeof path !== "string")))
76
+ ) {
77
+ throw new Error(
78
+ "skill_checkout requires a Skill, a directory, and optional relative paths.",
79
+ );
80
+ }
81
+ const paths = args.paths as string[] | undefined;
82
+ const started = performance.now();
83
+ const phases: { resolve: number | null; sandbox: number | null; write: number | null } = {
84
+ resolve: null,
85
+ sandbox: null,
86
+ write: null,
56
87
  };
57
- return {
58
- isError: false,
59
- content: [{ type: "text", text: JSON.stringify(output) }],
60
- structuredContent: output,
88
+ const timed = async <T>(phase: keyof typeof phases, run: () => Promise<T>): Promise<T> => {
89
+ const phaseStarted = performance.now();
90
+ try {
91
+ return await run();
92
+ } finally {
93
+ phases[phase] = (performance.now() - phaseStarted) / 1_000;
94
+ }
61
95
  };
96
+ let copied: Awaited<ReturnType<typeof checkoutSkillDirectory>> | undefined;
97
+ let outcome: SkillCheckoutOutcome = "refused";
98
+ try {
99
+ const skill = await timed("resolve", async () => {
100
+ await input.authorize();
101
+ return input.load(args.skill as string);
102
+ });
103
+ outcome = "failed";
104
+ const filesystem = await timed("sandbox", input.filesystem);
105
+ copied = await timed("write", () =>
106
+ checkoutSkillDirectory(
107
+ filesystem,
108
+ args.directory as string,
109
+ skill.files,
110
+ paths ? { paths } : {},
111
+ ),
112
+ );
113
+ outcome = copied.written > 0 ? "written" : "unchanged";
114
+ // Only a complete copy into a directory this call created mirrors the
115
+ // revision exactly, so only it may serve as a skill_publish base.
116
+ const publishable = !paths && copied.createdDirectory;
117
+ const output = {
118
+ directory: copied.directory,
119
+ fileCount: copied.fileCount,
120
+ written: copied.written,
121
+ unchanged: copied.unchanged,
122
+ skillId: skill.skillId,
123
+ ...(publishable
124
+ ? { revisionId: skill.revisionId, scopeVersion: skill.scopeVersion }
125
+ : { publishable: false }),
126
+ };
127
+ return {
128
+ isError: false,
129
+ content: [{ type: "text", text: JSON.stringify(output) }],
130
+ structuredContent: output,
131
+ };
132
+ } finally {
133
+ try {
134
+ input.observe?.({
135
+ outcome,
136
+ selection: paths ? "paths" : "all",
137
+ files: copied?.fileCount ?? 0,
138
+ written: copied?.written ?? 0,
139
+ unchanged: copied?.unchanged ?? 0,
140
+ resolveSeconds: phases.resolve,
141
+ sandboxSeconds: phases.sandbox,
142
+ writeSeconds: phases.write,
143
+ totalSeconds: (performance.now() - started) / 1_000,
144
+ });
145
+ } catch {
146
+ // Telemetry is best effort.
147
+ }
148
+ }
62
149
  },
63
150
  };
64
151
  }
65
152
 
66
153
  export function createSkillPublishAttemptToolDefinition(input: {
67
154
  authorize: () => Promise<void>;
68
- filesystem: () => Promise<SkillFileSystem>;
155
+ filesystem: () => Promise<Pick<SkillFileSystem, "fsList" | "fsRead">>;
69
156
  save: (request: SkillSaveRequest) => Promise<SkillSaveReceipt>;
70
157
  }): AttemptToolDefinition {
71
158
  return {
@@ -17,7 +17,7 @@ export function createSkillInstallAttemptToolDefinition(input: {
17
17
  codemodePath: ["opengeni", "skill_install"],
18
18
  title: "Install a Skill",
19
19
  description:
20
- "Install a Skill from a public skills.sh or GitHub URL, or library:<id> returned by skill_search. The server resolves and pins the source; no prior preview or invented hash is required. The effective Skills setting governs agent installation: Automatic publishes, Review first leaves a pending change in Knowledge > Needs review while the task continues, and Off prevents agent installation. Human installation from the UI remains available. Do not ask an approval question for a pending receipt. Replacing an existing installation requires its current installation version, and preserves workspace customizations.",
20
+ "Install a Skill from a public skills.sh or GitHub URL, such as a public skill_search result, or a curated Opengeni library entry as library:<id>. The server resolves and pins the source; no prior preview or invented hash is required. The effective Skills setting governs agent installation: Automatic publishes, Review first leaves a pending change in Knowledge > Needs review while the task continues, and Off prevents agent installation. Human installation from the UI remains available. Do not ask an approval question for a pending receipt. Replacing an existing installation requires its current installation version, and preserves workspace customizations.",
21
21
  inputSchema: {
22
22
  type: "object",
23
23
  properties: {