@opengeni/worker-bundle 2.0.1 → 2.0.2-canary.38686408778001
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/activities/agent-run-admission.d.ts +1 -12
- package/dist/activities/agent-turn/admission.d.ts +88 -10
- package/dist/activities/agent-turn/agent-build.d.ts +14 -3
- package/dist/activities/agent-turn/claim.d.ts +4 -1
- package/dist/activities/agent-turn/claude-core.d.ts +195 -0
- package/dist/activities/agent-turn/code-search.d.ts +60 -0
- package/dist/activities/agent-turn/codex-capacity.d.ts +3 -0
- package/dist/activities/agent-turn/codex-core-capacity.d.ts +37 -0
- package/dist/activities/agent-turn/codex-core-claim.d.ts +40 -0
- package/dist/activities/agent-turn/codex-core-errors.d.ts +102 -0
- package/dist/activities/agent-turn/codex-core-failover.d.ts +15 -0
- package/dist/activities/agent-turn/codex-core-requests.d.ts +28 -0
- package/dist/activities/agent-turn/codex-core-settlement.d.ts +77 -0
- package/dist/activities/agent-turn/codex-credit-policy.d.ts +30 -0
- package/dist/activities/agent-turn/codex-plan-entitlement.d.ts +105 -0
- package/dist/activities/agent-turn/codex-usage-policy.d.ts +2 -0
- package/dist/activities/agent-turn/codex.d.ts +2 -19
- package/dist/activities/agent-turn/compaction-interruption.d.ts +32 -0
- package/dist/activities/agent-turn/compaction-prep.d.ts +30 -1
- package/dist/activities/agent-turn/credential-leases.d.ts +64 -37
- package/dist/activities/agent-turn/credential-restriction.d.ts +3 -0
- package/dist/activities/agent-turn/errors.d.ts +172 -28
- package/dist/activities/agent-turn/failure-settlement.d.ts +10 -43
- package/dist/activities/agent-turn/final-reply.d.ts +18 -0
- package/dist/activities/agent-turn/finalization-monitor.d.ts +7 -2
- package/dist/activities/agent-turn/finalization.d.ts +2 -0
- package/dist/activities/agent-turn/github-repository-bindings.d.ts +2 -0
- package/dist/activities/agent-turn/governance-model.d.ts +13 -1
- package/dist/activities/agent-turn/history-sink.d.ts +3 -1
- package/dist/activities/agent-turn/history.d.ts +2 -0
- package/dist/activities/agent-turn/input-wait-reply.d.ts +76 -0
- package/dist/activities/agent-turn/meaningful-output.d.ts +9 -0
- package/dist/activities/agent-turn/media-artifacts.d.ts +5 -3
- package/dist/activities/agent-turn/model-call-admission.d.ts +15 -0
- package/dist/activities/agent-turn/model-usage.d.ts +56 -14
- package/dist/activities/agent-turn/model-wire-dispatch.d.ts +15 -0
- package/dist/activities/agent-turn/optional-repositories.d.ts +59 -0
- package/dist/activities/agent-turn/prompt-tool-availability.d.ts +17 -0
- package/dist/activities/agent-turn/provider-dispatch-barrier.d.ts +12 -1
- package/dist/activities/agent-turn/provider-recovery-copy.d.ts +24 -0
- package/dist/activities/agent-turn/provider-recovery-metrics.d.ts +18 -0
- package/dist/activities/agent-turn/provider-recovery-policy.d.ts +6 -0
- package/dist/activities/agent-turn/quiescence.d.ts +6 -7
- package/dist/activities/agent-turn/recovery-warning.d.ts +6 -5
- package/dist/activities/agent-turn/refresh-credentials.d.ts +6 -0
- package/dist/activities/agent-turn/run-credentials.d.ts +9 -5
- package/dist/activities/agent-turn/run.d.ts +27 -2
- package/dist/activities/agent-turn/sandbox-establish.d.ts +1 -0
- package/dist/activities/agent-turn/sandbox-provision.d.ts +25 -1
- package/dist/activities/agent-turn/sandbox-route.d.ts +3 -0
- package/dist/activities/agent-turn/sandbox-runtime.d.ts +1 -1
- package/dist/activities/agent-turn/secret-resolver.d.ts +64 -0
- package/dist/activities/agent-turn/session-title.d.ts +60 -3
- package/dist/activities/agent-turn/session-usage-custody.d.ts +66 -0
- package/dist/activities/agent-turn/skill-checkout.d.ts +25 -6
- package/dist/activities/agent-turn/skill-read.d.ts +70 -2
- package/dist/activities/agent-turn/skill-search.d.ts +2 -0
- package/dist/activities/agent-turn/skill-tools.d.ts +41 -4
- package/dist/activities/agent-turn/skill-transfer.d.ts +18 -6
- package/dist/activities/agent-turn/stream-attempt.d.ts +6 -3
- package/dist/activities/agent-turn/subscription-capacity-arming.d.ts +41 -0
- package/dist/activities/agent-turn/subscription-core-capacity.d.ts +86 -0
- package/dist/activities/agent-turn/subscription-core-failover.d.ts +69 -0
- package/dist/activities/agent-turn/subscription-core-placed.d.ts +14 -0
- package/dist/activities/agent-turn/subscription-core-requests.d.ts +109 -0
- package/dist/activities/agent-turn/subscription-core-settlement.d.ts +112 -0
- package/dist/activities/agent-turn/subscription-lease.d.ts +44 -0
- package/dist/activities/agent-turn/subscription-serving-capacity.d.ts +6 -0
- package/dist/activities/agent-turn/subscription-serving-catalog.d.ts +13 -0
- package/dist/activities/agent-turn/subscription-serving-claim.d.ts +30 -0
- package/dist/activities/agent-turn/subscription-serving-providers.d.ts +2 -0
- package/dist/activities/agent-turn/tool-environment.d.ts +30 -6
- package/dist/activities/agent-turn/tool-policy.d.ts +55 -3
- package/dist/activities/agent-turn/turn-context.d.ts +104 -5
- package/dist/activities/agent-turn/web-search.d.ts +57 -0
- package/dist/activities/agent-turn/xai-core.d.ts +96 -0
- package/dist/activities/automations.d.ts +3 -1
- package/dist/activities/browser-deadline-checkpoint.d.ts +34 -0
- package/dist/activities/capabilities.d.ts +8 -20
- package/dist/activities/codemode-dispatcher.d.ts +20 -3
- package/dist/activities/codex-capacity.d.ts +1 -56
- package/dist/activities/codex-image-generation.d.ts +49 -3
- package/dist/activities/common.d.ts +3 -1
- package/dist/activities/context-compaction.d.ts +41 -2
- package/dist/activities/environment.d.ts +1 -19
- package/dist/activities/gmail-files.d.ts +50 -0
- package/dist/activities/goals.d.ts +1 -9
- package/dist/activities/incident-telemetry-authority.d.ts +5 -2
- package/dist/activities/incident-telemetry-preflight.d.ts +10 -3
- package/dist/activities/knowledge-indexing.d.ts +19 -0
- package/dist/activities/mcp-account-routes.d.ts +2 -21
- package/dist/activities/model-call-fact-reconciler.d.ts +34 -0
- package/dist/activities/open-suffix-resume.d.ts +15 -0
- package/dist/activities/parent-wake.d.ts +17 -12
- package/dist/activities/programmatic-approvals.d.ts +10 -0
- package/dist/activities/requester-unavailable-receipt.d.ts +8 -0
- package/dist/activities/retained-screenshots.d.ts +7 -2
- package/dist/activities/run-credential-renewal.d.ts +1 -0
- package/dist/activities/run-credentials.d.ts +16 -4
- package/dist/activities/run-input.d.ts +17 -0
- package/dist/activities/sandbox-lease.d.ts +132 -12
- package/dist/activities/scheduled-tasks.d.ts +4 -35
- package/dist/activities/session-archive.d.ts +58 -0
- package/dist/activities/session-state.d.ts +15 -3
- package/dist/activities/session-storage.d.ts +44 -0
- package/dist/activities/subscription-core-claude-waits.d.ts +2 -0
- package/dist/activities/subscription-core-codex-quota.d.ts +25 -0
- package/dist/activities/subscription-core-codex-waits.d.ts +153 -0
- package/dist/activities/subscription-core-image-operation.d.ts +29 -0
- package/dist/activities/subscription-core-usage-recheck.d.ts +49 -0
- package/dist/activities/subscription-core-wait-bindings.d.ts +3 -0
- package/dist/activities/subscription-core-xai-quota.d.ts +30 -0
- package/dist/activities/subscription-core-xai-waits.d.ts +2 -0
- package/dist/activities/types.d.ts +68 -5
- package/dist/activities/video-generation-admission.d.ts +2 -8
- package/dist/activities/video-generation-credential.d.ts +15 -12
- package/dist/activities/video-generation-subscription-core.d.ts +70 -0
- package/dist/activities/workspace-capture.d.ts +2 -0
- package/dist/activities/workspace-credential-provider.d.ts +47 -0
- package/dist/activities/xai-auth.d.ts +6 -18
- package/dist/activities/xai-image-generation.d.ts +22 -6
- package/dist/{activities-control-QA6OLRQY.js → activities-control-NTXZHYET.js} +1552 -2876
- package/dist/activities-control-NTXZHYET.js.map +1 -0
- package/dist/activities-control.d.ts +64 -4
- package/dist/{activities-turn-YVVKCGAK.js → activities-turn-RKRI5GY4.js} +9238 -4392
- package/dist/activities-turn-RKRI5GY4.js.map +1 -0
- package/dist/activities.d.ts +64 -4
- package/dist/artifact-materializer-entry.js +104 -35
- package/dist/artifact-materializer-entry.js.map +1 -1
- package/dist/artifact-outbox-entry.js +132 -61
- package/dist/artifact-outbox-entry.js.map +1 -1
- package/dist/browser-deadline-checkpoint-contract.d.ts +2 -0
- package/dist/{chunk-GDCLDKSH.js → chunk-24GP3BX5.js} +79 -72
- package/dist/chunk-24GP3BX5.js.map +1 -0
- package/dist/{chunk-RAMNYSAW.js → chunk-4ER3YXOT.js} +22 -4
- package/dist/chunk-4ER3YXOT.js.map +1 -0
- package/dist/{chunk-I7HKKMUJ.js → chunk-5NNS4327.js} +734 -58
- package/dist/chunk-5NNS4327.js.map +1 -0
- package/dist/{chunk-M3NVMF2V.js → chunk-7BIHFUGB.js} +2293 -3956
- package/dist/chunk-7BIHFUGB.js.map +1 -0
- package/dist/chunk-MVESOYFC.js +3746 -0
- package/dist/chunk-MVESOYFC.js.map +1 -0
- package/dist/chunk-NQDVJ6RI.js +2823 -0
- package/dist/chunk-NQDVJ6RI.js.map +1 -0
- package/dist/chunk-O7UPBWXK.js +79 -0
- package/dist/chunk-O7UPBWXK.js.map +1 -0
- package/dist/chunk-W2QSM5HR.js +414 -0
- package/dist/chunk-W2QSM5HR.js.map +1 -0
- package/dist/chunk-ZN3XJR33.js +227 -0
- package/dist/chunk-ZN3XJR33.js.map +1 -0
- package/dist/editable-artifact-outbox-dispatcher.d.ts +12 -1
- package/dist/editable-artifact-outbox-service.d.ts +3 -1
- package/dist/host-export-pump.d.ts +3 -1
- package/dist/host-export.d.ts +2 -2
- package/dist/host-export.js +1 -1
- package/dist/http.d.ts +1 -1
- package/dist/index.d.ts +49 -48
- package/dist/index.js +835 -256
- package/dist/index.js.map +1 -1
- package/dist/internal-maintenance.d.ts +63 -0
- package/dist/maintenance-cadence.d.ts +43 -0
- package/dist/observability-metrics.d.ts +293 -24
- package/dist/onepassword-vault-provider.d.ts +7 -0
- package/dist/parent-wake-PCLH7A3Y.js +24 -0
- package/dist/parent-wake-PCLH7A3Y.js.map +1 -0
- package/dist/personal-github-git-credentials.d.ts +1 -1
- package/dist/readiness-checks.d.ts +39 -0
- package/dist/retained-process-retry.d.ts +7 -0
- package/dist/sandbox-lease-BJYU72N3.js +84 -0
- package/dist/sandbox-lease-BJYU72N3.js.map +1 -0
- package/dist/sandbox-reaper-contract.d.ts +25 -0
- package/dist/sandbox-resume.d.ts +72 -4
- package/dist/sandbox-routing.d.ts +4 -2
- package/dist/session-event-fanout.d.ts +6 -0
- package/dist/site-auth-maintenance-WK3MR2PV.js +12 -0
- package/dist/site-auth-maintenance-WK3MR2PV.js.map +1 -0
- package/dist/telemetry-scheduler.d.ts +14 -0
- package/dist/temporal-runtime-logger.d.ts +22 -0
- package/dist/turn-task-queue-reader.d.ts +18 -0
- package/dist/turn-worker-activity-telemetry.d.ts +47 -0
- package/dist/worker-service-lifecycle.d.ts +12 -0
- package/dist/workflow-bundle.js +468 -71
- package/dist/workflows/activities.d.ts +1 -1
- package/dist/workflows/browser-deadline-checkpoint.d.ts +10 -0
- package/dist/workflows/sandbox-reaper.d.ts +10 -1
- package/dist/workflows/scheduled-tasks.d.ts +4 -0
- package/dist/workflows/session-storage.d.ts +2 -0
- package/dist/workflows/session.d.ts +36 -0
- package/dist/workflows/site-auth-maintenance.d.ts +2 -1
- package/dist/workflows/workflow-wake.d.ts +14 -3
- package/dist/workflows.d.ts +3 -1
- package/package.json +26 -20
- package/src/activities/agent-run-admission.ts +1 -82
- package/src/activities/agent-turn/admission.ts +175 -24
- package/src/activities/agent-turn/agent-build.ts +226 -145
- package/src/activities/agent-turn/claim.ts +363 -64
- package/src/activities/agent-turn/claude-core.ts +587 -0
- package/src/activities/agent-turn/code-search.ts +275 -0
- package/src/activities/agent-turn/codex-capacity.ts +30 -757
- package/src/activities/agent-turn/codex-core-capacity.ts +190 -0
- package/src/activities/agent-turn/codex-core-claim.ts +83 -0
- package/src/activities/agent-turn/codex-core-errors.ts +308 -0
- package/src/activities/agent-turn/codex-core-failover.ts +73 -0
- package/src/activities/agent-turn/codex-core-requests.ts +86 -0
- package/src/activities/agent-turn/codex-core-settlement.ts +263 -0
- package/src/activities/agent-turn/codex-credit-policy.ts +247 -0
- package/src/activities/agent-turn/codex-plan-entitlement.ts +254 -0
- package/src/activities/agent-turn/codex-usage-policy.ts +2 -0
- package/src/activities/agent-turn/codex.ts +8 -76
- package/src/activities/agent-turn/compaction-interruption.ts +56 -0
- package/src/activities/agent-turn/compaction-prep.ts +249 -36
- package/src/activities/agent-turn/credential-leases.ts +269 -214
- package/src/activities/agent-turn/credential-restriction.ts +14 -0
- package/src/activities/agent-turn/errors.ts +1134 -82
- package/src/activities/agent-turn/failure-settlement.ts +879 -886
- package/src/activities/agent-turn/final-reply.ts +46 -0
- package/src/activities/agent-turn/finalization-monitor.ts +17 -5
- package/src/activities/agent-turn/finalization.ts +107 -88
- package/src/activities/agent-turn/github-repository-bindings.ts +3 -1
- package/src/activities/agent-turn/governance-model.ts +90 -22
- package/src/activities/agent-turn/history-sink.ts +26 -4
- package/src/activities/agent-turn/history.ts +25 -5
- package/src/activities/agent-turn/input-wait-reply.ts +139 -0
- package/src/activities/agent-turn/knowledge-source-tools.ts +2 -0
- package/src/activities/agent-turn/meaningful-output.ts +44 -0
- package/src/activities/agent-turn/media-artifacts.ts +3 -1
- package/src/activities/agent-turn/model-call-admission.ts +94 -0
- package/src/activities/agent-turn/model-usage.ts +299 -233
- package/src/activities/agent-turn/model-wire-dispatch.ts +27 -0
- package/src/activities/agent-turn/optional-repositories.ts +224 -0
- package/src/activities/agent-turn/prompt-tool-availability.ts +27 -0
- package/src/activities/agent-turn/provider-dispatch-barrier.ts +22 -0
- package/src/activities/agent-turn/provider-recovery-copy.ts +76 -0
- package/src/activities/agent-turn/provider-recovery-metrics.ts +64 -0
- package/src/activities/agent-turn/provider-recovery-policy.ts +25 -0
- package/src/activities/agent-turn/quiescence.ts +7 -7
- package/src/activities/agent-turn/recovery-warning.ts +6 -8
- package/src/activities/agent-turn/refresh-credentials.ts +44 -0
- package/src/activities/agent-turn/run-credentials.ts +124 -76
- package/src/activities/agent-turn/run.ts +501 -112
- package/src/activities/agent-turn/sandbox-establish.ts +152 -75
- package/src/activities/agent-turn/sandbox-provision.ts +54 -1
- package/src/activities/agent-turn/sandbox-route.ts +4 -1
- package/src/activities/agent-turn/sandbox-runtime.ts +319 -11
- package/src/activities/agent-turn/secret-resolver.ts +155 -0
- package/src/activities/agent-turn/session-title.ts +177 -12
- package/src/activities/agent-turn/session-usage-custody.ts +170 -0
- package/src/activities/agent-turn/skill-checkout.ts +111 -24
- package/src/activities/agent-turn/skill-install.ts +1 -1
- package/src/activities/agent-turn/skill-read.ts +374 -28
- package/src/activities/agent-turn/skill-save.ts +35 -7
- package/src/activities/agent-turn/skill-search.ts +9 -0
- package/src/activities/agent-turn/skill-selection.ts +4 -0
- package/src/activities/agent-turn/skill-tools.ts +208 -21
- package/src/activities/agent-turn/skill-transfer.ts +68 -23
- package/src/activities/agent-turn/stream-attempt.ts +599 -110
- package/src/activities/agent-turn/subscription-capacity-arming.ts +81 -0
- package/src/activities/agent-turn/subscription-core-capacity.ts +439 -0
- package/src/activities/agent-turn/subscription-core-failover.ts +229 -0
- package/src/activities/agent-turn/subscription-core-placed.ts +37 -0
- package/src/activities/agent-turn/subscription-core-requests.ts +271 -0
- package/src/activities/agent-turn/subscription-core-settlement.ts +234 -0
- package/src/activities/agent-turn/subscription-lease.ts +140 -0
- package/src/activities/agent-turn/subscription-serving-capacity.ts +195 -0
- package/src/activities/agent-turn/subscription-serving-catalog.ts +71 -0
- package/src/activities/agent-turn/subscription-serving-claim.ts +178 -0
- package/src/activities/agent-turn/subscription-serving-providers.ts +15 -0
- package/src/activities/agent-turn/tool-environment.ts +384 -292
- package/src/activities/agent-turn/tool-policy.ts +104 -4
- package/src/activities/agent-turn/tool-result-spill.ts +1 -0
- package/src/activities/agent-turn/turn-context.ts +124 -8
- package/src/activities/agent-turn/web-search.ts +431 -0
- package/src/activities/agent-turn/xai-core.ts +301 -0
- package/src/activities/automations.ts +81 -6
- package/src/activities/browser-deadline-checkpoint.ts +297 -0
- package/src/activities/capabilities.ts +53 -213
- package/src/activities/codemode-dispatcher.ts +236 -14
- package/src/activities/codex-capacity.ts +27 -380
- package/src/activities/codex-image-generation.ts +252 -42
- package/src/activities/common.ts +12 -0
- package/src/activities/connector-attachments.ts +3 -1
- package/src/activities/context-compaction.ts +162 -21
- package/src/activities/environment.ts +18 -106
- package/src/activities/gmail-files.ts +108 -0
- package/src/activities/goals.ts +120 -204
- package/src/activities/image-generation-operation.ts +1 -1
- package/src/activities/incident-telemetry-authority.ts +80 -50
- package/src/activities/incident-telemetry-preflight.ts +27 -15
- package/src/activities/knowledge-indexing.ts +287 -17
- package/src/activities/knowledge-source-sync.ts +10 -0
- package/src/activities/mcp-account-routes.ts +2 -124
- package/src/activities/model-call-fact-reconciler.ts +112 -0
- package/src/activities/open-suffix-resume.ts +122 -88
- package/src/activities/parent-wake.ts +89 -21
- package/src/activities/programmatic-approvals.ts +26 -0
- package/src/activities/requester-unavailable-receipt.ts +14 -0
- package/src/activities/retained-screenshots.ts +135 -24
- package/src/activities/run-credential-renewal.ts +13 -1
- package/src/activities/run-credentials.ts +61 -19
- package/src/activities/run-input.ts +116 -9
- package/src/activities/sandbox-lease.ts +1615 -73
- package/src/activities/scheduled-tasks.ts +758 -141
- package/src/activities/session-archive.ts +382 -0
- package/src/activities/session-state.ts +219 -10
- package/src/activities/session-storage.ts +124 -0
- package/src/activities/site-auth-maintenance.ts +5 -2
- package/src/activities/subscription-core-claude-waits.ts +49 -0
- package/src/activities/subscription-core-codex-quota.ts +46 -0
- package/src/activities/subscription-core-codex-waits.ts +488 -0
- package/src/activities/subscription-core-image-operation.ts +126 -0
- package/src/activities/subscription-core-usage-recheck.ts +146 -0
- package/src/activities/subscription-core-wait-bindings.ts +12 -0
- package/src/activities/subscription-core-xai-quota.ts +85 -0
- package/src/activities/subscription-core-xai-waits.ts +48 -0
- package/src/activities/types.ts +85 -9
- package/src/activities/video-generation-admission.ts +1 -36
- package/src/activities/video-generation-credential.ts +38 -56
- package/src/activities/video-generation-reconciliation.ts +150 -131
- package/src/activities/video-generation-subscription-core.ts +180 -0
- package/src/activities/workspace-capture.ts +13 -2
- package/src/activities/workspace-credential-provider.ts +302 -0
- package/src/activities/xai-auth.ts +34 -112
- package/src/activities/xai-image-generation.ts +84 -36
- package/src/activities-control.ts +8 -0
- package/src/activities-turn.ts +5 -0
- package/src/activities.ts +17 -0
- package/src/activity-services.ts +29 -4
- package/src/browser-deadline-checkpoint-contract.ts +5 -0
- package/src/editable-artifact-hint-broker.ts +3 -0
- package/src/editable-artifact-materializer-service.ts +79 -38
- package/src/editable-artifact-materializer-subprocess.ts +47 -2
- package/src/editable-artifact-outbox-dispatcher.ts +107 -46
- package/src/editable-artifact-outbox-service.ts +55 -25
- package/src/github-rest-mcp.ts +1 -1
- package/src/host-export-pump.ts +26 -4
- package/src/host-export.ts +4 -1
- package/src/http.ts +4 -2
- package/src/index.ts +222 -282
- package/src/internal-maintenance.ts +347 -0
- package/src/maintenance-cadence.ts +156 -0
- package/src/observability-metrics.ts +1173 -73
- package/src/onepassword-vault-provider.ts +11 -0
- package/src/personal-github-git-credentials.ts +3 -1
- package/src/pr-review-credentials.ts +1 -1
- package/src/readiness-checks.ts +113 -0
- package/src/retained-process-retry.ts +36 -0
- package/src/sandbox-reaper-contract.ts +33 -0
- package/src/sandbox-resume.ts +444 -73
- package/src/sandbox-routing.ts +230 -75
- package/src/session-event-fanout.ts +23 -0
- package/src/telemetry-scheduler.ts +53 -0
- package/src/temporal-runtime-logger.ts +44 -0
- package/src/turn-task-queue-reader.ts +110 -0
- package/src/turn-worker-activity-telemetry.ts +209 -0
- package/src/worker-service-lifecycle.ts +54 -1
- package/src/workflows/activities.ts +16 -1
- package/src/workflows/browser-deadline-checkpoint.ts +55 -0
- package/src/workflows/file-upload-reaper.ts +2 -0
- package/src/workflows/sandbox-reaper.ts +88 -0
- package/src/workflows/scheduled-tasks.ts +26 -13
- package/src/workflows/session-storage.ts +19 -0
- package/src/workflows/session.ts +238 -33
- package/src/workflows/site-auth-maintenance.ts +2 -1
- package/src/workflows/workflow-wake.ts +26 -4
- package/src/workflows.ts +7 -0
- package/dist/activities/agent-turn/xai-capacity.d.ts +0 -2
- package/dist/activities/codex-fleet-shadow.d.ts +0 -74
- package/dist/activities/codex-rotation.d.ts +0 -200
- package/dist/activities/xai-quota.d.ts +0 -3
- package/dist/activities-control-QA6OLRQY.js.map +0 -1
- package/dist/activities-turn-YVVKCGAK.js.map +0 -1
- package/dist/chunk-GDCLDKSH.js.map +0 -1
- package/dist/chunk-I7HKKMUJ.js.map +0 -1
- package/dist/chunk-M3NVMF2V.js.map +0 -1
- package/dist/chunk-RAMNYSAW.js.map +0 -1
- package/src/activities/agent-turn/xai-capacity.ts +0 -257
- package/src/activities/codex-fleet-shadow.ts +0 -306
- package/src/activities/codex-rotation.ts +0 -685
- package/src/activities/xai-quota.ts +0 -35
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { environmentsEncryptionKeyBytes, type Settings } from "@opengeni/config";
|
|
2
|
+
import {
|
|
3
|
+
CredentialProviderResponse,
|
|
4
|
+
OPENGENI_SIGNATURE_HEADER,
|
|
5
|
+
signOpenGeniPayload,
|
|
6
|
+
type CredentialProviderRequest,
|
|
7
|
+
type RunCredentialsRequest,
|
|
8
|
+
type RunCredentialsResolution,
|
|
9
|
+
} from "@opengeni/contracts";
|
|
10
|
+
import {
|
|
11
|
+
decryptEnvironmentValue,
|
|
12
|
+
resolveWorkspaceCredentialProvider,
|
|
13
|
+
resolveInitiatingHuman,
|
|
14
|
+
type Database,
|
|
15
|
+
} from "@opengeni/db";
|
|
16
|
+
import { pinnedFetch, type OutboundNetworkSettings } from "@opengeni/network";
|
|
17
|
+
|
|
18
|
+
const MAX_RESPONSE_BYTES = 5 * 1024 * 1024;
|
|
19
|
+
export const GIT_CREDENTIALS_FILE = "git/credentials";
|
|
20
|
+
export const GIT_CREDENTIALS_FILE_ENV = "OPENGENI_GIT_CREDENTIALS_FILE";
|
|
21
|
+
export const PROVIDER_GIT_CONFIG_COUNT_ENV = "OPENGENI_PROVIDER_GIT_CONFIG_COUNT";
|
|
22
|
+
|
|
23
|
+
export class CredentialProviderError extends Error {
|
|
24
|
+
constructor(message: string) {
|
|
25
|
+
super(message);
|
|
26
|
+
this.name = "CredentialProviderError";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type WorkspaceRunCredentialResolver = (
|
|
31
|
+
input: RunCredentialsRequest,
|
|
32
|
+
) => Promise<RunCredentialsResolution>;
|
|
33
|
+
|
|
34
|
+
type ProviderOk = Extract<CredentialProviderResponse, { status: "ok" }>;
|
|
35
|
+
|
|
36
|
+
function gitCredentialLine(entry: NonNullable<ProviderOk["git"]>[number]): string {
|
|
37
|
+
const username = encodeURIComponent(entry.username ?? "x-access-token");
|
|
38
|
+
return `https://${username}:${encodeURIComponent(entry.password)}@${entry.host.toLowerCase()}`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Turn the provider's `git` sugar into ordinary run-credential material: one
|
|
43
|
+
* renewable credential-store file plus a read-only helper configured through
|
|
44
|
+
* GIT_CONFIG_* environment entries appended after any the host already set.
|
|
45
|
+
*/
|
|
46
|
+
export function withGitCredentialHelper(response: ProviderOk): ProviderOk {
|
|
47
|
+
const environment = { ...response.environment };
|
|
48
|
+
// The clone hook resets ambient helpers. Fence the exact configuration supplied
|
|
49
|
+
// by this authenticated provider so its renewable custom helpers can be
|
|
50
|
+
// reapplied without trusting an image's inherited GIT_CONFIG_* variables.
|
|
51
|
+
delete environment[PROVIDER_GIT_CONFIG_COUNT_ENV];
|
|
52
|
+
const declaredCount = environment.GIT_CONFIG_COUNT ?? "0";
|
|
53
|
+
if (!/^(0|[1-9][0-9]*)$/.test(declaredCount) || Number(declaredCount) > 128) {
|
|
54
|
+
throw new CredentialProviderError("Invalid provider Git configuration count");
|
|
55
|
+
}
|
|
56
|
+
for (let i = 0; i < Number(declaredCount); i++) {
|
|
57
|
+
if (
|
|
58
|
+
environment[`GIT_CONFIG_KEY_${i}`] === undefined ||
|
|
59
|
+
environment[`GIT_CONFIG_VALUE_${i}`] === undefined
|
|
60
|
+
) {
|
|
61
|
+
throw new CredentialProviderError("Incomplete provider Git configuration");
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
environment[PROVIDER_GIT_CONFIG_COUNT_ENV] = declaredCount;
|
|
65
|
+
if (!response.git?.length) return { ...response, environment };
|
|
66
|
+
const existingCount = Number.parseInt(environment.GIT_CONFIG_COUNT ?? "0", 10);
|
|
67
|
+
const index = Number.isFinite(existingCount) && existingCount > 0 ? existingCount : 0;
|
|
68
|
+
environment[`GIT_CONFIG_KEY_${index}`] = "credential.helper";
|
|
69
|
+
environment[`GIT_CONFIG_VALUE_${index}`] =
|
|
70
|
+
`!f() { test "$1" = get && sed '/^path=/d' | git credential-store --file="$${GIT_CREDENTIALS_FILE_ENV}" get; }; f`;
|
|
71
|
+
environment.GIT_CONFIG_COUNT = String(index + 1);
|
|
72
|
+
environment[PROVIDER_GIT_CONFIG_COUNT_ENV] = String(index + 1);
|
|
73
|
+
return {
|
|
74
|
+
...response,
|
|
75
|
+
environment,
|
|
76
|
+
files: [
|
|
77
|
+
...(response.files ?? []),
|
|
78
|
+
{
|
|
79
|
+
path: GIT_CREDENTIALS_FILE,
|
|
80
|
+
content: `${response.git.map(gitCredentialLine).join("\n")}\n`,
|
|
81
|
+
mode: "0400",
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
fileEnvironment: {
|
|
85
|
+
...response.fileEnvironment,
|
|
86
|
+
[GIT_CREDENTIALS_FILE_ENV]: GIT_CREDENTIALS_FILE,
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function credentialProviderRequestBody(
|
|
92
|
+
input: RunCredentialsRequest,
|
|
93
|
+
initiatingHumanSubjectId: string | null,
|
|
94
|
+
initiatingHuman: CredentialProviderRequest["initiatingHuman"] = null,
|
|
95
|
+
selection: Pick<CredentialProviderRequest, "lane" | "mcpServers"> = {
|
|
96
|
+
lane: "workspace",
|
|
97
|
+
mcpServers: [],
|
|
98
|
+
},
|
|
99
|
+
): CredentialProviderRequest {
|
|
100
|
+
const via = input.initiatorContext.via;
|
|
101
|
+
const latestHop = Array.isArray(via) ? via.at(-1) : null;
|
|
102
|
+
return {
|
|
103
|
+
type: "credentials.request",
|
|
104
|
+
lane: selection.lane,
|
|
105
|
+
mcpServers: selection.mcpServers.map(({ id, url }) => ({ id, url })),
|
|
106
|
+
purpose: input.purpose,
|
|
107
|
+
forceRefresh: input.forceRefresh,
|
|
108
|
+
accountId: input.accountId,
|
|
109
|
+
workspaceId: input.workspaceId,
|
|
110
|
+
sessionId: input.sessionId,
|
|
111
|
+
rootSessionId: input.rootSessionId,
|
|
112
|
+
parentSessionId: input.parentSessionId,
|
|
113
|
+
turnId: input.turnId,
|
|
114
|
+
attemptId: input.attemptId,
|
|
115
|
+
initiator: { kind: input.initiator.kind, subjectId: input.initiator.subjectId },
|
|
116
|
+
initiatorContext: {
|
|
117
|
+
kind:
|
|
118
|
+
latestHop?.kind === "agent"
|
|
119
|
+
? "agent"
|
|
120
|
+
: input.initiator.kind === "subject"
|
|
121
|
+
? "human"
|
|
122
|
+
: "service",
|
|
123
|
+
initiator: input.initiator,
|
|
124
|
+
context: input.initiatorContext,
|
|
125
|
+
},
|
|
126
|
+
initiatingHumanSubjectId,
|
|
127
|
+
initiatingHuman,
|
|
128
|
+
sandboxBackend: input.effectiveSandboxBackend,
|
|
129
|
+
sandboxOs: input.sandboxOs,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Drop undefined-valued keys; the runtime normalizer re-validates everything. */
|
|
134
|
+
function wire<T>(value: unknown): T {
|
|
135
|
+
return JSON.parse(JSON.stringify(value)) as T;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export function toRunCredentialsResolution(
|
|
139
|
+
response: CredentialProviderResponse,
|
|
140
|
+
scope: { accountId: string; workspaceId: string; sessionId: string },
|
|
141
|
+
): RunCredentialsResolution {
|
|
142
|
+
if (response.status === "not_applicable") return { status: "not_applicable", ...scope };
|
|
143
|
+
if (response.status === "auth_needed") {
|
|
144
|
+
return wire({ status: "auth_needed", ...scope, authNeeded: response.authNeeded });
|
|
145
|
+
}
|
|
146
|
+
const { git: _git, ...material } = withGitCredentialHelper(response);
|
|
147
|
+
return wire({ ...material, status: "ok", ...scope, environment: material.environment ?? {} });
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
async function readBoundedText(response: Response): Promise<string> {
|
|
151
|
+
const declared = Number(response.headers.get("content-length"));
|
|
152
|
+
if (Number.isFinite(declared) && declared > MAX_RESPONSE_BYTES) {
|
|
153
|
+
throw new CredentialProviderError("credential provider response is too large");
|
|
154
|
+
}
|
|
155
|
+
const reader = response.body?.getReader();
|
|
156
|
+
if (!reader) return "";
|
|
157
|
+
const chunks: Uint8Array[] = [];
|
|
158
|
+
let total = 0;
|
|
159
|
+
for (;;) {
|
|
160
|
+
const { done, value } = await reader.read();
|
|
161
|
+
if (done) break;
|
|
162
|
+
total += value.byteLength;
|
|
163
|
+
if (total > MAX_RESPONSE_BYTES) {
|
|
164
|
+
await reader.cancel().catch(() => undefined);
|
|
165
|
+
throw new CredentialProviderError("credential provider response is too large");
|
|
166
|
+
}
|
|
167
|
+
chunks.push(value);
|
|
168
|
+
}
|
|
169
|
+
return new TextDecoder().decode(Buffer.concat(chunks));
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export type WorkspaceCredentialProviderDeps = {
|
|
173
|
+
fetch?: typeof pinnedFetch;
|
|
174
|
+
resolveProvider?: typeof resolveWorkspaceCredentialProvider;
|
|
175
|
+
resolveHuman?: typeof resolveInitiatingHuman;
|
|
176
|
+
/** Trusted selected session-attached remote targets, frozen by the worker. */
|
|
177
|
+
mcpServers?: readonly { id: string; url: string }[];
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Resolve the workspace's configured HTTP credential provider, if any. The
|
|
182
|
+
* returned resolver has the same contract as a host `runCredentials` port, so
|
|
183
|
+
* provisioning, file materialization, renewal, and reconnect notices reuse the
|
|
184
|
+
* existing run-credential lifecycle unchanged.
|
|
185
|
+
*/
|
|
186
|
+
export async function workspaceCredentialProviderResolver(
|
|
187
|
+
db: Database,
|
|
188
|
+
settings: Settings,
|
|
189
|
+
scope: { accountId: string; workspaceId: string },
|
|
190
|
+
initiatingHumanSubjectId: string | null,
|
|
191
|
+
deps: WorkspaceCredentialProviderDeps = {},
|
|
192
|
+
): Promise<WorkspaceRunCredentialResolver | null> {
|
|
193
|
+
const row = await (deps.resolveProvider ?? resolveWorkspaceCredentialProvider)(db, scope);
|
|
194
|
+
if (!row) return null;
|
|
195
|
+
if (!row.enabled) {
|
|
196
|
+
// A disabled workspace override is an explicit pause, not an absent
|
|
197
|
+
// provider. Return a resolver so the deployment port cannot be borrowed.
|
|
198
|
+
return async (input) => ({
|
|
199
|
+
status: "not_applicable",
|
|
200
|
+
accountId: input.accountId,
|
|
201
|
+
workspaceId: input.workspaceId,
|
|
202
|
+
sessionId: input.sessionId,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
const key = environmentsEncryptionKeyBytes(settings);
|
|
206
|
+
if (!key) {
|
|
207
|
+
throw new CredentialProviderError(
|
|
208
|
+
"OPENGENI_ENVIRONMENTS_ENCRYPTION_KEY is required to use a workspace credential provider",
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
const fetchImpl = deps.fetch ?? pinnedFetch;
|
|
212
|
+
const network: OutboundNetworkSettings = settings;
|
|
213
|
+
const selection = {
|
|
214
|
+
lane:
|
|
215
|
+
"workspaceId" in row && row.workspaceId !== null
|
|
216
|
+
? ("workspace" as const)
|
|
217
|
+
: ("organization" as const),
|
|
218
|
+
mcpServers: (deps.mcpServers ?? []).map(({ id, url }) => ({ id, url })),
|
|
219
|
+
};
|
|
220
|
+
return async (input) => {
|
|
221
|
+
const echo = {
|
|
222
|
+
accountId: input.accountId,
|
|
223
|
+
workspaceId: input.workspaceId,
|
|
224
|
+
sessionId: input.sessionId,
|
|
225
|
+
};
|
|
226
|
+
// Rotation and disabling take effect on the next outbound request. Never
|
|
227
|
+
// switch registration mid-attempt if deletion exposes an inherited row.
|
|
228
|
+
const current = await (deps.resolveProvider ?? resolveWorkspaceCredentialProvider)(db, scope);
|
|
229
|
+
if (!current?.enabled || current.id !== row.id) {
|
|
230
|
+
return { status: "not_applicable", ...echo };
|
|
231
|
+
}
|
|
232
|
+
const secret = decryptEnvironmentValue(key, current.secretEncrypted);
|
|
233
|
+
const initiatingHuman = await (deps.resolveHuman ?? resolveInitiatingHuman)(
|
|
234
|
+
db,
|
|
235
|
+
scope,
|
|
236
|
+
initiatingHumanSubjectId,
|
|
237
|
+
input.turnId,
|
|
238
|
+
);
|
|
239
|
+
const body = JSON.stringify(
|
|
240
|
+
credentialProviderRequestBody(input, initiatingHumanSubjectId, initiatingHuman, selection),
|
|
241
|
+
);
|
|
242
|
+
let status: number;
|
|
243
|
+
let text: string;
|
|
244
|
+
try {
|
|
245
|
+
const response = await fetchImpl(
|
|
246
|
+
current.url,
|
|
247
|
+
{
|
|
248
|
+
method: "POST",
|
|
249
|
+
headers: {
|
|
250
|
+
"content-type": "application/json",
|
|
251
|
+
"user-agent": "OpenGeni-CredentialProvider/1",
|
|
252
|
+
[OPENGENI_SIGNATURE_HEADER]: await signOpenGeniPayload(secret, body),
|
|
253
|
+
},
|
|
254
|
+
body,
|
|
255
|
+
signal: AbortSignal.timeout(current.timeoutMs),
|
|
256
|
+
},
|
|
257
|
+
network,
|
|
258
|
+
{ label: "Workspace credential provider", requireHttpsOutsideLocalTest: true },
|
|
259
|
+
);
|
|
260
|
+
status = response.status;
|
|
261
|
+
text = await readBoundedText(response);
|
|
262
|
+
} catch (error) {
|
|
263
|
+
return failure(input, echo, `request failed: ${errorName(error)}`);
|
|
264
|
+
}
|
|
265
|
+
if (status < 200 || status >= 300) {
|
|
266
|
+
return failure(input, echo, `returned HTTP ${status}`);
|
|
267
|
+
}
|
|
268
|
+
let parsed: CredentialProviderResponse;
|
|
269
|
+
try {
|
|
270
|
+
parsed = CredentialProviderResponse.parse(JSON.parse(text));
|
|
271
|
+
} catch {
|
|
272
|
+
return failure(input, echo, "returned an invalid response body");
|
|
273
|
+
}
|
|
274
|
+
return toRunCredentialsResolution(parsed, echo);
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function errorName(error: unknown): string {
|
|
279
|
+
if (error instanceof Error) {
|
|
280
|
+
return error.name === "TimeoutError" || error.name === "AbortError" ? "timeout" : error.name;
|
|
281
|
+
}
|
|
282
|
+
return "unknown";
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* A failed renewal throws so the renewal loop keeps the last good material and
|
|
287
|
+
* retries with backoff. A failed first provision degrades to a visible
|
|
288
|
+
* reconnect notice instead of blocking the turn.
|
|
289
|
+
*/
|
|
290
|
+
function failure(
|
|
291
|
+
input: RunCredentialsRequest,
|
|
292
|
+
echo: { accountId: string; workspaceId: string; sessionId: string },
|
|
293
|
+
reason: string,
|
|
294
|
+
): RunCredentialsResolution {
|
|
295
|
+
const message = `Workspace credential provider ${reason}`;
|
|
296
|
+
if (input.purpose === "renewal") throw new CredentialProviderError(message);
|
|
297
|
+
return {
|
|
298
|
+
status: "auth_needed",
|
|
299
|
+
...echo,
|
|
300
|
+
authNeeded: [{ reason: "refresh_failed", message }],
|
|
301
|
+
};
|
|
302
|
+
}
|
|
@@ -1,130 +1,52 @@
|
|
|
1
|
-
import { environmentsEncryptionKeyBytes, type Settings } from "@opengeni/config";
|
|
2
1
|
import {
|
|
3
|
-
materializeXaiCredentialForRun,
|
|
4
|
-
refreshXaiSubscriptionCredentialSerialized,
|
|
5
|
-
type Database,
|
|
6
|
-
} from "@opengeni/db";
|
|
7
|
-
import type { XaiProviderAccountAuthoritySnapshotV1 } from "@opengeni/contracts";
|
|
8
|
-
import {
|
|
9
|
-
refreshXaiToken,
|
|
10
2
|
XAI_CLIENT_VERSION,
|
|
11
3
|
XAI_SUBSCRIPTION_MODEL_ID_PREFIX,
|
|
12
|
-
XaiSubscriptionReloginRequired,
|
|
13
|
-
xaiAccessTokenExpiry,
|
|
14
|
-
type XaiFetch,
|
|
15
4
|
type XaiSubscriptionRequestContext,
|
|
16
|
-
type XaiSubscriptionTokenSnapshot,
|
|
17
5
|
} from "@opengeni/xai-subscription";
|
|
18
6
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
credentialId: string;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export async function buildXaiTurnRequestAuthorization(input: {
|
|
25
|
-
db: Database;
|
|
26
|
-
settings: Settings;
|
|
27
|
-
accountId: string;
|
|
28
|
-
workspaceId: string;
|
|
29
|
-
subjectId: string;
|
|
7
|
+
/** The request-context options of a core SuperGrok turn. */
|
|
8
|
+
export type XaiTurnRequestContextOptions = {
|
|
30
9
|
sessionId: string;
|
|
31
10
|
turnId: string;
|
|
32
|
-
credentialId: string;
|
|
33
|
-
authoritySnapshot: XaiProviderAccountAuthoritySnapshotV1;
|
|
34
|
-
fetch?: XaiFetch;
|
|
35
11
|
hostedSearch?: XaiSubscriptionRequestContext["hostedSearch"];
|
|
36
12
|
onFinalContextUsage?: XaiSubscriptionRequestContext["onFinalContextUsage"];
|
|
37
13
|
nextRequestId?: XaiSubscriptionRequestContext["nextRequestId"];
|
|
38
14
|
streamIdleTimeoutMs?: XaiSubscriptionRequestContext["streamIdleTimeoutMs"];
|
|
39
15
|
onModelRequestDiagnostic?: XaiSubscriptionRequestContext["onModelRequestDiagnostic"];
|
|
40
16
|
onModelRequestEvent?: XaiSubscriptionRequestContext["onModelRequestEvent"];
|
|
41
|
-
}
|
|
42
|
-
const encryptionKey = environmentsEncryptionKeyBytes(input.settings);
|
|
43
|
-
if (!encryptionKey) {
|
|
44
|
-
throw new Error("SuperGrok subscriptions require OPENGENI_ENVIRONMENTS_ENCRYPTION_KEY");
|
|
45
|
-
}
|
|
46
|
-
let credential = await materializeXaiCredentialForRun(input.db, {
|
|
47
|
-
workspaceId: input.workspaceId,
|
|
48
|
-
subjectId: input.subjectId,
|
|
49
|
-
credentialId: input.credentialId,
|
|
50
|
-
authoritySnapshot: input.authoritySnapshot,
|
|
51
|
-
encryptionKey,
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
const tokenSnapshot = (): XaiSubscriptionTokenSnapshot => {
|
|
55
|
-
const accessToken = credential.secret.accessToken;
|
|
56
|
-
const userId = credential.providerAccountId;
|
|
57
|
-
if (!accessToken || !userId) {
|
|
58
|
-
throw new XaiSubscriptionReloginRequired(
|
|
59
|
-
"The SuperGrok connection is missing a verified token identity. Reconnect the account.",
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
return { accessToken, userId };
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const refresh = async (): Promise<XaiSubscriptionTokenSnapshot> => {
|
|
66
|
-
const observedAccessToken = credential.secret.accessToken;
|
|
67
|
-
const observedRefreshToken = credential.secret.refreshToken;
|
|
68
|
-
if (!observedRefreshToken) {
|
|
69
|
-
throw new XaiSubscriptionReloginRequired(
|
|
70
|
-
"The SuperGrok connection cannot be refreshed. Reconnect the account.",
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
const result = await refreshXaiSubscriptionCredentialSerialized(input.db, {
|
|
74
|
-
accountId: input.accountId,
|
|
75
|
-
workspaceId: input.workspaceId,
|
|
76
|
-
subjectId: input.subjectId,
|
|
77
|
-
credentialId: input.credentialId,
|
|
78
|
-
authoritySnapshot: input.authoritySnapshot,
|
|
79
|
-
encryptionKey,
|
|
80
|
-
observedAccessToken,
|
|
81
|
-
observedRefreshToken,
|
|
82
|
-
refresh: async (current) => {
|
|
83
|
-
const refreshToken = current.secret.refreshToken;
|
|
84
|
-
if (!refreshToken) {
|
|
85
|
-
throw new XaiSubscriptionReloginRequired(
|
|
86
|
-
"The SuperGrok connection cannot be refreshed. Reconnect the account.",
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
const tokens = await refreshXaiToken(refreshToken, {
|
|
90
|
-
...(input.fetch ? { fetch: input.fetch } : {}),
|
|
91
|
-
});
|
|
92
|
-
return {
|
|
93
|
-
secret: {
|
|
94
|
-
version: 1,
|
|
95
|
-
accessToken: tokens.accessToken,
|
|
96
|
-
refreshToken: tokens.refreshToken,
|
|
97
|
-
},
|
|
98
|
-
expiresAt:
|
|
99
|
-
xaiAccessTokenExpiry(tokens.accessToken) ??
|
|
100
|
-
new Date(Date.now() + tokens.expiresInSeconds * 1_000),
|
|
101
|
-
};
|
|
102
|
-
},
|
|
103
|
-
});
|
|
104
|
-
credential = result.credential;
|
|
105
|
-
return tokenSnapshot();
|
|
106
|
-
};
|
|
17
|
+
};
|
|
107
18
|
|
|
19
|
+
/** One turn's SuperGrok request context from its core bearer source and custody. */
|
|
20
|
+
export function xaiTurnRequestContext(
|
|
21
|
+
input: XaiTurnRequestContextOptions,
|
|
22
|
+
credentials: Pick<
|
|
23
|
+
XaiSubscriptionRequestContext,
|
|
24
|
+
"getToken" | "refresh" | "beforeProviderDispatch" | "onProviderRequestSettled"
|
|
25
|
+
>,
|
|
26
|
+
): XaiSubscriptionRequestContext {
|
|
108
27
|
return {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
model
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
28
|
+
clientVersion: XAI_CLIENT_VERSION,
|
|
29
|
+
sessionId: input.sessionId,
|
|
30
|
+
turnId: input.turnId,
|
|
31
|
+
getToken: credentials.getToken,
|
|
32
|
+
refresh: credentials.refresh,
|
|
33
|
+
resolveModel: (model) =>
|
|
34
|
+
model.startsWith(XAI_SUBSCRIPTION_MODEL_ID_PREFIX)
|
|
35
|
+
? model.slice(XAI_SUBSCRIPTION_MODEL_ID_PREFIX.length)
|
|
36
|
+
: model,
|
|
37
|
+
...(input.hostedSearch ? { hostedSearch: input.hostedSearch } : {}),
|
|
38
|
+
...(input.onFinalContextUsage ? { onFinalContextUsage: input.onFinalContextUsage } : {}),
|
|
39
|
+
...(input.nextRequestId ? { nextRequestId: input.nextRequestId } : {}),
|
|
40
|
+
...(input.streamIdleTimeoutMs ? { streamIdleTimeoutMs: input.streamIdleTimeoutMs } : {}),
|
|
41
|
+
...(input.onModelRequestDiagnostic
|
|
42
|
+
? { onModelRequestDiagnostic: input.onModelRequestDiagnostic }
|
|
43
|
+
: {}),
|
|
44
|
+
...(input.onModelRequestEvent ? { onModelRequestEvent: input.onModelRequestEvent } : {}),
|
|
45
|
+
...(credentials.beforeProviderDispatch
|
|
46
|
+
? { beforeProviderDispatch: credentials.beforeProviderDispatch }
|
|
47
|
+
: {}),
|
|
48
|
+
...(credentials.onProviderRequestSettled
|
|
49
|
+
? { onProviderRequestSettled: credentials.onProviderRequestSettled }
|
|
50
|
+
: {}),
|
|
129
51
|
};
|
|
130
52
|
}
|
|
@@ -2,16 +2,29 @@ import {
|
|
|
2
2
|
generateXaiSubscriptionImage,
|
|
3
3
|
XAI_IMAGE_MODEL,
|
|
4
4
|
XAI_SUBSCRIPTION_PROVIDER_ID,
|
|
5
|
-
type XaiSubscriptionRequestContext,
|
|
6
5
|
} from "@opengeni/xai-subscription";
|
|
7
|
-
import type {
|
|
6
|
+
import type { Settings } from "@opengeni/config";
|
|
7
|
+
import {
|
|
8
|
+
SUBSCRIPTION_CORE_XAI,
|
|
9
|
+
subscriptionCoreXaiBearer,
|
|
10
|
+
subscriptionCoreXaiFetch,
|
|
11
|
+
type Database,
|
|
12
|
+
type SubscriptionCoreFetch,
|
|
13
|
+
type SubscriptionCoreProvider,
|
|
14
|
+
type SubscriptionCoreTurnIdentity,
|
|
15
|
+
} from "@opengeni/db";
|
|
8
16
|
import type { ObjectStorage } from "@opengeni/storage";
|
|
9
17
|
import type { GeneratedImageReceipt } from "./generated-images";
|
|
10
18
|
import {
|
|
11
19
|
executeImageGenerationOperation,
|
|
20
|
+
imageGenerationOperationIdentity,
|
|
12
21
|
imageProviderBindingHash,
|
|
13
22
|
} from "./image-generation-operation";
|
|
14
23
|
import type { ResolvedImageGenerationReference } from "./image-generation-references";
|
|
24
|
+
import {
|
|
25
|
+
runSubscriptionCoreImageOperation,
|
|
26
|
+
SubscriptionCoreImageDispatchRejected,
|
|
27
|
+
} from "./subscription-core-image-operation";
|
|
15
28
|
|
|
16
29
|
export type XaiImageGenerationPorts = {
|
|
17
30
|
execute: typeof executeImageGenerationOperation;
|
|
@@ -23,8 +36,15 @@ const xaiImageGenerationPorts: XaiImageGenerationPorts = {
|
|
|
23
36
|
generate: generateXaiSubscriptionImage,
|
|
24
37
|
};
|
|
25
38
|
|
|
26
|
-
/**
|
|
27
|
-
|
|
39
|
+
/**
|
|
40
|
+
* SuperGrok image generation of a turn placed on the shared core (design
|
|
41
|
+
* 5.3, EP-N09/N10): the turn's placed connection under its own `image`
|
|
42
|
+
* operation lease, the bearer from the core seam and every request in the
|
|
43
|
+
* core's custody. A refused lease or fence before dispatch returns the
|
|
44
|
+
* ledger row to `prepared`. This is SuperGrok's only image path: the legacy
|
|
45
|
+
* credential-bound executor was deleted with its runtime (M4 X4).
|
|
46
|
+
*/
|
|
47
|
+
export async function executeCoreXaiImageGeneration(
|
|
28
48
|
input: {
|
|
29
49
|
db: Database;
|
|
30
50
|
objectStorage: ObjectStorage | null;
|
|
@@ -36,51 +56,79 @@ export async function executeXaiSubscriptionImageGeneration(
|
|
|
36
56
|
toolCallId: string;
|
|
37
57
|
prompt: string;
|
|
38
58
|
references?: readonly ResolvedImageGenerationReference[];
|
|
39
|
-
credentialId: string;
|
|
40
|
-
xaiContext: Pick<XaiSubscriptionRequestContext, "getToken" | "refresh">;
|
|
41
59
|
abortSignal?: AbortSignal;
|
|
60
|
+
settings: Settings;
|
|
61
|
+
core: { identity: SubscriptionCoreTurnIdentity; connectionId: string };
|
|
62
|
+
executionGeneration: number;
|
|
63
|
+
/** The turn's chat-lease dispatch fence (`leases.xai.assertCurrentForDispatch`). */
|
|
64
|
+
assertChatLease: () => Promise<void>;
|
|
65
|
+
provider?: SubscriptionCoreProvider;
|
|
66
|
+
fetchImpl?: SubscriptionCoreFetch;
|
|
42
67
|
},
|
|
43
68
|
ports: XaiImageGenerationPorts = xaiImageGenerationPorts,
|
|
44
69
|
): Promise<GeneratedImageReceipt> {
|
|
45
70
|
const providerBindingHash = imageProviderBindingHash(
|
|
46
71
|
XAI_SUBSCRIPTION_PROVIDER_ID,
|
|
47
|
-
input.
|
|
72
|
+
input.core.connectionId,
|
|
48
73
|
);
|
|
49
|
-
|
|
50
|
-
db: input.db,
|
|
51
|
-
objectStorage: input.objectStorage,
|
|
52
|
-
accountId: input.accountId,
|
|
74
|
+
const request = {
|
|
53
75
|
workspaceId: input.workspaceId,
|
|
54
76
|
sessionId: input.sessionId,
|
|
55
77
|
turnId: input.turnId,
|
|
56
|
-
attemptId: input.attemptId,
|
|
57
78
|
toolCallId: input.toolCallId,
|
|
58
|
-
prompt: input.prompt,
|
|
59
79
|
providerId: XAI_SUBSCRIPTION_PROVIDER_ID,
|
|
60
80
|
providerBindingHash,
|
|
61
81
|
modelId: XAI_IMAGE_MODEL,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
prompt: input.prompt,
|
|
83
|
+
...(input.references ? { referenceDigests: input.references } : {}),
|
|
84
|
+
};
|
|
85
|
+
return await ports.execute({
|
|
86
|
+
...request,
|
|
87
|
+
db: input.db,
|
|
88
|
+
objectStorage: input.objectStorage,
|
|
89
|
+
accountId: input.accountId,
|
|
90
|
+
attemptId: input.attemptId,
|
|
91
|
+
isProviderDispatchRejected: (error) => error instanceof SubscriptionCoreImageDispatchRejected,
|
|
92
|
+
generate: async () =>
|
|
93
|
+
await runSubscriptionCoreImageOperation(
|
|
94
|
+
{
|
|
95
|
+
db: input.db,
|
|
96
|
+
settings: input.settings,
|
|
97
|
+
provider: input.provider ?? (SUBSCRIPTION_CORE_XAI as SubscriptionCoreProvider),
|
|
98
|
+
identity: input.core.identity,
|
|
99
|
+
connectionId: input.core.connectionId,
|
|
100
|
+
attemptId: input.attemptId,
|
|
101
|
+
executionGeneration: input.executionGeneration,
|
|
102
|
+
operationId: imageGenerationOperationIdentity(request).operationId,
|
|
103
|
+
toolCallId: input.toolCallId,
|
|
104
|
+
assertChatLease: input.assertChatLease,
|
|
105
|
+
bearer: subscriptionCoreXaiBearer,
|
|
106
|
+
...(input.fetchImpl ? { fetchImpl: input.fetchImpl } : {}),
|
|
107
|
+
},
|
|
108
|
+
async ({ auth, fetch }) => {
|
|
109
|
+
const generated = await ports.generate({
|
|
110
|
+
prompt: input.prompt,
|
|
111
|
+
sessionId: input.sessionId,
|
|
112
|
+
...(input.references?.length
|
|
113
|
+
? {
|
|
114
|
+
references: input.references.map((reference) => ({
|
|
115
|
+
mediaType: reference.mediaType,
|
|
116
|
+
bytes: reference.bytes,
|
|
117
|
+
})),
|
|
118
|
+
}
|
|
119
|
+
: {}),
|
|
120
|
+
getToken: auth.getToken,
|
|
121
|
+
refresh: auth.refresh,
|
|
122
|
+
fetch: subscriptionCoreXaiFetch(fetch),
|
|
123
|
+
...(input.abortSignal ? { abortSignal: input.abortSignal } : {}),
|
|
124
|
+
});
|
|
125
|
+
return {
|
|
126
|
+
toolCallId: input.toolCallId,
|
|
127
|
+
providerItemId: null,
|
|
128
|
+
bytes: generated.bytes,
|
|
129
|
+
declaredMediaType: generated.declaredMediaType,
|
|
130
|
+
};
|
|
131
|
+
},
|
|
132
|
+
),
|
|
85
133
|
});
|
|
86
134
|
}
|
|
@@ -2,10 +2,12 @@ import { createKnowledgeIndexingActivities } from "./activities/knowledge-indexi
|
|
|
2
2
|
import { createSharedActivityServices } from "./activity-services";
|
|
3
3
|
import { createCodexCapacityActivities } from "./activities/codex-capacity";
|
|
4
4
|
import { createBrowserStateArtifactMaintenanceActivities } from "./activities/browser-state-artifact-reaper";
|
|
5
|
+
import { createBrowserDeadlineCheckpointActivities } from "./activities/browser-deadline-checkpoint";
|
|
5
6
|
import { createAutomationActivities } from "./activities/automations";
|
|
6
7
|
import { createDocumentActivities } from "./activities/documents";
|
|
7
8
|
import { createFileUploadReaperActivities } from "./activities/file-upload-reaper";
|
|
8
9
|
import { createGoalActivities } from "./activities/goals";
|
|
10
|
+
import { createModelCallFactReconcilerActivities } from "./activities/model-call-fact-reconciler";
|
|
9
11
|
import { createKnowledgeSourceSyncActivities } from "./activities/knowledge-source-sync";
|
|
10
12
|
import { createRetainedScreenshotMaintenanceActivities } from "./activities/retained-screenshot-reaper";
|
|
11
13
|
import { createRigVerificationActivities } from "./activities/rig-verification";
|
|
@@ -13,6 +15,8 @@ import { createSandboxLeaseActivities } from "./activities/sandbox-lease";
|
|
|
13
15
|
import { createScheduledTaskActivities } from "./activities/scheduled-tasks";
|
|
14
16
|
import { createSiteAuthMaintenanceActivities } from "./activities/site-auth-maintenance";
|
|
15
17
|
import { createSessionStateActivities } from "./activities/session-state";
|
|
18
|
+
import { createSessionArchiveActivities } from "./activities/session-archive";
|
|
19
|
+
import { createSessionStorageActivities } from "./activities/session-storage";
|
|
16
20
|
import type { ActivityDependencies, ControlActivityServices } from "./activities/types";
|
|
17
21
|
import { createWorkflowWakeActivities } from "./activities/workflow-wake";
|
|
18
22
|
|
|
@@ -33,13 +37,17 @@ export function createControlActivitiesFromServices(
|
|
|
33
37
|
...createKnowledgeIndexingActivities(services, resolveDocumentServices),
|
|
34
38
|
...createKnowledgeSourceSyncActivities(services, resolveDocumentServices),
|
|
35
39
|
...createSessionStateActivities(services),
|
|
40
|
+
...createSessionStorageActivities(services),
|
|
41
|
+
...createSessionArchiveActivities(services),
|
|
36
42
|
...createScheduledTaskActivities(services),
|
|
37
43
|
...createSiteAuthMaintenanceActivities(services),
|
|
38
44
|
...createGoalActivities(services),
|
|
39
45
|
...createCodexCapacityActivities(services),
|
|
40
46
|
...createRigVerificationActivities(services),
|
|
41
47
|
...createBrowserStateArtifactMaintenanceActivities(services),
|
|
48
|
+
...createBrowserDeadlineCheckpointActivities(services),
|
|
42
49
|
...createFileUploadReaperActivities(services),
|
|
50
|
+
...createModelCallFactReconcilerActivities(services),
|
|
43
51
|
...createRetainedScreenshotMaintenanceActivities(services),
|
|
44
52
|
...createWorkflowWakeActivities(services),
|
|
45
53
|
...createSandboxLeaseActivities(services),
|