@opengeni/worker-bundle 0.22.8 → 0.23.4-canary.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-turn/admission.d.ts +10 -2
- package/dist/activities/agent-turn/agent-build.d.ts +1 -4
- package/dist/activities/agent-turn/claim.d.ts +3 -4
- package/dist/activities/agent-turn/codex.d.ts +8 -7
- package/dist/activities/agent-turn/compaction-prep.d.ts +2 -0
- package/dist/activities/agent-turn/errors.d.ts +13 -0
- package/dist/activities/agent-turn/finalization.d.ts +1 -3
- package/dist/activities/agent-turn/list-models.d.ts +16 -0
- package/dist/activities/agent-turn/model-usage.d.ts +10 -1
- package/dist/activities/agent-turn/quiescence.d.ts +39 -0
- package/dist/activities/agent-turn/sandbox-route.d.ts +14 -24
- package/dist/activities/agent-turn/sandbox-runtime.d.ts +1 -4
- package/dist/activities/agent-turn/sandbox-shared-preparation.d.ts +30 -0
- package/dist/activities/agent-turn/stream-attempt.d.ts +7 -0
- package/dist/activities/agent-turn/tool-environment.d.ts +1 -0
- package/dist/activities/agent-turn/tool-policy.d.ts +7 -5
- package/dist/activities/agent-turn/turn-context.d.ts +3 -8
- package/dist/activities/agent-turn/turn-sandbox-access.d.ts +12 -0
- package/dist/activities/agent-turn/video-reference-sandbox.d.ts +7 -0
- package/dist/activities/automations.d.ts +1 -0
- package/dist/activities/capabilities.d.ts +2 -1
- package/dist/activities/codex-rotation.d.ts +2 -0
- package/dist/activities/goals.d.ts +11 -0
- package/dist/activities/image-generation-references.d.ts +2 -1
- package/dist/activities/scheduled-tasks.d.ts +1 -0
- package/dist/activities/session-state.d.ts +2 -1
- package/dist/activities/types.d.ts +8 -0
- package/dist/{activities-control-VZIIV7RX.js → activities-control-SGU2WEVB.js} +328 -107
- package/dist/activities-control-SGU2WEVB.js.map +1 -0
- package/dist/activities-control.d.ts +2 -0
- package/dist/{activities-turn-5RGQDBFV.js → activities-turn-7EAQXW6Q.js} +828 -540
- package/dist/activities-turn-7EAQXW6Q.js.map +1 -0
- package/dist/activities.d.ts +2 -0
- package/dist/{chunk-O4HDX5SC.js → chunk-S2QVRVJW.js} +227 -36
- package/dist/chunk-S2QVRVJW.js.map +1 -0
- package/dist/{chunk-NAVSAZ56.js → chunk-TJIPCHMP.js} +162 -2
- package/dist/chunk-TJIPCHMP.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +69 -6
- package/dist/index.js.map +1 -1
- package/dist/observability-metrics.d.ts +29 -0
- package/dist/personal-github-git-credentials.d.ts +1 -0
- package/dist/unhandled-rejection-boundary.d.ts +29 -0
- package/dist/workflow-bundle.js +26 -3
- package/dist/workflows/activities.d.ts +5 -0
- package/dist/workflows/automations.d.ts +5 -0
- package/package.json +18 -18
- package/src/activities/agent-run-admission.ts +7 -1
- package/src/activities/agent-turn/admission.ts +28 -6
- package/src/activities/agent-turn/agent-build.ts +15 -31
- package/src/activities/agent-turn/claim.ts +53 -72
- package/src/activities/agent-turn/codex.ts +21 -12
- package/src/activities/agent-turn/compaction-prep.ts +52 -1
- package/src/activities/agent-turn/errors.ts +78 -0
- package/src/activities/agent-turn/failure-settlement.ts +30 -19
- package/src/activities/agent-turn/finalization.ts +24 -21
- package/src/activities/agent-turn/history.ts +5 -1
- package/src/activities/agent-turn/list-models.ts +101 -0
- package/src/activities/agent-turn/model-usage.ts +88 -42
- package/src/activities/agent-turn/quiescence.ts +86 -0
- package/src/activities/agent-turn/run-credentials.ts +12 -1
- package/src/activities/agent-turn/run.ts +20 -14
- package/src/activities/agent-turn/sandbox-establish.ts +46 -11
- package/src/activities/agent-turn/sandbox-route.ts +21 -25
- package/src/activities/agent-turn/sandbox-runtime.ts +1 -116
- package/src/activities/agent-turn/sandbox-shared-preparation.ts +206 -0
- package/src/activities/agent-turn/stream-attempt.ts +106 -14
- package/src/activities/agent-turn/tool-environment.ts +72 -14
- package/src/activities/agent-turn/tool-policy.ts +7 -6
- package/src/activities/agent-turn/turn-context.ts +12 -14
- package/src/activities/agent-turn/{image-reference-sandbox.ts → turn-sandbox-access.ts} +15 -13
- package/src/activities/agent-turn/video-reference-sandbox.ts +23 -0
- package/src/activities/automations.ts +122 -67
- package/src/activities/capabilities.ts +72 -2
- package/src/activities/codex-capacity.ts +13 -5
- package/src/activities/codex-rotation.ts +17 -0
- package/src/activities/goals.ts +117 -35
- package/src/activities/image-generation-references.ts +9 -9
- package/src/activities/retained-screenshots.ts +104 -21
- package/src/activities/sandbox-lease.ts +7 -4
- package/src/activities/scheduled-tasks.ts +248 -30
- package/src/activities/session-state.ts +8 -1
- package/src/activities/site-auth-maintenance.ts +12 -12
- package/src/activities/types.ts +6 -0
- package/src/activities.ts +1 -0
- package/src/activity-services.ts +4 -1
- package/src/github-rest-mcp.ts +8 -4
- package/src/http.ts +3 -0
- package/src/index.ts +38 -4
- package/src/observability-metrics.ts +202 -0
- package/src/personal-github-git-credentials.ts +45 -4
- package/src/sandbox-resume.ts +1 -1
- package/src/sandbox-routing.ts +7 -4
- package/src/unhandled-rejection-boundary.ts +73 -0
- package/src/workflows/activities.ts +15 -0
- package/src/workflows/automations.ts +21 -2
- package/dist/activities/agent-turn/image-reference-sandbox.d.ts +0 -14
- package/dist/activities/recording.d.ts +0 -90
- package/dist/activities-control-VZIIV7RX.js.map +0 -1
- package/dist/activities-turn-5RGQDBFV.js.map +0 -1
- package/dist/chunk-NAVSAZ56.js.map +0 -1
- package/dist/chunk-O4HDX5SC.js.map +0 -1
- package/src/activities/recording.ts +0 -279
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { type SessionEventType } from "@opengeni/contracts";
|
|
2
|
+
import type { SessionEventAppendPhaseObservation } from "@opengeni/db";
|
|
2
3
|
import type { EventLogger } from "@opengeni/events";
|
|
3
4
|
import type { Observability } from "@opengeni/observability";
|
|
4
5
|
import type { CompanyBrainContributionReceipt } from "./model-context-contributions.js";
|
|
5
6
|
import { type OpenSandboxKubernetesInventory } from "./opensandbox-kubernetes-inventory.js";
|
|
6
7
|
import { type RuntimeMetricsHooks, type SelfhostedOpObservation, type SelfhostedOpObserver } from "@opengeni/runtime";
|
|
7
8
|
export type TurnOutcome = "completed" | "failed" | "cancelled" | "recovering";
|
|
9
|
+
export type WorkerDeathRecoveryOutcome = "recovering" | "exhausted";
|
|
8
10
|
export type CreditMicrosKind = "usage" | "grant" | "topup" | "refund";
|
|
9
11
|
export type SandboxLeaseLiveness = "cold" | "warming" | "warm" | "draining";
|
|
10
12
|
export type CreditBalanceGauge = {
|
|
@@ -18,6 +20,10 @@ export type TurnTaskQueueStats = {
|
|
|
18
20
|
tasksAddRate: number;
|
|
19
21
|
tasksDispatchRate: number;
|
|
20
22
|
};
|
|
23
|
+
export type SessionRecoveryBacklog = {
|
|
24
|
+
quiescence_missing: number;
|
|
25
|
+
projection_stale: number;
|
|
26
|
+
};
|
|
21
27
|
export type TemporalTurnTaskQueueStats = {
|
|
22
28
|
approximateBacklogCount?: unknown;
|
|
23
29
|
approximateBacklogAge?: {
|
|
@@ -64,6 +70,11 @@ export declare function makeMachineOpObserver(hooks: RuntimeMetricsHooks): {
|
|
|
64
70
|
drainEvents(): MachineOpSessionEvent[];
|
|
65
71
|
};
|
|
66
72
|
export declare function turnLifecycleMetricsFor(observability: Observability): TurnLifecycleMetrics;
|
|
73
|
+
export declare function initializeWorkerOutcomeMetrics(observability: Observability): void;
|
|
74
|
+
export declare function recordWorkerDeathRecoveryMetrics(observability: Observability, input: {
|
|
75
|
+
outcome: WorkerDeathRecoveryOutcome;
|
|
76
|
+
timeoutType: "HEARTBEAT" | "SCHEDULE_TO_START";
|
|
77
|
+
}): void;
|
|
67
78
|
export declare class TurnLifecycleMetrics {
|
|
68
79
|
private readonly observability;
|
|
69
80
|
private readonly options;
|
|
@@ -122,6 +133,15 @@ export declare function startTurnCapacityMonitor(input: {
|
|
|
122
133
|
}): {
|
|
123
134
|
close: () => Promise<void>;
|
|
124
135
|
};
|
|
136
|
+
export declare function recordSessionRecoveryBacklogGauges(observability: Observability, counts: SessionRecoveryBacklog): void;
|
|
137
|
+
export declare function startSessionRecoveryMonitor(input: {
|
|
138
|
+
observability: Observability;
|
|
139
|
+
read: () => Promise<SessionRecoveryBacklog>;
|
|
140
|
+
intervalMs?: number;
|
|
141
|
+
now?: () => number;
|
|
142
|
+
}): {
|
|
143
|
+
close: () => Promise<void>;
|
|
144
|
+
};
|
|
125
145
|
export declare function recordSandboxLeaseGauges(observability: Observability, counts: Partial<Record<SandboxLeaseLiveness, number>>): void;
|
|
126
146
|
export declare function recordOpenSandboxKubernetesInventoryGauges(observability: Observability, inventory: OpenSandboxKubernetesInventory): void;
|
|
127
147
|
export declare const SANDBOX_INVENTORY_PROJECTION_DOMAINS: readonly ["leases", "checkpoint_artifacts", "rotation_backlog", "retained_processes", "expired_drains", "opensandbox_kubernetes"];
|
|
@@ -141,6 +161,7 @@ export declare function recordSandboxRotationBacklogGauges(observability: Observ
|
|
|
141
161
|
turnBlocked: number;
|
|
142
162
|
directBlocked: number;
|
|
143
163
|
processBlocked: number;
|
|
164
|
+
interactionBlocked: number;
|
|
144
165
|
}): void;
|
|
145
166
|
export declare function recordRetainedProcessInventoryGauges(observability: Observability, counts: Array<{
|
|
146
167
|
ownerState: string;
|
|
@@ -224,6 +245,11 @@ export declare function recordSandboxLogicalProvision(observability: Observabili
|
|
|
224
245
|
internalAttempts: number;
|
|
225
246
|
durationSeconds: number;
|
|
226
247
|
}): void;
|
|
248
|
+
export declare function recordSandboxSharedPreparation(observability: Observability, measurement: {
|
|
249
|
+
path: "owner" | "joined" | "reused";
|
|
250
|
+
outcome: "completed" | "failed";
|
|
251
|
+
durationSeconds: number;
|
|
252
|
+
}): void;
|
|
227
253
|
export declare function recordTurnWorkerPreparationTotal(observability: Observability, input: {
|
|
228
254
|
provider: string;
|
|
229
255
|
backend: string;
|
|
@@ -285,6 +311,9 @@ export declare function recordBatchFlush(observability: Observability, input: {
|
|
|
285
311
|
export declare function recordSessionEventAppendLatency(observability: Observability, input: {
|
|
286
312
|
durationSeconds: number;
|
|
287
313
|
}): void;
|
|
314
|
+
export declare function sessionEventBatchSizeClass(eventCount: number): string;
|
|
315
|
+
/** Bounded database-phase attribution for exact-attempt event appends. */
|
|
316
|
+
export declare function recordSessionEventAppendPhase(observability: Observability, observation: SessionEventAppendPhaseObservation): void;
|
|
288
317
|
/** Latency of the best-effort NATS live fan-out — the delivery path. A p99 climb
|
|
289
318
|
* here (with append healthy) is delivery, not the write path. */
|
|
290
319
|
export declare function recordSessionEventPublishLatency(observability: Observability, input: {
|
|
@@ -7,3 +7,4 @@ import { type Database } from "@opengeni/db";
|
|
|
7
7
|
* the API/database process and never crosses into a sandbox or worker result.
|
|
8
8
|
*/
|
|
9
9
|
export declare function buildPersonalGitHubGitCredentials(db: Database, settings: Settings): NonNullable<ConnectionCredentialsPort["gitCredentials"]> | null;
|
|
10
|
+
export declare function personalGitBrokerOrigin(settings: Settings): string | null;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type WorkerUnhandledRejectionProcess = {
|
|
2
|
+
on: (event: "unhandledRejection", listener: (reason: unknown) => void) => void;
|
|
3
|
+
off: (event: "unhandledRejection", listener: (reason: unknown) => void) => void;
|
|
4
|
+
};
|
|
5
|
+
export type WorkerUnhandledRejectionClassification = "detached_runtime_mcp_lifecycle" | "detached_unknown";
|
|
6
|
+
type RuntimeMcpLifecycleError = {
|
|
7
|
+
name: "McpLifecycleError";
|
|
8
|
+
code: "mcp_connect_failed" | "mcp_close_failed";
|
|
9
|
+
origin: "runtime";
|
|
10
|
+
serverId: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* The Agents SDK owns MCP connect promises and also installs a process-global
|
|
14
|
+
* unhandled-rejection listener. A best-effort lifecycle rejection can surface
|
|
15
|
+
* twice under concurrent teardown: once through the awaited MCP result and once
|
|
16
|
+
* through the SDK's detached worker promise. The first path already records and
|
|
17
|
+
* degrades the server; the second must not terminate the whole turn-worker pod.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isDetachedRuntimeMcpLifecycleRejection(reason: unknown): reason is RuntimeMcpLifecycleError;
|
|
20
|
+
/**
|
|
21
|
+
* Keep process-global promise rejection handling observational. Turn activities
|
|
22
|
+
* have their own durable failure/lease boundary; killing the shared worker here
|
|
23
|
+
* converts one detached SDK/transport promise into unrelated lease losses across
|
|
24
|
+
* every session assigned to the pod. The Agents SDK also checks for a consumer
|
|
25
|
+
* listener before applying its own process.exit(1), so this boundary must never
|
|
26
|
+
* reintroduce that fail-fast behavior for an unknown rejection shape.
|
|
27
|
+
*/
|
|
28
|
+
export declare function installWorkerUnhandledRejectionBoundary(runtimeProcess?: WorkerUnhandledRejectionProcess, report?: (classification: WorkerUnhandledRejectionClassification) => void): () => void;
|
|
29
|
+
export {};
|