@rivet-dev/agentos-runtime-core 0.0.0-main.29b0797 → 0.0.0-main.5ac5a14

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.
Files changed (76) hide show
  1. package/README.md +1 -1
  2. package/commands/[ +0 -0
  3. package/commands/_stubs +0 -0
  4. package/commands/awk +0 -0
  5. package/commands/bash +0 -0
  6. package/commands/chcon +0 -0
  7. package/commands/chroot +0 -0
  8. package/commands/column +0 -0
  9. package/commands/diff +0 -0
  10. package/commands/du +0 -0
  11. package/commands/egrep +0 -0
  12. package/commands/env +0 -0
  13. package/commands/expr +0 -0
  14. package/commands/fgrep +0 -0
  15. package/commands/file +0 -0
  16. package/commands/groups +0 -0
  17. package/commands/gunzip +0 -0
  18. package/commands/gzip +0 -0
  19. package/commands/hostid +0 -0
  20. package/commands/http-test +0 -0
  21. package/commands/install +0 -0
  22. package/commands/jq +0 -0
  23. package/commands/nice +0 -0
  24. package/commands/nohup +0 -0
  25. package/commands/pinky +0 -0
  26. package/commands/rev +0 -0
  27. package/commands/rg +0 -0
  28. package/commands/runcon +0 -0
  29. package/commands/sh +0 -0
  30. package/commands/sleep +0 -0
  31. package/commands/spawn-test-host +0 -0
  32. package/commands/ssh +0 -0
  33. package/commands/stdbuf +0 -0
  34. package/commands/strings +0 -0
  35. package/commands/stty +0 -0
  36. package/commands/sync +0 -0
  37. package/commands/tar +0 -0
  38. package/commands/test +0 -0
  39. package/commands/timeout +0 -0
  40. package/commands/tty +0 -0
  41. package/commands/unzip +0 -0
  42. package/commands/uptime +0 -0
  43. package/commands/users +0 -0
  44. package/commands/wget +0 -0
  45. package/commands/which +0 -0
  46. package/commands/who +0 -0
  47. package/commands/whoami +0 -0
  48. package/commands/yq +0 -0
  49. package/commands/zcat +0 -0
  50. package/commands/zip +0 -0
  51. package/dist/event-buffer.d.ts +14 -0
  52. package/dist/event-buffer.js +30 -1
  53. package/dist/frame-stream.d.ts +1 -0
  54. package/dist/frame-stream.js +8 -0
  55. package/dist/generated/ExecutionLimitsConfig.d.ts +5 -0
  56. package/dist/generated/ExecutionLimitsConfig.js +2 -0
  57. package/dist/generated/VmLimitsConfig.d.ts +2 -0
  58. package/dist/generated/VmSqliteDescriptor.d.ts +0 -1
  59. package/dist/generated-protocol.d.ts +550 -0
  60. package/dist/generated-protocol.js +1446 -122
  61. package/dist/kernel-proxy.js +1 -1
  62. package/dist/native-client.js +22 -9
  63. package/dist/node-runtime.js +5 -5
  64. package/dist/process.d.ts +4 -2
  65. package/dist/process.js +11 -3
  66. package/dist/protocol-client.d.ts +2 -0
  67. package/dist/protocol-client.js +29 -0
  68. package/dist/request-payloads.d.ts +96 -0
  69. package/dist/request-payloads.js +66 -0
  70. package/dist/response-payloads.d.ts +27 -0
  71. package/dist/response-payloads.js +18 -0
  72. package/dist/sidecar-process.d.ts +8 -1
  73. package/dist/sidecar-process.js +27 -2
  74. package/dist/test-runtime.d.ts +7 -1
  75. package/dist/test-runtime.js +95 -14
  76. package/package.json +10 -3
@@ -26,7 +26,7 @@ export function serializeMountConfigForSidecar(mount) {
26
26
  }
27
27
  const SYNTHETIC_PID_BASE = 1_000_000;
28
28
  const MISSING_EXIT_EVENT_GRACE_MS = 500;
29
- const PROTECTED_READ_ONLY_GUEST_ROOTS = ["/etc/secure-exec"];
29
+ const PROTECTED_READ_ONLY_GUEST_ROOTS = ["/etc/agentos"];
30
30
  const TRAILING_OUTPUT_DRAIN_INTERVAL_MS = 10;
31
31
  const TRAILING_OUTPUT_DRAIN_MAX_MS = 250;
32
32
  const TRAILING_OUTPUT_DRAIN_QUIET_TURNS = 2;
@@ -18,10 +18,19 @@ export class StdioSidecarProtocolClient {
18
18
  this.gracefulExitMs = options.gracefulExitMs;
19
19
  this.forceExitMs = options.forceExitMs;
20
20
  this.disposedErrorMessage = options.disposedErrorMessage;
21
+ const transportOptions = this.sidecarProcess.combinedStdio
22
+ ? {
23
+ stdin: this.child.stdin,
24
+ stdout: this.child.stdout,
25
+ combinedStdio: true,
26
+ }
27
+ : {
28
+ stdin: this.child.stdin,
29
+ stdout: this.child.stdout,
30
+ control: this.sidecarProcess.control,
31
+ };
21
32
  this.protocolClient = new SidecarProtocolClient({
22
- stdin: this.child.stdin,
23
- stdout: this.child.stdout,
24
- control: this.sidecarProcess.control,
33
+ ...transportOptions,
25
34
  eventBufferCapacity: options.eventBufferCapacity,
26
35
  payloadCodec: options.payloadCodec,
27
36
  silenceTimeoutMs: options.silenceTimeoutMs,
@@ -53,10 +62,12 @@ export class StdioSidecarProtocolClient {
53
62
  });
54
63
  }
55
64
  static spawn(options = {}) {
65
+ const combinedStdio = typeof globalThis._childProcessSpawnStart !== "undefined";
56
66
  return new StdioSidecarProtocolClient(StdioSidecarProcess.spawn({
57
67
  command: options.command ?? resolvePublishedSidecarBinary(),
58
68
  args: options.args ?? [],
59
69
  cwd: options.cwd,
70
+ combinedStdio,
60
71
  }), {
61
72
  silenceTimeoutMs: options.silenceTimeoutMs,
62
73
  eventBufferCapacity: options.eventBufferCapacity ?? DEFAULT_SIDECAR_EVENT_BUFFER_CAPACITY,
@@ -95,7 +106,7 @@ export class StdioSidecarProtocolClient {
95
106
  // Stdin may already be closing. The child exit watcher will catch up.
96
107
  }
97
108
  }
98
- if (!this.sidecarProcess.control.destroyed) {
109
+ if (this.sidecarProcess.control && !this.sidecarProcess.control.destroyed) {
99
110
  try {
100
111
  this.sidecarProcess.control.end();
101
112
  }
@@ -132,11 +143,13 @@ export class StdioSidecarProtocolClient {
132
143
  catch {
133
144
  // Best effort. The child is gone so the descriptor will close on its own.
134
145
  }
135
- try {
136
- this.sidecarProcess.control.destroy();
137
- }
138
- catch {
139
- // Best effort. The child is gone so the descriptor will close on its own.
146
+ if (this.sidecarProcess.control) {
147
+ try {
148
+ this.sidecarProcess.control.destroy();
149
+ }
150
+ catch {
151
+ // Best effort. The child is gone so the descriptor will close on its own.
152
+ }
140
153
  }
141
154
  if (exitCode !== null && exitCode !== 0 && this.child.signalCode === null) {
142
155
  throw new Error(`sidecar exited with code ${exitCode}\nstderr:\n${this.sidecarProcess.stderrText()}`);
@@ -35,7 +35,7 @@ const REPO_COMMANDS_DIR = path.join(REPO_ROOT, "toolchain/target/wasm32-wasip1/r
35
35
  /**
36
36
  * Commands vendored into the published `@rivet-dev/agentos-runtime-core` package by
37
37
  * `scripts/copy-wasm-commands.mjs` (listed in `files` as `commands`). This is
38
- * the directory a real `npm install secure-exec` resolves: from the compiled
38
+ * the directory a real `npm install agentos` resolves: from the compiled
39
39
  * `dist/node-runtime.js` it sits at `<package>/commands`. This is the analogue
40
40
  * of how the sidecar binary ships inside `@rivet-dev/agentos-runtime-sidecar`.
41
41
  */
@@ -222,7 +222,7 @@ export class NodeRuntime {
222
222
  * `node <file>`; it runs as standard ESM (top-level `await`, `import`).
223
223
  */
224
224
  async exec(code, options = {}) {
225
- const programPath = `/tmp/secure-exec-program-${nextProgramId++}.mjs`;
225
+ const programPath = `/tmp/agentos-program-${nextProgramId++}.mjs`;
226
226
  await this.kernel.writeFile(programPath, withBindingPreamble(code));
227
227
  return this.runProgram(programPath, options);
228
228
  }
@@ -328,7 +328,7 @@ export class NodeRuntime {
328
328
  * ```
329
329
  */
330
330
  async spawn(code, options = {}) {
331
- const programPath = `/tmp/secure-exec-program-${nextProgramId++}.mjs`;
331
+ const programPath = `/tmp/agentos-program-${nextProgramId++}.mjs`;
332
332
  await this.kernel.writeFile(programPath, withBindingPreamble(code));
333
333
  const proc = this.kernel.spawn("node", [programPath], {
334
334
  env: options.env,
@@ -442,8 +442,8 @@ export class NodeRuntime {
442
442
  */
443
443
  async run(code, options = {}) {
444
444
  const id = nextProgramId++;
445
- const resultPath = `/tmp/secure-exec-result-${id}.json`;
446
- const programPath = `/tmp/secure-exec-program-${id}.mjs`;
445
+ const resultPath = `/tmp/agentos-result-${id}.json`;
446
+ const programPath = `/tmp/agentos-program-${id}.mjs`;
447
447
  // Inject the __return helper as a module-level preamble, then the user
448
448
  // code at module top level. Import declarations (preamble's and the
449
449
  // user's) are hoisted, so __return is defined before the user's
package/dist/process.d.ts CHANGED
@@ -6,16 +6,18 @@ export interface StdioSidecarProcessSpawnOptions {
6
6
  command: string;
7
7
  args?: string[];
8
8
  cwd?: string;
9
+ combinedStdio?: boolean;
9
10
  }
10
11
  export declare class StdioSidecarProcess {
11
12
  readonly child: ChildProcessWithoutNullStreams;
12
- readonly control: Duplex;
13
+ readonly control: Duplex | null;
14
+ readonly combinedStdio: boolean;
13
15
  private readonly stderrChunks;
14
16
  private readonly exitListeners;
15
17
  private readonly errorListeners;
16
18
  private constructor();
17
19
  static spawn(options: StdioSidecarProcessSpawnOptions): StdioSidecarProcess;
18
- static fromChild(child: ChildProcessWithoutNullStreams, control?: Duplex): StdioSidecarProcess;
20
+ static fromChild(child: ChildProcessWithoutNullStreams, control?: Duplex | null): StdioSidecarProcess;
19
21
  onExit(handler: (error: SidecarProcessExited) => void): () => void;
20
22
  onError(handler: (error: SidecarProcessError) => void): () => void;
21
23
  stderrText(): string;
package/dist/process.js CHANGED
@@ -4,12 +4,14 @@ import { SidecarProcessError, SidecarProcessExited } from "./sidecar-errors.js";
4
4
  export class StdioSidecarProcess {
5
5
  child;
6
6
  control;
7
+ combinedStdio;
7
8
  stderrChunks = [];
8
9
  exitListeners = new Set();
9
10
  errorListeners = new Set();
10
11
  constructor(child, control) {
11
12
  this.child = child;
12
13
  this.control = control;
14
+ this.combinedStdio = control === null;
13
15
  this.child.stderr.on("data", (chunk) => {
14
16
  this.stderrChunks.push(typeof chunk === "string" ? Buffer.from(chunk) : Buffer.from(chunk));
15
17
  });
@@ -32,12 +34,18 @@ export class StdioSidecarProcess {
32
34
  });
33
35
  }
34
36
  static spawn(options) {
37
+ const combinedStdio = options.combinedStdio === true;
35
38
  const child = spawn(options.command, options.args ?? [], {
36
39
  cwd: options.cwd,
37
- stdio: ["pipe", "pipe", "pipe", "pipe"],
40
+ env: combinedStdio
41
+ ? { ...process.env, AGENTOS_SIDECAR_COMBINED_STDIO: "1" }
42
+ : process.env,
43
+ stdio: combinedStdio
44
+ ? ["pipe", "pipe", "pipe"]
45
+ : ["pipe", "pipe", "pipe", "pipe"],
38
46
  });
39
47
  try {
40
- return new StdioSidecarProcess(child, requireControlStream(child));
48
+ return new StdioSidecarProcess(child, combinedStdio ? null : requireControlStream(child));
41
49
  }
42
50
  catch (error) {
43
51
  child.kill("SIGKILL");
@@ -45,7 +53,7 @@ export class StdioSidecarProcess {
45
53
  }
46
54
  }
47
55
  static fromChild(child, control) {
48
- return new StdioSidecarProcess(child, control ?? requireControlStream(child));
56
+ return new StdioSidecarProcess(child, control === null ? null : (control ?? requireControlStream(child)));
49
57
  }
50
58
  onExit(handler) {
51
59
  this.exitListeners.add(handler);
@@ -12,6 +12,8 @@ export interface SidecarProtocolClientOptions {
12
12
  stdin?: Writable;
13
13
  stdout?: Readable;
14
14
  control?: Readable & Writable;
15
+ /** Use one bidirectional stdin/stdout transport when the host cannot inherit fd 3. */
16
+ combinedStdio?: boolean;
15
17
  eventBufferCapacity: number;
16
18
  payloadCodec?: ProtocolFramePayloadCodec;
17
19
  stderrText?: () => string;
@@ -193,6 +193,20 @@ export class SidecarProtocolClient {
193
193
  await this.frameTransport.writeFrame(frame);
194
194
  }
195
195
  async dispatchSidecarRequest(request) {
196
+ // A callback can arrive immediately before the response that acknowledges
197
+ // the command which created it. Let the inbound decoder finish that turn
198
+ // before writing a callback response; otherwise a very fast host callback
199
+ // can complete and reap the guest process while its execute request is
200
+ // still being admitted, leaving the host waiting for an exit it missed.
201
+ await new Promise((resolve) => {
202
+ const scheduleImmediate = globalThis.setImmediate;
203
+ if (scheduleImmediate) {
204
+ scheduleImmediate(resolve);
205
+ }
206
+ else {
207
+ setTimeout(resolve, 0);
208
+ }
209
+ });
196
210
  const payload = await resolveSidecarRequestFramePayload(request, this.sidecarRequestHandler);
197
211
  try {
198
212
  await this.writeFrame(this.hostFrameFactory.createSidecarResponseFrame({
@@ -251,6 +265,21 @@ function resolveProtocolFrameTransport(options, payloadCodec) {
251
265
  const hasStdio = options.stdin !== undefined ||
252
266
  options.stdout !== undefined ||
253
267
  options.control !== undefined;
268
+ if (options.combinedStdio) {
269
+ if (options.frameTransport ||
270
+ hasSplitTransport ||
271
+ options.control !== undefined ||
272
+ !options.stdin ||
273
+ !options.stdout) {
274
+ throw new Error("SidecarProtocolClient combinedStdio requires only stdin and stdout streams");
275
+ }
276
+ return new StdioFrameTransport({
277
+ stdin: options.stdin,
278
+ stdout: options.stdout,
279
+ encodeFrame: (frame) => encodeProtocolFramePayload(frame, payloadCodec),
280
+ decodeFrame: (payload) => decodeProtocolFramePayload(payload, payloadCodec),
281
+ });
282
+ }
254
283
  if (options.frameTransport) {
255
284
  if (hasSplitTransport || hasStdio) {
256
285
  throw new Error("SidecarProtocolClient frameTransport cannot be combined with split-lane transports or streams");
@@ -150,6 +150,10 @@ export type LiveRequestPayload = {
150
150
  path: string;
151
151
  headers_json: string;
152
152
  body?: string;
153
+ body_base64?: string;
154
+ stream_operation?: "start" | "read" | "cancel";
155
+ stream_id?: string;
156
+ max_bytes?: number;
153
157
  } | {
154
158
  type: "get_signal_state";
155
159
  process_id: string;
@@ -167,6 +171,98 @@ export type LiveRequestPayload = {
167
171
  type: "persistence_flush";
168
172
  key: string;
169
173
  payload_size_bytes: number;
174
+ } | {
175
+ type: "shell_execution";
176
+ request: protocol.ShellExecutionRequest;
177
+ } | {
178
+ type: "argv_execution";
179
+ request: protocol.ArgvExecutionRequest;
180
+ } | {
181
+ type: "javascript_execution";
182
+ request: protocol.JavaScriptExecutionRequest;
183
+ } | {
184
+ type: "javascript_evaluation";
185
+ request: protocol.JavaScriptEvaluationRequest;
186
+ } | {
187
+ type: "javascript_file_execution";
188
+ request: protocol.JavaScriptFileExecutionRequest;
189
+ } | {
190
+ type: "typescript_execution";
191
+ request: protocol.TypeScriptExecutionRequest;
192
+ } | {
193
+ type: "typescript_evaluation";
194
+ request: protocol.TypeScriptEvaluationRequest;
195
+ } | {
196
+ type: "typescript_file_execution";
197
+ request: protocol.TypeScriptFileExecutionRequest;
198
+ } | {
199
+ type: "typescript_check";
200
+ request: protocol.TypeScriptCheckRequest;
201
+ } | {
202
+ type: "typescript_project_check";
203
+ request: protocol.TypeScriptProjectCheckRequest;
204
+ } | {
205
+ type: "npm_project_install";
206
+ request: protocol.NpmProjectInstallRequest;
207
+ } | {
208
+ type: "npm_package_install";
209
+ request: protocol.NpmPackageInstallRequest;
210
+ } | {
211
+ type: "npm_script_execution";
212
+ request: protocol.NpmScriptExecutionRequest;
213
+ } | {
214
+ type: "npm_package_execution";
215
+ request: protocol.NpmPackageExecutionRequest;
216
+ } | {
217
+ type: "python_execution";
218
+ request: protocol.PythonExecutionRequest;
219
+ } | {
220
+ type: "python_evaluation";
221
+ request: protocol.PythonEvaluationRequest;
222
+ } | {
223
+ type: "python_file_execution";
224
+ request: protocol.PythonFileExecutionRequest;
225
+ } | {
226
+ type: "python_module_execution";
227
+ request: protocol.PythonModuleExecutionRequest;
228
+ } | {
229
+ type: "python_install";
230
+ request: protocol.PythonInstallRequest;
231
+ } | {
232
+ type: "create_context";
233
+ request: protocol.CreateContextRequest;
234
+ } | {
235
+ type: "get_execution";
236
+ request: protocol.GetExecutionRequest;
237
+ } | {
238
+ type: "list_executions";
239
+ } | {
240
+ type: "wait_execution";
241
+ request: protocol.WaitExecutionRequest;
242
+ } | {
243
+ type: "cancel_execution";
244
+ request: protocol.CancelExecutionRequest;
245
+ } | {
246
+ type: "signal_execution";
247
+ request: protocol.SignalExecutionRequest;
248
+ } | {
249
+ type: "reset_execution";
250
+ request: protocol.ResetExecutionRequest;
251
+ } | {
252
+ type: "delete_execution";
253
+ request: protocol.DeleteExecutionRequest;
254
+ } | {
255
+ type: "write_execution_stdin";
256
+ request: protocol.WriteExecutionStdinRequest;
257
+ } | {
258
+ type: "close_execution_stdin";
259
+ request: protocol.CloseExecutionStdinRequest;
260
+ } | {
261
+ type: "resize_execution_pty";
262
+ request: protocol.ResizeExecutionPtyRequest;
263
+ } | {
264
+ type: "read_execution_output";
265
+ request: protocol.ReadExecutionOutputRequest;
170
266
  } | {
171
267
  type: "ext";
172
268
  envelope: LiveExtEnvelope;
@@ -231,6 +231,10 @@ export function toGeneratedRequestPayload(payload) {
231
231
  path: payload.path,
232
232
  headersJson: payload.headers_json,
233
233
  body: payload.body ?? null,
234
+ bodyBase64: payload.body_base64 ?? null,
235
+ streamOperation: payload.stream_operation ?? null,
236
+ streamId: payload.stream_id ?? null,
237
+ maxBytes: payload.max_bytes ?? null,
234
238
  },
235
239
  };
236
240
  case "get_signal_state":
@@ -262,6 +266,68 @@ export function toGeneratedRequestPayload(payload) {
262
266
  payloadSizeBytes: BigInt(payload.payload_size_bytes),
263
267
  },
264
268
  };
269
+ case "shell_execution":
270
+ return { tag: "ShellExecutionRequest", val: payload.request };
271
+ case "argv_execution":
272
+ return { tag: "ArgvExecutionRequest", val: payload.request };
273
+ case "javascript_execution":
274
+ return { tag: "JavaScriptExecutionRequest", val: payload.request };
275
+ case "javascript_evaluation":
276
+ return { tag: "JavaScriptEvaluationRequest", val: payload.request };
277
+ case "javascript_file_execution":
278
+ return { tag: "JavaScriptFileExecutionRequest", val: payload.request };
279
+ case "typescript_execution":
280
+ return { tag: "TypeScriptExecutionRequest", val: payload.request };
281
+ case "typescript_evaluation":
282
+ return { tag: "TypeScriptEvaluationRequest", val: payload.request };
283
+ case "typescript_file_execution":
284
+ return { tag: "TypeScriptFileExecutionRequest", val: payload.request };
285
+ case "typescript_check":
286
+ return { tag: "TypeScriptCheckRequest", val: payload.request };
287
+ case "typescript_project_check":
288
+ return { tag: "TypeScriptProjectCheckRequest", val: payload.request };
289
+ case "npm_project_install":
290
+ return { tag: "NpmProjectInstallRequest", val: payload.request };
291
+ case "npm_package_install":
292
+ return { tag: "NpmPackageInstallRequest", val: payload.request };
293
+ case "npm_script_execution":
294
+ return { tag: "NpmScriptExecutionRequest", val: payload.request };
295
+ case "npm_package_execution":
296
+ return { tag: "NpmPackageExecutionRequest", val: payload.request };
297
+ case "python_execution":
298
+ return { tag: "PythonExecutionRequest", val: payload.request };
299
+ case "python_evaluation":
300
+ return { tag: "PythonEvaluationRequest", val: payload.request };
301
+ case "python_file_execution":
302
+ return { tag: "PythonFileExecutionRequest", val: payload.request };
303
+ case "python_module_execution":
304
+ return { tag: "PythonModuleExecutionRequest", val: payload.request };
305
+ case "python_install":
306
+ return { tag: "PythonInstallRequest", val: payload.request };
307
+ case "create_context":
308
+ return { tag: "CreateContextRequest", val: payload.request };
309
+ case "get_execution":
310
+ return { tag: "GetExecutionRequest", val: payload.request };
311
+ case "list_executions":
312
+ return { tag: "ListExecutionsRequest", val: null };
313
+ case "wait_execution":
314
+ return { tag: "WaitExecutionRequest", val: payload.request };
315
+ case "cancel_execution":
316
+ return { tag: "CancelExecutionRequest", val: payload.request };
317
+ case "signal_execution":
318
+ return { tag: "SignalExecutionRequest", val: payload.request };
319
+ case "reset_execution":
320
+ return { tag: "ResetExecutionRequest", val: payload.request };
321
+ case "delete_execution":
322
+ return { tag: "DeleteExecutionRequest", val: payload.request };
323
+ case "write_execution_stdin":
324
+ return { tag: "WriteExecutionStdinRequest", val: payload.request };
325
+ case "close_execution_stdin":
326
+ return { tag: "CloseExecutionStdinRequest", val: payload.request };
327
+ case "resize_execution_pty":
328
+ return { tag: "ResizeExecutionPtyRequest", val: payload.request };
329
+ case "read_execution_output":
330
+ return { tag: "ReadExecutionOutputRequest", val: payload.request };
265
331
  case "ext":
266
332
  return {
267
333
  tag: "ExtEnvelope",
@@ -200,6 +200,33 @@ export type LiveResponsePayload = {
200
200
  configuration_path: string | null;
201
201
  retryable: boolean | null;
202
202
  errno: string | null;
203
+ } | {
204
+ type: "execution_accepted";
205
+ response: protocol.ExecutionAcceptedResponse;
206
+ } | {
207
+ type: "execution_completed";
208
+ response: protocol.ExecutionCompletedResponse;
209
+ } | {
210
+ type: "execution_evaluation";
211
+ response: protocol.ExecutionEvaluationResponse;
212
+ } | {
213
+ type: "typescript_check";
214
+ response: protocol.TypeScriptCheckResponse;
215
+ } | {
216
+ type: "execution_descriptor";
217
+ response: protocol.ExecutionDescriptorResponse;
218
+ } | {
219
+ type: "execution_list";
220
+ response: protocol.ExecutionListResponse;
221
+ } | {
222
+ type: "execution_deleted";
223
+ response: protocol.ExecutionDeletedResponse;
224
+ } | {
225
+ type: "execution_io";
226
+ response: protocol.ExecutionIoResponse;
227
+ } | {
228
+ type: "execution_output_page";
229
+ response: protocol.ExecutionOutputPageResponse;
203
230
  } | {
204
231
  type: "ext_result";
205
232
  envelope: LiveExtEnvelope;
@@ -271,6 +271,24 @@ export function fromGeneratedResponsePayload(payload) {
271
271
  type: "ext_result",
272
272
  envelope: fromGeneratedExtEnvelope(payload.val),
273
273
  };
274
+ case "ExecutionAcceptedResponse":
275
+ return { type: "execution_accepted", response: payload.val };
276
+ case "ExecutionCompletedResponse":
277
+ return { type: "execution_completed", response: payload.val };
278
+ case "ExecutionEvaluationResponse":
279
+ return { type: "execution_evaluation", response: payload.val };
280
+ case "TypeScriptCheckResponse":
281
+ return { type: "typescript_check", response: payload.val };
282
+ case "ExecutionDescriptorResponse":
283
+ return { type: "execution_descriptor", response: payload.val };
284
+ case "ExecutionListResponse":
285
+ return { type: "execution_list", response: payload.val };
286
+ case "ExecutionDeletedResponse":
287
+ return { type: "execution_deleted", response: payload.val };
288
+ case "ExecutionIoResponse":
289
+ return { type: "execution_io", response: payload.val };
290
+ case "ExecutionOutputPageResponse":
291
+ return { type: "execution_output_page", response: payload.val };
274
292
  }
275
293
  }
276
294
  function fromGeneratedAgentosProjectedAgent(agent) {
@@ -7,7 +7,8 @@ import type { SidecarProcessTransport } from "./sidecar-client.js";
7
7
  import { type LiveFsPermissionRule, type LivePatternPermissionRule, type LivePermissionMode, type LivePermissionScope, type LiveRulePermissions } from "./permissions.js";
8
8
  import type { LiveFilesystemOperation, LiveGuestRuntimeKind, LiveWasmPermissionTier } from "./protocol-maps.js";
9
9
  import { type LiveEventFrame, type LiveSidecarRequestHandler, type LiveSidecarRequestFrame, type LiveSidecarResponseFrame, type ProtocolFramePayloadCodec } from "./protocol-frames.js";
10
- import type { LiveGuestDirEntry } from "./response-payloads.js";
10
+ import { type LiveRequestPayload } from "./request-payloads.js";
11
+ import type { LiveGuestDirEntry, LiveResponsePayload } from "./response-payloads.js";
11
12
  import { type LiveGuestFilesystemStat } from "./state.js";
12
13
  export { SidecarProcessError, SidecarProcessExited, SidecarSilenceTimeout, } from "./sidecar-errors.js";
13
14
  export { SidecarEventBufferOverflow } from "./event-buffer.js";
@@ -348,6 +349,10 @@ export declare class SidecarProcess {
348
349
  path: string;
349
350
  headersJson: string;
350
351
  body?: string;
352
+ bodyBase64?: string;
353
+ streamOperation?: "start" | "read" | "cancel";
354
+ streamId?: string;
355
+ maxBytes?: number;
351
356
  }): Promise<string>;
352
357
  getSignalState(session: AuthenticatedSession, vm: CreatedVm, processId: string): Promise<SidecarSignalState>;
353
358
  getZombieTimerCount(session: AuthenticatedSession, vm: CreatedVm): Promise<SidecarZombieTimerCount>;
@@ -364,6 +369,8 @@ export declare class SidecarProcess {
364
369
  waitForEvent(matcher: SidecarEventSelector | ((event: EventFrame) => boolean), timeoutMs?: number, options?: {
365
370
  signal?: AbortSignal;
366
371
  }): Promise<EventFrame>;
372
+ /** Internal semantic request entrypoint used by the AgentOS client surface. */
373
+ sendVmRequest(session: AuthenticatedSession, vm: CreatedVm, payload: LiveRequestPayload): Promise<LiveResponsePayload>;
367
374
  dispose(): Promise<void>;
368
375
  private sendRequest;
369
376
  private guestFilesystemCall;
@@ -53,8 +53,8 @@ export class SidecarProcess {
53
53
  },
54
54
  payload: {
55
55
  type: "authenticate",
56
- client_name: "secure-exec-core-client",
57
- auth_token: "secure-exec-core-client-token",
56
+ client_name: "agentos-core-client",
57
+ auth_token: "agentos-core-client-token",
58
58
  protocol_version: SIDECAR_PROTOCOL_SCHEMA.version,
59
59
  bridge_version: BRIDGE_CONTRACT_VERSION,
60
60
  },
@@ -814,6 +814,18 @@ export class SidecarProcess {
814
814
  path: request.path,
815
815
  headers_json: request.headersJson,
816
816
  ...(request.body !== undefined ? { body: request.body } : {}),
817
+ ...(request.bodyBase64 !== undefined
818
+ ? { body_base64: request.bodyBase64 }
819
+ : {}),
820
+ ...(request.streamOperation !== undefined
821
+ ? { stream_operation: request.streamOperation }
822
+ : {}),
823
+ ...(request.streamId !== undefined
824
+ ? { stream_id: request.streamId }
825
+ : {}),
826
+ ...(request.maxBytes !== undefined
827
+ ? { max_bytes: request.maxBytes }
828
+ : {}),
817
829
  },
818
830
  });
819
831
  if (response.payload.type !== "vm_fetch_result") {
@@ -934,6 +946,19 @@ export class SidecarProcess {
934
946
  async waitForEvent(matcher, timeoutMs, options) {
935
947
  return await this.protocolClient.waitForEvent(matcher, timeoutMs, options);
936
948
  }
949
+ /** Internal semantic request entrypoint used by the AgentOS client surface. */
950
+ async sendVmRequest(session, vm, payload) {
951
+ const response = await this.sendRequest({
952
+ ownership: {
953
+ scope: "vm",
954
+ connection_id: session.connectionId,
955
+ session_id: session.sessionId,
956
+ vm_id: vm.vmId,
957
+ },
958
+ payload,
959
+ });
960
+ return response.payload;
961
+ }
937
962
  async dispose() {
938
963
  await this.protocolClient.dispose();
939
964
  }
@@ -1,7 +1,8 @@
1
1
  import "./native-client.js";
2
- import { SidecarProcess } from "./kernel-proxy.js";
3
2
  import type { JsRuntimeConfig } from "./generated/JsRuntimeConfig.js";
3
+ import type { VmLimitsConfig } from "./generated/VmLimitsConfig.js";
4
4
  import type { VmUserConfig } from "./generated/VmUserConfig.js";
5
+ import { SidecarProcess } from "./kernel-proxy.js";
5
6
  export declare const AF_INET = 2;
6
7
  export declare const AF_UNIX = 1;
7
8
  export declare const SOCK_STREAM = 1;
@@ -341,6 +342,10 @@ export interface Kernel extends KernelInterface {
341
342
  path: string;
342
343
  headersJson: string;
343
344
  body?: string;
345
+ bodyBase64?: string;
346
+ streamOperation?: "start" | "read" | "cancel";
347
+ streamId?: string;
348
+ maxBytes?: number;
344
349
  }): Promise<string>;
345
350
  registerBindings(bindings: Record<string, BindingDefinition>): Promise<void>;
346
351
  getResourceSnapshot(): Promise<{
@@ -567,6 +572,7 @@ export declare function createKernel(options: {
567
572
  hostNetworkAdapter?: unknown;
568
573
  loopbackExemptPorts?: number[];
569
574
  jsRuntime?: Partial<JsRuntimeConfig>;
575
+ limits?: VmLimitsConfig;
570
576
  logger?: unknown;
571
577
  mounts?: Array<{
572
578
  path: string;