@opengeni/runtime 2.4.2-canary.1 → 2.4.2-canary.2

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 CHANGED
@@ -244,7 +244,7 @@ import {
244
244
  workspaceEnvironmentInstructions,
245
245
  wrapAttemptToolDefinitions,
246
246
  wrapAttemptToolExecute
247
- } from "./chunk-D3NTOAWT.js";
247
+ } from "./chunk-AJGE4GG3.js";
248
248
  import {
249
249
  ActiveBackendUnresolvableError,
250
250
  BROWSER_CONTROL_ADMIN_TOKEN_FILE,
@@ -514,7 +514,7 @@ import {
514
514
  withRunCredentialsClient,
515
515
  withRunCredentialsSession,
516
516
  withoutSandboxProviderIdentity
517
- } from "./chunk-7DAVK6Y5.js";
517
+ } from "./chunk-WATBACLT.js";
518
518
  import "./chunk-YRKIQK25.js";
519
519
  import {
520
520
  SKILL_MAX_FILES,
@@ -265,7 +265,7 @@ import {
265
265
  withRunCredentialsClient,
266
266
  withRunCredentialsSession,
267
267
  withoutSandboxProviderIdentity
268
- } from "../chunk-7DAVK6Y5.js";
268
+ } from "../chunk-WATBACLT.js";
269
269
  import "../chunk-YRKIQK25.js";
270
270
  import "../chunk-ORKCCH5X.js";
271
271
  import "../chunk-PZ5AY32C.js";
@@ -24,11 +24,12 @@ export type ModalProviderOutputPage = {
24
24
  * returned locator/cursors outside the command's write authority. */
25
25
  export declare class ModalCommandControl {
26
26
  private readonly client;
27
- private readonly sandboxId;
27
+ private readonly sandboxIdentity;
28
28
  private readonly root;
29
29
  private readonly environment;
30
30
  private constructor();
31
- static forSandbox(client: CommandClient, sandboxId: string, root: string, environment?: Record<string, string> | (() => Record<string, string>)): ModalCommandControl;
31
+ static forSandbox(client: CommandClient, sandboxId: string | (() => string), root: string, environment?: Record<string, string> | (() => Record<string, string>)): ModalCommandControl;
32
+ private get sandboxId();
32
33
  start(args: ChannelAExecArgs, signal?: AbortSignal): Promise<ModalProviderCommand>;
33
34
  read(command: ModalProviderCommand, yieldTimeMs: number, signal?: AbortSignal): Promise<ModalProviderOutputPage>;
34
35
  write(command: ModalProviderCommand, chars: string, messageIndex: number): Promise<void>;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  prepareAgentTools
3
- } from "./chunk-D3NTOAWT.js";
4
- import "./chunk-7DAVK6Y5.js";
3
+ } from "./chunk-AJGE4GG3.js";
4
+ import "./chunk-WATBACLT.js";
5
5
  import "./chunk-YRKIQK25.js";
6
6
  import "./chunk-7K6WOXFS.js";
7
7
  import "./chunk-UZ66CGC2.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeni/runtime",
3
- "version": "2.4.2-canary.1",
3
+ "version": "2.4.2-canary.2",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -62,16 +62,16 @@
62
62
  "@openai/agents": "0.14.3",
63
63
  "@openai/agents-core": "0.14.3",
64
64
  "@openai/agents-extensions": "0.14.3",
65
- "@opengeni/agent-proto": "^0.5.1-canary.21",
66
- "@opengeni/capabilities": "^0.3.3-canary.3",
67
- "@opengeni/codemode": "^0.5.2-canary.1",
68
- "@opengeni/codex": "^0.2.22-canary.3",
69
- "@opengeni/config": "^1.0.3-canary.1",
70
- "@opengeni/contracts": "^2.15.1-canary.1",
71
- "@opengeni/network": "^0.3.1-canary.3",
72
- "@opengeni/sdk": "^4.0.1-canary.1",
73
- "@opengeni/tool-gateway": "^0.1.3-canary.1",
74
- "@opengeni/xai-subscription": "^0.1.4-canary.3",
65
+ "@opengeni/agent-proto": "^0.5.1-canary.22",
66
+ "@opengeni/capabilities": "^0.3.3-canary.4",
67
+ "@opengeni/codemode": "^0.5.2-canary.2",
68
+ "@opengeni/codex": "^0.2.22-canary.4",
69
+ "@opengeni/config": "^1.0.3-canary.2",
70
+ "@opengeni/contracts": "^2.15.1-canary.2",
71
+ "@opengeni/network": "^0.3.1-canary.4",
72
+ "@opengeni/sdk": "^4.0.1-canary.2",
73
+ "@opengeni/tool-gateway": "^0.1.3-canary.2",
74
+ "@opengeni/xai-subscription": "^0.1.4-canary.4",
75
75
  "debug": "4.4.3",
