@opengeni/worker-bundle 2.0.1 → 2.0.2-canary.38789554071001
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/activities/agent-run-admission.d.ts +1 -12
- package/dist/activities/agent-turn/admission.d.ts +88 -10
- package/dist/activities/agent-turn/agent-build.d.ts +14 -3
- package/dist/activities/agent-turn/claim.d.ts +4 -1
- package/dist/activities/agent-turn/claude-core.d.ts +195 -0
- package/dist/activities/agent-turn/code-search.d.ts +60 -0
- package/dist/activities/agent-turn/codex-capacity.d.ts +3 -0
- package/dist/activities/agent-turn/codex-core-capacity.d.ts +37 -0
- package/dist/activities/agent-turn/codex-core-claim.d.ts +40 -0
- package/dist/activities/agent-turn/codex-core-errors.d.ts +102 -0
- package/dist/activities/agent-turn/codex-core-failover.d.ts +15 -0
- package/dist/activities/agent-turn/codex-core-requests.d.ts +28 -0
- package/dist/activities/agent-turn/codex-core-settlement.d.ts +77 -0
- package/dist/activities/agent-turn/codex-credit-policy.d.ts +30 -0
- package/dist/activities/agent-turn/codex-plan-entitlement.d.ts +105 -0
- package/dist/activities/agent-turn/codex-usage-policy.d.ts +2 -0
- package/dist/activities/agent-turn/codex.d.ts +2 -19
- package/dist/activities/agent-turn/compaction-interruption.d.ts +32 -0
- package/dist/activities/agent-turn/compaction-prep.d.ts +30 -1
- package/dist/activities/agent-turn/credential-leases.d.ts +64 -37
- package/dist/activities/agent-turn/credential-restriction.d.ts +3 -0
- package/dist/activities/agent-turn/errors.d.ts +185 -26
- package/dist/activities/agent-turn/failure-settlement.d.ts +10 -43
- package/dist/activities/agent-turn/final-reply.d.ts +18 -0
- package/dist/activities/agent-turn/finalization-monitor.d.ts +7 -2
- package/dist/activities/agent-turn/finalization.d.ts +2 -0
- package/dist/activities/agent-turn/github-repository-bindings.d.ts +2 -0
- package/dist/activities/agent-turn/governance-model.d.ts +13 -1
- package/dist/activities/agent-turn/history-sink.d.ts +4 -1
- package/dist/activities/agent-turn/history.d.ts +2 -0
- package/dist/activities/agent-turn/input-wait-reply.d.ts +76 -0
- package/dist/activities/agent-turn/meaningful-output.d.ts +9 -0
- package/dist/activities/agent-turn/media-artifacts.d.ts +5 -3
- package/dist/activities/agent-turn/model-call-admission.d.ts +15 -0
- package/dist/activities/agent-turn/model-usage.d.ts +56 -14
- package/dist/activities/agent-turn/model-wire-dispatch.d.ts +15 -0
- package/dist/activities/agent-turn/optional-repositories.d.ts +59 -0
- package/dist/activities/agent-turn/prompt-tool-availability.d.ts +17 -0
- package/dist/activities/agent-turn/provider-dispatch-barrier.d.ts +12 -1
- package/dist/activities/agent-turn/provider-recovery-copy.d.ts +24 -0
- package/dist/activities/agent-turn/provider-recovery-metrics.d.ts +18 -0
- package/dist/activities/agent-turn/provider-recovery-policy.d.ts +6 -0
- package/dist/activities/agent-turn/quiescence.d.ts +6 -7
- package/dist/activities/agent-turn/recovery-warning.d.ts +6 -5
- package/dist/activities/agent-turn/refresh-credentials.d.ts +6 -0
- package/dist/activities/agent-turn/run-credentials.d.ts +9 -5
- package/dist/activities/agent-turn/run.d.ts +27 -2
- package/dist/activities/agent-turn/sandbox-establish.d.ts +1 -0
- package/dist/activities/agent-turn/sandbox-provision.d.ts +25 -1
- package/dist/activities/agent-turn/sandbox-route.d.ts +3 -0
- package/dist/activities/agent-turn/sandbox-runtime.d.ts +1 -1
- package/dist/activities/agent-turn/secret-resolver.d.ts +64 -0
- package/dist/activities/agent-turn/session-title.d.ts +60 -3
- package/dist/activities/agent-turn/session-usage-custody.d.ts +66 -0
- package/dist/activities/agent-turn/skill-checkout.d.ts +25 -6
- package/dist/activities/agent-turn/skill-read.d.ts +70 -2
- package/dist/activities/agent-turn/skill-search.d.ts +2 -0
- package/dist/activities/agent-turn/skill-tools.d.ts +41 -4
- package/dist/activities/agent-turn/skill-transfer.d.ts +18 -6
- package/dist/activities/agent-turn/stream-attempt.d.ts +6 -3
- package/dist/activities/agent-turn/subscription-capacity-arming.d.ts +41 -0
- package/dist/activities/agent-turn/subscription-core-capacity.d.ts +86 -0
- package/dist/activities/agent-turn/subscription-core-failover.d.ts +69 -0
- package/dist/activities/agent-turn/subscription-core-placed.d.ts +14 -0
- package/dist/activities/agent-turn/subscription-core-requests.d.ts +109 -0
- package/dist/activities/agent-turn/subscription-core-settlement.d.ts +112 -0
- package/dist/activities/agent-turn/subscription-lease.d.ts +44 -0
- package/dist/activities/agent-turn/subscription-serving-capacity.d.ts +6 -0
- package/dist/activities/agent-turn/subscription-serving-catalog.d.ts +13 -0
- package/dist/activities/agent-turn/subscription-serving-claim.d.ts +30 -0
- package/dist/activities/agent-turn/subscription-serving-providers.d.ts +2 -0
- package/dist/activities/agent-turn/tool-environment.d.ts +31 -6
- package/dist/activities/agent-turn/tool-policy.d.ts +55 -3
- package/dist/activities/agent-turn/turn-context.d.ts +104 -5
- package/dist/activities/agent-turn/web-search.d.ts +57 -0
- package/dist/activities/agent-turn/xai-core.d.ts +96 -0
- package/dist/activities/automations.d.ts +3 -1
- package/dist/activities/browser-deadline-checkpoint.d.ts +34 -0
- package/dist/activities/capabilities.d.ts +8 -20
- package/dist/activities/codemode-dispatcher.d.ts +20 -3
- package/dist/activities/codex-capacity.d.ts +1 -56
- package/dist/activities/codex-image-generation.d.ts +49 -3
- package/dist/activities/common.d.ts +3 -1
- package/dist/activities/context-compaction.d.ts +41 -2
- package/dist/activities/environment.d.ts +1 -19
- package/dist/activities/gmail-files.d.ts +50 -0
- package/dist/activities/goals.d.ts +1 -9
- package/dist/activities/incident-telemetry-authority.d.ts +5 -2
- package/dist/activities/incident-telemetry-preflight.d.ts +10 -3
- package/dist/activities/knowledge-indexing.d.ts +19 -0
- package/dist/activities/mcp-account-routes.d.ts +2 -21
- package/dist/activities/model-call-fact-reconciler.d.ts +34 -0
- package/dist/activities/open-suffix-resume.d.ts +15 -0
- package/dist/activities/parent-wake.d.ts +17 -12
- package/dist/activities/programmatic-approvals.d.ts +10 -0
- package/dist/activities/requester-unavailable-receipt.d.ts +8 -0
- package/dist/activities/retained-screenshots.d.ts +7 -2
- package/dist/activities/run-credential-renewal.d.ts +1 -0
- package/dist/activities/run-credentials.d.ts +16 -4
- package/dist/activities/run-input.d.ts +17 -0
- package/dist/activities/sandbox-lease.d.ts +132 -12
- package/dist/activities/scheduled-tasks.d.ts +4 -35
- package/dist/activities/session-archive.d.ts +58 -0
- package/dist/activities/session-state.d.ts +15 -3
- package/dist/activities/session-storage.d.ts +44 -0
- package/dist/activities/subscription-core-claude-waits.d.ts +2 -0
- package/dist/activities/subscription-core-codex-quota.d.ts +25 -0
- package/dist/activities/subscription-core-codex-waits.d.ts +153 -0
- package/dist/activities/subscription-core-image-operation.d.ts +29 -0
- package/dist/activities/subscription-core-usage-recheck.d.ts +49 -0
- package/dist/activities/subscription-core-wait-bindings.d.ts +3 -0
- package/dist/activities/subscription-core-xai-quota.d.ts +30 -0
- package/dist/activities/subscription-core-xai-waits.d.ts +2 -0
- package/dist/activities/types.d.ts +68 -5
- package/dist/activities/video-generation-admission.d.ts +2 -8
- package/dist/activities/video-generation-credential.d.ts +15 -12
- package/dist/activities/video-generation-subscription-core.d.ts +70 -0
- package/dist/activities/workspace-capture.d.ts +2 -0
- package/dist/activities/workspace-credential-provider.d.ts +47 -0
- package/dist/activities/xai-auth.d.ts +6 -18
- package/dist/activities/xai-image-generation.d.ts +22 -6
- package/dist/{activities-control-QA6OLRQY.js → activities-control-5IIVRXLA.js} +1569 -2883
- package/dist/activities-control-5IIVRXLA.js.map +1 -0
- package/dist/activities-control.d.ts +64 -4
- package/dist/{activities-turn-YVVKCGAK.js → activities-turn-FLYJOM54.js} +9300 -4403
- package/dist/activities-turn-FLYJOM54.js.map +1 -0
- package/dist/activities.d.ts +64 -4
- package/dist/artifact-materializer-entry.js +107 -36
- package/dist/artifact-materializer-entry.js.map +1 -1
- package/dist/artifact-outbox-entry.js +132 -61
- package/dist/artifact-outbox-entry.js.map +1 -1
- package/dist/browser-deadline-checkpoint-contract.d.ts +2 -0
- package/dist/{chunk-GDCLDKSH.js → chunk-24GP3BX5.js} +79 -72
- package/dist/chunk-24GP3BX5.js.map +1 -0
- package/dist/{chunk-RAMNYSAW.js → chunk-4ER3YXOT.js} +22 -4
- package/dist/chunk-4ER3YXOT.js.map +1 -0
- package/dist/{chunk-I7HKKMUJ.js → chunk-5NNS4327.js} +734 -58
- package/dist/chunk-5NNS4327.js.map +1 -0
- package/dist/chunk-MVESOYFC.js +3746 -0
- package/dist/chunk-MVESOYFC.js.map +1 -0
- package/dist/{chunk-M3NVMF2V.js → chunk-N57B3PJ5.js} +2307 -3951
- package/dist/chunk-N57B3PJ5.js.map +1 -0
- package/dist/chunk-NQDVJ6RI.js +2823 -0
- package/dist/chunk-NQDVJ6RI.js.map +1 -0
- package/dist/chunk-O7UPBWXK.js +79 -0
- package/dist/chunk-O7UPBWXK.js.map +1 -0
- package/dist/chunk-W2QSM5HR.js +414 -0
- package/dist/chunk-W2QSM5HR.js.map +1 -0
- package/dist/chunk-ZN3XJR33.js +227 -0
- package/dist/chunk-ZN3XJR33.js.map +1 -0
- package/dist/editable-artifact-outbox-dispatcher.d.ts +12 -1
- package/dist/editable-artifact-outbox-service.d.ts +3 -1
- package/dist/host-export-pump.d.ts +3 -1
- package/dist/host-export.d.ts +2 -2
- package/dist/host-export.js +1 -1
- package/dist/http.d.ts +1 -1
- package/dist/index.d.ts +49 -48
- package/dist/index.js +835 -256
- package/dist/index.js.map +1 -1
- package/dist/internal-maintenance.d.ts +63 -0
- package/dist/maintenance-cadence.d.ts +43 -0
- package/dist/observability-metrics.d.ts +293 -24
- package/dist/onepassword-vault-provider.d.ts +7 -0
- package/dist/parent-wake-PCLH7A3Y.js +24 -0
- package/dist/parent-wake-PCLH7A3Y.js.map +1 -0
- package/dist/personal-github-git-credentials.d.ts +1 -1
- package/dist/readiness-checks.d.ts +39 -0
- package/dist/retained-process-retry.d.ts +7 -0
- package/dist/sandbox-lease-BJYU72N3.js +84 -0
- package/dist/sandbox-lease-BJYU72N3.js.map +1 -0
- package/dist/sandbox-reaper-contract.d.ts +25 -0
- package/dist/sandbox-resume.d.ts +72 -4
- package/dist/sandbox-routing.d.ts +4 -2
- package/dist/session-event-fanout.d.ts +6 -0
- package/dist/site-auth-maintenance-WK3MR2PV.js +12 -0
- package/dist/site-auth-maintenance-WK3MR2PV.js.map +1 -0
- package/dist/telemetry-scheduler.d.ts +14 -0
- package/dist/temporal-runtime-logger.d.ts +22 -0
- package/dist/turn-task-queue-reader.d.ts +18 -0
- package/dist/turn-worker-activity-telemetry.d.ts +47 -0
- package/dist/worker-service-lifecycle.d.ts +12 -0
- package/dist/workflow-bundle.js +468 -71
- package/dist/workflows/activities.d.ts +1 -1
- package/dist/workflows/browser-deadline-checkpoint.d.ts +10 -0
- package/dist/workflows/sandbox-reaper.d.ts +10 -1
- package/dist/workflows/scheduled-tasks.d.ts +4 -0
- package/dist/workflows/session-storage.d.ts +2 -0
- package/dist/workflows/session.d.ts +36 -0
- package/dist/workflows/site-auth-maintenance.d.ts +2 -1
- package/dist/workflows/workflow-wake.d.ts +14 -3
- package/dist/workflows.d.ts +3 -1
- package/package.json +26 -20
- package/src/activities/agent-run-admission.ts +1 -82
- package/src/activities/agent-turn/admission.ts +175 -24
- package/src/activities/agent-turn/agent-build.ts +226 -145
- package/src/activities/agent-turn/claim.ts +363 -64
- package/src/activities/agent-turn/claude-core.ts +587 -0
- package/src/activities/agent-turn/code-search.ts +275 -0
- package/src/activities/agent-turn/codex-capacity.ts +30 -757
- package/src/activities/agent-turn/codex-core-capacity.ts +190 -0
- package/src/activities/agent-turn/codex-core-claim.ts +83 -0
- package/src/activities/agent-turn/codex-core-errors.ts +308 -0
- package/src/activities/agent-turn/codex-core-failover.ts +73 -0
- package/src/activities/agent-turn/codex-core-requests.ts +86 -0
- package/src/activities/agent-turn/codex-core-settlement.ts +263 -0
- package/src/activities/agent-turn/codex-credit-policy.ts +247 -0
- package/src/activities/agent-turn/codex-plan-entitlement.ts +254 -0
- package/src/activities/agent-turn/codex-usage-policy.ts +2 -0
- package/src/activities/agent-turn/codex.ts +8 -76
- package/src/activities/agent-turn/compaction-interruption.ts +56 -0
- package/src/activities/agent-turn/compaction-prep.ts +249 -36
- package/src/activities/agent-turn/credential-leases.ts +269 -214
- package/src/activities/agent-turn/credential-restriction.ts +14 -0
- package/src/activities/agent-turn/errors.ts +1152 -82
- package/src/activities/agent-turn/failure-settlement.ts +879 -886
- package/src/activities/agent-turn/final-reply.ts +46 -0
- package/src/activities/agent-turn/finalization-monitor.ts +17 -5
- package/src/activities/agent-turn/finalization.ts +107 -88
- package/src/activities/agent-turn/github-repository-bindings.ts +3 -1
- package/src/activities/agent-turn/governance-model.ts +90 -22
- package/src/activities/agent-turn/history-sink.ts +42 -12
- package/src/activities/agent-turn/history.ts +25 -5
- package/src/activities/agent-turn/input-wait-reply.ts +139 -0
- package/src/activities/agent-turn/knowledge-source-tools.ts +2 -0
- package/src/activities/agent-turn/meaningful-output.ts +44 -0
- package/src/activities/agent-turn/media-artifacts.ts +3 -1
- package/src/activities/agent-turn/model-call-admission.ts +114 -0
- package/src/activities/agent-turn/model-usage.ts +299 -233
- package/src/activities/agent-turn/model-wire-dispatch.ts +27 -0
- package/src/activities/agent-turn/optional-repositories.ts +224 -0
- package/src/activities/agent-turn/prompt-tool-availability.ts +27 -0
- package/src/activities/agent-turn/provider-dispatch-barrier.ts +22 -0
- package/src/activities/agent-turn/provider-recovery-copy.ts +76 -0
- package/src/activities/agent-turn/provider-recovery-metrics.ts +64 -0
- package/src/activities/agent-turn/provider-recovery-policy.ts +25 -0
- package/src/activities/agent-turn/quiescence.ts +7 -7
- package/src/activities/agent-turn/recovery-warning.ts +6 -8
- package/src/activities/agent-turn/refresh-credentials.ts +44 -0
- package/src/activities/agent-turn/run-credentials.ts +124 -76
- package/src/activities/agent-turn/run.ts +501 -112
- package/src/activities/agent-turn/sandbox-establish.ts +152 -75
- package/src/activities/agent-turn/sandbox-provision.ts +54 -1
- package/src/activities/agent-turn/sandbox-route.ts +4 -1
- package/src/activities/agent-turn/sandbox-runtime.ts +319 -11
- package/src/activities/agent-turn/secret-resolver.ts +155 -0
- package/src/activities/agent-turn/session-title.ts +177 -12
- package/src/activities/agent-turn/session-usage-custody.ts +170 -0
- package/src/activities/agent-turn/skill-checkout.ts +111 -24
- package/src/activities/agent-turn/skill-install.ts +1 -1
- package/src/activities/agent-turn/skill-read.ts +374 -28
- package/src/activities/agent-turn/skill-save.ts +35 -7
- package/src/activities/agent-turn/skill-search.ts +9 -0
- package/src/activities/agent-turn/skill-selection.ts +4 -0
- package/src/activities/agent-turn/skill-tools.ts +208 -21
- package/src/activities/agent-turn/skill-transfer.ts +68 -23
- package/src/activities/agent-turn/stream-attempt.ts +634 -111
- package/src/activities/agent-turn/subscription-capacity-arming.ts +81 -0
- package/src/activities/agent-turn/subscription-core-capacity.ts +439 -0
- package/src/activities/agent-turn/subscription-core-failover.ts +229 -0
- package/src/activities/agent-turn/subscription-core-placed.ts +37 -0
- package/src/activities/agent-turn/subscription-core-requests.ts +271 -0
- package/src/activities/agent-turn/subscription-core-settlement.ts +234 -0
- package/src/activities/agent-turn/subscription-lease.ts +140 -0
- package/src/activities/agent-turn/subscription-serving-capacity.ts +195 -0
- package/src/activities/agent-turn/subscription-serving-catalog.ts +71 -0
- package/src/activities/agent-turn/subscription-serving-claim.ts +178 -0
- package/src/activities/agent-turn/subscription-serving-providers.ts +15 -0
- package/src/activities/agent-turn/tool-environment.ts +384 -292
- package/src/activities/agent-turn/tool-policy.ts +104 -4
- package/src/activities/agent-turn/tool-result-spill.ts +1 -0
- package/src/activities/agent-turn/turn-context.ts +124 -8
- package/src/activities/agent-turn/web-search.ts +431 -0
- package/src/activities/agent-turn/xai-core.ts +301 -0
- package/src/activities/automations.ts +81 -6
- package/src/activities/browser-deadline-checkpoint.ts +297 -0
- package/src/activities/capabilities.ts +53 -213
- package/src/activities/codemode-dispatcher.ts +236 -14
- package/src/activities/codex-capacity.ts +27 -380
- package/src/activities/codex-image-generation.ts +252 -42
- package/src/activities/common.ts +12 -0
- package/src/activities/connector-attachments.ts +3 -1
- package/src/activities/context-compaction.ts +182 -21
- package/src/activities/environment.ts +18 -106
- package/src/activities/gmail-files.ts +108 -0
- package/src/activities/goals.ts +120 -204
- package/src/activities/image-generation-operation.ts +1 -1
- package/src/activities/incident-telemetry-authority.ts +80 -50
- package/src/activities/incident-telemetry-preflight.ts +27 -15
- package/src/activities/knowledge-indexing.ts +287 -17
- package/src/activities/knowledge-source-sync.ts +10 -0
- package/src/activities/mcp-account-routes.ts +2 -124
- package/src/activities/model-call-fact-reconciler.ts +112 -0
- package/src/activities/open-suffix-resume.ts +122 -88
- package/src/activities/parent-wake.ts +89 -21
- package/src/activities/programmatic-approvals.ts +26 -0
- package/src/activities/requester-unavailable-receipt.ts +14 -0
- package/src/activities/retained-screenshots.ts +135 -24
- package/src/activities/run-credential-renewal.ts +13 -1
- package/src/activities/run-credentials.ts +61 -19
- package/src/activities/run-input.ts +124 -9
- package/src/activities/sandbox-lease.ts +1615 -73
- package/src/activities/scheduled-tasks.ts +780 -147
- package/src/activities/session-archive.ts +382 -0
- package/src/activities/session-state.ts +219 -10
- package/src/activities/session-storage.ts +124 -0
- package/src/activities/site-auth-maintenance.ts +5 -2
- package/src/activities/subscription-core-claude-waits.ts +49 -0
- package/src/activities/subscription-core-codex-quota.ts +46 -0
- package/src/activities/subscription-core-codex-waits.ts +488 -0
- package/src/activities/subscription-core-image-operation.ts +126 -0
- package/src/activities/subscription-core-usage-recheck.ts +146 -0
- package/src/activities/subscription-core-wait-bindings.ts +12 -0
- package/src/activities/subscription-core-xai-quota.ts +85 -0
- package/src/activities/subscription-core-xai-waits.ts +48 -0
- package/src/activities/types.ts +85 -9
- package/src/activities/video-generation-admission.ts +1 -36
- package/src/activities/video-generation-credential.ts +38 -56
- package/src/activities/video-generation-reconciliation.ts +150 -131
- package/src/activities/video-generation-subscription-core.ts +180 -0
- package/src/activities/workspace-capture.ts +13 -2
- package/src/activities/workspace-credential-provider.ts +302 -0
- package/src/activities/xai-auth.ts +34 -112
- package/src/activities/xai-image-generation.ts +84 -36
- package/src/activities-control.ts +8 -0
- package/src/activities-turn.ts +5 -0
- package/src/activities.ts +17 -0
- package/src/activity-services.ts +29 -4
- package/src/browser-deadline-checkpoint-contract.ts +5 -0
- package/src/editable-artifact-hint-broker.ts +3 -0
- package/src/editable-artifact-materializer-service.ts +85 -39
- package/src/editable-artifact-materializer-subprocess.ts +47 -2
- package/src/editable-artifact-outbox-dispatcher.ts +107 -46
- package/src/editable-artifact-outbox-service.ts +55 -25
- package/src/github-rest-mcp.ts +1 -1
- package/src/host-export-pump.ts +26 -4
- package/src/host-export.ts +4 -1
- package/src/http.ts +4 -2
- package/src/index.ts +222 -282
- package/src/internal-maintenance.ts +347 -0
- package/src/maintenance-cadence.ts +156 -0
- package/src/observability-metrics.ts +1173 -73
- package/src/onepassword-vault-provider.ts +11 -0
- package/src/personal-github-git-credentials.ts +3 -1
- package/src/pr-review-credentials.ts +1 -1
- package/src/readiness-checks.ts +113 -0
- package/src/retained-process-retry.ts +36 -0
- package/src/sandbox-reaper-contract.ts +33 -0
- package/src/sandbox-resume.ts +444 -73
- package/src/sandbox-routing.ts +230 -75
- package/src/session-event-fanout.ts +23 -0
- package/src/telemetry-scheduler.ts +53 -0
- package/src/temporal-runtime-logger.ts +44 -0
- package/src/turn-task-queue-reader.ts +110 -0
- package/src/turn-worker-activity-telemetry.ts +209 -0
- package/src/worker-service-lifecycle.ts +54 -1
- package/src/workflows/activities.ts +16 -1
- package/src/workflows/browser-deadline-checkpoint.ts +55 -0
- package/src/workflows/file-upload-reaper.ts +2 -0
- package/src/workflows/sandbox-reaper.ts +88 -0
- package/src/workflows/scheduled-tasks.ts +26 -13
- package/src/workflows/session-storage.ts +19 -0
- package/src/workflows/session.ts +238 -33
- package/src/workflows/site-auth-maintenance.ts +2 -1
- package/src/workflows/workflow-wake.ts +26 -4
- package/src/workflows.ts +7 -0
- package/dist/activities/agent-turn/xai-capacity.d.ts +0 -2
- package/dist/activities/codex-fleet-shadow.d.ts +0 -74
- package/dist/activities/codex-rotation.d.ts +0 -200
- package/dist/activities/xai-quota.d.ts +0 -3
- package/dist/activities-control-QA6OLRQY.js.map +0 -1
- package/dist/activities-turn-YVVKCGAK.js.map +0 -1
- package/dist/chunk-GDCLDKSH.js.map +0 -1
- package/dist/chunk-I7HKKMUJ.js.map +0 -1
- package/dist/chunk-M3NVMF2V.js.map +0 -1
- package/dist/chunk-RAMNYSAW.js.map +0 -1
- package/src/activities/agent-turn/xai-capacity.ts +0 -257
- package/src/activities/codex-fleet-shadow.ts +0 -306
- package/src/activities/codex-rotation.ts +0 -685
- package/src/activities/xai-quota.ts +0 -35
|
@@ -1,16 +1,31 @@
|
|
|
1
1
|
import {
|
|
2
2
|
advanceWorkspaceGeneration,
|
|
3
3
|
verifyWorkspaceMutationSettlement,
|
|
4
|
-
|
|
4
|
+
heartbeatLeaseHolderStatus,
|
|
5
5
|
readLease,
|
|
6
6
|
accrueWarmSeconds,
|
|
7
7
|
SandboxWorkspaceMutationFencedError,
|
|
8
|
+
SandboxWorkspaceMutationOutputRejectedError,
|
|
9
|
+
retainWorkspaceMutationProcess,
|
|
10
|
+
retainedProviderCommandPersistence,
|
|
11
|
+
SandboxRetainedProcessPromotionFencedError,
|
|
8
12
|
} from "@opengeni/db";
|
|
13
|
+
import { createProviderCommandRetainer } from "@opengeni/db/retained-provider-commands";
|
|
9
14
|
import {
|
|
10
15
|
RoutingMutationOutcomeUnknownError,
|
|
16
|
+
RoutingMutationOutputRejectedError,
|
|
17
|
+
ProviderCommandStartOutcomeUnknownError,
|
|
18
|
+
ProviderCommandObservationUnavailableError,
|
|
19
|
+
isModalCommandStartOutcomeUnknownError,
|
|
20
|
+
withModalCommandStartSignal,
|
|
21
|
+
resolveModalCheckpointProviderBindingForSession,
|
|
11
22
|
runManagedCodemodeClientHook,
|
|
12
23
|
type EstablishedSandboxSession,
|
|
24
|
+
type ProviderCommandSession,
|
|
25
|
+
type RoutingRetainedProcess,
|
|
13
26
|
} from "@opengeni/runtime";
|
|
27
|
+
import { ModalRouterProviderCommand } from "@opengeni/contracts";
|
|
28
|
+
import { isDeepStrictEqual } from "node:util";
|
|
14
29
|
import {
|
|
15
30
|
sandboxLifecycleTransitionWaitMs,
|
|
16
31
|
sandboxWarmRateMicrosPerSecond,
|
|
@@ -50,6 +65,114 @@ export type SandboxTurnRuntimeDeps = {
|
|
|
50
65
|
|
|
51
66
|
export type SandboxTurnRuntime = ReturnType<typeof createSandboxTurnRuntime>;
|
|
52
67
|
|
|
68
|
+
const retainInternalProviderCommand = createProviderCommandRetainer(
|
|
69
|
+
retainWorkspaceMutationProcess,
|
|
70
|
+
(error) => (error instanceof SandboxRetainedProcessPromotionFencedError ? error.process : null),
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
/** Only the complete runtime producer boundary supplies a command descriptor.
|
|
74
|
+
* A bare SDK boundary can veto rejection, but its task/exec fields alone cannot
|
|
75
|
+
* establish its sandbox, PTY or complete original invocation. */
|
|
76
|
+
function internalMutationUnknownCommand(
|
|
77
|
+
error: unknown,
|
|
78
|
+
instanceId: string,
|
|
79
|
+
): { unknown: boolean; command: ModalRouterProviderCommand | null } {
|
|
80
|
+
const pending = [{ value: error, depth: 0 }];
|
|
81
|
+
const seen = new Set<object>();
|
|
82
|
+
const commands: ModalRouterProviderCommand[] = [];
|
|
83
|
+
let unknown = false;
|
|
84
|
+
let incomplete = false;
|
|
85
|
+
for (let inspected = 0; pending.length && inspected < 128; inspected++) {
|
|
86
|
+
const { value, depth } = pending.shift()!;
|
|
87
|
+
if (!value || typeof value !== "object" || seen.has(value)) continue;
|
|
88
|
+
seen.add(value);
|
|
89
|
+
try {
|
|
90
|
+
if (
|
|
91
|
+
value instanceof ProviderCommandStartOutcomeUnknownError ||
|
|
92
|
+
value instanceof ProviderCommandObservationUnavailableError
|
|
93
|
+
) {
|
|
94
|
+
unknown = true;
|
|
95
|
+
// Zod reads ordinary properties. First make a bounded own-data-only
|
|
96
|
+
// copy so neither validation nor equality executes descriptor getters.
|
|
97
|
+
// This contract has no arrays, functions or symbol-keyed fields.
|
|
98
|
+
let remaining = 64;
|
|
99
|
+
const copyCommandData = (candidate: unknown, descriptorDepth = 0): unknown => {
|
|
100
|
+
if (--remaining < 0 || descriptorDepth > 4)
|
|
101
|
+
throw new Error("Internal command descriptor exceeded inspection bounds");
|
|
102
|
+
if (
|
|
103
|
+
candidate === null ||
|
|
104
|
+
candidate === undefined ||
|
|
105
|
+
typeof candidate === "string" ||
|
|
106
|
+
typeof candidate === "number" ||
|
|
107
|
+
typeof candidate === "boolean"
|
|
108
|
+
)
|
|
109
|
+
return candidate;
|
|
110
|
+
if (typeof candidate !== "object" || Array.isArray(candidate))
|
|
111
|
+
throw new Error("Internal command descriptor is not a data object");
|
|
112
|
+
const keys = Reflect.ownKeys(candidate);
|
|
113
|
+
if (keys.length > 16)
|
|
114
|
+
throw new Error("Internal command descriptor exceeded field bounds");
|
|
115
|
+
const copy: Record<string, unknown> = Object.create(null);
|
|
116
|
+
for (const key of keys) {
|
|
117
|
+
const property = Object.getOwnPropertyDescriptor(candidate, key);
|
|
118
|
+
if (typeof key !== "string" || !property || !("value" in property))
|
|
119
|
+
throw new Error("Internal command descriptor contains a non-data field");
|
|
120
|
+
copy[key] = copyCommandData(property.value, descriptorDepth + 1);
|
|
121
|
+
}
|
|
122
|
+
return copy;
|
|
123
|
+
};
|
|
124
|
+
const parsed = ModalRouterProviderCommand.safeParse(
|
|
125
|
+
copyCommandData(Object.getOwnPropertyDescriptor(value, "command")?.value),
|
|
126
|
+
);
|
|
127
|
+
if (!parsed.success || parsed.data.sandboxId !== instanceId) incomplete = true;
|
|
128
|
+
else commands.push(parsed.data);
|
|
129
|
+
// This complete producer boundary owns its original SDK cause. Do not
|
|
130
|
+
// reinterpret that cause's partial locator as a second command.
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
const sdkUnknown = isModalCommandStartOutcomeUnknownError(value);
|
|
134
|
+
if (sdkUnknown || value instanceof RoutingMutationOutcomeUnknownError) unknown = true;
|
|
135
|
+
const nested: unknown[] = [];
|
|
136
|
+
for (const key of ["cause", "error", "errors"] as const) {
|
|
137
|
+
const property = Object.getOwnPropertyDescriptor(value, key);
|
|
138
|
+
if (!property) continue;
|
|
139
|
+
if (!("value" in property)) {
|
|
140
|
+
incomplete = true;
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
if (key === "errors" && Array.isArray(property.value)) {
|
|
144
|
+
const length = Object.getOwnPropertyDescriptor(property.value, "length")?.value;
|
|
145
|
+
if (typeof length !== "number" || !Number.isSafeInteger(length) || length < 0) {
|
|
146
|
+
incomplete = true;
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
if (length > 64) incomplete = true;
|
|
150
|
+
for (let index = 0; index < Math.min(length, 64); index++) {
|
|
151
|
+
const element = Object.getOwnPropertyDescriptor(property.value, String(index));
|
|
152
|
+
if (!element || !("value" in element)) incomplete = true;
|
|
153
|
+
else nested.push(element.value);
|
|
154
|
+
}
|
|
155
|
+
} else if (property.value !== undefined) nested.push(property.value);
|
|
156
|
+
}
|
|
157
|
+
if (
|
|
158
|
+
sdkUnknown &&
|
|
159
|
+
(nested.length === 0 ||
|
|
160
|
+
Object.getOwnPropertyDescriptor(value, "taskId") ||
|
|
161
|
+
Object.getOwnPropertyDescriptor(value, "execId"))
|
|
162
|
+
)
|
|
163
|
+
incomplete = true;
|
|
164
|
+
if (depth >= 12 && nested.length) incomplete = true;
|
|
165
|
+
else for (const child of nested) pending.push({ value: child, depth: depth + 1 });
|
|
166
|
+
} catch {
|
|
167
|
+
incomplete = true;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (pending.length) incomplete = true;
|
|
171
|
+
const command = commands[0] ?? null;
|
|
172
|
+
if (commands.some((candidate) => !isDeepStrictEqual(candidate, command))) incomplete = true;
|
|
173
|
+
return { unknown: unknown || incomplete, command: incomplete ? null : command };
|
|
174
|
+
}
|
|
175
|
+
|
|
53
176
|
/**
|
|
54
177
|
* Provider-deadline rotation is a preemption boundary, not a cooperative
|
|
55
178
|
* snapshot boundary. Snapshotting while this attempt still owns active tools
|
|
@@ -85,12 +208,62 @@ export function createSandboxTurnRuntime(deps: SandboxTurnRuntimeDeps) {
|
|
|
85
208
|
eventing,
|
|
86
209
|
attempt,
|
|
87
210
|
} = deps;
|
|
211
|
+
const commandStartSignal = cancellationSignal
|
|
212
|
+
? AbortSignal.any([cancellationSignal, sandboxRotationController.signal])
|
|
213
|
+
: sandboxRotationController.signal;
|
|
214
|
+
|
|
215
|
+
// The exact existing private release closure is the holder authority. Keep
|
|
216
|
+
// its ordinary eager release, but never pass a false writer-drain proof that
|
|
217
|
+
// would let releaseLeaseHolder settle an ambiguous null-outcome admission.
|
|
218
|
+
const releaseGuards = new WeakMap<
|
|
219
|
+
ResumedTurnSandbox["release"],
|
|
220
|
+
{
|
|
221
|
+
pending: Map<string, { operation: string; cause?: unknown }>;
|
|
222
|
+
release: ResumedTurnSandbox["release"];
|
|
223
|
+
}
|
|
224
|
+
>();
|
|
225
|
+
const guardSandboxRelease = (sandbox: ResumedTurnSandbox) => {
|
|
226
|
+
if (typeof sandbox.release !== "function") return null;
|
|
227
|
+
const original = sandbox.release;
|
|
228
|
+
let guard = releaseGuards.get(original);
|
|
229
|
+
if (!guard) {
|
|
230
|
+
const pending = new Map<string, { operation: string; cause?: unknown }>();
|
|
231
|
+
const release: ResumedTurnSandbox["release"] = async (options) => {
|
|
232
|
+
if (options?.workspaceWritersQuiesced && pending.size) {
|
|
233
|
+
await original();
|
|
234
|
+
throw new RoutingMutationOutcomeUnknownError(
|
|
235
|
+
"internalWorkspaceMutationDrain",
|
|
236
|
+
"Internal workspace command is still outcome-unknown; its admission remains fenced until exact retention or physical settlement",
|
|
237
|
+
{ cause: new AggregateError([...pending.values()].map((entry) => entry.cause)) },
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
await original(options);
|
|
241
|
+
};
|
|
242
|
+
guard = { pending, release };
|
|
243
|
+
releaseGuards.set(original, guard);
|
|
244
|
+
releaseGuards.set(release, guard);
|
|
245
|
+
}
|
|
246
|
+
// Rebound preparation may use a shallow copy of the published sandbox.
|
|
247
|
+
// Protect every known copy of this SAME private holder release closure,
|
|
248
|
+
// never another lease or a newly fabricated holder.
|
|
249
|
+
for (const target of [
|
|
250
|
+
sandbox,
|
|
251
|
+
sandboxState.resolvedSandbox,
|
|
252
|
+
sandboxState.prefetchedManagedBoxResult,
|
|
253
|
+
...(sandboxState.lateSandboxesAwaitingWriterDrain ?? []),
|
|
254
|
+
]) {
|
|
255
|
+
if (target?.release === original || target?.release === guard.release)
|
|
256
|
+
target.release = guard.release;
|
|
257
|
+
}
|
|
258
|
+
return guard;
|
|
259
|
+
};
|
|
88
260
|
|
|
89
261
|
// P1.2 ownership inversion: when sandboxOwnershipEnabled, the turn resolves
|
|
90
262
|
// the one box by id from the group lease and injects it NON-OWNED into the
|
|
91
263
|
// run. null when the flag is off (byte-for-byte the legacy build-and-discard
|
|
92
264
|
// path) OR when the backend is "none". Released + dropped in `finally`.
|
|
93
265
|
const releaseLateSandbox = async (sandbox: ResumedTurnSandbox): Promise<void> => {
|
|
266
|
+
guardSandboxRelease(sandbox);
|
|
94
267
|
sandboxState.lateSandboxesAwaitingWriterDrain.add(sandbox);
|
|
95
268
|
// Drop the holder/timer immediately, but keep its null-outcome admissions
|
|
96
269
|
// fenced until the shared attempt writer drain completes. The staged
|
|
@@ -118,10 +291,11 @@ export function createSandboxTurnRuntime(deps: SandboxTurnRuntimeDeps) {
|
|
|
118
291
|
// Platform setup (beforeAgentStart hooks + file materialization) execs against
|
|
119
292
|
// THIS handle so a mid-turn sandbox_swap can never re-route those execs onto a
|
|
120
293
|
// connected machine (the user's real computer).
|
|
121
|
-
const finalizeTurnOpStreamOps = async (): Promise<void> => {
|
|
294
|
+
const finalizeTurnOpStreamOps = async (toolCallIds?: readonly string[]): Promise<void> => {
|
|
122
295
|
await finalizeDurableTurnOpStreams(
|
|
123
296
|
[sandboxState.lazyOwnedSandbox?.session, sandboxState.resolvedSandbox?.established.session],
|
|
124
297
|
sandboxState.machinePrimarySession,
|
|
298
|
+
toolCallIds,
|
|
125
299
|
);
|
|
126
300
|
};
|
|
127
301
|
// A same-target API repair can replace the home provider while this turn is
|
|
@@ -314,13 +488,116 @@ export function createSandboxTurnRuntime(deps: SandboxTurnRuntimeDeps) {
|
|
|
314
488
|
}
|
|
315
489
|
};
|
|
316
490
|
let result: T;
|
|
491
|
+
const releaseGuard = guardSandboxRelease(sandbox);
|
|
492
|
+
releaseGuard?.pending.set(admission.id, { operation });
|
|
317
493
|
const providerStartedAt = performance.now();
|
|
318
494
|
let providerOutcome: "completed" | "failed" = "failed";
|
|
319
495
|
try {
|
|
320
|
-
result = await mutation
|
|
496
|
+
result = await withModalCommandStartSignal(commandStartSignal, mutation);
|
|
321
497
|
providerOutcome = "completed";
|
|
322
498
|
} catch (providerError) {
|
|
323
499
|
observeMutationPhase("provider", providerOutcome, performance.now() - providerStartedAt);
|
|
500
|
+
const ambiguity = internalMutationUnknownCommand(providerError, identity.expectedInstanceId);
|
|
501
|
+
if (ambiguity.unknown) {
|
|
502
|
+
releaseGuard?.pending.set(admission.id, { operation, cause: providerError });
|
|
503
|
+
if (!ambiguity.command) {
|
|
504
|
+
throw new RoutingMutationOutcomeUnknownError(
|
|
505
|
+
operation,
|
|
506
|
+
`Platform workspace mutation "${operation}" has no unique exact command descriptor; its admission remains fenced and it was not replayed`,
|
|
507
|
+
{ cause: providerError },
|
|
508
|
+
);
|
|
509
|
+
}
|
|
510
|
+
const process: RoutingRetainedProcess = {
|
|
511
|
+
id: crypto.randomUUID(),
|
|
512
|
+
providerSessionId: admission.workspaceGeneration,
|
|
513
|
+
providerCommand: ambiguity.command,
|
|
514
|
+
};
|
|
515
|
+
let exactRetentionVerified = false;
|
|
516
|
+
try {
|
|
517
|
+
const providerBinding = await resolveModalCheckpointProviderBindingForSession(
|
|
518
|
+
settings,
|
|
519
|
+
sandbox.established.session,
|
|
520
|
+
);
|
|
521
|
+
try {
|
|
522
|
+
await retainInternalProviderCommand(db, {
|
|
523
|
+
accountId: input.accountId,
|
|
524
|
+
workspaceId: input.workspaceId,
|
|
525
|
+
sessionId: input.sessionId,
|
|
526
|
+
processId: process.id,
|
|
527
|
+
providerSessionId: process.providerSessionId,
|
|
528
|
+
providerCommand: ambiguity.command,
|
|
529
|
+
admissionId: admission.id,
|
|
530
|
+
admittedWorkspaceGeneration: admission.workspaceGeneration,
|
|
531
|
+
operation,
|
|
532
|
+
providerBinding,
|
|
533
|
+
owner: { kind: "turn", ...identity },
|
|
534
|
+
});
|
|
535
|
+
} catch (promotionError) {
|
|
536
|
+
if (!(promotionError instanceof SandboxRetainedProcessPromotionFencedError))
|
|
537
|
+
throw promotionError;
|
|
538
|
+
const durable = promotionError.process;
|
|
539
|
+
if (
|
|
540
|
+
durable.id !== process.id ||
|
|
541
|
+
durable.providerSessionId !== process.providerSessionId ||
|
|
542
|
+
durable.parentAdmissionId !== admission.id ||
|
|
543
|
+
durable.accountId !== identity.accountId ||
|
|
544
|
+
durable.workspaceId !== identity.workspaceId ||
|
|
545
|
+
durable.sessionId !== identity.sessionId ||
|
|
546
|
+
durable.leaseId !== admission.leaseId ||
|
|
547
|
+
durable.sandboxGroupId !== identity.sandboxGroupId ||
|
|
548
|
+
durable.ownerActorKind !== admission.actorKind ||
|
|
549
|
+
durable.ownerActorId !== admission.actorId ||
|
|
550
|
+
durable.ownerTurnId !== identity.turnId ||
|
|
551
|
+
durable.ownerAttemptId !== identity.attemptId ||
|
|
552
|
+
durable.ownerExecutionGeneration !== identity.executionGeneration ||
|
|
553
|
+
durable.leaseEpoch !== identity.expectedEpoch ||
|
|
554
|
+
durable.providerBackend !== "modal" ||
|
|
555
|
+
durable.providerInstanceId !== identity.expectedInstanceId ||
|
|
556
|
+
durable.providerBindingKey !== providerBinding.key ||
|
|
557
|
+
!isDeepStrictEqual(durable.providerBinding, providerBinding.binding) ||
|
|
558
|
+
durable.routeKind !== admission.routeKind ||
|
|
559
|
+
durable.routeTargetId !== admission.routeTargetId ||
|
|
560
|
+
durable.routeEpoch !== admission.routeEpoch ||
|
|
561
|
+
durable.state !== "active"
|
|
562
|
+
)
|
|
563
|
+
throw promotionError;
|
|
564
|
+
// The established retainer committed BOTH locator and holder before
|
|
565
|
+
// rejecting stale output. Do not undo that physical retention.
|
|
566
|
+
}
|
|
567
|
+
const persistence = retainedProviderCommandPersistence(db, {
|
|
568
|
+
accountId: input.accountId,
|
|
569
|
+
workspaceId: input.workspaceId,
|
|
570
|
+
sessionId: input.sessionId,
|
|
571
|
+
processId: process.id,
|
|
572
|
+
});
|
|
573
|
+
if (!isDeepStrictEqual(await persistence.load(), ambiguity.command))
|
|
574
|
+
throw new Error("Internal command retention lost its exact original locator", {
|
|
575
|
+
cause: providerError,
|
|
576
|
+
});
|
|
577
|
+
exactRetentionVerified = true;
|
|
578
|
+
releaseGuard?.pending.delete(admission.id);
|
|
579
|
+
(sandbox.established.session as ProviderCommandSession).bindProviderCommand?.(
|
|
580
|
+
process.providerSessionId,
|
|
581
|
+
ambiguity.command,
|
|
582
|
+
persistence,
|
|
583
|
+
);
|
|
584
|
+
} catch (retentionError) {
|
|
585
|
+
throw new RoutingMutationOutcomeUnknownError(
|
|
586
|
+
operation,
|
|
587
|
+
`Platform workspace mutation "${operation}" remains outcome-unknown and its exact retention or observer binding failed; it was not replayed`,
|
|
588
|
+
{
|
|
589
|
+
cause: new AggregateError([providerError, retentionError]),
|
|
590
|
+
...(exactRetentionVerified ? { retainedProcess: process } : {}),
|
|
591
|
+
},
|
|
592
|
+
);
|
|
593
|
+
}
|
|
594
|
+
throw new RoutingMutationOutcomeUnknownError(
|
|
595
|
+
operation,
|
|
596
|
+
`Platform workspace mutation "${operation}" has an unknown Start outcome; its exact original invocation is retained and it was not replayed`,
|
|
597
|
+
{ cause: providerError, retainedProcess: process },
|
|
598
|
+
);
|
|
599
|
+
}
|
|
600
|
+
releaseGuard?.pending.delete(admission.id);
|
|
324
601
|
const partialMutation = providerError instanceof ChannelAPartialMutationError;
|
|
325
602
|
try {
|
|
326
603
|
await settleMutation(partialMutation ? "resolved" : "rejected");
|
|
@@ -342,10 +619,25 @@ export function createSandboxTurnRuntime(deps: SandboxTurnRuntimeDeps) {
|
|
|
342
619
|
}
|
|
343
620
|
throw providerError;
|
|
344
621
|
}
|
|
622
|
+
releaseGuard?.pending.delete(admission.id);
|
|
345
623
|
observeMutationPhase("provider", providerOutcome, performance.now() - providerStartedAt);
|
|
346
624
|
try {
|
|
347
625
|
await settleMutation("resolved");
|
|
348
626
|
} catch (settlementError) {
|
|
627
|
+
if (
|
|
628
|
+
settlementError instanceof SandboxWorkspaceMutationOutputRejectedError &&
|
|
629
|
+
settlementError.matchesPhysicalSettlement({
|
|
630
|
+
accountId: identity.accountId,
|
|
631
|
+
workspaceId: identity.workspaceId,
|
|
632
|
+
admission,
|
|
633
|
+
operation,
|
|
634
|
+
outcome: "resolved",
|
|
635
|
+
})
|
|
636
|
+
) {
|
|
637
|
+
throw new RoutingMutationOutputRejectedError(operation, settlementError.code, {
|
|
638
|
+
cause: settlementError,
|
|
639
|
+
});
|
|
640
|
+
}
|
|
349
641
|
throw new RoutingMutationOutcomeUnknownError(
|
|
350
642
|
operation,
|
|
351
643
|
`Platform workspace mutation "${operation}" returned from the provider but lost its durable settlement fence; its outcome is unknown and it was not replayed`,
|
|
@@ -526,12 +818,15 @@ export function createSandboxTurnRuntime(deps: SandboxTurnRuntimeDeps) {
|
|
|
526
818
|
// home turn that degraded to the cloud group box (swap-away / flag-off), that
|
|
527
819
|
// is the deployment default (modal), so the fallback box is warm-metered at
|
|
528
820
|
// the cloud rate instead of selfhosted's rate-0 (which would under-bill).
|
|
529
|
-
const warmRate =
|
|
530
|
-
settings
|
|
531
|
-
|
|
532
|
-
|
|
821
|
+
const warmRate =
|
|
822
|
+
settings.sandboxWarmBillingMode === "usage_only"
|
|
823
|
+
? 0
|
|
824
|
+
: sandboxWarmRateMicrosPerSecond(
|
|
825
|
+
settings,
|
|
826
|
+
warmBackend ?? (sandbox.established.backendId as Settings["sandboxBackend"]),
|
|
827
|
+
);
|
|
533
828
|
sandboxState.leaseHeartbeatTimer = setInterval(() => {
|
|
534
|
-
void
|
|
829
|
+
void heartbeatLeaseHolderStatus(db, {
|
|
535
830
|
accountId: input.accountId,
|
|
536
831
|
workspaceId: input.workspaceId,
|
|
537
832
|
sandboxGroupId: heartbeatGroupId,
|
|
@@ -539,9 +834,17 @@ export function createSandboxTurnRuntime(deps: SandboxTurnRuntimeDeps) {
|
|
|
539
834
|
holderId: heartbeatHolderId,
|
|
540
835
|
leaseTtlMs: settings.sandboxLeaseTtlMs,
|
|
541
836
|
expectedEpoch: heartbeatEpoch,
|
|
837
|
+
billingMode: settings.sandboxWarmBillingMode,
|
|
542
838
|
})
|
|
543
|
-
.then(async (
|
|
544
|
-
if (
|
|
839
|
+
.then(async (status) => {
|
|
840
|
+
if (status.fence === "funding") {
|
|
841
|
+
stopLeaseHeartbeat();
|
|
842
|
+
sandboxRotationController.abort(
|
|
843
|
+
new Error("Insufficient Opengeni credits to extend paid sandbox compute"),
|
|
844
|
+
);
|
|
845
|
+
return;
|
|
846
|
+
}
|
|
847
|
+
if (status.leaseExtended) return;
|
|
545
848
|
const rotation = await beginRotationPreemption(sandbox, heartbeatEpoch, heartbeatGroupId);
|
|
546
849
|
if (rotation === "not_rotating") {
|
|
547
850
|
// The holder was reaped, the exact attempt closed, the epoch was
|
|
@@ -557,9 +860,14 @@ export function createSandboxTurnRuntime(deps: SandboxTurnRuntimeDeps) {
|
|
|
557
860
|
sandboxGroupId: heartbeatGroupId,
|
|
558
861
|
expectedEpoch: heartbeatEpoch,
|
|
559
862
|
warmRateMicrosPerSecond: warmRate,
|
|
863
|
+
billingMode: settings.sandboxWarmBillingMode,
|
|
560
864
|
subjectId: input.sessionId,
|
|
561
865
|
})
|
|
562
|
-
.then((result) =>
|
|
866
|
+
.then((result) => {
|
|
867
|
+
if (settings.sandboxWarmBillingMode === "credits") {
|
|
868
|
+
recordCreditMicros(observability, "usage", result.costMicros);
|
|
869
|
+
}
|
|
870
|
+
})
|
|
563
871
|
.catch(() => undefined);
|
|
564
872
|
// MID-SESSION snapshot (sandbox-file-persistence): while the turn holds
|
|
565
873
|
// the box, fold a fresh /workspace snapshot onto the lease every
|
|
@@ -0,0 +1,155 @@
|
|
|
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 { environmentsEncryptionKeyBytes, type Settings } from "@opengeni/config";
|
|
8
|
+
import {
|
|
9
|
+
VAULT_LIMITS,
|
|
10
|
+
type ResolvedAgentConfig,
|
|
11
|
+
type SecretPrincipal,
|
|
12
|
+
type SecretResolver,
|
|
13
|
+
} from "@opengeni/contracts";
|
|
14
|
+
import {
|
|
15
|
+
createSecretResolver,
|
|
16
|
+
createWorkspaceVaultProviderRegistry,
|
|
17
|
+
type OnePasswordVaultProviderFactory,
|
|
18
|
+
} from "@opengeni/core";
|
|
19
|
+
import { listVaultsForSubject, type Database } from "@opengeni/db";
|
|
20
|
+
import {
|
|
21
|
+
createProviderCallBudget,
|
|
22
|
+
type ProviderCallBudget,
|
|
23
|
+
type VaultProvider,
|
|
24
|
+
type VaultProviderRegistry,
|
|
25
|
+
} from "@opengeni/vaults";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Q-17: a frozen configuration without the key reads `from === "all"` (the
|
|
29
|
+
* contracts parse fills it); legacy null-config sessions get secrets on.
|
|
30
|
+
*/
|
|
31
|
+
export function secretsCapabilityEnabled(agentConfig: ResolvedAgentConfig | null | undefined) {
|
|
32
|
+
return agentConfig ? agentConfig.capabilities.secrets === true : true;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Connected-vault access for one attempt: the provider registry (1Password
|
|
37
|
+
* tokens load for the acting human, host vaults use the embedder port) and a
|
|
38
|
+
* single read budget shared by every resolver of the attempt (Q-18).
|
|
39
|
+
*/
|
|
40
|
+
export type AttemptVaultAccess = {
|
|
41
|
+
providers: VaultProviderRegistry;
|
|
42
|
+
attemptBudget: ProviderCallBudget;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export function createAttemptVaultAccess(input: {
|
|
46
|
+
db: Database;
|
|
47
|
+
settings: Settings;
|
|
48
|
+
workspaceId: string;
|
|
49
|
+
subjectId: string | null;
|
|
50
|
+
hostVaultProvider: VaultProvider | null | undefined;
|
|
51
|
+
onePasswordVaultProvider: OnePasswordVaultProviderFactory | null | undefined;
|
|
52
|
+
}): AttemptVaultAccess {
|
|
53
|
+
return {
|
|
54
|
+
providers: createWorkspaceVaultProviderRegistry({
|
|
55
|
+
db: input.db,
|
|
56
|
+
settings: input.settings,
|
|
57
|
+
workspaceId: input.workspaceId,
|
|
58
|
+
subjectId: input.subjectId,
|
|
59
|
+
hostVaultProvider: input.hostVaultProvider ?? null,
|
|
60
|
+
onePasswordVaultProvider: input.onePasswordVaultProvider ?? null,
|
|
61
|
+
}),
|
|
62
|
+
attemptBudget: createProviderCallBudget(VAULT_LIMITS.providerReadsPerAttempt),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
type AttemptSecretInput = {
|
|
67
|
+
db: Database;
|
|
68
|
+
settings: Settings;
|
|
69
|
+
agentConfig: ResolvedAgentConfig | null | undefined;
|
|
70
|
+
vaultAccess?: AttemptVaultAccess | undefined;
|
|
71
|
+
accountId: string;
|
|
72
|
+
workspaceId: string;
|
|
73
|
+
sessionId: string;
|
|
74
|
+
turnId: string;
|
|
75
|
+
attemptId: string;
|
|
76
|
+
executionGeneration: number;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
function attemptPrincipal(
|
|
80
|
+
input: Omit<AttemptSecretInput, "db" | "settings" | "agentConfig" | "vaultAccess">,
|
|
81
|
+
) {
|
|
82
|
+
return {
|
|
83
|
+
kind: "attempt",
|
|
84
|
+
accountId: input.accountId,
|
|
85
|
+
workspaceId: input.workspaceId,
|
|
86
|
+
sessionId: input.sessionId,
|
|
87
|
+
turnId: input.turnId,
|
|
88
|
+
attemptId: input.attemptId,
|
|
89
|
+
executionGeneration: input.executionGeneration,
|
|
90
|
+
} satisfies SecretPrincipal;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function attemptSecretResolver(input: AttemptSecretInput): SecretResolver {
|
|
94
|
+
return createSecretResolver(
|
|
95
|
+
{
|
|
96
|
+
db: input.db,
|
|
97
|
+
encryptionKey: environmentsEncryptionKeyBytes(input.settings) ?? null,
|
|
98
|
+
...(input.vaultAccess ? { providers: input.vaultAccess.providers } : {}),
|
|
99
|
+
},
|
|
100
|
+
attemptPrincipal(input),
|
|
101
|
+
{
|
|
102
|
+
capabilityEnabled: secretsCapabilityEnabled(input.agentConfig),
|
|
103
|
+
...(input.vaultAccess ? { attemptBudget: input.vaultAccess.attemptBudget } : {}),
|
|
104
|
+
},
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const SAVE_TO_OWNER = { user: "user", task: "task", workspace: "workspace" } as const;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Ask-card vault check (Q-05): a named vault must be reachable by this
|
|
112
|
+
* attempt, belong to the chosen saveTo scope, and be a writable Opengeni vault.
|
|
113
|
+
* Returns a model-facing reason, or null when the vault can take the answer.
|
|
114
|
+
*/
|
|
115
|
+
export function attemptQuestionVaultValidator(
|
|
116
|
+
input: Omit<AttemptSecretInput, "settings" | "agentConfig" | "vaultAccess">,
|
|
117
|
+
) {
|
|
118
|
+
return async ({
|
|
119
|
+
vault,
|
|
120
|
+
saveTo,
|
|
121
|
+
}: {
|
|
122
|
+
vault: string;
|
|
123
|
+
saveTo: "user" | "task" | "workspace";
|
|
124
|
+
}): Promise<string | null> => {
|
|
125
|
+
const vaults = await listVaultsForSubject(
|
|
126
|
+
input.db,
|
|
127
|
+
{ kind: "principal", principal: attemptPrincipal(input) },
|
|
128
|
+
{ workspaceId: input.workspaceId },
|
|
129
|
+
);
|
|
130
|
+
const wanted = vault.trim().toLowerCase();
|
|
131
|
+
const match = vaults.find((row) => row.name.trim().toLowerCase() === wanted);
|
|
132
|
+
if (!match) return "No vault with that name is reachable from this task.";
|
|
133
|
+
if (match.source !== "opengeni" || match.mode !== "read_write") {
|
|
134
|
+
return "It is a connected or read-only vault, so answers cannot be saved there.";
|
|
135
|
+
}
|
|
136
|
+
if (match.ownerKind !== SAVE_TO_OWNER[saveTo]) {
|
|
137
|
+
return `It is not a "${saveTo}" vault.`;
|
|
138
|
+
}
|
|
139
|
+
return null;
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Exec-boundary resolver (W1 delivery). Same attempt principal and capability
|
|
145
|
+
* gate as every other surface; kept as a named entry point for the sandbox
|
|
146
|
+
* tool wiring in agent-build.
|
|
147
|
+
*/
|
|
148
|
+
export function createAttemptSecretResolver(
|
|
149
|
+
input: Omit<AttemptSecretInput, "agentConfig"> & {
|
|
150
|
+
agent: ResolvedAgentConfig | null | undefined;
|
|
151
|
+
},
|
|
152
|
+
): SecretResolver {
|
|
153
|
+
const { agent, ...rest } = input;
|
|
154
|
+
return attemptSecretResolver({ ...rest, agentConfig: agent });
|
|
155
|
+
}
|