@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,8 +1,3 @@
|
|
|
1
|
-
// src/observability-metrics.ts
|
|
2
|
-
import { createHash } from "crypto";
|
|
3
|
-
import { errorCodeToJSON } from "@opengeni/agent-proto";
|
|
4
|
-
import { SandboxBackend } from "@opengeni/contracts";
|
|
5
|
-
|
|
6
1
|
// src/opensandbox-kubernetes-inventory.ts
|
|
7
2
|
import { readFile } from "fs/promises";
|
|
8
3
|
import { request as httpsRequest } from "https";
|
|
@@ -217,11 +212,71 @@ function zeroRecord(keys) {
|
|
|
217
212
|
return Object.fromEntries(keys.map((key) => [key, 0]));
|
|
218
213
|
}
|
|
219
214
|
|
|
215
|
+
// src/observability-metrics.ts
|
|
216
|
+
import { createHash } from "crypto";
|
|
217
|
+
import { errorCodeToJSON } from "@opengeni/agent-proto";
|
|
218
|
+
import {
|
|
219
|
+
BundledSkillId,
|
|
220
|
+
CREDIT_GRANT_CLASSES,
|
|
221
|
+
SandboxBackend
|
|
222
|
+
} from "@opengeni/contracts";
|
|
223
|
+
import {
|
|
224
|
+
ACTIVE_USER_WINDOWS
|
|
225
|
+
} from "@opengeni/db";
|
|
226
|
+
import {
|
|
227
|
+
natsSubscriptionTerminationCounter
|
|
228
|
+
} from "@opengeni/events";
|
|
229
|
+
|
|
230
|
+
// src/telemetry-scheduler.ts
|
|
231
|
+
var telemetryScheduler = {
|
|
232
|
+
timeout(callback, delayMs) {
|
|
233
|
+
const timer = setTimeout(callback, delayMs);
|
|
234
|
+
timer.unref?.();
|
|
235
|
+
return () => clearTimeout(timer);
|
|
236
|
+
},
|
|
237
|
+
interval(callback, intervalMs) {
|
|
238
|
+
const timer = setInterval(callback, intervalMs);
|
|
239
|
+
timer.unref?.();
|
|
240
|
+
return () => clearInterval(timer);
|
|
241
|
+
},
|
|
242
|
+
defer: queueMicrotask
|
|
243
|
+
};
|
|
244
|
+
function telemetryInterval(value, name) {
|
|
245
|
+
if (!Number.isSafeInteger(value) || value < 1) {
|
|
246
|
+
throw new Error(`${name} must be a positive integer`);
|
|
247
|
+
}
|
|
248
|
+
return value;
|
|
249
|
+
}
|
|
250
|
+
function createTelemetryClock(now) {
|
|
251
|
+
let latest = null;
|
|
252
|
+
return {
|
|
253
|
+
read() {
|
|
254
|
+
let observed;
|
|
255
|
+
try {
|
|
256
|
+
observed = now();
|
|
257
|
+
} catch {
|
|
258
|
+
return null;
|
|
259
|
+
}
|
|
260
|
+
if (!Number.isFinite(observed) || observed < 0 || observed > Number.MAX_SAFE_INTEGER || latest !== null && observed < latest)
|
|
261
|
+
return null;
|
|
262
|
+
latest = observed;
|
|
263
|
+
return observed;
|
|
264
|
+
},
|
|
265
|
+
latest: () => latest
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
|
|
220
269
|
// src/observability-metrics.ts
|
|
221
270
|
import {
|
|
271
|
+
MCP_TOOL_METRIC_EXTERNAL_LABEL,
|
|
222
272
|
SELFHOSTED_INFRASTRUCTURE_FAULT_CLASSES,
|
|
273
|
+
WORKSPACE_CAPTURE_SKIP_REASONS,
|
|
274
|
+
isMcpToolMetricLabel,
|
|
223
275
|
modelUsageTokenCountOrNull
|
|
224
276
|
} from "@opengeni/runtime";
|
|
277
|
+
function turnTaskQueueMetricLabels(identity) {
|
|
278
|
+
return { temporal_namespace: identity.temporalNamespace, task_queue: identity.taskQueue };
|
|
279
|
+
}
|
|
225
280
|
var turnTrackers = /* @__PURE__ */ new WeakMap();
|
|
226
281
|
var modelRequestTrackers = /* @__PURE__ */ new WeakMap();
|
|
227
282
|
var creditBalanceGaugeAccounts = /* @__PURE__ */ new WeakMap();
|
|
@@ -243,6 +298,12 @@ var CONTEXT_COMPACTIONS_METRIC = {
|
|
|
243
298
|
name: "opengeni_context_compactions_total",
|
|
244
299
|
help: "Total completed context compactions, by trigger."
|
|
245
300
|
};
|
|
301
|
+
function observabilityEventBusOptions(observability) {
|
|
302
|
+
return {
|
|
303
|
+
logger: observabilityEventLogger(observability),
|
|
304
|
+
onSubscriptionTerminated: natsSubscriptionTerminationCounter(observability)
|
|
305
|
+
};
|
|
306
|
+
}
|
|
246
307
|
function observabilityEventLogger(observability) {
|
|
247
308
|
return {
|
|
248
309
|
debug: (message, attributes) => observability.debug(message, eventAttributes(attributes)),
|
|
@@ -308,6 +369,13 @@ function runtimeMetricsHooksForObservability(observability) {
|
|
|
308
369
|
labels: { backend, stage }
|
|
309
370
|
});
|
|
310
371
|
},
|
|
372
|
+
onSandboxReadinessReplacement: ({ backend, outcome }) => {
|
|
373
|
+
observability.incrementCounter({
|
|
374
|
+
name: "opengeni_sandbox_readiness_replacements_total",
|
|
375
|
+
help: "Fresh sandbox command-readiness replacement decisions by backend and outcome.",
|
|
376
|
+
labels: { backend, outcome }
|
|
377
|
+
});
|
|
378
|
+
},
|
|
311
379
|
onSandboxProviderApiThrottle: ({ backend, operation }) => {
|
|
312
380
|
observability.incrementCounter({
|
|
313
381
|
name: "opengeni_sandbox_provider_api_throttles_total",
|
|
@@ -343,6 +411,15 @@ function runtimeMetricsHooksForObservability(observability) {
|
|
|
343
411
|
value: durationSeconds
|
|
344
412
|
});
|
|
345
413
|
},
|
|
414
|
+
onWorkspaceCaptureSkipped: ({ backend, reason }) => {
|
|
415
|
+
const safeBackend = SandboxBackend.safeParse(backend).success ? backend : "unknown";
|
|
416
|
+
const safeReason = WORKSPACE_CAPTURE_SKIP_REASONS.includes(reason) ? reason : "unknown";
|
|
417
|
+
observability.incrementCounter({
|
|
418
|
+
name: "opengeni_workspace_capture_skipped_total",
|
|
419
|
+
help: "Due warm workspace checkpoints that could not start, by backend and fixed reason. Not-yet-due (throttled) and already-complete checkpoints are excluded.",
|
|
420
|
+
labels: { backend: safeBackend, reason: safeReason }
|
|
421
|
+
});
|
|
422
|
+
},
|
|
346
423
|
onWorkspaceArchiveObject: ({ outcome, backend }) => {
|
|
347
424
|
observability.incrementCounter({
|
|
348
425
|
name: "opengeni_workspace_archive_object_total",
|
|
@@ -350,17 +427,21 @@ function runtimeMetricsHooksForObservability(observability) {
|
|
|
350
427
|
labels: { outcome, backend }
|
|
351
428
|
});
|
|
352
429
|
},
|
|
353
|
-
onMcpToolCall: ({ outcome, durationSeconds }) => {
|
|
354
|
-
|
|
430
|
+
onMcpToolCall: ({ outcome, tool, durationSeconds }) => {
|
|
431
|
+
const safeTool = isMcpToolMetricLabel(tool) ? tool : MCP_TOOL_METRIC_EXTERNAL_LABEL;
|
|
432
|
+
completedOperationSpan(observability, "worker.mcp.tool_call", durationSeconds, {
|
|
433
|
+
outcome,
|
|
434
|
+
tool: safeTool
|
|
435
|
+
});
|
|
355
436
|
observability.incrementCounter({
|
|
356
437
|
name: "opengeni_mcp_tool_calls_total",
|
|
357
|
-
help: "Total physical MCP tool calls by bounded structural outcome.",
|
|
358
|
-
labels: { outcome }
|
|
438
|
+
help: "Total physical MCP tool calls by bounded structural outcome and first-party tool (other tools are 'external').",
|
|
439
|
+
labels: { outcome, tool: safeTool }
|
|
359
440
|
});
|
|
360
441
|
observability.observeHistogram({
|
|
361
442
|
name: "opengeni_mcp_tool_call_duration_seconds",
|
|
362
|
-
help: "MCP tool-call duration in seconds by bounded structural outcome.",
|
|
363
|
-
labels: { outcome },
|
|
443
|
+
help: "MCP tool-call duration in seconds by bounded structural outcome and first-party tool (other tools are 'external').",
|
|
444
|
+
labels: { outcome, tool: safeTool },
|
|
364
445
|
value: durationSeconds
|
|
365
446
|
});
|
|
366
447
|
},
|
|
@@ -711,39 +792,56 @@ function recordTurnsQueuedGauge(observability, value) {
|
|
|
711
792
|
value
|
|
712
793
|
});
|
|
713
794
|
}
|
|
714
|
-
function recordTurnTaskQueueStats(observability, stats) {
|
|
795
|
+
function recordTurnTaskQueueStats(observability, stats, identity) {
|
|
796
|
+
const labels = turnTaskQueueMetricLabels(identity);
|
|
797
|
+
const values = {
|
|
798
|
+
backlog: requiredTemporalNumber(stats.eligibleBacklog, "eligibleBacklog", { integer: true }),
|
|
799
|
+
age: requiredTemporalNumber(stats.oldestBacklogAgeSeconds, "oldestBacklogAgeSeconds"),
|
|
800
|
+
add: requiredTemporalNumber(stats.tasksAddRate, "tasksAddRate"),
|
|
801
|
+
dispatch: requiredTemporalNumber(stats.tasksDispatchRate, "tasksDispatchRate")
|
|
802
|
+
};
|
|
715
803
|
observability.setGauge({
|
|
716
804
|
name: "opengeni_turn_eligible_backlog",
|
|
717
|
-
help: "Temporal
|
|
718
|
-
|
|
805
|
+
help: "Approximate Temporal activity backlog on the shared turn-worker queue, including video and retries.",
|
|
806
|
+
labels,
|
|
807
|
+
value: values.backlog
|
|
719
808
|
});
|
|
720
809
|
observability.setGauge({
|
|
721
810
|
name: "opengeni_turn_eligible_backlog_oldest_age_seconds",
|
|
722
|
-
help: "Approximate age of the oldest eligible
|
|
723
|
-
|
|
811
|
+
help: "Approximate age of the oldest eligible activity task on the shared turn-worker queue.",
|
|
812
|
+
labels,
|
|
813
|
+
value: values.age
|
|
724
814
|
});
|
|
725
815
|
observability.setGauge({
|
|
726
816
|
name: "opengeni_turn_eligible_tasks_add_rate",
|
|
727
|
-
help: "Temporal
|
|
728
|
-
|
|
817
|
+
help: "Temporal activities added per second to the shared turn-worker queue over its rolling window.",
|
|
818
|
+
labels,
|
|
819
|
+
value: values.add
|
|
729
820
|
});
|
|
730
821
|
observability.setGauge({
|
|
731
822
|
name: "opengeni_turn_eligible_tasks_dispatch_rate",
|
|
732
|
-
help: "Temporal
|
|
733
|
-
|
|
823
|
+
help: "Temporal activities dispatched per second from the shared turn-worker queue over its rolling window.",
|
|
824
|
+
labels,
|
|
825
|
+
value: values.dispatch
|
|
734
826
|
});
|
|
735
827
|
}
|
|
736
828
|
function normalizeTurnTaskQueueStats(stats) {
|
|
737
829
|
if (!stats) {
|
|
738
830
|
throw new Error("Temporal DescribeTaskQueue response omitted required stats");
|
|
739
831
|
}
|
|
832
|
+
if (typeof stats !== "object" || Array.isArray(stats)) {
|
|
833
|
+
throw new Error("Temporal DescribeTaskQueue returned malformed stats");
|
|
834
|
+
}
|
|
740
835
|
const eligibleBacklog = requiredTemporalNumber(
|
|
741
836
|
stats.approximateBacklogCount,
|
|
742
837
|
"approximateBacklogCount",
|
|
743
838
|
{ integer: true }
|
|
744
839
|
);
|
|
745
840
|
let oldestBacklogAgeSeconds = 0;
|
|
746
|
-
if (stats.approximateBacklogAge) {
|
|
841
|
+
if (stats.approximateBacklogAge !== null && stats.approximateBacklogAge !== void 0) {
|
|
842
|
+
if (typeof stats.approximateBacklogAge !== "object" || Array.isArray(stats.approximateBacklogAge)) {
|
|
843
|
+
throw new Error("Temporal stats returned invalid approximateBacklogAge");
|
|
844
|
+
}
|
|
747
845
|
const seconds = optionalTemporalNumber(
|
|
748
846
|
stats.approximateBacklogAge.seconds,
|
|
749
847
|
"approximateBacklogAge.seconds",
|
|
@@ -769,17 +867,42 @@ function normalizeTurnTaskQueueStats(stats) {
|
|
|
769
867
|
};
|
|
770
868
|
}
|
|
771
869
|
function startTurnCapacityMonitor(input) {
|
|
772
|
-
const intervalMs = input.intervalMs ?? 15e3;
|
|
773
|
-
const
|
|
774
|
-
|
|
870
|
+
const intervalMs = telemetryInterval(input.intervalMs ?? 15e3, "queue monitor intervalMs");
|
|
871
|
+
const readTimeoutMs = telemetryInterval(
|
|
872
|
+
input.readTimeoutMs ?? 5e3,
|
|
873
|
+
"queue monitor readTimeoutMs"
|
|
874
|
+
);
|
|
875
|
+
const closeTimeoutMs = telemetryInterval(
|
|
876
|
+
input.closeTimeoutMs ?? 1e3,
|
|
877
|
+
"queue monitor closeTimeoutMs"
|
|
878
|
+
);
|
|
879
|
+
const scheduler = input.scheduler ?? telemetryScheduler;
|
|
880
|
+
const labels = turnTaskQueueMetricLabels(input.identity);
|
|
881
|
+
const wallClock = createTelemetryClock(input.now ?? Date.now);
|
|
882
|
+
const monotonicClock = createTelemetryClock(input.monotonicNow ?? (() => performance.now()));
|
|
883
|
+
let startedAt = wallClock.read();
|
|
884
|
+
const readClock = () => {
|
|
885
|
+
const wall = wallClock.read();
|
|
886
|
+
const monotonic = monotonicClock.read();
|
|
887
|
+
return wall === null || monotonic === null ? null : { wall, monotonic };
|
|
888
|
+
};
|
|
775
889
|
let lastSuccessAt = null;
|
|
776
890
|
let lastReadSucceeded = false;
|
|
777
891
|
let stopped = false;
|
|
778
892
|
let running = null;
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
893
|
+
let closePromise;
|
|
894
|
+
const safely = (action) => {
|
|
895
|
+
try {
|
|
896
|
+
action();
|
|
897
|
+
} catch {
|
|
898
|
+
}
|
|
899
|
+
};
|
|
900
|
+
const recordStatus = (observation = readClock()) => {
|
|
901
|
+
if (observation === null) lastReadSucceeded = false;
|
|
902
|
+
const observedAt = wallClock.latest();
|
|
903
|
+
startedAt ??= observedAt;
|
|
904
|
+
const successAgeMs = observedAt === null ? 0 : observedAt - (lastSuccessAt ?? startedAt ?? observedAt);
|
|
905
|
+
const set = (name, help, value) => safely(() => input.observability.setGauge({ name, help, labels, value }));
|
|
783
906
|
set(
|
|
784
907
|
"opengeni_turn_capacity_monitor_last_read_success",
|
|
785
908
|
"Whether the latest Temporal turn-queue capacity read completed successfully.",
|
|
@@ -797,46 +920,108 @@ function startTurnCapacityMonitor(input) {
|
|
|
797
920
|
);
|
|
798
921
|
set(
|
|
799
922
|
"opengeni_turn_capacity_monitor_fresh",
|
|
800
|
-
"Whether
|
|
923
|
+
"Whether the latest read succeeded and the shared activity-queue gauges are within three monitor intervals.",
|
|
801
924
|
lastReadSucceeded && lastSuccessAt !== null && successAgeMs <= intervalMs * 3 ? 1 : 0
|
|
802
925
|
);
|
|
803
926
|
};
|
|
804
927
|
const refresh = () => {
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
928
|
+
if (stopped) return;
|
|
929
|
+
const observation = readClock();
|
|
930
|
+
recordStatus(observation);
|
|
931
|
+
if (running || observation === null) return;
|
|
932
|
+
const deadline = observation.wall + readTimeoutMs;
|
|
933
|
+
if (!Number.isFinite(deadline) || deadline > Number.MAX_SAFE_INTEGER) {
|
|
934
|
+
recordStatus(null);
|
|
935
|
+
return;
|
|
936
|
+
}
|
|
937
|
+
const controller = new AbortController();
|
|
938
|
+
const attempt = { controller, done: Promise.resolve(), cancelTimeout: () => {
|
|
939
|
+
} };
|
|
940
|
+
running = attempt;
|
|
941
|
+
attempt.cancelTimeout = scheduler.timeout(() => {
|
|
942
|
+
if (stopped || running !== attempt) return;
|
|
943
|
+
lastReadSucceeded = false;
|
|
811
944
|
recordStatus();
|
|
812
|
-
|
|
945
|
+
controller.abort();
|
|
946
|
+
}, readTimeoutMs);
|
|
947
|
+
let read;
|
|
948
|
+
try {
|
|
949
|
+
read = input.read({ signal: controller.signal, deadline });
|
|
950
|
+
} catch (error) {
|
|
951
|
+
read = Promise.reject(error);
|
|
952
|
+
}
|
|
953
|
+
attempt.done = read.then((stats) => {
|
|
954
|
+
if (stopped || controller.signal.aborted || running !== attempt) return;
|
|
955
|
+
const completedAt = readClock();
|
|
956
|
+
if (completedAt === null || completedAt.wall >= deadline || completedAt.monotonic - observation.monotonic >= readTimeoutMs) {
|
|
957
|
+
lastReadSucceeded = false;
|
|
958
|
+
recordStatus(completedAt);
|
|
959
|
+
controller.abort();
|
|
960
|
+
return;
|
|
961
|
+
}
|
|
962
|
+
recordTurnTaskQueueStats(input.observability, stats, input.identity);
|
|
963
|
+
lastSuccessAt = completedAt.wall;
|
|
964
|
+
lastReadSucceeded = true;
|
|
965
|
+
recordStatus(completedAt);
|
|
966
|
+
}).catch(() => {
|
|
967
|
+
if (stopped || controller.signal.aborted || running !== attempt) return;
|
|
813
968
|
lastReadSucceeded = false;
|
|
814
969
|
recordStatus();
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
970
|
+
safely(
|
|
971
|
+
() => input.observability.warn("turn capacity monitor: Temporal task-queue stats failed", {
|
|
972
|
+
// Do not export arbitrary server errors or credentials.
|
|
973
|
+
errorClass: "WorkerTelemetryReadError",
|
|
974
|
+
origin: "turn-capacity-monitor"
|
|
975
|
+
})
|
|
976
|
+
);
|
|
818
977
|
}).finally(() => {
|
|
819
|
-
|
|
978
|
+
attempt.cancelTimeout();
|
|
979
|
+
if (running === attempt) running = null;
|
|
820
980
|
});
|
|
821
981
|
};
|
|
822
982
|
refresh();
|
|
823
|
-
const
|
|
824
|
-
timer.unref?.();
|
|
983
|
+
const stopTimer = scheduler.interval(refresh, intervalMs);
|
|
825
984
|
return {
|
|
826
|
-
close:
|
|
985
|
+
close: () => {
|
|
986
|
+
if (closePromise) return closePromise;
|
|
827
987
|
stopped = true;
|
|
828
|
-
|
|
829
|
-
|
|
988
|
+
stopTimer();
|
|
989
|
+
lastReadSucceeded = false;
|
|
990
|
+
recordStatus();
|
|
991
|
+
const attempt = running;
|
|
992
|
+
attempt?.cancelTimeout();
|
|
993
|
+
attempt?.controller.abort();
|
|
994
|
+
closePromise = attempt ? new Promise((resolve) => {
|
|
995
|
+
const cancel = scheduler.timeout(resolve, closeTimeoutMs);
|
|
996
|
+
void attempt.done.then(() => {
|
|
997
|
+
cancel();
|
|
998
|
+
resolve();
|
|
999
|
+
});
|
|
1000
|
+
}) : Promise.resolve();
|
|
1001
|
+
return closePromise;
|
|
830
1002
|
}
|
|
831
1003
|
};
|
|
832
1004
|
}
|
|
833
|
-
function recordSessionRecoveryBacklogGauges(observability,
|
|
1005
|
+
function recordSessionRecoveryBacklogGauges(observability, backlog) {
|
|
834
1006
|
for (const state of ["quiescence_missing", "projection_stale"]) {
|
|
1007
|
+
const summary = backlog[state];
|
|
835
1008
|
observability.setGauge({
|
|
836
1009
|
name: "opengeni_session_recovery_backlog",
|
|
837
|
-
help: "Current durable recovering-session obligations with no active attempt, by bounded reconciliation state.",
|
|
1010
|
+
help: "Current durable recovering-session obligations with no active attempt, by bounded reconciliation state. Includes sessions legitimately sleeping in their recorded recovery backoff.",
|
|
1011
|
+
labels: { state },
|
|
1012
|
+
value: nonnegativeFinite(summary.count)
|
|
1013
|
+
});
|
|
1014
|
+
observability.setGauge({
|
|
1015
|
+
name: "opengeni_session_recovery_scheduled",
|
|
1016
|
+
help: "Durable recovering sessions still inside the recovery backoff (provider Retry-After or connectivity pacing) their recovery request recorded, by bounded reconciliation state.",
|
|
1017
|
+
labels: { state },
|
|
1018
|
+
value: nonnegativeFinite(summary.scheduled)
|
|
1019
|
+
});
|
|
1020
|
+
observability.setGauge({
|
|
1021
|
+
name: "opengeni_session_recovery_oldest_overdue_seconds",
|
|
1022
|
+
help: "Seconds the single oldest durable recovering session with no active attempt has been past its recovery due time, by bounded reconciliation state; 0 when none is overdue.",
|
|
838
1023
|
labels: { state },
|
|
839
|
-
value: nonnegativeFinite(
|
|
1024
|
+
value: nonnegativeFinite(summary.oldestOverdueSeconds)
|
|
840
1025
|
});
|
|
841
1026
|
}
|
|
842
1027
|
}
|
|
@@ -871,8 +1056,8 @@ function startSessionRecoveryMonitor(input) {
|
|
|
871
1056
|
const refresh = () => {
|
|
872
1057
|
recordStatus();
|
|
873
1058
|
if (stopped || running) return;
|
|
874
|
-
running = input.read().then((
|
|
875
|
-
recordSessionRecoveryBacklogGauges(input.observability,
|
|
1059
|
+
running = input.read().then((backlog) => {
|
|
1060
|
+
recordSessionRecoveryBacklogGauges(input.observability, backlog);
|
|
876
1061
|
lastSuccessAt = now();
|
|
877
1062
|
lastReadSucceeded = true;
|
|
878
1063
|
recordStatus();
|
|
@@ -1045,6 +1230,79 @@ function recordCreditBalanceGauges(observability, balances) {
|
|
|
1045
1230
|
}
|
|
1046
1231
|
creditBalanceGaugeAccounts.set(observability, current);
|
|
1047
1232
|
}
|
|
1233
|
+
function recordActiveUserGauges(observability, counts) {
|
|
1234
|
+
for (const window of ACTIVE_USER_WINDOWS) {
|
|
1235
|
+
observability.setGauge({
|
|
1236
|
+
name: "opengeni_active_users",
|
|
1237
|
+
help: "Distinct managed users with authenticated activity within the window (global; use max across pods).",
|
|
1238
|
+
labels: { window },
|
|
1239
|
+
value: counts[window]
|
|
1240
|
+
});
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
function recordCreditGrantGauges(observability, totals) {
|
|
1244
|
+
for (const grantClass of CREDIT_GRANT_CLASSES) {
|
|
1245
|
+
const total = totals[grantClass];
|
|
1246
|
+
observability.setGauge({
|
|
1247
|
+
name: "opengeni_credit_grants_total",
|
|
1248
|
+
help: "Positive credit grants observed in the ledger since migration 0565, by grant class (global cumulative; use max across pods).",
|
|
1249
|
+
labels: { grant_class: grantClass },
|
|
1250
|
+
value: total.count
|
|
1251
|
+
});
|
|
1252
|
+
observability.setGauge({
|
|
1253
|
+
name: "opengeni_credit_granted_micros_total",
|
|
1254
|
+
help: "Credit micros granted in the ledger since migration 0565, by grant class (global cumulative; use max across pods).",
|
|
1255
|
+
labels: { grant_class: grantClass },
|
|
1256
|
+
value: total.micros
|
|
1257
|
+
});
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
function recordVerifiedSignupTrialSwitchGauge(observability, grantsEnabled) {
|
|
1261
|
+
observability.setGauge({
|
|
1262
|
+
name: "opengeni_verified_signup_trial_credits_runtime_enabled",
|
|
1263
|
+
help: "Whether the runtime switch allows new verified signup trial credit grants (1) or blocks them (0).",
|
|
1264
|
+
value: grantsEnabled ? 1 : 0
|
|
1265
|
+
});
|
|
1266
|
+
}
|
|
1267
|
+
function recordManagedAuthNewSignupsSwitchGauge(observability, signupsEnabled) {
|
|
1268
|
+
observability.setGauge({
|
|
1269
|
+
name: "opengeni_managed_auth_new_signups_runtime_enabled",
|
|
1270
|
+
help: "Whether the runtime switch allows new managed account sign-ups (1) or has paused them (0).",
|
|
1271
|
+
value: signupsEnabled ? 1 : 0
|
|
1272
|
+
});
|
|
1273
|
+
}
|
|
1274
|
+
function recordVerifiedSignupTrialDeploymentFlagGauge(observability, enabled) {
|
|
1275
|
+
observability.setGauge({
|
|
1276
|
+
name: "opengeni_verified_signup_trial_credits_deployment_enabled",
|
|
1277
|
+
help: "Whether the OPENGENI_VERIFIED_SIGNUP_TRIAL_CREDITS_ENABLED master opt-in is on (1) or off (0) in this deployment's configuration.",
|
|
1278
|
+
value: enabled ? 1 : 0
|
|
1279
|
+
});
|
|
1280
|
+
}
|
|
1281
|
+
function recordModalSandboxInventoryGauges(observability, inventory) {
|
|
1282
|
+
const states = {
|
|
1283
|
+
running: inventory.running,
|
|
1284
|
+
unleased: inventory.unleased,
|
|
1285
|
+
lease_missing_instance: inventory.liveLeaseInstancesMissing
|
|
1286
|
+
};
|
|
1287
|
+
for (const [state, value] of Object.entries(states)) {
|
|
1288
|
+
observability.setGauge({
|
|
1289
|
+
name: "opengeni_modal_sandbox_inventory",
|
|
1290
|
+
help: "Running Modal sandboxes reconciled against live sandbox leases by the orphan sweep.",
|
|
1291
|
+
labels: { state },
|
|
1292
|
+
value: Math.max(0, value)
|
|
1293
|
+
});
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
function recordInteractionOnlyLeaseGauges(observability, counts) {
|
|
1297
|
+
for (const [idleBucket, value] of Object.entries(counts)) {
|
|
1298
|
+
observability.setGauge({
|
|
1299
|
+
name: "opengeni_sandbox_leases_interaction_only",
|
|
1300
|
+
help: "Warm sandbox leases held only by Browser/Computer sessions, by time since last interaction activity.",
|
|
1301
|
+
labels: { idle_bucket: idleBucket },
|
|
1302
|
+
value: Math.max(0, value)
|
|
1303
|
+
});
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1048
1306
|
function recordSandboxOrphansTerminated(observability, count) {
|
|
1049
1307
|
if (count <= 0) {
|
|
1050
1308
|
return;
|
|
@@ -1090,6 +1348,126 @@ function recordSandboxDeadlineRotationsRequested(observability, count) {
|
|
|
1090
1348
|
amount: count
|
|
1091
1349
|
});
|
|
1092
1350
|
}
|
|
1351
|
+
var SUBSCRIPTION_CORE_SHADOW_REQUIREMENTS = [
|
|
1352
|
+
"SUB-ACCESS-06",
|
|
1353
|
+
"SUB-CREDITS-01",
|
|
1354
|
+
"SUB-ELIG-01",
|
|
1355
|
+
"SUB-ELIG-02",
|
|
1356
|
+
"SUB-ELIG-03",
|
|
1357
|
+
"SUB-ELIG-04",
|
|
1358
|
+
"SUB-ELIG-05",
|
|
1359
|
+
"SUB-FAIL-02",
|
|
1360
|
+
"SUB-FAIL-03",
|
|
1361
|
+
"SUB-FAIL-04",
|
|
1362
|
+
"SUB-OWN-05",
|
|
1363
|
+
"SUB-SEL-02",
|
|
1364
|
+
"SUB-SEL-04",
|
|
1365
|
+
"SUB-SET-06",
|
|
1366
|
+
"SUB-STICK-02",
|
|
1367
|
+
"SUB-WAIT-01",
|
|
1368
|
+
"SUB-WAIT-02",
|
|
1369
|
+
"other",
|
|
1370
|
+
"checker_error"
|
|
1371
|
+
];
|
|
1372
|
+
var SUBSCRIPTION_CORE_SHADOW_REQUIREMENT_SET = new Set(
|
|
1373
|
+
SUBSCRIPTION_CORE_SHADOW_REQUIREMENTS
|
|
1374
|
+
);
|
|
1375
|
+
var SUBSCRIPTION_CORE_SHADOW_PARITY_REASONS = [
|
|
1376
|
+
"provider_disabled",
|
|
1377
|
+
"organization_accounts_off",
|
|
1378
|
+
"out_of_scope",
|
|
1379
|
+
"personal_connections_disabled",
|
|
1380
|
+
"personal_owner_inactive",
|
|
1381
|
+
"personal_not_owners_work",
|
|
1382
|
+
"personal_authority_missing",
|
|
1383
|
+
"unhealthy",
|
|
1384
|
+
"allocator_disabled",
|
|
1385
|
+
"wrong_provider",
|
|
1386
|
+
"model_unknown",
|
|
1387
|
+
"model_not_allowed_by_workspace",
|
|
1388
|
+
"model_not_entitled",
|
|
1389
|
+
"model_not_allowed_by_connection",
|
|
1390
|
+
"model_cooling_down",
|
|
1391
|
+
"exhausted"
|
|
1392
|
+
];
|
|
1393
|
+
var SUBSCRIPTION_CORE_SHADOW_PARITY_REASON_SET = new Set(
|
|
1394
|
+
SUBSCRIPTION_CORE_SHADOW_PARITY_REASONS
|
|
1395
|
+
);
|
|
1396
|
+
function recordSandboxIdleInteractionRelease(observability, outcome) {
|
|
1397
|
+
observability.incrementCounter({
|
|
1398
|
+
name: "opengeni_sandbox_idle_interaction_release_total",
|
|
1399
|
+
help: "Idle browser and desktop release inspections on warm boxes, by fixed outcome.",
|
|
1400
|
+
labels: { outcome }
|
|
1401
|
+
});
|
|
1402
|
+
}
|
|
1403
|
+
function recordSandboxCommandContainment(observability, outcome) {
|
|
1404
|
+
observability.incrementCounter({
|
|
1405
|
+
name: "opengeni_sandbox_command_containment_total",
|
|
1406
|
+
help: "Legacy retained-command containment inspections and enrolled drain commits by fixed outcome.",
|
|
1407
|
+
labels: { outcome }
|
|
1408
|
+
});
|
|
1409
|
+
}
|
|
1410
|
+
function recordSandboxProviderMissingBeforeCapture(observability, backend) {
|
|
1411
|
+
const safeBackend = SandboxBackend.safeParse(backend).success ? backend : "unknown";
|
|
1412
|
+
observability.incrementCounter({
|
|
1413
|
+
name: "opengeni_sandbox_provider_missing_before_capture_total",
|
|
1414
|
+
help: "Exact sandbox cold commits after definitive provider disappearance before workspace capture.",
|
|
1415
|
+
labels: { backend: safeBackend }
|
|
1416
|
+
});
|
|
1417
|
+
}
|
|
1418
|
+
function recordSandboxDockerWorkspaceRelease(observability, status) {
|
|
1419
|
+
observability.incrementCounter({
|
|
1420
|
+
name: "opengeni_sandbox_docker_workspace_release_total",
|
|
1421
|
+
help: "Docker drain host workspace directories released or retained after exact-container teardown.",
|
|
1422
|
+
labels: { status }
|
|
1423
|
+
});
|
|
1424
|
+
}
|
|
1425
|
+
function recordSandboxRecoveryObservationGauges(observability, observations) {
|
|
1426
|
+
for (const [kind, value] of [
|
|
1427
|
+
["provider_missing_before_capture", observations.providerLosses],
|
|
1428
|
+
["checkpoint_fallback_selected", observations.fallbackSelections],
|
|
1429
|
+
["fresh_workspace_selected", observations.freshWorkspaceSelections ?? 0]
|
|
1430
|
+
]) {
|
|
1431
|
+
observability.setGauge({
|
|
1432
|
+
name: "opengeni_sandbox_recovery_observations_recent",
|
|
1433
|
+
help: "Committed sandbox recovery observations in the last 30 minutes by fixed kind.",
|
|
1434
|
+
labels: { kind },
|
|
1435
|
+
value
|
|
1436
|
+
});
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1439
|
+
function sandboxAutomaticRecoveryOutcome(input) {
|
|
1440
|
+
if (input.lane === "fresh_workspace") return "fresh_workspace";
|
|
1441
|
+
return input.groupSessionCount > 1 ? "selected_shared" : "selected";
|
|
1442
|
+
}
|
|
1443
|
+
function recordSandboxAutomaticRecoverySelected(observability, backend, outcome) {
|
|
1444
|
+
const safeBackend = SandboxBackend.safeParse(backend).success ? backend : "unknown";
|
|
1445
|
+
observability.incrementCounter({
|
|
1446
|
+
name: "opengeni_sandbox_checkpoint_fallback_total",
|
|
1447
|
+
help: "System-selected continuity after managed provider loss: verified checkpoint or empty workspace.",
|
|
1448
|
+
labels: { backend: safeBackend, outcome }
|
|
1449
|
+
});
|
|
1450
|
+
}
|
|
1451
|
+
function recordSandboxCheckpointStalenessGauges(observability, staleness) {
|
|
1452
|
+
const values = {
|
|
1453
|
+
dirty: staleness.dirty,
|
|
1454
|
+
stale_4h: staleness.stale4h,
|
|
1455
|
+
stale_12h: staleness.stale12h
|
|
1456
|
+
};
|
|
1457
|
+
for (const [kind, value] of Object.entries(values)) {
|
|
1458
|
+
observability.setGauge({
|
|
1459
|
+
name: "opengeni_sandbox_checkpoint_staleness",
|
|
1460
|
+
help: "Live Modal sandboxes holding a write their last checkpoint did not capture, by age of the first such write.",
|
|
1461
|
+
labels: { kind },
|
|
1462
|
+
value
|
|
1463
|
+
});
|
|
1464
|
+
}
|
|
1465
|
+
observability.setGauge({
|
|
1466
|
+
name: "opengeni_sandbox_checkpoint_age_max_seconds",
|
|
1467
|
+
help: "Age in seconds of the oldest write a live Modal sandbox's last checkpoint did not capture.",
|
|
1468
|
+
value: Number.isFinite(staleness.maxAgeSeconds) ? Math.max(0, staleness.maxAgeSeconds) : 0
|
|
1469
|
+
});
|
|
1470
|
+
}
|
|
1093
1471
|
function recordSandboxRotationBacklogGauges(observability, backlog) {
|
|
1094
1472
|
const values = {
|
|
1095
1473
|
requested: backlog.requested,
|
|
@@ -1109,6 +1487,11 @@ function recordSandboxRotationBacklogGauges(observability, backlog) {
|
|
|
1109
1487
|
}
|
|
1110
1488
|
}
|
|
1111
1489
|
var RETAINED_PROCESS_OWNER_STATES = [
|
|
1490
|
+
// Session-owned background commands (migration 0637). Running is live
|
|
1491
|
+
// session work after its launch turn ended; stopping already has a stop
|
|
1492
|
+
// request, so it still counts as terminal-owner backlog.
|
|
1493
|
+
"background_running",
|
|
1494
|
+
"background_stopping",
|
|
1112
1495
|
"direct",
|
|
1113
1496
|
"queued",
|
|
1114
1497
|
"running",
|
|
@@ -1144,7 +1527,7 @@ function recordRetainedProcessInventoryGauges(observability, counts) {
|
|
|
1144
1527
|
});
|
|
1145
1528
|
observability.setGauge({
|
|
1146
1529
|
name: "opengeni_retained_processes_terminal_owner_backlog",
|
|
1147
|
-
help: "Current active retained processes whose
|
|
1530
|
+
help: "Current active retained processes whose owner is gone: a closed launch attempt or released direct request, or a background command already asked to stop. A running session background command is never counted.",
|
|
1148
1531
|
labels: { owner_state: ownerState },
|
|
1149
1532
|
value: count.terminal
|
|
1150
1533
|
});
|
|
@@ -1194,6 +1577,89 @@ function recordCreditMicros(observability, kind, amountMicros) {
|
|
|
1194
1577
|
amount: amountMicros
|
|
1195
1578
|
});
|
|
1196
1579
|
}
|
|
1580
|
+
var MODEL_METRIC_LABEL_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:/@+-]{0,127}$/;
|
|
1581
|
+
var MAX_MODEL_METRIC_LABELS = 64;
|
|
1582
|
+
var modelMetricLabels = /* @__PURE__ */ new WeakMap();
|
|
1583
|
+
function boundedModelMetricLabel(observability, model) {
|
|
1584
|
+
if (model === "custom" || model === "other") return model;
|
|
1585
|
+
if (!MODEL_METRIC_LABEL_PATTERN.test(model)) return "custom";
|
|
1586
|
+
let seen = modelMetricLabels.get(observability);
|
|
1587
|
+
if (!seen) {
|
|
1588
|
+
seen = /* @__PURE__ */ new Set();
|
|
1589
|
+
modelMetricLabels.set(observability, seen);
|
|
1590
|
+
}
|
|
1591
|
+
if (seen.has(model)) return model;
|
|
1592
|
+
if (seen.size >= MAX_MODEL_METRIC_LABELS) return "other";
|
|
1593
|
+
seen.add(model);
|
|
1594
|
+
return model;
|
|
1595
|
+
}
|
|
1596
|
+
function nonnegativeSafeInteger(value) {
|
|
1597
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value > 0 ? value : 0;
|
|
1598
|
+
}
|
|
1599
|
+
function recordModelResponseUsage(observability, input) {
|
|
1600
|
+
const model = boundedModelMetricLabel(observability, input.model);
|
|
1601
|
+
const base = { provider: input.provider, model };
|
|
1602
|
+
const priced = input.pricingSource !== null && input.estimatedProviderCostMicros !== null;
|
|
1603
|
+
observability.incrementCounter({
|
|
1604
|
+
name: "opengeni_model_responses_total",
|
|
1605
|
+
help: "Authoritative model responses with reported usage, by provider, catalog model and whether a cost estimate exists.",
|
|
1606
|
+
labels: { ...base, priced: priced ? "true" : "false" }
|
|
1607
|
+
});
|
|
1608
|
+
const tokenTypes = [
|
|
1609
|
+
["input", input.tokens.inputTokens],
|
|
1610
|
+
["cached_input", input.tokens.cachedTokens],
|
|
1611
|
+
["cache_write", input.tokens.cacheWriteTokens],
|
|
1612
|
+
["output", input.tokens.outputTokens],
|
|
1613
|
+
["reasoning", input.tokens.reasoningTokens]
|
|
1614
|
+
];
|
|
1615
|
+
for (const [type, value] of tokenTypes) {
|
|
1616
|
+
const amount = modelUsageTokenCountOrNull(value);
|
|
1617
|
+
if (amount === null || amount === 0) continue;
|
|
1618
|
+
incrementBoundedModelCacheCounter(observability, {
|
|
1619
|
+
name: "opengeni_model_tokens_total",
|
|
1620
|
+
help: "Tokens of authoritative model responses by provider, catalog model and token type (cached_input and cache_write are subsets of input; reasoning is a subset of output).",
|
|
1621
|
+
provider: input.provider,
|
|
1622
|
+
labels: { ...base, type },
|
|
1623
|
+
amount
|
|
1624
|
+
});
|
|
1625
|
+
}
|
|
1626
|
+
const searches = nonnegativeSafeInteger(input.webSearchRequests ?? 0);
|
|
1627
|
+
if (searches > 0)
|
|
1628
|
+
observability.incrementCounter({
|
|
1629
|
+
name: "opengeni_model_web_search_requests_total",
|
|
1630
|
+
help: "Provider-run web searches billed with authoritative model responses, by provider, catalog model and payer.",
|
|
1631
|
+
labels: { ...base, payer: input.payer },
|
|
1632
|
+
amount: searches
|
|
1633
|
+
});
|
|
1634
|
+
const cost = nonnegativeSafeInteger(input.estimatedProviderCostMicros);
|
|
1635
|
+
if (priced && input.pricingSource !== null && cost > 0) {
|
|
1636
|
+
observability.incrementCounter({
|
|
1637
|
+
name: "opengeni_model_provider_cost_micros_total",
|
|
1638
|
+
help: "Estimated upstream provider cost in USD micros by provider, catalog model, payer and pricing source.",
|
|
1639
|
+
labels: { ...base, payer: input.payer, pricing_source: input.pricingSource },
|
|
1640
|
+
amount: cost
|
|
1641
|
+
});
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
function recordModelCreditsCharged(observability, input) {
|
|
1645
|
+
if (!observability) return;
|
|
1646
|
+
const debited = nonnegativeSafeInteger(input.debitedMicros);
|
|
1647
|
+
if (debited === 0) return;
|
|
1648
|
+
const promotional = Math.min(debited, nonnegativeSafeInteger(input.grantDebitedMicros));
|
|
1649
|
+
const model = boundedModelMetricLabel(observability, input.model);
|
|
1650
|
+
for (const [funding, amount] of [
|
|
1651
|
+
["promotional", promotional],
|
|
1652
|
+
["general", debited - promotional]
|
|
1653
|
+
]) {
|
|
1654
|
+
if (amount === 0) continue;
|
|
1655
|
+
observability.incrementCounter({
|
|
1656
|
+
name: "opengeni_model_credits_charged_micros_total",
|
|
1657
|
+
help: "Credit micros debited for model usage by provider, catalog model and funding (promotional grant or general credit).",
|
|
1658
|
+
labels: { provider: input.provider, model, funding },
|
|
1659
|
+
amount
|
|
1660
|
+
});
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1197
1663
|
var MODEL_REQUEST_PHASE_BUCKETS = [
|
|
1198
1664
|
5e-3,
|
|
1199
1665
|
0.01,
|
|
@@ -1281,6 +1747,24 @@ function recordTurnStartupPhase(observability, input) {
|
|
|
1281
1747
|
value: Math.max(0, input.durationSeconds)
|
|
1282
1748
|
});
|
|
1283
1749
|
}
|
|
1750
|
+
async function measureTurnStartupPhase(observability, input, work) {
|
|
1751
|
+
const started = performance.now();
|
|
1752
|
+
let outcome = "failed";
|
|
1753
|
+
try {
|
|
1754
|
+
const result = await work();
|
|
1755
|
+
outcome = "completed";
|
|
1756
|
+
return result;
|
|
1757
|
+
} finally {
|
|
1758
|
+
try {
|
|
1759
|
+
recordTurnStartupPhase(observability, {
|
|
1760
|
+
...input,
|
|
1761
|
+
outcome,
|
|
1762
|
+
durationSeconds: (performance.now() - started) / 1e3
|
|
1763
|
+
});
|
|
1764
|
+
} catch {
|
|
1765
|
+
}
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1284
1768
|
function recordToolPreparationPhase(observability, input) {
|
|
1285
1769
|
if (input.execution === "blocking") {
|
|
1286
1770
|
recordTurnStartupPhase(observability, {
|
|
@@ -1456,8 +1940,47 @@ function contentDeltaClass(type) {
|
|
|
1456
1940
|
}
|
|
1457
1941
|
return null;
|
|
1458
1942
|
}
|
|
1459
|
-
var STREAM_TTFT_BUCKETS = [
|
|
1943
|
+
var STREAM_TTFT_BUCKETS = [
|
|
1944
|
+
0.02,
|
|
1945
|
+
0.05,
|
|
1946
|
+
0.1,
|
|
1947
|
+
0.2,
|
|
1948
|
+
0.35,
|
|
1949
|
+
0.5,
|
|
1950
|
+
0.75,
|
|
1951
|
+
1,
|
|
1952
|
+
1.5,
|
|
1953
|
+
2,
|
|
1954
|
+
3,
|
|
1955
|
+
5,
|
|
1956
|
+
10,
|
|
1957
|
+
15,
|
|
1958
|
+
20,
|
|
1959
|
+
30,
|
|
1960
|
+
45,
|
|
1961
|
+
60,
|
|
1962
|
+
90,
|
|
1963
|
+
120,
|
|
1964
|
+
180,
|
|
1965
|
+
300
|
|
1966
|
+
];
|
|
1460
1967
|
var STREAM_INTER_DELTA_BUCKETS = [5e-3, 0.01, 0.025, 0.05, 0.1, 0.2, 0.35, 0.5, 1, 2, 5];
|
|
1968
|
+
var MODEL_REQUEST_PRE_DISPATCH_BUCKETS = [
|
|
1969
|
+
5e-3,
|
|
1970
|
+
0.01,
|
|
1971
|
+
0.025,
|
|
1972
|
+
0.05,
|
|
1973
|
+
0.1,
|
|
1974
|
+
0.25,
|
|
1975
|
+
0.5,
|
|
1976
|
+
1,
|
|
1977
|
+
2,
|
|
1978
|
+
5,
|
|
1979
|
+
10,
|
|
1980
|
+
30,
|
|
1981
|
+
60,
|
|
1982
|
+
120
|
|
1983
|
+
];
|
|
1461
1984
|
var StreamTimingMetrics = class {
|
|
1462
1985
|
constructor(observability, options) {
|
|
1463
1986
|
this.observability = observability;
|
|
@@ -1469,6 +1992,30 @@ var StreamTimingMetrics = class {
|
|
|
1469
1992
|
ttftAnchor;
|
|
1470
1993
|
ttftArmed = true;
|
|
1471
1994
|
lastDeltaAt = /* @__PURE__ */ new Map();
|
|
1995
|
+
modelEntryAt = null;
|
|
1996
|
+
dispatchedAt = null;
|
|
1997
|
+
providerFirstRecorded = /* @__PURE__ */ new Set();
|
|
1998
|
+
/** Producer side: the SDK entered a model request (first admission check).
|
|
1999
|
+
* Admission can be re-entered for the same request; keep the earliest. */
|
|
2000
|
+
onModelRequestEntry() {
|
|
2001
|
+
if (this.modelEntryAt === null) this.modelEntryAt = this.now();
|
|
2002
|
+
}
|
|
2003
|
+
/** Producer side: request bytes are about to leave this process. */
|
|
2004
|
+
onProviderDispatch() {
|
|
2005
|
+
const at = this.now();
|
|
2006
|
+
if (this.modelEntryAt !== null) {
|
|
2007
|
+
this.observability.observeHistogram({
|
|
2008
|
+
name: "opengeni_model_request_pre_dispatch_seconds",
|
|
2009
|
+
help: "Seconds of Opengeni work from SDK model-request entry to literal provider dispatch.",
|
|
2010
|
+
buckets: MODEL_REQUEST_PRE_DISPATCH_BUCKETS,
|
|
2011
|
+
labels: { provider: this.options.provider },
|
|
2012
|
+
value: Math.max(0, (at - this.modelEntryAt) / 1e3)
|
|
2013
|
+
});
|
|
2014
|
+
this.modelEntryAt = null;
|
|
2015
|
+
}
|
|
2016
|
+
this.dispatchedAt = at;
|
|
2017
|
+
this.providerFirstRecorded.clear();
|
|
2018
|
+
}
|
|
1472
2019
|
onEvent(type) {
|
|
1473
2020
|
const deltaClass = contentDeltaClass(type);
|
|
1474
2021
|
if (deltaClass === null) {
|
|
@@ -1481,13 +2028,17 @@ var StreamTimingMetrics = class {
|
|
|
1481
2028
|
if (this.ttftArmed) {
|
|
1482
2029
|
this.observability.observeHistogram({
|
|
1483
2030
|
name: "opengeni_stream_ttft_seconds",
|
|
1484
|
-
help: "Seconds from a
|
|
2031
|
+
help: "Seconds from a stream start or structural boundary to the next streamed content delta (user-perceived; includes Opengeni between-call work).",
|
|
1485
2032
|
buckets: STREAM_TTFT_BUCKETS,
|
|
1486
2033
|
labels: { provider: this.options.provider },
|
|
1487
2034
|
value: Math.max(0, (at - this.ttftAnchor) / 1e3)
|
|
1488
2035
|
});
|
|
1489
2036
|
this.ttftArmed = false;
|
|
1490
2037
|
}
|
|
2038
|
+
if (this.dispatchedAt !== null) {
|
|
2039
|
+
this.observeProviderFirst("any", at);
|
|
2040
|
+
if (deltaClass === "message") this.observeProviderFirst("text", at);
|
|
2041
|
+
}
|
|
1491
2042
|
const last = this.lastDeltaAt.get(deltaClass);
|
|
1492
2043
|
if (last !== void 0) {
|
|
1493
2044
|
this.observability.observeHistogram({
|
|
@@ -1500,6 +2051,17 @@ var StreamTimingMetrics = class {
|
|
|
1500
2051
|
}
|
|
1501
2052
|
this.lastDeltaAt.set(deltaClass, at);
|
|
1502
2053
|
}
|
|
2054
|
+
observeProviderFirst(content, at) {
|
|
2055
|
+
if (this.dispatchedAt === null || this.providerFirstRecorded.has(content)) return;
|
|
2056
|
+
this.providerFirstRecorded.add(content);
|
|
2057
|
+
this.observability.observeHistogram({
|
|
2058
|
+
name: "opengeni_model_provider_ttft_seconds",
|
|
2059
|
+
help: "Seconds from literal provider dispatch to the first streamed content delta (any = reasoning or text, text = answer text).",
|
|
2060
|
+
buckets: STREAM_TTFT_BUCKETS,
|
|
2061
|
+
labels: { provider: this.options.provider, content },
|
|
2062
|
+
value: Math.max(0, (at - this.dispatchedAt) / 1e3)
|
|
2063
|
+
});
|
|
2064
|
+
}
|
|
1503
2065
|
};
|
|
1504
2066
|
var STREAM_BATCH_SIZE_BUCKETS = [1, 2, 5, 10, 20, 50, 100, 200, 500];
|
|
1505
2067
|
var STREAM_IO_BUCKETS = [1e-3, 25e-4, 5e-3, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5];
|
|
@@ -1700,9 +2262,15 @@ function requiredTemporalNumber(value, field, options = {}) {
|
|
|
1700
2262
|
if (value === null || value === void 0) {
|
|
1701
2263
|
throw new Error(`Temporal stats omitted required ${field}`);
|
|
1702
2264
|
}
|
|
1703
|
-
|
|
2265
|
+
let raw = value;
|
|
2266
|
+
try {
|
|
2267
|
+
if (typeof raw === "object" && raw !== null && !Array.isArray(raw)) raw = raw.toString();
|
|
2268
|
+
} catch {
|
|
2269
|
+
throw new Error(`Temporal stats returned invalid ${field}`);
|
|
2270
|
+
}
|
|
2271
|
+
const parsed = typeof raw === "number" ? raw : typeof raw === "string" && /^\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/.test(raw) ? Number(raw) : Number.NaN;
|
|
1704
2272
|
if (!Number.isFinite(parsed) || parsed < 0 || options.integer && !Number.isSafeInteger(parsed)) {
|
|
1705
|
-
throw new Error(`Temporal stats returned invalid ${field}
|
|
2273
|
+
throw new Error(`Temporal stats returned invalid ${field}`);
|
|
1706
2274
|
}
|
|
1707
2275
|
return parsed;
|
|
1708
2276
|
}
|
|
@@ -1722,10 +2290,97 @@ function modelCallAccountContext(input) {
|
|
|
1722
2290
|
accountChangedFromPrevCall
|
|
1723
2291
|
};
|
|
1724
2292
|
}
|
|
2293
|
+
function recordCodeSearchCall(observability, input) {
|
|
2294
|
+
observability.incrementCounter({
|
|
2295
|
+
name: "opengeni_code_search_calls_total",
|
|
2296
|
+
help: "Jev-backed code_search tool calls by outcome.",
|
|
2297
|
+
labels: { outcome: input.outcome }
|
|
2298
|
+
});
|
|
2299
|
+
observability.observeHistogram({
|
|
2300
|
+
name: "opengeni_code_search_duration_seconds",
|
|
2301
|
+
help: "Wall time of one code_search tool call.",
|
|
2302
|
+
buckets: [0.5, 1, 2, 4, 8, 15, 30, 60],
|
|
2303
|
+
labels: { outcome: input.outcome },
|
|
2304
|
+
value: Math.max(0, input.durationSeconds)
|
|
2305
|
+
});
|
|
2306
|
+
if (input.jevRequests > 0) {
|
|
2307
|
+
observability.incrementCounter({
|
|
2308
|
+
name: "opengeni_code_search_jev_requests_total",
|
|
2309
|
+
help: "Jev requests made by code_search.",
|
|
2310
|
+
amount: input.jevRequests
|
|
2311
|
+
});
|
|
2312
|
+
}
|
|
2313
|
+
if (input.jevCostUsd > 0) {
|
|
2314
|
+
observability.incrementCounter({
|
|
2315
|
+
name: "opengeni_code_search_jev_cost_micro_usd_total",
|
|
2316
|
+
help: "Estimated Jev list-price cost of code_search, in micro-USD.",
|
|
2317
|
+
amount: Math.round(input.jevCostUsd * 1e6)
|
|
2318
|
+
});
|
|
2319
|
+
}
|
|
2320
|
+
}
|
|
2321
|
+
function recordSkillRead(observability, read) {
|
|
2322
|
+
observability.incrementCounter({
|
|
2323
|
+
name: "opengeni_skill_reads_total",
|
|
2324
|
+
help: "skill_read calls by Skill source, built-in Skill id (custom for any other Skill), result kind, and caller.",
|
|
2325
|
+
labels: {
|
|
2326
|
+
source: read.source ?? "unknown",
|
|
2327
|
+
skill: skillReadMetricLabel(read.source, read.skill),
|
|
2328
|
+
kind: read.kind,
|
|
2329
|
+
caller: read.caller
|
|
2330
|
+
}
|
|
2331
|
+
});
|
|
2332
|
+
}
|
|
2333
|
+
function recordSkillCheckout(observability, checkout) {
|
|
2334
|
+
observability.incrementCounter({
|
|
2335
|
+
name: "opengeni_skill_checkouts_total",
|
|
2336
|
+
help: "skill_checkout calls by outcome and whether they selected specific paths.",
|
|
2337
|
+
labels: { outcome: checkout.outcome, selection: checkout.selection }
|
|
2338
|
+
});
|
|
2339
|
+
const phases = [
|
|
2340
|
+
["resolve", checkout.resolveSeconds],
|
|
2341
|
+
["sandbox", checkout.sandboxSeconds],
|
|
2342
|
+
["write", checkout.writeSeconds],
|
|
2343
|
+
["total", checkout.totalSeconds]
|
|
2344
|
+
];
|
|
2345
|
+
for (const [phase, seconds] of phases) {
|
|
2346
|
+
if (seconds === null) continue;
|
|
2347
|
+
observability.observeHistogram({
|
|
2348
|
+
name: "opengeni_skill_checkout_duration_seconds",
|
|
2349
|
+
help: "Wall time of skill_checkout phases: resolve (authority and Skill read), sandbox (filesystem handle, including lazy box start), write (batched file write), and total.",
|
|
2350
|
+
buckets: [0.05, 0.1, 0.25, 0.5, 1, 2, 4, 8, 15, 30, 60],
|
|
2351
|
+
labels: { phase, outcome: checkout.outcome },
|
|
2352
|
+
value: Math.max(0, seconds)
|
|
2353
|
+
});
|
|
2354
|
+
}
|
|
2355
|
+
for (const [result, amount] of [
|
|
2356
|
+
["written", checkout.written],
|
|
2357
|
+
["unchanged", checkout.unchanged]
|
|
2358
|
+
]) {
|
|
2359
|
+
if (amount <= 0) continue;
|
|
2360
|
+
observability.incrementCounter({
|
|
2361
|
+
name: "opengeni_skill_checkout_files_total",
|
|
2362
|
+
help: "Files skill_checkout wrote or found already present with the same content.",
|
|
2363
|
+
labels: { result },
|
|
2364
|
+
amount
|
|
2365
|
+
});
|
|
2366
|
+
}
|
|
2367
|
+
}
|
|
2368
|
+
function skillReadMetricLabel(source, skill) {
|
|
2369
|
+
if (source !== null && source !== "builtin") return "custom";
|
|
2370
|
+
for (const candidate of source === null ? [skill, `builtin:${skill}`] : [skill]) {
|
|
2371
|
+
const parsed = BundledSkillId.safeParse(candidate);
|
|
2372
|
+
if (parsed.success) return parsed.data;
|
|
2373
|
+
}
|
|
2374
|
+
return "custom";
|
|
2375
|
+
}
|
|
1725
2376
|
|
|
1726
2377
|
export {
|
|
2378
|
+
telemetryScheduler,
|
|
2379
|
+
telemetryInterval,
|
|
2380
|
+
createTelemetryClock,
|
|
1727
2381
|
inspectOpenSandboxKubernetesInventory,
|
|
1728
|
-
|
|
2382
|
+
turnTaskQueueMetricLabels,
|
|
2383
|
+
observabilityEventBusOptions,
|
|
1729
2384
|
runtimeMetricsHooksForObservability,
|
|
1730
2385
|
makeMachineOpObserver,
|
|
1731
2386
|
turnLifecycleMetricsFor,
|
|
@@ -1743,17 +2398,35 @@ export {
|
|
|
1743
2398
|
recordSandboxInventoryProjectionSuccess,
|
|
1744
2399
|
recordSandboxInventoryProjectionFailure,
|
|
1745
2400
|
recordCreditBalanceGauges,
|
|
2401
|
+
recordActiveUserGauges,
|
|
2402
|
+
recordCreditGrantGauges,
|
|
2403
|
+
recordVerifiedSignupTrialSwitchGauge,
|
|
2404
|
+
recordManagedAuthNewSignupsSwitchGauge,
|
|
2405
|
+
recordVerifiedSignupTrialDeploymentFlagGauge,
|
|
2406
|
+
recordModalSandboxInventoryGauges,
|
|
2407
|
+
recordInteractionOnlyLeaseGauges,
|
|
1746
2408
|
recordSandboxOrphansTerminated,
|
|
1747
2409
|
recordSandboxCheckpointArtifactGauges,
|
|
1748
2410
|
recordSandboxCheckpointArtifactOutcome,
|
|
1749
2411
|
recordSandboxDeadlineRotationsRequested,
|
|
2412
|
+
recordSandboxIdleInteractionRelease,
|
|
2413
|
+
recordSandboxCommandContainment,
|
|
2414
|
+
recordSandboxProviderMissingBeforeCapture,
|
|
2415
|
+
recordSandboxDockerWorkspaceRelease,
|
|
2416
|
+
recordSandboxRecoveryObservationGauges,
|
|
2417
|
+
sandboxAutomaticRecoveryOutcome,
|
|
2418
|
+
recordSandboxAutomaticRecoverySelected,
|
|
2419
|
+
recordSandboxCheckpointStalenessGauges,
|
|
1750
2420
|
recordSandboxRotationBacklogGauges,
|
|
1751
2421
|
recordRetainedProcessInventoryGauges,
|
|
1752
2422
|
recordExpiredDrainingSandboxLeaseGauges,
|
|
1753
2423
|
recordRetainedProcessReconciliation,
|
|
1754
2424
|
recordCreditMicros,
|
|
2425
|
+
recordModelResponseUsage,
|
|
2426
|
+
recordModelCreditsCharged,
|
|
1755
2427
|
recordModelRequestPhase,
|
|
1756
2428
|
recordTurnStartupPhase,
|
|
2429
|
+
measureTurnStartupPhase,
|
|
1757
2430
|
recordToolPreparationPhase,
|
|
1758
2431
|
recordTurnSandboxEstablishPolicy,
|
|
1759
2432
|
recordSandboxProvisionAttempt,
|
|
@@ -1771,6 +2444,9 @@ export {
|
|
|
1771
2444
|
recordContextCompactionStarted,
|
|
1772
2445
|
recordCompanyBrainContributions,
|
|
1773
2446
|
recordModelCacheTokens,
|
|
1774
|
-
modelCallAccountContext
|
|
2447
|
+
modelCallAccountContext,
|
|
2448
|
+
recordCodeSearchCall,
|
|
2449
|
+
recordSkillRead,
|
|
2450
|
+
recordSkillCheckout
|
|
1775
2451
|
};
|
|
1776
|
-
//# sourceMappingURL=chunk-
|
|
2452
|
+
//# sourceMappingURL=chunk-5NNS4327.js.map
|