@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
|
@@ -1,37 +1,33 @@
|
|
|
1
1
|
import { createKnowledgeSourceAttemptTools } from "./knowledge-source-tools";
|
|
2
|
-
import { getWorkspaceConnectionModelRestrictions } from "@opengeni/db";
|
|
3
2
|
import {
|
|
3
|
+
resolveInitiatingHuman,
|
|
4
|
+
buildSlackApiRateLimiter,
|
|
4
5
|
beginConnectorActionExecution,
|
|
5
6
|
getExternalLinkTurnAuthorization,
|
|
6
7
|
getSessionTurnForAttempt,
|
|
7
8
|
getWorkspaceVideoGenerationPolicy,
|
|
8
9
|
listSkillDescriptors,
|
|
9
10
|
completeConnectorActionExecution,
|
|
10
|
-
getScheduledVariableSetExpectedGenerationForAttempt,
|
|
11
|
-
getWorkspaceModelPolicy,
|
|
12
|
-
listWorkspaceGatewayCustomModels,
|
|
13
|
-
listWorkspaceOpenRouterCustomModels,
|
|
14
|
-
listOrganizationModelProviderCustomModelsForWorkspace,
|
|
15
|
-
organizationModelProviderConnectionActiveForWorkspace,
|
|
16
11
|
persistAttemptToolCatalog,
|
|
12
|
+
requireWorkspace,
|
|
17
13
|
prepareConnectorActionApproval,
|
|
14
|
+
recordUsageEvent,
|
|
18
15
|
previewConnectorActionApproval,
|
|
19
16
|
namedSubjectHasLiveWorkspaceAuthority,
|
|
20
17
|
updateSessionTitleWithEvent,
|
|
21
|
-
|
|
22
|
-
workspaceCodexSubscriptionActive,
|
|
23
|
-
workspaceVercelAiGatewayConnectionActive,
|
|
24
|
-
workspaceOpenRouterConnectionActive,
|
|
25
|
-
workspaceXaiSubscriptionActiveForAuthority,
|
|
18
|
+
subscriptionCoreCodexAppsRequestAuth,
|
|
26
19
|
} from "@opengeni/db";
|
|
27
20
|
import { publishDurableSessionEvents } from "@opengeni/events";
|
|
28
21
|
import {
|
|
29
22
|
type OpenGeniRuntime,
|
|
23
|
+
type RunMcpCredentials,
|
|
24
|
+
selectedSessionRemoteMcpTargets,
|
|
30
25
|
type AttemptConnectorActionBinding,
|
|
31
26
|
type ConnectorAttachmentMaterializationRequest,
|
|
32
27
|
type ConnectorActionPolicyHooks,
|
|
33
28
|
createFirstPartyInteractionAttemptToolDefinitions,
|
|
34
29
|
mcpToolDisplayMetadata,
|
|
30
|
+
toolFamilyForCatalogIdentity,
|
|
35
31
|
} from "@opengeni/runtime";
|
|
36
32
|
import {
|
|
37
33
|
createGoogleDrivePublicationAttemptTool,
|
|
@@ -51,40 +47,56 @@ import { readMcpOperation } from "../mcp-operation-reader";
|
|
|
51
47
|
import { createOperationReadAttemptToolDefinition } from "./mcp-operation-read-tool";
|
|
52
48
|
import { buildGitHubRestMcpForTurn } from "../../github-rest-mcp";
|
|
53
49
|
import { materializeConnectorAttachmentsInChannel } from "../connector-attachments";
|
|
54
|
-
import {
|
|
50
|
+
import {
|
|
51
|
+
materializeConnectorFile,
|
|
52
|
+
materializeGmailFile,
|
|
53
|
+
readGmailFileFromChannel,
|
|
54
|
+
} from "../gmail-files";
|
|
55
|
+
import { objectStorageForSandboxDownloads } from "./file-resources";
|
|
56
|
+
import {
|
|
57
|
+
allowedFirstPartyMcpToolsForSession,
|
|
58
|
+
resolveSessionFirstPartyMcpTools,
|
|
59
|
+
type Settings,
|
|
60
|
+
} from "@opengeni/config";
|
|
55
61
|
import { CodemodeAttemptDispatcher } from "../codemode-dispatcher";
|
|
56
|
-
import { buildCodexTokenResolver } from "../codex-auth";
|
|
57
|
-
import { CODEX_CLIENT_VERSION } from "@opengeni/codex";
|
|
58
62
|
import { mergeResourceRefs } from "../common";
|
|
59
63
|
import {
|
|
60
64
|
workspaceSessionToolPolicyDefaultServerIds,
|
|
61
|
-
loadRigDefaultVariableSetEnvironment,
|
|
62
|
-
mergeRigDefaultVariableSetEnvironment,
|
|
63
65
|
buildApiIntegrationMcpServers,
|
|
64
66
|
resolveCatalogSettings,
|
|
65
67
|
resolveWorkspaceModelSelection,
|
|
68
|
+
loadWorkspaceModelSelectionInput,
|
|
66
69
|
withFrozenPersonalConnectionDelegations,
|
|
67
|
-
|
|
70
|
+
resolveTurnToolPolicy,
|
|
71
|
+
scheduledTurnMcpServerIds,
|
|
72
|
+
scheduledTurnFirstPartyMcpTools,
|
|
68
73
|
hasPermission,
|
|
74
|
+
requireExplicitPermissionDelegation,
|
|
75
|
+
createWebSearchBilling,
|
|
69
76
|
} from "@opengeni/core";
|
|
70
|
-
import { loadWorkspaceEnvironmentForRunWithCredentials } from "../environment";
|
|
71
77
|
import { withFirstPartyTools } from "../goals";
|
|
72
78
|
import type { TurnActivityServices as ActivityServices, RunAgentTurnInput } from "../types";
|
|
73
|
-
import {
|
|
79
|
+
import {
|
|
80
|
+
recordSkillCheckout,
|
|
81
|
+
recordSkillRead,
|
|
82
|
+
recordToolPreparationPhase,
|
|
83
|
+
recordTurnStartupPhase,
|
|
84
|
+
} from "../../observability-metrics";
|
|
74
85
|
import { ToolResultSpill } from "./tool-result-spill";
|
|
75
86
|
import { createTurnMediaArtifacts } from "./media-artifacts";
|
|
87
|
+
import { promptToolAvailabilityForTurn } from "./prompt-tool-availability";
|
|
76
88
|
import { SandboxChannelAService } from "@opengeni/runtime/sandbox";
|
|
77
89
|
import { sandboxRunAs } from "@opengeni/runtime";
|
|
78
90
|
import {
|
|
91
|
+
bundledSkillSelectionForAgentConfig,
|
|
79
92
|
DEFAULT_FIRST_PARTY_MCP_PERMISSIONS,
|
|
93
|
+
resolveAgentToolFamilies,
|
|
94
|
+
type ResourceRef,
|
|
95
|
+
type Permission,
|
|
80
96
|
type ToolAuthNeededPayload,
|
|
81
97
|
} from "@opengeni/contracts";
|
|
82
98
|
|
|
83
|
-
import {
|
|
84
|
-
rollingSafeToolAuthNeededPayload,
|
|
85
|
-
shouldPublishToolAuthNeededForTurn,
|
|
86
|
-
xaiCatalogReadinessAuthority,
|
|
87
|
-
} from "./admission";
|
|
99
|
+
import { rollingSafeToolAuthNeededPayload, shouldPublishToolAuthNeededForTurn } from "./admission";
|
|
88
100
|
import { unavailableMcpOperationalContext } from "./errors";
|
|
89
101
|
import { runtimeResourcesForTurn } from "./file-resources";
|
|
90
102
|
import { waitForTurnOperation } from "./sandbox-provision";
|
|
@@ -96,25 +108,48 @@ import type { sandboxArtifactRuntimeAdmission } from "./sandbox-route";
|
|
|
96
108
|
import type {
|
|
97
109
|
AttemptIdentityState,
|
|
98
110
|
EventingState,
|
|
111
|
+
RenewalState,
|
|
99
112
|
SandboxRuntimeState,
|
|
100
113
|
WorkspaceRefState,
|
|
101
114
|
} from "./turn-context";
|
|
102
115
|
import {
|
|
103
116
|
createSessionTitleAttemptToolDefinition,
|
|
117
|
+
routeAllowsSessionTitleRequests,
|
|
104
118
|
sessionTitleToolPlan,
|
|
105
119
|
shouldRequestMissingSessionTitle,
|
|
106
120
|
} from "./session-title";
|
|
107
121
|
import { resolveTurnSandboxAccess } from "./turn-sandbox-access";
|
|
108
122
|
import { createListModelsAttemptToolDefinition } from "./list-models";
|
|
109
|
-
import {
|
|
123
|
+
import { createRefreshCredentialsAttemptToolDefinition } from "./refresh-credentials";
|
|
124
|
+
import { codeSearchToolDefinitions, codeSearchWorkspaceFromChannel } from "./code-search";
|
|
125
|
+
import { turnWebSearchPlan, webSearchToolDefinitions } from "./web-search";
|
|
126
|
+
import {
|
|
127
|
+
createWorkspaceSkillTools,
|
|
128
|
+
sessionShadowedSkillNames,
|
|
129
|
+
withoutSessionShadowedSkills,
|
|
130
|
+
} from "./skill-tools";
|
|
110
131
|
import { loadConfiguredBundledSkills } from "./skill-selection";
|
|
111
132
|
import { guardSkillFilesystem } from "./skill-transfer";
|
|
133
|
+
import { turnCredentialRestriction } from "./credential-restriction";
|
|
134
|
+
import { attemptSecretResolver, type AttemptVaultAccess } from "./secret-resolver";
|
|
135
|
+
|
|
136
|
+
/** A linked turn's immutable policy must survive array and token boundaries. */
|
|
137
|
+
export function linkedTurnFirstPartyPermissions(
|
|
138
|
+
selected: Permission[] | null,
|
|
139
|
+
linked: { permissions: Permission[]; permissionMode?: "legacy" | "explicit" } | null,
|
|
140
|
+
): Permission[] | null {
|
|
141
|
+
if (!linked) return selected;
|
|
142
|
+
const permissions = (selected ?? DEFAULT_FIRST_PARTY_MCP_PERMISSIONS).filter((permission) =>
|
|
143
|
+
hasPermission(linked.permissions, permission, linked.permissionMode),
|
|
144
|
+
);
|
|
145
|
+
requireExplicitPermissionDelegation(linked, permissions);
|
|
146
|
+
return permissions;
|
|
147
|
+
}
|
|
112
148
|
|
|
113
149
|
export type PrepareTurnToolPolicyDeps = {
|
|
114
150
|
input: RunAgentTurnInput;
|
|
115
151
|
db: ActivityServices["db"];
|
|
116
152
|
cancellationSignal: AbortSignal | undefined;
|
|
117
|
-
connectionCredentials: ActivityServices["connectionCredentials"];
|
|
118
153
|
turn: ClaimTurnOk["turn"];
|
|
119
154
|
session: ClaimTurnOk["session"];
|
|
120
155
|
fileAuthoritySubjectId: ClaimTurnOk["fileAuthoritySubjectId"];
|
|
@@ -125,6 +160,8 @@ export type PrepareTurnToolPolicyDeps = {
|
|
|
125
160
|
};
|
|
126
161
|
|
|
127
162
|
export type PrepareTurnToolRuntimeDeps = {
|
|
163
|
+
/** Connected-vault providers and the shared read budget for this attempt. */
|
|
164
|
+
vaultAccess: AttemptVaultAccess;
|
|
128
165
|
fetchKnowledgeSource?:
|
|
129
166
|
| ((
|
|
130
167
|
input: import("../types").RunKnowledgeSourceSyncBatchInput,
|
|
@@ -148,11 +185,14 @@ export type PrepareTurnToolRuntimeDeps = {
|
|
|
148
185
|
fileAuthoritySubjectId: ClaimTurnOk["fileAuthoritySubjectId"];
|
|
149
186
|
capabilitySettings: ClaimTurnOk["capabilitySettings"];
|
|
150
187
|
installedApiIntegrations: ClaimTurnOk["installedApiIntegrations"];
|
|
151
|
-
|
|
188
|
+
codexAppsCoreConnectionId?: ClaimTurnOk["codexAppsCoreConnectionId"];
|
|
152
189
|
turnExecutionPolicy: ClaimTurnOk["turnExecutionPolicy"];
|
|
153
190
|
trigger: ClaimTurnOk["trigger"];
|
|
154
191
|
runSettings: GovernanceModelOk["runSettings"];
|
|
192
|
+
resolvedModel: GovernanceModelOk["resolvedModel"];
|
|
155
193
|
lazyToolTransport: GovernanceModelOk["lazyToolTransport"];
|
|
194
|
+
/** The workspace allows Opengeni credits; paid web tools are omitted when not. */
|
|
195
|
+
workspaceCreditModelsAllowed: GovernanceModelOk["workspaceCreditModelsAllowed"];
|
|
156
196
|
turnTools: ReturnType<typeof withFirstPartyTools>;
|
|
157
197
|
connectionScope: { accountId: string; workspaceId: string };
|
|
158
198
|
sandboxArtifactRuntime: ReturnType<typeof sandboxArtifactRuntimeAdmission>;
|
|
@@ -163,22 +203,29 @@ export type PrepareTurnToolRuntimeDeps = {
|
|
|
163
203
|
credentialSubjectId: ClaimTurnOk["credentialSubjectId"];
|
|
164
204
|
interactionInterventionResume: ClaimTurnOk["interactionInterventionResume"];
|
|
165
205
|
runWorkspaceMutationForSandbox: SandboxTurnRuntime["runWorkspaceMutationForSandbox"];
|
|
206
|
+
/** Deployment and workspace allow the Jev-backed code_search tool. */
|
|
207
|
+
codeSearchEnabled: boolean;
|
|
208
|
+
/**
|
|
209
|
+
* False for an optional repository that sits this turn out after losing
|
|
210
|
+
* access (dropUnavailableOptionalRepositories), so no tool surface offers it.
|
|
211
|
+
*/
|
|
212
|
+
retainsOptionalRepository?: (resource: ResourceRef) => boolean;
|
|
166
213
|
throwIfWorkerShuttingDown: () => void;
|
|
167
214
|
throwIfTurnCancelled: () => void;
|
|
215
|
+
/** Present when this turn resolves host-managed run credentials. */
|
|
216
|
+
runCredentialRenewals?: RenewalState | undefined;
|
|
217
|
+
runMcpCredentials?: RunMcpCredentials;
|
|
168
218
|
};
|
|
169
219
|
|
|
170
220
|
export async function prepareTurnToolPolicy(deps: PrepareTurnToolPolicyDeps) {
|
|
171
221
|
const {
|
|
172
222
|
input,
|
|
173
223
|
db,
|
|
174
|
-
cancellationSignal,
|
|
175
|
-
connectionCredentials,
|
|
176
224
|
turn,
|
|
177
225
|
session,
|
|
178
226
|
fileAuthoritySubjectId,
|
|
179
227
|
capabilitySettings,
|
|
180
228
|
runSettings,
|
|
181
|
-
rigVersion,
|
|
182
229
|
workspaceRefs,
|
|
183
230
|
} = deps;
|
|
184
231
|
|
|
@@ -197,155 +244,52 @@ export async function prepareTurnToolPolicy(deps: PrepareTurnToolPolicyDeps) {
|
|
|
197
244
|
// sessions follow the current configured MCP set,
|
|
198
245
|
// while explicit, inherited-fixed, and legacy sessions remain narrowed
|
|
199
246
|
// to their stored materialized allow-list.
|
|
200
|
-
const
|
|
201
|
-
const value =
|
|
202
|
-
turn.metadata && typeof turn.metadata === "object" && !Array.isArray(turn.metadata)
|
|
203
|
-
? (turn.metadata as Record<string, unknown>).scheduledEffectiveMcpServerIds
|
|
204
|
-
: null;
|
|
205
|
-
return Array.isArray(value) && value.every((id) => typeof id === "string")
|
|
206
|
-
? [...new Set(value)].sort()
|
|
207
|
-
: null;
|
|
208
|
-
})();
|
|
209
|
-
const currentMcpServerIds = new Set(runSettings.mcpServers.map((server) => server.id));
|
|
210
|
-
const resolvedToolPolicy = resolveSessionToolPolicy({
|
|
247
|
+
const resolvedToolPolicy = resolveTurnToolPolicy({
|
|
211
248
|
toolPolicy: session.toolPolicy,
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
: [...currentMcpServerIds],
|
|
249
|
+
session,
|
|
250
|
+
turn,
|
|
251
|
+
availableMcpServerIds: runSettings.mcpServers.map((server) => server.id),
|
|
216
252
|
defaultMcpServerIds:
|
|
217
|
-
|
|
218
|
-
(session.toolPolicy.mode === "workspace_default"
|
|
253
|
+
scheduledTurnMcpServerIds(turn) === null && session.toolPolicy.mode === "workspace_default"
|
|
219
254
|
? await workspaceSessionToolPolicyDefaultServerIds(
|
|
220
255
|
db,
|
|
221
256
|
input.workspaceId,
|
|
222
257
|
capabilitySettings,
|
|
223
258
|
fileAuthoritySubjectId ?? undefined,
|
|
224
259
|
)
|
|
225
|
-
: []
|
|
260
|
+
: [],
|
|
226
261
|
});
|
|
227
262
|
const mcpAvailabilityNote = unavailableMcpOperationalContext({
|
|
228
263
|
droppedIds: resolvedToolPolicy.effectivePolicy.droppedIds,
|
|
229
264
|
droppedCount: resolvedToolPolicy.effectivePolicy.counts.dropped,
|
|
230
265
|
});
|
|
231
|
-
const
|
|
266
|
+
const families = resolveAgentToolFamilies(session.agent, {
|
|
267
|
+
productServerIds: new Set([
|
|
268
|
+
...session.mcpServers.map((server) => server.id),
|
|
269
|
+
...(session.toolPolicy.mode !== "workspace_default"
|
|
270
|
+
? session.tools.map((tool) => tool.id)
|
|
271
|
+
: []),
|
|
272
|
+
]),
|
|
273
|
+
});
|
|
274
|
+
const effectivePolicyTools = resolvedToolPolicy.toolRefs.filter(
|
|
275
|
+
(tool) => tool.kind !== "mcp" || families.allowsMcpServer(tool.id),
|
|
276
|
+
);
|
|
232
277
|
const turnTools = withFirstPartyTools(runSettings, effectivePolicyTools);
|
|
233
|
-
//
|
|
234
|
-
//
|
|
235
|
-
//
|
|
236
|
-
//
|
|
237
|
-
// additionally require the causal human frozen into the admitted turn.
|
|
278
|
+
// W1 (secrets delivery): the turn no longer loads or decrypts Variable Sets,
|
|
279
|
+
// and nothing user-defined is injected into the sandbox environment. User
|
|
280
|
+
// secrets reach a command only through `{{secret:…}}` references resolved at
|
|
281
|
+
// the exec boundary. Variable Sets stay readable elsewhere until W6 removes them.
|
|
238
282
|
const connectionScope = {
|
|
239
283
|
accountId: input.accountId,
|
|
240
284
|
workspaceId: input.workspaceId,
|
|
241
285
|
};
|
|
242
|
-
|
|
243
|
-
const sessionVariableSetIds = session.variableSetIds;
|
|
244
|
-
let workspaceVariableSet: Awaited<
|
|
245
|
-
ReturnType<typeof loadWorkspaceEnvironmentForRunWithCredentials>
|
|
246
|
-
> = null;
|
|
247
|
-
const explicitEnvironmentValues: Record<string, string> = {};
|
|
248
|
-
const rigDefaultEnvironmentValues: Record<string, string> = {};
|
|
249
|
-
if (sessionVariableSetIds.length > 0 || rigDefaultVariableSetIds.length > 0) {
|
|
250
|
-
const variableSetAuthority = {
|
|
251
|
-
sessionId: input.sessionId,
|
|
252
|
-
turnId: turn.id,
|
|
253
|
-
attemptId: input.attemptId,
|
|
254
|
-
executionGeneration: turn.executionGeneration,
|
|
255
|
-
initiator: turn.initiator,
|
|
256
|
-
initiatingHumanSubjectId: fileAuthoritySubjectId,
|
|
257
|
-
};
|
|
258
|
-
// A scheduled attempt may materialize only the exact generation frozen
|
|
259
|
-
// on its accepted occurrence; ordinary turns resolve to null.
|
|
260
|
-
const expectedVariableSetGeneration = async (
|
|
261
|
-
candidateVariableSetId: string,
|
|
262
|
-
): Promise<number | null> =>
|
|
263
|
-
await getScheduledVariableSetExpectedGenerationForAttempt(db, {
|
|
264
|
-
accountId: input.accountId,
|
|
265
|
-
workspaceId: input.workspaceId,
|
|
266
|
-
subjectId: fileAuthoritySubjectId ?? turn.initiator.subjectId,
|
|
267
|
-
initiatingHumanSubjectId: fileAuthoritySubjectId,
|
|
268
|
-
sessionId: input.sessionId,
|
|
269
|
-
turnId: turn.id,
|
|
270
|
-
attemptId: input.attemptId,
|
|
271
|
-
executionGeneration: turn.executionGeneration,
|
|
272
|
-
variableSetId: candidateVariableSetId,
|
|
273
|
-
});
|
|
274
|
-
for (const variableSetId of sessionVariableSetIds) {
|
|
275
|
-
const selected = await waitForTurnOperation(
|
|
276
|
-
(async () =>
|
|
277
|
-
loadWorkspaceEnvironmentForRunWithCredentials(
|
|
278
|
-
db,
|
|
279
|
-
runSettings,
|
|
280
|
-
connectionScope,
|
|
281
|
-
variableSetId,
|
|
282
|
-
variableSetAuthority,
|
|
283
|
-
connectionCredentials?.sandboxSecrets,
|
|
284
|
-
connectionCredentials?.sandboxSecrets
|
|
285
|
-
? { expectedGeneration: await expectedVariableSetGeneration(variableSetId) }
|
|
286
|
-
: {},
|
|
287
|
-
))(),
|
|
288
|
-
cancellationSignal,
|
|
289
|
-
undefined,
|
|
290
|
-
);
|
|
291
|
-
if (!selected) continue;
|
|
292
|
-
Object.assign(explicitEnvironmentValues, selected.values);
|
|
293
|
-
// Preserve the legacy single-set metadata view as the final,
|
|
294
|
-
// highest-precedence explicit selection while its values represent the
|
|
295
|
-
// complete ordered explicit layer.
|
|
296
|
-
workspaceVariableSet = { ...selected, values: { ...explicitEnvironmentValues } };
|
|
297
|
-
}
|
|
298
|
-
// RIG DEFAULT VARIABLE SETS (M3): decrypt the frozen rig version's default
|
|
299
|
-
// variable sets and layer them BELOW the session's own set — the session's
|
|
300
|
-
// values WIN on any key collision. Loaded through the SAME host-secrets
|
|
301
|
-
// provider path as the session set (embedded-topology parity). Precedence
|
|
302
|
-
// WITHIN the rig defaults is listed order (a later set overrides an earlier
|
|
303
|
-
// one), then the session set overrides all. STABLE-ENV INVARIANT: the rig
|
|
304
|
-
// VERSION is frozen per session, so the SET of default variable sets is
|
|
305
|
-
// fixed for the session's life — the merged manifest env is therefore stable
|
|
306
|
-
// across the session's turns (the same guarantee the session's own variable
|
|
307
|
-
// set already relies on), keeping validateNoEnvironmentDelta empty.
|
|
308
|
-
Object.assign(
|
|
309
|
-
rigDefaultEnvironmentValues,
|
|
310
|
-
await loadRigDefaultVariableSetEnvironment(
|
|
311
|
-
rigDefaultVariableSetIds,
|
|
312
|
-
async (rigDefaultVariableSetId) =>
|
|
313
|
-
await waitForTurnOperation(
|
|
314
|
-
(async () =>
|
|
315
|
-
loadWorkspaceEnvironmentForRunWithCredentials(
|
|
316
|
-
db,
|
|
317
|
-
runSettings,
|
|
318
|
-
connectionScope,
|
|
319
|
-
rigDefaultVariableSetId,
|
|
320
|
-
variableSetAuthority,
|
|
321
|
-
connectionCredentials?.sandboxSecrets,
|
|
322
|
-
connectionCredentials?.sandboxSecrets
|
|
323
|
-
? {
|
|
324
|
-
expectedGeneration:
|
|
325
|
-
await expectedVariableSetGeneration(rigDefaultVariableSetId),
|
|
326
|
-
}
|
|
327
|
-
: {},
|
|
328
|
-
))(),
|
|
329
|
-
cancellationSignal,
|
|
330
|
-
undefined,
|
|
331
|
-
),
|
|
332
|
-
),
|
|
333
|
-
);
|
|
334
|
-
}
|
|
335
|
-
workspaceRefs.variableSetId = workspaceVariableSet?.id ?? "";
|
|
336
|
-
// Session set wins collisions with the rig defaults (explicit precedence).
|
|
337
|
-
const sandboxWorkspaceEnvironmentValues = mergeRigDefaultVariableSetEnvironment(
|
|
338
|
-
rigDefaultEnvironmentValues,
|
|
339
|
-
explicitEnvironmentValues,
|
|
340
|
-
);
|
|
286
|
+
workspaceRefs.variableSetId = "";
|
|
341
287
|
return {
|
|
342
288
|
turnResources,
|
|
343
289
|
runtimeResources,
|
|
344
290
|
mcpAvailabilityNote,
|
|
345
291
|
turnTools,
|
|
346
292
|
connectionScope,
|
|
347
|
-
workspaceVariableSet,
|
|
348
|
-
sandboxWorkspaceEnvironmentValues,
|
|
349
293
|
};
|
|
350
294
|
}
|
|
351
295
|
|
|
@@ -367,11 +311,13 @@ export async function prepareTurnToolRuntime(deps: PrepareTurnToolRuntimeDeps) {
|
|
|
367
311
|
turn,
|
|
368
312
|
session,
|
|
369
313
|
installedApiIntegrations,
|
|
370
|
-
|
|
314
|
+
codexAppsCoreConnectionId,
|
|
371
315
|
turnExecutionPolicy,
|
|
372
316
|
trigger,
|
|
373
317
|
runSettings: canonicalRunSettings,
|
|
318
|
+
resolvedModel,
|
|
374
319
|
lazyToolTransport,
|
|
320
|
+
workspaceCreditModelsAllowed,
|
|
375
321
|
turnTools: canonicalTurnTools,
|
|
376
322
|
sandboxArtifactRuntime,
|
|
377
323
|
activeSandboxBackend,
|
|
@@ -381,6 +327,8 @@ export async function prepareTurnToolRuntime(deps: PrepareTurnToolRuntimeDeps) {
|
|
|
381
327
|
credentialSubjectId,
|
|
382
328
|
interactionInterventionResume,
|
|
383
329
|
runWorkspaceMutationForSandbox,
|
|
330
|
+
codeSearchEnabled,
|
|
331
|
+
retainsOptionalRepository,
|
|
384
332
|
throwIfWorkerShuttingDown,
|
|
385
333
|
throwIfTurnCancelled,
|
|
386
334
|
} = deps;
|
|
@@ -392,6 +340,7 @@ export async function prepareTurnToolRuntime(deps: PrepareTurnToolRuntimeDeps) {
|
|
|
392
340
|
});
|
|
393
341
|
const runSettings = accountRoutes.settings;
|
|
394
342
|
const turnTools = accountRoutes.tools;
|
|
343
|
+
const credentialRestriction = turnCredentialRestriction(turnExecutionPolicy, session.metadata);
|
|
395
344
|
const toolContextPreparationStartedAt = performance.now();
|
|
396
345
|
throwIfWorkerShuttingDown();
|
|
397
346
|
throwIfTurnCancelled();
|
|
@@ -512,37 +461,20 @@ export async function prepareTurnToolRuntime(deps: PrepareTurnToolRuntimeDeps) {
|
|
|
512
461
|
sessionId: input.sessionId,
|
|
513
462
|
attemptId: input.attemptId,
|
|
514
463
|
turn,
|
|
515
|
-
resources: mergeResourceRefs(session.resources, turn.resources)
|
|
464
|
+
resources: mergeResourceRefs(session.resources, turn.resources).filter(
|
|
465
|
+
(resource) => retainsOptionalRepository?.(resource) ?? true,
|
|
466
|
+
),
|
|
516
467
|
tools: turnTools,
|
|
517
468
|
resolveCredential,
|
|
518
469
|
});
|
|
519
470
|
const localMcpServers = [...apiIntegrationMcpServers, ...githubRestMcp.localMcpServers];
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
);
|
|
528
|
-
return {
|
|
529
|
-
clientVersion: CODEX_CLIENT_VERSION,
|
|
530
|
-
withAuthorization: async <T>(
|
|
531
|
-
use: (token: { accessToken: string; chatgptAccountId: string | null }) => Promise<T>,
|
|
532
|
-
): Promise<T> => {
|
|
533
|
-
const snapshot = await resolver.getToken();
|
|
534
|
-
|
|
535
|
-
return await withCodexAppsRequestAuthorization(
|
|
536
|
-
db,
|
|
537
|
-
{
|
|
538
|
-
workspaceId: input.workspaceId,
|
|
539
|
-
credentialId: codexAppsCredentialId,
|
|
540
|
-
},
|
|
541
|
-
async () => await use(snapshot),
|
|
542
|
-
);
|
|
543
|
-
},
|
|
544
|
-
};
|
|
545
|
-
})()
|
|
471
|
+
// Apps authorization is the exact core designation resolved at claim.
|
|
472
|
+
const codexAppsAuth = codexAppsCoreConnectionId
|
|
473
|
+
? subscriptionCoreCodexAppsRequestAuth(db, runSettings, {
|
|
474
|
+
accountId: input.accountId,
|
|
475
|
+
workspaceId: input.workspaceId,
|
|
476
|
+
connectionId: codexAppsCoreConnectionId,
|
|
477
|
+
})
|
|
546
478
|
: undefined;
|
|
547
479
|
const linkedAuthority = await getExternalLinkTurnAuthorization(
|
|
548
480
|
db,
|
|
@@ -554,25 +486,46 @@ export async function prepareTurnToolRuntime(deps: PrepareTurnToolRuntimeDeps) {
|
|
|
554
486
|
);
|
|
555
487
|
if (linkedAuthority && !linkedAuthority.authorized)
|
|
556
488
|
throw new Error("Native identity link was revoked");
|
|
557
|
-
const effectiveFirstPartyPermissions =
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
)
|
|
561
|
-
: session.firstPartyMcpPermissions;
|
|
562
|
-
const selectedFirstPartyMcpTools = allowedFirstPartyMcpToolsForSession(
|
|
563
|
-
runSettings,
|
|
564
|
-
session.firstPartyMcpTools,
|
|
489
|
+
const effectiveFirstPartyPermissions = linkedTurnFirstPartyPermissions(
|
|
490
|
+
session.firstPartyMcpPermissions,
|
|
491
|
+
linkedAuthority,
|
|
565
492
|
);
|
|
493
|
+
// Background-command tools need compute: the effective route of this turn,
|
|
494
|
+
// a managed sandbox or an attached Connected Machine, not the durable home.
|
|
495
|
+
const toolFamilies = resolveAgentToolFamilies(session.agent, {
|
|
496
|
+
sandboxAttached: (activeSandboxBackend ?? groupBoxBackend) !== "none",
|
|
497
|
+
});
|
|
498
|
+
const selectedFirstPartyMcpTools = toolFamilies.firstPartyTools(
|
|
499
|
+
scheduledTurnMcpServerIds(turn) !== null
|
|
500
|
+
? allowedFirstPartyMcpToolsForSession(
|
|
501
|
+
runSettings,
|
|
502
|
+
scheduledTurnFirstPartyMcpTools(turn) ?? session.firstPartyMcpTools,
|
|
503
|
+
)
|
|
504
|
+
: resolveSessionFirstPartyMcpTools(
|
|
505
|
+
runSettings,
|
|
506
|
+
session,
|
|
507
|
+
(await requireWorkspace(db, input.workspaceId)).settings,
|
|
508
|
+
),
|
|
509
|
+
);
|
|
510
|
+
// Frozen with the selection and ceiling above; instructions only.
|
|
511
|
+
const promptToolAvailability = promptToolAvailabilityForTurn({
|
|
512
|
+
agentConfig: session.agent,
|
|
513
|
+
selectedFirstPartyMcpTools,
|
|
514
|
+
firstPartyPermissions: effectiveFirstPartyPermissions,
|
|
515
|
+
});
|
|
566
516
|
const titleToolPlan = sessionTitleToolPlan({
|
|
517
|
+
agentConfig: session.agent,
|
|
567
518
|
tools: turnTools,
|
|
568
519
|
selectedFirstPartyMcpTools,
|
|
569
520
|
shouldRequestTitle: shouldRequestMissingSessionTitle({
|
|
521
|
+
agentConfig: session.agent,
|
|
570
522
|
title: session.title,
|
|
571
523
|
titleSource: session.titleSource,
|
|
572
524
|
firstPartyMcpTools: selectedFirstPartyMcpTools,
|
|
573
525
|
firstPartyMcpPermissions: effectiveFirstPartyPermissions,
|
|
574
526
|
}),
|
|
575
527
|
parallelGenerationAvailable: typeof runtime.generateSessionTitle === "function",
|
|
528
|
+
routeAllowsTitleRequests: routeAllowsSessionTitleRequests(resolvedModel),
|
|
576
529
|
});
|
|
577
530
|
const googleDrivePublicationAllowed =
|
|
578
531
|
selectedFirstPartyMcpTools.includes("editable_artifact_export") &&
|
|
@@ -618,9 +571,20 @@ export async function prepareTurnToolRuntime(deps: PrepareTurnToolRuntimeDeps) {
|
|
|
618
571
|
outcome,
|
|
619
572
|
}),
|
|
620
573
|
};
|
|
621
|
-
|
|
574
|
+
// Independent scoped reads after the native-link authority check. Both
|
|
575
|
+
// finish before assembling the Skill index or preparing executable tools.
|
|
576
|
+
const [skillConfiguration, sharedSkillDescriptors] = await Promise.all([
|
|
577
|
+
getWorkspaceVideoGenerationPolicy(db, input.workspaceId),
|
|
578
|
+
listSkillDescriptors(db, {
|
|
579
|
+
accountId: input.accountId,
|
|
580
|
+
workspaceId: input.workspaceId,
|
|
581
|
+
...(deps.fileAuthoritySubjectId ? { subjectId: deps.fileAuthoritySubjectId } : {}),
|
|
582
|
+
}),
|
|
583
|
+
]);
|
|
622
584
|
const bundledSkills = loadConfiguredBundledSkills({
|
|
623
|
-
|
|
585
|
+
// Rows that could not freeze the "none" default at create (scheduled
|
|
586
|
+
// generated sessions, pre-existing rows) get the same rule here.
|
|
587
|
+
bundledSkillIds: bundledSkillSelectionForAgentConfig(session.bundledSkillIds, session.agent),
|
|
624
588
|
firstPartyTools: selectedFirstPartyMcpTools,
|
|
625
589
|
videoGenerationEnabled:
|
|
626
590
|
skillConfiguration.defaultModelId !== null && skillConfiguration.enabledModelIds.length > 0,
|
|
@@ -632,25 +596,24 @@ export async function prepareTurnToolRuntime(deps: PrepareTurnToolRuntimeDeps) {
|
|
|
632
596
|
artifact: skill,
|
|
633
597
|
})),
|
|
634
598
|
];
|
|
635
|
-
const
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
];
|
|
599
|
+
const skillCatalog =
|
|
600
|
+
toolFamilies.skills === false
|
|
601
|
+
? []
|
|
602
|
+
: [
|
|
603
|
+
...withoutSessionShadowedSkills(
|
|
604
|
+
sharedSkillDescriptors.filter((entry) => entry.activationMode === "workspace_managed"),
|
|
605
|
+
sessionShadowedSkillNames(selectedSkills),
|
|
606
|
+
).map((entry) => ({
|
|
607
|
+
id: entry.id,
|
|
608
|
+
name: entry.title,
|
|
609
|
+
description: entry.description,
|
|
610
|
+
})),
|
|
611
|
+
...selectedSkills.map((entry) => ({
|
|
612
|
+
id: entry.id,
|
|
613
|
+
name: entry.artifact.name,
|
|
614
|
+
description: entry.artifact.description || entry.artifact.name,
|
|
615
|
+
})),
|
|
616
|
+
];
|
|
654
617
|
const skillTools = createWorkspaceSkillTools({
|
|
655
618
|
db,
|
|
656
619
|
settings: runSettings,
|
|
@@ -665,6 +628,19 @@ export async function prepareTurnToolRuntime(deps: PrepareTurnToolRuntimeDeps) {
|
|
|
665
628
|
executionGeneration: attempt.executionGeneration,
|
|
666
629
|
},
|
|
667
630
|
selected: selectedSkills,
|
|
631
|
+
modelToolOutputTruncationTokens: () =>
|
|
632
|
+
eventing.modelRunSettings.modelToolOutputTruncationTokens,
|
|
633
|
+
onSkillReadHistoryLookupFailed: () =>
|
|
634
|
+
observability.warn("skill_read history lookup failed; returning the full Skill text", {
|
|
635
|
+
errorCode: "skill_read_history_lookup_failed",
|
|
636
|
+
origin: "worker",
|
|
637
|
+
}),
|
|
638
|
+
skillReadTelemetry: {
|
|
639
|
+
// Set once agent build freezes this turn's model-visible Skill index.
|
|
640
|
+
indexedSkillIds: () => eventing.modelVisibleSkillIds,
|
|
641
|
+
observe: (observation) => recordSkillRead(observability, observation),
|
|
642
|
+
},
|
|
643
|
+
observeSkillCheckout: (observation) => recordSkillCheckout(observability, observation),
|
|
668
644
|
filesystem: async () => {
|
|
669
645
|
throwIfWorkerShuttingDown();
|
|
670
646
|
throwIfTurnCancelled();
|
|
@@ -677,6 +653,14 @@ export async function prepareTurnToolRuntime(deps: PrepareTurnToolRuntimeDeps) {
|
|
|
677
653
|
const runAs = sandboxRunAs(runSettings);
|
|
678
654
|
const channel = new SandboxChannelAService({
|
|
679
655
|
session: access.session,
|
|
656
|
+
commandRunner: async (commandSession, args) => {
|
|
657
|
+
const fence = eventing.toolCancellationFenceRef.current;
|
|
658
|
+
if (!fence)
|
|
659
|
+
throw new Error(
|
|
660
|
+
"Skill filesystem execution requires the active turn cancellation controller.",
|
|
661
|
+
);
|
|
662
|
+
return await fence.runSandboxCommandSynchronous(commandSession, args);
|
|
663
|
+
},
|
|
680
664
|
workspaceRoot: machineRoot ?? "/workspace",
|
|
681
665
|
...(machineRoot ? { providerPathMode: "workspace-relative" as const } : {}),
|
|
682
666
|
leaseEpoch: access.leaseEpoch,
|
|
@@ -762,6 +746,80 @@ export async function prepareTurnToolRuntime(deps: PrepareTurnToolRuntimeDeps) {
|
|
|
762
746
|
return ((await prepared.ready) ?? prepared).attemptToolEnvironment;
|
|
763
747
|
},
|
|
764
748
|
});
|
|
749
|
+
const codeSearchTools = codeSearchToolDefinitions({
|
|
750
|
+
enabled: codeSearchEnabled,
|
|
751
|
+
settings: runSettings,
|
|
752
|
+
backend: activeSandboxBackend ?? groupBoxBackend,
|
|
753
|
+
machineWorkspaceRoot: sandboxState.machinePrimarySession?.workspaceRoot ?? null,
|
|
754
|
+
observability,
|
|
755
|
+
// Opengeni's Jev key pays for these calls whatever model billing the
|
|
756
|
+
// workspace uses; record them per workspace so the cost stays visible.
|
|
757
|
+
recordUsage: async (usage) => {
|
|
758
|
+
const shared = {
|
|
759
|
+
accountId: input.accountId,
|
|
760
|
+
workspaceId: input.workspaceId,
|
|
761
|
+
sourceResourceType: "code_search",
|
|
762
|
+
sourceResourceId: usage.operationId,
|
|
763
|
+
sessionId: input.sessionId,
|
|
764
|
+
turnId: turn.id,
|
|
765
|
+
turnAttemptId: input.attemptId,
|
|
766
|
+
};
|
|
767
|
+
await recordUsageEvent(db, {
|
|
768
|
+
...shared,
|
|
769
|
+
eventType: "code_search.jev_input_tokens",
|
|
770
|
+
quantity: usage.jevInputTokens,
|
|
771
|
+
unit: "tokens",
|
|
772
|
+
idempotencyKey: `usage:code_search.jev_input_tokens:${input.attemptId}:${usage.operationId}`,
|
|
773
|
+
});
|
|
774
|
+
await recordUsageEvent(db, {
|
|
775
|
+
...shared,
|
|
776
|
+
eventType: "code_search.jev_cost",
|
|
777
|
+
quantity: Math.round(usage.jevCostUsd * 1_000_000),
|
|
778
|
+
unit: "usd_micros",
|
|
779
|
+
idempotencyKey: `usage:code_search.jev_cost:${input.attemptId}:${usage.operationId}`,
|
|
780
|
+
});
|
|
781
|
+
},
|
|
782
|
+
workspace: async () => {
|
|
783
|
+
throwIfWorkerShuttingDown();
|
|
784
|
+
throwIfTurnCancelled();
|
|
785
|
+
const access = await resolveTurnSandboxAccess(
|
|
786
|
+
sandboxState,
|
|
787
|
+
media.sdkOwnedSandboxSession,
|
|
788
|
+
"code_search requires a sandbox or Connected Machine.",
|
|
789
|
+
);
|
|
790
|
+
const machineRoot = sandboxState.machinePrimarySession?.workspaceRoot;
|
|
791
|
+
const runAs = sandboxRunAs(runSettings);
|
|
792
|
+
return codeSearchWorkspaceFromChannel(
|
|
793
|
+
new SandboxChannelAService({
|
|
794
|
+
session: access.session,
|
|
795
|
+
workspaceRoot: machineRoot ?? "/workspace",
|
|
796
|
+
...(machineRoot ? { providerPathMode: "workspace-relative" as const } : {}),
|
|
797
|
+
leaseEpoch: access.leaseEpoch,
|
|
798
|
+
...(runAs ? { runAs } : {}),
|
|
799
|
+
}),
|
|
800
|
+
);
|
|
801
|
+
},
|
|
802
|
+
});
|
|
803
|
+
const attemptToolFamilies = resolveAgentToolFamilies(session.agent, {
|
|
804
|
+
hasSkills: skillCatalog.length > 0,
|
|
805
|
+
});
|
|
806
|
+
// Provider web search: only where the turn has no hosted search (or the
|
|
807
|
+
// operator chose `replace`), only when a provider is configured, and only
|
|
808
|
+
// when the session's agent configuration allows web search (filtered below).
|
|
809
|
+
const webSearchTools = webSearchToolDefinitions({
|
|
810
|
+
settings: runSettings,
|
|
811
|
+
tools: turnWebSearchPlan(resolvedModel, runSettings, workspaceCreditModelsAllowed)
|
|
812
|
+
.providerTools,
|
|
813
|
+
scope: {
|
|
814
|
+
accountId: input.accountId,
|
|
815
|
+
workspaceId: input.workspaceId,
|
|
816
|
+
sessionId: input.sessionId,
|
|
817
|
+
turnId: turn.id,
|
|
818
|
+
attemptId: input.attemptId,
|
|
819
|
+
},
|
|
820
|
+
billing: createWebSearchBilling({ db, settings: runSettings }),
|
|
821
|
+
observability,
|
|
822
|
+
});
|
|
765
823
|
const attemptToolDefinitions = [
|
|
766
824
|
...(operationReadStore
|
|
767
825
|
? [
|
|
@@ -776,87 +834,32 @@ export async function prepareTurnToolRuntime(deps: PrepareTurnToolRuntimeDeps) {
|
|
|
776
834
|
: []),
|
|
777
835
|
...skillTools,
|
|
778
836
|
...sourceTools,
|
|
837
|
+
...(deps.runCredentialRenewals
|
|
838
|
+
? [
|
|
839
|
+
createRefreshCredentialsAttemptToolDefinition({
|
|
840
|
+
refresh: async () => {
|
|
841
|
+
const renewals = deps.runCredentialRenewals!;
|
|
842
|
+
const controller = renewals.runCredentialRenewal;
|
|
843
|
+
if (!controller) return "not_provisioned";
|
|
844
|
+
renewals.runCredentialRenewalOutcome = null;
|
|
845
|
+
await controller.refreshNow();
|
|
846
|
+
return renewals.runCredentialRenewalOutcome ?? "completed";
|
|
847
|
+
},
|
|
848
|
+
}),
|
|
849
|
+
]
|
|
850
|
+
: []),
|
|
779
851
|
createListModelsAttemptToolDefinition({
|
|
780
852
|
currentModelId: turnExecutionPolicy.productModelId,
|
|
781
853
|
load: async () => {
|
|
782
854
|
const currentCatalog = await resolveCatalogSettings(db, catalogSourceSettings);
|
|
783
855
|
const currentSettings = currentCatalog.settings;
|
|
784
|
-
const
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
xaiSubscriptionActive,
|
|
790
|
-
workspaceGatewayConnectionActive,
|
|
791
|
-
workspaceGatewayCustomModels,
|
|
792
|
-
openRouterConnectionActive,
|
|
793
|
-
workspaceOpenRouterCustomModels,
|
|
794
|
-
organizationGatewayConnectionActive,
|
|
795
|
-
organizationGatewayCustomModels,
|
|
796
|
-
organizationOpenRouterConnectionActive,
|
|
797
|
-
organizationOpenRouterCustomModels,
|
|
798
|
-
] = await Promise.all([
|
|
799
|
-
getWorkspaceConnectionModelRestrictions(
|
|
800
|
-
db,
|
|
801
|
-
input.workspaceId,
|
|
802
|
-
xaiReadinessAuthority?.subjectId ?? credentialSubjectId ?? "worker:model-access",
|
|
803
|
-
xaiReadinessAuthority?.authoritySnapshot,
|
|
804
|
-
),
|
|
805
|
-
getWorkspaceModelPolicy(db, input.workspaceId),
|
|
806
|
-
workspaceCodexSubscriptionActive(db, currentSettings, input.workspaceId),
|
|
807
|
-
xaiReadinessAuthority && currentSettings.supergrokSubscriptionEnabled
|
|
808
|
-
? workspaceXaiSubscriptionActiveForAuthority(db, currentSettings, {
|
|
809
|
-
workspaceId: input.workspaceId,
|
|
810
|
-
...xaiReadinessAuthority,
|
|
811
|
-
})
|
|
812
|
-
: false,
|
|
813
|
-
workspaceVercelAiGatewayConnectionActive(db, input.workspaceId),
|
|
814
|
-
listWorkspaceGatewayCustomModels(db, {
|
|
815
|
-
accountId: input.accountId,
|
|
816
|
-
workspaceId: input.workspaceId,
|
|
817
|
-
}),
|
|
818
|
-
workspaceOpenRouterConnectionActive(db, input.workspaceId),
|
|
819
|
-
listWorkspaceOpenRouterCustomModels(db, {
|
|
820
|
-
accountId: input.accountId,
|
|
821
|
-
workspaceId: input.workspaceId,
|
|
822
|
-
}),
|
|
823
|
-
organizationModelProviderConnectionActiveForWorkspace(db, {
|
|
824
|
-
accountId: input.accountId,
|
|
825
|
-
workspaceId: input.workspaceId,
|
|
826
|
-
providerKind: "vercel_gateway",
|
|
827
|
-
}),
|
|
828
|
-
listOrganizationModelProviderCustomModelsForWorkspace(db, {
|
|
829
|
-
accountId: input.accountId,
|
|
830
|
-
workspaceId: input.workspaceId,
|
|
831
|
-
providerKind: "vercel_gateway",
|
|
832
|
-
}),
|
|
833
|
-
organizationModelProviderConnectionActiveForWorkspace(db, {
|
|
834
|
-
accountId: input.accountId,
|
|
835
|
-
workspaceId: input.workspaceId,
|
|
836
|
-
providerKind: "openrouter",
|
|
837
|
-
}),
|
|
838
|
-
listOrganizationModelProviderCustomModelsForWorkspace(db, {
|
|
839
|
-
accountId: input.accountId,
|
|
840
|
-
workspaceId: input.workspaceId,
|
|
841
|
-
providerKind: "openrouter",
|
|
842
|
-
}),
|
|
843
|
-
]);
|
|
856
|
+
const selectionInput = await loadWorkspaceModelSelectionInput(db, currentSettings, {
|
|
857
|
+
accountId: input.accountId,
|
|
858
|
+
workspaceId: input.workspaceId,
|
|
859
|
+
subjectId: turn.initiatingHumanSubjectId ?? credentialSubjectId ?? "worker:model-access",
|
|
860
|
+
});
|
|
844
861
|
return {
|
|
845
|
-
selections: resolveWorkspaceModelSelection(
|
|
846
|
-
connectionModelRestrictions,
|
|
847
|
-
settings: currentSettings,
|
|
848
|
-
policy,
|
|
849
|
-
codexSubscriptionActive,
|
|
850
|
-
xaiSubscriptionActive,
|
|
851
|
-
workspaceGatewayConnectionActive,
|
|
852
|
-
workspaceGatewayCustomModels,
|
|
853
|
-
workspaceOpenRouterConnectionActive: openRouterConnectionActive,
|
|
854
|
-
workspaceOpenRouterCustomModels,
|
|
855
|
-
organizationGatewayConnectionActive,
|
|
856
|
-
organizationGatewayCustomModels,
|
|
857
|
-
organizationOpenRouterConnectionActive,
|
|
858
|
-
organizationOpenRouterCustomModels,
|
|
859
|
-
}),
|
|
862
|
+
selections: resolveWorkspaceModelSelection(selectionInput),
|
|
860
863
|
modelNotes: currentCatalog.modelNotes,
|
|
861
864
|
};
|
|
862
865
|
},
|
|
@@ -884,6 +887,7 @@ export async function prepareTurnToolRuntime(deps: PrepareTurnToolRuntimeDeps) {
|
|
|
884
887
|
: []),
|
|
885
888
|
...createFirstPartyInteractionAttemptToolDefinitions({
|
|
886
889
|
settings: runSettings,
|
|
890
|
+
...(credentialRestriction ? { credentialRestriction } : {}),
|
|
887
891
|
scope: {
|
|
888
892
|
accountId: input.accountId,
|
|
889
893
|
workspaceId: input.workspaceId,
|
|
@@ -895,7 +899,7 @@ export async function prepareTurnToolRuntime(deps: PrepareTurnToolRuntimeDeps) {
|
|
|
895
899
|
...(effectiveFirstPartyPermissions ? { permissions: effectiveFirstPartyPermissions } : {}),
|
|
896
900
|
selectedTools: selectedFirstPartyMcpTools,
|
|
897
901
|
subjectId: "worker:first-party-mcp",
|
|
898
|
-
subjectLabel: "
|
|
902
|
+
subjectLabel: "Opengeni worker",
|
|
899
903
|
...(interactionInterventionResume
|
|
900
904
|
? { interventionResume: interactionInterventionResume }
|
|
901
905
|
: {}),
|
|
@@ -903,7 +907,9 @@ export async function prepareTurnToolRuntime(deps: PrepareTurnToolRuntimeDeps) {
|
|
|
903
907
|
...(googleDrivePublicationTool && googleDrivePublicationAllowed
|
|
904
908
|
? [googleDrivePublicationTool]
|
|
905
909
|
: []),
|
|
906
|
-
|
|
910
|
+
...codeSearchTools,
|
|
911
|
+
...webSearchTools,
|
|
912
|
+
].filter((tool) => attemptToolFamilies.allowsFunctionTool(tool.modelName));
|
|
907
913
|
recordTurnStartupPhase(observability, {
|
|
908
914
|
phase: "tool_context_preparation",
|
|
909
915
|
provider: turnExecutionPolicy.providerId,
|
|
@@ -942,10 +948,12 @@ export async function prepareTurnToolRuntime(deps: PrepareTurnToolRuntimeDeps) {
|
|
|
942
948
|
"Connector attachment sandbox is unavailable",
|
|
943
949
|
);
|
|
944
950
|
const sandbox = sandboxAccess.sandbox;
|
|
951
|
+
const machineRoot = sandboxState.machinePrimarySession?.workspaceRoot;
|
|
945
952
|
const runAs = sandboxRunAs(runSettings);
|
|
946
953
|
const channel = new SandboxChannelAService({
|
|
947
954
|
session: sandboxAccess.session,
|
|
948
|
-
workspaceRoot: "/workspace",
|
|
955
|
+
workspaceRoot: machineRoot ?? "/workspace",
|
|
956
|
+
...(machineRoot ? { providerPathMode: "workspace-relative" as const } : {}),
|
|
949
957
|
leaseEpoch: sandboxAccess.leaseEpoch,
|
|
950
958
|
emit: async (events) => {
|
|
951
959
|
await eventing.publish?.(events, true);
|
|
@@ -965,9 +973,38 @@ export async function prepareTurnToolRuntime(deps: PrepareTurnToolRuntimeDeps) {
|
|
|
965
973
|
},
|
|
966
974
|
});
|
|
967
975
|
};
|
|
976
|
+
const connectorFileStaging = () => {
|
|
977
|
+
if (!deps.objectStorage) throw new Error("Connector file delivery requires object storage");
|
|
978
|
+
return {
|
|
979
|
+
workspaceId: input.workspaceId,
|
|
980
|
+
storage: deps.objectStorage,
|
|
981
|
+
downloadStorage: objectStorageForSandboxDownloads(
|
|
982
|
+
runSettings,
|
|
983
|
+
deps.objectStorage,
|
|
984
|
+
deps.activeSandboxBackend ?? deps.groupBoxBackend,
|
|
985
|
+
),
|
|
986
|
+
materialize: materializeConnectorAttachments,
|
|
987
|
+
onCleanupFailure: (key: string) =>
|
|
988
|
+
console.warn("[connector-files] Temporary transfer cleanup requires operator retry", {
|
|
989
|
+
objectKey: key,
|
|
990
|
+
}),
|
|
991
|
+
};
|
|
992
|
+
};
|
|
993
|
+
const initiatingHuman = await waitForTurnOperation(
|
|
994
|
+
resolveInitiatingHuman(
|
|
995
|
+
db,
|
|
996
|
+
deps.connectionScope,
|
|
997
|
+
turn.initiatingHumanSubjectId ?? null,
|
|
998
|
+
turn.id,
|
|
999
|
+
),
|
|
1000
|
+
cancellationSignal,
|
|
1001
|
+
undefined,
|
|
1002
|
+
);
|
|
968
1003
|
try {
|
|
969
1004
|
eventing.preparedTools = await waitForTurnOperation(
|
|
970
1005
|
runtime.prepareTools(githubRestMcp.settings, githubRestMcp.tools, {
|
|
1006
|
+
...(credentialRestriction ? { credentialRestriction } : {}),
|
|
1007
|
+
inputWaitReplyGuard: async () => (await eventing.inputWaitReplyGuard?.()) ?? null,
|
|
971
1008
|
mcpAccountLabels: accountRoutes.accountLabels,
|
|
972
1009
|
accountId: input.accountId,
|
|
973
1010
|
workspaceId: input.workspaceId,
|
|
@@ -979,10 +1016,32 @@ export async function prepareTurnToolRuntime(deps: PrepareTurnToolRuntimeDeps) {
|
|
|
979
1016
|
attemptId: input.attemptId,
|
|
980
1017
|
executionGeneration: attempt.executionGeneration,
|
|
981
1018
|
subjectId: "worker:first-party-mcp",
|
|
982
|
-
|
|
1019
|
+
secretResolver: attemptSecretResolver({
|
|
1020
|
+
db,
|
|
1021
|
+
settings: githubRestMcp.settings,
|
|
1022
|
+
agentConfig: session.agent,
|
|
1023
|
+
vaultAccess: deps.vaultAccess,
|
|
1024
|
+
accountId: input.accountId,
|
|
1025
|
+
workspaceId: input.workspaceId,
|
|
1026
|
+
sessionId: input.sessionId,
|
|
1027
|
+
turnId: turn.id,
|
|
1028
|
+
attemptId: input.attemptId,
|
|
1029
|
+
executionGeneration: attempt.executionGeneration,
|
|
1030
|
+
}),
|
|
1031
|
+
subjectLabel: "Opengeni worker",
|
|
983
1032
|
...(credentialSubjectId ? { credentialSubjectId } : {}),
|
|
1033
|
+
initiatingHumanSubjectId: turn.initiatingHumanSubjectId ?? null,
|
|
1034
|
+
initiatingHumanExternalIdentity: initiatingHuman?.externalIdentity ?? null,
|
|
1035
|
+
sessionAttachedRemoteMcpTargets: selectedSessionRemoteMcpTargets(
|
|
1036
|
+
githubRestMcp.settings,
|
|
1037
|
+
session.mcpServers ?? [],
|
|
1038
|
+
githubRestMcp.tools,
|
|
1039
|
+
localMcpServers,
|
|
1040
|
+
),
|
|
1041
|
+
...(deps.runMcpCredentials ? { runMcpCredentials: deps.runMcpCredentials } : {}),
|
|
984
1042
|
...(codexAppsAuth ? { codexAppsAuth } : {}),
|
|
985
1043
|
resolveCredential,
|
|
1044
|
+
slackRateLimit: buildSlackApiRateLimiter(db, githubRestMcp.settings),
|
|
986
1045
|
...(operationPersistence ? { mcpOperationPersistence: operationPersistence } : {}),
|
|
987
1046
|
...(linkedAuthority
|
|
988
1047
|
? {
|
|
@@ -1004,6 +1063,35 @@ export async function prepareTurnToolRuntime(deps: PrepareTurnToolRuntimeDeps) {
|
|
|
1004
1063
|
: {}),
|
|
1005
1064
|
onAuthNeeded: publishToolAuthNeeded,
|
|
1006
1065
|
materializeConnectorAttachments,
|
|
1066
|
+
materializeGmailFile: async (request) => {
|
|
1067
|
+
throwIfWorkerShuttingDown();
|
|
1068
|
+
throwIfTurnCancelled();
|
|
1069
|
+
return await materializeGmailFile(request, connectorFileStaging());
|
|
1070
|
+
},
|
|
1071
|
+
materializeConnectorFile: async (request) => {
|
|
1072
|
+
throwIfWorkerShuttingDown();
|
|
1073
|
+
throwIfTurnCancelled();
|
|
1074
|
+
return await materializeConnectorFile(request, connectorFileStaging());
|
|
1075
|
+
},
|
|
1076
|
+
readGmailFile: async (request) => {
|
|
1077
|
+
throwIfWorkerShuttingDown();
|
|
1078
|
+
throwIfTurnCancelled();
|
|
1079
|
+
const access = await resolveTurnSandboxAccess(
|
|
1080
|
+
sandboxState,
|
|
1081
|
+
media.sdkOwnedSandboxSession,
|
|
1082
|
+
"Gmail attachment filesystem is unavailable",
|
|
1083
|
+
);
|
|
1084
|
+
const runAs = sandboxRunAs(runSettings);
|
|
1085
|
+
const machineRoot = sandboxState.machinePrimarySession?.workspaceRoot;
|
|
1086
|
+
const channel = new SandboxChannelAService({
|
|
1087
|
+
session: access.session,
|
|
1088
|
+
workspaceRoot: machineRoot ?? "/workspace",
|
|
1089
|
+
...(machineRoot ? { providerPathMode: "workspace-relative" as const } : {}),
|
|
1090
|
+
leaseEpoch: access.leaseEpoch,
|
|
1091
|
+
...(runAs ? { runAs } : {}),
|
|
1092
|
+
});
|
|
1093
|
+
return await readGmailFileFromChannel(channel, request);
|
|
1094
|
+
},
|
|
1007
1095
|
refreshOwnedCommand: async (commandId) => {
|
|
1008
1096
|
throwIfWorkerShuttingDown();
|
|
1009
1097
|
throwIfTurnCancelled();
|
|
@@ -1099,6 +1187,8 @@ export async function prepareTurnToolRuntime(deps: PrepareTurnToolRuntimeDeps) {
|
|
|
1099
1187
|
undefined,
|
|
1100
1188
|
{},
|
|
1101
1189
|
(name) => mcpToolDisplayMetadata(tools.mcpServers, name),
|
|
1190
|
+
(entry) => toolFamilyForCatalogIdentity(entry, runSettings.mcpServers),
|
|
1191
|
+
tools.inputWaitYield,
|
|
1102
1192
|
);
|
|
1103
1193
|
eventing.codemodeDispatcher.start();
|
|
1104
1194
|
};
|
|
@@ -1124,6 +1214,8 @@ export async function prepareTurnToolRuntime(deps: PrepareTurnToolRuntimeDeps) {
|
|
|
1124
1214
|
...titleToolPlan.preparationIndependentToolNames,
|
|
1125
1215
|
"skill_read",
|
|
1126
1216
|
],
|
|
1217
|
+
codeSearchAvailable: codeSearchTools.length > 0,
|
|
1218
|
+
promptToolAvailability,
|
|
1127
1219
|
skillCatalog,
|
|
1128
1220
|
};
|
|
1129
1221
|
}
|