@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.
- 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 +172 -28
- 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 +3 -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 +30 -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-NTXZHYET.js} +1552 -2876
- package/dist/activities-control-NTXZHYET.js.map +1 -0
- package/dist/activities-control.d.ts +64 -4
- package/dist/{activities-turn-YVVKCGAK.js → activities-turn-RKRI5GY4.js} +9238 -4392
- package/dist/activities-turn-RKRI5GY4.js.map +1 -0
- package/dist/activities.d.ts +64 -4
- package/dist/artifact-materializer-entry.js +104 -35
- 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-M3NVMF2V.js → chunk-7BIHFUGB.js} +2293 -3956
- package/dist/chunk-7BIHFUGB.js.map +1 -0
- package/dist/chunk-MVESOYFC.js +3746 -0
- package/dist/chunk-MVESOYFC.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 +1134 -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 +26 -4
- 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 +94 -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 +599 -110
- 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 +162 -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 +116 -9
- package/src/activities/sandbox-lease.ts +1615 -73
- package/src/activities/scheduled-tasks.ts +758 -141
- 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 +79 -38
- 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
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** One durable, same-logical-turn handoff, not a retry of model/tool effects. */
|
|
2
|
+
export function finalReplyNudge(turnId: string) {
|
|
3
|
+
return {
|
|
4
|
+
type: "message" as const,
|
|
5
|
+
role: "developer" as const,
|
|
6
|
+
content: [
|
|
7
|
+
{
|
|
8
|
+
type: "input_text" as const,
|
|
9
|
+
text: `[Runtime final-reply handoff for turn ${turnId}]\nYour final user-facing answer was empty. Reply to the user now with the requested deliverable or a concise outcome and its retained artifact link. Goal evidence is a short ledger proof, not the answer, and goal_complete does not deliver a chat reply. Use the completed work and tool results already in history; do not repeat completed tools or restart the task. If this is a late child result after goal completion, integrate material new findings and deliver any still-missing handoff. Do not change the completed goal or invent a result.`,
|
|
10
|
+
},
|
|
11
|
+
],
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function hasFinalReplyNudge(history: readonly unknown[], turnId: string): boolean {
|
|
16
|
+
const text = finalReplyNudge(turnId).content[0]!.text;
|
|
17
|
+
return history.some((item) => {
|
|
18
|
+
const message = item as { role?: unknown; content?: unknown } | null;
|
|
19
|
+
return (
|
|
20
|
+
message?.role === "developer" &&
|
|
21
|
+
Array.isArray(message.content) &&
|
|
22
|
+
message.content.some(
|
|
23
|
+
(part: { type?: unknown; text?: unknown }) =>
|
|
24
|
+
part?.type === "input_text" && part.text === text,
|
|
25
|
+
)
|
|
26
|
+
);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function needsFinalReply(input: {
|
|
31
|
+
output: unknown;
|
|
32
|
+
inputWaitYielded: boolean;
|
|
33
|
+
interrupted: boolean;
|
|
34
|
+
maintenance: boolean;
|
|
35
|
+
toolsExecuted: boolean;
|
|
36
|
+
completedGoal: boolean;
|
|
37
|
+
}): boolean {
|
|
38
|
+
return (
|
|
39
|
+
typeof input.output === "string" &&
|
|
40
|
+
input.output.trim().length === 0 &&
|
|
41
|
+
!input.inputWaitYielded &&
|
|
42
|
+
!input.interrupted &&
|
|
43
|
+
!input.maintenance &&
|
|
44
|
+
(input.toolsExecuted || input.completedGoal)
|
|
45
|
+
);
|
|
46
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { turnExecutionTelemetryKey, type Observability } from "@opengeni/observability";
|
|
2
2
|
import type { TurnHeartbeatDetails } from "../../op-journal";
|
|
3
3
|
import { armTurnQuiescenceWatchdog } from "./quiescence";
|
|
4
4
|
|
|
@@ -41,11 +41,22 @@ export function startTurnFinalizationMonitor(input: {
|
|
|
41
41
|
observability: Observability;
|
|
42
42
|
details: TurnHeartbeatDetails;
|
|
43
43
|
heartbeat: (details: TurnHeartbeatDetails) => void;
|
|
44
|
-
|
|
44
|
+
requestWorkerDrain: () => void;
|
|
45
|
+
execution?: { workspaceId: string; sessionId: string; attemptId: string };
|
|
45
46
|
timeoutMs?: number;
|
|
46
47
|
slowAfterMs?: number;
|
|
47
48
|
}) {
|
|
48
49
|
const { observability, details } = input;
|
|
50
|
+
const correlation: { correlationId?: string } = {};
|
|
51
|
+
diagnose(() => {
|
|
52
|
+
if (input.execution) {
|
|
53
|
+
correlation.correlationId = turnExecutionTelemetryKey(
|
|
54
|
+
input.execution.workspaceId,
|
|
55
|
+
input.execution.sessionId,
|
|
56
|
+
input.execution.attemptId,
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
49
60
|
if (!initialized.has(observability)) {
|
|
50
61
|
for (const stage of TURN_FINALIZATION_STAGES) {
|
|
51
62
|
diagnose(() => observability.incrementGauge({ ...INFLIGHT, labels: { stage }, amount: 0 }));
|
|
@@ -88,15 +99,15 @@ export function startTurnFinalizationMonitor(input: {
|
|
|
88
99
|
surface: "turn_finalization",
|
|
89
100
|
outcome: "containment",
|
|
90
101
|
reason: next,
|
|
102
|
+
...correlation,
|
|
91
103
|
});
|
|
92
104
|
} catch {
|
|
93
105
|
// Diagnostic failure must never disable physical containment.
|
|
94
106
|
}
|
|
95
107
|
},
|
|
96
|
-
terminateWorker: input.
|
|
108
|
+
terminateWorker: input.requestWorkerDrain,
|
|
97
109
|
});
|
|
98
|
-
// Record the precursor while the process remains scrapeable.
|
|
99
|
-
// increment immediately before process.exit can never reach Prometheus.
|
|
110
|
+
// Record the precursor while the process remains scrapeable.
|
|
100
111
|
slowTimer = setTimeout(
|
|
101
112
|
() =>
|
|
102
113
|
diagnose(() => {
|
|
@@ -105,6 +116,7 @@ export function startTurnFinalizationMonitor(input: {
|
|
|
105
116
|
surface: "turn_finalization",
|
|
106
117
|
outcome: "slow",
|
|
107
118
|
reason: next,
|
|
119
|
+
...correlation,
|
|
108
120
|
});
|
|
109
121
|
}),
|
|
110
122
|
input.slowAfterMs ?? 30_000,
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
commitSessionAttemptQuiescence,
|
|
3
3
|
listPendingSessionTurns,
|
|
4
|
-
recordCodexAccountUsageForFinalization,
|
|
5
|
-
releaseCodexCredentialLease,
|
|
6
|
-
releaseXaiCredentialLease,
|
|
7
|
-
updateXaiQuotaMetadata,
|
|
8
4
|
type SessionAttemptQuiescenceCommit,
|
|
9
5
|
} from "@opengeni/db";
|
|
10
6
|
import { appendAndPublishTurnEventsFenced, publishDurableSessionEvents } from "@opengeni/events";
|
|
11
7
|
import { sandboxLeaseTelemetryKey } from "@opengeni/observability";
|
|
12
8
|
import { clearRunCredentialsForAttempt } from "@opengeni/runtime";
|
|
13
|
-
import { fetchXaiSubscriptionQuota } from "@opengeni/xai-subscription";
|
|
14
9
|
import type { Settings } from "@opengeni/config";
|
|
15
|
-
|
|
10
|
+
|
|
16
11
|
import { startActivityHeartbeat, type currentActivityContext } from "../streaming";
|
|
17
12
|
import { startTurnFinalizationMonitor } from "./finalization-monitor";
|
|
18
13
|
import type { CodemodeTokenRenewalController } from "../codemode-token-renewal";
|
|
@@ -41,6 +36,12 @@ import {
|
|
|
41
36
|
type ResumedTurnSandbox,
|
|
42
37
|
} from "../../sandbox-resume";
|
|
43
38
|
import { createTurnCredentialLeases } from "./credential-leases";
|
|
39
|
+
import { coreCodexModelCallCompletedAt, finalizeCoreCodexUsage } from "./codex-core-settlement";
|
|
40
|
+
import { finalizeCoreSubscriptionTurn } from "./subscription-core-settlement";
|
|
41
|
+
import { XAI_CORE_REFUSAL } from "./xai-core";
|
|
42
|
+
import { wakeSubscriptionCoreCodexWaitersAndDeliver } from "../subscription-core-codex-waits";
|
|
43
|
+
import { finalizeCoreClaudeTurn } from "./claude-core";
|
|
44
|
+
import { drainPhysicalSandboxResumes } from "./sandbox-provision";
|
|
44
45
|
import { safeErrorDiagnostic, safeErrorForTelemetry } from "./errors";
|
|
45
46
|
import {
|
|
46
47
|
assertPhysicalToolQuiescenceForCancellation,
|
|
@@ -73,6 +74,8 @@ export type TurnFinalizationDeps = {
|
|
|
73
74
|
wakeSessionWorkflow: ActivityServices["wakeSessionWorkflow"];
|
|
74
75
|
signalSessionAttemptQuiesced: ActivityServices["signalSessionAttemptQuiesced"];
|
|
75
76
|
signalCodexCapacityWorkflow: ActivityServices["signalCodexCapacityWorkflow"];
|
|
77
|
+
requestWorkerDrain: ActivityServices["requestWorkerDrain"];
|
|
78
|
+
turnFinalizationTimeoutMs: ActivityServices["turnFinalizationTimeoutMs"];
|
|
76
79
|
cancellationSignal: AbortSignal | undefined;
|
|
77
80
|
sandboxResumeController: AbortController;
|
|
78
81
|
activityContext: ReturnType<typeof currentActivityContext>;
|
|
@@ -112,6 +115,9 @@ export async function finalizeTurnAttempt(deps: TurnFinalizationDeps): Promise<v
|
|
|
112
115
|
deps.eventing.heartbeatTimer = startActivityHeartbeat(deps.activityContext, details);
|
|
113
116
|
const monitor = startTurnFinalizationMonitor({
|
|
114
117
|
observability: deps.observability,
|
|
118
|
+
...(deps.turnFinalizationTimeoutMs === undefined
|
|
119
|
+
? {}
|
|
120
|
+
: { timeoutMs: deps.turnFinalizationTimeoutMs }),
|
|
115
121
|
details,
|
|
116
122
|
heartbeat: (value) => {
|
|
117
123
|
try {
|
|
@@ -120,7 +126,12 @@ export async function finalizeTurnAttempt(deps: TurnFinalizationDeps): Promise<v
|
|
|
120
126
|
// A closed Temporal transport is not proof of physical quiescence.
|
|
121
127
|
}
|
|
122
128
|
},
|
|
123
|
-
|
|
129
|
+
requestWorkerDrain: deps.requestWorkerDrain,
|
|
130
|
+
execution: {
|
|
131
|
+
workspaceId: deps.input.workspaceId,
|
|
132
|
+
sessionId: deps.input.sessionId,
|
|
133
|
+
attemptId: deps.input.attemptId,
|
|
134
|
+
},
|
|
124
135
|
});
|
|
125
136
|
try {
|
|
126
137
|
monitor.enter("tool_writers");
|
|
@@ -213,6 +224,8 @@ async function finalizeTurnAttemptSteps(
|
|
|
213
224
|
renewals.codemodeTokenRenewal as CodemodeTokenRenewalController | null;
|
|
214
225
|
renewals.codemodeTokenRenewal = null;
|
|
215
226
|
renewals.runCredentialRenewalClosed = true;
|
|
227
|
+
renewals.runMcpCredentials?.close();
|
|
228
|
+
delete renewals.runMcpCredentials;
|
|
216
229
|
const runRenewalToStop = renewals.runCredentialRenewal as RunCredentialRenewalController | null;
|
|
217
230
|
renewals.runCredentialRenewal = null;
|
|
218
231
|
|
|
@@ -232,6 +245,22 @@ async function finalizeTurnAttemptSteps(
|
|
|
232
245
|
codemodeTokenRenewal: codemodeRenewalToStop,
|
|
233
246
|
runCredentialRenewal: runRenewalToStop,
|
|
234
247
|
});
|
|
248
|
+
// W1 / SEC-4: remove this attempt's secret files (`secretfile` paths and
|
|
249
|
+
// any leftover env file) once every writer has drained. Best effort: the
|
|
250
|
+
// files are 0600 under a 0700 attempt directory and a later attempt never
|
|
251
|
+
// reads them, so a failure is logged rather than holding the receipt.
|
|
252
|
+
if (toolCancellationFence?.clearSecretFiles) {
|
|
253
|
+
monitor.enter("credential_cleanup");
|
|
254
|
+
try {
|
|
255
|
+
await toolCancellationFence.clearSecretFiles();
|
|
256
|
+
} catch (error) {
|
|
257
|
+
observability.warn("attempt secret file cleanup failed", {
|
|
258
|
+
"opengeni.session_id": input.sessionId,
|
|
259
|
+
"opengeni.attempt_id": input.attemptId,
|
|
260
|
+
"error.type": error instanceof Error ? error.name : "unknown",
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
}
|
|
235
264
|
// Attempt-qualified credential deletion is also a real workspace write,
|
|
236
265
|
// but it must not be submitted behind the very command being cancelled.
|
|
237
266
|
// Drain tool processes and credential renewals first, then delete only this
|
|
@@ -408,44 +437,33 @@ async function finalizeTurnAttemptSteps(
|
|
|
408
437
|
// best-effort (same discipline as today's usage write). Both writers skip
|
|
409
438
|
// version/updatedAt, so neither can race the token-refresh CAS.
|
|
410
439
|
monitor.enter("provider_leases");
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
//
|
|
414
|
-
//
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
leases.codex.holderId &&
|
|
420
|
-
leases.codex.generation !== null &&
|
|
421
|
-
providerTurn.effectiveCodexCredentialVersion !== null
|
|
422
|
-
) {
|
|
423
|
-
const usageMutation = await waitForTurnFinalizerStep(
|
|
424
|
-
recordCodexAccountUsageForFinalization(
|
|
440
|
+
const coreCodex = providerTurn.codexSubscriptionCore;
|
|
441
|
+
if (coreCodex) {
|
|
442
|
+
// Shared-core turn: usage headers become a quota observation on the
|
|
443
|
+
// leased connection and a completed model call advances the binding's
|
|
444
|
+
// cache clock. The legacy Codex usage cache never sees a core id.
|
|
445
|
+
if (attempt.turnId && leases.codex.held) {
|
|
446
|
+
const finalized = await waitForTurnFinalizerStep(
|
|
447
|
+
finalizeCoreCodexUsage({
|
|
425
448
|
db,
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
providerTurn.latestCodexUsage,
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
attemptId: input.attemptId,
|
|
433
|
-
executionGeneration: attempt.executionGeneration,
|
|
434
|
-
holderId: leases.codex.holderId,
|
|
435
|
-
generation: leases.codex.generation,
|
|
436
|
-
credentialVersion: providerTurn.effectiveCodexCredentialVersion,
|
|
437
|
-
},
|
|
438
|
-
).catch(() => null),
|
|
449
|
+
core: coreCodex,
|
|
450
|
+
lease: leases.codex,
|
|
451
|
+
usage: providerTurn.latestCodexUsage,
|
|
452
|
+
credentialVersion: providerTurn.effectiveCodexCredentialVersion,
|
|
453
|
+
modelCallCompletedAt: coreCodexModelCallCompletedAt(providerTurn),
|
|
454
|
+
}).catch(() => undefined),
|
|
439
455
|
finalizerSignal,
|
|
440
456
|
);
|
|
441
|
-
|
|
457
|
+
// An observation that ended a stored exhaustion is a capacity change
|
|
458
|
+
// for every core waiter of the account (EP-T10).
|
|
459
|
+
if (finalized?.capacityRecovered) {
|
|
442
460
|
await waitForTurnFinalizerStep(
|
|
443
|
-
|
|
444
|
-
{
|
|
445
|
-
|
|
461
|
+
wakeSubscriptionCoreCodexWaitersAndDeliver(
|
|
462
|
+
{ db, signalCodexCapacityWorkflow },
|
|
463
|
+
{ accountId: input.accountId, reason: "quota_observed_available" },
|
|
446
464
|
),
|
|
447
465
|
finalizerSignal,
|
|
448
|
-
);
|
|
466
|
+
).catch(() => undefined);
|
|
449
467
|
}
|
|
450
468
|
}
|
|
451
469
|
}
|
|
@@ -457,66 +475,52 @@ async function finalizeTurnAttemptSteps(
|
|
|
457
475
|
leases.codex.generation !== null
|
|
458
476
|
) {
|
|
459
477
|
await waitForTurnFinalizerStep(
|
|
460
|
-
|
|
461
|
-
db,
|
|
462
|
-
input.accountId,
|
|
463
|
-
input.workspaceId,
|
|
464
|
-
attempt.turnId,
|
|
465
|
-
leases.codex.holderId,
|
|
466
|
-
leases.codex.generation,
|
|
467
|
-
).catch(() => undefined),
|
|
478
|
+
leases.codex.releaseCurrent().catch(() => false),
|
|
468
479
|
finalizerSignal,
|
|
469
480
|
);
|
|
470
481
|
leases.codex.held = false;
|
|
471
482
|
}
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
483
|
+
// A core-placed SuperGrok turn moves its binding's cache clock after a
|
|
484
|
+
// completed model call, then releases its core lease (SuperGrok has no
|
|
485
|
+
// legacy lease after its cutover).
|
|
486
|
+
if (providerTurn.xaiSubscriptionCore && leases.xai.held && attempt.turnId) {
|
|
487
|
+
await waitForTurnFinalizerStep(
|
|
488
|
+
finalizeCoreSubscriptionTurn({
|
|
489
|
+
db,
|
|
490
|
+
provider: XAI_CORE_REFUSAL.provider,
|
|
491
|
+
core: providerTurn.xaiSubscriptionCore,
|
|
492
|
+
lease: leases.xai,
|
|
493
|
+
}).catch(() => undefined),
|
|
480
494
|
finalizerSignal,
|
|
481
495
|
);
|
|
482
|
-
|
|
483
|
-
await waitForTurnFinalizerStep(
|
|
484
|
-
updateXaiQuotaMetadata(db, {
|
|
485
|
-
workspaceId: input.workspaceId,
|
|
486
|
-
subjectId: leases.xai.subjectId,
|
|
487
|
-
credentialId: providerTurn.effectiveXaiCredentialId,
|
|
488
|
-
quotaUsedPercent: quota.usedPercent,
|
|
489
|
-
quotaResetAt: quota.period?.end ?? null,
|
|
490
|
-
quotaCheckedAt: quota.checkedAt,
|
|
491
|
-
exhaustedUntil:
|
|
492
|
-
quota.usedPercent !== null && quota.usedPercent >= 100
|
|
493
|
-
? (quota.period?.end ?? null)
|
|
494
|
-
: null,
|
|
495
|
-
}).catch(() => undefined),
|
|
496
|
-
finalizerSignal,
|
|
497
|
-
);
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
leases.xai.stopHeartbeat();
|
|
501
|
-
if (
|
|
502
|
-
leases.xai.held &&
|
|
503
|
-
attempt.turnId &&
|
|
504
|
-
leases.xai.subjectId &&
|
|
505
|
-
leases.xai.holderId &&
|
|
506
|
-
leases.xai.generation !== null
|
|
507
|
-
) {
|
|
496
|
+
leases.xai.stopHeartbeat();
|
|
508
497
|
await waitForTurnFinalizerStep(
|
|
509
|
-
|
|
510
|
-
workspaceId: input.workspaceId,
|
|
511
|
-
subjectId: leases.xai.subjectId,
|
|
512
|
-
turnId: attempt.turnId,
|
|
513
|
-
holderId: leases.xai.holderId,
|
|
514
|
-
generation: leases.xai.generation,
|
|
515
|
-
}).catch(() => undefined),
|
|
498
|
+
leases.xai.releaseCurrent().catch(() => false),
|
|
516
499
|
finalizerSignal,
|
|
517
500
|
);
|
|
518
501
|
leases.xai.held = false;
|
|
519
502
|
}
|
|
503
|
+
// The same for a Claude turn (always core-placed: the legacy Claude
|
|
504
|
+
// runtime, its usage receipts and its lease release are deleted).
|
|
505
|
+
if (providerTurn.claudeSubscriptionCore && leases.claude.held && attempt.turnId) {
|
|
506
|
+
// Queued quota writes still need this lease's fence. Cancellation and
|
|
507
|
+
// housekeeping timeouts may detach only the wake, never that write join.
|
|
508
|
+
// The provider_leases stage monitor contains a genuinely stuck join by
|
|
509
|
+
// requesting host drain; it must not manufacture completion/release.
|
|
510
|
+
await finalizeCoreClaudeTurn({
|
|
511
|
+
db,
|
|
512
|
+
signalCodexCapacityWorkflow,
|
|
513
|
+
core: providerTurn.claudeSubscriptionCore,
|
|
514
|
+
lease: leases.claude,
|
|
515
|
+
signal: finalizerSignal,
|
|
516
|
+
}).catch(() => undefined);
|
|
517
|
+
leases.claude.stopHeartbeat();
|
|
518
|
+
await waitForTurnFinalizerStep(
|
|
519
|
+
leases.claude.releaseCurrent().catch(() => false),
|
|
520
|
+
finalizerSignal,
|
|
521
|
+
);
|
|
522
|
+
leases.claude.held = false;
|
|
523
|
+
}
|
|
520
524
|
// Workbench v2 turn-end workspace capture — runs FIRST in
|
|
521
525
|
// the turn-end finally, while the box is MAXIMALLY ALIVE. The agent's last
|
|
522
526
|
// tool ran before this finally, so /workspace is already final; capture is
|
|
@@ -728,6 +732,21 @@ async function finalizeTurnAttemptSteps(
|
|
|
728
732
|
}
|
|
729
733
|
monitor.enter("workspace_snapshot");
|
|
730
734
|
await drainInFlightWarmSnapshot();
|
|
735
|
+
// Join any provider establish still running behind a cancelled wrapper
|
|
736
|
+
// (finalization already aborted provisioning when no box resolved). Its
|
|
737
|
+
// own exact cleanup (roll an unpublished box back to cold, or keep a
|
|
738
|
+
// published box and drop its holder) must commit before this activity can
|
|
739
|
+
// let a shutting-down worker exit. A late success is routed through
|
|
740
|
+
// releaseLateSandbox before the release targets are collected below.
|
|
741
|
+
monitor.enter("sandbox_provisioning");
|
|
742
|
+
if (sandboxState.inFlightSandboxResumes.size > 0) {
|
|
743
|
+
const drained = await drainPhysicalSandboxResumes(sandboxState.inFlightSandboxResumes);
|
|
744
|
+
if (drained === "timed_out") {
|
|
745
|
+
console.error(
|
|
746
|
+
"in-flight sandbox establish did not settle before finalization; the lease reaper owns its warming row",
|
|
747
|
+
);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
731
750
|
monitor.enter("sandbox_release");
|
|
732
751
|
const sandboxReleaseTargets = new Set(sandboxState.lateSandboxesAwaitingWriterDrain);
|
|
733
752
|
sandboxState.lateSandboxesAwaitingWriterDrain.clear();
|
|
@@ -229,6 +229,8 @@ export type ApplyTurnGitHubRepositoryBindingsInput = {
|
|
|
229
229
|
workspaceId: string;
|
|
230
230
|
sessionId: string;
|
|
231
231
|
activeSandboxBackend: Settings["sandboxBackend"] | undefined;
|
|
232
|
+
/** Product-owned credentials take precedence over inferred platform bindings. */
|
|
233
|
+
hasCredentialProvider?: boolean;
|
|
232
234
|
claimedTurnResources: readonly ResourceRef[];
|
|
233
235
|
claimedRuntimeResources: readonly ResourceRef[];
|
|
234
236
|
/** Publishes one attempt-fenced session event batch. */
|
|
@@ -258,7 +260,7 @@ export async function applyTurnGitHubRepositoryBindings(
|
|
|
258
260
|
turnResources: [...input.claimedTurnResources],
|
|
259
261
|
runtimeResources: [...input.claimedRuntimeResources],
|
|
260
262
|
};
|
|
261
|
-
if (input.activeSandboxBackend === "selfhosted") {
|
|
263
|
+
if (input.activeSandboxBackend === "selfhosted" || input.hasCredentialProvider) {
|
|
262
264
|
return passthrough;
|
|
263
265
|
}
|
|
264
266
|
let resolved: TurnGitHubRepositoryBindings;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
materializeRigVersionForAttempt,
|
|
3
3
|
getWorkspaceModelPolicy,
|
|
4
|
+
getOrganizationModelDefaults,
|
|
4
5
|
getFilesForSubject,
|
|
5
6
|
getWorkspace,
|
|
6
7
|
resolveCompanyBrainContextSelection,
|
|
@@ -11,6 +12,7 @@ import {
|
|
|
11
12
|
getOrCreateWorkspaceInstructionPolicySnapshot,
|
|
12
13
|
PreferenceRegistryInitiatorError,
|
|
13
14
|
resolveSessionAttemptPersonalResources,
|
|
15
|
+
freezeAgentLearningPolicy,
|
|
14
16
|
} from "@opengeni/db";
|
|
15
17
|
import {
|
|
16
18
|
projectHistoryForProvider,
|
|
@@ -20,10 +22,15 @@ import {
|
|
|
20
22
|
renderWorkspaceGovernanceContext,
|
|
21
23
|
type OpenGeniRuntime,
|
|
22
24
|
} from "@opengeni/runtime";
|
|
23
|
-
import {
|
|
25
|
+
import {
|
|
26
|
+
codeSearchDeploymentPolicy,
|
|
27
|
+
policyChargesCreditsForModel,
|
|
28
|
+
settingsWithResolvedModelContext,
|
|
29
|
+
type Settings,
|
|
30
|
+
} from "@opengeni/config";
|
|
24
31
|
import { projectReasoningConfigurations, supportsReasoningConfiguration } from "@opengeni/codex";
|
|
25
32
|
import { settingsWithSessionMcpServersForRun } from "../capabilities";
|
|
26
|
-
import { resolveRigProviderImageForRun } from "@opengeni/core";
|
|
33
|
+
import { resolveRigProviderImageForRun, settingsWithWorkspaceSandboxImage } from "@opengeni/core";
|
|
27
34
|
import { createModelHistoryAttachmentProjector } from "../run-input";
|
|
28
35
|
import type {
|
|
29
36
|
TurnActivityServices as ActivityServices,
|
|
@@ -40,26 +47,32 @@ import {
|
|
|
40
47
|
} from "../generated-images";
|
|
41
48
|
import { createTurnMediaArtifacts } from "./media-artifacts";
|
|
42
49
|
import { retryWhileMissing } from "@opengeni/storage";
|
|
50
|
+
import { measureTurnStartupPhase } from "../../observability-metrics";
|
|
43
51
|
import { WorkspaceModelPolicyBlockedError } from "@opengeni/runtime";
|
|
44
52
|
import {
|
|
45
53
|
evaluateWorkspaceModelPolicy,
|
|
46
54
|
resolveWorkspaceAgentHumanInputEnabled,
|
|
55
|
+
resolveWorkspaceDefaultAgentIdentity,
|
|
47
56
|
type MediaGenerationResult,
|
|
48
57
|
} from "@opengeni/contracts";
|
|
58
|
+
import { codeSearchEnabledForTurn } from "@opengeni/contracts/code-search";
|
|
49
59
|
|
|
50
60
|
import { assertWorkspaceHumanInputAllowed } from "./admission";
|
|
51
61
|
import {
|
|
52
62
|
lazyToolTransportForTurn,
|
|
53
63
|
openAiHostedImageProviderBindingForTurn,
|
|
54
64
|
modelAttachmentInputPolicyForTurn,
|
|
65
|
+
resolveAcceptedTurnModel,
|
|
55
66
|
} from "./tool-policy";
|
|
56
67
|
|
|
57
68
|
import type { ClaimTurnOk } from "./claim";
|
|
58
69
|
import type { EventingState, WorkspaceRefState } from "./turn-context";
|
|
59
70
|
|
|
60
71
|
export type GovernanceModelDeps = {
|
|
72
|
+
learningPolicy: Awaited<ReturnType<typeof freezeAgentLearningPolicy>>;
|
|
61
73
|
input: RunAgentTurnInput;
|
|
62
74
|
db: ActivityServices["db"];
|
|
75
|
+
observability: ActivityServices["observability"];
|
|
63
76
|
runtime: ActivityServices["runtime"];
|
|
64
77
|
objectStorage: ActivityServices["objectStorage"];
|
|
65
78
|
eventing: EventingState;
|
|
@@ -89,9 +102,19 @@ export type GovernanceModelOk = {
|
|
|
89
102
|
| null;
|
|
90
103
|
rigName: string | null;
|
|
91
104
|
agentHumanInputEnabled: boolean;
|
|
105
|
+
/** Deployment and workspace allow the Jev-backed code_search tool. */
|
|
106
|
+
codeSearchEnabled: boolean;
|
|
92
107
|
workspaceAgentInstructions: string | null | undefined;
|
|
108
|
+
/**
|
|
109
|
+
* Modular composer identity tier: the explicit workspace default identity,
|
|
110
|
+
* else the frozen legacy persona without `{{core}}`. Never dropped by
|
|
111
|
+
* instruction policies (only read for sessions with an agent configuration).
|
|
112
|
+
*/
|
|
113
|
+
workspaceAgentIdentity: string | null;
|
|
93
114
|
workspaceGovernance: ReturnType<typeof renderWorkspaceGovernanceContext>;
|
|
94
115
|
structuredWorkspacePolicyActive: boolean;
|
|
116
|
+
/** False when the workspace turned Opengeni credits off (model policy). */
|
|
117
|
+
workspaceCreditModelsAllowed: boolean;
|
|
95
118
|
workspaceMemory: string | null | undefined;
|
|
96
119
|
buildCompanyBrainContributionReceiptFor: (
|
|
97
120
|
skillCatalogText: string,
|
|
@@ -154,6 +177,7 @@ export async function prepareGovernanceAndModel(
|
|
|
154
177
|
const {
|
|
155
178
|
input,
|
|
156
179
|
db,
|
|
180
|
+
observability,
|
|
157
181
|
runtime,
|
|
158
182
|
objectStorage,
|
|
159
183
|
eventing,
|
|
@@ -196,6 +220,7 @@ export async function prepareGovernanceAndModel(
|
|
|
196
220
|
rigMaterialization,
|
|
197
221
|
[workspace, companyProfileSnapshot, instructionPolicySnapshot, preferenceSnapshot],
|
|
198
222
|
workspaceModelPolicy,
|
|
223
|
+
organizationModelDefaults,
|
|
199
224
|
] = await Promise.all([
|
|
200
225
|
session.rigId && session.rigVersionId
|
|
201
226
|
? (async () =>
|
|
@@ -219,6 +244,7 @@ export async function prepareGovernanceAndModel(
|
|
|
219
244
|
),
|
|
220
245
|
]),
|
|
221
246
|
getWorkspaceModelPolicy(db, input.workspaceId),
|
|
247
|
+
getOrganizationModelDefaults(db, input.accountId),
|
|
222
248
|
]);
|
|
223
249
|
const rigVersion = rigMaterialization?.version ?? null;
|
|
224
250
|
// Rig display name for the doctrine block + setup events/errors (only on a
|
|
@@ -230,13 +256,26 @@ export async function prepareGovernanceAndModel(
|
|
|
230
256
|
workspaceRefs.rigVersionId = session.rigVersionId ?? "";
|
|
231
257
|
if (!workspace) throw new Error(`Workspace not found: ${input.workspaceId}`);
|
|
232
258
|
const agentHumanInputEnabled = resolveWorkspaceAgentHumanInputEnabled(workspace.settings);
|
|
259
|
+
// The session's decision was frozen when it was created, so only a
|
|
260
|
+
// deliberate switch-off (deployment or workspace Off), or undoing one,
|
|
261
|
+
// changes its tool list.
|
|
262
|
+
const codeSearchEnabled = codeSearchEnabledForTurn(
|
|
263
|
+
session.codeSearchEnabled,
|
|
264
|
+
workspace.settings,
|
|
265
|
+
codeSearchDeploymentPolicy(capabilitySettings),
|
|
266
|
+
);
|
|
233
267
|
const contextSelection = await resolveCompanyBrainContextSelection(db, governanceClaims);
|
|
234
268
|
const workspaceAgentInstructions = contextSelection.legacyWorkspaceInstructions;
|
|
269
|
+
const workspaceAgentIdentity = resolveWorkspaceDefaultAgentIdentity(
|
|
270
|
+
workspace.settings,
|
|
271
|
+
workspaceAgentInstructions,
|
|
272
|
+
).identity;
|
|
235
273
|
const memoryPromptMode = contextSelection.receipt.memoryPromptMode;
|
|
236
274
|
assertWorkspaceHumanInputAllowed(agentHumanInputEnabled, "resume", humanInputResume !== null);
|
|
237
275
|
const companyProfileIncluded = contextSelection.receipt.companyProfileIncluded;
|
|
238
276
|
const workspaceGovernance = renderWorkspaceGovernanceContext(
|
|
239
277
|
{
|
|
278
|
+
learningPolicy: deps.learningPolicy,
|
|
240
279
|
companyProfile: companyProfileSnapshot,
|
|
241
280
|
instructionPolicy: instructionPolicySnapshot,
|
|
242
281
|
preferences: preferenceSnapshot,
|
|
@@ -276,8 +315,13 @@ export async function prepareGovernanceAndModel(
|
|
|
276
315
|
} catch {
|
|
277
316
|
// Contribution telemetry must never change model execution semantics.
|
|
278
317
|
}
|
|
279
|
-
// A Rig is always a setup/check layer over the deployment platform sandbox
|
|
280
|
-
|
|
318
|
+
// A Rig is always a setup/check layer over the deployment platform sandbox,
|
|
319
|
+
// or over the workspace's allowlisted selection of one.
|
|
320
|
+
const logicalSandboxSettings = settingsWithWorkspaceSandboxImage(
|
|
321
|
+
capabilitySettings,
|
|
322
|
+
workspace.settings,
|
|
323
|
+
turn.sandboxBackend,
|
|
324
|
+
);
|
|
281
325
|
const providerImageSelection = await resolveRigProviderImageForRun(
|
|
282
326
|
logicalSandboxSettings,
|
|
283
327
|
rigVersion,
|
|
@@ -293,16 +337,25 @@ export async function prepareGovernanceAndModel(
|
|
|
293
337
|
// provider-native ID is applied only to fresh creation without
|
|
294
338
|
// changing the logical lease image.
|
|
295
339
|
...providerImageSettings,
|
|
296
|
-
openaiModel:
|
|
297
|
-
openaiReasoningEffort:
|
|
340
|
+
openaiModel: turnExecutionPolicy.productModelId,
|
|
341
|
+
openaiReasoningEffort: turnExecutionPolicy.reasoningEffort,
|
|
298
342
|
sandboxBackend: turn.sandboxBackend,
|
|
299
343
|
};
|
|
300
|
-
const runSettings = await
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
344
|
+
const runSettings = await measureTurnStartupPhase(
|
|
345
|
+
observability,
|
|
346
|
+
{
|
|
347
|
+
phase: "session_mcp_settings",
|
|
348
|
+
provider: turnExecutionPolicy.providerId,
|
|
349
|
+
backend: turn.sandboxBackend,
|
|
350
|
+
},
|
|
351
|
+
() =>
|
|
352
|
+
settingsWithSessionMcpServersForRun(
|
|
353
|
+
db,
|
|
354
|
+
input.workspaceId,
|
|
355
|
+
input.sessionId,
|
|
356
|
+
input.attemptId,
|
|
357
|
+
baseRunSettings,
|
|
358
|
+
),
|
|
306
359
|
);
|
|
307
360
|
|
|
308
361
|
// Multi-provider per-turn routing → the provider gating (compaction mode,
|
|
@@ -318,10 +371,11 @@ export async function prepareGovernanceAndModel(
|
|
|
318
371
|
// a chat-only Fireworks model. Resolving against the default-model settings
|
|
319
372
|
// keeps gating consistent with the router. Cost accounting covers registry
|
|
320
373
|
// models via configuredModelPricing.
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
374
|
+
//
|
|
375
|
+
// The accepted policy is then projected back onto the resolved shape: a
|
|
376
|
+
// turn frozen before hosted web search was enabled keeps its frozen tool set
|
|
377
|
+
// on every attempt, so recovery never adds a tool mid-turn.
|
|
378
|
+
const resolvedModel = resolveAcceptedTurnModel(runtime, capabilitySettings, turnExecutionPolicy);
|
|
325
379
|
const providerApi = resolvedModel?.provider.api ?? "responses";
|
|
326
380
|
const nativeImageProviderBinding =
|
|
327
381
|
providerApi === "responses"
|
|
@@ -329,10 +383,8 @@ export async function prepareGovernanceAndModel(
|
|
|
329
383
|
: null;
|
|
330
384
|
const lazyToolTransport = lazyToolTransportForTurn(resolvedModel);
|
|
331
385
|
const modelInputPolicy = modelAttachmentInputPolicyForTurn(resolvedModel);
|
|
332
|
-
//
|
|
333
|
-
//
|
|
334
|
-
// image transport for that wire yet; exposing view_image there would turn
|
|
335
|
-
// pixels into a multi-megabyte text/base64 function result.
|
|
386
|
+
// The shared input policy combines model modality with the supported wire
|
|
387
|
+
// transport, including typed image projection for vision-capable Chat models.
|
|
336
388
|
const supportsImageInput = modelInputPolicy.supportsImageInput;
|
|
337
389
|
media.modelCanReceiveRetainedSessionImages = supportsImageInput;
|
|
338
390
|
const attachmentProjector = createModelHistoryAttachmentProjector(
|
|
@@ -358,7 +410,10 @@ export async function prepareGovernanceAndModel(
|
|
|
358
410
|
runSettings.reasoningConfigurationUpdatesEnabled &&
|
|
359
411
|
providerApi === "responses" &&
|
|
360
412
|
(resolvedModel?.provider.id === "codex" || resolvedModel?.provider.id === "openai") &&
|
|
361
|
-
supportsReasoningConfiguration(
|
|
413
|
+
supportsReasoningConfiguration(
|
|
414
|
+
turnExecutionPolicy.upstreamModelId,
|
|
415
|
+
turnExecutionPolicy.reasoningEffort,
|
|
416
|
+
);
|
|
362
417
|
const modelHistoryProjector = async (
|
|
363
418
|
items: Array<Record<string, unknown>>,
|
|
364
419
|
projectionOptions?: Parameters<typeof attachmentProjector>[1],
|
|
@@ -390,7 +445,12 @@ export async function prepareGovernanceAndModel(
|
|
|
390
445
|
// catalog values and must reach pre-turn compaction, history guards, and
|
|
391
446
|
// every model call together.
|
|
392
447
|
eventing.modelRunSettings = resolvedModel
|
|
393
|
-
? settingsWithResolvedModelContext(
|
|
448
|
+
? settingsWithResolvedModelContext(
|
|
449
|
+
runSettings,
|
|
450
|
+
resolvedModel.configured,
|
|
451
|
+
workspace.settings,
|
|
452
|
+
organizationModelDefaults,
|
|
453
|
+
)
|
|
394
454
|
: runSettings;
|
|
395
455
|
// WORKSPACE MODEL POLICY — the authoritative hard gate. Runs immediately
|
|
396
456
|
// after resolution and BEFORE any model call (the compaction summarizer
|
|
@@ -405,6 +465,11 @@ export async function prepareGovernanceAndModel(
|
|
|
405
465
|
const verdict = evaluateWorkspaceModelPolicy(workspaceModelPolicy, {
|
|
406
466
|
providerId: turnExecutionPolicy.providerId,
|
|
407
467
|
modelId: turnExecutionPolicy.productModelId,
|
|
468
|
+
// The same cost class the claim bills (`chargesOpenGeniCredits`):
|
|
469
|
+
// the resolved definition when present, else the frozen product id.
|
|
470
|
+
chargesCredits: resolvedModel
|
|
471
|
+
? resolvedModel.configured.cost === "credits"
|
|
472
|
+
: policyChargesCreditsForModel(capabilitySettings, turnExecutionPolicy.productModelId),
|
|
408
473
|
});
|
|
409
474
|
if (!verdict.allowed) {
|
|
410
475
|
throw new WorkspaceModelPolicyBlockedError(
|
|
@@ -460,9 +525,12 @@ export async function prepareGovernanceAndModel(
|
|
|
460
525
|
rigVersion,
|
|
461
526
|
rigName,
|
|
462
527
|
agentHumanInputEnabled,
|
|
528
|
+
codeSearchEnabled,
|
|
463
529
|
workspaceAgentInstructions,
|
|
530
|
+
workspaceAgentIdentity,
|
|
464
531
|
workspaceGovernance,
|
|
465
532
|
structuredWorkspacePolicyActive,
|
|
533
|
+
workspaceCreditModelsAllowed: workspaceModelPolicy?.allowCreditModels !== false,
|
|
466
534
|
workspaceMemory,
|
|
467
535
|
buildCompanyBrainContributionReceiptFor,
|
|
468
536
|
logicalSandboxSettings,
|