@opengeni/worker-bundle 2.0.1 → 2.0.2-canary.38789554071001
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 +185 -26
- 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 +4 -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 +31 -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-5IIVRXLA.js} +1569 -2883
- package/dist/activities-control-5IIVRXLA.js.map +1 -0
- package/dist/activities-control.d.ts +64 -4
- package/dist/{activities-turn-YVVKCGAK.js → activities-turn-FLYJOM54.js} +9300 -4403
- package/dist/activities-turn-FLYJOM54.js.map +1 -0
- package/dist/activities.d.ts +64 -4
- package/dist/artifact-materializer-entry.js +107 -36
- 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-MVESOYFC.js +3746 -0
- package/dist/chunk-MVESOYFC.js.map +1 -0
- package/dist/{chunk-M3NVMF2V.js → chunk-N57B3PJ5.js} +2307 -3951
- package/dist/chunk-N57B3PJ5.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 +1152 -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 +42 -12
- 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 +114 -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 +634 -111
- 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 +182 -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 +124 -9
- package/src/activities/sandbox-lease.ts +1615 -73
- package/src/activities/scheduled-tasks.ts +780 -147
- 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 +85 -39
- 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,301 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SuperGrok on the shared subscription core (design 5.3, SuperGrok track
|
|
3
|
+
* X1a): the provider-neutral chat placement and request custody bound to
|
|
4
|
+
* SuperGrok. SuperGrok runs only on the core (the legacy path was deleted in
|
|
5
|
+
* X4): the route is `core` after the SuperGrok drained cutover commits its
|
|
6
|
+
* receipt (X3), which this binary requires; any other route fails closed.
|
|
7
|
+
*/
|
|
8
|
+
import {
|
|
9
|
+
readSubscriptionCoreProviderRoute,
|
|
10
|
+
SUBSCRIPTION_CORE_XAI,
|
|
11
|
+
SubscriptionCoreError,
|
|
12
|
+
subscriptionCoreRequests,
|
|
13
|
+
subscriptionCoreTurns,
|
|
14
|
+
withRlsContext,
|
|
15
|
+
buildSubscriptionCoreXaiTokenResolver,
|
|
16
|
+
XAI_CREDENTIAL_LEASE_TTL_MS,
|
|
17
|
+
type Database,
|
|
18
|
+
type SubscriptionCoreProvider,
|
|
19
|
+
} from "@opengeni/db";
|
|
20
|
+
import type { Settings } from "@opengeni/config";
|
|
21
|
+
import type { XaiSubscriptionRequestContext } from "@opengeni/xai-subscription";
|
|
22
|
+
import type { CapacityPhaseDeps, CapacityPhaseOutcome } from "./codex-capacity";
|
|
23
|
+
import { subscriptionCoreCutoverDisabledFailure } from "./codex-core-errors";
|
|
24
|
+
import type { XaiTurnLease } from "./credential-leases";
|
|
25
|
+
import { classifyXaiProviderError } from "./errors";
|
|
26
|
+
import {
|
|
27
|
+
assertCoreSourceConnected,
|
|
28
|
+
coreLeaseRef,
|
|
29
|
+
guardCoreTokenResolver,
|
|
30
|
+
parkCoreSubscriptionTurn,
|
|
31
|
+
selectCoreSubscriptionTurnCapacity,
|
|
32
|
+
type CoreTurnPlacementProvider,
|
|
33
|
+
} from "./subscription-core-capacity";
|
|
34
|
+
import {
|
|
35
|
+
SUBSCRIPTION_CORE_TURN_REFUSAL_LIMIT,
|
|
36
|
+
subscriptionCoreFailoverMetrics,
|
|
37
|
+
} from "./subscription-core-failover";
|
|
38
|
+
import {
|
|
39
|
+
createCoreSubscriptionRequests,
|
|
40
|
+
type CoreSubscriptionRequests,
|
|
41
|
+
} from "./subscription-core-requests";
|
|
42
|
+
import type { CoreRefusalBinding } from "./subscription-core-settlement";
|
|
43
|
+
import type { SubscriptionCoreTurn } from "./turn-context";
|
|
44
|
+
import { subscriptionTurnLeaseHolderId } from "./subscription-lease";
|
|
45
|
+
import { recoverCoreHealthAndWake } from "../subscription-core-codex-waits";
|
|
46
|
+
import { XAI_CORE_WAIT_BINDING } from "../subscription-core-xai-waits";
|
|
47
|
+
import { refreshExhaustedXaiCoreQuota } from "../subscription-core-xai-quota";
|
|
48
|
+
|
|
49
|
+
const XAI = SUBSCRIPTION_CORE_XAI as SubscriptionCoreProvider;
|
|
50
|
+
const DISPLAY_NAME = "SuperGrok";
|
|
51
|
+
|
|
52
|
+
const hasCoreCode = (error: unknown, code: string): boolean =>
|
|
53
|
+
error instanceof SubscriptionCoreError && error.code === code;
|
|
54
|
+
|
|
55
|
+
/** SuperGrok's chat placement on the shared core. */
|
|
56
|
+
export const XAI_CORE_TURN_PROVIDER: CoreTurnPlacementProvider = {
|
|
57
|
+
id: "xai",
|
|
58
|
+
displayName: DISPLAY_NAME,
|
|
59
|
+
startupPhaseProvider: "supergrok-subscription",
|
|
60
|
+
leaseTtlMs: XAI_CREDENTIAL_LEASE_TTL_MS,
|
|
61
|
+
lease: (deps) => deps.leases.xai,
|
|
62
|
+
place: (db, request) => subscriptionCoreTurns(XAI).placeSubscriptionCoreTurn(db, request),
|
|
63
|
+
// A recovery wakes the account's other SuperGrok waiters too.
|
|
64
|
+
recoverHealth: async ({ db, signalCodexCapacityWorkflow }, identity) => {
|
|
65
|
+
await recoverCoreHealthAndWake(
|
|
66
|
+
{ db, signalCodexCapacityWorkflow },
|
|
67
|
+
XAI_CORE_WAIT_BINDING,
|
|
68
|
+
identity,
|
|
69
|
+
);
|
|
70
|
+
},
|
|
71
|
+
// Re-read billing for exhausted connections before placement trusts a
|
|
72
|
+
// stored exhaustion, as the legacy path did (EP-N22): the shared pool, and
|
|
73
|
+
// the personal connections placement's personal authorization admits for
|
|
74
|
+
// this exact turn.
|
|
75
|
+
beforePlacement: async ({ db, settings }, identity) => {
|
|
76
|
+
await refreshExhaustedXaiCoreQuota({
|
|
77
|
+
db,
|
|
78
|
+
settings,
|
|
79
|
+
accountId: identity.accountId,
|
|
80
|
+
workspaceId: identity.workspaceId,
|
|
81
|
+
personalTurn: identity,
|
|
82
|
+
});
|
|
83
|
+
},
|
|
84
|
+
adopt: ({ providerTurn }, core, placement) => {
|
|
85
|
+
providerTurn.xaiSubscriptionCore = core;
|
|
86
|
+
providerTurn.effectiveXaiCredentialId = placement.connectionId;
|
|
87
|
+
},
|
|
88
|
+
// A wait parks the same turn on the durable core waiter (EP-T09).
|
|
89
|
+
park: (deps, wait) => parkCoreSubscriptionTurn(deps, wait, XAI_CORE_WAIT_BINDING, DISPLAY_NAME),
|
|
90
|
+
isSourceDisconnected: (db, identity, connectionId) =>
|
|
91
|
+
subscriptionCoreRequests(XAI).isSubscriptionCoreSourceDisconnected(db, identity, connectionId),
|
|
92
|
+
sourceDisconnectedError: () => XAI.errors.sourceDisconnected(),
|
|
93
|
+
// SuperGrok records no Codex selection receipt, the only step that raises an
|
|
94
|
+
// attempt-fence error here; any other failure propagates.
|
|
95
|
+
isAttemptFenced: () => false,
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* The SuperGrok capacity phase by the organization's SuperGrok route: `core`
|
|
100
|
+
* places on the shared core; `maintenance` and a missing receipt (`legacy`,
|
|
101
|
+
* which this binary's readiness check already refuses) fail closed.
|
|
102
|
+
*/
|
|
103
|
+
export async function selectXaiTurnCapacityByRoute(
|
|
104
|
+
deps: CapacityPhaseDeps,
|
|
105
|
+
): Promise<CapacityPhaseOutcome> {
|
|
106
|
+
if (!deps.billingState.isXaiTurn) return { ok: true };
|
|
107
|
+
const { input } = deps;
|
|
108
|
+
const route = await withRlsContext(
|
|
109
|
+
deps.db,
|
|
110
|
+
{ accountId: input.accountId, workspaceId: input.workspaceId },
|
|
111
|
+
(scoped) =>
|
|
112
|
+
readSubscriptionCoreProviderRoute(scoped, { accountId: input.accountId, provider: "xai" }),
|
|
113
|
+
);
|
|
114
|
+
if (route !== "core") throw subscriptionCoreCutoverDisabledFailure(DISPLAY_NAME);
|
|
115
|
+
const turnId = deps.attempt.turnId;
|
|
116
|
+
if (!turnId) throw new Error("Turn id was not initialized");
|
|
117
|
+
deps.leases.xai.holderId ??= subscriptionTurnLeaseHolderId("xai", DISPLAY_NAME, input, turnId);
|
|
118
|
+
return await selectCoreSubscriptionTurnCapacity(deps, XAI_CORE_TURN_PROVIDER);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** One attempt's SuperGrok request custody on the core (unknown outcomes are never replayed). */
|
|
122
|
+
export function createCoreXaiRequests(
|
|
123
|
+
db: Database,
|
|
124
|
+
core: SubscriptionCoreTurn,
|
|
125
|
+
ref: { connectionId: string; holderId: string; generation: number },
|
|
126
|
+
execution: { attemptId: string; executionGeneration: number },
|
|
127
|
+
) {
|
|
128
|
+
const requests = subscriptionCoreRequests(XAI);
|
|
129
|
+
return createCoreSubscriptionRequests({
|
|
130
|
+
reserve: (request) =>
|
|
131
|
+
requests.reserveSubscriptionCoreRequest(db, core.identity, ref, { ...request, ...execution }),
|
|
132
|
+
settle: (request) =>
|
|
133
|
+
requests.settleSubscriptionCoreRequest(db, core.identity, ref, { ...request, ...execution }),
|
|
134
|
+
displayName: DISPLAY_NAME,
|
|
135
|
+
outcomeUnknown: () => XAI.errors.requestOutcomeUnknown(),
|
|
136
|
+
isOutcomeUnknown: (error) => hasCoreCode(error, "subscription_core_request_outcome_unknown"),
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export type XaiCoreRequestAuthorization = {
|
|
141
|
+
getToken: XaiSubscriptionRequestContext["getToken"];
|
|
142
|
+
refresh: XaiSubscriptionRequestContext["refresh"];
|
|
143
|
+
/**
|
|
144
|
+
* The same bearer for session-title requests. A title request never moves
|
|
145
|
+
* the main lane's refusal fence (`core.credentialVersion`).
|
|
146
|
+
*/
|
|
147
|
+
titleGetToken: XaiSubscriptionRequestContext["getToken"];
|
|
148
|
+
titleRefresh: XaiSubscriptionRequestContext["refresh"];
|
|
149
|
+
/** The dispatch fence every physical request passes before its reservation. */
|
|
150
|
+
assertDispatch: () => Promise<void>;
|
|
151
|
+
beforeProviderDispatch: NonNullable<XaiSubscriptionRequestContext["beforeProviderDispatch"]>;
|
|
152
|
+
onProviderRequestSettled: NonNullable<XaiSubscriptionRequestContext["onProviderRequestSettled"]>;
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Materialization, refresh and custody for a core-placed SuperGrok turn: the
|
|
157
|
+
* bearer comes from the shared core resolver under the exact accepted turn
|
|
158
|
+
* and this attempt's live core lease; each physical request (each transport
|
|
159
|
+
* attempt and each continuation) is fenced and reserved before network I/O.
|
|
160
|
+
* Session-title requests use `core.titleRequests` with the same fence.
|
|
161
|
+
*/
|
|
162
|
+
export function buildXaiCoreRequestAuthorization(input: {
|
|
163
|
+
db: Database;
|
|
164
|
+
settings: Settings;
|
|
165
|
+
core: SubscriptionCoreTurn;
|
|
166
|
+
lease: XaiTurnLease;
|
|
167
|
+
execution: { attemptId: string; executionGeneration: number };
|
|
168
|
+
}): XaiCoreRequestAuthorization {
|
|
169
|
+
const { db, core, lease } = input;
|
|
170
|
+
const ref = coreLeaseRef(lease, core, DISPLAY_NAME);
|
|
171
|
+
core.requests = createCoreXaiRequests(db, core, ref, input.execution);
|
|
172
|
+
core.titleRequests = createCoreXaiRequests(db, core, ref, input.execution);
|
|
173
|
+
const resolver = guardCoreTokenResolver(
|
|
174
|
+
db,
|
|
175
|
+
XAI_CORE_TURN_PROVIDER,
|
|
176
|
+
core,
|
|
177
|
+
lease,
|
|
178
|
+
buildSubscriptionCoreXaiTokenResolver(db, input.settings, core.identity, ref),
|
|
179
|
+
(error) => hasCoreCode(error, "subscription_core_lease_lost"),
|
|
180
|
+
);
|
|
181
|
+
const assertDispatch = async () => {
|
|
182
|
+
await assertCoreSourceConnected(db, XAI_CORE_TURN_PROVIDER, core);
|
|
183
|
+
await lease.assertCurrentForDispatch();
|
|
184
|
+
};
|
|
185
|
+
const requests = core.requests;
|
|
186
|
+
// The refusal settlement fences its health write on the generation the
|
|
187
|
+
// refused bearer carried: the main lane records the generation of the
|
|
188
|
+
// bearer it obtained when that physical request is dispatched. Main-lane
|
|
189
|
+
// requests are sequential, so at settlement the slot holds the refused
|
|
190
|
+
// request's generation; title requests (their own lane) never write it.
|
|
191
|
+
let mainLaneGeneration: number | null = null;
|
|
192
|
+
type Snapshot = { accessToken: string; userId: string; credentialVersion: number };
|
|
193
|
+
const bearer = (snapshot: Snapshot) => ({
|
|
194
|
+
accessToken: snapshot.accessToken,
|
|
195
|
+
userId: snapshot.userId,
|
|
196
|
+
});
|
|
197
|
+
const mainLane = (snapshot: Snapshot) => {
|
|
198
|
+
mainLaneGeneration = snapshot.credentialVersion;
|
|
199
|
+
return bearer(snapshot);
|
|
200
|
+
};
|
|
201
|
+
return {
|
|
202
|
+
getToken: async () => mainLane(await resolver.getToken()),
|
|
203
|
+
refresh: async () => mainLane(await resolver.refresh()),
|
|
204
|
+
titleGetToken: async () => bearer(await resolver.getToken()),
|
|
205
|
+
titleRefresh: async () => bearer(await resolver.refresh()),
|
|
206
|
+
assertDispatch,
|
|
207
|
+
beforeProviderDispatch: async (request) => {
|
|
208
|
+
await assertDispatch();
|
|
209
|
+
await requests.reserve(request);
|
|
210
|
+
if (mainLaneGeneration !== null) core.credentialVersion = mainLaneGeneration;
|
|
211
|
+
},
|
|
212
|
+
onProviderRequestSettled: requests.observe,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* The session-title custody of a turn: none on the legacy route; on the core
|
|
218
|
+
* the turn's dispatch fence and its title lane, and a turn placed on the core
|
|
219
|
+
* without either fails closed instead of sending unreserved title requests.
|
|
220
|
+
*/
|
|
221
|
+
export function xaiCoreTitleCustody(
|
|
222
|
+
core: Pick<SubscriptionCoreTurn, "titleRequests"> | null,
|
|
223
|
+
authorization: Pick<
|
|
224
|
+
XaiCoreRequestAuthorization,
|
|
225
|
+
"assertDispatch" | "titleGetToken" | "titleRefresh"
|
|
226
|
+
> | null,
|
|
227
|
+
):
|
|
228
|
+
| {
|
|
229
|
+
assertDispatch: () => Promise<void>;
|
|
230
|
+
requests: CoreSubscriptionRequests;
|
|
231
|
+
getToken: XaiSubscriptionRequestContext["getToken"];
|
|
232
|
+
refresh: XaiSubscriptionRequestContext["refresh"];
|
|
233
|
+
}
|
|
234
|
+
| undefined {
|
|
235
|
+
if (!core) return undefined;
|
|
236
|
+
if (!authorization || !core.titleRequests)
|
|
237
|
+
throw new Error("A SuperGrok turn on the shared core has no session-title request custody");
|
|
238
|
+
return {
|
|
239
|
+
assertDispatch: authorization.assertDispatch,
|
|
240
|
+
requests: core.titleRequests,
|
|
241
|
+
getToken: authorization.titleGetToken,
|
|
242
|
+
refresh: authorization.titleRefresh,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* The terminal unknown-outcome failure of a core SuperGrok turn, or null: an
|
|
248
|
+
* earlier or own request whose outcome is unknown is never replayed
|
|
249
|
+
* automatically.
|
|
250
|
+
*/
|
|
251
|
+
export function xaiCoreRequestOutcomeUnknown(
|
|
252
|
+
error: unknown,
|
|
253
|
+
core: Pick<SubscriptionCoreTurn, "requests">,
|
|
254
|
+
): (Error & { code: string }) | null {
|
|
255
|
+
let current: unknown = error;
|
|
256
|
+
let unknown = false;
|
|
257
|
+
for (let depth = 0; depth < 8 && current instanceof Error && !unknown; depth++) {
|
|
258
|
+
unknown = hasCoreCode(current, "subscription_core_request_outcome_unknown");
|
|
259
|
+
current = current.cause;
|
|
260
|
+
}
|
|
261
|
+
// The tool-less session-title request never enters history and is joined
|
|
262
|
+
// before settlement, so its custody does not fence replay.
|
|
263
|
+
if (!unknown && !core.requests?.hasUnknownOutcome()) return null;
|
|
264
|
+
return XAI.errors.requestOutcomeUnknown() as Error & { code: string };
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/** After the history commit, settle completed responses; true when no request is unresolved. */
|
|
268
|
+
export async function xaiCoreLanesRecoverAfterCheckpoint(
|
|
269
|
+
core: Pick<SubscriptionCoreTurn, "requests">,
|
|
270
|
+
commitHistory: () => Promise<void>,
|
|
271
|
+
): Promise<boolean> {
|
|
272
|
+
try {
|
|
273
|
+
await commitHistory();
|
|
274
|
+
await core.requests?.checkpoint();
|
|
275
|
+
return !core.requests || core.requests.canRecover();
|
|
276
|
+
} catch {
|
|
277
|
+
return false;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/** SuperGrok's in-turn failover and refusal settlement on the core (X1b). */
|
|
282
|
+
export const XAI_CORE_REFUSAL: CoreRefusalBinding = {
|
|
283
|
+
provider: XAI,
|
|
284
|
+
displayName: DISPLAY_NAME,
|
|
285
|
+
// OAuth credentials renew, and the transport refreshes and retries an
|
|
286
|
+
// unauthorized request once before it surfaces as a refusal.
|
|
287
|
+
credential: { renewable: true, refreshedBeforeRefusal: true },
|
|
288
|
+
classify: classifyXaiProviderError,
|
|
289
|
+
lease: (deps) => deps.leases.xai,
|
|
290
|
+
isSourceDisconnected: XAI_CORE_TURN_PROVIDER.isSourceDisconnected,
|
|
291
|
+
failover: {
|
|
292
|
+
displayName: DISPLAY_NAME,
|
|
293
|
+
lease: (deps) => deps.leases.xai,
|
|
294
|
+
countRefusals: (db, identity) =>
|
|
295
|
+
subscriptionCoreTurns(XAI).countSubscriptionCoreTurnRefusals(db, identity),
|
|
296
|
+
refusalLimit: SUBSCRIPTION_CORE_TURN_REFUSAL_LIMIT,
|
|
297
|
+
recoveryReason: "xai_credential_failover",
|
|
298
|
+
recoveryProvider: "supergrok-subscription",
|
|
299
|
+
metrics: subscriptionCoreFailoverMetrics("xai"),
|
|
300
|
+
},
|
|
301
|
+
};
|
|
@@ -2,20 +2,25 @@ import {
|
|
|
2
2
|
resolveTurnExecutionPolicyV1,
|
|
3
3
|
WORKSPACE_GATEWAY_MODEL_ID_PREFIX,
|
|
4
4
|
WORKSPACE_OPENROUTER_MODEL_ID_PREFIX,
|
|
5
|
+
WORKSPACE_OPPER_MODEL_ID_PREFIX,
|
|
5
6
|
} from "@opengeni/config";
|
|
6
7
|
import {
|
|
8
|
+
applySessionAgentConfigWriteThrough,
|
|
7
9
|
assertWorkspaceModelPolicyAllows,
|
|
8
10
|
canonicalConfiguredModel,
|
|
11
|
+
resolveSessionAgentConfigForCreate,
|
|
9
12
|
createAndStartSessionWithOutcome,
|
|
10
13
|
recordWorkspaceUsage,
|
|
11
14
|
resolveCatalogSettings,
|
|
12
15
|
resolveWorkspaceCatalogSettings,
|
|
16
|
+
isDeveloperSetupDelegatedPermissionAllowed,
|
|
13
17
|
} from "@opengeni/core";
|
|
14
18
|
import {
|
|
15
19
|
AutomationAuthorityRevokedError,
|
|
16
20
|
assertAutomationRunAuthorityInTransaction,
|
|
17
21
|
claimAutomationRun,
|
|
18
22
|
settleAutomationRun,
|
|
23
|
+
requireWorkspace,
|
|
19
24
|
} from "@opengeni/db";
|
|
20
25
|
import { SessionSkills } from "@opengeni/contracts";
|
|
21
26
|
import { agentRunAdmissionDenial } from "./agent-run-admission";
|
|
@@ -30,6 +35,8 @@ export type AutomationActivityOptions = {
|
|
|
30
35
|
settle?: typeof settleAutomationRun;
|
|
31
36
|
assertAuthority?: typeof assertAutomationRunAuthorityInTransaction;
|
|
32
37
|
createSession?: typeof createAndStartSessionWithOutcome;
|
|
38
|
+
/** Workspace read for agent-configuration defaults (tests inject it). */
|
|
39
|
+
readWorkspace?: typeof requireWorkspace;
|
|
33
40
|
admit?: typeof agentRunAdmissionDenial;
|
|
34
41
|
assertModelPolicy?: typeof assertWorkspaceModelPolicyAllows;
|
|
35
42
|
recordUsage?: typeof recordWorkspaceUsage;
|
|
@@ -43,6 +50,7 @@ export function createAutomationActivities(
|
|
|
43
50
|
const settle = options.settle ?? settleAutomationRun;
|
|
44
51
|
const assertAuthority = options.assertAuthority ?? assertAutomationRunAuthorityInTransaction;
|
|
45
52
|
const createSession = options.createSession ?? createAndStartSessionWithOutcome;
|
|
53
|
+
const readWorkspace = options.readWorkspace ?? requireWorkspace;
|
|
46
54
|
const admit = options.admit ?? agentRunAdmissionDenial;
|
|
47
55
|
const assertModelPolicy = options.assertModelPolicy ?? assertWorkspaceModelPolicyAllows;
|
|
48
56
|
const recordUsage = options.recordUsage ?? recordWorkspaceUsage;
|
|
@@ -100,10 +108,25 @@ export function createAutomationActivities(
|
|
|
100
108
|
}
|
|
101
109
|
|
|
102
110
|
const template = accepted.sessionTemplate;
|
|
111
|
+
if (
|
|
112
|
+
template.credentialRestriction === "developer_setup" &&
|
|
113
|
+
template.firstPartyMcpPermissions.some(
|
|
114
|
+
(permission) => !isDeveloperSetupDelegatedPermissionAllowed(permission),
|
|
115
|
+
)
|
|
116
|
+
) {
|
|
117
|
+
await settle(service.db, {
|
|
118
|
+
workspaceId: input.workspaceId,
|
|
119
|
+
runId: run.id,
|
|
120
|
+
status: "failed",
|
|
121
|
+
errorCode: "credential_restriction_violation",
|
|
122
|
+
});
|
|
123
|
+
return { action: "failed", reason: "credential_restriction_violation" };
|
|
124
|
+
}
|
|
103
125
|
const requestedModel = template.model ?? deploymentCatalogSettings.openaiModel;
|
|
104
126
|
const catalogSettings =
|
|
105
127
|
requestedModel.startsWith(WORKSPACE_GATEWAY_MODEL_ID_PREFIX) ||
|
|
106
|
-
requestedModel.startsWith(WORKSPACE_OPENROUTER_MODEL_ID_PREFIX)
|
|
128
|
+
requestedModel.startsWith(WORKSPACE_OPENROUTER_MODEL_ID_PREFIX) ||
|
|
129
|
+
requestedModel.startsWith(WORKSPACE_OPPER_MODEL_ID_PREFIX)
|
|
107
130
|
? (
|
|
108
131
|
await resolveWorkspaceCatalogSettings(service.db, catalogSourceSettings, {
|
|
109
132
|
accountId: input.accountId,
|
|
@@ -158,7 +181,49 @@ export function createAutomationActivities(
|
|
|
158
181
|
reason: "interactive_compute_not_allowed",
|
|
159
182
|
};
|
|
160
183
|
}
|
|
161
|
-
|
|
184
|
+
// Agent configuration for the generated session (null = legacy). The
|
|
185
|
+
// template's explicit tools are its baseline; capabilities only narrow.
|
|
186
|
+
let agentWriteThrough: {
|
|
187
|
+
config: import("@opengeni/contracts").ResolvedAgentConfig | null;
|
|
188
|
+
instructions: string | undefined;
|
|
189
|
+
firstPartyMcpTools: typeof template.firstPartyMcpTools;
|
|
190
|
+
tools: typeof template.tools;
|
|
191
|
+
};
|
|
192
|
+
try {
|
|
193
|
+
const workspaceSettings = (await readWorkspace(service.db, input.workspaceId)).settings;
|
|
194
|
+
const resolution = resolveSessionAgentConfigForCreate({
|
|
195
|
+
settings: catalogSettings,
|
|
196
|
+
creator: "automation",
|
|
197
|
+
request: template.agent,
|
|
198
|
+
instructions: template.instructions ?? undefined,
|
|
199
|
+
workspaceSettings,
|
|
200
|
+
parent: null,
|
|
201
|
+
goal: false,
|
|
202
|
+
});
|
|
203
|
+
const written = applySessionAgentConfigWriteThrough({
|
|
204
|
+
config: resolution.config,
|
|
205
|
+
firstPartyMcpTools: template.firstPartyMcpTools,
|
|
206
|
+
tools: template.tools,
|
|
207
|
+
toolPolicy: { mode: "explicit", inheritedFromSessionId: null },
|
|
208
|
+
productServerIds: template.tools.map((tool) => tool.id),
|
|
209
|
+
});
|
|
210
|
+
agentWriteThrough = {
|
|
211
|
+
config: resolution.config,
|
|
212
|
+
instructions: resolution.instructions,
|
|
213
|
+
firstPartyMcpTools: written.firstPartyMcpTools,
|
|
214
|
+
tools: written.tools,
|
|
215
|
+
};
|
|
216
|
+
} catch (error) {
|
|
217
|
+
if (!isUnprocessableEntity(error)) throw error;
|
|
218
|
+
await settle(service.db, {
|
|
219
|
+
workspaceId: input.workspaceId,
|
|
220
|
+
runId: run.id,
|
|
221
|
+
status: "failed",
|
|
222
|
+
errorCode: "dispatch_failed",
|
|
223
|
+
});
|
|
224
|
+
return { action: "failed", reason: "dispatch_failed" };
|
|
225
|
+
}
|
|
226
|
+
const resolvedTurnExecutionPolicy = resolveTurnExecutionPolicyV1(catalogSettings, {
|
|
162
227
|
modelId: model,
|
|
163
228
|
requestedModelId: template.model,
|
|
164
229
|
modelSource: template.model ? "explicit" : "deployment",
|
|
@@ -167,6 +232,12 @@ export function createAutomationActivities(
|
|
|
167
232
|
latencyMode: "standard",
|
|
168
233
|
latencyModeSource: "deployment",
|
|
169
234
|
});
|
|
235
|
+
const turnExecutionPolicy = template.credentialRestriction
|
|
236
|
+
? {
|
|
237
|
+
...resolvedTurnExecutionPolicy,
|
|
238
|
+
credentialRestriction: template.credentialRestriction,
|
|
239
|
+
}
|
|
240
|
+
: resolvedTurnExecutionPolicy;
|
|
170
241
|
const created = await createSession({
|
|
171
242
|
db: service.db,
|
|
172
243
|
bus: service.bus,
|
|
@@ -189,10 +260,12 @@ export function createAutomationActivities(
|
|
|
189
260
|
accountId: input.accountId,
|
|
190
261
|
workspaceId: input.workspaceId,
|
|
191
262
|
initialMessage: accepted.initialMessage,
|
|
263
|
+
surface: "automation",
|
|
264
|
+
metrics: service.observability,
|
|
192
265
|
resources: template.resources,
|
|
193
266
|
skills: SessionSkills.parse(template.skills),
|
|
194
267
|
bundledSkillIds: template.bundledSkillIds,
|
|
195
|
-
tools:
|
|
268
|
+
tools: agentWriteThrough.tools,
|
|
196
269
|
toolPolicy: { mode: "explicit", inheritedFromSessionId: null },
|
|
197
270
|
model,
|
|
198
271
|
reasoningEffort,
|
|
@@ -211,13 +284,15 @@ export function createAutomationActivities(
|
|
|
211
284
|
label: accepted.serviceLabel,
|
|
212
285
|
},
|
|
213
286
|
createdByContext: accepted.provenance,
|
|
214
|
-
instructions: template.instructions,
|
|
287
|
+
instructions: agentWriteThrough.instructions ?? template.instructions,
|
|
215
288
|
policyRole: template.policyRole,
|
|
216
289
|
firstPartyMcpPermissions: template.firstPartyMcpPermissions,
|
|
217
|
-
firstPartyMcpTools:
|
|
290
|
+
firstPartyMcpTools: agentWriteThrough.firstPartyMcpTools,
|
|
291
|
+
...(agentWriteThrough.config ? { agentConfig: agentWriteThrough.config } : {}),
|
|
218
292
|
retainWorkspaceCustomModel:
|
|
219
293
|
model.startsWith(WORKSPACE_GATEWAY_MODEL_ID_PREFIX) ||
|
|
220
|
-
model.startsWith(WORKSPACE_OPENROUTER_MODEL_ID_PREFIX)
|
|
294
|
+
model.startsWith(WORKSPACE_OPENROUTER_MODEL_ID_PREFIX) ||
|
|
295
|
+
model.startsWith(WORKSPACE_OPPER_MODEL_ID_PREFIX),
|
|
221
296
|
createIdempotencyKey: `automation-run:${run.id}`,
|
|
222
297
|
subjectId: accepted.serviceSubjectId,
|
|
223
298
|
});
|