@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/sandbox-routing.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isDeepStrictEqual } from "node:util";
|
|
1
2
|
// apps/worker/src/sandbox-routing.ts — wire the agent-loop-free routing proxy
|
|
2
3
|
// (`@opengeni/runtime` RoutingSandboxSession + makeActiveBackendResolver) to the
|
|
3
4
|
// real DB pointer + the live NATS control plane for the WORKER TURN path (M7).
|
|
@@ -39,14 +40,20 @@ import {
|
|
|
39
40
|
readActiveSandbox,
|
|
40
41
|
resolvePersonalMachineConnectionForAttempt,
|
|
41
42
|
SandboxRetainedProcessPromotionFencedError,
|
|
43
|
+
SandboxRetainedProcessTerminalError,
|
|
44
|
+
SandboxWorkspaceMutationOutputRejectedError,
|
|
42
45
|
type Database,
|
|
43
46
|
type EnrollmentRecord,
|
|
44
47
|
type SandboxWorkspaceMutationAdmission,
|
|
45
48
|
} from "@opengeni/db";
|
|
46
|
-
import {
|
|
49
|
+
import {
|
|
50
|
+
observeSessionBackgroundCommandCompletion,
|
|
51
|
+
recordConnectedCommandOutputConsumption,
|
|
52
|
+
} from "@opengeni/db/session-background-commands";
|
|
47
53
|
import { appendSessionCommandOutput } from "@opengeni/db/session-command-output";
|
|
48
54
|
import type { OpStreamOutputFrame } from "@opengeni/runtime/sandbox";
|
|
49
55
|
import type { EventBus } from "@opengeni/events";
|
|
56
|
+
import { publishDurableSessionEvents } from "./session-event-fanout";
|
|
50
57
|
import {
|
|
51
58
|
buildSelfhostedBackendSession,
|
|
52
59
|
ActiveBackendUnresolvableError,
|
|
@@ -58,6 +65,7 @@ import {
|
|
|
58
65
|
NatsOpStreamTransport,
|
|
59
66
|
RoutingBackendRecoveryRequiredError,
|
|
60
67
|
RoutingSandboxSession,
|
|
68
|
+
RoutingMutationOutputRejectedError,
|
|
61
69
|
resolveModalCheckpointProviderBindingForSession,
|
|
62
70
|
resolveConnectedMachineWorkspaceRoot,
|
|
63
71
|
sandboxProviderInstanceIdFromEnvelope,
|
|
@@ -401,6 +409,11 @@ async function resolveCurrentHomeBackend(
|
|
|
401
409
|
diagnostic: "provider_not_found_during_home_route_rebind",
|
|
402
410
|
});
|
|
403
411
|
if (marked.status === "marked") {
|
|
412
|
+
await publishDurableSessionEvents(
|
|
413
|
+
services.bus,
|
|
414
|
+
ids.workspaceId,
|
|
415
|
+
marked.backgroundCommandEvents,
|
|
416
|
+
);
|
|
404
417
|
await services.onHomeSandboxLost?.({
|
|
405
418
|
sandboxGroupId: ids.sandboxGroupId,
|
|
406
419
|
instanceId: lease.instanceId,
|
|
@@ -496,7 +509,7 @@ function afterPersistableHomeMutation(
|
|
|
496
509
|
op: string;
|
|
497
510
|
backend: ResolvedActiveBackend;
|
|
498
511
|
admission: unknown;
|
|
499
|
-
outcome: "resolved" | "rejected";
|
|
512
|
+
outcome: "resolved" | "rejected" | "outcome_unknown";
|
|
500
513
|
result?: unknown;
|
|
501
514
|
retainedProcess?: RoutingRetainedProcess;
|
|
502
515
|
}) => Promise<void | RoutingMutationSettlementResult>)
|
|
@@ -523,7 +536,7 @@ function afterPersistableHomeMutation(
|
|
|
523
536
|
) {
|
|
524
537
|
throw new Error("Persistable home mutation settlement lacked its bound admission");
|
|
525
538
|
}
|
|
526
|
-
if (outcome === "resolved" && retainedProcess) {
|
|
539
|
+
if ((outcome === "resolved" || outcome === "outcome_unknown") && retainedProcess) {
|
|
527
540
|
try {
|
|
528
541
|
await retainWorkspaceProviderCommand(services.db, {
|
|
529
542
|
accountId: fence.accountId,
|
|
@@ -582,21 +595,39 @@ function afterPersistableHomeMutation(
|
|
|
582
595
|
}
|
|
583
596
|
return;
|
|
584
597
|
}
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
598
|
+
if (outcome === "outcome_unknown")
|
|
599
|
+
throw new Error("Outcome-unknown command settlement requires its exact retained invocation");
|
|
600
|
+
try {
|
|
601
|
+
await verifyWorkspaceMutationSettlement(services.db, {
|
|
602
|
+
accountId: fence.accountId,
|
|
603
|
+
workspaceId: ids.workspaceId,
|
|
604
|
+
sessionId: ids.sessionId,
|
|
605
|
+
turnId: fence.turnId,
|
|
606
|
+
executionGeneration: fence.executionGeneration,
|
|
607
|
+
attemptId: fence.attemptId,
|
|
608
|
+
holderId: sandboxLeaseHolderIdForAttempt(fence.attemptId),
|
|
609
|
+
sandboxGroupId: home.sandboxGroupId,
|
|
610
|
+
expectedEpoch: backend.leaseEpoch,
|
|
611
|
+
expectedInstanceId: backend.providerInstanceId,
|
|
612
|
+
admission: exactAdmission,
|
|
613
|
+
operation: op,
|
|
614
|
+
outcome,
|
|
615
|
+
});
|
|
616
|
+
} catch (error) {
|
|
617
|
+
if (
|
|
618
|
+
error instanceof SandboxWorkspaceMutationOutputRejectedError &&
|
|
619
|
+
error.matchesPhysicalSettlement({
|
|
620
|
+
accountId: fence.accountId,
|
|
621
|
+
workspaceId: ids.workspaceId,
|
|
622
|
+
admission: exactAdmission,
|
|
623
|
+
operation: op,
|
|
624
|
+
outcome,
|
|
625
|
+
})
|
|
626
|
+
) {
|
|
627
|
+
throw new RoutingMutationOutputRejectedError(op, error.code, { cause: error });
|
|
628
|
+
}
|
|
629
|
+
throw error;
|
|
630
|
+
}
|
|
600
631
|
};
|
|
601
632
|
}
|
|
602
633
|
|
|
@@ -649,15 +680,42 @@ function afterRetainedProcessMutation(
|
|
|
649
680
|
) {
|
|
650
681
|
throw new Error("Retained-process mutation settlement lacked its exact admission");
|
|
651
682
|
}
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
683
|
+
try {
|
|
684
|
+
await verifyRetainedProcessMutationSettlement(services.db, {
|
|
685
|
+
accountId: fence.accountId,
|
|
686
|
+
workspaceId: ids.workspaceId,
|
|
687
|
+
sessionId: ids.sessionId,
|
|
688
|
+
processId: process.id,
|
|
689
|
+
admission: admission as SandboxWorkspaceMutationAdmission,
|
|
690
|
+
operation: op,
|
|
691
|
+
outcome,
|
|
692
|
+
});
|
|
693
|
+
} catch (error) {
|
|
694
|
+
if (
|
|
695
|
+
error instanceof SandboxWorkspaceMutationOutputRejectedError &&
|
|
696
|
+
error.matchesPhysicalSettlement({
|
|
697
|
+
accountId: fence.accountId,
|
|
698
|
+
workspaceId: ids.workspaceId,
|
|
699
|
+
admission: admission as SandboxWorkspaceMutationAdmission,
|
|
700
|
+
operation: op,
|
|
701
|
+
outcome,
|
|
702
|
+
})
|
|
703
|
+
) {
|
|
704
|
+
if (error.retainedProcessTerminal) {
|
|
705
|
+
// Another authority (the reaper's exact-proof reconciliation) settled
|
|
706
|
+
// this retained process terminal between admission and settlement.
|
|
707
|
+
// The admission is physically settled and its output stays rejected;
|
|
708
|
+
// surface the durable terminal truth so routing reports completion
|
|
709
|
+
// instead of failing the turn. Nothing is replayed.
|
|
710
|
+
throw new SandboxRetainedProcessTerminalError(
|
|
711
|
+
error.retainedProcessTerminal.state,
|
|
712
|
+
error.retainedProcessTerminal.exitCode,
|
|
713
|
+
);
|
|
714
|
+
}
|
|
715
|
+
throw new RoutingMutationOutputRejectedError(op, error.code, { cause: error });
|
|
716
|
+
}
|
|
717
|
+
throw error;
|
|
718
|
+
}
|
|
661
719
|
};
|
|
662
720
|
}
|
|
663
721
|
|
|
@@ -783,6 +841,62 @@ function settleRetainedProcessForTurn(
|
|
|
783
841
|
};
|
|
784
842
|
}
|
|
785
843
|
|
|
844
|
+
/** Cleanup can observe the independently settled row even when this worker's
|
|
845
|
+
* pending output receipt or original provider transport can no longer advance. */
|
|
846
|
+
function isRetainedProcessSettledForTurn(services: RoutingWiringServices, ids: RoutingWiringIds) {
|
|
847
|
+
const fence = ids.workspaceMutationFence;
|
|
848
|
+
if (!fence) return undefined;
|
|
849
|
+
return async ({
|
|
850
|
+
backend,
|
|
851
|
+
process,
|
|
852
|
+
}: {
|
|
853
|
+
backend: ResolvedActiveBackend;
|
|
854
|
+
process: RoutingRetainedProcess;
|
|
855
|
+
}): Promise<boolean> => {
|
|
856
|
+
const durable = await getRetainedProcess(services.db, {
|
|
857
|
+
workspaceId: ids.workspaceId,
|
|
858
|
+
sessionId: ids.sessionId,
|
|
859
|
+
processId: process.id,
|
|
860
|
+
});
|
|
861
|
+
if (
|
|
862
|
+
!durable ||
|
|
863
|
+
durable.state === "active" ||
|
|
864
|
+
durable.providerSessionId !== process.providerSessionId ||
|
|
865
|
+
durable.providerBackend !== (sandboxBackendForSdkBackendId(backend.kind) ?? backend.kind) ||
|
|
866
|
+
durable.providerInstanceId !== backend.providerInstanceId ||
|
|
867
|
+
durable.leaseEpoch !== backend.leaseEpoch ||
|
|
868
|
+
durable.routeKind !== (backend.sandboxId === null ? "home" : "active") ||
|
|
869
|
+
durable.routeTargetId !== backend.sandboxId ||
|
|
870
|
+
durable.routeEpoch !== backend.activeEpoch
|
|
871
|
+
)
|
|
872
|
+
return false;
|
|
873
|
+
if (process.providerCommand) {
|
|
874
|
+
// The general process projection deliberately omits the provider locator.
|
|
875
|
+
// Load its immutable identity through the exact protected persistence seam.
|
|
876
|
+
const command = await retainedProviderCommandPersistence(services.db, {
|
|
877
|
+
accountId: fence.accountId,
|
|
878
|
+
workspaceId: ids.workspaceId,
|
|
879
|
+
sessionId: ids.sessionId,
|
|
880
|
+
processId: process.id,
|
|
881
|
+
}).load();
|
|
882
|
+
if (
|
|
883
|
+
!command ||
|
|
884
|
+
command.kind !== process.providerCommand.kind ||
|
|
885
|
+
command.execId !== process.providerCommand.execId ||
|
|
886
|
+
command.taskId !== process.providerCommand.taskId ||
|
|
887
|
+
command.sandboxId !== process.providerCommand.sandboxId ||
|
|
888
|
+
Boolean(command.pty) !== Boolean(process.providerCommand.pty) ||
|
|
889
|
+
(command.kind === "modal-router-v1" &&
|
|
890
|
+
process.providerCommand.kind === "modal-router-v1" &&
|
|
891
|
+
!isDeepStrictEqual(command.supervision, process.providerCommand.supervision))
|
|
892
|
+
)
|
|
893
|
+
return false;
|
|
894
|
+
}
|
|
895
|
+
// Terminal rows are written only through proof-gated physical settlement.
|
|
896
|
+
return true;
|
|
897
|
+
};
|
|
898
|
+
}
|
|
899
|
+
|
|
786
900
|
function adoptRetainedProcessAsBackgroundCommandForTurn(
|
|
787
901
|
services: RoutingWiringServices,
|
|
788
902
|
ids: RoutingWiringIds,
|
|
@@ -865,6 +979,7 @@ export function wrapTurnBoxWithRouting(
|
|
|
865
979
|
const beforeProcessMutation = beforeRetainedProcessMutation(services, ids);
|
|
866
980
|
const afterProcessMutation = afterRetainedProcessMutation(services, ids);
|
|
867
981
|
const settleProcess = settleRetainedProcessForTurn(services, ids);
|
|
982
|
+
const isProcessSettled = isRetainedProcessSettledForTurn(services, ids);
|
|
868
983
|
const adoptProcessAsBackgroundCommand = adoptRetainedProcessAsBackgroundCommandForTurn(
|
|
869
984
|
services,
|
|
870
985
|
ids,
|
|
@@ -1061,6 +1176,7 @@ export function wrapTurnBoxWithRouting(
|
|
|
1061
1176
|
...(beforeProcessMutation ? { beforeProcessMutation } : {}),
|
|
1062
1177
|
...(afterProcessMutation ? { afterProcessMutation } : {}),
|
|
1063
1178
|
...(settleProcess ? { settleProcess } : {}),
|
|
1179
|
+
...(isProcessSettled ? { isProcessSettled } : {}),
|
|
1064
1180
|
...(ids.workspaceMutationFence
|
|
1065
1181
|
? { observeProcessTerminal: observeRetainedProcessTerminalForTurn(services, ids)! }
|
|
1066
1182
|
: {}),
|
|
@@ -1091,6 +1207,11 @@ export function wrapTurnBoxWithRouting(
|
|
|
1091
1207
|
diagnostic: "provider_not_found_during_routed_operation",
|
|
1092
1208
|
});
|
|
1093
1209
|
if (marked.status === "marked") {
|
|
1210
|
+
await publishDurableSessionEvents(
|
|
1211
|
+
services.bus,
|
|
1212
|
+
ids.workspaceId,
|
|
1213
|
+
marked.backgroundCommandEvents,
|
|
1214
|
+
);
|
|
1094
1215
|
await services.onHomeSandboxLost?.({
|
|
1095
1216
|
sandboxGroupId: home.sandboxGroupId,
|
|
1096
1217
|
instanceId: expectedInstanceId,
|
|
@@ -1147,6 +1268,7 @@ export function wrapLazyTurnBoxWithRouting(
|
|
|
1147
1268
|
const beforeProcessMutation = beforeRetainedProcessMutation(services, ids);
|
|
1148
1269
|
const afterProcessMutation = afterRetainedProcessMutation(services, ids);
|
|
1149
1270
|
const settleProcess = settleRetainedProcessForTurn(services, ids);
|
|
1271
|
+
const isProcessSettled = isRetainedProcessSettledForTurn(services, ids);
|
|
1150
1272
|
const adoptProcessAsBackgroundCommand = adoptRetainedProcessAsBackgroundCommandForTurn(
|
|
1151
1273
|
services,
|
|
1152
1274
|
ids,
|
|
@@ -1322,6 +1444,7 @@ export function wrapLazyTurnBoxWithRouting(
|
|
|
1322
1444
|
...(beforeProcessMutation ? { beforeProcessMutation } : {}),
|
|
1323
1445
|
...(afterProcessMutation ? { afterProcessMutation } : {}),
|
|
1324
1446
|
...(settleProcess ? { settleProcess } : {}),
|
|
1447
|
+
...(isProcessSettled ? { isProcessSettled } : {}),
|
|
1325
1448
|
...(ids.workspaceMutationFence
|
|
1326
1449
|
? { observeProcessTerminal: observeRetainedProcessTerminalForTurn(services, ids)! }
|
|
1327
1450
|
: {}),
|
|
@@ -1353,6 +1476,11 @@ export function wrapLazyTurnBoxWithRouting(
|
|
|
1353
1476
|
diagnostic: "provider_not_found_during_routed_operation",
|
|
1354
1477
|
});
|
|
1355
1478
|
if (marked.status === "marked") {
|
|
1479
|
+
await publishDurableSessionEvents(
|
|
1480
|
+
services.bus,
|
|
1481
|
+
ids.workspaceId,
|
|
1482
|
+
marked.backgroundCommandEvents,
|
|
1483
|
+
);
|
|
1356
1484
|
await services.onHomeSandboxLost?.({
|
|
1357
1485
|
sandboxGroupId: home.sandboxGroupId,
|
|
1358
1486
|
instanceId: backend.providerInstanceId,
|
|
@@ -1426,8 +1554,10 @@ export type SelfhostedTurnSessionArgs = {
|
|
|
1426
1554
|
workingDir: string | null;
|
|
1427
1555
|
/** Effective absolute host-native root frozen for this attempt. */
|
|
1428
1556
|
workspaceRoot: string;
|
|
1429
|
-
/** Present
|
|
1430
|
-
*
|
|
1557
|
+
/** Present whenever the turn has an initiating human. A machine can become
|
|
1558
|
+
* Only me during the turn, so every provider operation reads the current
|
|
1559
|
+
* scope and rechecks this frozen accepted-attempt authority immediately
|
|
1560
|
+
* before dispatch while the machine is user-owned. */
|
|
1431
1561
|
personalMachineAttempt?: NonNullable<RoutingWiringIds["personalMachineAttempt"]> & {
|
|
1432
1562
|
sessionId: string;
|
|
1433
1563
|
};
|
|
@@ -1491,42 +1621,46 @@ export function connectionBindingFor(
|
|
|
1491
1621
|
};
|
|
1492
1622
|
}
|
|
1493
1623
|
|
|
1494
|
-
/** Personal-machine discovery is not execution authority.
|
|
1495
|
-
*
|
|
1496
|
-
*
|
|
1497
|
-
*
|
|
1624
|
+
/** Personal-machine discovery is not execution authority. A machine's audience
|
|
1625
|
+
* can change in place while a routed session is cached, so the current scope is
|
|
1626
|
+
* read from the enrollment itself, never from the sandbox snapshot taken when
|
|
1627
|
+
* the session was built. A machine that is Only me now rechecks the frozen
|
|
1628
|
+
* initiating human, exact current attempt, authorization snapshot and current
|
|
1629
|
+
* visibility-keyed grant immediately before each routed operation resolves a
|
|
1630
|
+
* live control-plane connection. */
|
|
1498
1631
|
async function resolveRoutedMachineConnection(
|
|
1499
1632
|
db: Database,
|
|
1500
1633
|
ids: RoutingWiringIds,
|
|
1501
1634
|
sandbox: RoutableSandbox,
|
|
1502
1635
|
): Promise<EnrollmentRecord | null> {
|
|
1503
1636
|
if (!sandbox.enrollmentId) return null;
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1637
|
+
const current = await getLiveEnrollmentConnection(db, sandbox.workspaceId, sandbox.enrollmentId);
|
|
1638
|
+
if (!current) return null;
|
|
1639
|
+
if (current.scope === "user") {
|
|
1640
|
+
const authority = ids.personalMachineAttempt;
|
|
1641
|
+
if (!authority) return null;
|
|
1642
|
+
return await resolvePersonalMachineConnectionForAttempt(db, {
|
|
1643
|
+
accountId: authority.accountId,
|
|
1644
|
+
workspaceId: ids.workspaceId,
|
|
1645
|
+
subjectId: authority.subjectId,
|
|
1646
|
+
sessionId: ids.sessionId,
|
|
1647
|
+
turnId: authority.turnId,
|
|
1648
|
+
attemptId: authority.attemptId,
|
|
1649
|
+
executionGeneration: authority.executionGeneration,
|
|
1650
|
+
enrollmentId: sandbox.enrollmentId,
|
|
1651
|
+
requireActiveSandbox: true,
|
|
1652
|
+
});
|
|
1516
1653
|
}
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
enrollmentId: sandbox.enrollmentId,
|
|
1528
|
-
requireActiveSandbox: true,
|
|
1529
|
-
});
|
|
1654
|
+
if (!ids.resourceAccountId || !ids.resourceSubjectId) return current;
|
|
1655
|
+
return await getLiveEnrollmentConnection(
|
|
1656
|
+
db,
|
|
1657
|
+
{
|
|
1658
|
+
accountId: ids.resourceAccountId,
|
|
1659
|
+
workspaceId: ids.workspaceId,
|
|
1660
|
+
subjectId: ids.resourceSubjectId,
|
|
1661
|
+
},
|
|
1662
|
+
sandbox.enrollmentId,
|
|
1663
|
+
);
|
|
1530
1664
|
}
|
|
1531
1665
|
|
|
1532
1666
|
export async function establishSelfhostedTurnSession(
|
|
@@ -1560,23 +1694,30 @@ export async function establishSelfhostedTurnSession(
|
|
|
1560
1694
|
operationCpuQuotaSupported: args.operationCpuQuotaSupported,
|
|
1561
1695
|
transactionalFsWriteSupported: args.transactionalFsWriteSupported === true,
|
|
1562
1696
|
resolveOperationAdmission: async () => {
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1697
|
+
// The machine's audience can change in place during a turn. Read the
|
|
1698
|
+
// current scope on every admitted operation: a machine that is Only me now
|
|
1699
|
+
// needs the frozen accepted-attempt authority, a shared one does not.
|
|
1700
|
+
const current = await getLiveEnrollmentConnection(
|
|
1701
|
+
db,
|
|
1702
|
+
args.controlWorkspaceId ?? args.workspaceId,
|
|
1703
|
+
args.agentId,
|
|
1704
|
+
);
|
|
1705
|
+
const enrollment =
|
|
1706
|
+
current?.scope !== "user"
|
|
1707
|
+
? current
|
|
1708
|
+
: args.personalMachineAttempt
|
|
1709
|
+
? await resolvePersonalMachineConnectionForAttempt(db, {
|
|
1710
|
+
accountId: args.personalMachineAttempt.accountId,
|
|
1711
|
+
workspaceId: args.workspaceId,
|
|
1712
|
+
subjectId: args.personalMachineAttempt.subjectId,
|
|
1713
|
+
sessionId: args.personalMachineAttempt.sessionId,
|
|
1714
|
+
turnId: args.personalMachineAttempt.turnId,
|
|
1715
|
+
attemptId: args.personalMachineAttempt.attemptId,
|
|
1716
|
+
executionGeneration: args.personalMachineAttempt.executionGeneration,
|
|
1717
|
+
enrollmentId: args.agentId,
|
|
1718
|
+
requireActiveSandbox: true,
|
|
1719
|
+
})
|
|
1720
|
+
: null;
|
|
1580
1721
|
const binding = connectionBindingFor(services, enrollment);
|
|
1581
1722
|
if (!binding) return null;
|
|
1582
1723
|
if (!binding.workspaceRoot) {
|
|
@@ -1635,6 +1776,20 @@ export async function establishSelfhostedTurnSession(
|
|
|
1635
1776
|
reason: command.reason,
|
|
1636
1777
|
...(command.failure ? { failure: command.failure } : {}),
|
|
1637
1778
|
});
|
|
1779
|
+
if (command.outputReceipt && command.outcome === "exited" && command.exitCode !== null) {
|
|
1780
|
+
await recordConnectedCommandOutputConsumption(db, {
|
|
1781
|
+
accountId: args.accountId,
|
|
1782
|
+
workspaceId: args.workspaceId,
|
|
1783
|
+
sessionId: args.sessionId,
|
|
1784
|
+
commandId: command.commandId,
|
|
1785
|
+
controlWorkspaceId: command.controlWorkspaceId,
|
|
1786
|
+
enrollmentId: command.enrollmentId,
|
|
1787
|
+
connectionInstanceId: command.connectionInstanceId,
|
|
1788
|
+
opId: command.opId,
|
|
1789
|
+
receipt: command.outputReceipt,
|
|
1790
|
+
exitCode: command.exitCode,
|
|
1791
|
+
});
|
|
1792
|
+
}
|
|
1638
1793
|
if (settlement && bus) {
|
|
1639
1794
|
await bus
|
|
1640
1795
|
.publish(args.workspaceId, args.sessionId, settlement.events)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { SessionEvent } from "@opengeni/contracts";
|
|
2
|
+
import type { EventBus } from "@opengeni/events";
|
|
3
|
+
|
|
4
|
+
/** Best-effort live fanout of events that are already durable, grouped by
|
|
5
|
+
* session. Durable catch-up remains the source of truth, so failures are only
|
|
6
|
+
* reported. */
|
|
7
|
+
export async function publishDurableSessionEvents(
|
|
8
|
+
bus: EventBus | null | undefined,
|
|
9
|
+
workspaceId: string,
|
|
10
|
+
events: readonly SessionEvent[] | undefined,
|
|
11
|
+
onError: (error: unknown) => void = () => undefined,
|
|
12
|
+
): Promise<void> {
|
|
13
|
+
if (!bus || !events?.length) return;
|
|
14
|
+
for (const sessionId of new Set(events.map((event) => event.sessionId))) {
|
|
15
|
+
await bus
|
|
16
|
+
.publish(
|
|
17
|
+
workspaceId,
|
|
18
|
+
sessionId,
|
|
19
|
+
events.filter((event) => event.sessionId === sessionId),
|
|
20
|
+
)
|
|
21
|
+
.catch(onError);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** Small injectable clock edges for deterministic telemetry lifecycle tests. */
|
|
2
|
+
export type TelemetryScheduler = {
|
|
3
|
+
timeout(callback: () => void, delayMs: number): () => void;
|
|
4
|
+
interval(callback: () => void, intervalMs: number): () => void;
|
|
5
|
+
defer(callback: () => void): void;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const telemetryScheduler: TelemetryScheduler = {
|
|
9
|
+
timeout(callback, delayMs) {
|
|
10
|
+
const timer = setTimeout(callback, delayMs);
|
|
11
|
+
timer.unref?.();
|
|
12
|
+
return () => clearTimeout(timer);
|
|
13
|
+
},
|
|
14
|
+
interval(callback, intervalMs) {
|
|
15
|
+
const timer = setInterval(callback, intervalMs);
|
|
16
|
+
timer.unref?.();
|
|
17
|
+
return () => clearInterval(timer);
|
|
18
|
+
},
|
|
19
|
+
defer: queueMicrotask,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export function telemetryInterval(value: number, name: string): number {
|
|
23
|
+
if (!Number.isSafeInteger(value) || value < 1) {
|
|
24
|
+
throw new Error(`${name} must be a positive integer`);
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Bad/regressing clocks are unknown, not a new timestamp or a zero age.
|
|
30
|
+
* Retain the last valid high-water observation for diagnostic age reporting. */
|
|
31
|
+
export function createTelemetryClock(now: () => number) {
|
|
32
|
+
let latest: number | null = null;
|
|
33
|
+
return {
|
|
34
|
+
read(): number | null {
|
|
35
|
+
let observed: number;
|
|
36
|
+
try {
|
|
37
|
+
observed = now();
|
|
38
|
+
} catch {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
if (
|
|
42
|
+
!Number.isFinite(observed) ||
|
|
43
|
+
observed < 0 ||
|
|
44
|
+
observed > Number.MAX_SAFE_INTEGER ||
|
|
45
|
+
(latest !== null && observed < latest)
|
|
46
|
+
)
|
|
47
|
+
return null;
|
|
48
|
+
latest = observed;
|
|
49
|
+
return observed;
|
|
50
|
+
},
|
|
51
|
+
latest: () => latest,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { createTemporalSdkLogger, type Observability } from "@opengeni/observability";
|
|
2
|
+
import { makeTelemetryFilterString, Runtime, type RuntimeOptions } from "@temporalio/worker";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Runtime options that send every Temporal SDK log record, including records
|
|
6
|
+
* forwarded from the Rust core, through the structured Opengeni logger.
|
|
7
|
+
* Without this the SDK's DefaultLogger prints multi-line objects (with task
|
|
8
|
+
* tokens, raw errors and stacks) and core prints plain text, both outside the
|
|
9
|
+
* public log projection and the one-JSON-object-per-line contract.
|
|
10
|
+
*/
|
|
11
|
+
export function temporalRuntimeLoggingOptions(
|
|
12
|
+
observability: Pick<Observability, "log">,
|
|
13
|
+
): RuntimeOptions {
|
|
14
|
+
return {
|
|
15
|
+
logger: createTemporalSdkLogger(observability),
|
|
16
|
+
telemetryOptions: {
|
|
17
|
+
logging: {
|
|
18
|
+
// The SDK's default core filter, now forwarded instead of printed.
|
|
19
|
+
filter: makeTelemetryFilterString({ core: "WARN", other: "ERROR" }),
|
|
20
|
+
forward: {},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
type RuntimeInstaller = {
|
|
27
|
+
readonly _instance?: unknown;
|
|
28
|
+
install(options: RuntimeOptions): unknown;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Install the process-wide Temporal Runtime with the structured logger. Must
|
|
33
|
+
* run before the first NativeConnection or Worker is created. Returns false
|
|
34
|
+
* when an embedding host already installed its own Runtime, which is left
|
|
35
|
+
* untouched.
|
|
36
|
+
*/
|
|
37
|
+
export function installTemporalRuntimeLogging(
|
|
38
|
+
observability: Pick<Observability, "log">,
|
|
39
|
+
runtime: RuntimeInstaller = Runtime,
|
|
40
|
+
): boolean {
|
|
41
|
+
if (runtime._instance !== undefined) return false;
|
|
42
|
+
runtime.install(temporalRuntimeLoggingOptions(observability));
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { Connection, type ConnectionOptions } from "@temporalio/client";
|
|
2
|
+
import {
|
|
3
|
+
normalizeTurnTaskQueueStats,
|
|
4
|
+
type TurnTaskQueueIdentity,
|
|
5
|
+
type TurnTaskQueueReadOptions,
|
|
6
|
+
type TurnTaskQueueStats,
|
|
7
|
+
} from "./observability-metrics";
|
|
8
|
+
import {
|
|
9
|
+
telemetryInterval,
|
|
10
|
+
telemetryScheduler,
|
|
11
|
+
type TelemetryScheduler,
|
|
12
|
+
} from "./telemetry-scheduler";
|
|
13
|
+
|
|
14
|
+
/** Own diagnostic traffic separately from admission/signaling. SDK1.22's retry
|
|
15
|
+
* interceptor does not cancel backoff or replacement calls, so each diagnostic
|
|
16
|
+
* RPC is one native attempt; the monitor schedules any later observation.
|
|
17
|
+
* Lazy construction avoids another startup/connect retry or an unbounded probe. */
|
|
18
|
+
export function createTurnTaskQueueStatsClient(
|
|
19
|
+
connectionOptions: ConnectionOptions,
|
|
20
|
+
input: { scheduler?: TelemetryScheduler; closeTimeoutMs?: number } = {},
|
|
21
|
+
): {
|
|
22
|
+
read(
|
|
23
|
+
options: TurnTaskQueueReadOptions,
|
|
24
|
+
identity: TurnTaskQueueIdentity,
|
|
25
|
+
): Promise<TurnTaskQueueStats>;
|
|
26
|
+
close(): Promise<void>;
|
|
27
|
+
} {
|
|
28
|
+
const scheduler = input.scheduler ?? telemetryScheduler;
|
|
29
|
+
const closeTimeoutMs = telemetryInterval(
|
|
30
|
+
input.closeTimeoutMs ?? 1_000,
|
|
31
|
+
"queue client closeTimeoutMs",
|
|
32
|
+
);
|
|
33
|
+
let connection: Connection | undefined;
|
|
34
|
+
let closed = false;
|
|
35
|
+
let closing: Promise<void> | undefined;
|
|
36
|
+
const active = new Set<AbortController>();
|
|
37
|
+
return {
|
|
38
|
+
read: async ({ signal, deadline }, identity) => {
|
|
39
|
+
signal.throwIfAborted();
|
|
40
|
+
if (closed) throw new Error("turn task-queue diagnostic client is closed");
|
|
41
|
+
const controller = new AbortController();
|
|
42
|
+
const abort = () => controller.abort(signal.reason);
|
|
43
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
44
|
+
active.add(controller);
|
|
45
|
+
try {
|
|
46
|
+
connection ??= Connection.lazy({ ...connectionOptions, interceptors: [] });
|
|
47
|
+
const stats = await createTurnTaskQueueStatsReader(
|
|
48
|
+
connection,
|
|
49
|
+
identity,
|
|
50
|
+
)({
|
|
51
|
+
signal: controller.signal,
|
|
52
|
+
deadline,
|
|
53
|
+
});
|
|
54
|
+
controller.signal.throwIfAborted(); // Close/abort cannot resurrect a late result.
|
|
55
|
+
return stats;
|
|
56
|
+
} finally {
|
|
57
|
+
active.delete(controller);
|
|
58
|
+
signal.removeEventListener("abort", abort);
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
close: () => {
|
|
62
|
+
if (closing) return closing;
|
|
63
|
+
closed = true;
|
|
64
|
+
for (const controller of active) controller.abort();
|
|
65
|
+
const owned = connection;
|
|
66
|
+
if (!owned) return (closing = Promise.resolve());
|
|
67
|
+
closing = new Promise<void>((resolve) => {
|
|
68
|
+
const cancelTimeout = scheduler.timeout(resolve, closeTimeoutMs);
|
|
69
|
+
const settled = () => {
|
|
70
|
+
cancelTimeout();
|
|
71
|
+
resolve();
|
|
72
|
+
};
|
|
73
|
+
try {
|
|
74
|
+
void owned.close().then(settled, settled);
|
|
75
|
+
} catch {
|
|
76
|
+
settled(); // Diagnostic close failure must not break worker cleanup.
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
return closing;
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Scope only this diagnostic RPC, never signal/start/admission traffic. Both
|
|
85
|
+
* call-context APIs are public in the pinned Temporal TS SDK 1.22. The caller
|
|
86
|
+
* must supply a retry-disabled connection (the owned client above does so). */
|
|
87
|
+
export function createTurnTaskQueueStatsReader(
|
|
88
|
+
connection: Pick<Connection, "workflowService" | "withDeadline" | "withAbortSignal">,
|
|
89
|
+
identity: TurnTaskQueueIdentity,
|
|
90
|
+
): (options: TurnTaskQueueReadOptions) => Promise<TurnTaskQueueStats> {
|
|
91
|
+
return async ({ signal, deadline }) => {
|
|
92
|
+
// SDK1.22 installs its cancel listener when creating the gRPC call; do not
|
|
93
|
+
// launch a call with an already-aborted signal whose event has passed.
|
|
94
|
+
signal.throwIfAborted();
|
|
95
|
+
return connection.withAbortSignal(signal, () =>
|
|
96
|
+
connection.withDeadline(deadline, async () => {
|
|
97
|
+
signal.throwIfAborted();
|
|
98
|
+
const response = await connection.workflowService.describeTaskQueue({
|
|
99
|
+
namespace: identity.temporalNamespace,
|
|
100
|
+
taskQueue: { name: identity.taskQueue },
|
|
101
|
+
// TASK_QUEUE_TYPE_ACTIVITY, supported DEFAULT mode. This is the shared
|
|
102
|
+
// turn-worker activity queue (also video/retries), not a turn count.
|
|
103
|
+
taskQueueType: 2,
|
|
104
|
+
reportStats: true,
|
|
105
|
+
});
|
|
106
|
+
return normalizeTurnTaskQueueStats(response.stats);
|
|
107
|
+
}),
|
|
108
|
+
);
|
|
109
|
+
};
|
|
110
|
+
}
|