@opengeni/worker-bundle 1.0.0-canary.0 → 1.0.0
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 +3 -1
- package/dist/activities/agent-turn/admission.d.ts +24 -3
- package/dist/activities/agent-turn/agent-build.d.ts +4 -0
- package/dist/activities/agent-turn/claude-usage-observer.d.ts +58 -0
- package/dist/activities/agent-turn/code-search.d.ts +60 -0
- package/dist/activities/agent-turn/codex-capacity.d.ts +13 -0
- package/dist/activities/agent-turn/codex-plan-entitlement.d.ts +105 -0
- package/dist/activities/agent-turn/codex.d.ts +3 -2
- package/dist/activities/agent-turn/compaction-prep.d.ts +21 -5
- package/dist/activities/agent-turn/credential-leases.d.ts +19 -33
- package/dist/activities/agent-turn/credential-restriction.d.ts +3 -0
- package/dist/activities/agent-turn/errors.d.ts +82 -11
- package/dist/activities/agent-turn/failure-settlement.d.ts +6 -3
- package/dist/activities/agent-turn/final-reply.d.ts +18 -0
- package/dist/activities/agent-turn/finalization-monitor.d.ts +17 -0
- package/dist/activities/agent-turn/finalization.d.ts +4 -2
- package/dist/activities/agent-turn/github-repository-bindings.d.ts +2 -0
- package/dist/activities/agent-turn/governance-model.d.ts +9 -2
- package/dist/activities/agent-turn/history-sink.d.ts +2 -0
- package/dist/activities/agent-turn/history.d.ts +2 -0
- package/dist/activities/agent-turn/input-wait-reply.d.ts +41 -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 +6 -0
- 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/provider-dispatch-barrier.d.ts +12 -1
- package/dist/activities/agent-turn/quiescence.d.ts +7 -7
- package/dist/activities/agent-turn/recovery-warning.d.ts +9 -0
- package/dist/activities/agent-turn/refresh-credentials.d.ts +6 -0
- package/dist/activities/agent-turn/run-credentials.d.ts +8 -3
- package/dist/activities/agent-turn/sandbox-establish.d.ts +2 -1
- package/dist/activities/agent-turn/sandbox-provision.d.ts +3 -1
- package/dist/activities/agent-turn/sandbox-route.d.ts +3 -20
- package/dist/activities/agent-turn/sandbox-runtime.d.ts +2 -2
- package/dist/activities/agent-turn/session-title.d.ts +34 -2
- 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-remove.d.ts +14 -0
- package/dist/activities/agent-turn/skill-search.d.ts +3 -1
- package/dist/activities/agent-turn/skill-tools.d.ts +15 -2
- package/dist/activities/agent-turn/skill-transfer.d.ts +18 -6
- package/dist/activities/agent-turn/stream-attempt.d.ts +7 -3
- package/dist/activities/agent-turn/subscription-lease.d.ts +38 -0
- package/dist/activities/agent-turn/tool-environment.d.ts +56 -6
- package/dist/activities/agent-turn/tool-policy.d.ts +43 -0
- package/dist/activities/agent-turn/turn-context.d.ts +29 -0
- package/dist/activities/agent-turn/turn-sandbox-access.d.ts +3 -0
- package/dist/activities/agent-turn/xai-capacity.d.ts +2 -1
- package/dist/activities/automations.d.ts +3 -1
- package/dist/activities/browser-deadline-checkpoint.d.ts +29 -0
- package/dist/activities/codemode-dispatcher.d.ts +9 -2
- package/dist/activities/codex-capacity.d.ts +18 -2
- package/dist/activities/codex-rotation.d.ts +7 -1
- package/dist/activities/context-compaction.d.ts +16 -2
- package/dist/activities/gmail-files.d.ts +32 -0
- package/dist/activities/goals.d.ts +8 -0
- package/dist/activities/knowledge-indexing.d.ts +19 -0
- package/dist/activities/mcp-account-routes.d.ts +3 -0
- package/dist/activities/mcp-credentials.d.ts +12 -13
- package/dist/activities/mcp-operation-authority.d.ts +0 -5
- package/dist/activities/model-call-fact-reconciler.d.ts +34 -0
- package/dist/activities/open-suffix-resume.d.ts +13 -0
- package/dist/activities/parent-wake.d.ts +6 -12
- package/dist/activities/retained-screenshots.d.ts +7 -2
- package/dist/activities/rig-verification.d.ts +2 -3
- package/dist/activities/run-credential-renewal.d.ts +1 -0
- package/dist/activities/run-credentials.d.ts +15 -3
- package/dist/activities/sandbox-images.d.ts +1 -1
- package/dist/activities/sandbox-lease.d.ts +47 -9
- package/dist/activities/scheduled-tasks.d.ts +4 -35
- package/dist/activities/session-state.d.ts +70 -3
- package/dist/activities/types.d.ts +55 -6
- package/dist/activities/workspace-capture.d.ts +2 -0
- package/dist/activities/workspace-credential-provider.d.ts +46 -0
- package/dist/{activities-control-HMFGSKC5.js → activities-control-BNPTRTOE.js} +1896 -418
- package/dist/activities-control-BNPTRTOE.js.map +1 -0
- package/dist/activities-control.d.ts +182 -4
- package/dist/{activities-turn-AP67JADS.js → activities-turn-5LGZOSVU.js} +4476 -1327
- package/dist/activities-turn-5LGZOSVU.js.map +1 -0
- package/dist/activities.d.ts +182 -4
- package/dist/artifact-materializer-entry.js +5 -2
- package/dist/artifact-materializer-entry.js.map +1 -1
- package/dist/artifact-outbox-entry.js +5 -2
- package/dist/artifact-outbox-entry.js.map +1 -1
- package/dist/browser-deadline-checkpoint-contract.d.ts +2 -0
- package/dist/{chunk-A4XQWVZK.js → chunk-3ZTRWDMN.js} +307 -4
- package/dist/chunk-3ZTRWDMN.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-CYITU5UH.js → chunk-LJX7Z2KP.js} +1445 -343
- package/dist/chunk-LJX7Z2KP.js.map +1 -0
- package/dist/editable-artifact-materializer-service.d.ts +2 -2
- package/dist/editable-artifact-outbox-service.d.ts +2 -2
- package/dist/host-export-pump.d.ts +3 -1
- package/dist/host-export.d.ts +1 -1
- package/dist/host-export.js +1 -1
- package/dist/http.d.ts +1 -1
- package/dist/index.d.ts +95 -3
- package/dist/index.js +137 -43
- package/dist/index.js.map +1 -1
- package/dist/observability-metrics.d.ts +118 -8
- package/dist/retained-process-diagnostics.d.ts +4 -0
- package/dist/retained-process-retry.d.ts +7 -0
- package/dist/sandbox-resume.d.ts +55 -13
- package/dist/sandbox-routing.d.ts +5 -3
- package/dist/sandbox-snapshot-diagnostics.d.ts +20 -0
- package/dist/session-event-fanout.d.ts +6 -0
- package/dist/warm-capture-holder.d.ts +3 -0
- package/dist/worker-service-lifecycle.d.ts +12 -0
- package/dist/workflow-bundle.js +273 -41
- package/dist/workflows/activities.d.ts +1 -1
- package/dist/workflows/browser-deadline-checkpoint.d.ts +9 -0
- package/dist/workflows/scheduled-tasks.d.ts +4 -0
- package/dist/workflows/session.d.ts +36 -0
- package/dist/workflows.d.ts +1 -0
- package/package.json +21 -19
- package/src/activities/agent-run-admission.ts +17 -1
- package/src/activities/agent-turn/admission.ts +66 -3
- package/src/activities/agent-turn/agent-build.ts +84 -10
- package/src/activities/agent-turn/claim.ts +186 -43
- package/src/activities/agent-turn/claude-usage-observer.ts +221 -0
- package/src/activities/agent-turn/code-search.ts +275 -0
- package/src/activities/agent-turn/codex-capacity.ts +172 -8
- package/src/activities/agent-turn/codex-plan-entitlement.ts +254 -0
- package/src/activities/agent-turn/codex.ts +13 -5
- package/src/activities/agent-turn/compaction-prep.ts +170 -102
- package/src/activities/agent-turn/credential-leases.ts +122 -216
- package/src/activities/agent-turn/credential-restriction.ts +14 -0
- package/src/activities/agent-turn/errors.ts +647 -48
- package/src/activities/agent-turn/failure-settlement.ts +682 -130
- package/src/activities/agent-turn/final-reply.ts +46 -0
- package/src/activities/agent-turn/finalization-monitor.ts +120 -0
- package/src/activities/agent-turn/finalization.ts +146 -43
- package/src/activities/agent-turn/github-repository-bindings.ts +3 -1
- package/src/activities/agent-turn/governance-model.ts +69 -28
- package/src/activities/agent-turn/history-sink.ts +16 -2
- package/src/activities/agent-turn/history.ts +38 -11
- package/src/activities/agent-turn/input-wait-reply.ts +103 -0
- package/src/activities/agent-turn/knowledge-source-tools.ts +2 -0
- package/src/activities/agent-turn/media-artifacts.ts +2 -1
- package/src/activities/agent-turn/model-call-admission.ts +94 -0
- package/src/activities/agent-turn/model-usage.ts +64 -3
- 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/provider-dispatch-barrier.ts +22 -0
- package/src/activities/agent-turn/quiescence.ts +10 -7
- package/src/activities/agent-turn/recovery-warning.ts +16 -0
- package/src/activities/agent-turn/refresh-credentials.ts +44 -0
- package/src/activities/agent-turn/run-credentials.ts +116 -55
- package/src/activities/agent-turn/run.ts +320 -93
- package/src/activities/agent-turn/sandbox-establish.ts +84 -8
- package/src/activities/agent-turn/sandbox-provision.ts +3 -1
- package/src/activities/agent-turn/sandbox-route.ts +4 -21
- package/src/activities/agent-turn/sandbox-runtime.ts +343 -18
- package/src/activities/agent-turn/session-title.ts +81 -5
- 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-remove.ts +46 -0
- package/src/activities/agent-turn/skill-save.ts +1 -1
- package/src/activities/agent-turn/skill-search.ts +10 -1
- package/src/activities/agent-turn/skill-selection.ts +4 -0
- package/src/activities/agent-turn/skill-tools.ts +112 -18
- package/src/activities/agent-turn/skill-transfer.ts +68 -23
- package/src/activities/agent-turn/stream-attempt.ts +313 -77
- package/src/activities/agent-turn/subscription-lease.ts +115 -0
- package/src/activities/agent-turn/tool-environment.ts +316 -167
- package/src/activities/agent-turn/tool-policy.ts +80 -1
- package/src/activities/agent-turn/turn-context.ts +35 -0
- package/src/activities/agent-turn/turn-sandbox-access.ts +7 -1
- package/src/activities/agent-turn/xai-capacity.ts +94 -51
- package/src/activities/automations.ts +76 -4
- package/src/activities/browser-deadline-checkpoint.ts +279 -0
- package/src/activities/capabilities.ts +108 -11
- package/src/activities/codemode-dispatcher.ts +36 -8
- package/src/activities/codex-capacity.ts +60 -25
- package/src/activities/codex-rotation.ts +39 -17
- package/src/activities/context-compaction.ts +75 -18
- package/src/activities/gmail-files.ts +88 -0
- package/src/activities/goals.ts +116 -121
- package/src/activities/google-drive-publication.ts +1 -3
- package/src/activities/image-generation-operation.ts +1 -1
- package/src/activities/knowledge-indexing.ts +269 -15
- package/src/activities/knowledge-source-sync.ts +10 -0
- package/src/activities/mcp-account-routes.ts +17 -0
- package/src/activities/mcp-credentials.ts +83 -194
- package/src/activities/mcp-operation-authority.ts +16 -41
- package/src/activities/model-call-fact-reconciler.ts +112 -0
- package/src/activities/open-suffix-resume.ts +15 -2
- package/src/activities/parent-wake.ts +46 -21
- package/src/activities/retained-screenshots.ts +82 -11
- package/src/activities/rig-verification.ts +38 -37
- package/src/activities/run-credential-renewal.ts +13 -1
- package/src/activities/run-credentials.ts +59 -17
- package/src/activities/run-input.ts +25 -16
- package/src/activities/sandbox-images.ts +0 -1
- package/src/activities/sandbox-lease.ts +798 -82
- package/src/activities/scheduled-tasks.ts +550 -178
- package/src/activities/session-state.ts +245 -6
- package/src/activities/site-auth-maintenance.ts +3 -0
- package/src/activities/types.ts +72 -5
- package/src/activities/workflow-wake.ts +2 -17
- package/src/activities/workspace-capture.ts +13 -2
- package/src/activities/workspace-credential-provider.ts +283 -0
- package/src/activities-control.ts +4 -0
- package/src/activities-turn.ts +5 -0
- package/src/activities.ts +13 -0
- package/src/activity-services.ts +16 -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 +7 -3
- package/src/editable-artifact-outbox-service.ts +4 -4
- package/src/github-rest-mcp.ts +1 -2
- package/src/host-export-pump.ts +26 -4
- package/src/host-export.ts +3 -0
- package/src/http.ts +4 -2
- package/src/index.ts +99 -37
- package/src/observability-metrics.ts +510 -5
- package/src/personal-github-git-credentials.ts +2 -1
- package/src/pr-review-credentials.ts +1 -3
- package/src/retained-process-diagnostics.ts +50 -0
- package/src/retained-process-retry.ts +36 -0
- package/src/sandbox-resume.ts +388 -101
- package/src/sandbox-routing.ts +150 -25
- package/src/sandbox-snapshot-diagnostics.ts +112 -0
- package/src/session-event-fanout.ts +23 -0
- package/src/warm-capture-holder.ts +15 -0
- package/src/worker-service-lifecycle.ts +53 -0
- package/src/workflows/activities.ts +16 -1
- package/src/workflows/browser-deadline-checkpoint.ts +50 -0
- package/src/workflows/file-upload-reaper.ts +2 -0
- package/src/workflows/scheduled-tasks.ts +26 -13
- package/src/workflows/session.ts +242 -22
- package/src/workflows.ts +4 -0
- package/dist/activities/agent-turn/knowledge-sources.d.ts +0 -20
- package/dist/activities/packs.d.ts +0 -55
- package/dist/activities-control-HMFGSKC5.js.map +0 -1
- package/dist/activities-turn-AP67JADS.js.map +0 -1
- package/dist/chunk-A4XQWVZK.js.map +0 -1
- package/dist/chunk-CYITU5UH.js.map +0 -1
- package/dist/chunk-RAMNYSAW.js.map +0 -1
- package/src/activities/agent-turn/knowledge-sources.ts +0 -86
- package/src/activities/packs.ts +0 -166
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
// src/observability-metrics.ts
|
|
2
2
|
import { createHash } from "crypto";
|
|
3
3
|
import { errorCodeToJSON } from "@opengeni/agent-proto";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
BundledSkillId,
|
|
6
|
+
CREDIT_GRANT_CLASSES,
|
|
7
|
+
SandboxBackend
|
|
8
|
+
} from "@opengeni/contracts";
|
|
9
|
+
import {
|
|
10
|
+
ACTIVE_USER_WINDOWS
|
|
11
|
+
} from "@opengeni/db";
|
|
12
|
+
import {
|
|
13
|
+
natsSubscriptionTerminationCounter
|
|
14
|
+
} from "@opengeni/events";
|
|
5
15
|
|
|
6
16
|
// src/opensandbox-kubernetes-inventory.ts
|
|
7
17
|
import { readFile } from "fs/promises";
|
|
@@ -243,6 +253,12 @@ var CONTEXT_COMPACTIONS_METRIC = {
|
|
|
243
253
|
name: "opengeni_context_compactions_total",
|
|
244
254
|
help: "Total completed context compactions, by trigger."
|
|
245
255
|
};
|
|
256
|
+
function observabilityEventBusOptions(observability) {
|
|
257
|
+
return {
|
|
258
|
+
logger: observabilityEventLogger(observability),
|
|
259
|
+
onSubscriptionTerminated: natsSubscriptionTerminationCounter(observability)
|
|
260
|
+
};
|
|
261
|
+
}
|
|
246
262
|
function observabilityEventLogger(observability) {
|
|
247
263
|
return {
|
|
248
264
|
debug: (message, attributes) => observability.debug(message, eventAttributes(attributes)),
|
|
@@ -272,6 +288,10 @@ function eventAttributeValue(value) {
|
|
|
272
288
|
function runtimeMetricsHooksForObservability(observability) {
|
|
273
289
|
return {
|
|
274
290
|
onModelCall: ({ provider, outcome, durationSeconds }) => {
|
|
291
|
+
completedOperationSpan(observability, "worker.model.call", durationSeconds, {
|
|
292
|
+
provider,
|
|
293
|
+
outcome
|
|
294
|
+
});
|
|
275
295
|
observability.incrementCounter({
|
|
276
296
|
name: "opengeni_model_calls_total",
|
|
277
297
|
help: "Total model calls by provider and outcome.",
|
|
@@ -304,6 +324,13 @@ function runtimeMetricsHooksForObservability(observability) {
|
|
|
304
324
|
labels: { backend, stage }
|
|
305
325
|
});
|
|
306
326
|
},
|
|
327
|
+
onSandboxReadinessReplacement: ({ backend, outcome }) => {
|
|
328
|
+
observability.incrementCounter({
|
|
329
|
+
name: "opengeni_sandbox_readiness_replacements_total",
|
|
330
|
+
help: "Fresh sandbox command-readiness replacement decisions by backend and outcome.",
|
|
331
|
+
labels: { backend, outcome }
|
|
332
|
+
});
|
|
333
|
+
},
|
|
307
334
|
onSandboxProviderApiThrottle: ({ backend, operation }) => {
|
|
308
335
|
observability.incrementCounter({
|
|
309
336
|
name: "opengeni_sandbox_provider_api_throttles_total",
|
|
@@ -325,6 +352,20 @@ function runtimeMetricsHooksForObservability(observability) {
|
|
|
325
352
|
labels: { outcome, port: String(port) }
|
|
326
353
|
});
|
|
327
354
|
},
|
|
355
|
+
onWorkspaceCapture: ({ backend, outcome, durationSeconds }) => {
|
|
356
|
+
if (!Number.isFinite(durationSeconds) || durationSeconds < 0) return;
|
|
357
|
+
const safeBackend = SandboxBackend.safeParse(backend).success ? backend : "unknown";
|
|
358
|
+
completedOperationSpan(observability, "worker.workspace_capture", durationSeconds, {
|
|
359
|
+
backend: safeBackend,
|
|
360
|
+
outcome
|
|
361
|
+
});
|
|
362
|
+
observability.observeHistogram({
|
|
363
|
+
name: "opengeni_workspace_capture_duration_seconds",
|
|
364
|
+
help: "Physical warm workspace capture and publication duration, including late settlement after caller timeout.",
|
|
365
|
+
labels: { backend: safeBackend, outcome },
|
|
366
|
+
value: durationSeconds
|
|
367
|
+
});
|
|
368
|
+
},
|
|
328
369
|
onWorkspaceArchiveObject: ({ outcome, backend }) => {
|
|
329
370
|
observability.incrementCounter({
|
|
330
371
|
name: "opengeni_workspace_archive_object_total",
|
|
@@ -333,6 +374,7 @@ function runtimeMetricsHooksForObservability(observability) {
|
|
|
333
374
|
});
|
|
334
375
|
},
|
|
335
376
|
onMcpToolCall: ({ outcome, durationSeconds }) => {
|
|
377
|
+
completedOperationSpan(observability, "worker.mcp.tool_call", durationSeconds, { outcome });
|
|
336
378
|
observability.incrementCounter({
|
|
337
379
|
name: "opengeni_mcp_tool_calls_total",
|
|
338
380
|
help: "Total physical MCP tool calls by bounded structural outcome.",
|
|
@@ -1026,6 +1068,54 @@ function recordCreditBalanceGauges(observability, balances) {
|
|
|
1026
1068
|
}
|
|
1027
1069
|
creditBalanceGaugeAccounts.set(observability, current);
|
|
1028
1070
|
}
|
|
1071
|
+
function recordActiveUserGauges(observability, counts) {
|
|
1072
|
+
for (const window of ACTIVE_USER_WINDOWS) {
|
|
1073
|
+
observability.setGauge({
|
|
1074
|
+
name: "opengeni_active_users",
|
|
1075
|
+
help: "Distinct managed users with authenticated activity within the window (global; use max across pods).",
|
|
1076
|
+
labels: { window },
|
|
1077
|
+
value: counts[window]
|
|
1078
|
+
});
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
function recordCreditGrantGauges(observability, totals) {
|
|
1082
|
+
for (const grantClass of CREDIT_GRANT_CLASSES) {
|
|
1083
|
+
const total = totals[grantClass];
|
|
1084
|
+
observability.setGauge({
|
|
1085
|
+
name: "opengeni_credit_grants_total",
|
|
1086
|
+
help: "Positive credit grants observed in the ledger since migration 0565, by grant class (global cumulative; use max across pods).",
|
|
1087
|
+
labels: { grant_class: grantClass },
|
|
1088
|
+
value: total.count
|
|
1089
|
+
});
|
|
1090
|
+
observability.setGauge({
|
|
1091
|
+
name: "opengeni_credit_granted_micros_total",
|
|
1092
|
+
help: "Credit micros granted in the ledger since migration 0565, by grant class (global cumulative; use max across pods).",
|
|
1093
|
+
labels: { grant_class: grantClass },
|
|
1094
|
+
value: total.micros
|
|
1095
|
+
});
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
function recordVerifiedSignupTrialSwitchGauge(observability, grantsEnabled) {
|
|
1099
|
+
observability.setGauge({
|
|
1100
|
+
name: "opengeni_verified_signup_trial_credits_runtime_enabled",
|
|
1101
|
+
help: "Whether the runtime switch allows new verified signup trial credit grants (1) or blocks them (0).",
|
|
1102
|
+
value: grantsEnabled ? 1 : 0
|
|
1103
|
+
});
|
|
1104
|
+
}
|
|
1105
|
+
function recordManagedAuthNewSignupsSwitchGauge(observability, signupsEnabled) {
|
|
1106
|
+
observability.setGauge({
|
|
1107
|
+
name: "opengeni_managed_auth_new_signups_runtime_enabled",
|
|
1108
|
+
help: "Whether the runtime switch allows new managed account sign-ups (1) or has paused them (0).",
|
|
1109
|
+
value: signupsEnabled ? 1 : 0
|
|
1110
|
+
});
|
|
1111
|
+
}
|
|
1112
|
+
function recordVerifiedSignupTrialDeploymentFlagGauge(observability, enabled) {
|
|
1113
|
+
observability.setGauge({
|
|
1114
|
+
name: "opengeni_verified_signup_trial_credits_deployment_enabled",
|
|
1115
|
+
help: "Whether the OPENGENI_VERIFIED_SIGNUP_TRIAL_CREDITS_ENABLED master opt-in is on (1) or off (0) in this deployment's configuration.",
|
|
1116
|
+
value: enabled ? 1 : 0
|
|
1117
|
+
});
|
|
1118
|
+
}
|
|
1029
1119
|
function recordSandboxOrphansTerminated(observability, count) {
|
|
1030
1120
|
if (count <= 0) {
|
|
1031
1121
|
return;
|
|
@@ -1071,6 +1161,47 @@ function recordSandboxDeadlineRotationsRequested(observability, count) {
|
|
|
1071
1161
|
amount: count
|
|
1072
1162
|
});
|
|
1073
1163
|
}
|
|
1164
|
+
function recordSandboxCommandContainment(observability, outcome) {
|
|
1165
|
+
observability.incrementCounter({
|
|
1166
|
+
name: "opengeni_sandbox_command_containment_total",
|
|
1167
|
+
help: "Legacy retained-command containment inspections and enrolled drain commits by fixed outcome.",
|
|
1168
|
+
labels: { outcome }
|
|
1169
|
+
});
|
|
1170
|
+
}
|
|
1171
|
+
function recordSandboxProviderMissingBeforeCapture(observability, backend) {
|
|
1172
|
+
const safeBackend = SandboxBackend.safeParse(backend).success ? backend : "unknown";
|
|
1173
|
+
observability.incrementCounter({
|
|
1174
|
+
name: "opengeni_sandbox_provider_missing_before_capture_total",
|
|
1175
|
+
help: "Exact sandbox cold commits after definitive provider disappearance before workspace capture.",
|
|
1176
|
+
labels: { backend: safeBackend }
|
|
1177
|
+
});
|
|
1178
|
+
}
|
|
1179
|
+
function recordSandboxRecoveryObservationGauges(observability, observations) {
|
|
1180
|
+
for (const [kind, value] of [
|
|
1181
|
+
["provider_missing_before_capture", observations.providerLosses],
|
|
1182
|
+
["checkpoint_fallback_selected", observations.fallbackSelections],
|
|
1183
|
+
["fresh_workspace_selected", observations.freshWorkspaceSelections ?? 0]
|
|
1184
|
+
]) {
|
|
1185
|
+
observability.setGauge({
|
|
1186
|
+
name: "opengeni_sandbox_recovery_observations_recent",
|
|
1187
|
+
help: "Committed sandbox recovery observations in the last 30 minutes by fixed kind.",
|
|
1188
|
+
labels: { kind },
|
|
1189
|
+
value
|
|
1190
|
+
});
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
function sandboxAutomaticRecoveryOutcome(input) {
|
|
1194
|
+
if (input.lane === "fresh_workspace") return "fresh_workspace";
|
|
1195
|
+
return input.groupSessionCount > 1 ? "selected_shared" : "selected";
|
|
1196
|
+
}
|
|
1197
|
+
function recordSandboxAutomaticRecoverySelected(observability, backend, outcome) {
|
|
1198
|
+
const safeBackend = SandboxBackend.safeParse(backend).success ? backend : "unknown";
|
|
1199
|
+
observability.incrementCounter({
|
|
1200
|
+
name: "opengeni_sandbox_checkpoint_fallback_total",
|
|
1201
|
+
help: "System-selected continuity after managed provider loss: verified checkpoint or empty workspace.",
|
|
1202
|
+
labels: { backend: safeBackend, outcome }
|
|
1203
|
+
});
|
|
1204
|
+
}
|
|
1074
1205
|
function recordSandboxRotationBacklogGauges(observability, backlog) {
|
|
1075
1206
|
const values = {
|
|
1076
1207
|
requested: backlog.requested,
|
|
@@ -1241,6 +1372,12 @@ function turnStartupCountBucket(count) {
|
|
|
1241
1372
|
return "21+";
|
|
1242
1373
|
}
|
|
1243
1374
|
function recordTurnStartupPhase(observability, input) {
|
|
1375
|
+
completedOperationSpan(observability, `worker.prepare.${input.phase}`, input.durationSeconds, {
|
|
1376
|
+
provider: input.provider,
|
|
1377
|
+
backend: input.backend,
|
|
1378
|
+
outcome: input.outcome,
|
|
1379
|
+
...input.phase === "claim_and_policy" && /^turn_[0-9a-f]{32}$/.test(input.executionCorrelationId ?? "") ? { correlationId: input.executionCorrelationId } : {}
|
|
1380
|
+
});
|
|
1244
1381
|
observability.observeHistogram({
|
|
1245
1382
|
name: "opengeni_turn_startup_phase_duration_seconds",
|
|
1246
1383
|
help: "Turn startup phase duration before the model response stream begins.",
|
|
@@ -1256,6 +1393,74 @@ function recordTurnStartupPhase(observability, input) {
|
|
|
1256
1393
|
value: Math.max(0, input.durationSeconds)
|
|
1257
1394
|
});
|
|
1258
1395
|
}
|
|
1396
|
+
async function measureTurnStartupPhase(observability, input, work) {
|
|
1397
|
+
const started = performance.now();
|
|
1398
|
+
let outcome = "failed";
|
|
1399
|
+
try {
|
|
1400
|
+
const result = await work();
|
|
1401
|
+
outcome = "completed";
|
|
1402
|
+
return result;
|
|
1403
|
+
} finally {
|
|
1404
|
+
try {
|
|
1405
|
+
recordTurnStartupPhase(observability, {
|
|
1406
|
+
...input,
|
|
1407
|
+
outcome,
|
|
1408
|
+
durationSeconds: (performance.now() - started) / 1e3
|
|
1409
|
+
});
|
|
1410
|
+
} catch {
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
function recordToolPreparationPhase(observability, input) {
|
|
1415
|
+
if (input.execution === "blocking") {
|
|
1416
|
+
recordTurnStartupPhase(observability, {
|
|
1417
|
+
...input,
|
|
1418
|
+
phase: `tool_${input.phase}`
|
|
1419
|
+
});
|
|
1420
|
+
return;
|
|
1421
|
+
}
|
|
1422
|
+
completedOperationSpan(
|
|
1423
|
+
observability,
|
|
1424
|
+
`worker.tool_prepare.${input.phase}`,
|
|
1425
|
+
input.durationSeconds,
|
|
1426
|
+
{
|
|
1427
|
+
provider: input.provider,
|
|
1428
|
+
backend: input.backend,
|
|
1429
|
+
outcome: input.outcome
|
|
1430
|
+
}
|
|
1431
|
+
);
|
|
1432
|
+
observability.observeHistogram({
|
|
1433
|
+
name: "opengeni_tool_background_preparation_duration_seconds",
|
|
1434
|
+
help: "Nonblocking MCP preparation operations; may overlap startup and later execution.",
|
|
1435
|
+
buckets: TURN_STARTUP_PHASE_BUCKETS,
|
|
1436
|
+
labels: {
|
|
1437
|
+
phase: input.phase,
|
|
1438
|
+
provider: input.provider,
|
|
1439
|
+
backend: input.backend,
|
|
1440
|
+
outcome: input.outcome
|
|
1441
|
+
},
|
|
1442
|
+
value: Math.max(0, input.durationSeconds)
|
|
1443
|
+
});
|
|
1444
|
+
}
|
|
1445
|
+
function completedOperationSpan(observability, name, durationSeconds, attributes) {
|
|
1446
|
+
if (!Number.isFinite(durationSeconds) || durationSeconds < 0) return;
|
|
1447
|
+
try {
|
|
1448
|
+
const failed = [
|
|
1449
|
+
"failed",
|
|
1450
|
+
"error",
|
|
1451
|
+
"provider_declared_error",
|
|
1452
|
+
"auth_needed",
|
|
1453
|
+
"outcome_uncertain",
|
|
1454
|
+
"timeout",
|
|
1455
|
+
"thrown_transport_error",
|
|
1456
|
+
"thrown_protocol_error"
|
|
1457
|
+
].includes(attributes.outcome);
|
|
1458
|
+
observability.startSpan(name, attributes, { startTimeMs: Date.now() - durationSeconds * 1e3 }).end({
|
|
1459
|
+
...failed ? { error: true } : {}
|
|
1460
|
+
});
|
|
1461
|
+
} catch {
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1259
1464
|
function recordTurnSandboxEstablishPolicy(observability, input) {
|
|
1260
1465
|
observability.incrementCounter({
|
|
1261
1466
|
name: "opengeni_turn_sandbox_establish_policy_total",
|
|
@@ -1647,10 +1852,93 @@ function modelCallAccountContext(input) {
|
|
|
1647
1852
|
accountChangedFromPrevCall
|
|
1648
1853
|
};
|
|
1649
1854
|
}
|
|
1855
|
+
function recordCodeSearchCall(observability, input) {
|
|
1856
|
+
observability.incrementCounter({
|
|
1857
|
+
name: "opengeni_code_search_calls_total",
|
|
1858
|
+
help: "Jev-backed code_search tool calls by outcome.",
|
|
1859
|
+
labels: { outcome: input.outcome }
|
|
1860
|
+
});
|
|
1861
|
+
observability.observeHistogram({
|
|
1862
|
+
name: "opengeni_code_search_duration_seconds",
|
|
1863
|
+
help: "Wall time of one code_search tool call.",
|
|
1864
|
+
buckets: [0.5, 1, 2, 4, 8, 15, 30, 60],
|
|
1865
|
+
labels: { outcome: input.outcome },
|
|
1866
|
+
value: Math.max(0, input.durationSeconds)
|
|
1867
|
+
});
|
|
1868
|
+
if (input.jevRequests > 0) {
|
|
1869
|
+
observability.incrementCounter({
|
|
1870
|
+
name: "opengeni_code_search_jev_requests_total",
|
|
1871
|
+
help: "Jev requests made by code_search.",
|
|
1872
|
+
amount: input.jevRequests
|
|
1873
|
+
});
|
|
1874
|
+
}
|
|
1875
|
+
if (input.jevCostUsd > 0) {
|
|
1876
|
+
observability.incrementCounter({
|
|
1877
|
+
name: "opengeni_code_search_jev_cost_micro_usd_total",
|
|
1878
|
+
help: "Estimated Jev list-price cost of code_search, in micro-USD.",
|
|
1879
|
+
amount: Math.round(input.jevCostUsd * 1e6)
|
|
1880
|
+
});
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
function recordSkillRead(observability, read) {
|
|
1884
|
+
observability.incrementCounter({
|
|
1885
|
+
name: "opengeni_skill_reads_total",
|
|
1886
|
+
help: "skill_read calls by Skill source, built-in Skill id (custom for any other Skill), result kind, and caller.",
|
|
1887
|
+
labels: {
|
|
1888
|
+
source: read.source ?? "unknown",
|
|
1889
|
+
skill: skillReadMetricLabel(read.source, read.skill),
|
|
1890
|
+
kind: read.kind,
|
|
1891
|
+
caller: read.caller
|
|
1892
|
+
}
|
|
1893
|
+
});
|
|
1894
|
+
}
|
|
1895
|
+
function recordSkillCheckout(observability, checkout) {
|
|
1896
|
+
observability.incrementCounter({
|
|
1897
|
+
name: "opengeni_skill_checkouts_total",
|
|
1898
|
+
help: "skill_checkout calls by outcome and whether they selected specific paths.",
|
|
1899
|
+
labels: { outcome: checkout.outcome, selection: checkout.selection }
|
|
1900
|
+
});
|
|
1901
|
+
const phases = [
|
|
1902
|
+
["resolve", checkout.resolveSeconds],
|
|
1903
|
+
["sandbox", checkout.sandboxSeconds],
|
|
1904
|
+
["write", checkout.writeSeconds],
|
|
1905
|
+
["total", checkout.totalSeconds]
|
|
1906
|
+
];
|
|
1907
|
+
for (const [phase, seconds] of phases) {
|
|
1908
|
+
if (seconds === null) continue;
|
|
1909
|
+
observability.observeHistogram({
|
|
1910
|
+
name: "opengeni_skill_checkout_duration_seconds",
|
|
1911
|
+
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.",
|
|
1912
|
+
buckets: [0.05, 0.1, 0.25, 0.5, 1, 2, 4, 8, 15, 30, 60],
|
|
1913
|
+
labels: { phase, outcome: checkout.outcome },
|
|
1914
|
+
value: Math.max(0, seconds)
|
|
1915
|
+
});
|
|
1916
|
+
}
|
|
1917
|
+
for (const [result, amount] of [
|
|
1918
|
+
["written", checkout.written],
|
|
1919
|
+
["unchanged", checkout.unchanged]
|
|
1920
|
+
]) {
|
|
1921
|
+
if (amount <= 0) continue;
|
|
1922
|
+
observability.incrementCounter({
|
|
1923
|
+
name: "opengeni_skill_checkout_files_total",
|
|
1924
|
+
help: "Files skill_checkout wrote or found already present with the same content.",
|
|
1925
|
+
labels: { result },
|
|
1926
|
+
amount
|
|
1927
|
+
});
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1930
|
+
function skillReadMetricLabel(source, skill) {
|
|
1931
|
+
if (source !== null && source !== "builtin") return "custom";
|
|
1932
|
+
for (const candidate of source === null ? [skill, `builtin:${skill}`] : [skill]) {
|
|
1933
|
+
const parsed = BundledSkillId.safeParse(candidate);
|
|
1934
|
+
if (parsed.success) return parsed.data;
|
|
1935
|
+
}
|
|
1936
|
+
return "custom";
|
|
1937
|
+
}
|
|
1650
1938
|
|
|
1651
1939
|
export {
|
|
1652
1940
|
inspectOpenSandboxKubernetesInventory,
|
|
1653
|
-
|
|
1941
|
+
observabilityEventBusOptions,
|
|
1654
1942
|
runtimeMetricsHooksForObservability,
|
|
1655
1943
|
makeMachineOpObserver,
|
|
1656
1944
|
turnLifecycleMetricsFor,
|
|
@@ -1668,10 +1956,20 @@ export {
|
|
|
1668
1956
|
recordSandboxInventoryProjectionSuccess,
|
|
1669
1957
|
recordSandboxInventoryProjectionFailure,
|
|
1670
1958
|
recordCreditBalanceGauges,
|
|
1959
|
+
recordActiveUserGauges,
|
|
1960
|
+
recordCreditGrantGauges,
|
|
1961
|
+
recordVerifiedSignupTrialSwitchGauge,
|
|
1962
|
+
recordManagedAuthNewSignupsSwitchGauge,
|
|
1963
|
+
recordVerifiedSignupTrialDeploymentFlagGauge,
|
|
1671
1964
|
recordSandboxOrphansTerminated,
|
|
1672
1965
|
recordSandboxCheckpointArtifactGauges,
|
|
1673
1966
|
recordSandboxCheckpointArtifactOutcome,
|
|
1674
1967
|
recordSandboxDeadlineRotationsRequested,
|
|
1968
|
+
recordSandboxCommandContainment,
|
|
1969
|
+
recordSandboxProviderMissingBeforeCapture,
|
|
1970
|
+
recordSandboxRecoveryObservationGauges,
|
|
1971
|
+
sandboxAutomaticRecoveryOutcome,
|
|
1972
|
+
recordSandboxAutomaticRecoverySelected,
|
|
1675
1973
|
recordSandboxRotationBacklogGauges,
|
|
1676
1974
|
recordRetainedProcessInventoryGauges,
|
|
1677
1975
|
recordExpiredDrainingSandboxLeaseGauges,
|
|
@@ -1679,6 +1977,8 @@ export {
|
|
|
1679
1977
|
recordCreditMicros,
|
|
1680
1978
|
recordModelRequestPhase,
|
|
1681
1979
|
recordTurnStartupPhase,
|
|
1980
|
+
measureTurnStartupPhase,
|
|
1981
|
+
recordToolPreparationPhase,
|
|
1682
1982
|
recordTurnSandboxEstablishPolicy,
|
|
1683
1983
|
recordSandboxProvisionAttempt,
|
|
1684
1984
|
recordSandboxLogicalProvision,
|
|
@@ -1695,6 +1995,9 @@ export {
|
|
|
1695
1995
|
recordContextCompactionStarted,
|
|
1696
1996
|
recordCompanyBrainContributions,
|
|
1697
1997
|
recordModelCacheTokens,
|
|
1698
|
-
modelCallAccountContext
|
|
1998
|
+
modelCallAccountContext,
|
|
1999
|
+
recordCodeSearchCall,
|
|
2000
|
+
recordSkillRead,
|
|
2001
|
+
recordSkillCheckout
|
|
1699
2002
|
};
|
|
1700
|
-
//# sourceMappingURL=chunk-
|
|
2003
|
+
//# sourceMappingURL=chunk-3ZTRWDMN.js.map
|