@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
|
@@ -6,33 +6,47 @@ import {
|
|
|
6
6
|
blockSessionWorkBeforeAttemptClaim,
|
|
7
7
|
requestSessionTurnRecovery,
|
|
8
8
|
recoverSessionDispatch,
|
|
9
|
+
reconcileSettledSessionAttempt,
|
|
9
10
|
reconcileSessionAttemptQuiescence,
|
|
11
|
+
reconcileCompletedSandboxSetup,
|
|
10
12
|
peekSessionWork as peekSessionWorkDb,
|
|
11
13
|
settleSessionInputWait as settleSessionInputWaitDb,
|
|
12
14
|
countQueuedTurns,
|
|
13
15
|
getSessionAttemptActivityRef,
|
|
14
16
|
getSessionEvent,
|
|
15
17
|
getSessionTurnForAttempt,
|
|
18
|
+
getWorkspace,
|
|
16
19
|
expireSessionInteractionIntervention as expireSessionInteractionInterventionDb,
|
|
20
|
+
expireScheduledRunHumanWait as expireScheduledRunHumanWaitDb,
|
|
17
21
|
expireSessionHumanInputRequest,
|
|
18
22
|
markSessionAttemptQuiesced,
|
|
19
23
|
requireSession,
|
|
20
24
|
settleSessionIdleWithParentOutbox,
|
|
25
|
+
SANDBOX_SETUP_RECOVERY_LIMIT,
|
|
21
26
|
} from "@opengeni/db";
|
|
22
27
|
import { publishDurableSessionEvents } from "@opengeni/events";
|
|
23
28
|
import { CancelledFailure } from "@temporalio/activity";
|
|
24
29
|
import { currentActivityContext } from "./streaming";
|
|
25
30
|
import { deliverFailedChildTurnToParent, notifyParentOfChildIdle } from "./parent-wake";
|
|
31
|
+
import { interactionInterventionMetricObserver } from "@opengeni/observability";
|
|
26
32
|
import { recordTurnsQueuedGauge, recordWorkerDeathRecoveryMetrics } from "../observability-metrics";
|
|
27
33
|
import {
|
|
28
34
|
MAX_AUTOMATIC_PROVIDER_RECOVERIES,
|
|
29
35
|
providerRecoveryCountFromMetadata,
|
|
36
|
+
providerRecoveryLimit,
|
|
30
37
|
} from "./agent-turn/errors";
|
|
38
|
+
import {
|
|
39
|
+
PROVIDER_OVERLOAD_RECOVERY_CODE,
|
|
40
|
+
validProviderOverloadRecoveryDelay,
|
|
41
|
+
} from "./agent-turn/provider-recovery-policy";
|
|
42
|
+
import { writeSessionUsageReceipts } from "./agent-turn/session-usage-custody";
|
|
31
43
|
import type {
|
|
32
44
|
ControlActivityServices,
|
|
33
45
|
ExpireSessionHumanInputInput,
|
|
34
46
|
ExpireSessionHumanInputResult,
|
|
35
47
|
ExpireSessionInteractionInterventionInput,
|
|
48
|
+
ExpireScheduledRunHumanWaitInput,
|
|
49
|
+
ExpireScheduledRunHumanWaitResult,
|
|
36
50
|
ExpireSessionInteractionInterventionResult,
|
|
37
51
|
PeekSessionWorkInput,
|
|
38
52
|
FailSessionAttemptInput,
|
|
@@ -42,6 +56,8 @@ import type {
|
|
|
42
56
|
PersistSessionAttemptQuiescenceInput,
|
|
43
57
|
ReconcileSessionAttemptQuiescenceInput,
|
|
44
58
|
ReconcileSessionAttemptQuiescenceResult,
|
|
59
|
+
ReconcileSettledSessionAttemptInput,
|
|
60
|
+
ReconcileSettledSessionAttemptResult,
|
|
45
61
|
RecoverDispatchInput,
|
|
46
62
|
RecoverDispatchResult,
|
|
47
63
|
RecoverEscapedMcpTimeoutInput,
|
|
@@ -58,15 +74,19 @@ export type SessionStateActivityOverrides = Partial<{
|
|
|
58
74
|
blockSessionWorkBeforeAttemptClaim: typeof blockSessionWorkBeforeAttemptClaim;
|
|
59
75
|
requestSessionTurnRecovery: typeof requestSessionTurnRecovery;
|
|
60
76
|
recoverSessionDispatch: typeof recoverSessionDispatch;
|
|
77
|
+
reconcileSettledSessionAttempt: typeof reconcileSettledSessionAttempt;
|
|
61
78
|
reconcileSessionAttemptQuiescence: typeof reconcileSessionAttemptQuiescence;
|
|
79
|
+
reconcileCompletedSandboxSetup: typeof reconcileCompletedSandboxSetup;
|
|
62
80
|
peekSessionWork: typeof peekSessionWorkDb;
|
|
63
81
|
settleSessionInputWait: typeof settleSessionInputWaitDb;
|
|
64
82
|
countQueuedTurns: typeof countQueuedTurns;
|
|
65
83
|
getSessionAttemptActivityRef: typeof getSessionAttemptActivityRef;
|
|
66
84
|
getSessionEvent: typeof getSessionEvent;
|
|
67
85
|
getSessionTurnForAttempt: typeof getSessionTurnForAttempt;
|
|
86
|
+
getWorkspace: typeof getWorkspace;
|
|
68
87
|
expireSessionHumanInputRequest: typeof expireSessionHumanInputRequest;
|
|
69
88
|
expireSessionInteractionIntervention: typeof expireSessionInteractionInterventionDb;
|
|
89
|
+
expireScheduledRunHumanWait: typeof expireScheduledRunHumanWaitDb;
|
|
70
90
|
requireSession: typeof requireSession;
|
|
71
91
|
settleSessionIdleWithParentOutbox: typeof settleSessionIdleWithParentOutbox;
|
|
72
92
|
markSessionAttemptQuiesced: typeof markSessionAttemptQuiesced;
|
|
@@ -100,19 +120,26 @@ export function createSessionStateActivities(
|
|
|
100
120
|
const requestSessionTurnRecoveryFn =
|
|
101
121
|
overrides.requestSessionTurnRecovery ?? requestSessionTurnRecovery;
|
|
102
122
|
const recoverSessionDispatchFn = overrides.recoverSessionDispatch ?? recoverSessionDispatch;
|
|
123
|
+
const reconcileSettledSessionAttemptFn =
|
|
124
|
+
overrides.reconcileSettledSessionAttempt ?? reconcileSettledSessionAttempt;
|
|
103
125
|
const reconcileSessionAttemptQuiescenceFn =
|
|
104
126
|
overrides.reconcileSessionAttemptQuiescence ?? reconcileSessionAttemptQuiescence;
|
|
105
127
|
const peekSessionWorkFn = overrides.peekSessionWork ?? peekSessionWorkDb;
|
|
128
|
+
const reconcileCompletedSandboxSetupFn =
|
|
129
|
+
overrides.reconcileCompletedSandboxSetup ?? reconcileCompletedSandboxSetup;
|
|
106
130
|
const settleSessionInputWaitFn = overrides.settleSessionInputWait ?? settleSessionInputWaitDb;
|
|
107
131
|
const countQueuedTurnsFn = overrides.countQueuedTurns ?? countQueuedTurns;
|
|
108
132
|
const getSessionAttemptActivityRefFn =
|
|
109
133
|
overrides.getSessionAttemptActivityRef ?? getSessionAttemptActivityRef;
|
|
110
134
|
const getSessionEventFn = overrides.getSessionEvent ?? getSessionEvent;
|
|
111
135
|
const getSessionTurnForAttemptFn = overrides.getSessionTurnForAttempt ?? getSessionTurnForAttempt;
|
|
136
|
+
const getWorkspaceFn = overrides.getWorkspace ?? getWorkspace;
|
|
112
137
|
const expireSessionHumanInputRequestFn =
|
|
113
138
|
overrides.expireSessionHumanInputRequest ?? expireSessionHumanInputRequest;
|
|
114
139
|
const expireSessionInteractionInterventionFn =
|
|
115
140
|
overrides.expireSessionInteractionIntervention ?? expireSessionInteractionInterventionDb;
|
|
141
|
+
const expireScheduledRunHumanWaitFn =
|
|
142
|
+
overrides.expireScheduledRunHumanWait ?? expireScheduledRunHumanWaitDb;
|
|
116
143
|
const requireSessionFn = overrides.requireSession ?? requireSession;
|
|
117
144
|
const settleSessionIdleWithParentOutboxFn =
|
|
118
145
|
overrides.settleSessionIdleWithParentOutbox ?? settleSessionIdleWithParentOutbox;
|
|
@@ -233,6 +260,11 @@ export function createSessionStateActivities(
|
|
|
233
260
|
turn.triggerEventId === postClaimRecovery.triggerEventId &&
|
|
234
261
|
turn.executionGeneration === postClaimRecovery.executionGeneration,
|
|
235
262
|
);
|
|
263
|
+
// A typed checkpoint belongs to one exact turn/generation. A stale wire
|
|
264
|
+
// cannot recover or terminally fail a different current attempt.
|
|
265
|
+
if (postClaimRecovery && !postClaimIdentityMatches) {
|
|
266
|
+
return { action: "stale" };
|
|
267
|
+
}
|
|
236
268
|
const providerRecoveryCount = postClaimIdentityMatches
|
|
237
269
|
? postClaimRecovery?.providerRecoveryCount
|
|
238
270
|
: undefined;
|
|
@@ -241,15 +273,34 @@ export function createSessionStateActivities(
|
|
|
241
273
|
: undefined;
|
|
242
274
|
const hasProviderRecoveryCount = providerRecoveryCount !== undefined;
|
|
243
275
|
const hasProviderFailureCode = providerFailureCode !== undefined;
|
|
276
|
+
const providerRecoveryContinueDelayMs = postClaimIdentityMatches
|
|
277
|
+
? postClaimRecovery?.providerRecoveryContinueDelayMs
|
|
278
|
+
: undefined;
|
|
279
|
+
const setupOutcomeUnknown =
|
|
280
|
+
postClaimIdentityMatches && postClaimRecovery?.sandboxSetupOutcomeUnknown === true;
|
|
281
|
+
const setupRecoveryExhausted =
|
|
282
|
+
postClaimIdentityMatches && postClaimRecovery?.sandboxSetupRecoveryExhausted === true;
|
|
283
|
+
if (
|
|
284
|
+
(setupOutcomeUnknown && setupRecoveryExhausted) ||
|
|
285
|
+
((setupOutcomeUnknown || setupRecoveryExhausted) &&
|
|
286
|
+
(hasProviderRecoveryCount || hasProviderFailureCode)) ||
|
|
287
|
+
(setupRecoveryExhausted &&
|
|
288
|
+
turn.metadata?.providerRecoveryCount !== SANDBOX_SETUP_RECOVERY_LIMIT)
|
|
289
|
+
) {
|
|
290
|
+
return { action: "stale" };
|
|
291
|
+
}
|
|
244
292
|
if (hasProviderRecoveryCount !== hasProviderFailureCode) {
|
|
245
293
|
return { action: "stale" };
|
|
246
294
|
}
|
|
295
|
+
if (!validProviderOverloadRecoveryDelay(providerFailureCode, providerRecoveryContinueDelayMs)) {
|
|
296
|
+
return { action: "stale" };
|
|
297
|
+
}
|
|
247
298
|
if (
|
|
248
299
|
providerRecoveryCount !== undefined &&
|
|
249
300
|
(!Number.isSafeInteger(providerRecoveryCount) ||
|
|
250
301
|
providerRecoveryCount <= 0 ||
|
|
251
302
|
providerRecoveryCount !== providerRecoveryCountFromMetadata(turn.metadata ?? {}) + 1 ||
|
|
252
|
-
providerRecoveryCount >
|
|
303
|
+
providerRecoveryCount > providerRecoveryLimit(providerFailureCode) ||
|
|
253
304
|
typeof providerFailureCode !== "string" ||
|
|
254
305
|
!/^[a-z][a-z0-9_]{0,63}$/.test(providerFailureCode))
|
|
255
306
|
) {
|
|
@@ -264,20 +315,61 @@ export function createSessionStateActivities(
|
|
|
264
315
|
? "legacy_retryable_preclaim_database_failure"
|
|
265
316
|
: null;
|
|
266
317
|
if (recoveredClaimCode) {
|
|
318
|
+
// Known usage from the failed attempt is recorded under its original
|
|
319
|
+
// source identities before any replacement attempt can dispatch. A
|
|
320
|
+
// failure here retries this DB-only lane; nothing is re-requested.
|
|
321
|
+
const heldReceipts = postClaimIdentityMatches
|
|
322
|
+
? (postClaimRecovery?.sessionUsageReceipts ?? [])
|
|
323
|
+
: [];
|
|
324
|
+
if (heldReceipts.length > 0) {
|
|
325
|
+
await writeSessionUsageReceipts(
|
|
326
|
+
db,
|
|
327
|
+
{ accountId: input.accountId, workspaceId: input.workspaceId },
|
|
328
|
+
heldReceipts,
|
|
329
|
+
);
|
|
330
|
+
}
|
|
267
331
|
const recovery = await requestSessionTurnRecoveryFn(db, input.workspaceId, {
|
|
268
332
|
sessionId: input.sessionId,
|
|
269
333
|
turnId: turn.id,
|
|
270
334
|
triggerEventId: turn.triggerEventId,
|
|
271
335
|
attemptId: input.attemptId,
|
|
272
|
-
reason:
|
|
336
|
+
reason: setupOutcomeUnknown
|
|
337
|
+
? "sandbox_command_start_outcome_unknown"
|
|
338
|
+
: setupRecoveryExhausted
|
|
339
|
+
? "sandbox_command_start_recovery_exhausted"
|
|
340
|
+
: (providerFailureCode ?? "claimed_attempt_database_failure"),
|
|
341
|
+
...(setupOutcomeUnknown ? { sandboxSetupOutcomeUnknown: true } : {}),
|
|
342
|
+
...(setupRecoveryExhausted ? { sandboxSetupRecoveryExhausted: true } : {}),
|
|
273
343
|
...(providerRecoveryCount !== undefined ? { providerRecoveryCount } : {}),
|
|
274
344
|
detail: {
|
|
275
|
-
code:
|
|
276
|
-
|
|
345
|
+
code: setupOutcomeUnknown
|
|
346
|
+
? "sandbox_command_start_outcome_unknown"
|
|
347
|
+
: setupRecoveryExhausted
|
|
348
|
+
? "sandbox_command_start_recovery_exhausted"
|
|
349
|
+
: providerFailureCode === PROVIDER_OVERLOAD_RECOVERY_CODE
|
|
350
|
+
? "provider_unavailable"
|
|
351
|
+
: (providerFailureCode ?? recoveredClaimCode),
|
|
352
|
+
retryable: !setupOutcomeUnknown && !setupRecoveryExhausted,
|
|
353
|
+
...(setupOutcomeUnknown ? { setupOutcome: "unknown", replay: "blocked" } : {}),
|
|
354
|
+
...(setupRecoveryExhausted
|
|
355
|
+
? {
|
|
356
|
+
setupOutcome: "not_started",
|
|
357
|
+
replay: "blocked",
|
|
358
|
+
recoveryExhausted: true,
|
|
359
|
+
providerRecoveryCount: SANDBOX_SETUP_RECOVERY_LIMIT,
|
|
360
|
+
}
|
|
361
|
+
: {}),
|
|
277
362
|
...(providerRecoveryCount !== undefined
|
|
278
363
|
? {
|
|
279
364
|
databaseFailureCode: recoveredClaimCode,
|
|
280
365
|
providerRecoveryCount,
|
|
366
|
+
...(providerFailureCode === PROVIDER_OVERLOAD_RECOVERY_CODE
|
|
367
|
+
? {
|
|
368
|
+
providerCondition: "overloaded",
|
|
369
|
+
maxProviderRecoveryCount: providerRecoveryLimit(providerFailureCode),
|
|
370
|
+
continueDelayMs: providerRecoveryContinueDelayMs,
|
|
371
|
+
}
|
|
372
|
+
: {}),
|
|
281
373
|
}
|
|
282
374
|
: {}),
|
|
283
375
|
recoverySource: "workflow_activity_failure",
|
|
@@ -292,7 +384,12 @@ export function createSessionStateActivities(
|
|
|
292
384
|
countQueuedTurnsFn,
|
|
293
385
|
recordTurnsQueuedGaugeFn,
|
|
294
386
|
);
|
|
295
|
-
return {
|
|
387
|
+
return {
|
|
388
|
+
action: "recovering",
|
|
389
|
+
...(providerRecoveryContinueDelayMs !== undefined
|
|
390
|
+
? { continueDelayMs: providerRecoveryContinueDelayMs }
|
|
391
|
+
: {}),
|
|
392
|
+
};
|
|
296
393
|
}
|
|
297
394
|
const trigger = await getSessionEventFn(db, input.workspaceId, turn.triggerEventId);
|
|
298
395
|
const result = await applySessionTurnSettlementFn(db, input.workspaceId, {
|
|
@@ -425,6 +522,63 @@ export function createSessionStateActivities(
|
|
|
425
522
|
return { action: result.action };
|
|
426
523
|
}
|
|
427
524
|
|
|
525
|
+
/** A new authenticated inspection, never trust the earlier observer hint.
|
|
526
|
+
* The DB seam independently revalidates the entire stored/current identity,
|
|
527
|
+
* control and both writer predicates under canonical locks before closing. */
|
|
528
|
+
async function reconcileSettledSessionAttemptActivity(
|
|
529
|
+
input: ReconcileSettledSessionAttemptInput,
|
|
530
|
+
): Promise<ReconcileSettledSessionAttemptResult> {
|
|
531
|
+
const { db, bus, inspectSessionAttemptActivity, settings, observability, wakeSessionWorkflow } =
|
|
532
|
+
await services();
|
|
533
|
+
const ref = await getSessionAttemptActivityRefFn(db, {
|
|
534
|
+
...input,
|
|
535
|
+
temporalWorkflowId: input.workflowId,
|
|
536
|
+
});
|
|
537
|
+
if (!ref || ref.workflowRunId !== input.workflowRunId || ref.activityId !== input.activityId)
|
|
538
|
+
return { action: "stale" };
|
|
539
|
+
if (!inspectSessionAttemptActivity) return { action: "pending" };
|
|
540
|
+
try {
|
|
541
|
+
if ((await inspectSessionAttemptActivity(ref)) !== "settled") return { action: "pending" };
|
|
542
|
+
} catch (error) {
|
|
543
|
+
if (error instanceof CancelledFailure) throw error;
|
|
544
|
+
if (currentActivityContext()?.cancellationSignal.aborted)
|
|
545
|
+
throw new CancelledFailure("Settled-owner reconciliation cancelled");
|
|
546
|
+
return { action: "pending" };
|
|
547
|
+
}
|
|
548
|
+
if (currentActivityContext()?.cancellationSignal.aborted)
|
|
549
|
+
throw new CancelledFailure("Settled-owner reconciliation cancelled");
|
|
550
|
+
const result = await reconcileSettledSessionAttemptFn(db, {
|
|
551
|
+
accountId: input.accountId,
|
|
552
|
+
workspaceId: input.workspaceId,
|
|
553
|
+
sessionId: input.sessionId,
|
|
554
|
+
turnId: input.turnId,
|
|
555
|
+
attemptId: input.attemptId,
|
|
556
|
+
executionGeneration: input.executionGeneration,
|
|
557
|
+
temporalWorkflowId: ref.workflowId,
|
|
558
|
+
temporalWorkflowRunId: ref.workflowRunId,
|
|
559
|
+
temporalActivityId: ref.activityId,
|
|
560
|
+
activitySettled: true,
|
|
561
|
+
maxRedispatches: WORKER_DEATH_MAX_REDISPATCHES,
|
|
562
|
+
});
|
|
563
|
+
// Atomic Postgres recovery/quiescence/wake truth is already sufficient if
|
|
564
|
+
// live fanout fails. It must not be replaced by an observer-only wake.
|
|
565
|
+
if (result.events.length > 0)
|
|
566
|
+
await publishDurableSessionEventsFn(
|
|
567
|
+
bus,
|
|
568
|
+
input.workspaceId,
|
|
569
|
+
input.sessionId,
|
|
570
|
+
result.events,
|
|
571
|
+
).catch(() => undefined);
|
|
572
|
+
if (result.action === "exceeded")
|
|
573
|
+
await deliverFailedChildTurnToParentFn(
|
|
574
|
+
{ db, bus, settings, observability, wakeSessionWorkflow },
|
|
575
|
+
input.workspaceId,
|
|
576
|
+
input.sessionId,
|
|
577
|
+
result.turnId,
|
|
578
|
+
);
|
|
579
|
+
return { action: result.action };
|
|
580
|
+
}
|
|
581
|
+
|
|
428
582
|
/**
|
|
429
583
|
* Recover the same current inference when its worker dies without completing
|
|
430
584
|
* a graceful checkpoint (heartbeat timeout, SIGKILL, OOM, or node loss).
|
|
@@ -523,15 +677,48 @@ export function createSessionStateActivities(
|
|
|
523
677
|
}
|
|
524
678
|
|
|
525
679
|
async function peekSessionWork(input: PeekSessionWorkInput) {
|
|
526
|
-
const { db, observability, inspectSessionAttemptActivity } = await services();
|
|
527
|
-
|
|
680
|
+
const { db, bus, observability, inspectSessionAttemptActivity } = await services();
|
|
681
|
+
// Already scheduled activities retain their old input across workflow upgrades.
|
|
682
|
+
// Resolve its workspace scope exactly as the legacy DB path did, then use the
|
|
683
|
+
// observer path so absent rows and a still-owned attempt are observations.
|
|
684
|
+
const observerAccountId =
|
|
685
|
+
input.observerAccountId ?? (await getWorkspaceFn(db, input.workspaceId))?.accountId;
|
|
686
|
+
if (!observerAccountId) return { kind: "unavailable" as const };
|
|
687
|
+
let peek = await peekSessionWorkFn(
|
|
528
688
|
db,
|
|
529
689
|
input.workspaceId,
|
|
530
690
|
input.sessionId,
|
|
531
691
|
input.includeAdmissionFence,
|
|
532
|
-
|
|
692
|
+
observerAccountId,
|
|
533
693
|
);
|
|
534
694
|
if (peek.kind === "unavailable") return peek;
|
|
695
|
+
if (peek.kind === "admission-blocked" && peek.reason === "sandbox_setup_outcome_unknown") {
|
|
696
|
+
const ref = peek.ref;
|
|
697
|
+
if (ref && "turnId" in ref && "attemptId" in ref) {
|
|
698
|
+
const settled = await reconcileCompletedSandboxSetupFn(db, {
|
|
699
|
+
accountId: observerAccountId,
|
|
700
|
+
workspaceId: input.workspaceId,
|
|
701
|
+
sessionId: input.sessionId,
|
|
702
|
+
turnId: ref.turnId,
|
|
703
|
+
attemptId: ref.attemptId,
|
|
704
|
+
});
|
|
705
|
+
if (settled.events.length > 0)
|
|
706
|
+
await publishDurableSessionEventsFn(
|
|
707
|
+
bus,
|
|
708
|
+
input.workspaceId,
|
|
709
|
+
input.sessionId,
|
|
710
|
+
settled.events,
|
|
711
|
+
);
|
|
712
|
+
if (settled.reconciled)
|
|
713
|
+
peek = await peekSessionWorkFn(
|
|
714
|
+
db,
|
|
715
|
+
input.workspaceId,
|
|
716
|
+
input.sessionId,
|
|
717
|
+
input.includeAdmissionFence,
|
|
718
|
+
observerAccountId,
|
|
719
|
+
);
|
|
720
|
+
}
|
|
721
|
+
}
|
|
535
722
|
if (peek.kind === "attempt-owned") {
|
|
536
723
|
// Observation never revokes a writer or recovers a live owner. In
|
|
537
724
|
// particular, a settled Temporal activity is not physical-writer proof.
|
|
@@ -556,7 +743,7 @@ export function createSessionStateActivities(
|
|
|
556
743
|
input.workspaceId,
|
|
557
744
|
input.sessionId,
|
|
558
745
|
input.includeAdmissionFence,
|
|
559
|
-
|
|
746
|
+
observerAccountId,
|
|
560
747
|
);
|
|
561
748
|
if (
|
|
562
749
|
current.kind !== "attempt-owned" ||
|
|
@@ -602,8 +789,28 @@ export function createSessionStateActivities(
|
|
|
602
789
|
async function expireSessionInteractionIntervention(
|
|
603
790
|
input: ExpireSessionInteractionInterventionInput,
|
|
604
791
|
): Promise<ExpireSessionInteractionInterventionResult> {
|
|
605
|
-
const { db, bus } = await services();
|
|
792
|
+
const { db, bus, observability } = await services();
|
|
606
793
|
const result = await expireSessionInteractionInterventionFn(db, input);
|
|
794
|
+
if (result.action === "expired" && result.intervention) {
|
|
795
|
+
// The unanswered-handoff timer settles here, never through the API.
|
|
796
|
+
interactionInterventionMetricObserver(observability)({
|
|
797
|
+
kind: result.intervention.kind,
|
|
798
|
+
outcome: "expired",
|
|
799
|
+
waitMs: Date.now() - result.intervention.createdAt.getTime(),
|
|
800
|
+
});
|
|
801
|
+
}
|
|
802
|
+
if (result.events.length > 0) {
|
|
803
|
+
await publishDurableSessionEventsFn(bus, input.workspaceId, input.sessionId, result.events);
|
|
804
|
+
}
|
|
805
|
+
return { action: result.action };
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
/** A scheduled run's approval timeout answers for its unanswered human wait. */
|
|
809
|
+
async function expireScheduledRunHumanWait(
|
|
810
|
+
input: ExpireScheduledRunHumanWaitInput,
|
|
811
|
+
): Promise<ExpireScheduledRunHumanWaitResult> {
|
|
812
|
+
const { db, bus } = await services();
|
|
813
|
+
const result = await expireScheduledRunHumanWaitFn(db, input);
|
|
607
814
|
if (result.events.length > 0) {
|
|
608
815
|
await publishDurableSessionEventsFn(bus, input.workspaceId, input.sessionId, result.events);
|
|
609
816
|
}
|
|
@@ -640,12 +847,14 @@ export function createSessionStateActivities(
|
|
|
640
847
|
settleSessionInterruptions,
|
|
641
848
|
persistSessionAttemptQuiescence,
|
|
642
849
|
reconcileSessionAttemptQuiescence: reconcileSessionAttemptQuiescenceActivity,
|
|
850
|
+
reconcileSettledSessionAttempt: reconcileSettledSessionAttemptActivity,
|
|
643
851
|
recoverDispatch,
|
|
644
852
|
recoverEscapedMcpTimeout,
|
|
645
853
|
peekSessionWork,
|
|
646
854
|
settleSessionInputWait,
|
|
647
855
|
expireSessionHumanInput,
|
|
648
856
|
expireSessionInteractionIntervention,
|
|
857
|
+
expireScheduledRunHumanWait,
|
|
649
858
|
markSessionIdle,
|
|
650
859
|
};
|
|
651
860
|
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import {
|
|
2
|
+
compactLegacySessionContent,
|
|
3
|
+
foldSessionTurnDeltas,
|
|
4
|
+
listSessionDeltaFoldCandidates,
|
|
5
|
+
} from "@opengeni/db";
|
|
6
|
+
import type { ControlActivityServices } from "./types";
|
|
7
|
+
|
|
8
|
+
/** Rows per content kind rewritten by one compaction batch. */
|
|
9
|
+
export const SESSION_CONTENT_COMPACTION_ROWS_PER_PASS = 200;
|
|
10
|
+
/** A turn's deltas fold once it has been settled this long. */
|
|
11
|
+
export const SESSION_DELTA_FOLD_SETTLE_SECONDS = 10 * 60;
|
|
12
|
+
export const SESSION_DELTA_FOLD_TURNS_PER_BATCH = 50;
|
|
13
|
+
/** Soft budget for one pass; the workflow's activity timeout is 15 minutes. */
|
|
14
|
+
export const SESSION_STORAGE_PASS_BUDGET_MS = 10 * 60 * 1_000;
|
|
15
|
+
|
|
16
|
+
export type MaintainSessionStorageResult = {
|
|
17
|
+
contentCompaction: { scanned: number; compacted: number; skipped: number; failed: number };
|
|
18
|
+
deltaFolding: {
|
|
19
|
+
turns: number;
|
|
20
|
+
runs: number;
|
|
21
|
+
removedRows: number;
|
|
22
|
+
refused: number;
|
|
23
|
+
failed: number;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type SessionStorageActivityOptions = {
|
|
28
|
+
compactionRowsPerPass?: number;
|
|
29
|
+
compactLegacyContent?: typeof compactLegacySessionContent;
|
|
30
|
+
listFoldCandidates?: typeof listSessionDeltaFoldCandidates;
|
|
31
|
+
foldTurn?: typeof foldSessionTurnDeltas;
|
|
32
|
+
foldTurnsPerBatch?: number;
|
|
33
|
+
foldSettleSeconds?: number;
|
|
34
|
+
timeBudgetMs?: number;
|
|
35
|
+
now?: () => number;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Deployment-wide session storage maintenance. Both steps are lossless and
|
|
40
|
+
* therefore always on: legacy content compaction (the database proves every
|
|
41
|
+
* rewrite) and folding the streamed deltas of settled turns (each folded row
|
|
42
|
+
* records every original fragment). Each keeps working through its backlog
|
|
43
|
+
* while it makes progress and the pass has budget left.
|
|
44
|
+
*/
|
|
45
|
+
export function createSessionStorageActivities(
|
|
46
|
+
services: () => Promise<ControlActivityServices>,
|
|
47
|
+
options: SessionStorageActivityOptions = {},
|
|
48
|
+
) {
|
|
49
|
+
const rowsPerPass = options.compactionRowsPerPass ?? SESSION_CONTENT_COMPACTION_ROWS_PER_PASS;
|
|
50
|
+
const compactLegacyContent = options.compactLegacyContent ?? compactLegacySessionContent;
|
|
51
|
+
const listFoldCandidates = options.listFoldCandidates ?? listSessionDeltaFoldCandidates;
|
|
52
|
+
const foldTurn = options.foldTurn ?? foldSessionTurnDeltas;
|
|
53
|
+
const foldTurnsPerBatch = options.foldTurnsPerBatch ?? SESSION_DELTA_FOLD_TURNS_PER_BATCH;
|
|
54
|
+
const foldSettleSeconds = options.foldSettleSeconds ?? SESSION_DELTA_FOLD_SETTLE_SECONDS;
|
|
55
|
+
const timeBudgetMs = options.timeBudgetMs ?? SESSION_STORAGE_PASS_BUDGET_MS;
|
|
56
|
+
const now = options.now ?? Date.now;
|
|
57
|
+
|
|
58
|
+
async function maintainSessionStorage(): Promise<MaintainSessionStorageResult> {
|
|
59
|
+
const { db, observability } = await services();
|
|
60
|
+
const deadline = now() + timeBudgetMs;
|
|
61
|
+
// Half the budget for compaction, so folding always gets its turn.
|
|
62
|
+
const compactionDeadline = now() + Math.floor(timeBudgetMs / 2);
|
|
63
|
+
const contentCompaction = { scanned: 0, compacted: 0, skipped: 0, failed: 0 };
|
|
64
|
+
do {
|
|
65
|
+
const batch = await compactLegacyContent(db, {
|
|
66
|
+
maxRows: rowsPerPass,
|
|
67
|
+
onRowError: (candidate, error) =>
|
|
68
|
+
observability.warn("session content compaction failed; row stays in legacy form", {
|
|
69
|
+
kind: candidate.kind,
|
|
70
|
+
workspaceId: candidate.workspaceId,
|
|
71
|
+
sessionId: candidate.sessionId,
|
|
72
|
+
attemptId: candidate.attemptId,
|
|
73
|
+
errorName: error instanceof Error ? error.name : "unknown",
|
|
74
|
+
}),
|
|
75
|
+
});
|
|
76
|
+
contentCompaction.scanned += batch.scanned;
|
|
77
|
+
contentCompaction.compacted += batch.compacted;
|
|
78
|
+
contentCompaction.skipped += batch.skipped;
|
|
79
|
+
contentCompaction.failed += batch.failed;
|
|
80
|
+
// Rows that stay legacy are rescanned first; stop once a batch gains nothing.
|
|
81
|
+
if (batch.compacted === 0) break;
|
|
82
|
+
} while (now() < compactionDeadline);
|
|
83
|
+
if (contentCompaction.compacted > 0 || contentCompaction.failed > 0) {
|
|
84
|
+
observability.info("session content compaction pass finished", contentCompaction);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const deltaFolding = { turns: 0, runs: 0, removedRows: 0, refused: 0, failed: 0 };
|
|
88
|
+
const attempted = new Set<string>();
|
|
89
|
+
while (now() < deadline) {
|
|
90
|
+
const candidates = (
|
|
91
|
+
await listFoldCandidates(db, {
|
|
92
|
+
settleSeconds: foldSettleSeconds,
|
|
93
|
+
limit: foldTurnsPerBatch + attempted.size,
|
|
94
|
+
})
|
|
95
|
+
).filter((candidate) => !attempted.has(candidate.turnId));
|
|
96
|
+
if (candidates.length === 0) break;
|
|
97
|
+
for (const candidate of candidates.slice(0, foldTurnsPerBatch)) {
|
|
98
|
+
if (now() >= deadline) break;
|
|
99
|
+
attempted.add(candidate.turnId);
|
|
100
|
+
try {
|
|
101
|
+
const folded = await foldTurn(db, candidate);
|
|
102
|
+
deltaFolding.turns += 1;
|
|
103
|
+
deltaFolding.runs += folded.runs;
|
|
104
|
+
deltaFolding.removedRows += folded.removedRows;
|
|
105
|
+
deltaFolding.refused += folded.refused;
|
|
106
|
+
} catch (error) {
|
|
107
|
+
deltaFolding.failed += 1;
|
|
108
|
+
observability.warn("session delta folding failed; the turn keeps its deltas", {
|
|
109
|
+
workspaceId: candidate.workspaceId,
|
|
110
|
+
sessionId: candidate.sessionId,
|
|
111
|
+
turnId: candidate.turnId,
|
|
112
|
+
errorName: error instanceof Error ? error.name : "unknown",
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (deltaFolding.removedRows > 0 || deltaFolding.failed > 0) {
|
|
118
|
+
observability.info("session delta folding pass finished", deltaFolding);
|
|
119
|
+
}
|
|
120
|
+
return { contentCompaction, deltaFolding };
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return { maintainSessionStorage };
|
|
124
|
+
}
|
|
@@ -174,6 +174,9 @@ async function dispatchMaintenanceSession(
|
|
|
174
174
|
accountId: maintenance.accountId,
|
|
175
175
|
workspaceId: maintenance.workspaceId,
|
|
176
176
|
initialMessage: maintenancePrompt(maintenance),
|
|
177
|
+
// Opengeni's own periodic check: no human or product surface entered it.
|
|
178
|
+
surface: "system",
|
|
179
|
+
metrics: service.observability,
|
|
177
180
|
resources: [],
|
|
178
181
|
tools: [{ kind: "mcp", id: "opengeni" }],
|
|
179
182
|
toolPolicy: { mode: "explicit", inheritedFromSessionId: null },
|
|
@@ -189,7 +192,7 @@ async function dispatchMaintenanceSession(
|
|
|
189
192
|
createdBy: {
|
|
190
193
|
kind: "service",
|
|
191
194
|
subjectId: "site-auth-maintenance",
|
|
192
|
-
label: "
|
|
195
|
+
label: "Opengeni authentication maintenance",
|
|
193
196
|
},
|
|
194
197
|
createdByContext: {
|
|
195
198
|
[SITE_AUTH_MAINTENANCE_CONNECTION_CONTEXT_KEY]: maintenance.siteAuthConnectionId,
|
|
@@ -251,7 +254,7 @@ function maintenancePrompt(maintenance: SiteAuthMaintenanceClaim): string {
|
|
|
251
254
|
maintenance.preferredNetworkRouteId
|
|
252
255
|
? `Preferred NetworkRoute: ${maintenance.preferredNetworkRouteId}`
|
|
253
256
|
: "No preferred NetworkRoute is configured.",
|
|
254
|
-
"First call browser_auth get_connection and ensure this exact maintenance action is still active. Open a new browser (do not reuse an unrelated session) with the preferred identity, placement, and network route. Observe the current page, start one AuthRun with the exact purpose above, and settle it as verified, failed, cancelled, or a durable human intervention.
|
|
257
|
+
"First call browser_auth get_connection and ensure this exact maintenance action is still active. Open a new browser (do not reuse an unrelated session) with the preferred identity, placement, and network route. Observe the current page, start one AuthRun with the exact purpose above, sign in through its provider-managed (external_provider) authority with browser_auth advance_external, and settle it as verified, failed, cancelled, or a durable human intervention. If authentication is already valid, verify it without logging in again. If a health check finds invalid authentication, report it failed; automatic repair, when enabled, is a separate maintenance run. Never save/publish browser state in this run.",
|
|
255
258
|
]
|
|
256
259
|
.filter((line): line is string => line !== null)
|
|
257
260
|
.join("\n");
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude's binding of the provider-neutral core waits (Claude track C1b).
|
|
3
|
+
* The workflow reaches it only for a waiter the core holds.
|
|
4
|
+
*/
|
|
5
|
+
import {
|
|
6
|
+
armSubscriptionCoreCapacityWait,
|
|
7
|
+
getSubscriptionCoreCapacityWaitById,
|
|
8
|
+
readSubscriptionCoreTurnModel,
|
|
9
|
+
reconcileSubscriptionCoreCapacityWait,
|
|
10
|
+
SUBSCRIPTION_CORE_CLAUDE,
|
|
11
|
+
subscriptionCoreTurns,
|
|
12
|
+
wakeSubscriptionCoreProviderCapacityWaiters,
|
|
13
|
+
type SubscriptionCoreProvider,
|
|
14
|
+
} from "@opengeni/db";
|
|
15
|
+
import type { CoreWaitBinding } from "./subscription-core-codex-waits";
|
|
16
|
+
import { refreshBlockedCoreQuotaBeforeReconcile } from "./subscription-core-usage-recheck";
|
|
17
|
+
|
|
18
|
+
const CLAUDE = SUBSCRIPTION_CORE_CLAUDE as SubscriptionCoreProvider;
|
|
19
|
+
|
|
20
|
+
export const CLAUDE_CORE_WAIT_BINDING: CoreWaitBinding = {
|
|
21
|
+
provider: "claude",
|
|
22
|
+
arm: (db, input) => armSubscriptionCoreCapacityWait(db, "claude", input),
|
|
23
|
+
getWaiterById: async (db, input) => {
|
|
24
|
+
const waiter = await getSubscriptionCoreCapacityWaitById(db, input);
|
|
25
|
+
return waiter?.provider === "claude" ? waiter : null;
|
|
26
|
+
},
|
|
27
|
+
readTurnModel: (db, input) => readSubscriptionCoreTurnModel(db, input),
|
|
28
|
+
recoverHealth: (db, identity) =>
|
|
29
|
+
subscriptionCoreTurns(CLAUDE).recoverSubscriptionCoreConnectionHealth(db, identity),
|
|
30
|
+
evaluatePlacement: (db, request) =>
|
|
31
|
+
subscriptionCoreTurns(CLAUDE).evaluateSubscriptionCorePlacement(db, request),
|
|
32
|
+
wakeWaiters: (db, input) => wakeSubscriptionCoreProviderCapacityWaiters(db, "claude", input),
|
|
33
|
+
reconcileWaiter: (db, input) =>
|
|
34
|
+
reconcileSubscriptionCoreCapacityWait(db, { ...input, provider: "claude" }),
|
|
35
|
+
// Anthropic can reset a plan limit before the reset a refused request
|
|
36
|
+
// reported, so a parked turn re-reads the Claude usage endpoint
|
|
37
|
+
// (rate-limited per connection and per probe scope) at each bounded
|
|
38
|
+
// recheck instead of sleeping until a stale reset: the shared pool, and the
|
|
39
|
+
// personal connections its exact accepted identity authorizes.
|
|
40
|
+
refreshBeforeReconcile: ({ db, settings }, turn) =>
|
|
41
|
+
refreshBlockedCoreQuotaBeforeReconcile({
|
|
42
|
+
provider: CLAUDE,
|
|
43
|
+
db,
|
|
44
|
+
settings,
|
|
45
|
+
accountId: turn.accountId,
|
|
46
|
+
workspaceId: turn.workspaceId,
|
|
47
|
+
personalTurn: turn,
|
|
48
|
+
}),
|
|
49
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {
|
|
2
|
+
subscriptionCoreProvider,
|
|
3
|
+
type Database,
|
|
4
|
+
type SubscriptionCoreTurnIdentity,
|
|
5
|
+
} from "@opengeni/db";
|
|
6
|
+
import type { Settings } from "@opengeni/config";
|
|
7
|
+
import {
|
|
8
|
+
CORE_USAGE_PROBE_ATTEMPT_INTERVAL_MS,
|
|
9
|
+
CORE_USAGE_RECHECK_MIN_INTERVAL_MS,
|
|
10
|
+
refreshBlockedCoreQuotaBeforeReconcile,
|
|
11
|
+
resetCoreUsageProbeAttempts,
|
|
12
|
+
} from "./subscription-core-usage-recheck";
|
|
13
|
+
|
|
14
|
+
/** Codex's per-connection re-read interval (the provider-neutral one). */
|
|
15
|
+
export const CODEX_CORE_USAGE_RECHECK_MIN_INTERVAL_MS = CORE_USAGE_RECHECK_MIN_INTERVAL_MS;
|
|
16
|
+
|
|
17
|
+
/** Codex's per-scope probe attempt interval (the provider-neutral one). */
|
|
18
|
+
export const CODEX_CORE_USAGE_PROBE_ATTEMPT_INTERVAL_MS = CORE_USAGE_PROBE_ATTEMPT_INTERVAL_MS;
|
|
19
|
+
|
|
20
|
+
/** Test seam: forget every recorded probe attempt. */
|
|
21
|
+
export function resetCodexCoreUsageProbeAttempts(): void {
|
|
22
|
+
resetCoreUsageProbeAttempts();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Before a parked Codex turn's reconcile: one `/wham/usage` read per
|
|
27
|
+
* exhausted connection the work can use whose stored quota was not observed
|
|
28
|
+
* within `CODEX_CORE_USAGE_RECHECK_MIN_INTERVAL_MS`, through the same core
|
|
29
|
+
* probe the usage refresh route uses (`refreshBlockedCoreQuotaBeforeReconcile`
|
|
30
|
+
* bound to Codex: shared connections as the core's service subject, and only
|
|
31
|
+
* the personal connections the exact accepted turn admits).
|
|
32
|
+
*/
|
|
33
|
+
export async function refreshExhaustedCodexCoreQuota(input: {
|
|
34
|
+
db: Database;
|
|
35
|
+
settings: Settings;
|
|
36
|
+
accountId: string;
|
|
37
|
+
workspaceId: string;
|
|
38
|
+
personalTurn?: SubscriptionCoreTurnIdentity | null;
|
|
39
|
+
fetch?: typeof fetch;
|
|
40
|
+
now?: number;
|
|
41
|
+
}): Promise<void> {
|
|
42
|
+
await refreshBlockedCoreQuotaBeforeReconcile({
|
|
43
|
+
...input,
|
|
44
|
+
provider: subscriptionCoreProvider("codex"),
|
|
45
|
+
});
|
|
46
|
+
}
|