76
76
  "modal": "0.9.0",
77
77
  "openai": "6.47.0",
@@ -117,14 +117,14 @@ function decodePage(prior: string, input: Uint8Array[], terminal: boolean) {
117
117
  export class ModalCommandControl {
118
118
  private constructor(
119
119
  private readonly client: ControlPlane,
120
- private readonly sandboxId: string,
120
+ private readonly sandboxIdentity: string | (() => string),
121
121
  private readonly root: string,
122
122
  private readonly environment: Record<string, string> | (() => Record<string, string>) = {},
123
123
  ) {}
124
124
 
125
125
  static forSandbox(
126
126
  client: CommandClient,
127
- sandboxId: string,
127
+ sandboxId: string | (() => string),
128
128
  root: string,
129
129
  environment: Record<string, string> | (() => Record<string, string>) = {},
130
130
  ): ModalCommandControl {
@@ -133,16 +133,24 @@ export class ModalCommandControl {
133
133
  return new ModalCommandControl(commandControlPlane(client), sandboxId, root, environment);
134
134
  }
135
135
 
136
+ private get sandboxId(): string {
137
+ return typeof this.sandboxIdentity === "function"
138
+ ? this.sandboxIdentity()
139
+ : this.sandboxIdentity;
140
+ }
141
+
136
142
  async start(args: ChannelAExecArgs, signal?: AbortSignal): Promise<ModalProviderCommand> {
137
143
  signal?.throwIfAborted();
138
144
  const workdir = posix.resolve(this.root, args.workdir ?? this.root);
139
145
  if (workdir !== this.root && !workdir.startsWith(`${this.root.replace(/\/$/u, "")}/`))
140
146
  throw new Error("Command workdir is outside the sandbox workspace");
141
- const task = await this.client.sandboxGetTaskId(
142
- { sandboxId: this.sandboxId },
143
- signal ? { signal } : undefined,
144
- );
147
+ // Hydration replaces the SDK sandbox. Freeze its current identity for this
148
+ // start so an asynchronous replacement cannot relabel the returned locator.
149
+ const sandboxId = this.sandboxId;
150
+ const task = await this.client.sandboxGetTaskId({ sandboxId }, signal ? { signal } : undefined);
145
151
  if (!task.taskId || task.taskResult) throw new Error("Modal command task is unavailable");
152
+ if (sandboxId !== this.sandboxId)
153
+ throw new Error("Modal sandbox changed during command preparation");
146
154
  const login = args.shell ? (args.login ?? true) : false;
147
155
  let command = [args.shell ?? "/bin/sh", login ? "-lc" : "-c", args.cmd];
148
156
  if (args.runAs) {
@@ -194,7 +202,7 @@ export class ModalCommandControl {
194
202
  if (!result.execId) throw new Error("Modal command start returned no execution identity");
195
203
  return {
196
204
  kind: "modal-control-v1",
197
- sandboxId: this.sandboxId,
205
+ sandboxId,
198
206
  taskId: task.taskId,
199
207
  execId: result.execId,
200
208
  ...(args.tty ? { pty: true } : {}),
@@ -562,7 +562,11 @@ export function installOpenGeniModalSnapshotPolicy<T extends object>(session: T)
562
562
  profile: mutable.modal.profile,
563
563
  ...(mutable.modal.logger ? { logger: mutable.modal.logger } : {}),
564
564
  },
565
- mutable.state.sandboxId,
565
+ () => {
566
+ const sandboxId = mutable.state?.sandboxId;
567
+ if (!sandboxId) throw new Error("Modal session sandbox identity is unavailable");
568
+ return sandboxId;
569
+ },
566
570
  mutable.state.manifest.root,
567
571
  () => mutable.state?.environment ?? {},
568
572
  ),