@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
package/src/workflows/session.ts
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
workflowInfo,
|
|
14
14
|
} from "@temporalio/workflow";
|
|
15
15
|
import type * as activities from "../activities";
|
|
16
|
+
import { validProviderOverloadRecoveryDelay } from "../activities/agent-turn/provider-recovery-policy";
|
|
16
17
|
import {
|
|
17
18
|
ESCAPED_MCP_TIMEOUT_RECOVERY_FAILURE_MESSAGE,
|
|
18
19
|
ESCAPED_MCP_TIMEOUT_RECOVERY_FAILURE_TYPE,
|
|
@@ -53,11 +54,61 @@ const HUMAN_INPUT_EXPIRY_STALE_RETRY_MS = 1_000;
|
|
|
53
54
|
* The minimum hold for a rotation all-capped idle (`idleUntilReset`). A MANDATORY
|
|
54
55
|
* floor so that even a 0/elapsed continueDelayMs (a stale/unknown reset) can never
|
|
55
56
|
* collapse the hold into a tight re-dispatch loop that hammers CPU/DB and never runs
|
|
56
|
-
* the model (invariant 4: NO THRASH).
|
|
57
|
+
* the model (invariant 4: NO THRASH). Retains the historical cooldown; kept
|
|
57
58
|
* local so the deterministic workflow bundle does not import the activities module.
|
|
58
59
|
*/
|
|
59
60
|
const ROTATION_IDLE_FLOOR_MS = 60_000; // 60s
|
|
60
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Provider capacity waits are shared: every waiter of one exhausted pool learns
|
|
64
|
+
* the same authoritative reset time, and one capacity mutation (for example the
|
|
65
|
+
* bounded refresh that verifies a quota reset) wakes every waiter at once, both
|
|
66
|
+
* as the typed capacity signal and as the generic durable workflow wake. Without
|
|
67
|
+
* spread, a reset resumes the whole backlog in the same few seconds and its
|
|
68
|
+
* turns stampede sandbox creation and the provider. Each workflow therefore
|
|
69
|
+
* delays its reconciliation by a bounded, replay-deterministic (Temporal-seeded
|
|
70
|
+
* `Math.random`) jitter: up to one minute past a scheduled reset timer and up to
|
|
71
|
+
* 30 seconds after a capacity or queue wake or an already-due waiter. A wake
|
|
72
|
+
* that lands inside a waiter's timer spread does not shorten it. The Postgres
|
|
73
|
+
* waiter stays authoritative; jitter only delays the same reconciliation
|
|
74
|
+
* activity and never creates queue rows, input, or inference. Interruptions are
|
|
75
|
+
* never delayed.
|
|
76
|
+
*
|
|
77
|
+
* The patch marker is not understood by workers built before it: rolling the
|
|
78
|
+
* worker image back past this change while a session has recorded the marker
|
|
79
|
+
* (it waited on capacity in its current run) fails that workflow's tasks as
|
|
80
|
+
* nondeterministic until a patched worker returns.
|
|
81
|
+
*/
|
|
82
|
+
export const CAPACITY_WAKE_JITTER_PATCH = "session-capacity-wake-jitter-v1";
|
|
83
|
+
/**
|
|
84
|
+
* A scheduled run's approval timeout sleeps on a durable Temporal timer. A
|
|
85
|
+
* history recorded by a worker that ignored the deadline has no timer command
|
|
86
|
+
* there, so replay only arms it behind this marker.
|
|
87
|
+
*/
|
|
88
|
+
export const SCHEDULED_HUMAN_WAIT_TIMEOUT_PATCH = "session-scheduled-human-wait-timeout-v1";
|
|
89
|
+
export const CAPACITY_TIMER_WAKE_JITTER_MAX_MS = 60_000;
|
|
90
|
+
export const CAPACITY_WAKE_JITTER_MAX_MS = 30_000;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Pure + exported so the bound is unit-testable without a workflow environment.
|
|
94
|
+
* `overrideMaxMs` is the test-only SessionWorkflowInput ceiling; it can only
|
|
95
|
+
* narrow the production bound.
|
|
96
|
+
*/
|
|
97
|
+
export function capacityWakeJitterMs(
|
|
98
|
+
kind: "timer" | "wake",
|
|
99
|
+
sample: number,
|
|
100
|
+
overrideMaxMs?: number,
|
|
101
|
+
): number {
|
|
102
|
+
const productionMax =
|
|
103
|
+
kind === "timer" ? CAPACITY_TIMER_WAKE_JITTER_MAX_MS : CAPACITY_WAKE_JITTER_MAX_MS;
|
|
104
|
+
const max =
|
|
105
|
+
overrideMaxMs !== undefined && Number.isFinite(overrideMaxMs)
|
|
106
|
+
? Math.min(productionMax, Math.max(0, Math.trunc(overrideMaxMs)))
|
|
107
|
+
: productionMax;
|
|
108
|
+
const unit = Number.isFinite(sample) ? Math.min(Math.max(sample, 0), 1 - Number.EPSILON) : 0;
|
|
109
|
+
return Math.floor(unit * max);
|
|
110
|
+
}
|
|
111
|
+
|
|
61
112
|
/**
|
|
62
113
|
* How long the continuation loop must hold before re-admitting the next turn. 0 ⇒ no
|
|
63
114
|
* hold (re-dispatch immediately — a rotation candidate is ready, or no idle delay was
|
|
@@ -315,7 +366,19 @@ export function postClaimDatabaseRecoveryDetail(
|
|
|
315
366
|
const hasProviderRecoveryCount = detail.providerRecoveryCount !== undefined;
|
|
316
367
|
const hasProviderFailureCode = detail.providerFailureCode !== undefined;
|
|
317
368
|
if (
|
|
369
|
+
(detail.sandboxSetupOutcomeUnknown !== undefined &&
|
|
370
|
+
detail.sandboxSetupOutcomeUnknown !== true) ||
|
|
371
|
+
(detail.sandboxSetupRecoveryExhausted !== undefined &&
|
|
372
|
+
detail.sandboxSetupRecoveryExhausted !== true) ||
|
|
373
|
+
(detail.sandboxSetupOutcomeUnknown === true && detail.sandboxSetupRecoveryExhausted === true) ||
|
|
374
|
+
((detail.sandboxSetupOutcomeUnknown === true ||
|
|
375
|
+
detail.sandboxSetupRecoveryExhausted === true) &&
|
|
376
|
+
hasProviderRecoveryCount) ||
|
|
318
377
|
hasProviderRecoveryCount !== hasProviderFailureCode ||
|
|
378
|
+
!validProviderOverloadRecoveryDelay(
|
|
379
|
+
detail.providerFailureCode,
|
|
380
|
+
detail.providerRecoveryContinueDelayMs,
|
|
381
|
+
) ||
|
|
319
382
|
(hasProviderRecoveryCount &&
|
|
320
383
|
(!Number.isSafeInteger(detail.providerRecoveryCount) ||
|
|
321
384
|
(detail.providerRecoveryCount ?? 0) <= 0 ||
|
|
@@ -324,9 +387,46 @@ export function postClaimDatabaseRecoveryDetail(
|
|
|
324
387
|
) {
|
|
325
388
|
return null;
|
|
326
389
|
}
|
|
390
|
+
if (
|
|
391
|
+
detail.sessionUsageReceipts !== undefined &&
|
|
392
|
+
!validPostClaimSessionUsageReceipts(detail.sessionUsageReceipts)
|
|
393
|
+
) {
|
|
394
|
+
return null;
|
|
395
|
+
}
|
|
327
396
|
return detail as PostClaimDatabaseRecoveryDetail;
|
|
328
397
|
}
|
|
329
398
|
|
|
399
|
+
const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
400
|
+
|
|
401
|
+
/** Bounded, content-free task usage receipts carried by a recovery detail. */
|
|
402
|
+
function validPostClaimSessionUsageReceipts(value: unknown): boolean {
|
|
403
|
+
if (!Array.isArray(value) || value.length === 0 || value.length > 64) return false;
|
|
404
|
+
return value.every((receipt) => {
|
|
405
|
+
if (!receipt || typeof receipt !== "object") return false;
|
|
406
|
+
const r = receipt as Record<string, unknown>;
|
|
407
|
+
const keys = Object.keys(r);
|
|
408
|
+
return (
|
|
409
|
+
keys.every((key) =>
|
|
410
|
+
["sessionId", "sourceId", "turnId", "amountMicros", "pricingSource", "model"].includes(key),
|
|
411
|
+
) &&
|
|
412
|
+
typeof r.sessionId === "string" &&
|
|
413
|
+
UUID_PATTERN.test(r.sessionId) &&
|
|
414
|
+
typeof r.sourceId === "string" &&
|
|
415
|
+
r.sourceId.length >= 1 &&
|
|
416
|
+
r.sourceId.length <= 1024 &&
|
|
417
|
+
(r.turnId === null || (typeof r.turnId === "string" && UUID_PATTERN.test(r.turnId))) &&
|
|
418
|
+
(r.amountMicros === null ||
|
|
419
|
+
(typeof r.amountMicros === "number" &&
|
|
420
|
+
Number.isSafeInteger(r.amountMicros) &&
|
|
421
|
+
r.amountMicros >= 0)) &&
|
|
422
|
+
(r.pricingSource === null ||
|
|
423
|
+
r.pricingSource === "configured_list_price" ||
|
|
424
|
+
r.pricingSource === "gateway_reported") &&
|
|
425
|
+
(r.model === null || (typeof r.model === "string" && r.model.length <= 512))
|
|
426
|
+
);
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
|
|
330
430
|
/**
|
|
331
431
|
* Classify only the exact turn-fence cancellation protocol used to arbitrate a
|
|
332
432
|
* database control commit that reaches the activity just before its Temporal
|
|
@@ -369,6 +469,9 @@ export type SessionWorkflowInput = {
|
|
|
369
469
|
// Test-only override for the durable capacity-wait continue-as-new
|
|
370
470
|
// backstop. Production uses CODEX_CAPACITY_CHECKS_PER_RUN_BACKSTOP.
|
|
371
471
|
maxCapacityChecksPerRun?: number;
|
|
472
|
+
// Test-only ceiling for capacity-wake jitter (0 disables it) so real-server
|
|
473
|
+
// workflow tests stay fast. Production omits it and uses the bounds above.
|
|
474
|
+
capacityWakeJitterMaxMs?: number;
|
|
372
475
|
};
|
|
373
476
|
|
|
374
477
|
export async function sessionWorkflow(input: SessionWorkflowInput): Promise<void> {
|
|
@@ -476,7 +579,14 @@ export async function sessionWorkflow(input: SessionWorkflowInput): Promise<void
|
|
|
476
579
|
const timerMs = Number.isFinite(parsedDeadline)
|
|
477
580
|
? Math.max(0, parsedDeadline - Date.now())
|
|
478
581
|
: 0;
|
|
582
|
+
const observedCause = (): activities.ReconcileCodexCapacityWaitInput["cause"] =>
|
|
583
|
+
wakeups !== seenWakeups
|
|
584
|
+
? "queue"
|
|
585
|
+
: capacityWakeups !== seenCapacityWakeups
|
|
586
|
+
? "signal"
|
|
587
|
+
: "timer";
|
|
479
588
|
let cause: activities.ReconcileCodexCapacityWaitInput["cause"] = "timer";
|
|
589
|
+
let spread = false;
|
|
480
590
|
if (wakeups !== seenWakeups) {
|
|
481
591
|
cause = "queue";
|
|
482
592
|
} else if (capacityWakeups !== seenCapacityWakeups) {
|
|
@@ -492,12 +602,48 @@ export async function sessionWorkflow(input: SessionWorkflowInput): Promise<void
|
|
|
492
602
|
if (interruptionWakeups !== seenInterruptionWakeups) {
|
|
493
603
|
return;
|
|
494
604
|
}
|
|
495
|
-
cause =
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
605
|
+
cause = observedCause();
|
|
606
|
+
// Histories recorded before the jitter replay without the marker and
|
|
607
|
+
// reconcile right at the deadline, exactly as they did.
|
|
608
|
+
if (cause === "timer" && patched(CAPACITY_WAKE_JITTER_PATCH)) {
|
|
609
|
+
// The shared reset deadline itself fired. The first waiter to
|
|
610
|
+
// reconcile usually refreshes usage and wakes every other waiter; a
|
|
611
|
+
// waiter already inside its own spread keeps it instead of starting a
|
|
612
|
+
// second, shorter one, so the backlog resumes across the whole window.
|
|
613
|
+
spread = true;
|
|
614
|
+
const timerJitterMs = capacityWakeJitterMs(
|
|
615
|
+
"timer",
|
|
616
|
+
Math.random(),
|
|
617
|
+
input.capacityWakeJitterMaxMs,
|
|
618
|
+
);
|
|
619
|
+
if (timerJitterMs > 0) {
|
|
620
|
+
await condition(() => interruptionWakeups !== seenInterruptionWakeups, timerJitterMs);
|
|
621
|
+
if (interruptionWakeups !== seenInterruptionWakeups) {
|
|
622
|
+
return;
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
cause = observedCause();
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
if (!spread && patched(CAPACITY_WAKE_JITTER_PATCH)) {
|
|
629
|
+
// One capacity mutation wakes every waiter of the pool at once (the typed
|
|
630
|
+
// capacity signal and the generic durable wake), and a fresh run after
|
|
631
|
+
// continue-as-new, restart, or Resume sees every unobserved wake as an
|
|
632
|
+
// already-due waiter. Spread those reconciliations too. A later wake
|
|
633
|
+
// does not cut the pause short (that would re-synchronize the herd); a
|
|
634
|
+
// queued prompt stays behind the blocked turn either way, so only an
|
|
635
|
+
// interruption (Pause/Steer/Cancel) wins immediately.
|
|
636
|
+
const wakeJitterMs = capacityWakeJitterMs(
|
|
637
|
+
"wake",
|
|
638
|
+
Math.random(),
|
|
639
|
+
input.capacityWakeJitterMaxMs,
|
|
640
|
+
);
|
|
641
|
+
if (wakeJitterMs > 0) {
|
|
642
|
+
await condition(() => interruptionWakeups !== seenInterruptionWakeups, wakeJitterMs);
|
|
643
|
+
if (interruptionWakeups !== seenInterruptionWakeups) {
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
}
|
|
501
647
|
}
|
|
502
648
|
const reconcileInput = {
|
|
503
649
|
accountId: input.accountId,
|
|
@@ -536,6 +682,9 @@ export async function sessionWorkflow(input: SessionWorkflowInput): Promise<void
|
|
|
536
682
|
...(input.maxCapacityChecksPerRun !== undefined
|
|
537
683
|
? { maxCapacityChecksPerRun: input.maxCapacityChecksPerRun }
|
|
538
684
|
: {}),
|
|
685
|
+
...(input.capacityWakeJitterMaxMs !== undefined
|
|
686
|
+
? { capacityWakeJitterMaxMs: input.capacityWakeJitterMaxMs }
|
|
687
|
+
: {}),
|
|
539
688
|
});
|
|
540
689
|
}
|
|
541
690
|
current = result;
|
|
@@ -582,6 +731,9 @@ export async function sessionWorkflow(input: SessionWorkflowInput): Promise<void
|
|
|
582
731
|
...(input.maxCapacityChecksPerRun !== undefined
|
|
583
732
|
? { maxCapacityChecksPerRun: input.maxCapacityChecksPerRun }
|
|
584
733
|
: {}),
|
|
734
|
+
...(input.capacityWakeJitterMaxMs !== undefined
|
|
735
|
+
? { capacityWakeJitterMaxMs: input.capacityWakeJitterMaxMs }
|
|
736
|
+
: {}),
|
|
585
737
|
});
|
|
586
738
|
}
|
|
587
739
|
}
|
|
@@ -603,6 +755,28 @@ export async function sessionWorkflow(input: SessionWorkflowInput): Promise<void
|
|
|
603
755
|
...(safeObservation ? { observerAccountId: input.accountId } : {}),
|
|
604
756
|
});
|
|
605
757
|
if (peek.kind === "unavailable" || peek.kind === "attempt-owned") {
|
|
758
|
+
if (
|
|
759
|
+
peek.kind === "attempt-owned" &&
|
|
760
|
+
"ownerActivityState" in peek &&
|
|
761
|
+
peek.ownerActivityState === "settled" &&
|
|
762
|
+
patched("session-settled-owner-recovery-v1")
|
|
763
|
+
) {
|
|
764
|
+
const reconciliation = await activity.reconcileSettledSessionAttempt({
|
|
765
|
+
accountId: input.accountId,
|
|
766
|
+
workspaceId: input.workspaceId,
|
|
767
|
+
sessionId: input.sessionId,
|
|
768
|
+
turnId: peek.turnId,
|
|
769
|
+
attemptId: peek.attemptId,
|
|
770
|
+
executionGeneration: peek.executionGeneration,
|
|
771
|
+
// Continue-as-new observers carry no owner authority. Always use
|
|
772
|
+
// the DB-stored original run/activity, not this observer's run.
|
|
773
|
+
workflowId: peek.activityRef.workflowId,
|
|
774
|
+
workflowRunId: peek.activityRef.workflowRunId,
|
|
775
|
+
activityId: peek.activityRef.activityId,
|
|
776
|
+
});
|
|
777
|
+
if (reconciliation.action === "recovering") continue;
|
|
778
|
+
if (reconciliation.action === "exceeded") return;
|
|
779
|
+
}
|
|
606
780
|
// No terminal/idle projection and no successor dispatch. Restoration
|
|
607
781
|
// need not produce a wake, so retain the observer with a bounded timer
|
|
608
782
|
// instead of closing and stranding durable work. Signals interrupt the
|
|
@@ -695,8 +869,13 @@ export async function sessionWorkflow(input: SessionWorkflowInput): Promise<void
|
|
|
695
869
|
const seenApprovalWakeups = approvalWakeups;
|
|
696
870
|
const seenWakeups = wakeups;
|
|
697
871
|
const seenInterruptionWakeups = interruptionWakeups;
|
|
872
|
+
const scheduledRunTimeout =
|
|
873
|
+
peek.scheduledRunTimeout && peek.expiresAt && patched(SCHEDULED_HUMAN_WAIT_TIMEOUT_PATCH)
|
|
874
|
+
? peek.scheduledRunTimeout
|
|
875
|
+
: undefined;
|
|
698
876
|
const timeoutMs =
|
|
699
|
-
(peek.humanInputRequestId || peek.interactionInterventionId) &&
|
|
877
|
+
(peek.humanInputRequestId || peek.interactionInterventionId || scheduledRunTimeout) &&
|
|
878
|
+
peek.expiresAt
|
|
700
879
|
? humanInputDeadlineWaitMs(peek.expiresAt)
|
|
701
880
|
: undefined;
|
|
702
881
|
const wakeCondition = () =>
|
|
@@ -731,6 +910,20 @@ export async function sessionWorkflow(input: SessionWorkflowInput): Promise<void
|
|
|
731
910
|
if (expiry.action === "stale") {
|
|
732
911
|
await condition(wakeCondition, HUMAN_INPUT_EXPIRY_STALE_RETRY_MS);
|
|
733
912
|
}
|
|
913
|
+
} else if (!woke && scheduledRunTimeout) {
|
|
914
|
+
// The scheduler answers for the unanswered person through the same
|
|
915
|
+
// acceptance boundary (a labelled system rejection/skip); the loop
|
|
916
|
+
// then re-peeks and resumes the turn like any decision.
|
|
917
|
+
const expiry = await activity.expireScheduledRunHumanWait({
|
|
918
|
+
accountId: input.accountId,
|
|
919
|
+
workspaceId: input.workspaceId,
|
|
920
|
+
sessionId: input.sessionId,
|
|
921
|
+
turnId: scheduledRunTimeout.turnId,
|
|
922
|
+
runId: scheduledRunTimeout.runId,
|
|
923
|
+
});
|
|
924
|
+
if (expiry.action === "stale") {
|
|
925
|
+
await condition(wakeCondition, HUMAN_INPUT_EXPIRY_STALE_RETRY_MS);
|
|
926
|
+
}
|
|
734
927
|
}
|
|
735
928
|
continue;
|
|
736
929
|
}
|
|
@@ -745,8 +938,8 @@ export async function sessionWorkflow(input: SessionWorkflowInput): Promise<void
|
|
|
745
938
|
if (settlement.action !== "held") continue;
|
|
746
939
|
|
|
747
940
|
// The durable outbox owns the long deadline. Keep this workflow run open
|
|
748
|
-
//
|
|
749
|
-
// signal is a hint to re-peek PostgreSQL truth.
|
|
941
|
+
// for its bounded close-race window; unlike ordinary idle, this held-wait
|
|
942
|
+
// path is unchanged. Any signal is a hint to re-peek PostgreSQL truth.
|
|
750
943
|
const seenWakeups = wakeups;
|
|
751
944
|
const seenApprovalWakeups = approvalWakeups;
|
|
752
945
|
const seenInterruptionWakeups = interruptionWakeups;
|
|
@@ -800,17 +993,24 @@ export async function sessionWorkflow(input: SessionWorkflowInput): Promise<void
|
|
|
800
993
|
// idle-backoff goal keeps its durable obligation armed; the delayed
|
|
801
994
|
// wake-outbox row at the pacing deadline or any producer signal restarts
|
|
802
995
|
// the workflow. No Temporal timer is used for pacing.
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
996
|
+
// Evaluate at the changed command so old recorded timers still replay,
|
|
997
|
+
// while the next live idle cycle can close without a grace period.
|
|
998
|
+
if (!patched("session-normal-idle-no-grace-v1")) {
|
|
999
|
+
const seenWakeups = wakeups;
|
|
1000
|
+
const seenApprovalWakeups = approvalWakeups;
|
|
1001
|
+
const seenInterruptionWakeups = interruptionWakeups;
|
|
1002
|
+
const woke = await condition(
|
|
1003
|
+
() =>
|
|
1004
|
+
interruptionWakeups !== seenInterruptionWakeups ||
|
|
1005
|
+
wakeups !== seenWakeups ||
|
|
1006
|
+
approvalWakeups !== seenApprovalWakeups,
|
|
1007
|
+
"5s",
|
|
1008
|
+
);
|
|
1009
|
+
if (woke) continue;
|
|
1010
|
+
}
|
|
1011
|
+
// Keep both the durable recheck and the transactional idle/parent-outbox
|
|
1012
|
+
// fence. A signal accepted during this activity chain makes us loop;
|
|
1013
|
+
// later work restarts the same session via durable signalWithStart.
|
|
814
1014
|
const finalPeek = await activity.peekSessionWork({
|
|
815
1015
|
workspaceId: input.workspaceId,
|
|
816
1016
|
sessionId: input.sessionId,
|
|
@@ -1172,18 +1372,23 @@ export async function sessionWorkflow(input: SessionWorkflowInput): Promise<void
|
|
|
1172
1372
|
// Neither path replays model or tool side effects speculatively.
|
|
1173
1373
|
if (!failure || failure.action === "unclaimed" || failure.action === "recovering") {
|
|
1174
1374
|
unclaimedAttemptFailures += 1;
|
|
1175
|
-
await condition(
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1375
|
+
await condition(
|
|
1376
|
+
() => {
|
|
1377
|
+
const current = {
|
|
1378
|
+
wakeups,
|
|
1379
|
+
interruptionWakeups,
|
|
1380
|
+
approvalWakeups,
|
|
1381
|
+
capacityWakeups,
|
|
1382
|
+
};
|
|
1383
|
+
return classifiedPreClaimFailure
|
|
1384
|
+
? unclaimedAttemptWakeChanged(retryWakeBaseline, current)
|
|
1385
|
+
: current.interruptionWakeups !== retryWakeBaseline.interruptionWakeups ||
|
|
1386
|
+
current.wakeups !== retryWakeBaseline.wakeups;
|
|
1387
|
+
},
|
|
1388
|
+
failure?.action === "recovering"
|
|
1389
|
+
? (failure.continueDelayMs ?? retryDelayMs)
|
|
1390
|
+
: retryDelayMs,
|
|
1391
|
+
);
|
|
1187
1392
|
return true;
|
|
1188
1393
|
}
|
|
1189
1394
|
unclaimedAttemptFailures = 0;
|
|
@@ -8,7 +8,8 @@ const maintenanceActivity = proxyActivities<Pick<typeof activities, "maintainSit
|
|
|
8
8
|
},
|
|
9
9
|
);
|
|
10
10
|
|
|
11
|
-
/** One bounded durable claim/dispatch sweep
|
|
11
|
+
/** One bounded durable claim/dispatch sweep over provider-managed (external_provider)
|
|
12
|
+
* site-auth connections; the Temporal Schedule owns cadence. */
|
|
12
13
|
export async function siteAuthMaintenanceWorkflow(): Promise<void> {
|
|
13
14
|
await maintenanceActivity.maintainSiteAuthConnections();
|
|
14
15
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { proxyActivities } from "@temporalio/workflow";
|
|
1
|
+
import { defineSignal, proxyActivities, setHandler } from "@temporalio/workflow";
|
|
2
2
|
import type * as activities from "../activities";
|
|
3
3
|
|
|
4
4
|
const wakeActivity = proxyActivities<Pick<typeof activities, "dispatchSessionWorkflowWakes">>({
|
|
@@ -6,8 +6,30 @@ const wakeActivity = proxyActivities<Pick<typeof activities, "dispatchSessionWor
|
|
|
6
6
|
retry: { maximumAttempts: 1 },
|
|
7
7
|
});
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
*
|
|
9
|
+
/** Must equal SESSION_WORKFLOW_WAKE_DISPATCH_REQUESTED_SIGNAL in @opengeni/core;
|
|
10
|
+
* workflow code cannot import that package. */
|
|
11
|
+
export const sessionWorkflowWakeDispatchRequestedSignal = defineSignal("dispatchRequested");
|
|
12
|
+
|
|
13
|
+
/** Bounds one execution's history. A request still pending at the cap is
|
|
14
|
+
* picked up by the control worker's next repair tick. */
|
|
15
|
+
export const SESSION_WORKFLOW_WAKE_DISPATCHER_MAX_SWEEPS = 50;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Bounded delivery sweeps. Producers and the control worker's repair cadence
|
|
19
|
+
* signal-with-start one fixed execution; a request that arrives during a sweep
|
|
20
|
+
* runs one more sweep afterwards, so no committed wake waits for a later tick.
|
|
21
|
+
*/
|
|
11
22
|
export async function sessionWorkflowWakeDispatcherWorkflow() {
|
|
12
|
-
|
|
23
|
+
let requested = false;
|
|
24
|
+
setHandler(sessionWorkflowWakeDispatchRequestedSignal, () => {
|
|
25
|
+
requested = true;
|
|
26
|
+
});
|
|
27
|
+
let result: Awaited<ReturnType<typeof wakeActivity.dispatchSessionWorkflowWakes>>;
|
|
28
|
+
let sweeps = 0;
|
|
29
|
+
do {
|
|
30
|
+
requested = false;
|
|
31
|
+
result = await wakeActivity.dispatchSessionWorkflowWakes();
|
|
32
|
+
sweeps += 1;
|
|
33
|
+
} while (requested && sweeps < SESSION_WORKFLOW_WAKE_DISPATCHER_MAX_SWEEPS);
|
|
34
|
+
return result;
|
|
13
35
|
}
|
package/src/workflows.ts
CHANGED
|
@@ -23,11 +23,18 @@ export {
|
|
|
23
23
|
} from "./workflows/knowledge-source-sync";
|
|
24
24
|
export {
|
|
25
25
|
sandboxDrainWorkflow,
|
|
26
|
+
sandboxIdleCheckpointSweepWorkflow,
|
|
27
|
+
sandboxIdleCheckpointWorkflow,
|
|
26
28
|
sandboxReaperMaintenanceWorkflow,
|
|
27
29
|
sandboxReaperWorkflow,
|
|
28
30
|
sandboxReaperWorkflowV2,
|
|
29
31
|
} from "./workflows/sandbox-reaper";
|
|
30
32
|
export { fileUploadReaperWorkflow } from "./workflows/file-upload-reaper";
|
|
33
|
+
export { sessionStorageMaintenanceWorkflow } from "./workflows/session-storage";
|
|
34
|
+
export {
|
|
35
|
+
browserDeadlineCheckpointWorkflow,
|
|
36
|
+
browserDeadlineCheckpointSweepWorkflow,
|
|
37
|
+
} from "./workflows/browser-deadline-checkpoint";
|
|
31
38
|
export { siteAuthMaintenanceWorkflow } from "./workflows/site-auth-maintenance";
|
|
32
39
|
export {
|
|
33
40
|
videoGenerationWorkflow,
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { type CodexFleetReplayRecordV1 } from "@opengeni/contracts";
|
|
2
|
-
import type { CodexLeaseAccountStatus } from "@opengeni/db";
|
|
3
|
-
export declare const CODEX_FLEET_SHADOW_MAX_PAYLOAD_BYTES: number;
|
|
4
|
-
export type CodexFleetActualDecisionV1 = {
|
|
5
|
-
outcome: "selected" | "waiting" | "none";
|
|
6
|
-
candidateKey: string | null;
|
|
7
|
-
reason: "lease_reused" | "affinity_reused" | "assigned" | "switched" | "pin" | "rotation" | "active" | "all_capped" | "allocator_disabled" | "none";
|
|
8
|
-
};
|
|
9
|
-
export type CodexFleetShadowComparisonV1 = "match" | "different_candidate" | "different_outcome" | "not_comparable_truncated";
|
|
10
|
-
export type CodexFleetShadowPayloadV1 = {
|
|
11
|
-
schemaVersion: 1;
|
|
12
|
-
mode: "shadow";
|
|
13
|
-
actual: CodexFleetActualDecisionV1;
|
|
14
|
-
comparison: CodexFleetShadowComparisonV1;
|
|
15
|
-
replay: CodexFleetReplayRecordV1;
|
|
16
|
-
};
|
|
17
|
-
export type CodexFleetShadowBuildInputV1 = {
|
|
18
|
-
accounts: readonly CodexLeaseAccountStatus[];
|
|
19
|
-
actualCredentialId: string | null;
|
|
20
|
-
actualOutcome: CodexFleetActualDecisionV1["outcome"];
|
|
21
|
-
actualReason: CodexFleetActualDecisionV1["reason"];
|
|
22
|
-
affinityCredentialId: string | null;
|
|
23
|
-
fencedInFlight: boolean;
|
|
24
|
-
nearExhaustionPct: number;
|
|
25
|
-
now: Date;
|
|
26
|
-
/** Per-event entropy used only to unlink account aliases; never persisted. */
|
|
27
|
-
aliasSeed: string;
|
|
28
|
-
};
|
|
29
|
-
export type CodexFleetShadowPublicationResultV1 = {
|
|
30
|
-
outcome: "disabled";
|
|
31
|
-
} | {
|
|
32
|
-
outcome: "published";
|
|
33
|
-
payload: CodexFleetShadowPayloadV1;
|
|
34
|
-
payloadBytes: number;
|
|
35
|
-
} | {
|
|
36
|
-
outcome: "failed";
|
|
37
|
-
stage: "build" | "serialize" | "publish";
|
|
38
|
-
reason: "payload_too_large" | "unexpected";
|
|
39
|
-
errorName: string;
|
|
40
|
-
payloadBytes: number | null;
|
|
41
|
-
};
|
|
42
|
-
export declare const CODEX_FLEET_SHADOW_DECISION_MAX_METRIC_SERIES: number;
|
|
43
|
-
export declare const CODEX_FLEET_SHADOW_ERROR_MAX_METRIC_SERIES: number;
|
|
44
|
-
/** Fixed low-cardinality labels; workspace/account/tenant identity is structurally absent. */
|
|
45
|
-
export declare function codexFleetShadowDecisionMetricLabelsV1(payload: CodexFleetShadowPayloadV1): {
|
|
46
|
-
readonly actual_outcome: "none" | "selected" | "waiting";
|
|
47
|
-
readonly shadow_outcome: "none" | "paced" | "selected";
|
|
48
|
-
readonly comparison: CodexFleetShadowComparisonV1;
|
|
49
|
-
readonly confidence: import("@opengeni/contracts").CodexFleetConfidence;
|
|
50
|
-
readonly truncated: "false" | "true";
|
|
51
|
-
};
|
|
52
|
-
export declare function codexFleetShadowErrorMetricLabelsV1(result: Extract<CodexFleetShadowPublicationResultV1, {
|
|
53
|
-
outcome: "failed";
|
|
54
|
-
}>): {
|
|
55
|
-
readonly stage: "build" | "publish" | "serialize";
|
|
56
|
-
readonly reason: "payload_too_large" | "unexpected";
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* Default-off, bounded, fail-open runtime seam for the shadow record.
|
|
60
|
-
*
|
|
61
|
-
* The typed result intentionally carries no error message: provider, database,
|
|
62
|
-
* or transport errors can include private metadata. Callers may count/log only
|
|
63
|
-
* the bounded stage, reason, name, and size fields returned here. A failure can
|
|
64
|
-
* never replace or clear the credential already selected by the allocator.
|
|
65
|
-
*/
|
|
66
|
-
export declare function publishCodexFleetShadowDecisionV1(input: {
|
|
67
|
-
enabled: boolean;
|
|
68
|
-
decision: CodexFleetShadowBuildInputV1;
|
|
69
|
-
publish: (events: Array<{
|
|
70
|
-
type: "codex.fleet.decision";
|
|
71
|
-
payload: CodexFleetShadowPayloadV1;
|
|
72
|
-
}>) => Promise<unknown>;
|
|
73
|
-
}): Promise<CodexFleetShadowPublicationResultV1>;
|
|
74
|
-
export declare function buildCodexFleetShadowPayloadV1(input: CodexFleetShadowBuildInputV1): CodexFleetShadowPayloadV1;
|