@opengeni/runtime 0.6.0 → 0.6.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.
@@ -1,6 +1,6 @@
1
1
  export { collectSandboxEnvironment, parseExposedPorts } from '@opengeni/config';
2
2
  export { CAPABILITY_DESCRIPTORS, CapabilityDescriptor, DESKTOP_STREAM_PORT, StreamTokenPayload, StreamTokenPayload as StreamTokenPayloadType, TERMINAL_STREAM_PORT } from '@opengeni/contracts';
3
3
  import '@openai/agents/sandbox';
4
- export { A as ActiveBackendResolverDeps, a as ActiveBackendUnresolvableError, b as ActivePointer, C as ChannelAConflictError, c as ChannelAEmitter, d as ChannelAExecArgs, e as ChannelAExecResult, f as ChannelANotFoundError, g as ChannelASession, h as ChannelAUnsupportedError, i as ChannelAValidationError, j as ControlRpc, D as DEFAULT_DESKTOP_GEOMETRY, k as DISPLAY_STACK_TIMEOUT_MS, l as DesktopGeometry, m as DisplayStackError, n as DisplayStackUnsupportedError, E as EnsureDisplayStackOptions, o as EnsureDisplayStackResult, p as EnsureTerminalServerOptions, q as EnsureTerminalServerResult, r as EstablishedSandboxSession, s as ExposeStreamPortInput, t as ExposeStreamPortResult, u as ExposedPortEndpoint, F as FinalizeRecordingResult, L as LiveModalSandboxLeaseAttribution, M as MintStreamTokenInput, v as MockAgentResponder, w as MockAgentResponderOptions, x as MockExecHandler, y as ModalModuleLoader, z as ModalOrphanSweepResult, B as ModalSandboxAttribution, N as NatsControlRpc, G as NatsRequestConnection, H as NegotiationContext, I as NumstatEntry, P as PROVIDER_REGISTRY, J as ProviderConstructionContext, K as ProviderRegistration, O as RecordingCodec, Q as RecordingContentType, S as RecordingError, T as RecordingProcess, U as RecordingUnavailableError, V as ResolvedActiveBackend, W as RoutableBackendSession, X as RoutableSandbox, Y as RoutingSandboxSession, Z as RoutingSandboxSessionDeps, _ as RoutingTransitionEvent, $ as RoutingUnsupportedError, a0 as SELFHOSTED_DEFAULT_TIMEOUT_MS, a1 as SELFHOSTED_RECONNECT_WINDOW_MS, a2 as SELFHOSTED_RELAY_STREAM_PATH, a3 as STREAM_PORT, a4 as STREAM_TOKEN_DEFAULT_TTL_SECONDS, a5 as SandboxChannelAService, a6 as SandboxChannelAServiceOptions, a7 as SandboxConfigError, a8 as SandboxCreatedCallback, a9 as SandboxProviderUnavailableError, aa as SelfhostedApplyDiff, ab as SelfhostedControlError, ac as SelfhostedEditor, ad as SelfhostedEnrollment, ae as SelfhostedExecArgs, af as SelfhostedExecResult, ag as SelfhostedImageOutput, ah as SelfhostedLivenessState, ai as SelfhostedNegotiationInput, aj as SelfhostedRelayConfig, ak as SelfhostedSandboxClient, al as SelfhostedSession, am as SelfhostedSessionBuild, an as SelfhostedSessionDeps, ao as SelfhostedSessionState, ap as SelfhostedUnavailableReason, aq as StartRecordingInput, ar as StreamPortUnavailableError, as as TERMINAL_SERVER_TIMEOUT_MS, at as TerminalServerError, au as TerminalServerUnsupportedError, av as agentErrorToControlError, aw as assertDescriptorRegistryInvariants, ax as assertProviderRegistryInvariants, ay as assertSafeRelPath, az as backendSupportsOs, aA as buildDisplayStackScript, aB as buildSelfhostedBackendSession, aC as buildStreamUrl, aD as buildTerminalServerScript, aE as contentTypeForCodec, aF as createSandboxClient, aG as createSandboxClientForBackend, aH as decodeModalSnapshotId, aI as deletePriorPersistedSnapshot, aJ as deleteRecordingArtifacts, aK as deserializeSandboxSessionStateEnvelope, aL as desktopCapableBackend, aM as ensureDisplayStack, aN as ensureModalRegistryImage, aO as ensureTerminalServer, aP as establishSandboxSessionFromEnvelope, aQ as exposeStreamPort, aR as extForCodec, aS as isExecSessionLostBanner, aT as isProviderSandboxNotFoundError, aU as isSelfhostedProviderNotFoundError, aV as isWorkspaceEscapeError, aW as makeActiveBackendResolver, aX as mintStreamToken, aY as modalSandboxAttributionEnvironment, aZ as modalSandboxAttributionTags, a_ as negotiateCapabilities, a$ as negotiateSelfhostedCapabilities, b0 as offlineAgentError, b1 as offlineControlResponse, b2 as parseExecBannerSessionId, b3 as parseNumstatZ, b4 as parsePorcelainV2, b5 as parseUnifiedPatch, b6 as readRecordingBytes, b7 as readWorkspaceArchiveFromEnvelopeSessionState, b8 as recordingStorageKey, b9 as restoredSandboxSessionStateFromEntry, ba as sandboxStateEntryFromRunState, bb as selectBackend, bc as selfhostedLiveness, bd as serializeEstablishedSandboxEnvelope, be as setSelfhostedApplyDiff, bf as startRecording, bg as stopRecording, bh as stripExecBanner, bi as subjectFor, bj as sweepModalOrphanSandboxes, bk as tagModalSandbox, bl as tearDownDisplayStack, bm as tearDownTerminalServer, bn as terminateModalSandboxById, bo as timeoutAgentError, bp as timeoutControlResponse, bq as verifyStreamToken } from '../index-otZkoLYq.js';
4
+ export { A as ActiveBackendResolverDeps, a as ActiveBackendUnresolvableError, b as ActivePointer, C as ChannelAConflictError, c as ChannelAEmitter, d as ChannelAExecArgs, e as ChannelAExecResult, f as ChannelANotFoundError, g as ChannelASession, h as ChannelAUnsupportedError, i as ChannelAValidationError, j as ControlRpc, D as DEFAULT_DESKTOP_GEOMETRY, k as DISPLAY_STACK_TIMEOUT_MS, l as DesktopGeometry, m as DisplayStackError, n as DisplayStackUnsupportedError, E as EnsureDisplayStackOptions, o as EnsureDisplayStackResult, p as EnsureTerminalServerOptions, q as EnsureTerminalServerResult, r as EstablishedSandboxSession, s as ExposeStreamPortInput, t as ExposeStreamPortResult, u as ExposedPortEndpoint, F as FinalizeRecordingResult, L as LiveModalSandboxLeaseAttribution, M as MintStreamTokenInput, v as MockAgentResponder, w as MockAgentResponderOptions, x as MockExecHandler, y as ModalModuleLoader, z as ModalOrphanSweepResult, B as ModalSandboxAttribution, N as NatsControlRpc, G as NatsRequestConnection, H as NegotiationContext, I as NumstatEntry, P as PROVIDER_REGISTRY, J as ProviderConstructionContext, K as ProviderRegistration, O as RecordingCodec, Q as RecordingContentType, S as RecordingError, T as RecordingProcess, U as RecordingUnavailableError, V as ResolvedActiveBackend, W as RoutableBackendSession, X as RoutableSandbox, Y as RoutingSandboxSession, Z as RoutingSandboxSessionDeps, _ as RoutingTransitionEvent, $ as RoutingUnsupportedError, a0 as SELFHOSTED_DEFAULT_TIMEOUT_MS, a1 as SELFHOSTED_RECONNECT_WINDOW_MS, a2 as SELFHOSTED_RELAY_STREAM_PATH, a3 as STREAM_PORT, a4 as STREAM_TOKEN_DEFAULT_TTL_SECONDS, a5 as SandboxChannelAService, a6 as SandboxChannelAServiceOptions, a7 as SandboxConfigError, a8 as SandboxCreatedCallback, a9 as SandboxProviderUnavailableError, aa as SelfhostedApplyDiff, ab as SelfhostedControlError, ac as SelfhostedEditor, ad as SelfhostedEnrollment, ae as SelfhostedExecArgs, af as SelfhostedExecResult, ag as SelfhostedImageOutput, ah as SelfhostedLivenessState, ai as SelfhostedNegotiationInput, aj as SelfhostedRelayConfig, ak as SelfhostedSandboxClient, al as SelfhostedSession, am as SelfhostedSessionBuild, an as SelfhostedSessionDeps, ao as SelfhostedSessionState, ap as SelfhostedUnavailableReason, aq as StartRecordingInput, ar as StreamPortUnavailableError, as as TERMINAL_SERVER_TIMEOUT_MS, at as TerminalServerError, au as TerminalServerUnsupportedError, av as agentErrorToControlError, aw as assertDescriptorRegistryInvariants, ax as assertProviderRegistryInvariants, ay as assertSafeRelPath, az as backendSupportsOs, aA as buildDisplayStackScript, aB as buildSelfhostedBackendSession, aC as buildStreamUrl, aD as buildTerminalServerScript, aE as contentTypeForCodec, aF as createSandboxClient, aG as createSandboxClientForBackend, aH as decodeModalSnapshotId, aI as deletePriorPersistedSnapshot, aJ as deleteRecordingArtifacts, aK as deserializeSandboxSessionStateEnvelope, aL as desktopCapableBackend, aM as ensureDisplayStack, aN as ensureModalRegistryImage, aO as ensureTerminalServer, aP as establishSandboxSessionFromEnvelope, aQ as exposeStreamPort, aR as extForCodec, aS as isExecSessionLostBanner, aT as isProviderSandboxNotFoundError, aU as isSelfhostedProviderNotFoundError, aV as isWorkspaceEscapeError, aW as makeActiveBackendResolver, aX as mintStreamToken, aY as modalSandboxAttributionEnvironment, aZ as modalSandboxAttributionTags, a_ as negotiateCapabilities, a$ as negotiateSelfhostedCapabilities, b0 as offlineAgentError, b1 as offlineControlResponse, b2 as parseExecBannerSessionId, b3 as parseNumstatZ, b4 as parsePorcelainV2, b5 as parseUnifiedPatch, b6 as readRecordingBytes, b7 as readWorkspaceArchiveFromEnvelopeSessionState, b8 as recordingStorageKey, b9 as restoredSandboxSessionStateFromEntry, ba as sandboxStateEntryFromRunState, bb as selectBackend, bc as selfhostedLiveness, bd as serializeEstablishedSandboxEnvelope, be as setSelfhostedApplyDiff, bf as startRecording, bg as stopRecording, bh as stripExecBanner, bi as subjectFor, bj as sweepModalOrphanSandboxes, bk as tagModalSandbox, bl as tearDownDisplayStack, bm as tearDownTerminalServer, bn as terminateModalSandboxById, bo as timeoutAgentError, bp as timeoutControlResponse, bq as verifyStreamToken } from '../index-BTo_bZvN.js';
5
5
  import 'modal';
