@rivet-dev/agentos-runtime-core 0.0.0-main.2f99c77 → 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 (238) hide show
  1. package/README.md +2 -2
  2. package/commands/[ +0 -0
  3. package/commands/_stubs +0 -0
  4. package/commands/acl_tools +0 -0
  5. package/commands/arch +0 -0
  6. package/commands/attr +0 -0
  7. package/commands/awk +0 -0
  8. package/commands/b2sum +0 -0
  9. package/commands/base32 +0 -0
  10. package/commands/base64 +0 -0
  11. package/commands/basename +0 -0
  12. package/commands/basenc +0 -0
  13. package/commands/bash +0 -0
  14. package/commands/bc +0 -0
  15. package/commands/cat +0 -0
  16. package/commands/chacl +0 -0
  17. package/commands/chcon +0 -0
  18. package/commands/chgrp +0 -0
  19. package/commands/chmod +0 -0
  20. package/commands/chown +0 -0
  21. package/commands/chroot +0 -0
  22. package/commands/cksum +0 -0
  23. package/commands/cmp +0 -0
  24. package/commands/column +0 -0
  25. package/commands/comm +0 -0
  26. package/commands/cp +0 -0
  27. package/commands/curl +0 -0
  28. package/commands/cut +0 -0
  29. package/commands/date +0 -0
  30. package/commands/dd +0 -0
  31. package/commands/df +0 -0
  32. package/commands/diff +0 -0
  33. package/commands/dir +0 -0
  34. package/commands/dircolors +0 -0
  35. package/commands/dirname +0 -0
  36. package/commands/du +0 -0
  37. package/commands/echo +0 -0
  38. package/commands/egrep +0 -0
  39. package/commands/env +0 -0
  40. package/commands/envsubst +0 -0
  41. package/commands/expand +0 -0
  42. package/commands/expr +0 -0
  43. package/commands/factor +0 -0
  44. package/commands/false +0 -0
  45. package/commands/fd +0 -0
  46. package/commands/fgrep +0 -0
  47. package/commands/file +0 -0
  48. package/commands/find +0 -0
  49. package/commands/findmnt +0 -0
  50. package/commands/fmt +0 -0
  51. package/commands/fold +0 -0
  52. package/commands/getent +0 -0
  53. package/commands/getfacl +0 -0
  54. package/commands/getfattr +0 -0
  55. package/commands/git +0 -0
  56. package/commands/git-receive-pack +0 -0
  57. package/commands/git-remote-http +0 -0
  58. package/commands/git-remote-https +0 -0
  59. package/commands/git-upload-archive +0 -0
  60. package/commands/git-upload-pack +0 -0
  61. package/commands/grep +0 -0
  62. package/commands/groups +0 -0
  63. package/commands/gunzip +0 -0
  64. package/commands/gzip +0 -0
  65. package/commands/head +0 -0
  66. package/commands/hostid +0 -0
  67. package/commands/hostname +0 -0
  68. package/commands/http-test +0 -0
  69. package/commands/id +0 -0
  70. package/commands/install +0 -0
  71. package/commands/join +0 -0
  72. package/commands/jq +0 -0
  73. package/commands/kill +0 -0
  74. package/commands/link +0 -0
  75. package/commands/ln +0 -0
  76. package/commands/logname +0 -0
  77. package/commands/ls +0 -0
  78. package/commands/md5sum +0 -0
  79. package/commands/mkdir +0 -0
  80. package/commands/mkfifo +0 -0
  81. package/commands/mknod +0 -0
  82. package/commands/mktemp +0 -0
  83. package/commands/more +0 -0
  84. package/commands/mount +0 -0
  85. package/commands/mv +0 -0
  86. package/commands/nice +0 -0
  87. package/commands/nl +0 -0
  88. package/commands/nohup +0 -0
  89. package/commands/nproc +0 -0
  90. package/commands/numfmt +0 -0
  91. package/commands/od +0 -0
  92. package/commands/paste +0 -0
  93. package/commands/pathchk +0 -0
  94. package/commands/pinky +0 -0
  95. package/commands/printenv +0 -0
  96. package/commands/printf +0 -0
  97. package/commands/ptx +0 -0
  98. package/commands/pwd +0 -0
  99. package/commands/readlink +0 -0
  100. package/commands/realpath +0 -0
  101. package/commands/rev +0 -0
  102. package/commands/rg +0 -0
  103. package/commands/rm +0 -0
  104. package/commands/rmdir +0 -0
  105. package/commands/runas +0 -0
  106. package/commands/runcon +0 -0
  107. package/commands/sed +0 -0
  108. package/commands/seq +0 -0
  109. package/commands/setfacl +0 -0
  110. package/commands/setfattr +0 -0
  111. package/commands/sh +0 -0
  112. package/commands/sha1sum +0 -0
  113. package/commands/sha224sum +0 -0
  114. package/commands/sha256sum +0 -0
  115. package/commands/sha384sum +0 -0
  116. package/commands/sha512sum +0 -0
  117. package/commands/shred +0 -0
  118. package/commands/shuf +0 -0
  119. package/commands/sleep +0 -0
  120. package/commands/sort +0 -0
  121. package/commands/spawn-test-host +0 -0
  122. package/commands/split +0 -0
  123. package/commands/sqlite3 +0 -0
  124. package/commands/ssh +0 -0
  125. package/commands/ssh-keysign +0 -0
  126. package/commands/ssh-sk-helper +0 -0
  127. package/commands/stat +0 -0
  128. package/commands/stdbuf +0 -0
  129. package/commands/strings +0 -0
  130. package/commands/stty +0 -0
  131. package/commands/su +0 -0
  132. package/commands/sum +0 -0
  133. package/commands/sync +0 -0
  134. package/commands/tac +0 -0
  135. package/commands/tail +0 -0
  136. package/commands/tar +0 -0
  137. package/commands/tee +0 -0
  138. package/commands/test +0 -0
  139. package/commands/timeout +0 -0
  140. package/commands/touch +0 -0
  141. package/commands/tr +0 -0
  142. package/commands/tree +0 -0
  143. package/commands/true +0 -0
  144. package/commands/truncate +0 -0
  145. package/commands/tsort +0 -0
  146. package/commands/tty +0 -0
  147. package/commands/uname +0 -0
  148. package/commands/unexpand +0 -0
  149. package/commands/uniq +0 -0
  150. package/commands/unlink +0 -0
  151. package/commands/unzip +0 -0
  152. package/commands/uptime +0 -0
  153. package/commands/users +0 -0
  154. package/commands/vdir +0 -0
  155. package/commands/wc +0 -0
  156. package/commands/wget +0 -0
  157. package/commands/which +0 -0
  158. package/commands/who +0 -0
  159. package/commands/whoami +0 -0
  160. package/commands/xargs +0 -0
  161. package/commands/xattr_tools +0 -0
  162. package/commands/xfs_io +0 -0
  163. package/commands/xu +0 -0
  164. package/commands/yes +0 -0
  165. package/commands/yq +0 -0
  166. package/commands/zcat +0 -0
  167. package/commands/zip +0 -0
  168. package/dist/binary.js +4 -3
  169. package/dist/descriptors.d.ts +2 -12
  170. package/dist/descriptors.js +10 -6
  171. package/dist/event-buffer.d.ts +14 -0
  172. package/dist/event-buffer.js +30 -1
  173. package/dist/frame-stream.d.ts +34 -0
  174. package/dist/frame-stream.js +121 -0
  175. package/dist/generated/AcpLimitsConfig.d.ts +16 -0
  176. package/dist/generated/BindingLimitsConfig.d.ts +10 -0
  177. package/dist/generated/CreateVmConfig.d.ts +4 -0
  178. package/dist/generated/ExecutionLimitsConfig.d.ts +5 -0
  179. package/dist/generated/ExecutionLimitsConfig.js +2 -0
  180. package/dist/generated/Http2LimitsConfig.d.ts +12 -0
  181. package/dist/generated/Http2LimitsConfig.js +2 -0
  182. package/dist/generated/JsRuntimeLimitsConfig.d.ts +1 -0
  183. package/dist/generated/MountPluginDescriptor.d.ts +1 -1
  184. package/dist/generated/ProcessLimitsConfig.d.ts +7 -0
  185. package/dist/generated/ProcessLimitsConfig.js +2 -0
  186. package/dist/generated/ReactorLimitsConfig.d.ts +23 -0
  187. package/dist/generated/ReactorLimitsConfig.js +2 -0
  188. package/dist/generated/SqliteLimitsConfig.d.ts +3 -0
  189. package/dist/generated/SqliteLimitsConfig.js +2 -0
  190. package/dist/generated/TlsLimitsConfig.d.ts +3 -0
  191. package/dist/generated/TlsLimitsConfig.js +2 -0
  192. package/dist/generated/UdpLimitsConfig.d.ts +4 -0
  193. package/dist/generated/UdpLimitsConfig.js +2 -0
  194. package/dist/generated/VmGroupConfig.d.ts +5 -0
  195. package/dist/generated/VmGroupConfig.js +2 -0
  196. package/dist/generated/VmLimitsConfig.d.ts +16 -2
  197. package/dist/generated/VmSqliteDescriptor.d.ts +10 -0
  198. package/dist/generated/VmSqliteDescriptor.js +2 -0
  199. package/dist/generated/VmUserAccountConfig.d.ts +9 -0
  200. package/dist/generated/VmUserAccountConfig.js +2 -0
  201. package/dist/generated/VmUserConfig.d.ts +19 -0
  202. package/dist/generated/VmUserConfig.js +1 -0
  203. package/dist/generated/WasmLimitsConfig.d.ts +1 -0
  204. package/dist/generated-protocol.d.ts +610 -2
  205. package/dist/generated-protocol.js +1534 -75
  206. package/dist/kernel-proxy.d.ts +4 -0
  207. package/dist/kernel-proxy.js +66 -34
  208. package/dist/native-client.d.ts +3 -3
  209. package/dist/native-client.js +43 -8
  210. package/dist/node-runtime-options-schema.d.ts +1 -1
  211. package/dist/node-runtime-options-schema.js +43 -1
  212. package/dist/node-runtime.d.ts +12 -3
  213. package/dist/node-runtime.js +13 -12
  214. package/dist/process.d.ts +5 -1
  215. package/dist/process.js +35 -8
  216. package/dist/protocol-client.d.ts +9 -2
  217. package/dist/protocol-client.js +127 -7
  218. package/dist/protocol-frames.d.ts +14 -3
  219. package/dist/protocol-frames.js +26 -1
  220. package/dist/protocol-schema.d.ts +1 -1
  221. package/dist/protocol-schema.js +1 -1
  222. package/dist/request-payloads.d.ts +100 -1
  223. package/dist/request-payloads.js +73 -2
  224. package/dist/response-payloads.d.ts +49 -1
  225. package/dist/response-payloads.js +51 -1
  226. package/dist/sidecar-errors.d.ts +22 -0
  227. package/dist/sidecar-errors.js +10 -0
  228. package/dist/sidecar-process.d.ts +20 -3
  229. package/dist/sidecar-process.js +104 -14
  230. package/dist/test-runtime.d.ts +25 -7
  231. package/dist/test-runtime.js +216 -69
  232. package/dist/vm-config.d.ts +5 -1
  233. package/package.json +16 -6
  234. package/commands/codex +0 -0
  235. package/commands/codex-exec +0 -0
  236. package/commands/http_get +0 -0
  237. package/dist/generated/ToolLimitsConfig.d.ts +0 -10
  238. /package/dist/generated/{ToolLimitsConfig.js → BindingLimitsConfig.js} +0 -0
@@ -1,13 +1,19 @@
1
1
  import type { Readable, Writable } from "node:stream";
2
2
  import { type LiveSidecarEventSelector } from "./event-buffer.js";
3
- import type { FrameTransport } from "./frame-stream.js";
4
- import { type LiveEventFrame, type LiveProtocolFrame, type LiveResponseFrame, type LiveSidecarRequestFrame, type LiveSidecarRequestHandler, type ProtocolFramePayloadCodec } from "./protocol-frames.js";
3
+ import { type FrameTransport } from "./frame-stream.js";
5
4
  import type { LiveOwnershipScope } from "./ownership.js";
5
+ import { type LiveControlFrame, type LiveEventFrame, type LiveProtocolFrame, type LiveRequestFrame, type LiveResponseFrame, type LiveSidecarRequestFrame, type LiveSidecarRequestHandler, type LiveSidecarResponseFrame, type ProtocolFramePayloadCodec } from "./protocol-frames.js";
6
6
  import type { LiveRequestPayload } from "./request-payloads.js";
7
7
  export interface SidecarProtocolClientOptions {
8
+ /** A combined transport remains supported for embedders and focused tests. */
8
9
  frameTransport?: FrameTransport<LiveResponseFrame | LiveEventFrame | LiveSidecarRequestFrame, LiveProtocolFrame>;
10
+ ordinaryFrameTransport?: FrameTransport<LiveEventFrame, LiveRequestFrame>;
11
+ controlFrameTransport?: FrameTransport<LiveResponseFrame | LiveSidecarRequestFrame | LiveEventFrame, LiveSidecarResponseFrame | LiveControlFrame>;
9
12
  stdin?: Writable;
10
13
  stdout?: Readable;
14
+ control?: Readable & Writable;
15
+ /** Use one bidirectional stdin/stdout transport when the host cannot inherit fd 3. */
16
+ combinedStdio?: boolean;
11
17
  eventBufferCapacity: number;
12
18
  payloadCodec?: ProtocolFramePayloadCodec;
13
19
  stderrText?: () => string;
@@ -50,6 +56,7 @@ export declare class SidecarProtocolClient {
50
56
  ownership: LiveOwnershipScope;
51
57
  payload: LiveRequestPayload;
52
58
  }): Promise<LiveResponseFrame>;
59
+ shutdown(reason: string): Promise<void>;
53
60
  waitForEvent(matcher: LiveSidecarEventSelector | ((event: LiveEventFrame) => boolean), timeoutMs?: number, options?: {
54
61
  signal?: AbortSignal;
55
62
  }): Promise<LiveEventFrame>;
@@ -1,7 +1,8 @@
1
- import { SidecarEventBuffer, SidecarEventBufferOverflow, normalizeSidecarEventMatcher, sidecarEventWaitAbortError, } from "./event-buffer.js";
1
+ import { normalizeSidecarEventMatcher, SidecarEventBuffer, SidecarEventBufferOverflow, sidecarEventWaitAbortError, } from "./event-buffer.js";
2
2
  import { FrameRpcTransport } from "./frame-rpc.js";
3
- import { HostProtocolFrameFactory, classifySidecarWrittenProtocolFrame, decodeProtocolFramePayload, encodeProtocolFramePayload, resolveSidecarRequestFramePayload, } from "./protocol-frames.js";
4
- import { SidecarSilenceTimeout } from "./sidecar-errors.js";
3
+ import { SplitLaneFrameTransport, StdioFrameTransport, } from "./frame-stream.js";
4
+ import { classifySidecarWrittenProtocolFrame, decodeProtocolFramePayload, encodeProtocolFramePayload, HostProtocolFrameFactory, resolveSidecarRequestFramePayload, } from "./protocol-frames.js";
5
+ import { SidecarRejectedError, SidecarSilenceTimeout, } from "./sidecar-errors.js";
5
6
  /**
6
7
  * How long the host tolerates TOTAL inbound silence (no responses, events,
7
8
  * sidecar requests, or heartbeats) before declaring the sidecar dead. The
@@ -30,9 +31,7 @@ export class SidecarProtocolClient {
30
31
  this.payloadCodec = options.payloadCodec ?? "bare";
31
32
  this.stderrText = options.stderrText ?? (() => "");
32
33
  this.frameTransport = new FrameRpcTransport({
33
- frameTransport: options.frameTransport,
34
- stdin: options.stdin,
35
- stdout: options.stdout,
34
+ frameTransport: resolveProtocolFrameTransport(options, this.payloadCodec),
36
35
  encodeFrame: (frame) => encodeProtocolFramePayload(frame, this.payloadCodec),
37
36
  decodeFrame: (payload) => decodeProtocolFramePayload(payload, this.payloadCodec),
38
37
  classifyFrame: classifySidecarWrittenProtocolFrame,
@@ -109,10 +108,16 @@ export class SidecarProtocolClient {
109
108
  // wedged sidecar rejects this via the silence watchdog instead.
110
109
  const response = await this.frameTransport.sendFrame(request.request_id, request);
111
110
  if (response.payload.type === "rejected") {
112
- throw new Error(`sidecar rejected request ${request.request_id}: ${response.payload.code}: ${response.payload.message}`);
111
+ throw new SidecarRejectedError(request.request_id, response.payload);
113
112
  }
114
113
  return response;
115
114
  }
115
+ async shutdown(reason) {
116
+ if (this.closedError) {
117
+ throw this.closedError;
118
+ }
119
+ await this.frameTransport.writeFrame(this.hostFrameFactory.createControlFrame({ type: "shutdown", reason }));
120
+ }
116
121
  async waitForEvent(matcher, timeoutMs, options) {
117
122
  if (this.closedError instanceof SidecarEventBufferOverflow) {
118
123
  throw this.closedError;
@@ -188,6 +193,20 @@ export class SidecarProtocolClient {
188
193
  await this.frameTransport.writeFrame(frame);
189
194
  }
190
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
+ });
191
210
  const payload = await resolveSidecarRequestFramePayload(request, this.sidecarRequestHandler);
192
211
  try {
193
212
  await this.writeFrame(this.hostFrameFactory.createSidecarResponseFrame({
@@ -240,3 +259,104 @@ export class SidecarProtocolClient {
240
259
  this.eventWaiters.clear();
241
260
  }
242
261
  }
262
+ function resolveProtocolFrameTransport(options, payloadCodec) {
263
+ const hasSplitTransport = options.ordinaryFrameTransport !== undefined ||
264
+ options.controlFrameTransport !== undefined;
265
+ const hasStdio = options.stdin !== undefined ||
266
+ options.stdout !== undefined ||
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
+ }
283
+ if (options.frameTransport) {
284
+ if (hasSplitTransport || hasStdio) {
285
+ throw new Error("SidecarProtocolClient frameTransport cannot be combined with split-lane transports or streams");
286
+ }
287
+ return options.frameTransport;
288
+ }
289
+ let ordinary = options.ordinaryFrameTransport;
290
+ let control = options.controlFrameTransport;
291
+ if (hasSplitTransport) {
292
+ if (!ordinary || !control || hasStdio) {
293
+ throw new Error("SidecarProtocolClient requires both ordinaryFrameTransport and controlFrameTransport, without stdio streams");
294
+ }
295
+ }
296
+ else {
297
+ if (!options.stdin || !options.stdout || !options.control) {
298
+ throw new Error("SidecarProtocolClient requires a combined frameTransport or stdin/stdout/control streams");
299
+ }
300
+ ordinary = new StdioFrameTransport({
301
+ stdin: options.stdin,
302
+ stdout: options.stdout,
303
+ encodeFrame: (frame) => encodeProtocolFramePayload(frame, payloadCodec),
304
+ decodeFrame: (payload) => {
305
+ const frame = decodeProtocolFramePayload(payload, payloadCodec);
306
+ validateOrdinaryInboundFrame(frame);
307
+ return frame;
308
+ },
309
+ });
310
+ control = new StdioFrameTransport({
311
+ stdin: options.control,
312
+ stdout: options.control,
313
+ encodeFrame: (frame) => encodeProtocolFramePayload(frame, payloadCodec),
314
+ decodeFrame: (payload) => {
315
+ const frame = decodeProtocolFramePayload(payload, payloadCodec);
316
+ validateControlInboundFrame(frame);
317
+ return frame;
318
+ },
319
+ });
320
+ }
321
+ return new SplitLaneFrameTransport({
322
+ ordinary,
323
+ control,
324
+ validateOrdinaryFrame: validateOrdinaryInboundFrame,
325
+ validateControlFrame: validateControlInboundFrame,
326
+ selectWriteLane: (frame) => {
327
+ switch (frame.frame_type) {
328
+ case "request":
329
+ return "ordinary";
330
+ case "sidecar_response":
331
+ case "control":
332
+ return "control";
333
+ default: {
334
+ const invalidFrame = frame;
335
+ throw new Error(`host frame ${invalidFrame.frame_type} is not valid on either writable protocol lane`);
336
+ }
337
+ }
338
+ },
339
+ });
340
+ }
341
+ function validateOrdinaryInboundFrame(frame) {
342
+ if (frame.frame_type !== "event") {
343
+ throw new Error(`sidecar frame ${frame.frame_type} is not valid on the ordinary protocol lane`);
344
+ }
345
+ if (isHeartbeatFrame(frame)) {
346
+ throw new Error("sidecar heartbeat event is not valid on the ordinary protocol lane");
347
+ }
348
+ }
349
+ function validateControlInboundFrame(frame) {
350
+ if (frame.frame_type === "response" ||
351
+ frame.frame_type === "sidecar_request") {
352
+ return;
353
+ }
354
+ if (frame.frame_type === "event" &&
355
+ isHeartbeatFrame(frame)) {
356
+ return;
357
+ }
358
+ throw new Error(`sidecar frame ${frame.frame_type} is not valid on the control protocol lane`);
359
+ }
360
+ function isHeartbeatFrame(frame) {
361
+ return (frame.payload.type === "structured" && frame.payload.name === "heartbeat");
362
+ }
@@ -1,7 +1,7 @@
1
- import { type TransportPayloadCodec } from "./frame-payload-codec.js";
2
- import type { ClassifiedFrame } from "./frame-rpc.js";
3
1
  import { type LiveSidecarRequestPayload, type LiveSidecarResponsePayload } from "./callbacks.js";
4
2
  import { type LiveSidecarEventPayload } from "./event-buffer.js";
3
+ import { type TransportPayloadCodec } from "./frame-payload-codec.js";
4
+ import type { ClassifiedFrame } from "./frame-rpc.js";
5
5
  import * as protocol from "./generated-protocol.js";
6
6
  import { type LiveOwnershipScope } from "./ownership.js";
7
7
  import { SIDECAR_PROTOCOL_SCHEMA } from "./protocol-schema.js";
@@ -41,7 +41,16 @@ export interface LiveSidecarResponseFrame {
41
41
  ownership: LiveOwnershipScope;
42
42
  payload: LiveSidecarResponsePayload;
43
43
  }
44
- export type LiveProtocolFrame = LiveRequestFrame | LiveResponseFrame | LiveEventFrame | LiveSidecarRequestFrame | LiveSidecarResponseFrame;
44
+ export type LiveControlPayload = {
45
+ type: "shutdown";
46
+ reason: string;
47
+ };
48
+ export interface LiveControlFrame {
49
+ frame_type: "control";
50
+ schema: typeof SIDECAR_PROTOCOL_SCHEMA;
51
+ payload: LiveControlPayload;
52
+ }
53
+ export type LiveProtocolFrame = LiveRequestFrame | LiveResponseFrame | LiveEventFrame | LiveSidecarRequestFrame | LiveSidecarResponseFrame | LiveControlFrame;
45
54
  export type LiveSidecarWrittenProtocolFrame = LiveResponseFrame | LiveEventFrame | LiveSidecarRequestFrame;
46
55
  export type ProtocolFramePayloadCodec = TransportPayloadCodec;
47
56
  export type ClassifiedSidecarWrittenProtocolFrame = ClassifiedFrame<LiveResponseFrame, LiveEventFrame, LiveSidecarRequestFrame>;
@@ -56,6 +65,7 @@ export declare class HostProtocolFrameFactory {
56
65
  request: LiveSidecarRequestFrame;
57
66
  payload: LiveSidecarResponsePayload;
58
67
  }): LiveSidecarResponseFrame;
68
+ createControlFrame(payload: LiveControlPayload): LiveControlFrame;
59
69
  }
60
70
  export declare function resolveSidecarRequestFramePayload(request: LiveSidecarRequestFrame, handler: LiveSidecarRequestHandler | null): Promise<LiveSidecarResponsePayload>;
61
71
  export declare function toGeneratedProtocolFrame(frame: LiveProtocolFrame): protocol.ProtocolFrame;
@@ -65,4 +75,5 @@ export declare function encodeProtocolFramePayload(frame: LiveProtocolFrame, cod
65
75
  export declare function decodeProtocolFramePayload(payload: Uint8Array, codec: ProtocolFramePayloadCodec): LiveSidecarWrittenProtocolFrame;
66
76
  export declare function classifySidecarWrittenProtocolFrame(frame: LiveSidecarWrittenProtocolFrame): ClassifiedSidecarWrittenProtocolFrame;
67
77
  export declare function fromGeneratedSidecarWrittenProtocolFrame(frame: protocol.ProtocolFrame): LiveSidecarWrittenProtocolFrame;
78
+ export declare function toGeneratedControlPayload(payload: LiveControlPayload): protocol.ControlPayload;
68
79
  export declare function toLiveProtocolSchema(schema: protocol.ProtocolSchema): typeof SIDECAR_PROTOCOL_SCHEMA;
@@ -1,7 +1,7 @@
1
1
  import { toExactUint8Array } from "./bytes.js";
2
- import { decodeJsonFramePayload, encodeJsonFramePayload, } from "./frame-payload-codec.js";
3
2
  import { errorSidecarResponsePayload, fromGeneratedSidecarRequestPayload, isMatchingSidecarResponsePayload, toGeneratedSidecarResponsePayload, } from "./callbacks.js";
4
3
  import { fromGeneratedEventPayload, } from "./event-buffer.js";
4
+ import { decodeJsonFramePayload, encodeJsonFramePayload, } from "./frame-payload-codec.js";
5
5
  import * as protocol from "./generated-protocol.js";
6
6
  import { bigIntToSafeNumber } from "./numbers.js";
7
7
  import { fromGeneratedOwnershipScope, toGeneratedOwnershipScope, } from "./ownership.js";
@@ -28,6 +28,13 @@ export class HostProtocolFrameFactory {
28
28
  payload: input.payload,
29
29
  };
30
30
  }
31
+ createControlFrame(payload) {
32
+ return {
33
+ frame_type: "control",
34
+ schema: SIDECAR_PROTOCOL_SCHEMA,
35
+ payload,
36
+ };
37
+ }
31
38
  }
32
39
  export async function resolveSidecarRequestFramePayload(request, handler) {
33
40
  try {
@@ -66,6 +73,14 @@ export function toGeneratedProtocolFrame(frame) {
66
73
  payload: toGeneratedSidecarResponsePayload(frame.payload),
67
74
  },
68
75
  };
76
+ case "control":
77
+ return {
78
+ tag: "ControlFrame",
79
+ val: {
80
+ schema: frame.schema,
81
+ payload: toGeneratedControlPayload(frame.payload),
82
+ },
83
+ };
69
84
  case "response":
70
85
  case "event":
71
86
  case "sidecar_request":
@@ -131,9 +146,19 @@ export function fromGeneratedSidecarWrittenProtocolFrame(frame) {
131
146
  };
132
147
  case "RequestFrame":
133
148
  case "SidecarResponseFrame":
149
+ case "ControlFrame":
134
150
  throw new Error(`unsupported BARE protocol frame tag: ${frame.tag}`);
135
151
  }
136
152
  }
153
+ export function toGeneratedControlPayload(payload) {
154
+ switch (payload.type) {
155
+ case "shutdown":
156
+ return {
157
+ tag: "ShutdownControl",
158
+ val: { reason: payload.reason },
159
+ };
160
+ }
161
+ }
137
162
  export function toLiveProtocolSchema(schema) {
138
163
  return validateSidecarProtocolSchema(schema);
139
164
  }
@@ -1,6 +1,6 @@
1
1
  export declare const SIDECAR_PROTOCOL_SCHEMA: {
2
2
  readonly name: "agentos-native-sidecar";
3
- readonly version: 7;
3
+ readonly version: 8;
4
4
  };
5
5
  export type LiveProtocolSchema = typeof SIDECAR_PROTOCOL_SCHEMA;
6
6
  export type ProtocolSchemaLike = {
@@ -1,6 +1,6 @@
1
1
  export const SIDECAR_PROTOCOL_SCHEMA = {
2
2
  name: "agentos-native-sidecar",
3
- version: 7,
3
+ version: 8,
4
4
  };
5
5
  export function validateSidecarProtocolSchema(schema) {
6
6
  if (schema.name !== SIDECAR_PROTOCOL_SCHEMA.name ||
@@ -42,7 +42,7 @@ export type LiveRequestPayload = {
42
42
  packages?: LivePackageDescriptor[];
43
43
  packages_mount_at?: string;
44
44
  bootstrap_commands?: string[];
45
- tool_shim_commands?: string[];
45
+ binding_shim_commands?: string[];
46
46
  } | {
47
47
  type: "link_package";
48
48
  package: LivePackageDescriptor;
@@ -79,6 +79,9 @@ export type LiveRequestPayload = {
79
79
  lower_layer_ids: string[];
80
80
  } | {
81
81
  type: "snapshot_root_filesystem";
82
+ max_bytes: number;
83
+ } | {
84
+ type: "list_mounts";
82
85
  } | {
83
86
  type: "guest_kernel_call";
84
87
  execution_id: string;
@@ -147,6 +150,10 @@ export type LiveRequestPayload = {
147
150
  path: string;
148
151
  headers_json: string;
149
152
  body?: string;
153
+ body_base64?: string;
154
+ stream_operation?: "start" | "read" | "cancel";
155
+ stream_id?: string;
156
+ max_bytes?: number;
150
157
  } | {
151
158
  type: "get_signal_state";
152
159
  process_id: string;
@@ -164,6 +171,98 @@ export type LiveRequestPayload = {
164
171
  type: "persistence_flush";
165
172
  key: string;
166
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;
167
266
  } | {
168
267
  type: "ext";
169
268
  envelope: LiveExtEnvelope;
@@ -58,7 +58,7 @@ export function toGeneratedRequestPayload(payload) {
58
58
  packages: (payload.packages ?? []).map(toGeneratedPackageDescriptor),
59
59
  packagesMountAt: payload.packages_mount_at ?? "",
60
60
  bootstrapCommands: payload.bootstrap_commands ?? [],
61
- toolShimCommands: payload.tool_shim_commands ?? [],
61
+ bindingShimCommands: payload.binding_shim_commands ?? [],
62
62
  },
63
63
  };
64
64
  case "link_package":
@@ -153,7 +153,12 @@ export function toGeneratedRequestPayload(payload) {
153
153
  },
154
154
  };
155
155
  case "snapshot_root_filesystem":
156
- return { tag: "SnapshotRootFilesystemRequest", val: null };
156
+ return {
157
+ tag: "SnapshotRootFilesystemRequest",
158
+ val: { maxBytes: BigInt(payload.max_bytes) },
159
+ };
160
+ case "list_mounts":
161
+ return { tag: "ListMountsRequest", val: null };
157
162
  case "execute":
158
163
  return {
159
164
  tag: "ExecuteRequest",
@@ -226,6 +231,10 @@ export function toGeneratedRequestPayload(payload) {
226
231
  path: payload.path,
227
232
  headersJson: payload.headers_json,
228
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,
229
238
  },
230
239
  };
231
240
  case "get_signal_state":
@@ -257,6 +266,68 @@ export function toGeneratedRequestPayload(payload) {
257
266
  payloadSizeBytes: BigInt(payload.payload_size_bytes),
258
267
  },
259
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 };
260
331
  case "ext":
261
332
  return {
262
333
  tag: "ExtEnvelope",
@@ -1,5 +1,5 @@
1
- import { type LiveRootFilesystemEntry, type LiveRootFilesystemEntryEncoding } from "./filesystem.js";
2
1
  import { type LiveExtEnvelope } from "./ext.js";
2
+ import { type LiveRootFilesystemEntry, type LiveRootFilesystemEntryEncoding } from "./filesystem.js";
3
3
  import type * as protocol from "./generated-protocol.js";
4
4
  import { type LiveFilesystemOperation, type LiveGuestFilesystemOperation, type LiveSignalDispositionAction } from "./protocol-maps.js";
5
5
  import { type LiveGuestFilesystemStat, type LiveProcessSnapshotEntry, type LiveSocketStateEntry } from "./state.js";
@@ -49,6 +49,11 @@ export interface LivePackageCommands {
49
49
  package_name: string;
50
50
  commands: string[];
51
51
  }
52
+ export interface LiveMountInfo {
53
+ path: string;
54
+ kind: string;
55
+ read_only: boolean;
56
+ }
52
57
  export interface LiveAgentosProjectedAgent {
53
58
  id: string;
54
59
  acp_entrypoint: string;
@@ -79,6 +84,9 @@ export type LiveResponsePayload = {
79
84
  } | {
80
85
  type: "provided_commands_response";
81
86
  packages: LivePackageCommands[];
87
+ } | {
88
+ type: "mounts_listed";
89
+ mounts: LiveMountInfo[];
82
90
  } | {
83
91
  type: "host_callbacks_registered";
84
92
  registration: string;
@@ -179,6 +187,46 @@ export type LiveResponsePayload = {
179
187
  type: "rejected";
180
188
  code: string;
181
189
  message: string;
190
+ limit_name: string | null;
191
+ configured_limit: number | null;
192
+ current_usage: number | null;
193
+ requested: number | null;
194
+ unit: string | null;
195
+ scope: string | null;
196
+ vm_id: string | null;
197
+ session_generation: number | null;
198
+ capability_id: number | null;
199
+ operation: string | null;
200
+ configuration_path: string | null;
201
+ retryable: boolean | null;
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;
182
230
  } | {
183
231
  type: "ext_result";
184
232
  envelope: LiveExtEnvelope;