@opengeni/worker-bundle 0.14.1 → 0.15.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeni/worker-bundle",
3
- "version": "0.14.1",
3
+ "version": "0.15.0",
4
4
  "description": "OpenGeni worker entry and reusable embedded lifecycle, shipped with a release-coherent pre-bundled Temporal workflow artifact.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -41,16 +41,16 @@
41
41
  "dependencies": {
42
42
  "@opengeni/agent-proto": "^0.3.0",
43
43
  "@opengeni/codex": "^0.2.9",
44
- "@opengeni/config": "^0.9.3",
45
- "@opengeni/contracts": "^0.30.0",
46
- "@opengeni/core": "^0.17.1",
47
- "@opengeni/db": "^0.21.0",
48
- "@opengeni/documents": "^0.2.66",
49
- "@opengeni/events": "^0.3.57",
50
- "@opengeni/github": "^0.4.15",
51
- "@opengeni/observability": "^0.4.2",
52
- "@opengeni/runtime": "^0.16.2",
53
- "@opengeni/storage": "^0.2.52",
44
+ "@opengeni/config": "^0.10.0",
45
+ "@opengeni/contracts": "^0.31.0",
46
+ "@opengeni/core": "^0.18.0",
47
+ "@opengeni/db": "^0.22.1",
48
+ "@opengeni/documents": "^0.2.69",
49
+ "@opengeni/events": "^0.3.59",
50
+ "@opengeni/github": "^0.4.16",
51
+ "@opengeni/observability": "^0.4.3",
52
+ "@opengeni/runtime": "^0.17.0",
53
+ "@opengeni/storage": "^0.2.53",
54
54
  "@temporalio/activity": "^1.17.0",
55
55
  "@temporalio/client": "^1.17.0",
56
56
  "@temporalio/worker": "^1.17.0",
@@ -70,6 +70,9 @@ import {
70
70
  getEnrollment,
71
71
  abandonRecordingForTurnAttempt,
72
72
  markSessionAttemptQuiesced,
73
+ beginConnectorActionExecution,
74
+ completeConnectorActionExecution,
75
+ prepareConnectorActionApproval,
73
76
  type AppendEventInput,
74
77
  type ActiveSandboxPointer,
75
78
  type SandboxRecord,
@@ -123,6 +126,7 @@ import {
123
126
  type ModelCallUsageInput,
124
127
  type ModelCallUsageNormalization,
125
128
  type BuildAgentOptions,
129
+ type ConnectorActionPolicyHooks,
126
130
  type RunAgentStreamOptions,
127
131
  type TurnToolCancellationFence,
128
132
  type BackendUnresolvableCode,
@@ -1769,9 +1773,11 @@ export async function reconcileActiveSandboxPointer(
1769
1773
  /**
1770
1774
  * Warm the Modal private-registry image for the image ref this turn actually
1771
1775
  * resolved, not only the deployment-global OPENGENI_MODAL_IMAGE_REF warmed at
1772
- * worker boot. Packs can override `modalImageRef` per workspace/turn, so a
1773
- * private pack image must be resolved before sandbox creation or Modal falls
1774
- * back to the unauthenticated `fromTag` path.
1776
+ * worker boot. A provider-native modalImageId bypasses registry import and is
1777
+ * resolved by ModalImageSelector.fromId during create. Otherwise packs can
1778
+ * override `modalImageRef` per workspace/turn, so a private pack image must be
1779
+ * resolved before sandbox creation or Modal falls back to the unauthenticated
1780
+ * `fromTag` path.
1775
1781
  */
1776
1782
  export async function ensureTurnModalRegistryImage(
1777
1783
  runSettings: Settings,
@@ -1781,6 +1787,9 @@ export async function ensureTurnModalRegistryImage(
1781
1787
  if (sandboxCreationBackend !== "modal") {
1782
1788
  return;
1783
1789
  }
1790
+ if (runSettings.modalImageId) {
1791
+ return;
1792
+ }
1784
1793
  if (!runSettings.modalImageRegistrySecret || !runSettings.modalImageRef) {
1785
1794
  return;
1786
1795
  }
@@ -4030,7 +4039,11 @@ export function createRunAgentTurnActivity(services: () => Promise<ActivityServi
4030
4039
  // deployment default; a rig with no image (or a rig-less turn) is a
4031
4040
  // pass-through, leaving the pack/deployment chain exactly as today.
4032
4041
  ...settingsWithRigImage(
4033
- settingsWithPackSandboxImage(capabilitySettings, packRuntime.sandboxImage),
4042
+ settingsWithPackSandboxImage(
4043
+ capabilitySettings,
4044
+ packRuntime.sandboxImage,
4045
+ packRuntime.sandboxProviderImages,
4046
+ ),
4034
4047
  rigVersion?.image ?? null,
4035
4048
  ),
4036
4049
  openaiModel: turn.model,
@@ -5470,6 +5483,32 @@ export function createRunAgentTurnActivity(services: () => Promise<ActivityServi
5470
5483
  turnExecutionPolicy.providerId,
5471
5484
  turnExecutionPolicy.latencyMode,
5472
5485
  );
5486
+ const connectorActionIdentity = {
5487
+ accountId: input.accountId,
5488
+ workspaceId: input.workspaceId,
5489
+ sessionId: input.sessionId,
5490
+ turnId,
5491
+ attemptId: input.attemptId,
5492
+ executionGeneration,
5493
+ initiator: {
5494
+ kind: turn.initiator.kind,
5495
+ subjectId: turn.initiator.subjectId,
5496
+ },
5497
+ } as const;
5498
+ const connectorActionPolicy: ConnectorActionPolicyHooks = {
5499
+ prepare: async (call) =>
5500
+ await prepareConnectorActionApproval(db, connectorActionIdentity, call),
5501
+ begin: async (call) =>
5502
+ await beginConnectorActionExecution(db, connectorActionIdentity, call),
5503
+ complete: async ({ requestId, outcome }) =>
5504
+ await completeConnectorActionExecution(db, {
5505
+ accountId: input.accountId,
5506
+ workspaceId: input.workspaceId,
5507
+ requestId,
5508
+ attemptId: input.attemptId,
5509
+ outcome,
5510
+ }),
5511
+ };
5473
5512
  const agent = runtime.buildAgent(modelRunSettings, turnResources, {
5474
5513
  reasoningEffort: turn.reasoningEffort,
5475
5514
  latencyMode: turnExecutionPolicy.latencyMode,
@@ -5516,6 +5555,8 @@ export function createRunAgentTurnActivity(services: () => Promise<ActivityServi
5516
5555
  ...(activeSandboxBackend ? { activeSandboxBackend } : {}),
5517
5556
  fileResourceDownloads,
5518
5557
  mcpServers: preparedTools.mcpServers,
5558
+ resolvedMcpConnectionIds: preparedTools.resolvedMcpConnectionIds,
5559
+ connectorActionPolicy,
5519
5560
  // LIVE by-reference connector namespaces (fills during this turn's
5520
5561
  // codex_apps tools/list): the codex tool_search description reads it per
5521
5562
  // model call so the model sees the account's real connected sources.
@@ -21,10 +21,15 @@ import {
21
21
  */
22
22
  export type WorkspacePackRuntime = {
23
23
  sandboxImage: string | null;
24
+ sandboxProviderImages: CapabilityPack["sandboxProviderImages"] | null;
24
25
  skills: PackSkill[];
25
26
  };
26
27
 
27
- const emptyPackRuntime: WorkspacePackRuntime = { sandboxImage: null, skills: [] };
28
+ const emptyPackRuntime: WorkspacePackRuntime = {
29
+ sandboxImage: null,
30
+ sandboxProviderImages: null,
31
+ skills: [],
32
+ };
28
33
 
29
34
  export type WorkspaceSkillLibraryRuntime = {
30
35
  skillLibrarySkills: PackSkill[];
@@ -200,6 +205,7 @@ export function workspacePackRuntimeFromPacks(packs: CapabilityPack[]): Workspac
200
205
  }
201
206
  return {
202
207
  sandboxImage: imagePacks[0]?.sandboxImage?.trim() ?? null,
208
+ sandboxProviderImages: imagePacks[0]?.sandboxProviderImages ?? null,
203
209
  skills,
204
210
  };
205
211
  }
@@ -231,6 +237,7 @@ export async function resolveWorkspaceAgentInstructions(
231
237
  export function settingsWithPackSandboxImage(
232
238
  settings: Settings,
233
239
  sandboxImage: string | null,
240
+ sandboxProviderImages: CapabilityPack["sandboxProviderImages"] | null = null,
234
241
  ): Settings {
235
242
  if (!sandboxImage) {
236
243
  return settings;
@@ -239,6 +246,7 @@ export function settingsWithPackSandboxImage(
239
246
  ...settings,
240
247
  dockerImage: sandboxImage,
241
248
  modalImageRef: sandboxImage,
249
+ modalImageId: sandboxProviderImages?.modal?.imageId,
242
250
  };
243
251
  }
244
252
 
@@ -260,6 +268,10 @@ export function settingsWithRigImage(settings: Settings, rigImage: string | null
260
268
  ...settings,
261
269
  dockerImage: rigImage,
262
270
  modalImageRef: rigImage,
271
+ // A rig image has no provider-native identity in the current rig contract.
272
+ // Clear a lower-precedence pack/deployment ID so the rig cannot silently
273
+ // run the wrong Modal image.
274
+ modalImageId: undefined,
263
275
  };
264
276
  }
265
277
 
package/src/index.ts CHANGED
@@ -165,9 +165,10 @@ export async function createOpenGeniWorker(options: WorkerOptions): Promise<{
165
165
  throw new Error("workflowBundle is valid only for the control worker role");
166
166
  }
167
167
  // Pre-resolve a PRIVATE-registry sandbox image before any turn creates a box.
168
- // No-op unless OPENGENI_MODAL_IMAGE_REGISTRY_SECRET + OPENGENI_MODAL_IMAGE_REF are
169
- // both set (so non-modal / public-image deployments are byte-unchanged and never
170
- // load the modal SDK here). Memoized in the provider, so this runs once per process.
168
+ // A provider-native OPENGENI_MODAL_IMAGE_ID intentionally bypasses this
169
+ // registry path and is resolved by ModalImageSelector.fromId at create time.
170
+ // Otherwise this is a no-op unless the registry secret + logical ref are both
171
+ // set. Memoized in the provider, so it runs once per process.
171
172
  if (options.role === "turn") {
172
173
  await retryStartupDependency(
173
174
  "Modal private-registry image",