@opengeni/worker-bundle 2.0.1 → 2.0.2-canary.38686408778001
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/activities/agent-run-admission.d.ts +1 -12
- package/dist/activities/agent-turn/admission.d.ts +88 -10
- package/dist/activities/agent-turn/agent-build.d.ts +14 -3
- package/dist/activities/agent-turn/claim.d.ts +4 -1
- package/dist/activities/agent-turn/claude-core.d.ts +195 -0
- package/dist/activities/agent-turn/code-search.d.ts +60 -0
- package/dist/activities/agent-turn/codex-capacity.d.ts +3 -0
- package/dist/activities/agent-turn/codex-core-capacity.d.ts +37 -0
- package/dist/activities/agent-turn/codex-core-claim.d.ts +40 -0
- package/dist/activities/agent-turn/codex-core-errors.d.ts +102 -0
- package/dist/activities/agent-turn/codex-core-failover.d.ts +15 -0
- package/dist/activities/agent-turn/codex-core-requests.d.ts +28 -0
- package/dist/activities/agent-turn/codex-core-settlement.d.ts +77 -0
- package/dist/activities/agent-turn/codex-credit-policy.d.ts +30 -0
- package/dist/activities/agent-turn/codex-plan-entitlement.d.ts +105 -0
- package/dist/activities/agent-turn/codex-usage-policy.d.ts +2 -0
- package/dist/activities/agent-turn/codex.d.ts +2 -19
- package/dist/activities/agent-turn/compaction-interruption.d.ts +32 -0
- package/dist/activities/agent-turn/compaction-prep.d.ts +30 -1
- package/dist/activities/agent-turn/credential-leases.d.ts +64 -37
- package/dist/activities/agent-turn/credential-restriction.d.ts +3 -0
- package/dist/activities/agent-turn/errors.d.ts +172 -28
- package/dist/activities/agent-turn/failure-settlement.d.ts +10 -43
- package/dist/activities/agent-turn/final-reply.d.ts +18 -0
- package/dist/activities/agent-turn/finalization-monitor.d.ts +7 -2
- package/dist/activities/agent-turn/finalization.d.ts +2 -0
- package/dist/activities/agent-turn/github-repository-bindings.d.ts +2 -0
- package/dist/activities/agent-turn/governance-model.d.ts +13 -1
- package/dist/activities/agent-turn/history-sink.d.ts +3 -1
- package/dist/activities/agent-turn/history.d.ts +2 -0
- package/dist/activities/agent-turn/input-wait-reply.d.ts +76 -0
- package/dist/activities/agent-turn/meaningful-output.d.ts +9 -0
- package/dist/activities/agent-turn/media-artifacts.d.ts +5 -3
- package/dist/activities/agent-turn/model-call-admission.d.ts +15 -0
- package/dist/activities/agent-turn/model-usage.d.ts +56 -14
- package/dist/activities/agent-turn/model-wire-dispatch.d.ts +15 -0
- package/dist/activities/agent-turn/optional-repositories.d.ts +59 -0
- package/dist/activities/agent-turn/prompt-tool-availability.d.ts +17 -0
- package/dist/activities/agent-turn/provider-dispatch-barrier.d.ts +12 -1
- package/dist/activities/agent-turn/provider-recovery-copy.d.ts +24 -0
- package/dist/activities/agent-turn/provider-recovery-metrics.d.ts +18 -0
- package/dist/activities/agent-turn/provider-recovery-policy.d.ts +6 -0
- package/dist/activities/agent-turn/quiescence.d.ts +6 -7
- package/dist/activities/agent-turn/recovery-warning.d.ts +6 -5
- package/dist/activities/agent-turn/refresh-credentials.d.ts +6 -0
- package/dist/activities/agent-turn/run-credentials.d.ts +9 -5
- package/dist/activities/agent-turn/run.d.ts +27 -2
- package/dist/activities/agent-turn/sandbox-establish.d.ts +1 -0
- package/dist/activities/agent-turn/sandbox-provision.d.ts +25 -1
- package/dist/activities/agent-turn/sandbox-route.d.ts +3 -0
- package/dist/activities/agent-turn/sandbox-runtime.d.ts +1 -1
- package/dist/activities/agent-turn/secret-resolver.d.ts +64 -0
- package/dist/activities/agent-turn/session-title.d.ts +60 -3
- package/dist/activities/agent-turn/session-usage-custody.d.ts +66 -0
- package/dist/activities/agent-turn/skill-checkout.d.ts +25 -6
- package/dist/activities/agent-turn/skill-read.d.ts +70 -2
- package/dist/activities/agent-turn/skill-search.d.ts +2 -0
- package/dist/activities/agent-turn/skill-tools.d.ts +41 -4
- package/dist/activities/agent-turn/skill-transfer.d.ts +18 -6
- package/dist/activities/agent-turn/stream-attempt.d.ts +6 -3
- package/dist/activities/agent-turn/subscription-capacity-arming.d.ts +41 -0
- package/dist/activities/agent-turn/subscription-core-capacity.d.ts +86 -0
- package/dist/activities/agent-turn/subscription-core-failover.d.ts +69 -0
- package/dist/activities/agent-turn/subscription-core-placed.d.ts +14 -0
- package/dist/activities/agent-turn/subscription-core-requests.d.ts +109 -0
- package/dist/activities/agent-turn/subscription-core-settlement.d.ts +112 -0
- package/dist/activities/agent-turn/subscription-lease.d.ts +44 -0
- package/dist/activities/agent-turn/subscription-serving-capacity.d.ts +6 -0
- package/dist/activities/agent-turn/subscription-serving-catalog.d.ts +13 -0
- package/dist/activities/agent-turn/subscription-serving-claim.d.ts +30 -0
- package/dist/activities/agent-turn/subscription-serving-providers.d.ts +2 -0
- package/dist/activities/agent-turn/tool-environment.d.ts +30 -6
- package/dist/activities/agent-turn/tool-policy.d.ts +55 -3
- package/dist/activities/agent-turn/turn-context.d.ts +104 -5
- package/dist/activities/agent-turn/web-search.d.ts +57 -0
- package/dist/activities/agent-turn/xai-core.d.ts +96 -0
- package/dist/activities/automations.d.ts +3 -1
- package/dist/activities/browser-deadline-checkpoint.d.ts +34 -0
- package/dist/activities/capabilities.d.ts +8 -20
- package/dist/activities/codemode-dispatcher.d.ts +20 -3
- package/dist/activities/codex-capacity.d.ts +1 -56
- package/dist/activities/codex-image-generation.d.ts +49 -3
- package/dist/activities/common.d.ts +3 -1
- package/dist/activities/context-compaction.d.ts +41 -2
- package/dist/activities/environment.d.ts +1 -19
- package/dist/activities/gmail-files.d.ts +50 -0
- package/dist/activities/goals.d.ts +1 -9
- package/dist/activities/incident-telemetry-authority.d.ts +5 -2
- package/dist/activities/incident-telemetry-preflight.d.ts +10 -3
- package/dist/activities/knowledge-indexing.d.ts +19 -0
- package/dist/activities/mcp-account-routes.d.ts +2 -21
- package/dist/activities/model-call-fact-reconciler.d.ts +34 -0
- package/dist/activities/open-suffix-resume.d.ts +15 -0
- package/dist/activities/parent-wake.d.ts +17 -12
- package/dist/activities/programmatic-approvals.d.ts +10 -0
- package/dist/activities/requester-unavailable-receipt.d.ts +8 -0
- package/dist/activities/retained-screenshots.d.ts +7 -2
- package/dist/activities/run-credential-renewal.d.ts +1 -0
- package/dist/activities/run-credentials.d.ts +16 -4
- package/dist/activities/run-input.d.ts +17 -0
- package/dist/activities/sandbox-lease.d.ts +132 -12
- package/dist/activities/scheduled-tasks.d.ts +4 -35
- package/dist/activities/session-archive.d.ts +58 -0
- package/dist/activities/session-state.d.ts +15 -3
- package/dist/activities/session-storage.d.ts +44 -0
- package/dist/activities/subscription-core-claude-waits.d.ts +2 -0
- package/dist/activities/subscription-core-codex-quota.d.ts +25 -0
- package/dist/activities/subscription-core-codex-waits.d.ts +153 -0
- package/dist/activities/subscription-core-image-operation.d.ts +29 -0
- package/dist/activities/subscription-core-usage-recheck.d.ts +49 -0
- package/dist/activities/subscription-core-wait-bindings.d.ts +3 -0
- package/dist/activities/subscription-core-xai-quota.d.ts +30 -0
- package/dist/activities/subscription-core-xai-waits.d.ts +2 -0
- package/dist/activities/types.d.ts +68 -5
- package/dist/activities/video-generation-admission.d.ts +2 -8
- package/dist/activities/video-generation-credential.d.ts +15 -12
- package/dist/activities/video-generation-subscription-core.d.ts +70 -0
- package/dist/activities/workspace-capture.d.ts +2 -0
- package/dist/activities/workspace-credential-provider.d.ts +47 -0
- package/dist/activities/xai-auth.d.ts +6 -18
- package/dist/activities/xai-image-generation.d.ts +22 -6
- package/dist/{activities-control-QA6OLRQY.js → activities-control-NTXZHYET.js} +1552 -2876
- package/dist/activities-control-NTXZHYET.js.map +1 -0
- package/dist/activities-control.d.ts +64 -4
- package/dist/{activities-turn-YVVKCGAK.js → activities-turn-RKRI5GY4.js} +9238 -4392
- package/dist/activities-turn-RKRI5GY4.js.map +1 -0
- package/dist/activities.d.ts +64 -4
- package/dist/artifact-materializer-entry.js +104 -35
- package/dist/artifact-materializer-entry.js.map +1 -1
- package/dist/artifact-outbox-entry.js +132 -61
- package/dist/artifact-outbox-entry.js.map +1 -1
- package/dist/browser-deadline-checkpoint-contract.d.ts +2 -0
- package/dist/{chunk-GDCLDKSH.js → chunk-24GP3BX5.js} +79 -72
- package/dist/chunk-24GP3BX5.js.map +1 -0
- package/dist/{chunk-RAMNYSAW.js → chunk-4ER3YXOT.js} +22 -4
- package/dist/chunk-4ER3YXOT.js.map +1 -0
- package/dist/{chunk-I7HKKMUJ.js → chunk-5NNS4327.js} +734 -58
- package/dist/chunk-5NNS4327.js.map +1 -0
- package/dist/{chunk-M3NVMF2V.js → chunk-7BIHFUGB.js} +2293 -3956
- package/dist/chunk-7BIHFUGB.js.map +1 -0
- package/dist/chunk-MVESOYFC.js +3746 -0
- package/dist/chunk-MVESOYFC.js.map +1 -0
- package/dist/chunk-NQDVJ6RI.js +2823 -0
- package/dist/chunk-NQDVJ6RI.js.map +1 -0
- package/dist/chunk-O7UPBWXK.js +79 -0
- package/dist/chunk-O7UPBWXK.js.map +1 -0
- package/dist/chunk-W2QSM5HR.js +414 -0
- package/dist/chunk-W2QSM5HR.js.map +1 -0
- package/dist/chunk-ZN3XJR33.js +227 -0
- package/dist/chunk-ZN3XJR33.js.map +1 -0
- package/dist/editable-artifact-outbox-dispatcher.d.ts +12 -1
- package/dist/editable-artifact-outbox-service.d.ts +3 -1
- package/dist/host-export-pump.d.ts +3 -1
- package/dist/host-export.d.ts +2 -2
- package/dist/host-export.js +1 -1
- package/dist/http.d.ts +1 -1
- package/dist/index.d.ts +49 -48
- package/dist/index.js +835 -256
- package/dist/index.js.map +1 -1
- package/dist/internal-maintenance.d.ts +63 -0
- package/dist/maintenance-cadence.d.ts +43 -0
- package/dist/observability-metrics.d.ts +293 -24
- package/dist/onepassword-vault-provider.d.ts +7 -0
- package/dist/parent-wake-PCLH7A3Y.js +24 -0
- package/dist/parent-wake-PCLH7A3Y.js.map +1 -0
- package/dist/personal-github-git-credentials.d.ts +1 -1
- package/dist/readiness-checks.d.ts +39 -0
- package/dist/retained-process-retry.d.ts +7 -0
- package/dist/sandbox-lease-BJYU72N3.js +84 -0
- package/dist/sandbox-lease-BJYU72N3.js.map +1 -0
- package/dist/sandbox-reaper-contract.d.ts +25 -0
- package/dist/sandbox-resume.d.ts +72 -4
- package/dist/sandbox-routing.d.ts +4 -2
- package/dist/session-event-fanout.d.ts +6 -0
- package/dist/site-auth-maintenance-WK3MR2PV.js +12 -0
- package/dist/site-auth-maintenance-WK3MR2PV.js.map +1 -0
- package/dist/telemetry-scheduler.d.ts +14 -0
- package/dist/temporal-runtime-logger.d.ts +22 -0
- package/dist/turn-task-queue-reader.d.ts +18 -0
- package/dist/turn-worker-activity-telemetry.d.ts +47 -0
- package/dist/worker-service-lifecycle.d.ts +12 -0
- package/dist/workflow-bundle.js +468 -71
- package/dist/workflows/activities.d.ts +1 -1
- package/dist/workflows/browser-deadline-checkpoint.d.ts +10 -0
- package/dist/workflows/sandbox-reaper.d.ts +10 -1
- package/dist/workflows/scheduled-tasks.d.ts +4 -0
- package/dist/workflows/session-storage.d.ts +2 -0
- package/dist/workflows/session.d.ts +36 -0
- package/dist/workflows/site-auth-maintenance.d.ts +2 -1
- package/dist/workflows/workflow-wake.d.ts +14 -3
- package/dist/workflows.d.ts +3 -1
- package/package.json +26 -20
- package/src/activities/agent-run-admission.ts +1 -82
- package/src/activities/agent-turn/admission.ts +175 -24
- package/src/activities/agent-turn/agent-build.ts +226 -145
- package/src/activities/agent-turn/claim.ts +363 -64
- package/src/activities/agent-turn/claude-core.ts +587 -0
- package/src/activities/agent-turn/code-search.ts +275 -0
- package/src/activities/agent-turn/codex-capacity.ts +30 -757
- package/src/activities/agent-turn/codex-core-capacity.ts +190 -0
- package/src/activities/agent-turn/codex-core-claim.ts +83 -0
- package/src/activities/agent-turn/codex-core-errors.ts +308 -0
- package/src/activities/agent-turn/codex-core-failover.ts +73 -0
- package/src/activities/agent-turn/codex-core-requests.ts +86 -0
- package/src/activities/agent-turn/codex-core-settlement.ts +263 -0
- package/src/activities/agent-turn/codex-credit-policy.ts +247 -0
- package/src/activities/agent-turn/codex-plan-entitlement.ts +254 -0
- package/src/activities/agent-turn/codex-usage-policy.ts +2 -0
- package/src/activities/agent-turn/codex.ts +8 -76
- package/src/activities/agent-turn/compaction-interruption.ts +56 -0
- package/src/activities/agent-turn/compaction-prep.ts +249 -36
- package/src/activities/agent-turn/credential-leases.ts +269 -214
- package/src/activities/agent-turn/credential-restriction.ts +14 -0
- package/src/activities/agent-turn/errors.ts +1134 -82
- package/src/activities/agent-turn/failure-settlement.ts +879 -886
- package/src/activities/agent-turn/final-reply.ts +46 -0
- package/src/activities/agent-turn/finalization-monitor.ts +17 -5
- package/src/activities/agent-turn/finalization.ts +107 -88
- package/src/activities/agent-turn/github-repository-bindings.ts +3 -1
- package/src/activities/agent-turn/governance-model.ts +90 -22
- package/src/activities/agent-turn/history-sink.ts +26 -4
- package/src/activities/agent-turn/history.ts +25 -5
- package/src/activities/agent-turn/input-wait-reply.ts +139 -0
- package/src/activities/agent-turn/knowledge-source-tools.ts +2 -0
- package/src/activities/agent-turn/meaningful-output.ts +44 -0
- package/src/activities/agent-turn/media-artifacts.ts +3 -1
- package/src/activities/agent-turn/model-call-admission.ts +94 -0
- package/src/activities/agent-turn/model-usage.ts +299 -233
- package/src/activities/agent-turn/model-wire-dispatch.ts +27 -0
- package/src/activities/agent-turn/optional-repositories.ts +224 -0
- package/src/activities/agent-turn/prompt-tool-availability.ts +27 -0
- package/src/activities/agent-turn/provider-dispatch-barrier.ts +22 -0
- package/src/activities/agent-turn/provider-recovery-copy.ts +76 -0
- package/src/activities/agent-turn/provider-recovery-metrics.ts +64 -0
- package/src/activities/agent-turn/provider-recovery-policy.ts +25 -0
- package/src/activities/agent-turn/quiescence.ts +7 -7
- package/src/activities/agent-turn/recovery-warning.ts +6 -8
- package/src/activities/agent-turn/refresh-credentials.ts +44 -0
- package/src/activities/agent-turn/run-credentials.ts +124 -76
- package/src/activities/agent-turn/run.ts +501 -112
- package/src/activities/agent-turn/sandbox-establish.ts +152 -75
- package/src/activities/agent-turn/sandbox-provision.ts +54 -1
- package/src/activities/agent-turn/sandbox-route.ts +4 -1
- package/src/activities/agent-turn/sandbox-runtime.ts +319 -11
- package/src/activities/agent-turn/secret-resolver.ts +155 -0
- package/src/activities/agent-turn/session-title.ts +177 -12
- package/src/activities/agent-turn/session-usage-custody.ts +170 -0
- package/src/activities/agent-turn/skill-checkout.ts +111 -24
- package/src/activities/agent-turn/skill-install.ts +1 -1
- package/src/activities/agent-turn/skill-read.ts +374 -28
- package/src/activities/agent-turn/skill-save.ts +35 -7
- package/src/activities/agent-turn/skill-search.ts +9 -0
- package/src/activities/agent-turn/skill-selection.ts +4 -0
- package/src/activities/agent-turn/skill-tools.ts +208 -21
- package/src/activities/agent-turn/skill-transfer.ts +68 -23
- package/src/activities/agent-turn/stream-attempt.ts +599 -110
- package/src/activities/agent-turn/subscription-capacity-arming.ts +81 -0
- package/src/activities/agent-turn/subscription-core-capacity.ts +439 -0
- package/src/activities/agent-turn/subscription-core-failover.ts +229 -0
- package/src/activities/agent-turn/subscription-core-placed.ts +37 -0
- package/src/activities/agent-turn/subscription-core-requests.ts +271 -0
- package/src/activities/agent-turn/subscription-core-settlement.ts +234 -0
- package/src/activities/agent-turn/subscription-lease.ts +140 -0
- package/src/activities/agent-turn/subscription-serving-capacity.ts +195 -0
- package/src/activities/agent-turn/subscription-serving-catalog.ts +71 -0
- package/src/activities/agent-turn/subscription-serving-claim.ts +178 -0
- package/src/activities/agent-turn/subscription-serving-providers.ts +15 -0
- package/src/activities/agent-turn/tool-environment.ts +384 -292
- package/src/activities/agent-turn/tool-policy.ts +104 -4
- package/src/activities/agent-turn/tool-result-spill.ts +1 -0
- package/src/activities/agent-turn/turn-context.ts +124 -8
- package/src/activities/agent-turn/web-search.ts +431 -0
- package/src/activities/agent-turn/xai-core.ts +301 -0
- package/src/activities/automations.ts +81 -6
- package/src/activities/browser-deadline-checkpoint.ts +297 -0
- package/src/activities/capabilities.ts +53 -213
- package/src/activities/codemode-dispatcher.ts +236 -14
- package/src/activities/codex-capacity.ts +27 -380
- package/src/activities/codex-image-generation.ts +252 -42
- package/src/activities/common.ts +12 -0
- package/src/activities/connector-attachments.ts +3 -1
- package/src/activities/context-compaction.ts +162 -21
- package/src/activities/environment.ts +18 -106
- package/src/activities/gmail-files.ts +108 -0
- package/src/activities/goals.ts +120 -204
- package/src/activities/image-generation-operation.ts +1 -1
- package/src/activities/incident-telemetry-authority.ts +80 -50
- package/src/activities/incident-telemetry-preflight.ts +27 -15
- package/src/activities/knowledge-indexing.ts +287 -17
- package/src/activities/knowledge-source-sync.ts +10 -0
- package/src/activities/mcp-account-routes.ts +2 -124
- package/src/activities/model-call-fact-reconciler.ts +112 -0
- package/src/activities/open-suffix-resume.ts +122 -88
- package/src/activities/parent-wake.ts +89 -21
- package/src/activities/programmatic-approvals.ts +26 -0
- package/src/activities/requester-unavailable-receipt.ts +14 -0
- package/src/activities/retained-screenshots.ts +135 -24
- package/src/activities/run-credential-renewal.ts +13 -1
- package/src/activities/run-credentials.ts +61 -19
- package/src/activities/run-input.ts +116 -9
- package/src/activities/sandbox-lease.ts +1615 -73
- package/src/activities/scheduled-tasks.ts +758 -141
- package/src/activities/session-archive.ts +382 -0
- package/src/activities/session-state.ts +219 -10
- package/src/activities/session-storage.ts +124 -0
- package/src/activities/site-auth-maintenance.ts +5 -2
- package/src/activities/subscription-core-claude-waits.ts +49 -0
- package/src/activities/subscription-core-codex-quota.ts +46 -0
- package/src/activities/subscription-core-codex-waits.ts +488 -0
- package/src/activities/subscription-core-image-operation.ts +126 -0
- package/src/activities/subscription-core-usage-recheck.ts +146 -0
- package/src/activities/subscription-core-wait-bindings.ts +12 -0
- package/src/activities/subscription-core-xai-quota.ts +85 -0
- package/src/activities/subscription-core-xai-waits.ts +48 -0
- package/src/activities/types.ts +85 -9
- package/src/activities/video-generation-admission.ts +1 -36
- package/src/activities/video-generation-credential.ts +38 -56
- package/src/activities/video-generation-reconciliation.ts +150 -131
- package/src/activities/video-generation-subscription-core.ts +180 -0
- package/src/activities/workspace-capture.ts +13 -2
- package/src/activities/workspace-credential-provider.ts +302 -0
- package/src/activities/xai-auth.ts +34 -112
- package/src/activities/xai-image-generation.ts +84 -36
- package/src/activities-control.ts +8 -0
- package/src/activities-turn.ts +5 -0
- package/src/activities.ts +17 -0
- package/src/activity-services.ts +29 -4
- package/src/browser-deadline-checkpoint-contract.ts +5 -0
- package/src/editable-artifact-hint-broker.ts +3 -0
- package/src/editable-artifact-materializer-service.ts +79 -38
- package/src/editable-artifact-materializer-subprocess.ts +47 -2
- package/src/editable-artifact-outbox-dispatcher.ts +107 -46
- package/src/editable-artifact-outbox-service.ts +55 -25
- package/src/github-rest-mcp.ts +1 -1
- package/src/host-export-pump.ts +26 -4
- package/src/host-export.ts +4 -1
- package/src/http.ts +4 -2
- package/src/index.ts +222 -282
- package/src/internal-maintenance.ts +347 -0
- package/src/maintenance-cadence.ts +156 -0
- package/src/observability-metrics.ts +1173 -73
- package/src/onepassword-vault-provider.ts +11 -0
- package/src/personal-github-git-credentials.ts +3 -1
- package/src/pr-review-credentials.ts +1 -1
- package/src/readiness-checks.ts +113 -0
- package/src/retained-process-retry.ts +36 -0
- package/src/sandbox-reaper-contract.ts +33 -0
- package/src/sandbox-resume.ts +444 -73
- package/src/sandbox-routing.ts +230 -75
- package/src/session-event-fanout.ts +23 -0
- package/src/telemetry-scheduler.ts +53 -0
- package/src/temporal-runtime-logger.ts +44 -0
- package/src/turn-task-queue-reader.ts +110 -0
- package/src/turn-worker-activity-telemetry.ts +209 -0
- package/src/worker-service-lifecycle.ts +54 -1
- package/src/workflows/activities.ts +16 -1
- package/src/workflows/browser-deadline-checkpoint.ts +55 -0
- package/src/workflows/file-upload-reaper.ts +2 -0
- package/src/workflows/sandbox-reaper.ts +88 -0
- package/src/workflows/scheduled-tasks.ts +26 -13
- package/src/workflows/session-storage.ts +19 -0
- package/src/workflows/session.ts +238 -33
- package/src/workflows/site-auth-maintenance.ts +2 -1
- package/src/workflows/workflow-wake.ts +26 -4
- package/src/workflows.ts +7 -0
- package/dist/activities/agent-turn/xai-capacity.d.ts +0 -2
- package/dist/activities/codex-fleet-shadow.d.ts +0 -74
- package/dist/activities/codex-rotation.d.ts +0 -200
- package/dist/activities/xai-quota.d.ts +0 -3
- package/dist/activities-control-QA6OLRQY.js.map +0 -1
- package/dist/activities-turn-YVVKCGAK.js.map +0 -1
- package/dist/chunk-GDCLDKSH.js.map +0 -1
- package/dist/chunk-I7HKKMUJ.js.map +0 -1
- package/dist/chunk-M3NVMF2V.js.map +0 -1
- package/dist/chunk-RAMNYSAW.js.map +0 -1
- package/src/activities/agent-turn/xai-capacity.ts +0 -257
- package/src/activities/codex-fleet-shadow.ts +0 -306
- package/src/activities/codex-rotation.ts +0 -685
- package/src/activities/xai-quota.ts +0 -35
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { canonicalizeConfiguredModelId } from "@opengeni/config";
|
|
1
2
|
import {
|
|
2
|
-
|
|
3
|
-
recordUsageEvent,
|
|
3
|
+
isStoredVerbatimAsLosslessJsonString,
|
|
4
4
|
recordModelCallFact,
|
|
5
5
|
type AppendEventInput,
|
|
6
6
|
type CanonicalTurnStartupMilestoneReceipt,
|
|
@@ -14,14 +14,9 @@ import {
|
|
|
14
14
|
type ModelCallUsageNormalization,
|
|
15
15
|
} from "@opengeni/runtime";
|
|
16
16
|
import {
|
|
17
|
-
|
|
18
|
-
calculateGatewayReportedProviderCostMicros,
|
|
19
|
-
calculateModelUsageCostBreakdown,
|
|
20
|
-
configuredModelPricingSchedules,
|
|
21
|
-
resolveModelProvider,
|
|
17
|
+
configuredModels,
|
|
22
18
|
responseSatisfiesLatencyMode,
|
|
23
|
-
|
|
24
|
-
WORKSPACE_GATEWAY_PROVIDER_ID,
|
|
19
|
+
WORKSPACE_GATEWAY_MODEL_ID_PREFIX,
|
|
25
20
|
type ModelUsageInput,
|
|
26
21
|
type ModelProviderApi,
|
|
27
22
|
type Settings,
|
|
@@ -32,7 +27,9 @@ import {
|
|
|
32
27
|
modelCallAccountContext,
|
|
33
28
|
recordCreditMicros,
|
|
34
29
|
recordModelCacheTokens,
|
|
30
|
+
recordModelCreditsCharged,
|
|
35
31
|
recordModelInputTokens,
|
|
32
|
+
recordModelResponseUsage,
|
|
36
33
|
} from "../../observability-metrics";
|
|
37
34
|
import {
|
|
38
35
|
type LatencyMode,
|
|
@@ -40,6 +37,16 @@ import {
|
|
|
40
37
|
type SessionEvent,
|
|
41
38
|
} from "@opengeni/contracts";
|
|
42
39
|
import { safeErrorDiagnostic } from "./errors";
|
|
40
|
+
import {
|
|
41
|
+
holdSessionUsageReceipt,
|
|
42
|
+
releaseHeldSessionUsageReceiptMeteredByEvent,
|
|
43
|
+
} from "./session-usage-custody";
|
|
44
|
+
import {
|
|
45
|
+
sanitizedModelUsageInput,
|
|
46
|
+
sessionUsageMeterAmountMicros,
|
|
47
|
+
settleModelUsage,
|
|
48
|
+
type ModelUsageBillingRecord,
|
|
49
|
+
} from "@opengeni/core";
|
|
43
50
|
|
|
44
51
|
export function modelUsageSourceKey(input: {
|
|
45
52
|
responseId?: string | null | undefined;
|
|
@@ -52,6 +59,27 @@ export function modelUsageSourceKey(input: {
|
|
|
52
59
|
return input.dispatchId ? `${input.dispatchId}:${input.positionalKey}` : input.positionalKey;
|
|
53
60
|
}
|
|
54
61
|
|
|
62
|
+
/** Legacy aggregate usage may only debit a policy shared by its completed calls. */
|
|
63
|
+
export function aggregateCreditPolicyRevision(input: {
|
|
64
|
+
responseRevisions: ReadonlySet<number | undefined>;
|
|
65
|
+
lastAdmittedRevision: number | undefined;
|
|
66
|
+
chargesOpenGeniCredits: boolean;
|
|
67
|
+
totalTokens: number | null;
|
|
68
|
+
}): number | undefined {
|
|
69
|
+
if (
|
|
70
|
+
input.chargesOpenGeniCredits &&
|
|
71
|
+
input.responseRevisions.size > 1 &&
|
|
72
|
+
(input.totalTokens ?? 0) > 0
|
|
73
|
+
) {
|
|
74
|
+
throw new Error("Aggregate model usage spans different credit policy revisions");
|
|
75
|
+
}
|
|
76
|
+
// Bind the completed response, even if later preparation changed admission.
|
|
77
|
+
// Older runtimes without response callbacks retain their admitted snapshot.
|
|
78
|
+
return input.responseRevisions.size === 1
|
|
79
|
+
? input.responseRevisions.values().next().value
|
|
80
|
+
: input.lastAdmittedRevision;
|
|
81
|
+
}
|
|
82
|
+
|
|
55
83
|
export function providerContextTokens(
|
|
56
84
|
usage:
|
|
57
85
|
| {
|
|
@@ -109,6 +137,15 @@ export type CompactionModelUsageEventState = {
|
|
|
109
137
|
claimedSourceKeys: Set<string>;
|
|
110
138
|
};
|
|
111
139
|
|
|
140
|
+
/**
|
|
141
|
+
* Why the worker made a model call. The durable `agent.model.usage` payload
|
|
142
|
+
* records it so a reader can tell the turn's own inference (`main`, including
|
|
143
|
+
* the aggregate billing fallback) from the auxiliary context summarizer and
|
|
144
|
+
* session-title calls. Only the worker sets it, at the call site; it changes no
|
|
145
|
+
* source key, billing, credit, idempotency or metric label.
|
|
146
|
+
*/
|
|
147
|
+
export type ModelCallPurpose = "main" | "compaction" | "session-title";
|
|
148
|
+
|
|
112
149
|
export function createModelResponseEventState(
|
|
113
150
|
claimedSourceKeys: Set<string> = new Set<string>(),
|
|
114
151
|
): ModelResponseEventState {
|
|
@@ -206,8 +243,11 @@ export async function processModelResponseTerminalEvent(input: {
|
|
|
206
243
|
externallyBilled: boolean;
|
|
207
244
|
chargesOpenGeniCredits?: boolean;
|
|
208
245
|
countsTowardTokenCap?: boolean;
|
|
246
|
+
creditPolicyRevision?: number | undefined;
|
|
209
247
|
servingCredentialId: string | null;
|
|
210
248
|
priorSessionCredentialId: string | null;
|
|
249
|
+
/** The shared-core subscription connection that served the call (billing attribution). */
|
|
250
|
+
subscriptionConnectionId?: string | null;
|
|
211
251
|
emittedSourceKeys: Set<string>;
|
|
212
252
|
renewLease: () => Promise<void>;
|
|
213
253
|
leaseLost: () => boolean;
|
|
@@ -228,6 +268,15 @@ export async function processModelResponseTerminalEvent(input: {
|
|
|
228
268
|
if (!terminal) {
|
|
229
269
|
return { status: "not_response" };
|
|
230
270
|
}
|
|
271
|
+
// Some providers mirror a terminal response before normalized usage arrives.
|
|
272
|
+
// Claiming that empty raw mirror would discard the SDK's billable response.
|
|
273
|
+
if (
|
|
274
|
+
!terminal.usage &&
|
|
275
|
+
input.event.type === "raw_model_stream_event" &&
|
|
276
|
+
input.event.data.type !== "response_done"
|
|
277
|
+
) {
|
|
278
|
+
return { status: "not_response" };
|
|
279
|
+
}
|
|
231
280
|
|
|
232
281
|
const responseOrdinal = input.state.responseCount + 1;
|
|
233
282
|
const sourceKey = modelUsageSourceKey({
|
|
@@ -265,6 +314,7 @@ export async function processModelResponseTerminalEvent(input: {
|
|
|
265
314
|
turnId: input.turnId,
|
|
266
315
|
turnAttemptId: input.turnAttemptId,
|
|
267
316
|
model: input.model,
|
|
317
|
+
creditPolicyRevision: input.creditPolicyRevision,
|
|
268
318
|
externallyBilled: input.externallyBilled,
|
|
269
319
|
...(input.chargesOpenGeniCredits !== undefined
|
|
270
320
|
? { chargesOpenGeniCredits: input.chargesOpenGeniCredits }
|
|
@@ -278,6 +328,7 @@ export async function processModelResponseTerminalEvent(input: {
|
|
|
278
328
|
sourceKey,
|
|
279
329
|
...(input.latencyMode ? { latencyMode: input.latencyMode } : {}),
|
|
280
330
|
observability: input.observability,
|
|
331
|
+
metricProvider: input.provider,
|
|
281
332
|
});
|
|
282
333
|
authoritative = await emitModelCallUsage({
|
|
283
334
|
observability: input.observability,
|
|
@@ -289,10 +340,12 @@ export async function processModelResponseTerminalEvent(input: {
|
|
|
289
340
|
provider: input.provider,
|
|
290
341
|
providerApi: input.providerApi,
|
|
291
342
|
model: input.model,
|
|
343
|
+
purpose: "main",
|
|
292
344
|
sourceKey,
|
|
293
345
|
usage: responseUsage,
|
|
294
346
|
normalizedUsage,
|
|
295
347
|
...(billing ? { billingPath: billing.billingPath } : {}),
|
|
348
|
+
...(billing ? { billingSnapshot: billing } : {}),
|
|
296
349
|
...(billing?.upstreamProvider ? { upstreamProvider: billing.upstreamProvider } : {}),
|
|
297
350
|
servingAccountHash: accountContext.servingAccountHash,
|
|
298
351
|
accountChangedFromPrevCall: accountContext.accountChangedFromPrevCall,
|
|
@@ -312,10 +365,20 @@ export async function processModelResponseTerminalEvent(input: {
|
|
|
312
365
|
providerApi: input.providerApi,
|
|
313
366
|
model: input.model,
|
|
314
367
|
billing,
|
|
368
|
+
subscriptionConnectionId: input.subscriptionConnectionId ?? null,
|
|
315
369
|
...(input.contextContributions !== undefined
|
|
316
370
|
? { contextContributions: input.contextContributions }
|
|
317
371
|
: {}),
|
|
318
372
|
});
|
|
373
|
+
recordAuthoritativeModelUsageMetrics({
|
|
374
|
+
observability: input.observability,
|
|
375
|
+
settings: input.settings,
|
|
376
|
+
provider: input.provider,
|
|
377
|
+
model: input.model,
|
|
378
|
+
externallyBilled: input.externallyBilled,
|
|
379
|
+
billing,
|
|
380
|
+
webSearchRequests: responseUsage?.webSearchRequests,
|
|
381
|
+
});
|
|
319
382
|
}
|
|
320
383
|
const observedInput = normalizedUsage.telemetry.inputTokens;
|
|
321
384
|
if (authoritative && observedInput !== null && observedInput > 0) {
|
|
@@ -324,12 +387,15 @@ export async function processModelResponseTerminalEvent(input: {
|
|
|
324
387
|
},
|
|
325
388
|
recordAttemptSignals: async () => {
|
|
326
389
|
if (!authoritative) return;
|
|
327
|
-
|
|
390
|
+
// Context is what the last request sent, not the sum of a response that
|
|
391
|
+
// took several requests (each re-sends the whole prefix).
|
|
392
|
+
const finalRequest = normalizedUsage.requestUsageEntries?.at(-1);
|
|
393
|
+
const observedTotal = finalRequest?.totalTokens ?? normalizedUsage.totalTokens;
|
|
328
394
|
input.state.contextSignal =
|
|
329
395
|
observedTotal !== null && observedTotal > 0
|
|
330
396
|
? { revision: responseOrdinal, totalTokens: observedTotal }
|
|
331
397
|
: null;
|
|
332
|
-
const observedInput = normalizedUsage.telemetry.inputTokens;
|
|
398
|
+
const observedInput = finalRequest?.inputTokens ?? normalizedUsage.telemetry.inputTokens;
|
|
333
399
|
await input.setLastInputTokens(
|
|
334
400
|
observedInput !== null && observedInput > 0 ? observedInput : null,
|
|
335
401
|
);
|
|
@@ -353,7 +419,7 @@ export async function processModelResponseTerminalEvent(input: {
|
|
|
353
419
|
export async function processCompactionModelUsageEvent(input: {
|
|
354
420
|
usage: ModelResponseUsage;
|
|
355
421
|
state: CompactionModelUsageEventState;
|
|
356
|
-
sourceKind?:
|
|
422
|
+
sourceKind?: Exclude<ModelCallPurpose, "main">;
|
|
357
423
|
dispatchId: string | null;
|
|
358
424
|
settings: Settings;
|
|
359
425
|
db: ActivityServices["db"];
|
|
@@ -370,8 +436,11 @@ export async function processCompactionModelUsageEvent(input: {
|
|
|
370
436
|
externallyBilled: boolean;
|
|
371
437
|
chargesOpenGeniCredits?: boolean;
|
|
372
438
|
countsTowardTokenCap?: boolean;
|
|
439
|
+
creditPolicyRevision?: number | undefined;
|
|
373
440
|
servingCredentialId: string | null;
|
|
374
441
|
priorSessionCredentialId: string | null;
|
|
442
|
+
/** The shared-core subscription connection that served the call (billing attribution). */
|
|
443
|
+
subscriptionConnectionId?: string | null;
|
|
375
444
|
emittedSourceKeys: Set<string>;
|
|
376
445
|
renewLease: () => Promise<void>;
|
|
377
446
|
leaseLost: () => boolean;
|
|
@@ -381,11 +450,12 @@ export async function processCompactionModelUsageEvent(input: {
|
|
|
381
450
|
| { status: "duplicate"; sourceKey: string }
|
|
382
451
|
| { status: "processed"; sourceKey: string; authoritative: boolean }
|
|
383
452
|
> {
|
|
453
|
+
const purpose = input.sourceKind ?? "compaction";
|
|
384
454
|
const usageOrdinal = input.state.usageCount + 1;
|
|
385
455
|
const sourceKey = modelUsageSourceKey({
|
|
386
456
|
responseId: input.usage.responseId,
|
|
387
457
|
dispatchId: input.dispatchId,
|
|
388
|
-
positionalKey: `${
|
|
458
|
+
positionalKey: `${purpose}-${usageOrdinal}`,
|
|
389
459
|
});
|
|
390
460
|
if (input.state.claimedSourceKeys.has(sourceKey)) {
|
|
391
461
|
return { status: "duplicate", sourceKey };
|
|
@@ -412,6 +482,7 @@ export async function processCompactionModelUsageEvent(input: {
|
|
|
412
482
|
turnId: input.turnId,
|
|
413
483
|
turnAttemptId: input.turnAttemptId,
|
|
414
484
|
model: input.model,
|
|
485
|
+
creditPolicyRevision: input.creditPolicyRevision,
|
|
415
486
|
externallyBilled: input.externallyBilled,
|
|
416
487
|
...(input.chargesOpenGeniCredits !== undefined
|
|
417
488
|
? { chargesOpenGeniCredits: input.chargesOpenGeniCredits }
|
|
@@ -424,6 +495,7 @@ export async function processCompactionModelUsageEvent(input: {
|
|
|
424
495
|
gatewayBilling: input.usage.gatewayBilling,
|
|
425
496
|
sourceKey,
|
|
426
497
|
observability: input.observability,
|
|
498
|
+
metricProvider: input.provider,
|
|
427
499
|
});
|
|
428
500
|
authoritative = await emitModelCallUsage({
|
|
429
501
|
observability: input.observability,
|
|
@@ -435,10 +507,12 @@ export async function processCompactionModelUsageEvent(input: {
|
|
|
435
507
|
provider: input.provider,
|
|
436
508
|
providerApi: input.providerApi,
|
|
437
509
|
model: input.model,
|
|
510
|
+
purpose,
|
|
438
511
|
sourceKey,
|
|
439
512
|
usage: input.usage,
|
|
440
513
|
normalizedUsage,
|
|
441
514
|
...(billing ? { billingPath: billing.billingPath } : {}),
|
|
515
|
+
...(billing ? { billingSnapshot: billing } : {}),
|
|
442
516
|
...(billing?.upstreamProvider ? { upstreamProvider: billing.upstreamProvider } : {}),
|
|
443
517
|
servingAccountHash: accountContext.servingAccountHash,
|
|
444
518
|
accountChangedFromPrevCall: accountContext.accountChangedFromPrevCall,
|
|
@@ -458,10 +532,19 @@ export async function processCompactionModelUsageEvent(input: {
|
|
|
458
532
|
providerApi: input.providerApi,
|
|
459
533
|
model: input.model,
|
|
460
534
|
billing,
|
|
535
|
+
subscriptionConnectionId: input.subscriptionConnectionId ?? null,
|
|
461
536
|
...(input.contextContributions !== undefined
|
|
462
537
|
? { contextContributions: input.contextContributions }
|
|
463
538
|
: {}),
|
|
464
539
|
});
|
|
540
|
+
recordAuthoritativeModelUsageMetrics({
|
|
541
|
+
observability: input.observability,
|
|
542
|
+
settings: input.settings,
|
|
543
|
+
provider: input.provider,
|
|
544
|
+
model: input.model,
|
|
545
|
+
externallyBilled: input.externallyBilled,
|
|
546
|
+
billing,
|
|
547
|
+
});
|
|
465
548
|
}
|
|
466
549
|
},
|
|
467
550
|
});
|
|
@@ -487,11 +570,23 @@ export async function emitModelCallUsage(input: {
|
|
|
487
570
|
provider: string;
|
|
488
571
|
providerApi: ModelProviderApi;
|
|
489
572
|
model: string;
|
|
573
|
+
/** Why the worker made this call; durable event and log line only, never a metric label. */
|
|
574
|
+
purpose: ModelCallPurpose;
|
|
490
575
|
sourceKey: string;
|
|
491
576
|
usage: ModelResponseUsage | { usage?: unknown | null } | null;
|
|
492
577
|
normalizedUsage?: ModelCallUsageNormalization;
|
|
493
578
|
/** Accepted billing authority persisted for Insights repair after a soft fact-write failure. */
|
|
494
579
|
billingPath?: ModelUsageBillingRecord["billingPath"];
|
|
580
|
+
/** Accepted comparisons are frozen with the event, not repriced during fact repair. */
|
|
581
|
+
billingSnapshot?: Pick<
|
|
582
|
+
ModelUsageBillingRecord,
|
|
583
|
+
| "pricedCostMicros"
|
|
584
|
+
| "estimatedProviderCostMicros"
|
|
585
|
+
| "equivalentCreditCostMicros"
|
|
586
|
+
| "pricingSource"
|
|
587
|
+
| "listByClassMicros"
|
|
588
|
+
| "listByClassApprox"
|
|
589
|
+
>;
|
|
495
590
|
/** Validated Gateway endpoint provider persisted for exact Insights repair. */
|
|
496
591
|
upstreamProvider?: string;
|
|
497
592
|
// Prompt-cache research dimensions (log-only; NEVER on a metric label or a
|
|
@@ -524,9 +619,20 @@ export async function emitModelCallUsage(input: {
|
|
|
524
619
|
provider: input.provider,
|
|
525
620
|
providerApi: input.providerApi,
|
|
526
621
|
model: input.model,
|
|
622
|
+
purpose: input.purpose,
|
|
527
623
|
sourceKey: input.sourceKey,
|
|
528
624
|
...(input.billingPath ? { billingPath: input.billingPath } : {}),
|
|
529
625
|
...(input.upstreamProvider ? { upstreamProvider: input.upstreamProvider } : {}),
|
|
626
|
+
...(input.billingSnapshot
|
|
627
|
+
? {
|
|
628
|
+
pricedCostMicros: input.billingSnapshot.pricedCostMicros,
|
|
629
|
+
estimatedProviderCostMicros: input.billingSnapshot.estimatedProviderCostMicros,
|
|
630
|
+
equivalentCreditCostMicros: input.billingSnapshot.equivalentCreditCostMicros,
|
|
631
|
+
pricingSource: input.billingSnapshot.pricingSource,
|
|
632
|
+
listByClassMicros: input.billingSnapshot.listByClassMicros ?? null,
|
|
633
|
+
listByClassApprox: input.billingSnapshot.listByClassApprox ?? false,
|
|
634
|
+
}
|
|
635
|
+
: {}),
|
|
530
636
|
...telemetry,
|
|
531
637
|
},
|
|
532
638
|
},
|
|
@@ -543,11 +649,13 @@ export async function emitModelCallUsage(input: {
|
|
|
543
649
|
(event.payload as Record<string, unknown>).sourceKey === input.sourceKey,
|
|
544
650
|
);
|
|
545
651
|
if (!authoritative) return false;
|
|
652
|
+
releaseReceiptMeteredByCommittedEvent(input, telemetry);
|
|
546
653
|
try {
|
|
547
654
|
input.observability.info("model call usage", {
|
|
548
655
|
provider: input.provider,
|
|
549
656
|
providerApi: input.providerApi,
|
|
550
657
|
model: input.model,
|
|
658
|
+
purpose: input.purpose,
|
|
551
659
|
inputTokens: telemetry.inputTokens,
|
|
552
660
|
outputTokens: telemetry.outputTokens,
|
|
553
661
|
cachedTokens: telemetry.cachedTokens,
|
|
@@ -579,6 +687,63 @@ export async function emitModelCallUsage(input: {
|
|
|
579
687
|
return true;
|
|
580
688
|
}
|
|
581
689
|
|
|
690
|
+
const METERED_PRICING_SOURCES = new Set(["configured_list_price", "gateway_reported"]);
|
|
691
|
+
const MAX_METERED_SOURCE_KEY_BYTES = 1024;
|
|
692
|
+
|
|
693
|
+
/**
|
|
694
|
+
* The committed `agent.model.usage` event metered this call's task usage in
|
|
695
|
+
* its own transaction (the database trigger applies `<turnId>:<sourceKey>`
|
|
696
|
+
* with the payload's amount; a failure would have rolled the event back).
|
|
697
|
+
* Drop a held receipt for that identity when the event carried exactly its
|
|
698
|
+
* amount, mirroring the trigger's acceptance rules conservatively: anything
|
|
699
|
+
* the trigger might value differently keeps the hold for the direct write.
|
|
700
|
+
* A source key the lossless codec stores encoded (NUL, a lone surrogate, the
|
|
701
|
+
* codec prefix) reaches the trigger as a different string and identity, so it
|
|
702
|
+
* never counts as metered here: the hold stays and fails closed.
|
|
703
|
+
*/
|
|
704
|
+
function releaseReceiptMeteredByCommittedEvent(
|
|
705
|
+
input: {
|
|
706
|
+
sessionId: string;
|
|
707
|
+
turnId: string;
|
|
708
|
+
sourceKey: string;
|
|
709
|
+
billingSnapshot?: Pick<
|
|
710
|
+
ModelUsageBillingRecord,
|
|
711
|
+
"estimatedProviderCostMicros" | "pricingSource"
|
|
712
|
+
>;
|
|
713
|
+
},
|
|
714
|
+
telemetry: { inputTokens?: number | null; outputTokens?: number | null },
|
|
715
|
+
): void {
|
|
716
|
+
if (!isStoredVerbatimAsLosslessJsonString(input.sourceKey)) return;
|
|
717
|
+
const keyBytes = new TextEncoder().encode(input.sourceKey).byteLength;
|
|
718
|
+
if (keyBytes < 1 || keyBytes > MAX_METERED_SOURCE_KEY_BYTES) return;
|
|
719
|
+
const estimated = input.billingSnapshot?.estimatedProviderCostMicros ?? null;
|
|
720
|
+
const pricingSource = input.billingSnapshot?.pricingSource ?? null;
|
|
721
|
+
const tokens = (value: number | null | undefined) =>
|
|
722
|
+
typeof value === "number" && Number.isSafeInteger(value) && value >= 0 && value < 1e15
|
|
723
|
+
? value
|
|
724
|
+
: null;
|
|
725
|
+
const eventAmount =
|
|
726
|
+
estimated !== null &&
|
|
727
|
+
Number.isSafeInteger(estimated) &&
|
|
728
|
+
estimated >= 0 &&
|
|
729
|
+
estimated < 1e16 &&
|
|
730
|
+
pricingSource !== null &&
|
|
731
|
+
METERED_PRICING_SOURCES.has(pricingSource)
|
|
732
|
+
? sessionUsageMeterAmountMicros({
|
|
733
|
+
estimatedProviderCostMicros: estimated,
|
|
734
|
+
gatewayReported: pricingSource === "gateway_reported",
|
|
735
|
+
inputTokens: tokens(telemetry.inputTokens),
|
|
736
|
+
outputTokens: tokens(telemetry.outputTokens),
|
|
737
|
+
})
|
|
738
|
+
: null;
|
|
739
|
+
releaseHeldSessionUsageReceiptMeteredByEvent({
|
|
740
|
+
sessionId: input.sessionId,
|
|
741
|
+
sourceId: `${input.turnId}:${input.sourceKey}`,
|
|
742
|
+
amountMicros: eventAmount,
|
|
743
|
+
pricingSource: eventAmount === null ? null : pricingSource,
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
|
|
582
747
|
/**
|
|
583
748
|
* Apply one authoritative, normalized model-call usage frame to the shared
|
|
584
749
|
* prompt-cache metrics. The durable source-key fence in `emitModelCallUsage`
|
|
@@ -596,18 +761,8 @@ export function applyCodexCacheTelemetry(
|
|
|
596
761
|
});
|
|
597
762
|
}
|
|
598
763
|
|
|
599
|
-
export type ModelUsageBillingRecord
|
|
600
|
-
|
|
601
|
-
/** Same quantity written to usage_events.model.cost when present; else 0. */
|
|
602
|
-
pricedCostMicros: number;
|
|
603
|
-
/** Hypothetical provider-rate USD micros; never an OpenGeni charge. */
|
|
604
|
-
estimatedProviderCostMicros: number | null;
|
|
605
|
-
/** Hypothetical OpenGeni credit price at the captured rate; never a debit. */
|
|
606
|
-
equivalentCreditCostMicros: number | null;
|
|
607
|
-
pricingSource: "configured_list_price" | "gateway_reported" | null;
|
|
608
|
-
normalizedUsage: ModelCallUsageNormalization;
|
|
609
|
-
upstreamProvider?: string;
|
|
610
|
-
};
|
|
764
|
+
export type { ModelUsageBillingRecord };
|
|
765
|
+
export { sanitizedModelUsageInput };
|
|
611
766
|
|
|
612
767
|
// Exported for unit testing the external-billing bypass; not part of the activity surface.
|
|
613
768
|
export async function recordModelUsageAndDebitCredits(
|
|
@@ -623,205 +778,130 @@ export async function recordModelUsageAndDebitCredits(
|
|
|
623
778
|
externallyBilled: boolean;
|
|
624
779
|
chargesOpenGeniCredits?: boolean;
|
|
625
780
|
countsTowardTokenCap?: boolean;
|
|
781
|
+
creditPolicyRevision?: number | undefined;
|
|
626
782
|
gatewayBilling?: ModelResponseUsage["gatewayBilling"];
|
|
627
783
|
usage?: ModelUsageInput | ModelCallUsageInput | null;
|
|
628
784
|
normalizedUsage?: ModelCallUsageNormalization;
|
|
629
785
|
sourceKey: string;
|
|
630
786
|
latencyMode?: LatencyMode;
|
|
631
787
|
observability?: ActivityServices["observability"];
|
|
788
|
+
/** Configured provider id for metric labels; never billing authority. */
|
|
789
|
+
metricProvider?: string;
|
|
632
790
|
},
|
|
633
791
|
): Promise<ModelUsageBillingRecord | null> {
|
|
634
792
|
if (!input.usage) {
|
|
635
793
|
return null;
|
|
636
794
|
}
|
|
637
|
-
|
|
638
|
-
const sanitizedUsage = sanitizedModelUsageInput(normalizedUsage);
|
|
639
|
-
const inputTokens = sanitizedUsage.inputTokens ?? 0;
|
|
640
|
-
const outputTokens = sanitizedUsage.outputTokens ?? 0;
|
|
641
|
-
const totalTokens = sanitizedUsage.totalTokens ?? 0;
|
|
642
|
-
const chargesOpenGeniCredits = input.chargesOpenGeniCredits ?? !input.externallyBilled;
|
|
643
|
-
const countsTowardTokenCap = input.countsTowardTokenCap ?? !input.externallyBilled;
|
|
644
|
-
const resolvedGatewayModel = input.gatewayBilling
|
|
645
|
-
? resolveModelProvider(settings, input.model)
|
|
646
|
-
: undefined;
|
|
647
|
-
const gatewayProviderId = resolvedGatewayModel?.provider.id;
|
|
648
|
-
const gatewayBilling =
|
|
649
|
-
gatewayProviderId === OPENGENI_GATEWAY_PROVIDER_ID ||
|
|
650
|
-
gatewayProviderId === WORKSPACE_GATEWAY_PROVIDER_ID
|
|
651
|
-
? input.gatewayBilling
|
|
652
|
-
: undefined;
|
|
653
|
-
const allowedProviders = resolvedGatewayModel?.model.requestPolicy?.gateway.only;
|
|
654
|
-
const unpinnedWorkspaceGatewayModel =
|
|
655
|
-
gatewayProviderId === WORKSPACE_GATEWAY_PROVIDER_ID && allowedProviders === undefined;
|
|
656
|
-
if (gatewayBilling) {
|
|
657
|
-
if (
|
|
658
|
-
!unpinnedWorkspaceGatewayModel &&
|
|
659
|
-
(!allowedProviders ||
|
|
660
|
-
!(allowedProviders as readonly string[]).includes(gatewayBilling.finalProvider))
|
|
661
|
-
) {
|
|
662
|
-
throw new Error(
|
|
663
|
-
`AI Gateway reported unapproved provider ${gatewayBilling.finalProvider} for ${input.model}`,
|
|
664
|
-
);
|
|
665
|
-
}
|
|
666
|
-
if (unpinnedWorkspaceGatewayModel && chargesOpenGeniCredits) {
|
|
667
|
-
throw new Error(
|
|
668
|
-
`Workspace Gateway custom model ${input.model} cannot charge OpenGeni credits without pinned pricing`,
|
|
669
|
-
);
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
const pricingSchedules = configuredModelPricingSchedules(settings);
|
|
673
|
-
const configuredPricingModel = pricingSchedules[input.model]
|
|
674
|
-
? input.model
|
|
675
|
-
: input.model.startsWith("codex/") && pricingSchedules[input.model.slice("codex/".length)]
|
|
676
|
-
? input.model.slice("codex/".length)
|
|
677
|
-
: null;
|
|
678
|
-
const pricingBreakdown = gatewayBilling
|
|
679
|
-
? unpinnedWorkspaceGatewayModel
|
|
680
|
-
? {
|
|
681
|
-
providerCostMicros: calculateGatewayReportedProviderCostMicros(
|
|
682
|
-
gatewayBilling.inferenceCostUsd,
|
|
683
|
-
),
|
|
684
|
-
creditCostMicros: 0,
|
|
685
|
-
}
|
|
686
|
-
: calculateGatewayReportedCostBreakdown(
|
|
687
|
-
settings,
|
|
688
|
-
configuredPricingModel ?? input.model,
|
|
689
|
-
gatewayBilling.inferenceCostUsd,
|
|
690
|
-
{ inputTokens },
|
|
691
|
-
)
|
|
692
|
-
: configuredPricingModel
|
|
693
|
-
? calculateModelUsageCostBreakdown(settings, configuredPricingModel, sanitizedUsage, {
|
|
694
|
-
latencyMode: input.latencyMode ?? "standard",
|
|
695
|
-
})
|
|
696
|
-
: null;
|
|
697
|
-
const hasCompleteCoreTokenTelemetry =
|
|
698
|
-
normalizedUsage.telemetry.inputTokens !== null &&
|
|
699
|
-
normalizedUsage.telemetry.outputTokens !== null;
|
|
700
|
-
const estimatedProviderCostMicros = gatewayBilling
|
|
701
|
-
? (pricingBreakdown?.providerCostMicros ?? null)
|
|
702
|
-
: hasCompleteCoreTokenTelemetry
|
|
703
|
-
? (pricingBreakdown?.providerCostMicros ?? null)
|
|
704
|
-
: null;
|
|
705
|
-
const equivalentCreditCostMicros =
|
|
706
|
-
pricingBreakdown && !unpinnedWorkspaceGatewayModel
|
|
707
|
-
? gatewayBilling || hasCompleteCoreTokenTelemetry
|
|
708
|
-
? pricingBreakdown.creditCostMicros
|
|
709
|
-
: null
|
|
710
|
-
: null;
|
|
711
|
-
const pricingSource = gatewayBilling
|
|
712
|
-
? ("gateway_reported" as const)
|
|
713
|
-
: estimatedProviderCostMicros !== null
|
|
714
|
-
? ("configured_list_price" as const)
|
|
715
|
-
: null;
|
|
716
|
-
// Provider settlement and workspace-facing cost are separate. Externally
|
|
717
|
-
// metered subscription/workspace turns remain exempt from the OpenGeni token
|
|
718
|
-
// cap, while a deployment-funded free model still records model.tokens. Every
|
|
719
|
-
// non-credit path records a zero-cost marker and never consults pricing for a
|
|
720
|
-
// debit.
|
|
721
|
-
if (countsTowardTokenCap && totalTokens > 0) {
|
|
722
|
-
await recordUsageEvent(db, {
|
|
723
|
-
accountId: input.accountId,
|
|
724
|
-
workspaceId: input.workspaceId,
|
|
725
|
-
eventType: "model.tokens",
|
|
726
|
-
quantity: totalTokens,
|
|
727
|
-
unit: "tokens",
|
|
728
|
-
sourceResourceType: "model_response",
|
|
729
|
-
sourceResourceId: `${input.turnId}:${input.sourceKey}`,
|
|
730
|
-
sessionId: input.sessionId,
|
|
731
|
-
turnId: input.turnId,
|
|
732
|
-
turnAttemptId: input.turnAttemptId,
|
|
733
|
-
idempotencyKey: `usage:model.tokens:${input.turnId}:${input.sourceKey}`,
|
|
734
|
-
});
|
|
735
|
-
}
|
|
736
|
-
if (!chargesOpenGeniCredits) {
|
|
737
|
-
await recordUsageEvent(db, {
|
|
738
|
-
accountId: input.accountId,
|
|
739
|
-
workspaceId: input.workspaceId,
|
|
740
|
-
eventType: "model.cost",
|
|
741
|
-
quantity: 0,
|
|
742
|
-
unit: "usd_micros",
|
|
743
|
-
sourceResourceType: "model_response",
|
|
744
|
-
sourceResourceId: `${input.turnId}:${input.sourceKey}`,
|
|
745
|
-
sessionId: input.sessionId,
|
|
746
|
-
turnId: input.turnId,
|
|
747
|
-
turnAttemptId: input.turnAttemptId,
|
|
748
|
-
idempotencyKey: `usage:model.cost:${input.turnId}:${input.sourceKey}`,
|
|
749
|
-
});
|
|
750
|
-
return {
|
|
751
|
-
billingPath: "external",
|
|
752
|
-
pricedCostMicros: 0,
|
|
753
|
-
estimatedProviderCostMicros,
|
|
754
|
-
equivalentCreditCostMicros,
|
|
755
|
-
pricingSource,
|
|
756
|
-
normalizedUsage,
|
|
757
|
-
...(gatewayBilling ? { upstreamProvider: gatewayBilling.finalProvider } : {}),
|
|
758
|
-
};
|
|
759
|
-
}
|
|
760
|
-
const shouldDebit = settings.billingMode === "stripe" || settings.usageLimitsMode === "managed";
|
|
761
|
-
if (!shouldDebit || (totalTokens === 0 && !gatewayBilling)) {
|
|
762
|
-
return {
|
|
763
|
-
billingPath: "opengeni_credits",
|
|
764
|
-
pricedCostMicros: 0,
|
|
765
|
-
estimatedProviderCostMicros,
|
|
766
|
-
equivalentCreditCostMicros,
|
|
767
|
-
pricingSource,
|
|
768
|
-
normalizedUsage,
|
|
769
|
-
...(gatewayBilling ? { upstreamProvider: gatewayBilling.finalProvider } : {}),
|
|
770
|
-
};
|
|
771
|
-
}
|
|
772
|
-
if (!pricingBreakdown) {
|
|
773
|
-
throw new Error(`Missing model pricing for ${input.model}`);
|
|
774
|
-
}
|
|
775
|
-
const costMicros = pricingBreakdown.creditCostMicros;
|
|
776
|
-
await recordUsageEvent(db, {
|
|
795
|
+
return await settleModelUsage(settings, db, {
|
|
777
796
|
accountId: input.accountId,
|
|
778
797
|
workspaceId: input.workspaceId,
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
798
|
+
model: input.model,
|
|
799
|
+
chargesOpenGeniCredits: input.chargesOpenGeniCredits ?? !input.externallyBilled,
|
|
800
|
+
countsTowardTokenCap: input.countsTowardTokenCap ?? !input.externallyBilled,
|
|
801
|
+
creditPolicyRevision: input.creditPolicyRevision,
|
|
802
|
+
...(input.gatewayBilling ? { gatewayBilling: input.gatewayBilling } : {}),
|
|
803
|
+
normalizedUsage: input.normalizedUsage ?? normalizeModelCallUsage(input.usage),
|
|
804
|
+
sourceId: `${input.turnId}:${input.sourceKey}`,
|
|
784
805
|
sessionId: input.sessionId,
|
|
785
806
|
turnId: input.turnId,
|
|
786
807
|
turnAttemptId: input.turnAttemptId,
|
|
787
|
-
|
|
808
|
+
usageLimitMetrics: input.observability ?? null,
|
|
809
|
+
// A failed task-usage receipt write never loses or replays the response:
|
|
810
|
+
// custody writes it before the next model request or turn completion.
|
|
811
|
+
receiptCustody: (receipt) =>
|
|
812
|
+
holdSessionUsageReceipt(
|
|
813
|
+
{ accountId: input.accountId, workspaceId: input.workspaceId },
|
|
814
|
+
receipt,
|
|
815
|
+
),
|
|
816
|
+
...(input.latencyMode ? { latencyMode: input.latencyMode } : {}),
|
|
817
|
+
debitMetadata: {
|
|
818
|
+
sessionId: input.sessionId,
|
|
819
|
+
turnId: input.turnId,
|
|
820
|
+
sourceKey: input.sourceKey,
|
|
821
|
+
},
|
|
822
|
+
onCreditsDebited: (result) => {
|
|
823
|
+
recordCreditMicros(input.observability, "usage", result.debitedMicros);
|
|
824
|
+
recordModelCreditsCharged(input.observability, {
|
|
825
|
+
provider: input.metricProvider ?? "unknown",
|
|
826
|
+
model: modelMetricProductId(settings, input.metricProvider, input.model),
|
|
827
|
+
debitedMicros: result.debitedMicros,
|
|
828
|
+
grantDebitedMicros: result.grantDebitedMicros,
|
|
829
|
+
});
|
|
830
|
+
},
|
|
788
831
|
});
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
const modelMetricProductIds = new WeakMap<Settings, Map<string, string>>();
|
|
835
|
+
|
|
836
|
+
/**
|
|
837
|
+
* The bounded `model` metric label: the deployment catalog product id for a
|
|
838
|
+
* catalog model, or `custom` for a workspace-owned model (workspace gateway or
|
|
839
|
+
* a customer-key provider) and for anything the deployment catalog does not
|
|
840
|
+
* list. Metrics only; never billing or routing authority.
|
|
841
|
+
*/
|
|
842
|
+
export function modelMetricProductId(
|
|
843
|
+
settings: Settings,
|
|
844
|
+
provider: string | undefined,
|
|
845
|
+
model: string,
|
|
846
|
+
): string {
|
|
847
|
+
if (provider?.startsWith("workspace-") || model.startsWith(WORKSPACE_GATEWAY_MODEL_ID_PREFIX)) {
|
|
848
|
+
return "custom";
|
|
849
|
+
}
|
|
850
|
+
let cache = modelMetricProductIds.get(settings);
|
|
851
|
+
if (!cache) {
|
|
852
|
+
cache = new Map();
|
|
853
|
+
modelMetricProductIds.set(settings, cache);
|
|
854
|
+
}
|
|
855
|
+
const cached = cache.get(model);
|
|
856
|
+
if (cached !== undefined) return cached;
|
|
857
|
+
let label = "custom";
|
|
858
|
+
try {
|
|
859
|
+
const canonical = canonicalizeConfiguredModelId(settings, model);
|
|
860
|
+
if (configuredModels(settings).some((candidate) => candidate.id === canonical)) {
|
|
861
|
+
label = canonical;
|
|
862
|
+
}
|
|
863
|
+
} catch {
|
|
864
|
+
// An unreadable catalog leaves the call labelled `custom`.
|
|
865
|
+
}
|
|
866
|
+
if (cache.size < 256) cache.set(model, label);
|
|
867
|
+
return label;
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
/**
|
|
871
|
+
* Per-model usage and estimated provider cost for one authoritative response.
|
|
872
|
+
* Call only after the durable usage event was accepted as current (the same
|
|
873
|
+
* fence as the Insights fact). Best-effort: never throws.
|
|
874
|
+
*/
|
|
875
|
+
export function recordAuthoritativeModelUsageMetrics(input: {
|
|
876
|
+
observability: ActivityServices["observability"];
|
|
877
|
+
settings: Settings;
|
|
878
|
+
provider: string;
|
|
879
|
+
model: string;
|
|
880
|
+
externallyBilled: boolean;
|
|
881
|
+
billing: ModelUsageBillingRecord;
|
|
882
|
+
/** Provider-run web searches this response billed, when the provider reports them. */
|
|
883
|
+
webSearchRequests?: number | undefined;
|
|
884
|
+
}): void {
|
|
885
|
+
try {
|
|
886
|
+
const telemetry = input.billing.normalizedUsage.telemetry;
|
|
887
|
+
recordModelResponseUsage(input.observability, {
|
|
888
|
+
provider: input.provider,
|
|
889
|
+
model: modelMetricProductId(input.settings, input.provider, input.model),
|
|
890
|
+
payer: input.externallyBilled ? "external" : "deployment",
|
|
891
|
+
tokens: telemetry,
|
|
892
|
+
estimatedProviderCostMicros: input.billing.estimatedProviderCostMicros,
|
|
893
|
+
pricingSource: input.billing.pricingSource,
|
|
894
|
+
...(input.webSearchRequests ? { webSearchRequests: input.webSearchRequests } : {}),
|
|
813
895
|
});
|
|
814
|
-
|
|
896
|
+
} catch {
|
|
897
|
+
// Durable event + billing already committed; metrics are best-effort only.
|
|
815
898
|
}
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
normalizedUsage,
|
|
823
|
-
...(gatewayBilling ? { upstreamProvider: gatewayBilling.finalProvider } : {}),
|
|
824
|
-
};
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
function isForeignKeyViolation(error: unknown): boolean {
|
|
902
|
+
const code = (error as { code?: unknown } | null)?.code;
|
|
903
|
+
const causeCode = (error as { cause?: { code?: unknown } } | null)?.cause?.code;
|
|
904
|
+
return code === "23503" || causeCode === "23503";
|
|
825
905
|
}
|
|
826
906
|
|
|
827
907
|
/** Soft-fail Insights fact write — never throws into the billing/emit path. */
|
|
@@ -838,11 +918,14 @@ export async function recordAuthoritativeModelCallFact(input: {
|
|
|
838
918
|
providerApi: ModelProviderApi;
|
|
839
919
|
model: string;
|
|
840
920
|
billing: ModelUsageBillingRecord;
|
|
921
|
+
/** The shared-core subscription connection that served the call, if any. */
|
|
922
|
+
subscriptionConnectionId?: string | null;
|
|
841
923
|
contextContributions?: readonly ModelContextContributionSummary[] | null;
|
|
842
924
|
}): Promise<void> {
|
|
843
925
|
try {
|
|
844
926
|
const telemetry = input.billing.normalizedUsage.telemetry;
|
|
845
|
-
|
|
927
|
+
const fact = (connectionId: string | null) => ({
|
|
928
|
+
connectionId,
|
|
846
929
|
accountId: input.accountId,
|
|
847
930
|
workspaceId: input.workspaceId,
|
|
848
931
|
sessionId: input.sessionId,
|
|
@@ -857,6 +940,8 @@ export async function recordAuthoritativeModelCallFact(input: {
|
|
|
857
940
|
estimatedProviderCostMicros: input.billing.estimatedProviderCostMicros,
|
|
858
941
|
equivalentCreditCostMicros: input.billing.equivalentCreditCostMicros,
|
|
859
942
|
pricingSource: input.billing.pricingSource,
|
|
943
|
+
listByClassMicros: input.billing.listByClassMicros ?? null,
|
|
944
|
+
listByClassApprox: input.billing.listByClassApprox ?? false,
|
|
860
945
|
inputTokens: telemetry.inputTokens,
|
|
861
946
|
outputTokens: telemetry.outputTokens,
|
|
862
947
|
cachedTokens: telemetry.cachedTokens,
|
|
@@ -867,6 +952,14 @@ export async function recordAuthoritativeModelCallFact(input: {
|
|
|
867
952
|
? { contextContributions: input.contextContributions }
|
|
868
953
|
: {}),
|
|
869
954
|
});
|
|
955
|
+
try {
|
|
956
|
+
await recordModelCallFact(input.db, fact(input.subscriptionConnectionId ?? null));
|
|
957
|
+
} catch (error) {
|
|
958
|
+
// The served connection was deleted mid-turn: keep the usage fact and
|
|
959
|
+
// drop only its attribution, never the whole fact.
|
|
960
|
+
if (!input.subscriptionConnectionId || !isForeignKeyViolation(error)) throw error;
|
|
961
|
+
await recordModelCallFact(input.db, fact(null));
|
|
962
|
+
}
|
|
870
963
|
} catch (error) {
|
|
871
964
|
input.observability.warn("model call fact persist failed", {
|
|
872
965
|
...safeErrorDiagnostic(error),
|
|
@@ -874,33 +967,6 @@ export async function recordAuthoritativeModelCallFact(input: {
|
|
|
874
967
|
}
|
|
875
968
|
}
|
|
876
969
|
|
|
877
|
-
export function sanitizedModelUsageInput(normalized: ModelCallUsageNormalization): ModelUsageInput {
|
|
878
|
-
return {
|
|
879
|
-
...(normalized.telemetry.inputTokens !== null
|
|
880
|
-
? { inputTokens: normalized.telemetry.inputTokens }
|
|
881
|
-
: {}),
|
|
882
|
-
...(normalized.telemetry.outputTokens !== null
|
|
883
|
-
? { outputTokens: normalized.telemetry.outputTokens }
|
|
884
|
-
: {}),
|
|
885
|
-
...(normalized.totalTokens !== null ? { totalTokens: normalized.totalTokens } : {}),
|
|
886
|
-
...(normalized.telemetry.cachedTokens !== null || normalized.telemetry.cacheWriteTokens !== null
|
|
887
|
-
? {
|
|
888
|
-
inputTokensDetails: {
|
|
889
|
-
...(normalized.telemetry.cachedTokens === null
|
|
890
|
-
? {}
|
|
891
|
-
: { cached_tokens: normalized.telemetry.cachedTokens }),
|
|
892
|
-
...(normalized.telemetry.cacheWriteTokens === null
|
|
893
|
-
? {}
|
|
894
|
-
: { cache_write_tokens: normalized.telemetry.cacheWriteTokens }),
|
|
895
|
-
},
|
|
896
|
-
}
|
|
897
|
-
: {}),
|
|
898
|
-
...(normalized.requestUsageEntries
|
|
899
|
-
? { requestUsageEntries: normalized.requestUsageEntries }
|
|
900
|
-
: {}),
|
|
901
|
-
};
|
|
902
|
-
}
|
|
903
|
-
|
|
904
970
|
export function startOfUtcMonth(): Date {
|
|
905
971
|
const now = new Date();
|
|
906
972
|
return new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), 1));
|