@opengeni/worker-bundle 0.6.0 → 0.7.1
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/index.js +22 -1
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
- package/src/activities/agent-turn.ts +35 -4
- package/src/index.ts +13 -0
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import { createNatsEventBus as createNatsEventBus2 } from "@opengeni/events";
|
|
|
5
5
|
import { createObservability as createObservability2, logStartupDependencyRetry } from "@opengeni/observability";
|
|
6
6
|
import { Connection, ScheduleAlreadyRunning, ScheduleOverlapPolicy, Client as TemporalClient } from "@temporalio/client";
|
|
7
7
|
import { NativeConnection, Worker } from "@temporalio/worker";
|
|
8
|
+
import { ensureModalRegistryImage as ensureModalRegistryImage2 } from "@opengeni/runtime";
|
|
8
9
|
|
|
9
10
|
// src/activities.ts
|
|
10
11
|
import { dbSearchPath, getSettings, resolveNatsControlPlaneAuth } from "@opengeni/config";
|
|
@@ -67,6 +68,7 @@ import {
|
|
|
67
68
|
normalizeSdkEvent,
|
|
68
69
|
sanitizeHistoryItemsForModel as sanitizeHistoryItemsForModel2,
|
|
69
70
|
summarizeForCompaction as summarizeForCompaction2,
|
|
71
|
+
ensureModalRegistryImage,
|
|
70
72
|
findCompactionNeededError,
|
|
71
73
|
SUMMARY_BUFFER_TOKENS as SUMMARY_BUFFER_TOKENS2
|
|
72
74
|
} from "@opengeni/runtime";
|
|
@@ -2189,6 +2191,15 @@ async function resolveActiveSandboxBackend(routingOn, loadPointer, loadSandboxKi
|
|
|
2189
2191
|
return void 0;
|
|
2190
2192
|
}
|
|
2191
2193
|
}
|
|
2194
|
+
async function ensureTurnModalRegistryImage(runSettings, sandboxCreationBackend, ensureRegistryImage = ensureModalRegistryImage) {
|
|
2195
|
+
if (sandboxCreationBackend !== "modal") {
|
|
2196
|
+
return;
|
|
2197
|
+
}
|
|
2198
|
+
if (!runSettings.modalImageRegistrySecret || !runSettings.modalImageRef) {
|
|
2199
|
+
return;
|
|
2200
|
+
}
|
|
2201
|
+
await ensureRegistryImage(runSettings);
|
|
2202
|
+
}
|
|
2192
2203
|
function shouldStartOnTurnRecording(params) {
|
|
2193
2204
|
return params.recordingEnabled && params.desktopEnabled && desktopCapableBackend2(params.establishedBackendId) && params.effectiveBackend !== "selfhosted";
|
|
2194
2205
|
}
|
|
@@ -2507,6 +2518,9 @@ function createRunAgentTurnActivity(services) {
|
|
|
2507
2518
|
async () => activeSandboxRecord?.kind ?? null
|
|
2508
2519
|
);
|
|
2509
2520
|
const machinePrimary = activeSandboxBackend === "selfhosted" && Boolean(activeSandboxPointer?.activeSandboxId) && Boolean(activeSandboxRecord?.enrollmentId);
|
|
2521
|
+
const groupBoxBackend = runSettings.sandboxBackend === "selfhosted" && !machinePrimary ? settings.sandboxBackend : runSettings.sandboxBackend;
|
|
2522
|
+
const sandboxCreationBackend = settings.sandboxOwnershipEnabled && runSettings.sandboxBackend !== "none" ? groupBoxBackend : runSettings.sandboxBackend;
|
|
2523
|
+
await ensureTurnModalRegistryImage(runSettings, sandboxCreationBackend);
|
|
2510
2524
|
const {
|
|
2511
2525
|
environment: sandboxEnvironment,
|
|
2512
2526
|
gitToken: sandboxGitToken,
|
|
@@ -2526,7 +2540,6 @@ function createRunAgentTurnActivity(services) {
|
|
|
2526
2540
|
if (settings.sandboxOwnershipEnabled && turn.sandboxBackend !== "none") {
|
|
2527
2541
|
sandboxHolderId = dispatchId ?? `turn:${turnId}`;
|
|
2528
2542
|
sandboxGroupId = session.sandboxGroupId;
|
|
2529
|
-
const groupBoxBackend = turn.sandboxBackend === "selfhosted" && !machinePrimary ? settings.sandboxBackend : turn.sandboxBackend;
|
|
2530
2543
|
if (machinePrimary) {
|
|
2531
2544
|
const established = await establishSelfhostedTurnSession(
|
|
2532
2545
|
{ db, settings, bus },
|
|
@@ -4785,6 +4798,14 @@ var SANDBOX_REAPER_SCHEDULE_ID = "opengeni-sandbox-lease-reaper";
|
|
|
4785
4798
|
async function createOpenGeniWorker(options = {}) {
|
|
4786
4799
|
const settings = options.settings ?? getSettings2();
|
|
4787
4800
|
const observability = options.activityDependencies?.observability ?? createObservability2(settings, { component: "worker" });
|
|
4801
|
+
await retryStartupDependency(
|
|
4802
|
+
"Modal private-registry image",
|
|
4803
|
+
() => ensureModalRegistryImage2(settings),
|
|
4804
|
+
{
|
|
4805
|
+
...startupRetryOptions(settings),
|
|
4806
|
+
onRetry: (event) => logStartupDependencyRetry(observability, event)
|
|
4807
|
+
}
|
|
4808
|
+
);
|
|
4788
4809
|
const connection = await retryStartupDependency(
|
|
4789
4810
|
"Temporal",
|
|
4790
4811
|
() => NativeConnection.connect({ address: settings.temporalHost }),
|