@opengeni/worker-bundle 0.22.8 → 0.23.3-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/agent-build.d.ts +1 -4
- package/dist/activities/agent-turn/claim.d.ts +2 -4
- package/dist/activities/agent-turn/codex.d.ts +6 -5
- 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/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-policy.d.ts +3 -32
- package/dist/activities/agent-turn/turn-context.d.ts +1 -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/codex-rotation.d.ts +2 -0
- package/dist/activities/session-state.d.ts +2 -1
- package/dist/{activities-control-VZIIV7RX.js → activities-control-52W5IDWM.js} +125 -13
- package/dist/activities-control-52W5IDWM.js.map +1 -0
- package/dist/{activities-turn-5RGQDBFV.js → activities-turn-A2G2KLSY.js} +534 -482
- package/dist/activities-turn-A2G2KLSY.js.map +1 -0
- package/dist/{chunk-NAVSAZ56.js → chunk-GFNXVZVQ.js} +160 -1
- package/dist/chunk-GFNXVZVQ.js.map +1 -0
- package/dist/{chunk-O4HDX5SC.js → chunk-IPVMCAW5.js} +144 -15
- package/dist/chunk-IPVMCAW5.js.map +1 -0
- package/dist/index.js +42 -2
- package/dist/index.js.map +1 -1
- package/dist/observability-metrics.d.ts +28 -0
- package/dist/personal-github-git-credentials.d.ts +1 -0
- package/dist/unhandled-rejection-boundary.d.ts +29 -0
- package/package.json +18 -18
- package/src/activities/agent-turn/agent-build.ts +15 -31
- package/src/activities/agent-turn/claim.ts +29 -68
- package/src/activities/agent-turn/codex.ts +19 -10
- package/src/activities/agent-turn/compaction-prep.ts +50 -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/quiescence.ts +86 -0
- package/src/activities/agent-turn/run-credentials.ts +12 -1
- package/src/activities/agent-turn/run.ts +14 -11
- 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 +98 -14
- package/src/activities/agent-turn/tool-environment.ts +10 -13
- package/src/activities/agent-turn/tool-policy.ts +3 -55
- package/src/activities/agent-turn/turn-context.ts +8 -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/codex-capacity.ts +13 -5
- package/src/activities/codex-rotation.ts +17 -0
- package/src/activities/goals.ts +10 -4
- package/src/activities/retained-screenshots.ts +104 -21
- package/src/activities/sandbox-lease.ts +7 -4
- package/src/activities/scheduled-tasks.ts +128 -4
- package/src/activities/session-state.ts +8 -1
- package/src/github-rest-mcp.ts +6 -3
- package/src/http.ts +3 -0
- package/src/index.ts +19 -0
- package/src/observability-metrics.ts +200 -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/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
package/dist/index.js
CHANGED
|
@@ -12,10 +12,12 @@ import {
|
|
|
12
12
|
turnWorkerConcurrencyLogFields
|
|
13
13
|
} from "./chunk-GRFQTTSQ.js";
|
|
14
14
|
import {
|
|
15
|
+
initializeWorkerOutcomeMetrics,
|
|
15
16
|
normalizeTurnTaskQueueStats,
|
|
16
17
|
observabilityEventLogger,
|
|
18
|
+
startSessionRecoveryMonitor,
|
|
17
19
|
startTurnCapacityMonitor
|
|
18
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-GFNXVZVQ.js";
|
|
19
21
|
|
|
20
22
|
// src/index.ts
|
|
21
23
|
import {
|
|
@@ -28,6 +30,7 @@ import {
|
|
|
28
30
|
} from "@opengeni/config";
|
|
29
31
|
import {
|
|
30
32
|
assertRuntimeDatabasePosture as assertRuntimeDatabasePosture2,
|
|
33
|
+
countSessionRecoveryBacklog,
|
|
31
34
|
createDb,
|
|
32
35
|
markSessionWorkflowWakeDelivered
|
|
33
36
|
} from "@opengeni/db";
|
|
@@ -120,6 +123,7 @@ import {
|
|
|
120
123
|
dbSql
|
|
121
124
|
} from "@opengeni/db";
|
|
122
125
|
import { requireSessionEventDurableFanoutCapability } from "@opengeni/events";
|
|
126
|
+
import { githubAppBotIdentityWarnings } from "@opengeni/github";
|
|
123
127
|
function createWorkerHttpHandler(input) {
|
|
124
128
|
const { settings, observability, checks, lifecycle } = input;
|
|
125
129
|
const timeoutMs = input.timeoutMs ?? 2e3;
|
|
@@ -131,12 +135,14 @@ function createWorkerHttpHandler(input) {
|
|
|
131
135
|
if (url.pathname === "/healthz") {
|
|
132
136
|
const state = lifecycle?.state();
|
|
133
137
|
const ok = state !== "failed" && state !== "stopped";
|
|
138
|
+
const warnings = githubAppBotIdentityWarnings(settings);
|
|
134
139
|
return Response.json(
|
|
135
140
|
{
|
|
136
141
|
service: settings.serviceName,
|
|
137
142
|
environment: settings.environment,
|
|
138
143
|
deploymentRevision: settings.deploymentRevision,
|
|
139
144
|
...lifecycle ? { role: lifecycle.role, state } : {},
|
|
145
|
+
...warnings.length > 0 ? { warnings } : {},
|
|
140
146
|
ok
|
|
141
147
|
},
|
|
142
148
|
{ status: ok ? 200 : 503 }
|
|
@@ -720,6 +726,29 @@ function safeWarn(observability, message, attributes) {
|
|
|
720
726
|
}
|
|
721
727
|
}
|
|
722
728
|
|
|
729
|
+
// src/unhandled-rejection-boundary.ts
|
|
730
|
+
function isDetachedRuntimeMcpLifecycleRejection(reason) {
|
|
731
|
+
try {
|
|
732
|
+
if (!reason || typeof reason !== "object") return false;
|
|
733
|
+
const candidate = reason;
|
|
734
|
+
return candidate.name === "McpLifecycleError" && (candidate.code === "mcp_connect_failed" || candidate.code === "mcp_close_failed") && candidate.origin === "runtime" && typeof candidate.serverId === "string" && candidate.serverId.length > 0;
|
|
735
|
+
} catch {
|
|
736
|
+
return false;
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
function reportIsolatedUnhandledRejection(classification) {
|
|
740
|
+
console.error("[worker] isolated detached unhandled rejection", { classification });
|
|
741
|
+
}
|
|
742
|
+
function installWorkerUnhandledRejectionBoundary(runtimeProcess = process, report = reportIsolatedUnhandledRejection) {
|
|
743
|
+
const onUnhandledRejection = (reason) => {
|
|
744
|
+
report(
|
|
745
|
+
isDetachedRuntimeMcpLifecycleRejection(reason) ? "detached_runtime_mcp_lifecycle" : "detached_unknown"
|
|
746
|
+
);
|
|
747
|
+
};
|
|
748
|
+
runtimeProcess.on("unhandledRejection", onUnhandledRejection);
|
|
749
|
+
return () => runtimeProcess.off("unhandledRejection", onUnhandledRejection);
|
|
750
|
+
}
|
|
751
|
+
|
|
723
752
|
// src/index.ts
|
|
724
753
|
var SANDBOX_REAPER_SCHEDULE_ID = "opengeni-sandbox-lease-reaper";
|
|
725
754
|
var FILE_UPLOAD_REAPER_SCHEDULE_ID = "opengeni-file-upload-reaper";
|
|
@@ -740,7 +769,7 @@ function temporalWorkflowExecutionNotFound(error) {
|
|
|
740
769
|
return isGrpcServiceError(error) && error.code === 5;
|
|
741
770
|
}
|
|
742
771
|
async function createDefaultWorkerActivities(role, dependencies = {}) {
|
|
743
|
-
return role === "control" ? (await import("./activities-control-
|
|
772
|
+
return role === "control" ? (await import("./activities-control-52W5IDWM.js")).createControlActivities(dependencies) : (await import("./activities-turn-A2G2KLSY.js")).createTurnActivities(dependencies);
|
|
744
773
|
}
|
|
745
774
|
function resolveOpenGeniWorkflowDefinition(moduleUrl = import.meta.url) {
|
|
746
775
|
const modulePath = fileURLToPath(moduleUrl).replaceAll("\\", "/");
|
|
@@ -767,6 +796,7 @@ async function createOpenGeniWorker(options) {
|
|
|
767
796
|
assertSandboxReaperActivityTimeout(settings);
|
|
768
797
|
}
|
|
769
798
|
const observability = options.activityDependencies?.observability ?? createObservability(settings, { component: `worker-${options.role}` });
|
|
799
|
+
initializeWorkerOutcomeMetrics(observability);
|
|
770
800
|
if (options.role === "turn" && options.workflowBundle) {
|
|
771
801
|
throw new Error("workflowBundle is valid only for the control worker role");
|
|
772
802
|
}
|
|
@@ -1189,6 +1219,7 @@ async function createOpenGeniWorkerService(options) {
|
|
|
1189
1219
|
let signaler;
|
|
1190
1220
|
let workerBundle;
|
|
1191
1221
|
let turnCapacityMonitor;
|
|
1222
|
+
let sessionRecoveryMonitor;
|
|
1192
1223
|
const schedules = [];
|
|
1193
1224
|
let httpServer;
|
|
1194
1225
|
let memoryPressureGuard;
|
|
@@ -1235,6 +1266,11 @@ async function createOpenGeniWorkerService(options) {
|
|
|
1235
1266
|
observability,
|
|
1236
1267
|
read: signaler.getTurnTaskQueueStats
|
|
1237
1268
|
});
|
|
1269
|
+
} else {
|
|
1270
|
+
sessionRecoveryMonitor = startSessionRecoveryMonitor({
|
|
1271
|
+
observability,
|
|
1272
|
+
read: async () => await countSessionRecoveryBacklog(options.activityDependencies.db)
|
|
1273
|
+
});
|
|
1238
1274
|
}
|
|
1239
1275
|
if (workerOwnsInternalSchedules(options.role, options.internalSchedules)) {
|
|
1240
1276
|
schedules.push(
|
|
@@ -1286,6 +1322,7 @@ async function createOpenGeniWorkerService(options) {
|
|
|
1286
1322
|
httpServer?.stop(true);
|
|
1287
1323
|
await Promise.allSettled([
|
|
1288
1324
|
turnCapacityMonitor?.close(),
|
|
1325
|
+
sessionRecoveryMonitor?.close(),
|
|
1289
1326
|
workerBundle?.connection.close(),
|
|
1290
1327
|
signaler?.close(),
|
|
1291
1328
|
...schedules.map((schedule) => schedule.close())
|
|
@@ -1306,6 +1343,7 @@ async function createOpenGeniWorkerService(options) {
|
|
|
1306
1343
|
httpServer?.stop(true);
|
|
1307
1344
|
await Promise.allSettled([
|
|
1308
1345
|
turnCapacityMonitor?.close(),
|
|
1346
|
+
sessionRecoveryMonitor?.close(),
|
|
1309
1347
|
activeWorkerBundle.connection.close(),
|
|
1310
1348
|
activeSignaler?.close(),
|
|
1311
1349
|
...schedules.map((schedule) => schedule.close())
|
|
@@ -1380,6 +1418,7 @@ async function startWorker() {
|
|
|
1380
1418
|
}
|
|
1381
1419
|
const settings = getSettings();
|
|
1382
1420
|
const observability = createObservability(settings, { component: `worker-${role}` });
|
|
1421
|
+
const disposeUnhandledRejectionBoundary = installWorkerUnhandledRejectionBoundary();
|
|
1383
1422
|
const retryOptions = startupRetryOptions(settings);
|
|
1384
1423
|
const onRetry = (event) => logStartupDependencyRetry(observability, event);
|
|
1385
1424
|
const searchPath = dbSearchPath(settings);
|
|
@@ -1428,6 +1467,7 @@ async function startWorker() {
|
|
|
1428
1467
|
});
|
|
1429
1468
|
} finally {
|
|
1430
1469
|
await Promise.allSettled([bus?.close(), readinessDbClient.close(), dbClient.close()]);
|
|
1470
|
+
disposeUnhandledRejectionBoundary();
|
|
1431
1471
|
}
|
|
1432
1472
|
}
|
|
1433
1473
|
if (import.meta.main) {
|