@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
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import { getScheduledTaskClaudeProviderAccountAuthoritySnapshot } from "@opengeni/db";
|
|
2
|
+
import {
|
|
3
|
+
ATLASSIAN_NATIVE_RETIRED_REASON,
|
|
4
|
+
isRetiredNativeAtlassianTask,
|
|
5
|
+
} from "@opengeni/contracts/atlassian-native-retirement";
|
|
6
|
+
import { GOOGLE_DRIVE_PUBLICATION_SERVER_ID } from "@opengeni/contracts/google-drive";
|
|
7
|
+
import { PERSONAL_GITHUB_CONNECTION_SURFACE_ID } from "@opengeni/contracts/personal-github";
|
|
1
8
|
import {
|
|
2
9
|
AUTOMATIC_SESSION_TITLE_FALLBACK,
|
|
3
10
|
DEFAULT_FIRST_PARTY_MCP_PERMISSIONS,
|
|
@@ -10,16 +17,24 @@ import {
|
|
|
10
17
|
SessionAgentAccess,
|
|
11
18
|
SessionMemoryScope,
|
|
12
19
|
normalizeAutomaticSessionTitle,
|
|
20
|
+
metadataWithTurnExecutionPolicyV1,
|
|
21
|
+
mergeResourceRefs,
|
|
22
|
+
resolveWorkspaceSessionToolDefaults,
|
|
13
23
|
scheduledOccurrencePayloadUtf8Bytes,
|
|
14
24
|
stableJson,
|
|
15
25
|
TurnExecutionPolicyV1,
|
|
26
|
+
type McpConnectionAccountSelection,
|
|
16
27
|
type ScheduledTask,
|
|
28
|
+
type ScheduledTaskDegradedAccount,
|
|
17
29
|
type ScheduledTaskRun,
|
|
30
|
+
type ResolvedAgentConfig,
|
|
18
31
|
} from "@opengeni/contracts";
|
|
19
32
|
import {
|
|
20
33
|
openGeniSlackBotMetadata,
|
|
21
34
|
requireOpenGeniSlackBotConnection,
|
|
35
|
+
withScheduledSlackBotPostingTools,
|
|
22
36
|
resolveWorkspaceCatalogSettings,
|
|
37
|
+
resolveScheduledTaskDefaultModel,
|
|
23
38
|
resolveSessionToolPolicy,
|
|
24
39
|
workspaceCustomModelReference,
|
|
25
40
|
lockActiveCustomModelForAdmission,
|
|
@@ -28,15 +43,25 @@ import {
|
|
|
28
43
|
ConnectionAccountSelectionError,
|
|
29
44
|
scheduledConnectionSurfaceEligibility,
|
|
30
45
|
scheduledConnectionTools,
|
|
46
|
+
scheduledTaskRunTools,
|
|
31
47
|
settingsWithEnabledCapabilityMcpServers,
|
|
32
48
|
settingsWithSessionMcpServerMetadata,
|
|
33
49
|
swapActiveSandbox,
|
|
50
|
+
applySessionAgentConfigWriteThrough,
|
|
51
|
+
resolveSessionAgentConfigForCreate,
|
|
52
|
+
recordSessionCreated,
|
|
53
|
+
recordUserMessageAccepted,
|
|
54
|
+
type ProductUsageMetricsSink,
|
|
34
55
|
} from "@opengeni/core";
|
|
35
56
|
import {
|
|
36
57
|
appendSessionEvents,
|
|
37
58
|
addSessionSystemUpdateWithSourceMutation,
|
|
38
59
|
bindScheduledTaskRunSessionInTransaction,
|
|
60
|
+
checkSessionUsageLimitAdmission,
|
|
39
61
|
createScheduledTaskRun,
|
|
62
|
+
recordScheduledTaskAdmissionFailure,
|
|
63
|
+
recordScheduledTaskAdmissionRefusal,
|
|
64
|
+
type ScheduledTaskAdmissionRefusalReason,
|
|
40
65
|
createSession,
|
|
41
66
|
createSessionWithIdempotencyKeyResult,
|
|
42
67
|
enqueueSessionWorkflowWakeIfRunnable,
|
|
@@ -49,14 +74,19 @@ import {
|
|
|
49
74
|
getScheduledTaskRunPersonalResourceAuthority,
|
|
50
75
|
getScheduledTaskPersonalResourceAuthoritySubject,
|
|
51
76
|
getScheduledTaskRevisionAuthority,
|
|
77
|
+
getScheduledTaskSubscriptionAuthority,
|
|
52
78
|
getScheduledTaskXaiProviderAccountAuthoritySnapshot,
|
|
53
79
|
getEnrollment,
|
|
54
80
|
getSandbox,
|
|
81
|
+
getSessionAuthorityEpoch,
|
|
82
|
+
issueSelfUserResourceGrant,
|
|
83
|
+
listSelfUserResourceAuthorities,
|
|
55
84
|
getRig,
|
|
56
85
|
getScheduledScopedRigVersionMetadata,
|
|
57
86
|
getNestedAgentDepthDeploymentPolicy,
|
|
58
87
|
getSessionByCreateIdempotencyKey,
|
|
59
88
|
getSessionCreationExecutionPolicy,
|
|
89
|
+
metadataWithAgentConfigCreateIdentity,
|
|
60
90
|
getVariableSet,
|
|
61
91
|
isCodexBilledModel,
|
|
62
92
|
initializeSessionStartAtomically,
|
|
@@ -73,12 +103,15 @@ import {
|
|
|
73
103
|
updateSessionTitleWithEvent,
|
|
74
104
|
upsertScheduledSessionGoalForRun,
|
|
75
105
|
withSessionActivityRlsContext,
|
|
106
|
+
withWorkspaceSubjectRls,
|
|
76
107
|
} from "@opengeni/db";
|
|
77
108
|
import { publishDurableSessionEvents } from "@opengeni/events";
|
|
78
109
|
import {
|
|
79
110
|
allowedFirstPartyMcpToolsForSession,
|
|
111
|
+
resolveSessionFirstPartyMcpTools,
|
|
80
112
|
resolveFirstPartyMcpToolPolicy,
|
|
81
113
|
resolveTurnExecutionPolicyV1,
|
|
114
|
+
TurnExecutionPolicyModelUnavailableError,
|
|
82
115
|
} from "@opengeni/config";
|
|
83
116
|
import { Context } from "@temporalio/activity";
|
|
84
117
|
import { createHash } from "node:crypto";
|
|
@@ -115,6 +148,30 @@ type ScheduledTemporalActivityIdentity = {
|
|
|
115
148
|
activityId: string;
|
|
116
149
|
};
|
|
117
150
|
|
|
151
|
+
export function scheduledTaskRunExecutionPolicy(
|
|
152
|
+
policy: TurnExecutionPolicyV1,
|
|
153
|
+
input: DispatchScheduledTaskRunInput,
|
|
154
|
+
creatorRestriction?: "developer_setup",
|
|
155
|
+
): TurnExecutionPolicyV1 {
|
|
156
|
+
return creatorRestriction === "developer_setup" ||
|
|
157
|
+
(input.triggerType !== "scheduled" && input.credentialRestriction === "developer_setup")
|
|
158
|
+
? { ...policy, credentialRestriction: "developer_setup" }
|
|
159
|
+
: policy;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** Only a creator ceiling is standing; a manual caller ceiling is per-run. */
|
|
163
|
+
export function scheduledSessionExecutionPolicyMetadata(
|
|
164
|
+
policy: unknown,
|
|
165
|
+
creatorRestriction?: "developer_setup",
|
|
166
|
+
): Record<string, unknown> {
|
|
167
|
+
if (policy === undefined || policy === null) return {};
|
|
168
|
+
const acceptedPolicy = TurnExecutionPolicyV1.parse(policy);
|
|
169
|
+
return creatorRestriction === "developer_setup" &&
|
|
170
|
+
acceptedPolicy.credentialRestriction === "developer_setup"
|
|
171
|
+
? metadataWithTurnExecutionPolicyV1({}, acceptedPolicy)
|
|
172
|
+
: {};
|
|
173
|
+
}
|
|
174
|
+
|
|
118
175
|
export function scheduledTaskRunProducerKey(
|
|
119
176
|
input: DispatchScheduledTaskRunInput,
|
|
120
177
|
suppliedActivityIdentity?: ScheduledTemporalActivityIdentity,
|
|
@@ -184,6 +241,15 @@ export function scheduledTaskGeneratedSessionCreateIdempotencyKey(producerKey: s
|
|
|
184
241
|
* alone, with no Intl call and so no host ICU or tzdata build to make the two
|
|
185
242
|
* texts differ.
|
|
186
243
|
*/
|
|
244
|
+
/** A scheduler-generated run session: a service-created root session. */
|
|
245
|
+
function recordScheduledSessionCreated(observability: ProductUsageMetricsSink | undefined): void {
|
|
246
|
+
recordSessionCreated(observability, {
|
|
247
|
+
surface: "scheduled",
|
|
248
|
+
createdByKind: "service",
|
|
249
|
+
parentSessionId: null,
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
|
|
187
253
|
export function scheduledTaskSessionTitle(taskName: string): string {
|
|
188
254
|
return normalizeAutomaticSessionTitle(taskName) ?? "Scheduled run";
|
|
189
255
|
}
|
|
@@ -283,6 +349,9 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
283
349
|
producerKey: stableProducerKey,
|
|
284
350
|
});
|
|
285
351
|
if (priorRun?.actionKind === "agent_turn") {
|
|
352
|
+
if (priorRun.admissionDiagnostic || priorRun.admissionRefusal) {
|
|
353
|
+
return scheduledAdmissionRefusalResult(priorRun);
|
|
354
|
+
}
|
|
286
355
|
const acceptedExecution = await getScheduledTaskRunAcceptedExecution(db, {
|
|
287
356
|
workspaceId: input.workspaceId,
|
|
288
357
|
runId: priorRun.id,
|
|
@@ -297,6 +366,15 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
297
366
|
}
|
|
298
367
|
throw new Error("scheduled agent run is missing accepted execution truth");
|
|
299
368
|
}
|
|
369
|
+
if (priorRun.status === "queued" && isRetiredNativeAtlassianTask(acceptedExecution.task)) {
|
|
370
|
+
await markScheduledTaskRunFailedIfQueued(
|
|
371
|
+
db,
|
|
372
|
+
priorRun.workspaceId,
|
|
373
|
+
priorRun.id,
|
|
374
|
+
ATLASSIAN_NATIVE_RETIRED_REASON,
|
|
375
|
+
);
|
|
376
|
+
return scheduledRunTerminalResult(ATLASSIAN_NATIVE_RETIRED_REASON);
|
|
377
|
+
}
|
|
300
378
|
await recordScheduledTaskFiredUsage(db, acceptedExecution, priorRun);
|
|
301
379
|
if (priorRun.status === "dispatched") {
|
|
302
380
|
return await replayScheduledTaskDispatch({
|
|
@@ -320,6 +398,7 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
320
398
|
try {
|
|
321
399
|
return await recoverBoundScheduledTaskDispatch({
|
|
322
400
|
db,
|
|
401
|
+
observability: baseService.observability,
|
|
323
402
|
bus,
|
|
324
403
|
settings,
|
|
325
404
|
wakeSessionWorkflow,
|
|
@@ -364,6 +443,8 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
364
443
|
if (!task) {
|
|
365
444
|
return { action: "deleted" };
|
|
366
445
|
}
|
|
446
|
+
if (isRetiredNativeAtlassianTask(task))
|
|
447
|
+
return { action: "blocked", reason: ATLASSIAN_NATIVE_RETIRED_REASON };
|
|
367
448
|
if (task.action.kind !== "agent_turn") {
|
|
368
449
|
return { action: "blocked", reason: "legacy_source_schedule_requires_migration" };
|
|
369
450
|
}
|
|
@@ -408,6 +489,38 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
408
489
|
taskAuthorityRevision: task.authorityRevision,
|
|
409
490
|
});
|
|
410
491
|
const taskAuthoritySubjectId = task.ownerSubjectId;
|
|
492
|
+
// Every pre-admission refusal below is recorded as a visible run receipt
|
|
493
|
+
// under this producer identity instead of throwing (a thrown activity is
|
|
494
|
+
// retried to exhaustion and leaves no run) or returning a bare blocked
|
|
495
|
+
// result (the occurrence silently disappears). Terminal refusals are
|
|
496
|
+
// deterministic for this task revision and digest; transient ones
|
|
497
|
+
// (`retryable`) are skipped and a later occurrence is admitted normally.
|
|
498
|
+
// Redelivery replays the same receipt, so no occurrence gets two runs.
|
|
499
|
+
const refuseAdmission = async (
|
|
500
|
+
reason: ScheduledTaskAdmissionRefusalReason,
|
|
501
|
+
retryable: boolean,
|
|
502
|
+
detail: string,
|
|
503
|
+
): Promise<DispatchScheduledTaskRunResult> => {
|
|
504
|
+
console.warn(
|
|
505
|
+
`[scheduled-task] refused occurrence of ${task.id} (revision ${task.authorityRevision}): ${reason}: ${detail}`,
|
|
506
|
+
);
|
|
507
|
+
const receipt = await recordScheduledTaskAdmissionRefusal(db, {
|
|
508
|
+
workspaceId: task.workspaceId,
|
|
509
|
+
taskId: task.id,
|
|
510
|
+
taskAuthorityRevision: task.authorityRevision,
|
|
511
|
+
taskExecutionDigest: task.executionDigest,
|
|
512
|
+
triggerType: input.triggerType,
|
|
513
|
+
producerKey: stableProducerKey,
|
|
514
|
+
reason,
|
|
515
|
+
retryable,
|
|
516
|
+
});
|
|
517
|
+
if (!receipt.admissionRefusal) {
|
|
518
|
+
// A concurrent delivery accepted this producer first. Follow the
|
|
519
|
+
// existing exact-receipt recovery path, never replace its outcome.
|
|
520
|
+
return createScheduledTaskActivities(services).dispatchScheduledTaskRun(input);
|
|
521
|
+
}
|
|
522
|
+
return scheduledAdmissionRefusalResult(receipt);
|
|
523
|
+
};
|
|
411
524
|
if (
|
|
412
525
|
task.action.kind === "agent_turn" &&
|
|
413
526
|
((taskRevisionAuthority?.subjectId ?? null) !== taskAuthoritySubjectId ||
|
|
@@ -415,7 +528,11 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
415
528
|
(subject) => subject !== null && subject !== taskAuthoritySubjectId,
|
|
416
529
|
))
|
|
417
530
|
) {
|
|
418
|
-
|
|
531
|
+
return await refuseAdmission(
|
|
532
|
+
"scheduled_authority_unavailable",
|
|
533
|
+
false,
|
|
534
|
+
"scheduled authority differs from its immutable execution owner",
|
|
535
|
+
);
|
|
419
536
|
}
|
|
420
537
|
const acceptedTargetSessionId =
|
|
421
538
|
task.runMode === "existing_session"
|
|
@@ -438,20 +555,100 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
438
555
|
)
|
|
439
556
|
: null;
|
|
440
557
|
const settings = await settingsForTask(task, targetSessionExecutionBase?.model);
|
|
441
|
-
|
|
442
|
-
|
|
558
|
+
// A task that names no model resolves the new-chat default at each fresh
|
|
559
|
+
// occurrence (saved workspace default, then a usable connected
|
|
560
|
+
// subscription under the task's frozen SuperGrok authority, then the
|
|
561
|
+
// credits default while the organization holds a credit balance, then the
|
|
562
|
+
// deployment default). A frozen SuperGrok pool that is gone only means
|
|
563
|
+
// SuperGrok is not ready. The accepted execution freezes the result, so
|
|
564
|
+
// retries and recovery never resolve again. Existing-session runs keep
|
|
565
|
+
// that session's model.
|
|
566
|
+
const resolvedDefault =
|
|
567
|
+
task.agentConfig.model || targetSessionExecutionBase
|
|
568
|
+
? null
|
|
569
|
+
: await resolveScheduledTaskDefaultModel(db, settings, task);
|
|
570
|
+
const model = task.agentConfig.model ?? resolvedDefault?.model ?? settings.openaiModel;
|
|
571
|
+
const reasoningEffort =
|
|
572
|
+
task.agentConfig.reasoningEffort ??
|
|
573
|
+
resolvedDefault?.reasoningEffort ??
|
|
574
|
+
settings.openaiReasoningEffort;
|
|
443
575
|
let sandboxBackend = task.agentConfig.sandboxBackend ?? settings.sandboxBackend;
|
|
444
576
|
let sandboxOs: "linux" | "macos" | "windows" = "linux";
|
|
445
|
-
|
|
577
|
+
// A schedule that follows the workspace defaults gets them as they are
|
|
578
|
+
// now, from the owner's registry; nothing about them was saved with it.
|
|
579
|
+
const runTools = task.agentConfig.toolPolicy
|
|
580
|
+
? scheduledTaskRunTools({
|
|
581
|
+
agentConfig: task.agentConfig,
|
|
582
|
+
settings,
|
|
583
|
+
runtimeSettings: await settingsWithEnabledCapabilityMcpServers(
|
|
584
|
+
db,
|
|
585
|
+
task.workspaceId,
|
|
586
|
+
settings,
|
|
587
|
+
taskAuthoritySubjectId ? { subjectId: taskAuthoritySubjectId } : {},
|
|
588
|
+
),
|
|
589
|
+
workspaceDefaults: resolveWorkspaceSessionToolDefaults(
|
|
590
|
+
(await requireWorkspace(db, task.workspaceId)).settings,
|
|
591
|
+
),
|
|
592
|
+
})
|
|
593
|
+
: task.agentConfig.tools;
|
|
594
|
+
let taskTools = withFirstPartyTools(settings, runTools);
|
|
446
595
|
// A task created by a live agent attempt froze its creator's effective
|
|
447
596
|
// first-party selection, permission set, and session access policy;
|
|
448
597
|
// its generated sessions inherit that boundary under today's
|
|
449
598
|
// deployment ceiling. A human/API-created task (null policy) keeps the
|
|
450
599
|
// deployment default exactly as before.
|
|
451
600
|
const creatorPolicy = await getScheduledTaskCreatorPolicy(db, task.workspaceId, task.id);
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
601
|
+
// A person-chosen Slack channel adds only the two bot posting tools;
|
|
602
|
+
// they post nowhere else, whatever the creator's own selection was.
|
|
603
|
+
let firstPartyMcpTools = withScheduledSlackBotPostingTools(
|
|
604
|
+
creatorPolicy?.firstPartyMcpTools
|
|
605
|
+
? allowedFirstPartyMcpToolsForSession(settings, creatorPolicy.firstPartyMcpTools)
|
|
606
|
+
: resolveFirstPartyMcpToolPolicy(settings).default,
|
|
607
|
+
task.agentConfig,
|
|
608
|
+
resolveFirstPartyMcpToolPolicy(settings).allowed,
|
|
609
|
+
);
|
|
610
|
+
// Agent configuration for generated sessions (null = legacy). The
|
|
611
|
+
// scheduled baseline above (creator policy or deployment default) is
|
|
612
|
+
// what "all" reproduces; capabilities only narrow it. Frozen into the
|
|
613
|
+
// accepted execution so retries and recovery never resolve again.
|
|
614
|
+
let resolvedAgentConfig: ResolvedAgentConfig | null = null;
|
|
615
|
+
let resolvedAgentInstructions: string | undefined;
|
|
616
|
+
const generatedTarget =
|
|
617
|
+
task.runMode === "new_session_per_run" ||
|
|
618
|
+
(task.runMode === "reusable_session" && task.reusableSessionId === null);
|
|
619
|
+
if (generatedTarget) {
|
|
620
|
+
try {
|
|
621
|
+
const agentResolution = resolveSessionAgentConfigForCreate({
|
|
622
|
+
settings,
|
|
623
|
+
creator: "scheduled",
|
|
624
|
+
request: task.agentConfig.agent,
|
|
625
|
+
instructions: undefined,
|
|
626
|
+
workspaceSettings: (await requireWorkspace(db, task.workspaceId)).settings,
|
|
627
|
+
parent: null,
|
|
628
|
+
goal: task.agentConfig.goal !== undefined,
|
|
629
|
+
});
|
|
630
|
+
resolvedAgentConfig = agentResolution.config;
|
|
631
|
+
resolvedAgentInstructions = agentResolution.instructions;
|
|
632
|
+
const written = applySessionAgentConfigWriteThrough({
|
|
633
|
+
config: resolvedAgentConfig,
|
|
634
|
+
firstPartyMcpTools,
|
|
635
|
+
tools: taskTools,
|
|
636
|
+
toolPolicy: { mode: "explicit", inheritedFromSessionId: null },
|
|
637
|
+
productServerIds: runTools.map((tool) => tool.id),
|
|
638
|
+
});
|
|
639
|
+
firstPartyMcpTools = written.firstPartyMcpTools;
|
|
640
|
+
taskTools = written.tools;
|
|
641
|
+
} catch (error) {
|
|
642
|
+
const status =
|
|
643
|
+
error instanceof Error ? (error as Error & { status?: unknown }).status : undefined;
|
|
644
|
+
if (!(error instanceof Error) || status !== 422) throw error;
|
|
645
|
+
return await refuseAdmission(
|
|
646
|
+
"scheduled_authority_unavailable",
|
|
647
|
+
false,
|
|
648
|
+
`scheduled agent configuration is not admissible: ${error.message}`,
|
|
649
|
+
);
|
|
650
|
+
}
|
|
651
|
+
}
|
|
455
652
|
const firstPartyMcpPermissions = creatorPolicy?.firstPartyMcpPermissions
|
|
456
653
|
? [...creatorPolicy.firstPartyMcpPermissions]
|
|
457
654
|
: [...DEFAULT_FIRST_PARTY_MCP_PERMISSIONS];
|
|
@@ -467,7 +664,8 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
467
664
|
acceptedTargetSessionId && targetSessionExecutionBase
|
|
468
665
|
? await requireSession(db, task.workspaceId, acceptedTargetSessionId)
|
|
469
666
|
: null;
|
|
470
|
-
const
|
|
667
|
+
const toolWorkspaceSettings = (await requireWorkspace(db, task.workspaceId)).settings;
|
|
668
|
+
let connectionTools = await scheduledConnectionTools(
|
|
471
669
|
db,
|
|
472
670
|
task.workspaceId,
|
|
473
671
|
connectionSettings,
|
|
@@ -475,46 +673,112 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
475
673
|
taskTools,
|
|
476
674
|
taskAuthoritySubjectId ?? undefined,
|
|
477
675
|
);
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
676
|
+
// Connector accounts resolve live at each fresh occurrence: every
|
|
677
|
+
// connector uses the owner's current accounts. Only an account a person
|
|
678
|
+
// pinned on a schedule that starts its own session narrows its
|
|
679
|
+
// connector. An existing-chat schedule never pins; that chat supplies
|
|
680
|
+
// its connectors and the owner's current accounts.
|
|
681
|
+
let runPins: McpConnectionAccountSelection[] =
|
|
682
|
+
task.runMode === "existing_session" ? [] : [...(task.agentConfig.pinnedAccounts ?? [])];
|
|
683
|
+
const surfaceEligibility = scheduledConnectionSurfaceEligibility(
|
|
684
|
+
settings,
|
|
685
|
+
connectionTarget ?? {
|
|
686
|
+
firstPartyMcpTools,
|
|
687
|
+
firstPartyMcpPermissions,
|
|
688
|
+
},
|
|
689
|
+
toolWorkspaceSettings,
|
|
690
|
+
);
|
|
691
|
+
const resolveTaskConnections = () =>
|
|
692
|
+
freezeConnectionAccounts({
|
|
693
|
+
db,
|
|
694
|
+
accountId: task.accountId,
|
|
695
|
+
workspaceId: task.workspaceId,
|
|
696
|
+
settings: connectionTarget
|
|
697
|
+
? settingsWithSessionMcpServerMetadata(connectionSettings, connectionTarget.mcpServers)
|
|
698
|
+
: connectionSettings,
|
|
699
|
+
tools: connectionTools,
|
|
700
|
+
resources: mergeResourceRefs(
|
|
701
|
+
connectionTarget?.resources ?? [],
|
|
702
|
+
task.agentConfig.resources,
|
|
703
|
+
),
|
|
704
|
+
source: taskAuthoritySubjectId
|
|
705
|
+
? { kind: "subject", subjectId: taskAuthoritySubjectId, accountId: task.accountId }
|
|
706
|
+
: { kind: "none" },
|
|
707
|
+
authoritySelections: runPins,
|
|
708
|
+
...surfaceEligibility,
|
|
709
|
+
}).catch((error: unknown) => {
|
|
710
|
+
if (error instanceof ConnectionAccountSelectionError) return error;
|
|
711
|
+
throw error;
|
|
712
|
+
});
|
|
713
|
+
let taskConnections = await resolveTaskConnections();
|
|
714
|
+
// A pinned account that can no longer be used is never replaced by
|
|
715
|
+
// another account. Unless the schedule requires its pinned accounts,
|
|
716
|
+
// the occurrence goes ahead without that connector and records what it
|
|
717
|
+
// ran without, so its owner can be told; a connector keeps any of its
|
|
718
|
+
// pins that still work.
|
|
719
|
+
const degradedAccounts: ScheduledTaskDegradedAccount[] = [];
|
|
720
|
+
while (
|
|
721
|
+
taskConnections instanceof ConnectionAccountSelectionError &&
|
|
722
|
+
task.agentConfig.pinnedAccountsRequired !== true
|
|
723
|
+
) {
|
|
724
|
+
const failure: ConnectionAccountSelectionError = taskConnections;
|
|
725
|
+
const stale = scheduledStalePins(runPins, failure);
|
|
726
|
+
// A personal repository pin is bound to the schedule's repository
|
|
727
|
+
// resources; there is no connector to leave out, so it cannot degrade.
|
|
728
|
+
if (
|
|
729
|
+
stale.length === 0 ||
|
|
730
|
+
stale.some((pin) => pin.serverId === PERSONAL_GITHUB_CONNECTION_SURFACE_ID)
|
|
731
|
+
) {
|
|
732
|
+
break;
|
|
733
|
+
}
|
|
734
|
+
degradedAccounts.push(...stale);
|
|
735
|
+
const staleKeys = new Set(stale.map(scheduledPinKey));
|
|
736
|
+
const staleServerIds = new Set(stale.map((pin) => pin.serverId));
|
|
737
|
+
runPins = runPins.filter((pin) => !staleKeys.has(scheduledPinKey(pin)));
|
|
738
|
+
const droppedServerIds = new Set(
|
|
739
|
+
[...staleServerIds].filter(
|
|
740
|
+
(serverId) => !runPins.some((pin) => pin.serverId === serverId),
|
|
741
|
+
),
|
|
742
|
+
);
|
|
743
|
+
if (droppedServerIds.has(GOOGLE_DRIVE_PUBLICATION_SERVER_ID)) {
|
|
744
|
+
surfaceEligibility.googleDrivePublicationEnabled = false;
|
|
745
|
+
}
|
|
746
|
+
connectionTools = connectionTools.filter(
|
|
747
|
+
(tool) => !(tool.kind === "mcp" && droppedServerIds.has(tool.id)),
|
|
748
|
+
);
|
|
749
|
+
taskTools = taskTools.filter(
|
|
750
|
+
(tool) => !(tool.kind === "mcp" && droppedServerIds.has(tool.id)),
|
|
751
|
+
);
|
|
752
|
+
taskConnections = await resolveTaskConnections();
|
|
753
|
+
}
|
|
754
|
+
if (taskConnections instanceof ConnectionAccountSelectionError) {
|
|
755
|
+
const receipt = await recordScheduledTaskAdmissionFailure(db, {
|
|
756
|
+
workspaceId: task.workspaceId,
|
|
757
|
+
taskId: task.id,
|
|
758
|
+
taskAuthorityRevision: task.authorityRevision,
|
|
759
|
+
taskExecutionDigest: task.executionDigest,
|
|
760
|
+
triggerType: input.triggerType,
|
|
761
|
+
producerKey: stableProducerKey,
|
|
762
|
+
diagnostic: taskConnections.diagnostic,
|
|
763
|
+
});
|
|
764
|
+
if (!receipt.admissionDiagnostic) {
|
|
765
|
+
// A concurrent delivery accepted this producer first. Follow the
|
|
766
|
+
// existing exact-receipt recovery path, never replace its outcome.
|
|
767
|
+
return createScheduledTaskActivities(services).dispatchScheduledTaskRun(input);
|
|
768
|
+
}
|
|
769
|
+
return scheduledAdmissionRefusalResult(receipt);
|
|
505
770
|
}
|
|
506
771
|
const {
|
|
507
772
|
personalConnectionDelegations: taskPersonalConnectionDelegations,
|
|
508
773
|
mcpAccountBindings: taskMcpAccountBindings,
|
|
774
|
+
connectionAccountIntent: taskConnectionAccountIntent,
|
|
509
775
|
} = taskConnections;
|
|
510
776
|
const taskConnectionAuthoritySubjectId =
|
|
511
777
|
taskPersonalConnectionDelegations.length > 0 ? taskAuthoritySubjectId : null;
|
|
512
778
|
const creatorSessionPolicy = scheduledCreatorSessionPolicyInput(
|
|
513
779
|
creatorPolicy?.sessionPolicy ?? null,
|
|
514
780
|
);
|
|
515
|
-
|
|
516
|
-
task.runMode === "new_session_per_run" ||
|
|
517
|
-
(task.runMode === "reusable_session" && task.reusableSessionId === null);
|
|
781
|
+
let acceptedPersonalMachine = false;
|
|
518
782
|
if (generatedTarget && task.agentConfig.machineTarget) {
|
|
519
783
|
const access = {
|
|
520
784
|
accountId: task.accountId,
|
|
@@ -526,22 +790,48 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
526
790
|
access,
|
|
527
791
|
task.agentConfig.machineTarget.targetSandboxId,
|
|
528
792
|
);
|
|
793
|
+
// A personal machine runs only its owner's Only me schedule. The scoped
|
|
794
|
+
// lookup returns a personal machine to its owner alone, and every attempt
|
|
795
|
+
// re-proves the owner's membership, workspace access and grant in the
|
|
796
|
+
// database before the machine is used.
|
|
529
797
|
if (
|
|
530
798
|
!machine ||
|
|
531
799
|
machine.kind !== "selfhosted" ||
|
|
532
800
|
!machine.enrollmentId ||
|
|
533
|
-
machine.scope === "user"
|
|
801
|
+
(machine.scope === "user" && !personalMachineScheduleOwner(task, access.subjectId))
|
|
534
802
|
) {
|
|
535
|
-
|
|
803
|
+
return await refuseAdmission(
|
|
804
|
+
"machine_target_unavailable",
|
|
805
|
+
false,
|
|
806
|
+
"scheduled Connected Machine target is unavailable",
|
|
807
|
+
);
|
|
536
808
|
}
|
|
537
809
|
const enrollment = await getEnrollment(db, access, machine.enrollmentId);
|
|
538
|
-
if (!enrollment
|
|
539
|
-
|
|
810
|
+
if (!enrollment) {
|
|
811
|
+
return await refuseAdmission(
|
|
812
|
+
"machine_target_unavailable",
|
|
813
|
+
false,
|
|
814
|
+
"scheduled Connected Machine enrollment is gone",
|
|
815
|
+
);
|
|
816
|
+
}
|
|
817
|
+
if (enrollment.status !== "active") {
|
|
818
|
+
// A paused/suspended enrollment can be re-activated; skip this
|
|
819
|
+
// occurrence rather than failing the schedule.
|
|
820
|
+
return await refuseAdmission(
|
|
821
|
+
"machine_enrollment_inactive",
|
|
822
|
+
true,
|
|
823
|
+
`scheduled Connected Machine enrollment is ${enrollment.status}`,
|
|
824
|
+
);
|
|
540
825
|
}
|
|
541
826
|
sandboxBackend = "selfhosted";
|
|
542
827
|
sandboxOs = enrollment.os;
|
|
828
|
+
acceptedPersonalMachine = machine.scope === "user";
|
|
543
829
|
} else if (generatedTarget && sandboxBackend === "selfhosted") {
|
|
544
|
-
|
|
830
|
+
return await refuseAdmission(
|
|
831
|
+
"machine_target_unavailable",
|
|
832
|
+
false,
|
|
833
|
+
"self-hosted scheduled task has no Connected Machine target",
|
|
834
|
+
);
|
|
545
835
|
}
|
|
546
836
|
const generatedSessionDepthPolicy = generatedTarget
|
|
547
837
|
? await (async () => {
|
|
@@ -603,6 +893,14 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
603
893
|
});
|
|
604
894
|
return {
|
|
605
895
|
...targetSessionExecutionBase,
|
|
896
|
+
effectiveFirstPartyMcpTools: resolveSessionFirstPartyMcpTools(
|
|
897
|
+
settings,
|
|
898
|
+
{
|
|
899
|
+
...targetSessionExecutionBase,
|
|
900
|
+
...(connectionTarget ? { agent: connectionTarget.agent } : {}),
|
|
901
|
+
},
|
|
902
|
+
toolWorkspaceSettings,
|
|
903
|
+
),
|
|
606
904
|
effectiveMcpServerIds: [
|
|
607
905
|
...new Set(
|
|
608
906
|
effective.toolRefs.flatMap((tool) => (tool.kind === "mcp" ? [tool.id] : [])),
|
|
@@ -628,7 +926,11 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
628
926
|
)
|
|
629
927
|
: null;
|
|
630
928
|
if (generatedTarget && task.variableSetId && !acceptedVariableSet) {
|
|
631
|
-
|
|
929
|
+
return await refuseAdmission(
|
|
930
|
+
"variable_set_unavailable",
|
|
931
|
+
false,
|
|
932
|
+
`variable set not found: ${task.variableSetId}`,
|
|
933
|
+
);
|
|
632
934
|
}
|
|
633
935
|
const acceptedRig =
|
|
634
936
|
generatedTarget && task.rigId
|
|
@@ -643,12 +945,17 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
643
945
|
)
|
|
644
946
|
: null;
|
|
645
947
|
if (generatedTarget && task.rigId && (!acceptedRig || !acceptedRig.activeVersion)) {
|
|
646
|
-
|
|
948
|
+
return await refuseAdmission(
|
|
949
|
+
"rig_version_unavailable",
|
|
950
|
+
false,
|
|
951
|
+
`sandbox environment has no active version to bind: ${task.rigId}`,
|
|
952
|
+
);
|
|
647
953
|
}
|
|
648
|
-
const
|
|
954
|
+
const acceptedRigDefaultVariableSetRows = acceptedRig?.activeVersion
|
|
649
955
|
? await Promise.all(
|
|
650
|
-
acceptedRig.activeVersion.defaultVariableSetIds.map(async (variableSetId) => {
|
|
651
|
-
|
|
956
|
+
acceptedRig.activeVersion.defaultVariableSetIds.map(async (variableSetId) => ({
|
|
957
|
+
variableSetId,
|
|
958
|
+
variableSet: await getVariableSet(
|
|
652
959
|
db,
|
|
653
960
|
{
|
|
654
961
|
accountId: task.accountId,
|
|
@@ -656,16 +963,23 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
656
963
|
subjectId: taskAuthoritySubjectId ?? task.createdBy.subjectId,
|
|
657
964
|
},
|
|
658
965
|
variableSetId,
|
|
659
|
-
)
|
|
660
|
-
|
|
661
|
-
throw new Error(
|
|
662
|
-
`sandbox environment default Variable Set not found: ${variableSetId}`,
|
|
663
|
-
);
|
|
664
|
-
}
|
|
665
|
-
return { id: variableSet.id, generation: variableSet.generation };
|
|
666
|
-
}),
|
|
966
|
+
),
|
|
967
|
+
})),
|
|
667
968
|
)
|
|
668
969
|
: [];
|
|
970
|
+
const missingRigDefaultVariableSet = acceptedRigDefaultVariableSetRows.find(
|
|
971
|
+
(row) => !row.variableSet,
|
|
972
|
+
);
|
|
973
|
+
if (missingRigDefaultVariableSet) {
|
|
974
|
+
return await refuseAdmission(
|
|
975
|
+
"variable_set_unavailable",
|
|
976
|
+
false,
|
|
977
|
+
`sandbox environment default Variable Set not found: ${missingRigDefaultVariableSet.variableSetId}`,
|
|
978
|
+
);
|
|
979
|
+
}
|
|
980
|
+
const acceptedRigDefaultVariableSets = acceptedRigDefaultVariableSetRows.map(
|
|
981
|
+
({ variableSet }) => ({ id: variableSet!.id, generation: variableSet!.generation }),
|
|
982
|
+
);
|
|
669
983
|
let incidentPreflightRequired = incidentDeclaration.action === "required";
|
|
670
984
|
if (incidentPreflightRequired) {
|
|
671
985
|
const existingSessionId =
|
|
@@ -687,16 +1001,15 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
687
1001
|
task,
|
|
688
1002
|
session: responderSession,
|
|
689
1003
|
personalConnectionDelegations: taskPersonalConnectionDelegations,
|
|
1004
|
+
plannedTools: taskTools,
|
|
690
1005
|
personalResourceAuthoritySubjectId: taskAuthoritySubjectId,
|
|
691
1006
|
executionPolicy: targetSessionExecution
|
|
692
1007
|
? {
|
|
693
1008
|
tools: targetSessionExecution.tools,
|
|
694
|
-
firstPartyMcpTools:
|
|
1009
|
+
firstPartyMcpTools:
|
|
1010
|
+
targetSessionExecution.effectiveFirstPartyMcpTools ??
|
|
1011
|
+
targetSessionExecution.firstPartyMcpTools,
|
|
695
1012
|
firstPartyMcpPermissions: targetSessionExecution.firstPartyMcpPermissions,
|
|
696
|
-
variableSetIds: targetSessionExecution.variableSets.map(
|
|
697
|
-
(variableSet) => variableSet.id,
|
|
698
|
-
),
|
|
699
|
-
variableSetId: targetSessionExecution.variableSetId,
|
|
700
1013
|
rigId: targetSessionExecution.rigId,
|
|
701
1014
|
rigVersionId: targetSessionExecution.rigVersionId,
|
|
702
1015
|
toolPolicy: targetSessionExecution.toolPolicy,
|
|
@@ -707,7 +1020,6 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
707
1020
|
tools: taskTools,
|
|
708
1021
|
firstPartyMcpTools,
|
|
709
1022
|
firstPartyMcpPermissions,
|
|
710
|
-
variableSetId: acceptedVariableSet?.id ?? null,
|
|
711
1023
|
rigId: acceptedRig?.id ?? null,
|
|
712
1024
|
rigVersionId: acceptedRig?.activeVersion?.id ?? null,
|
|
713
1025
|
toolPolicy: responderSession?.toolPolicy ?? {
|
|
@@ -729,6 +1041,17 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
729
1041
|
}
|
|
730
1042
|
const taskXaiProviderAccountAuthoritySnapshot =
|
|
731
1043
|
await getScheduledTaskXaiProviderAccountAuthoritySnapshot(db, task.workspaceId, task.id);
|
|
1044
|
+
const taskClaudeProviderAccountAuthoritySnapshot =
|
|
1045
|
+
await getScheduledTaskClaudeProviderAccountAuthoritySnapshot(db, task.workspaceId, task.id);
|
|
1046
|
+
// Codex v2 (M3 PR 3b, EP-T15): the task's value frozen at creation,
|
|
1047
|
+
// copied by every firing; empty when another person authorized the
|
|
1048
|
+
// current revision. Never recomputed from current membership.
|
|
1049
|
+
const taskSubscriptionAuthority = await getScheduledTaskSubscriptionAuthority(db, {
|
|
1050
|
+
workspaceId: task.workspaceId,
|
|
1051
|
+
taskId: task.id,
|
|
1052
|
+
revisionAuthorizerSubjectId: taskRevisionAuthority?.subjectId ?? null,
|
|
1053
|
+
taskAuthorityRevision: task.authorityRevision,
|
|
1054
|
+
});
|
|
732
1055
|
// A scheduled bot selection was authorized when the task was written,
|
|
733
1056
|
// but connection status and tenant/role binding are mutable. Revalidate
|
|
734
1057
|
// before any session/model cost and never fall back to a personal Slack
|
|
@@ -744,7 +1067,7 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
744
1067
|
? openGeniSlackBotMetadata(slackBotConnection.metadata)
|
|
745
1068
|
: null;
|
|
746
1069
|
if (slackBotConnection && !slackBotMetadata) {
|
|
747
|
-
throw new Error("
|
|
1070
|
+
throw new Error("Opengeni Slack bot connection metadata is invalid");
|
|
748
1071
|
}
|
|
749
1072
|
const xaiAuthoritySubjectId =
|
|
750
1073
|
taskXaiProviderAccountAuthoritySnapshot.scope === "user" &&
|
|
@@ -752,21 +1075,67 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
752
1075
|
? task.createdBy.subjectId
|
|
753
1076
|
: null;
|
|
754
1077
|
if (taskXaiProviderAccountAuthoritySnapshot.scope === "user" && !xaiAuthoritySubjectId) {
|
|
755
|
-
|
|
1078
|
+
return await refuseAdmission(
|
|
1079
|
+
"scheduled_authority_unavailable",
|
|
1080
|
+
false,
|
|
1081
|
+
"scheduled user-scoped xAI authority has no causal human",
|
|
1082
|
+
);
|
|
756
1083
|
}
|
|
757
1084
|
if (
|
|
758
1085
|
xaiAuthoritySubjectId &&
|
|
759
1086
|
taskAuthoritySubjectId &&
|
|
760
1087
|
xaiAuthoritySubjectId !== taskAuthoritySubjectId
|
|
761
1088
|
) {
|
|
762
|
-
|
|
1089
|
+
return await refuseAdmission(
|
|
1090
|
+
"scheduled_authority_unavailable",
|
|
1091
|
+
false,
|
|
1092
|
+
"scheduled authority classes have different causal humans",
|
|
1093
|
+
);
|
|
1094
|
+
}
|
|
1095
|
+
const claudeAuthoritySubjectId =
|
|
1096
|
+
taskClaudeProviderAccountAuthoritySnapshot.scope === "user" && task.ownerSubjectId
|
|
1097
|
+
? task.ownerSubjectId
|
|
1098
|
+
: null;
|
|
1099
|
+
if (
|
|
1100
|
+
taskClaudeProviderAccountAuthoritySnapshot.scope === "user" &&
|
|
1101
|
+
!claudeAuthoritySubjectId
|
|
1102
|
+
) {
|
|
1103
|
+
return await refuseAdmission(
|
|
1104
|
+
"scheduled_authority_unavailable",
|
|
1105
|
+
false,
|
|
1106
|
+
"scheduled user-scoped Claude authority has no causal human",
|
|
1107
|
+
);
|
|
763
1108
|
}
|
|
764
|
-
|
|
1109
|
+
if (
|
|
1110
|
+
claudeAuthoritySubjectId &&
|
|
1111
|
+
taskAuthoritySubjectId &&
|
|
1112
|
+
claudeAuthoritySubjectId !== taskAuthoritySubjectId
|
|
1113
|
+
) {
|
|
1114
|
+
return await refuseAdmission(
|
|
1115
|
+
"scheduled_authority_unavailable",
|
|
1116
|
+
false,
|
|
1117
|
+
"scheduled authority classes have different causal humans",
|
|
1118
|
+
);
|
|
1119
|
+
}
|
|
1120
|
+
const causalHumanSubjectId =
|
|
1121
|
+
taskAuthoritySubjectId ?? xaiAuthoritySubjectId ?? claudeAuthoritySubjectId;
|
|
1122
|
+
if (
|
|
1123
|
+
xaiAuthoritySubjectId &&
|
|
1124
|
+
claudeAuthoritySubjectId &&
|
|
1125
|
+
xaiAuthoritySubjectId !== claudeAuthoritySubjectId
|
|
1126
|
+
)
|
|
1127
|
+
return await refuseAdmission(
|
|
1128
|
+
"scheduled_authority_unavailable",
|
|
1129
|
+
false,
|
|
1130
|
+
"scheduled subscription pools have different causal humans",
|
|
1131
|
+
);
|
|
765
1132
|
if (
|
|
766
1133
|
task.agentConfig.knowledgeSource &&
|
|
767
1134
|
causalHumanSubjectId !== task.agentConfig.knowledgeSource.initiatingSubjectId
|
|
768
1135
|
) {
|
|
769
|
-
|
|
1136
|
+
return await refuseAdmission(
|
|
1137
|
+
"scheduled_authority_unavailable",
|
|
1138
|
+
false,
|
|
770
1139
|
"Source schedule requires its connection owner's current human authorization; update the source schedule to authorize it",
|
|
771
1140
|
);
|
|
772
1141
|
}
|
|
@@ -774,11 +1143,20 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
774
1143
|
// workspace authority; only a user-owned resource needs the exact frozen
|
|
775
1144
|
// human, and the database admission fence re-proves the same rule for
|
|
776
1145
|
// existing/warm targets.
|
|
1146
|
+
// A personal machine additionally needs that human to be the machine's owner.
|
|
1147
|
+
const personalResourceSelected =
|
|
1148
|
+
acceptedVariableSet?.scope === "user" ||
|
|
1149
|
+
acceptedRig?.scope === "user" ||
|
|
1150
|
+
acceptedPersonalMachine;
|
|
777
1151
|
if (
|
|
778
|
-
(
|
|
779
|
-
|
|
1152
|
+
(personalResourceSelected && !causalHumanSubjectId) ||
|
|
1153
|
+
(acceptedPersonalMachine && causalHumanSubjectId !== task.ownerSubjectId)
|
|
780
1154
|
) {
|
|
781
|
-
|
|
1155
|
+
return await refuseAdmission(
|
|
1156
|
+
"scheduled_authority_unavailable",
|
|
1157
|
+
false,
|
|
1158
|
+
"scheduled personal-resource execution has no causal human",
|
|
1159
|
+
);
|
|
782
1160
|
}
|
|
783
1161
|
const admissionDenial = await agentRunAdmissionDenial(
|
|
784
1162
|
{ ...baseService, settings },
|
|
@@ -787,10 +1165,33 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
787
1165
|
workspaceId: task.workspaceId,
|
|
788
1166
|
model: targetSessionExecution?.model ?? model,
|
|
789
1167
|
requestedAgentRuns: input.agentRunUsageIdempotencyKey ? 0 : 1,
|
|
1168
|
+
initiatingHumanSubjectId: causalHumanSubjectId,
|
|
790
1169
|
},
|
|
791
1170
|
);
|
|
792
1171
|
if (admissionDenial) {
|
|
793
|
-
|
|
1172
|
+
// Credits and monthly limits clear on their own (top-up, new period):
|
|
1173
|
+
// skip this occurrence visibly; a later one is admitted normally.
|
|
1174
|
+
return await refuseAdmission(admissionDenial, true, "agent run admission denied");
|
|
1175
|
+
}
|
|
1176
|
+
if (acceptedTargetSessionId && targetSessionExecutionBase) {
|
|
1177
|
+
// An occurrence that targets an existing task tree counts against
|
|
1178
|
+
// that task's usage limit. A reached limit skips the occurrence
|
|
1179
|
+
// visibly (no message, turn or wake is appended) until a person raises
|
|
1180
|
+
// or clears the limit; an unreadable state throws for activity retry,
|
|
1181
|
+
// never admitting as unlimited.
|
|
1182
|
+
const usageLimit = await checkSessionUsageLimitAdmission(db, {
|
|
1183
|
+
accountId: task.accountId,
|
|
1184
|
+
workspaceId: task.workspaceId,
|
|
1185
|
+
sessionId: acceptedTargetSessionId,
|
|
1186
|
+
runtime: true,
|
|
1187
|
+
});
|
|
1188
|
+
if (!usageLimit.allowed) {
|
|
1189
|
+
return await refuseAdmission(
|
|
1190
|
+
"session_usage_limit",
|
|
1191
|
+
true,
|
|
1192
|
+
"the target task reached its usage limit",
|
|
1193
|
+
);
|
|
1194
|
+
}
|
|
794
1195
|
}
|
|
795
1196
|
const acceptedModel = targetSessionExecution?.model ?? model;
|
|
796
1197
|
const acceptedReasoningEffort = targetSessionExecution?.reasoningEffort ?? reasoningEffort;
|
|
@@ -800,11 +1201,24 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
800
1201
|
: null;
|
|
801
1202
|
const beforeFreshAgentRunCommit = acceptedCustomModel
|
|
802
1203
|
? async (tx: Database): Promise<void> => {
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
1204
|
+
// Admission reads the task's accepted Claude authority (its
|
|
1205
|
+
// carrier) as the person accountable for the task. The subject is
|
|
1206
|
+
// scoped to this check and restored afterwards.
|
|
1207
|
+
const active = await withWorkspaceSubjectRls(
|
|
1208
|
+
tx,
|
|
1209
|
+
task.workspaceId,
|
|
1210
|
+
causalHumanSubjectId ?? task.ownerSubjectId ?? task.createdBy.subjectId,
|
|
1211
|
+
async (scoped) =>
|
|
1212
|
+
await lockActiveCustomModelForAdmission(scoped, {
|
|
1213
|
+
accountId: task.accountId,
|
|
1214
|
+
workspaceId: task.workspaceId,
|
|
1215
|
+
reference: acceptedCustomModel,
|
|
1216
|
+
claudeAuthority: {
|
|
1217
|
+
authoritySnapshot: taskClaudeProviderAccountAuthoritySnapshot,
|
|
1218
|
+
scheduledTaskId: task.id,
|
|
1219
|
+
},
|
|
1220
|
+
}),
|
|
1221
|
+
);
|
|
808
1222
|
if (!active) {
|
|
809
1223
|
throw new ScheduledRunTerminalAuthorityError(
|
|
810
1224
|
"scheduled_model_unavailable",
|
|
@@ -813,23 +1227,42 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
813
1227
|
}
|
|
814
1228
|
}
|
|
815
1229
|
: undefined;
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
?
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
1230
|
+
let acceptedTurnExecutionPolicy: ReturnType<typeof resolveTurnExecutionPolicyV1>;
|
|
1231
|
+
try {
|
|
1232
|
+
acceptedTurnExecutionPolicy = resolveTurnExecutionPolicyV1(settings, {
|
|
1233
|
+
modelId: acceptedModel,
|
|
1234
|
+
requestedModelId:
|
|
1235
|
+
generatedTarget && task.agentConfig.model ? task.agentConfig.model : null,
|
|
1236
|
+
modelSource: generatedTarget
|
|
1237
|
+
? task.agentConfig.model
|
|
1238
|
+
? "explicit"
|
|
1239
|
+
: "deployment"
|
|
1240
|
+
: "session",
|
|
1241
|
+
reasoningEffort: acceptedReasoningEffort,
|
|
1242
|
+
reasoningSource: generatedTarget
|
|
1243
|
+
? task.agentConfig.reasoningEffort
|
|
1244
|
+
? "explicit"
|
|
1245
|
+
: "deployment"
|
|
1246
|
+
: "session",
|
|
1247
|
+
latencyMode: acceptedLatencyMode,
|
|
1248
|
+
latencyModeSource: generatedTarget ? "deployment" : "session",
|
|
1249
|
+
});
|
|
1250
|
+
} catch (error) {
|
|
1251
|
+
// A retired or removed model refuses every occurrence until the task
|
|
1252
|
+
// (or its target session) names an available model: record that as a
|
|
1253
|
+
// visible terminal run instead of exhausting activity retries.
|
|
1254
|
+
if (!(error instanceof TurnExecutionPolicyModelUnavailableError)) throw error;
|
|
1255
|
+
return await refuseAdmission(
|
|
1256
|
+
"scheduled_model_unavailable",
|
|
1257
|
+
false,
|
|
1258
|
+
`${error.message}: ${acceptedModel}`,
|
|
1259
|
+
);
|
|
1260
|
+
}
|
|
1261
|
+
const turnExecutionPolicy = scheduledTaskRunExecutionPolicy(
|
|
1262
|
+
acceptedTurnExecutionPolicy,
|
|
1263
|
+
input,
|
|
1264
|
+
creatorPolicy?.credentialRestriction,
|
|
1265
|
+
);
|
|
833
1266
|
const deferredEvents: Array<{
|
|
834
1267
|
sessionId: string;
|
|
835
1268
|
events: Awaited<ReturnType<typeof appendSessionEvents>>;
|
|
@@ -862,6 +1295,12 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
862
1295
|
resolvedTools: taskTools,
|
|
863
1296
|
resolvedFirstPartyMcpTools: firstPartyMcpTools,
|
|
864
1297
|
resolvedFirstPartyMcpPermissions: firstPartyMcpPermissions,
|
|
1298
|
+
...(resolvedAgentConfig
|
|
1299
|
+
? {
|
|
1300
|
+
resolvedAgentConfig,
|
|
1301
|
+
...(resolvedAgentInstructions !== undefined ? { resolvedAgentInstructions } : {}),
|
|
1302
|
+
}
|
|
1303
|
+
: {}),
|
|
865
1304
|
resolvedVariableSet: acceptedVariableSet
|
|
866
1305
|
? { id: acceptedVariableSet.id, generation: acceptedVariableSet.generation }
|
|
867
1306
|
: null,
|
|
@@ -889,8 +1328,12 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
889
1328
|
causalHumanSubjectId,
|
|
890
1329
|
causalHumanAuthority: taskRevisionAuthority,
|
|
891
1330
|
xaiProviderAccountAuthoritySnapshot: taskXaiProviderAccountAuthoritySnapshot,
|
|
1331
|
+
claudeProviderAccountAuthoritySnapshot: taskClaudeProviderAccountAuthoritySnapshot,
|
|
892
1332
|
xaiAuthoritySubjectId,
|
|
1333
|
+
claudeAuthoritySubjectId,
|
|
893
1334
|
connectionAuthoritySubjectId: taskConnectionAuthoritySubjectId,
|
|
1335
|
+
...(degradedAccounts.length > 0 ? { degradedAccounts } : {}),
|
|
1336
|
+
connectionAccountIntent: taskConnectionAccountIntent,
|
|
894
1337
|
triggerInitiator: input.initiator ?? { kind: "service", subjectId: "scheduler" },
|
|
895
1338
|
agentRunUsageIdempotencyKey: input.agentRunUsageIdempotencyKey ?? null,
|
|
896
1339
|
incidentPreflightRequired,
|
|
@@ -1069,8 +1512,13 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
1069
1512
|
tools: taskTools,
|
|
1070
1513
|
firstPartyMcpTools,
|
|
1071
1514
|
firstPartyMcpPermissions,
|
|
1515
|
+
...(resolvedAgentConfig ? { agentConfig: resolvedAgentConfig } : {}),
|
|
1516
|
+
...(resolvedAgentInstructions !== undefined
|
|
1517
|
+
? { instructions: resolvedAgentInstructions }
|
|
1518
|
+
: {}),
|
|
1072
1519
|
...creatorSessionPolicy,
|
|
1073
|
-
...(task.agentConfig.knowledgeSource?.destination.kind === "personal"
|
|
1520
|
+
...(task.agentConfig.knowledgeSource?.destination.kind === "personal" ||
|
|
1521
|
+
task.visibility === "private"
|
|
1074
1522
|
? {
|
|
1075
1523
|
visibility: "user_private" as const,
|
|
1076
1524
|
scheduledSourceRunId: run.id,
|
|
@@ -1078,6 +1526,10 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
1078
1526
|
: {}),
|
|
1079
1527
|
metadata: {
|
|
1080
1528
|
...taskMetadata,
|
|
1529
|
+
...scheduledSessionExecutionPolicyMetadata(
|
|
1530
|
+
turnExecutionPolicy,
|
|
1531
|
+
creatorPolicy?.credentialRestriction,
|
|
1532
|
+
),
|
|
1081
1533
|
model,
|
|
1082
1534
|
reasoningEffort,
|
|
1083
1535
|
scheduledTaskId: task.id,
|
|
@@ -1105,10 +1557,15 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
1105
1557
|
sandboxBackend,
|
|
1106
1558
|
sandboxOs,
|
|
1107
1559
|
variableSetId: task.variableSetId ?? null,
|
|
1560
|
+
// The schedule's vault narrowing lives on the run session so every
|
|
1561
|
+
// later turn and every child inherits it through the policy chain.
|
|
1562
|
+
...(task.vaultPolicy ? { vaultPolicy: task.vaultPolicy } : {}),
|
|
1108
1563
|
rigId: frozenRigId,
|
|
1109
1564
|
rigVersionId: frozenRigVersionId,
|
|
1110
1565
|
personalConnectionDelegations: [],
|
|
1111
1566
|
initialXaiProviderAccountAuthoritySnapshot: taskXaiProviderAccountAuthoritySnapshot,
|
|
1567
|
+
initialClaudeProviderAccountAuthoritySnapshot:
|
|
1568
|
+
taskClaudeProviderAccountAuthoritySnapshot,
|
|
1112
1569
|
maxNestedAgentDepthOverride: task.agentConfig.maxNestedAgentDepth ?? null,
|
|
1113
1570
|
frozenNestedAgentDepthPolicy: {
|
|
1114
1571
|
effectiveMaxNestedAgentDepth:
|
|
@@ -1138,7 +1595,6 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
1138
1595
|
tools: exactSession.tools,
|
|
1139
1596
|
firstPartyMcpTools: exactSession.firstPartyMcpTools,
|
|
1140
1597
|
firstPartyMcpPermissions: exactSession.firstPartyMcpPermissions,
|
|
1141
|
-
variableSetId: exactSession.variableSetId,
|
|
1142
1598
|
rigId: exactSession.rigId,
|
|
1143
1599
|
rigVersionId: exactSession.rigVersionId,
|
|
1144
1600
|
toolPolicy: exactSession.toolPolicy,
|
|
@@ -1173,6 +1629,7 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
1173
1629
|
}
|
|
1174
1630
|
session = created.session;
|
|
1175
1631
|
sessionCreated = created.created;
|
|
1632
|
+
if (sessionCreated) recordScheduledSessionCreated(baseService.observability);
|
|
1176
1633
|
if (!sessionCreated) {
|
|
1177
1634
|
await bindScheduledTaskRunSessionInTransaction(dispatchDb, {
|
|
1178
1635
|
accountId: task.accountId,
|
|
@@ -1206,7 +1663,7 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
1206
1663
|
(task.agentConfig.slackBotConnectionId ?? null)
|
|
1207
1664
|
) {
|
|
1208
1665
|
throw new Error(
|
|
1209
|
-
"scheduled alert occurrence
|
|
1666
|
+
"scheduled alert occurrence Opengeni Slack bot binding does not match its canonical session",
|
|
1210
1667
|
);
|
|
1211
1668
|
}
|
|
1212
1669
|
}
|
|
@@ -1227,6 +1684,7 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
1227
1684
|
workspaceId: task.workspaceId,
|
|
1228
1685
|
sessionId: session.id,
|
|
1229
1686
|
reasoningEffortFallback: reasoningEffort,
|
|
1687
|
+
initialSubscriptionAuthority: taskSubscriptionAuthority,
|
|
1230
1688
|
createdEventPayload: {
|
|
1231
1689
|
scheduledTaskId:
|
|
1232
1690
|
typeof session.metadata.scheduledTaskId === "string"
|
|
@@ -1290,6 +1748,7 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
1290
1748
|
workspaceId: task.workspaceId,
|
|
1291
1749
|
sessionId: session.id,
|
|
1292
1750
|
reasoningEffortFallback: reasoningEffort,
|
|
1751
|
+
initialSubscriptionAuthority: taskSubscriptionAuthority,
|
|
1293
1752
|
createdEventPayload: {
|
|
1294
1753
|
scheduledTaskId:
|
|
1295
1754
|
typeof session.metadata.scheduledTaskId === "string"
|
|
@@ -1389,6 +1848,7 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
1389
1848
|
taskTools,
|
|
1390
1849
|
task.id,
|
|
1391
1850
|
run.id,
|
|
1851
|
+
degradedAccounts,
|
|
1392
1852
|
),
|
|
1393
1853
|
lineage: {
|
|
1394
1854
|
scheduledTaskId: task.id,
|
|
@@ -1401,10 +1861,13 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
1401
1861
|
task.createdBy.kind === "subject"
|
|
1402
1862
|
? { xaiAuthoritySubjectId: task.createdBy.subjectId }
|
|
1403
1863
|
: {}),
|
|
1864
|
+
...(claudeAuthoritySubjectId ? { claudeAuthoritySubjectId } : {}),
|
|
1404
1865
|
},
|
|
1405
1866
|
personalConnectionDelegations: taskPersonalConnectionDelegations,
|
|
1406
1867
|
mcpAccountBindings: taskMcpAccountBindings,
|
|
1407
1868
|
xaiProviderAccountAuthoritySnapshot: taskXaiProviderAccountAuthoritySnapshot,
|
|
1869
|
+
claudeProviderAccountAuthoritySnapshot: taskClaudeProviderAccountAuthoritySnapshot,
|
|
1870
|
+
subscriptionAuthority: taskSubscriptionAuthority,
|
|
1408
1871
|
scheduledTaskRunId: run.id,
|
|
1409
1872
|
},
|
|
1410
1873
|
async (tx, wakeEventId, _updateId, rejectionReason) => {
|
|
@@ -1448,7 +1911,8 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
1448
1911
|
);
|
|
1449
1912
|
if (
|
|
1450
1913
|
scheduledUpdate.reason === "session_cancelled" ||
|
|
1451
|
-
scheduledUpdate.reason === "session_not_idle"
|
|
1914
|
+
scheduledUpdate.reason === "session_not_idle" ||
|
|
1915
|
+
scheduledUpdate.reason === "session_paused"
|
|
1452
1916
|
) {
|
|
1453
1917
|
const error = scheduledSessionRejectionError(scheduledUpdate.reason);
|
|
1454
1918
|
return {
|
|
@@ -1457,6 +1921,9 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
1457
1921
|
run: { ...run, status: "skipped" as const, error },
|
|
1458
1922
|
};
|
|
1459
1923
|
}
|
|
1924
|
+
if (scheduledUpdate.added) {
|
|
1925
|
+
recordUserMessageAccepted(baseService.observability, { surface: "scheduled" });
|
|
1926
|
+
}
|
|
1460
1927
|
if (scheduledUpdate.added && scheduledUpdate.events.length > 0) {
|
|
1461
1928
|
if (deferPublications) {
|
|
1462
1929
|
deferredEvents.push({
|
|
@@ -1496,9 +1963,8 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
1496
1963
|
// the locked admission check below remains authoritative. Mirrors
|
|
1497
1964
|
// apps/api/src/domain/sessions.ts.
|
|
1498
1965
|
assertReusableSessionRevivable(session.status);
|
|
1499
|
-
//
|
|
1500
|
-
//
|
|
1501
|
-
// fail the run instead of silently running with the wrong secrets.
|
|
1966
|
+
// Slack routing remains bound to the reusable chat; execution
|
|
1967
|
+
// attachments come from its accepted target snapshot.
|
|
1502
1968
|
assertReusableSessionBindingMatches(session, task);
|
|
1503
1969
|
const bundled = await addSessionSystemUpdateWithSourceMutation(
|
|
1504
1970
|
dispatchDb,
|
|
@@ -1517,6 +1983,7 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
1517
1983
|
taskTools,
|
|
1518
1984
|
task.id,
|
|
1519
1985
|
run.id,
|
|
1986
|
+
degradedAccounts,
|
|
1520
1987
|
),
|
|
1521
1988
|
lineage: {
|
|
1522
1989
|
scheduledTaskId: task.id,
|
|
@@ -1529,10 +1996,13 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
1529
1996
|
task.createdBy.kind === "subject"
|
|
1530
1997
|
? { xaiAuthoritySubjectId: task.createdBy.subjectId }
|
|
1531
1998
|
: {}),
|
|
1999
|
+
...(claudeAuthoritySubjectId ? { claudeAuthoritySubjectId } : {}),
|
|
1532
2000
|
},
|
|
1533
2001
|
personalConnectionDelegations: taskPersonalConnectionDelegations,
|
|
1534
2002
|
mcpAccountBindings: taskMcpAccountBindings,
|
|
1535
2003
|
xaiProviderAccountAuthoritySnapshot: taskXaiProviderAccountAuthoritySnapshot,
|
|
2004
|
+
claudeProviderAccountAuthoritySnapshot: taskClaudeProviderAccountAuthoritySnapshot,
|
|
2005
|
+
subscriptionAuthority: taskSubscriptionAuthority,
|
|
1536
2006
|
scheduledTaskRunId: run.id,
|
|
1537
2007
|
},
|
|
1538
2008
|
async (tx, wakeEventId, _updateId, rejectionReason) => {
|
|
@@ -1592,7 +2062,11 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
1592
2062
|
},
|
|
1593
2063
|
},
|
|
1594
2064
|
);
|
|
1595
|
-
if (
|
|
2065
|
+
if (
|
|
2066
|
+
bundled.reason === "session_cancelled" ||
|
|
2067
|
+
bundled.reason === "session_not_idle" ||
|
|
2068
|
+
bundled.reason === "session_paused"
|
|
2069
|
+
) {
|
|
1596
2070
|
const error = scheduledSessionRejectionError(bundled.reason);
|
|
1597
2071
|
return {
|
|
1598
2072
|
kind: "blocked" as const,
|
|
@@ -1600,6 +2074,9 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
1600
2074
|
run: { ...run, status: "skipped" as const, error },
|
|
1601
2075
|
};
|
|
1602
2076
|
}
|
|
2077
|
+
if (bundled.added) {
|
|
2078
|
+
recordUserMessageAccepted(baseService.observability, { surface: "scheduled" });
|
|
2079
|
+
}
|
|
1603
2080
|
if (bundled.added && bundled.events.length > 0) {
|
|
1604
2081
|
if (deferPublications) {
|
|
1605
2082
|
deferredEvents.push({
|
|
@@ -1679,7 +2156,9 @@ export function createScheduledTaskActivities(services: () => Promise<ControlAct
|
|
|
1679
2156
|
}
|
|
1680
2157
|
const terminalError = scheduledRunRecoveryTerminalError(error);
|
|
1681
2158
|
if (terminalError?.code === "scheduled_model_unavailable") {
|
|
1682
|
-
|
|
2159
|
+
// The fresh-run admission rolled back the run insert. Record the
|
|
2160
|
+
// refusal as a visible run so the schedule never fails silently.
|
|
2161
|
+
return await refuseAdmission("scheduled_model_unavailable", false, terminalError.message);
|
|
1683
2162
|
}
|
|
1684
2163
|
throw error;
|
|
1685
2164
|
}
|
|
@@ -1724,28 +2203,24 @@ class IncidentTelemetryPreflightBlockedError extends Error {
|
|
|
1724
2203
|
}
|
|
1725
2204
|
|
|
1726
2205
|
/**
|
|
1727
|
-
* Defensive backstop for the API-level
|
|
1728
|
-
*
|
|
1729
|
-
*
|
|
1730
|
-
* the wrong secrets - on the first attempt and on every recovery attempt.
|
|
2206
|
+
* Defensive backstop for the API-level Slack binding guard. Variable Sets
|
|
2207
|
+
* belong to the live target and are fenced by its accepted execution snapshot,
|
|
2208
|
+
* not by the task's retained creation defaults.
|
|
1731
2209
|
*/
|
|
1732
2210
|
function assertReusableSessionBindingMatches(
|
|
1733
|
-
session: {
|
|
1734
|
-
task: Pick<ScheduledTask, "
|
|
2211
|
+
session: { metadata: Record<string, unknown> },
|
|
2212
|
+
task: Pick<ScheduledTask, "runMode" | "agentConfig">,
|
|
1735
2213
|
): void {
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
"scheduled task variableSet attachment does not match its reusable session",
|
|
1740
|
-
);
|
|
1741
|
-
}
|
|
2214
|
+
// Existing-chat messages use the target policy frozen at admission. Task
|
|
2215
|
+
// creation defaults are not an additional authority or binding constraint.
|
|
2216
|
+
if (task.runMode === "existing_session") return;
|
|
1742
2217
|
if (
|
|
1743
2218
|
scheduledSlackBotConnectionId(session.metadata) !==
|
|
1744
2219
|
(task.agentConfig.slackBotConnectionId ?? null)
|
|
1745
2220
|
) {
|
|
1746
2221
|
throw new ScheduledRunTerminalAuthorityError(
|
|
1747
2222
|
"scheduled_reusable_binding_changed",
|
|
1748
|
-
"scheduled task
|
|
2223
|
+
"scheduled task Opengeni Slack bot binding does not match its reusable session",
|
|
1749
2224
|
);
|
|
1750
2225
|
}
|
|
1751
2226
|
}
|
|
@@ -1803,9 +2278,60 @@ function scheduledRunRecoveryTerminalError(
|
|
|
1803
2278
|
return null;
|
|
1804
2279
|
}
|
|
1805
2280
|
|
|
2281
|
+
function scheduledPinKey(pin: { serverId: string; connectionId: string | null }): string {
|
|
2282
|
+
return JSON.stringify([pin.serverId, pin.connectionId]);
|
|
2283
|
+
}
|
|
2284
|
+
|
|
2285
|
+
/**
|
|
2286
|
+
* The pinned accounts an account-selection failure names. When the owner lost
|
|
2287
|
+
* workspace access, none of their pinned accounts can be used.
|
|
2288
|
+
*/
|
|
2289
|
+
function scheduledStalePins(
|
|
2290
|
+
pins: readonly McpConnectionAccountSelection[],
|
|
2291
|
+
failure: ConnectionAccountSelectionError,
|
|
2292
|
+
): ScheduledTaskDegradedAccount[] {
|
|
2293
|
+
const pinKeys = new Set(pins.map(scheduledPinKey));
|
|
2294
|
+
const named = failure.diagnostic.accounts.flatMap((account) =>
|
|
2295
|
+
pinKeys.has(scheduledPinKey(account))
|
|
2296
|
+
? [{ serverId: account.serverId, connectionId: account.connectionId, reason: account.reason }]
|
|
2297
|
+
: [],
|
|
2298
|
+
);
|
|
2299
|
+
if (named.length > 0) return named;
|
|
2300
|
+
if (failure.diagnostic.reason === "owner_access_unavailable") {
|
|
2301
|
+
return pins.map((pin) => ({
|
|
2302
|
+
serverId: pin.serverId,
|
|
2303
|
+
connectionId: pin.connectionId,
|
|
2304
|
+
reason: "owner_access_unavailable" as const,
|
|
2305
|
+
}));
|
|
2306
|
+
}
|
|
2307
|
+
return [];
|
|
2308
|
+
}
|
|
2309
|
+
|
|
2310
|
+
/** The blocked result of a diagnostic (refused) run receipt, fresh or replayed. */
|
|
2311
|
+
function scheduledAdmissionRefusalResult(
|
|
2312
|
+
run: Pick<ScheduledTaskRun, "id" | "admissionDiagnostic" | "admissionRefusal">,
|
|
2313
|
+
): Extract<DispatchScheduledTaskRunResult, { action: "blocked" }> {
|
|
2314
|
+
if (run.admissionRefusal) {
|
|
2315
|
+
return {
|
|
2316
|
+
action: "blocked",
|
|
2317
|
+
reason: run.admissionRefusal.reason as ScheduledTaskAdmissionRefusalReason,
|
|
2318
|
+
runId: run.id,
|
|
2319
|
+
refusal: run.admissionRefusal,
|
|
2320
|
+
};
|
|
2321
|
+
}
|
|
2322
|
+
return {
|
|
2323
|
+
action: "blocked",
|
|
2324
|
+
reason: "connection_account_unavailable",
|
|
2325
|
+
runId: run.id,
|
|
2326
|
+
...(run.admissionDiagnostic ? { diagnostic: run.admissionDiagnostic } : {}),
|
|
2327
|
+
};
|
|
2328
|
+
}
|
|
2329
|
+
|
|
1806
2330
|
function scheduledRunTerminalResult(
|
|
1807
2331
|
error: string | null,
|
|
1808
2332
|
): Extract<DispatchScheduledTaskRunResult, { action: "blocked" }> {
|
|
2333
|
+
if (error === ATLASSIAN_NATIVE_RETIRED_REASON)
|
|
2334
|
+
return { action: "blocked", reason: ATLASSIAN_NATIVE_RETIRED_REASON };
|
|
1809
2335
|
if (error === "scheduled_authority_exhausted") {
|
|
1810
2336
|
return { action: "blocked", reason: "scheduled_authority_exhausted" };
|
|
1811
2337
|
}
|
|
@@ -1822,8 +2348,9 @@ function scheduledRunTerminalResult(
|
|
|
1822
2348
|
}
|
|
1823
2349
|
|
|
1824
2350
|
function scheduledSessionRejectionError(
|
|
1825
|
-
rejectionReason: "session_cancelled" | "session_not_idle" | null,
|
|
1826
|
-
): "session_cancelled" | "scheduled_session_not_idle" {
|
|
2351
|
+
rejectionReason: "session_cancelled" | "session_not_idle" | "session_paused" | null,
|
|
2352
|
+
): "session_cancelled" | "scheduled_session_not_idle" | "scheduled_session_paused" {
|
|
2353
|
+
if (rejectionReason === "session_paused") return "scheduled_session_paused";
|
|
1827
2354
|
return rejectionReason === "session_not_idle"
|
|
1828
2355
|
? "scheduled_session_not_idle"
|
|
1829
2356
|
: "session_cancelled";
|
|
@@ -1851,13 +2378,11 @@ async function prepareIncidentTelemetrySource(input: {
|
|
|
1851
2378
|
executionPolicy: input.acceptedExecution.targetSessionExecution
|
|
1852
2379
|
? {
|
|
1853
2380
|
tools: input.acceptedExecution.targetSessionExecution.tools,
|
|
1854
|
-
firstPartyMcpTools:
|
|
2381
|
+
firstPartyMcpTools:
|
|
2382
|
+
input.acceptedExecution.targetSessionExecution.effectiveFirstPartyMcpTools ??
|
|
2383
|
+
input.acceptedExecution.targetSessionExecution.firstPartyMcpTools,
|
|
1855
2384
|
firstPartyMcpPermissions:
|
|
1856
2385
|
input.acceptedExecution.targetSessionExecution.firstPartyMcpPermissions,
|
|
1857
|
-
variableSetIds: input.acceptedExecution.targetSessionExecution.variableSets.map(
|
|
1858
|
-
(variableSet) => variableSet.id,
|
|
1859
|
-
),
|
|
1860
|
-
variableSetId: input.acceptedExecution.targetSessionExecution.variableSetId,
|
|
1861
2386
|
rigId: input.acceptedExecution.targetSessionExecution.rigId,
|
|
1862
2387
|
rigVersionId: input.acceptedExecution.targetSessionExecution.rigVersionId,
|
|
1863
2388
|
toolPolicy: input.acceptedExecution.targetSessionExecution.toolPolicy,
|
|
@@ -1868,7 +2393,6 @@ async function prepareIncidentTelemetrySource(input: {
|
|
|
1868
2393
|
tools: input.acceptedExecution.resolvedTools,
|
|
1869
2394
|
firstPartyMcpTools: input.acceptedExecution.resolvedFirstPartyMcpTools,
|
|
1870
2395
|
firstPartyMcpPermissions: input.acceptedExecution.resolvedFirstPartyMcpPermissions,
|
|
1871
|
-
variableSetId: input.acceptedExecution.resolvedVariableSet?.id ?? null,
|
|
1872
2396
|
rigId: input.acceptedExecution.resolvedRig?.id ?? null,
|
|
1873
2397
|
rigVersionId: input.acceptedExecution.resolvedRig?.versionId ?? null,
|
|
1874
2398
|
toolPolicy: session.toolPolicy,
|
|
@@ -1921,6 +2445,50 @@ async function recordScheduledTaskFiredUsage(
|
|
|
1921
2445
|
});
|
|
1922
2446
|
}
|
|
1923
2447
|
|
|
2448
|
+
function personalMachineScheduleOwner(task: ScheduledTask, subjectId: string | null): boolean {
|
|
2449
|
+
return (
|
|
2450
|
+
task.visibility === "private" &&
|
|
2451
|
+
task.ownerSubjectId !== null &&
|
|
2452
|
+
task.ownerSubjectId === subjectId
|
|
2453
|
+
);
|
|
2454
|
+
}
|
|
2455
|
+
|
|
2456
|
+
/**
|
|
2457
|
+
* The owner and machine authority when an Only me schedule runs on its owner's
|
|
2458
|
+
* personal machine; null for a shared machine. Throws when a personal machine is
|
|
2459
|
+
* no longer usable by the owner, so the run fails closed.
|
|
2460
|
+
*/
|
|
2461
|
+
async function scheduledPersonalMachineOwner(
|
|
2462
|
+
db: Database,
|
|
2463
|
+
task: ScheduledTask,
|
|
2464
|
+
target: NonNullable<ScheduledTask["agentConfig"]["machineTarget"]>,
|
|
2465
|
+
): Promise<{ subjectId: string; authorityId: string } | null> {
|
|
2466
|
+
const subjectId = task.ownerSubjectId;
|
|
2467
|
+
if (task.visibility !== "private" || !subjectId) return null;
|
|
2468
|
+
const access = { accountId: task.accountId, workspaceId: task.workspaceId, subjectId };
|
|
2469
|
+
const machine = await getSandbox(db, access, target.targetSandboxId);
|
|
2470
|
+
if (machine?.scope !== "user") return null;
|
|
2471
|
+
if (!machine.enrollmentId) {
|
|
2472
|
+
throw new Error("scheduled personal Connected Machine has no enrollment");
|
|
2473
|
+
}
|
|
2474
|
+
let cursor: string | undefined;
|
|
2475
|
+
for (let page = 0; page < 50; page += 1) {
|
|
2476
|
+
const listed = await listSelfUserResourceAuthorities(db, {
|
|
2477
|
+
...access,
|
|
2478
|
+
resourceKind: "connected_machine",
|
|
2479
|
+
limit: 100,
|
|
2480
|
+
...(cursor ? { cursor } : {}),
|
|
2481
|
+
});
|
|
2482
|
+
const authority = listed.authorities.find(
|
|
2483
|
+
(candidate) => candidate.resourceId === machine.enrollmentId && candidate.status === "active",
|
|
2484
|
+
);
|
|
2485
|
+
if (authority) return { subjectId, authorityId: authority.authorityId };
|
|
2486
|
+
if (!listed.nextCursor) break;
|
|
2487
|
+
cursor = listed.nextCursor;
|
|
2488
|
+
}
|
|
2489
|
+
throw new Error("scheduled personal Connected Machine authority is not active");
|
|
2490
|
+
}
|
|
2491
|
+
|
|
1924
2492
|
async function seedScheduledGeneratedSessionRoute(input: {
|
|
1925
2493
|
db: Database;
|
|
1926
2494
|
bus: ControlActivityServices["bus"];
|
|
@@ -1936,6 +2504,7 @@ async function seedScheduledGeneratedSessionRoute(input: {
|
|
|
1936
2504
|
}): Promise<Awaited<ReturnType<typeof createSession>>> {
|
|
1937
2505
|
const target = input.task.agentConfig.machineTarget;
|
|
1938
2506
|
if (!target) return input.session;
|
|
2507
|
+
const personalOwner = await scheduledPersonalMachineOwner(input.db, input.task, target);
|
|
1939
2508
|
const seeded = await swapActiveSandbox(
|
|
1940
2509
|
{
|
|
1941
2510
|
db: input.db,
|
|
@@ -1948,11 +2517,35 @@ async function seedScheduledGeneratedSessionRoute(input: {
|
|
|
1948
2517
|
sessionId: input.session.id,
|
|
1949
2518
|
sessionBackend: input.session.sandboxBackend,
|
|
1950
2519
|
sessionGroupId: input.session.sandboxGroupId,
|
|
2520
|
+
// A personal machine attaches through the owner's scoped authorization.
|
|
2521
|
+
...(personalOwner ? { subjectId: personalOwner.subjectId } : {}),
|
|
1951
2522
|
},
|
|
1952
2523
|
target.targetSandboxId,
|
|
1953
2524
|
target.workingDir ?? null,
|
|
1954
2525
|
);
|
|
1955
2526
|
if (seeded.swapped) {
|
|
2527
|
+
if (personalOwner) {
|
|
2528
|
+
// Saving an Only me schedule on your own machine is the consent. Each run
|
|
2529
|
+
// gets a grant for exactly its own chat, so other chats keep asking.
|
|
2530
|
+
const authorityEpoch = await getSessionAuthorityEpoch(input.db, {
|
|
2531
|
+
accountId: input.task.accountId,
|
|
2532
|
+
workspaceId: input.task.workspaceId,
|
|
2533
|
+
sessionId: input.session.id,
|
|
2534
|
+
});
|
|
2535
|
+
if (authorityEpoch === null) throw new Error("scheduled run chat has no authority epoch");
|
|
2536
|
+
await issueSelfUserResourceGrant(input.db, {
|
|
2537
|
+
accountId: input.task.accountId,
|
|
2538
|
+
workspaceId: input.task.workspaceId,
|
|
2539
|
+
subjectId: personalOwner.subjectId,
|
|
2540
|
+
authorityId: personalOwner.authorityId,
|
|
2541
|
+
resourceKind: "connected_machine",
|
|
2542
|
+
mode: "session",
|
|
2543
|
+
context: "user_private",
|
|
2544
|
+
sessionId: input.session.id,
|
|
2545
|
+
expectedAuthorityEpoch: authorityEpoch,
|
|
2546
|
+
workspaceSharedAcknowledged: false,
|
|
2547
|
+
});
|
|
2548
|
+
}
|
|
1956
2549
|
return await requireSession(input.db, input.task.workspaceId, input.session.id);
|
|
1957
2550
|
}
|
|
1958
2551
|
|
|
@@ -1991,6 +2584,7 @@ async function seedScheduledGeneratedSessionRoute(input: {
|
|
|
1991
2584
|
|
|
1992
2585
|
async function recoverBoundScheduledTaskDispatch(input: {
|
|
1993
2586
|
db: Database;
|
|
2587
|
+
observability?: ProductUsageMetricsSink | undefined;
|
|
1994
2588
|
bus: ControlActivityServices["bus"];
|
|
1995
2589
|
settings: ControlActivityServices["settings"];
|
|
1996
2590
|
wakeSessionWorkflow: WakeSessionWorkflowSignal | null;
|
|
@@ -2005,6 +2599,11 @@ async function recoverBoundScheduledTaskDispatch(input: {
|
|
|
2005
2599
|
const generatedSession =
|
|
2006
2600
|
task.runMode === "new_session_per_run" ||
|
|
2007
2601
|
(task.runMode === "reusable_session" && task.reusableSessionId === null);
|
|
2602
|
+
// The immutable creator policy determines standing session authority, not
|
|
2603
|
+
// a manual caller's per-run ceiling. Read it for creation and recovery checks.
|
|
2604
|
+
const recoveredCreatorPolicy = generatedSession
|
|
2605
|
+
? await getScheduledTaskCreatorPolicy(input.db, task.workspaceId, task.id)
|
|
2606
|
+
: null;
|
|
2008
2607
|
const frozenSlack = input.acceptedExecution.resolvedSlackBotConnection;
|
|
2009
2608
|
if (frozenSlack) {
|
|
2010
2609
|
const currentSlack = await requireOpenGeniSlackBotConnection(
|
|
@@ -2027,9 +2626,8 @@ async function recoverBoundScheduledTaskDispatch(input: {
|
|
|
2027
2626
|
let session: Awaited<ReturnType<typeof createSession>>;
|
|
2028
2627
|
if (input.run.sessionId) {
|
|
2029
2628
|
session = await requireSession(input.db, task.workspaceId, input.run.sessionId);
|
|
2030
|
-
//
|
|
2031
|
-
//
|
|
2032
|
-
// run terminally rather than deliver into a diverged session.
|
|
2629
|
+
// Preserve the reusable chat's Slack routing; the accepted target snapshot
|
|
2630
|
+
// independently fences its current Variable Set attachments during recovery.
|
|
2033
2631
|
if (!generatedSession) assertReusableSessionBindingMatches(session, task);
|
|
2034
2632
|
} else if (generatedSession) {
|
|
2035
2633
|
const variableSet = input.acceptedExecution.resolvedVariableSet;
|
|
@@ -2073,14 +2671,6 @@ async function recoverBoundScheduledTaskDispatch(input: {
|
|
|
2073
2671
|
}
|
|
2074
2672
|
const taskMetadata = { ...task.agentConfig.metadata };
|
|
2075
2673
|
delete taskMetadata[OPENGENI_SLACK_BOT_SESSION_METADATA_KEY];
|
|
2076
|
-
// Tools and permissions were frozen into the accepted execution. The
|
|
2077
|
-
// creator session policy is immutable on the task row (a tombstoned task
|
|
2078
|
-
// still answers), so re-reading it here is deterministic for the same run.
|
|
2079
|
-
const recoveredCreatorPolicy = await getScheduledTaskCreatorPolicy(
|
|
2080
|
-
input.db,
|
|
2081
|
-
task.workspaceId,
|
|
2082
|
-
task.id,
|
|
2083
|
-
);
|
|
2084
2674
|
const created = await createSessionWithIdempotencyKeyResult(input.db, {
|
|
2085
2675
|
accountId: task.accountId,
|
|
2086
2676
|
workspaceId: task.workspaceId,
|
|
@@ -2090,8 +2680,16 @@ async function recoverBoundScheduledTaskDispatch(input: {
|
|
|
2090
2680
|
tools: input.acceptedExecution.resolvedTools,
|
|
2091
2681
|
firstPartyMcpTools: input.acceptedExecution.resolvedFirstPartyMcpTools,
|
|
2092
2682
|
firstPartyMcpPermissions: input.acceptedExecution.resolvedFirstPartyMcpPermissions,
|
|
2683
|
+
...(input.acceptedExecution.resolvedAgentConfig
|
|
2684
|
+
? { agentConfig: input.acceptedExecution.resolvedAgentConfig }
|
|
2685
|
+
: {}),
|
|
2686
|
+
...(input.acceptedExecution.resolvedAgentInstructions !== undefined
|
|
2687
|
+
? { instructions: input.acceptedExecution.resolvedAgentInstructions }
|
|
2688
|
+
: {}),
|
|
2093
2689
|
...scheduledCreatorSessionPolicyInput(recoveredCreatorPolicy?.sessionPolicy ?? null),
|
|
2094
|
-
...(task.
|
|
2690
|
+
...(task.vaultPolicy ? { vaultPolicy: task.vaultPolicy } : {}),
|
|
2691
|
+
...(task.agentConfig.knowledgeSource?.destination.kind === "personal" ||
|
|
2692
|
+
task.visibility === "private"
|
|
2095
2693
|
? {
|
|
2096
2694
|
visibility: "user_private" as const,
|
|
2097
2695
|
scheduledSourceRunId: input.run.id,
|
|
@@ -2099,6 +2697,10 @@ async function recoverBoundScheduledTaskDispatch(input: {
|
|
|
2099
2697
|
: {}),
|
|
2100
2698
|
metadata: {
|
|
2101
2699
|
...taskMetadata,
|
|
2700
|
+
...scheduledSessionExecutionPolicyMetadata(
|
|
2701
|
+
input.acceptedExecution.turnExecutionPolicy,
|
|
2702
|
+
recoveredCreatorPolicy?.credentialRestriction,
|
|
2703
|
+
),
|
|
2102
2704
|
model: input.acceptedExecution.resolvedModel,
|
|
2103
2705
|
reasoningEffort: input.acceptedExecution.resolvedReasoningEffort,
|
|
2104
2706
|
scheduledTaskId: task.id,
|
|
@@ -2127,6 +2729,8 @@ async function recoverBoundScheduledTaskDispatch(input: {
|
|
|
2127
2729
|
personalConnectionDelegations: [],
|
|
2128
2730
|
initialXaiProviderAccountAuthoritySnapshot:
|
|
2129
2731
|
input.acceptedExecution.xaiProviderAccountAuthoritySnapshot,
|
|
2732
|
+
initialClaudeProviderAccountAuthoritySnapshot:
|
|
2733
|
+
input.acceptedExecution.claudeProviderAccountAuthoritySnapshot,
|
|
2130
2734
|
maxNestedAgentDepthOverride: task.agentConfig.maxNestedAgentDepth ?? null,
|
|
2131
2735
|
frozenNestedAgentDepthPolicy: {
|
|
2132
2736
|
effectiveMaxNestedAgentDepth:
|
|
@@ -2157,6 +2761,7 @@ async function recoverBoundScheduledTaskDispatch(input: {
|
|
|
2157
2761
|
});
|
|
2158
2762
|
if (created.denied) throw new SessionSpawnDeniedDbError(created.denial);
|
|
2159
2763
|
session = created.session;
|
|
2764
|
+
if (created.created) recordScheduledSessionCreated(input.observability);
|
|
2160
2765
|
if (!created.created) {
|
|
2161
2766
|
await bindScheduledTaskRunSessionInTransaction(input.db, {
|
|
2162
2767
|
accountId: task.accountId,
|
|
@@ -2227,20 +2832,27 @@ async function recoverBoundScheduledTaskDispatch(input: {
|
|
|
2227
2832
|
);
|
|
2228
2833
|
const expectedTaskMetadata = { ...task.agentConfig.metadata };
|
|
2229
2834
|
delete expectedTaskMetadata[OPENGENI_SLACK_BOT_SESSION_METADATA_KEY];
|
|
2230
|
-
const expectedMetadata =
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2835
|
+
const expectedMetadata = metadataWithAgentConfigCreateIdentity(
|
|
2836
|
+
{
|
|
2837
|
+
...expectedTaskMetadata,
|
|
2838
|
+
...scheduledSessionExecutionPolicyMetadata(
|
|
2839
|
+
input.acceptedExecution.turnExecutionPolicy,
|
|
2840
|
+
recoveredCreatorPolicy?.credentialRestriction,
|
|
2841
|
+
),
|
|
2842
|
+
model: input.acceptedExecution.resolvedModel,
|
|
2843
|
+
reasoningEffort: input.acceptedExecution.resolvedReasoningEffort,
|
|
2844
|
+
scheduledTaskId: task.id,
|
|
2845
|
+
scheduledTaskRunMode: task.runMode,
|
|
2846
|
+
...(task.agentConfig.goal ? { scheduledTaskGoal: task.agentConfig.goal } : {}),
|
|
2847
|
+
scheduledTaskRunId: canonicalGeneratedRunId,
|
|
2848
|
+
...(frozenSlack ? { [OPENGENI_SLACK_BOT_SESSION_METADATA_KEY]: frozenSlack.id } : {}),
|
|
2849
|
+
},
|
|
2850
|
+
input.acceptedExecution.resolvedAgentConfig,
|
|
2851
|
+
);
|
|
2240
2852
|
if (
|
|
2241
2853
|
session.createIdempotencyKey !== expectedCreateKey ||
|
|
2242
2854
|
session.initialMessage !== task.agentConfig.prompt ||
|
|
2243
|
-
session.instructions !== null ||
|
|
2855
|
+
session.instructions !== (input.acceptedExecution.resolvedAgentInstructions ?? null) ||
|
|
2244
2856
|
session.policyRole !== null ||
|
|
2245
2857
|
stableJson(session.skills) !== "[]" ||
|
|
2246
2858
|
stableJson(session.toolPolicy) !==
|
|
@@ -2282,6 +2894,8 @@ async function recoverBoundScheduledTaskDispatch(input: {
|
|
|
2282
2894
|
stableJson(input.acceptedExecution.resolvedFirstPartyMcpTools) ||
|
|
2283
2895
|
stableJson(session.firstPartyMcpPermissions) !==
|
|
2284
2896
|
stableJson(input.acceptedExecution.resolvedFirstPartyMcpPermissions) ||
|
|
2897
|
+
stableJson(session.agent) !==
|
|
2898
|
+
stableJson(input.acceptedExecution.resolvedAgentConfig ?? null) ||
|
|
2285
2899
|
session.maxNestedAgentDepthOverride !== (task.agentConfig.maxNestedAgentDepth ?? null) ||
|
|
2286
2900
|
(session.variableSetId ?? null) !==
|
|
2287
2901
|
(input.acceptedExecution.resolvedVariableSet?.id ?? null) ||
|
|
@@ -2363,6 +2977,7 @@ async function recoverBoundScheduledTaskDispatch(input: {
|
|
|
2363
2977
|
input.acceptedExecution.resolvedTools,
|
|
2364
2978
|
task.id,
|
|
2365
2979
|
input.run.id,
|
|
2980
|
+
input.acceptedExecution.degradedAccounts ?? [],
|
|
2366
2981
|
),
|
|
2367
2982
|
lineage: {
|
|
2368
2983
|
scheduledTaskId: task.id,
|
|
@@ -2378,11 +2993,25 @@ async function recoverBoundScheduledTaskDispatch(input: {
|
|
|
2378
2993
|
...(input.acceptedExecution.xaiAuthoritySubjectId
|
|
2379
2994
|
? { xaiAuthoritySubjectId: input.acceptedExecution.xaiAuthoritySubjectId }
|
|
2380
2995
|
: {}),
|
|
2996
|
+
...(input.acceptedExecution.claudeAuthoritySubjectId
|
|
2997
|
+
? { claudeAuthoritySubjectId: input.acceptedExecution.claudeAuthoritySubjectId }
|
|
2998
|
+
: {}),
|
|
2381
2999
|
},
|
|
2382
3000
|
personalConnectionDelegations: input.acceptedExecution.personalConnectionDelegations,
|
|
2383
3001
|
mcpAccountBindings: input.acceptedExecution.mcpAccountBindings ?? null,
|
|
2384
3002
|
xaiProviderAccountAuthoritySnapshot:
|
|
2385
3003
|
input.acceptedExecution.xaiProviderAccountAuthoritySnapshot,
|
|
3004
|
+
claudeProviderAccountAuthoritySnapshot:
|
|
3005
|
+
input.acceptedExecution.claudeProviderAccountAuthoritySnapshot,
|
|
3006
|
+
// Codex v2 (M3 PR 3b): the task's value frozen at creation, narrowed to
|
|
3007
|
+
// empty when the accepted revision's authorizer is not the owner.
|
|
3008
|
+
subscriptionAuthority: await getScheduledTaskSubscriptionAuthority(input.db, {
|
|
3009
|
+
workspaceId: task.workspaceId,
|
|
3010
|
+
taskId: task.id,
|
|
3011
|
+
revisionAuthorizerSubjectId:
|
|
3012
|
+
input.acceptedExecution.causalHumanAuthority?.subjectId ?? null,
|
|
3013
|
+
taskAuthorityRevision: task.authorityRevision,
|
|
3014
|
+
}),
|
|
2386
3015
|
scheduledTaskRunId: input.run.id,
|
|
2387
3016
|
},
|
|
2388
3017
|
async (tx, wakeEventId, _updateId, rejectionReason) => {
|
|
@@ -2443,10 +3072,14 @@ async function recoverBoundScheduledTaskDispatch(input: {
|
|
|
2443
3072
|
);
|
|
2444
3073
|
if (
|
|
2445
3074
|
scheduledUpdate.reason === "session_cancelled" ||
|
|
2446
|
-
scheduledUpdate.reason === "session_not_idle"
|
|
3075
|
+
scheduledUpdate.reason === "session_not_idle" ||
|
|
3076
|
+
scheduledUpdate.reason === "session_paused"
|
|
2447
3077
|
) {
|
|
2448
3078
|
return { action: "blocked", reason: "scheduled_run_terminal" };
|
|
2449
3079
|
}
|
|
3080
|
+
if (scheduledUpdate.added) {
|
|
3081
|
+
recordUserMessageAccepted(input.observability, { surface: "scheduled" });
|
|
3082
|
+
}
|
|
2450
3083
|
if (scheduledUpdate.added && scheduledUpdate.events.length > 0) {
|
|
2451
3084
|
await publishDurableSessionEvents(
|
|
2452
3085
|
input.bus,
|