6
6
  import '@opengeni/agent-proto';
@@ -96,7 +96,7 @@ import {
96
96
  timeoutAgentError,
97
97
  timeoutControlResponse,
98
98
  verifyStreamToken
99
- } from "../chunk-BHA2SU3H.js";
99
+ } from "../chunk-DYBF7ZEB.js";
100
100
  export {
101
101
  ActiveBackendUnresolvableError,
102
102
  CAPABILITY_DESCRIPTORS,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeni/runtime",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./dist/index.js",
@@ -1,4 +1,5 @@
1
1
  import type { AgentInputItem } from "@openai/agents";
2
+ import { SCREENSHOT_OMITTED_IMAGE_DATA_URL } from "./screenshot-omitted-card";
2
3
 
3
4
  export const SCREENSHOT_OMITTED_PLACEHOLDER =
4
5
  "[screenshot omitted: an older desktop frame — the full image remains in the session event log]";
@@ -59,7 +60,7 @@ function collectItemImageOccurrences(
59
60
  return;
60
61
  }
61
62
  if (item.type === "computer_call_result" || item.type === "computer_call_output") {
62
- collectComputerOutputImages(item, path, placeholder, out);
63
+ collectComputerOutputImages(item, path, out);
63
64
  return;
64
65
  }
65
66
  if (item.type === "function_call_result" || item.type === "function_call_output") {
@@ -70,7 +71,6 @@ function collectItemImageOccurrences(
70
71
  function collectComputerOutputImages(
71
72
  item: Record<string, unknown>,
72
73
  path: PathSegment[],
73
- placeholder: string,
74
74
  out: ImageOccurrence[],
75
75
  ): void {
76
76
  const output = item.output;
@@ -79,7 +79,7 @@ function collectComputerOutputImages(
79
79
  }
80
80
  for (const key of ["data", "image_url", "imageUrl"]) {
81
81
  if (isImageDataUrl(output[key])) {
82
- out.push({ path: [...path, "output", key], replacement: placeholder });
82
+ out.push({ path: [...path, "output", key], replacement: SCREENSHOT_OMITTED_IMAGE_DATA_URL });
83
83
  return;
84
84
  }
85
85
  }
package/src/index.ts CHANGED
@@ -180,6 +180,7 @@ export {
180
180
  elideStaleScreenshotImages,
181
181
  SCREENSHOT_OMITTED_PLACEHOLDER,
182
182
  } from "./image-history";
183
+ export { SCREENSHOT_OMITTED_IMAGE_DATA_URL } from "./screenshot-omitted-card";
183
184
  export type { ElideStaleScreenshotsOptions, ElideStaleScreenshotsResult } from "./image-history";
184
185
 
185
186
  ensureReadableStreamFrom();
@@ -115,14 +115,13 @@ type ModalClientLike = InstanceType<ModalModule["ModalClient"]>;
115
115
  // `fromRegistry(tag, secret)` image ONCE per process, then hand the provider `build`
116
116
  // a `ModalImageSelector.fromImage(...)`. `build` is synchronous and modal is imported
117
117
  // lazily (never loaded for non-modal backends), so resolution can't happen inside
118
- // `build`; the worker boot awaits `ensureModalRegistryImage` first and `build` reads
119
- // the settled result. Modal images are lazy, workspace-scoped definitions, so an image
120
- // built by this module's client is usable by the ModalSandboxClient's own client.
118
+ // `build`; the worker awaits `ensureModalRegistryImage` at boot for global refs and
119
+ // at turn time for pack-scoped refs, then `build` reads the settled result. Modal
120
+ // images are lazy, workspace-scoped definitions, so an image built by this module's
121
+ // client is usable by the ModalSandboxClient's own client.
121
122
 
122
123
  /** Loader seam so unit tests can inject a fake modal module. */
123
- export type ModalModuleLoader = () => Promise<
124
- Pick<ModalModule, "ModalClient" | "Secret">
125
- >;
124
+ export type ModalModuleLoader = () => Promise<Pick<ModalModule, "ModalClient">>;
126
125
 
127
126
  const defaultModalLoader: ModalModuleLoader = () => import("modal");
128
127
 
@@ -143,8 +142,9 @@ function registryImageCacheKey(settings: Settings): string {
143
142
  * Resolve + cache the private-registry Modal image. No-op unless BOTH
144
143
  * `modalImageRef` and `modalImageRegistrySecret` are set. Memoized per
145
144
  * (imageRef, secret, environment) so it runs once per worker process. Awaited at
146
- * worker boot BEFORE the first sandbox is created; `build` then reads the resolved
147
- * image and otherwise falls back to the public `fromTag` path.
145
+ * worker boot for the deployment-global image and at turn time for pack-scoped
146
+ * images BEFORE the first sandbox using that ref is created; `build` then reads the
147
+ * resolved image and otherwise falls back to the public `fromTag` path.
148
148
  */
149
149
  export async function ensureModalRegistryImage(
150
150
  settings: Settings,
@@ -162,7 +162,12 @@ export async function ensureModalRegistryImage(
162
162
  pending = (async () => {
163
163
  const modal = await loadModal();
164
164
  const client = new modal.ModalClient(modalClientOptions(settings));
165
- const secret = await modal.Secret.fromName(
165
+ // Resolve the Secret via the AUTHENTICATED client (client.secrets.fromName),
166
+ // NOT the static `modal.Secret.fromName`, which resolves against
167
+ // `getDefaultClient()` — i.e. the standard MODAL_TOKEN_ID/MODAL_TOKEN_SECRET env
168
+ // or ~/.modal.toml — and so would throw "Profile is missing token_id" in any host
169
+ // that supplies the token only through OpenGeni settings (OPENGENI_MODAL_TOKEN_ID).
170
+ const secret = await client.secrets.fromName(
166
171
  settings.modalImageRegistrySecret!,
167
172
  settings.modalEnvironment ? { environment: settings.modalEnvironment } : undefined,
168
173
  );
@@ -189,7 +194,7 @@ function cachedModalRegistryImage(settings: Settings): unknown | undefined {
189
194
  /**
190
195
  * Choose the image selector for a Modal sandbox client from settings. Returns:
191
196
  * - `fromImage(resolved)` when a private-registry secret is configured AND the
192
- * image has been resolved (ensureModalRegistryImage ran at worker boot);
197
+ * image has been resolved (ensureModalRegistryImage ran before create);
193
198
  * - `fromTag(modalImageRef)` for the public path (no secret, or cold cache — the
194
199
  * resume/attach paths never pull an image so the tag branch is harmless there);
195
200
  * - `undefined` when no image ref is set (Modal uses its default image).
@@ -0,0 +1,15 @@
1
+ // The legible "screenshot omitted" card that image-history substitutes for an
2
+ // ELIDED `computer_call_output` screenshot. The hosted computer tool requires
3
+ // `computer_call_output.output.image_url` to remain a syntactically valid URL;
4
+ // the text placeholder is valid for tool-result text paths but 400s this image
5
+ // channel once older screenshots are elided.
6
+ //
7
+ // This is a valid 8-bit RGBA PNG (signature + chunk CRCs emitted by the
8
+ // dependency-free generator) rendered from a fixed message:
9
+ // SCREENSHOT OMITTED
10
+ // EARLIER FRAME ELIDED
11
+ // TO SAVE CONTEXT.
12
+ //
13
+ // Regenerate with: `bun run scripts/gen-screenshot-omitted-card.mjs`
14
+ export const SCREENSHOT_OMITTED_IMAGE_DATA_URL =
15
+ "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgwAAAC0CAYAAAD4gHQ+AAAG2klEQVR42u3dMXLbMBCGUR/ChQuPT5KD+c5q1Ki2b+CMRlji38UrXpWYoUkA/AoM8vb17/sHAOAvbx4CACAYAADBAAAIBgBAMAAAggEAEAwAgGAAABAMAIBgAAAEAwAgGAAAwQAACAYAQDAAAIIBAEAwAACCAQAQDACAYAAABAMAIBgAAMEAAAiGco/77SVXXz/9fqvv/9nrvzoedr/ftPvfPX7S14fV7+fZn582f0+7vggQDIJBMAgGwSAYXF8wCAbBIBgEg2AQDK4vGASDYBAMgkEwCAbXFwznBUP1C0q/fvUHK+35rF7QT3+/u38+fX149YOyejxb/9yfYBAMgkEwCAbBYP1zf4JBMAgGwSAYBINgEAyiQDAIBsEgGASDYBAMgkEwCIbc51P954JBMCSPP+ufYBAMJoxgEAyCQTBY/9yfYBAMgkEwCAbBIBgEA4JBM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