@rivet-dev/agentos-runtime-core 0.0.0-glibc.4af31c1

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 (282) hide show
  1. package/README.md +7 -0
  2. package/commands/[ +0 -0
  3. package/commands/_stubs +0 -0
  4. package/commands/arch +0 -0
  5. package/commands/awk +0 -0
  6. package/commands/b2sum +0 -0
  7. package/commands/base32 +0 -0
  8. package/commands/base64 +0 -0
  9. package/commands/basename +0 -0
  10. package/commands/basenc +0 -0
  11. package/commands/bash +0 -0
  12. package/commands/cat +0 -0
  13. package/commands/chcon +0 -0
  14. package/commands/chgrp +0 -0
  15. package/commands/chmod +0 -0
  16. package/commands/chown +0 -0
  17. package/commands/chroot +0 -0
  18. package/commands/cksum +0 -0
  19. package/commands/codex +0 -0
  20. package/commands/codex-exec +0 -0
  21. package/commands/column +0 -0
  22. package/commands/comm +0 -0
  23. package/commands/cp +0 -0
  24. package/commands/curl +0 -0
  25. package/commands/cut +0 -0
  26. package/commands/date +0 -0
  27. package/commands/dd +0 -0
  28. package/commands/df +0 -0
  29. package/commands/diff +0 -0
  30. package/commands/dir +0 -0
  31. package/commands/dircolors +0 -0
  32. package/commands/dirname +0 -0
  33. package/commands/du +0 -0
  34. package/commands/echo +0 -0
  35. package/commands/egrep +0 -0
  36. package/commands/env +0 -0
  37. package/commands/envsubst +0 -0
  38. package/commands/expand +0 -0
  39. package/commands/expr +0 -0
  40. package/commands/factor +0 -0
  41. package/commands/false +0 -0
  42. package/commands/fd +0 -0
  43. package/commands/fgrep +0 -0
  44. package/commands/file +0 -0
  45. package/commands/find +0 -0
  46. package/commands/fmt +0 -0
  47. package/commands/fold +0 -0
  48. package/commands/git +0 -0
  49. package/commands/git-remote-http +0 -0
  50. package/commands/git-remote-https +0 -0
  51. package/commands/grep +0 -0
  52. package/commands/groups +0 -0
  53. package/commands/gunzip +0 -0
  54. package/commands/gzip +0 -0
  55. package/commands/head +0 -0
  56. package/commands/hostid +0 -0
  57. package/commands/hostname +0 -0
  58. package/commands/http-test +0 -0
  59. package/commands/http_get +0 -0
  60. package/commands/id +0 -0
  61. package/commands/install +0 -0
  62. package/commands/join +0 -0
  63. package/commands/jq +0 -0
  64. package/commands/kill +0 -0
  65. package/commands/link +0 -0
  66. package/commands/ln +0 -0
  67. package/commands/logname +0 -0
  68. package/commands/ls +0 -0
  69. package/commands/md5sum +0 -0
  70. package/commands/mkdir +0 -0
  71. package/commands/mkfifo +0 -0
  72. package/commands/mknod +0 -0
  73. package/commands/mktemp +0 -0
  74. package/commands/more +0 -0
  75. package/commands/mv +0 -0
  76. package/commands/nice +0 -0
  77. package/commands/nl +0 -0
  78. package/commands/nohup +0 -0
  79. package/commands/nproc +0 -0
  80. package/commands/numfmt +0 -0
  81. package/commands/od +0 -0
  82. package/commands/paste +0 -0
  83. package/commands/pathchk +0 -0
  84. package/commands/pinky +0 -0
  85. package/commands/printenv +0 -0
  86. package/commands/printf +0 -0
  87. package/commands/ptx +0 -0
  88. package/commands/pwd +0 -0
  89. package/commands/readlink +0 -0
  90. package/commands/realpath +0 -0
  91. package/commands/rev +0 -0
  92. package/commands/rg +0 -0
  93. package/commands/rm +0 -0
  94. package/commands/rmdir +0 -0
  95. package/commands/runcon +0 -0
  96. package/commands/sed +0 -0
  97. package/commands/seq +0 -0
  98. package/commands/sh +0 -0
  99. package/commands/sha1sum +0 -0
  100. package/commands/sha224sum +0 -0
  101. package/commands/sha256sum +0 -0
  102. package/commands/sha384sum +0 -0
  103. package/commands/sha512sum +0 -0
  104. package/commands/shred +0 -0
  105. package/commands/shuf +0 -0
  106. package/commands/sleep +0 -0
  107. package/commands/sort +0 -0
  108. package/commands/spawn-test-host +0 -0
  109. package/commands/split +0 -0
  110. package/commands/sqlite3 +0 -0
  111. package/commands/stat +0 -0
  112. package/commands/stdbuf +0 -0
  113. package/commands/strings +0 -0
  114. package/commands/stty +0 -0
  115. package/commands/sum +0 -0
  116. package/commands/sync +0 -0
  117. package/commands/tac +0 -0
  118. package/commands/tail +0 -0
  119. package/commands/tar +0 -0
  120. package/commands/tee +0 -0
  121. package/commands/test +0 -0
  122. package/commands/timeout +0 -0
  123. package/commands/touch +0 -0
  124. package/commands/tr +0 -0
  125. package/commands/tree +0 -0
  126. package/commands/true +0 -0
  127. package/commands/truncate +0 -0
  128. package/commands/tsort +0 -0
  129. package/commands/tty +0 -0
  130. package/commands/uname +0 -0
  131. package/commands/unexpand +0 -0
  132. package/commands/uniq +0 -0
  133. package/commands/unlink +0 -0
  134. package/commands/unzip +0 -0
  135. package/commands/uptime +0 -0
  136. package/commands/users +0 -0
  137. package/commands/vdir +0 -0
  138. package/commands/wc +0 -0
  139. package/commands/which +0 -0
  140. package/commands/who +0 -0
  141. package/commands/whoami +0 -0
  142. package/commands/xargs +0 -0
  143. package/commands/xu +0 -0
  144. package/commands/yes +0 -0
  145. package/commands/yq +0 -0
  146. package/commands/zcat +0 -0
  147. package/commands/zip +0 -0
  148. package/dist/binary.d.ts +4 -0
  149. package/dist/binary.js +25 -0
  150. package/dist/bytes.d.ts +2 -0
  151. package/dist/bytes.js +6 -0
  152. package/dist/callbacks.d.ts +41 -0
  153. package/dist/callbacks.js +94 -0
  154. package/dist/cargo.d.ts +2 -0
  155. package/dist/cargo.js +142 -0
  156. package/dist/correlation.d.ts +10 -0
  157. package/dist/correlation.js +49 -0
  158. package/dist/descriptors.d.ts +84 -0
  159. package/dist/descriptors.js +60 -0
  160. package/dist/event-buffer.d.ts +90 -0
  161. package/dist/event-buffer.js +313 -0
  162. package/dist/ext.d.ts +7 -0
  163. package/dist/ext.js +13 -0
  164. package/dist/filesystem.d.ts +41 -0
  165. package/dist/filesystem.js +70 -0
  166. package/dist/frame-payload-codec.d.ts +8 -0
  167. package/dist/frame-payload-codec.js +14 -0
  168. package/dist/frame-rpc.d.ts +40 -0
  169. package/dist/frame-rpc.js +81 -0
  170. package/dist/frame-stream.d.ts +34 -0
  171. package/dist/frame-stream.js +109 -0
  172. package/dist/framing.d.ts +8 -0
  173. package/dist/framing.js +23 -0
  174. package/dist/generated/AcpLimitsConfig.d.ts +4 -0
  175. package/dist/generated/AcpLimitsConfig.js +2 -0
  176. package/dist/generated/CreateVmConfig.d.ts +26 -0
  177. package/dist/generated/CreateVmConfig.js +1 -0
  178. package/dist/generated/FsPermissionRule.d.ts +6 -0
  179. package/dist/generated/FsPermissionRule.js +1 -0
  180. package/dist/generated/FsPermissionRuleSet.d.ts +6 -0
  181. package/dist/generated/FsPermissionRuleSet.js +1 -0
  182. package/dist/generated/FsPermissionScope.d.ts +3 -0
  183. package/dist/generated/FsPermissionScope.js +1 -0
  184. package/dist/generated/HttpLimitsConfig.d.ts +3 -0
  185. package/dist/generated/HttpLimitsConfig.js +2 -0
  186. package/dist/generated/JsModuleResolution.d.ts +1 -0
  187. package/dist/generated/JsModuleResolution.js +2 -0
  188. package/dist/generated/JsRuntimeConfig.d.ts +31 -0
  189. package/dist/generated/JsRuntimeConfig.js +1 -0
  190. package/dist/generated/JsRuntimeLimitsConfig.d.ts +11 -0
  191. package/dist/generated/JsRuntimeLimitsConfig.js +2 -0
  192. package/dist/generated/JsRuntimePlatform.d.ts +1 -0
  193. package/dist/generated/JsRuntimePlatform.js +2 -0
  194. package/dist/generated/MountPluginDescriptor.d.ts +4 -0
  195. package/dist/generated/MountPluginDescriptor.js +2 -0
  196. package/dist/generated/NativeRootFilesystemConfig.d.ts +5 -0
  197. package/dist/generated/NativeRootFilesystemConfig.js +1 -0
  198. package/dist/generated/PatternPermissionRule.d.ts +6 -0
  199. package/dist/generated/PatternPermissionRule.js +1 -0
  200. package/dist/generated/PatternPermissionRuleSet.d.ts +6 -0
  201. package/dist/generated/PatternPermissionRuleSet.js +1 -0
  202. package/dist/generated/PatternPermissionScope.d.ts +3 -0
  203. package/dist/generated/PatternPermissionScope.js +1 -0
  204. package/dist/generated/PermissionMode.d.ts +1 -0
  205. package/dist/generated/PermissionMode.js +2 -0
  206. package/dist/generated/PermissionsPolicy.d.ts +10 -0
  207. package/dist/generated/PermissionsPolicy.js +1 -0
  208. package/dist/generated/PluginLimitsConfig.d.ts +4 -0
  209. package/dist/generated/PluginLimitsConfig.js +2 -0
  210. package/dist/generated/PythonLimitsConfig.d.ts +6 -0
  211. package/dist/generated/PythonLimitsConfig.js +2 -0
  212. package/dist/generated/ResourceLimitsConfig.d.ts +24 -0
  213. package/dist/generated/ResourceLimitsConfig.js +2 -0
  214. package/dist/generated/RootFilesystemConfig.d.ts +9 -0
  215. package/dist/generated/RootFilesystemConfig.js +1 -0
  216. package/dist/generated/RootFilesystemEntry.d.ts +13 -0
  217. package/dist/generated/RootFilesystemEntry.js +1 -0
  218. package/dist/generated/RootFilesystemEntryEncoding.d.ts +1 -0
  219. package/dist/generated/RootFilesystemEntryEncoding.js +2 -0
  220. package/dist/generated/RootFilesystemEntryKind.d.ts +1 -0
  221. package/dist/generated/RootFilesystemEntryKind.js +2 -0
  222. package/dist/generated/RootFilesystemLowerDescriptor.d.ts +7 -0
  223. package/dist/generated/RootFilesystemLowerDescriptor.js +1 -0
  224. package/dist/generated/RootFilesystemMode.d.ts +1 -0
  225. package/dist/generated/RootFilesystemMode.js +2 -0
  226. package/dist/generated/ToolLimitsConfig.d.ts +10 -0
  227. package/dist/generated/ToolLimitsConfig.js +2 -0
  228. package/dist/generated/VmDnsConfig.d.ts +6 -0
  229. package/dist/generated/VmDnsConfig.js +2 -0
  230. package/dist/generated/VmLimitsConfig.d.ts +18 -0
  231. package/dist/generated/VmLimitsConfig.js +1 -0
  232. package/dist/generated/VmListenPolicyConfig.d.ts +5 -0
  233. package/dist/generated/VmListenPolicyConfig.js +2 -0
  234. package/dist/generated/WasmLimitsConfig.d.ts +7 -0
  235. package/dist/generated/WasmLimitsConfig.js +2 -0
  236. package/dist/generated-protocol.d.ts +1196 -0
  237. package/dist/generated-protocol.js +3286 -0
  238. package/dist/index.d.ts +29 -0
  239. package/dist/index.js +28 -0
  240. package/dist/json.d.ts +2 -0
  241. package/dist/json.js +20 -0
  242. package/dist/kernel-proxy.d.ts +166 -0
  243. package/dist/kernel-proxy.js +1777 -0
  244. package/dist/native-client.d.ts +42 -0
  245. package/dist/native-client.js +126 -0
  246. package/dist/node-runtime-options-schema.d.ts +117 -0
  247. package/dist/node-runtime-options-schema.js +121 -0
  248. package/dist/node-runtime.d.ts +593 -0
  249. package/dist/node-runtime.js +914 -0
  250. package/dist/numbers.d.ts +1 -0
  251. package/dist/numbers.js +8 -0
  252. package/dist/ownership.d.ts +18 -0
  253. package/dist/ownership.js +77 -0
  254. package/dist/permissions.d.ts +29 -0
  255. package/dist/permissions.js +68 -0
  256. package/dist/process.d.ts +22 -0
  257. package/dist/process.js +97 -0
  258. package/dist/protocol-client.d.ts +48 -0
  259. package/dist/protocol-client.js +181 -0
  260. package/dist/protocol-frames.d.ts +68 -0
  261. package/dist/protocol-frames.js +139 -0
  262. package/dist/protocol-maps.d.ts +31 -0
  263. package/dist/protocol-maps.js +273 -0
  264. package/dist/protocol-schema.d.ts +10 -0
  265. package/dist/protocol-schema.js +11 -0
  266. package/dist/request-payloads.d.ts +171 -0
  267. package/dist/request-payloads.js +269 -0
  268. package/dist/response-payloads.d.ts +186 -0
  269. package/dist/response-payloads.js +250 -0
  270. package/dist/sidecar-client.d.ts +17 -0
  271. package/dist/sidecar-client.js +1 -0
  272. package/dist/sidecar-errors.d.ts +15 -0
  273. package/dist/sidecar-errors.js +30 -0
  274. package/dist/sidecar-process.d.ts +356 -0
  275. package/dist/sidecar-process.js +1008 -0
  276. package/dist/state.d.ts +40 -0
  277. package/dist/state.js +44 -0
  278. package/dist/test-runtime.d.ts +563 -0
  279. package/dist/test-runtime.js +2171 -0
  280. package/dist/vm-config.d.ts +31 -0
  281. package/dist/vm-config.js +1 -0
  282. package/package.json +204 -0
@@ -0,0 +1,42 @@
1
+ import { StdioSidecarProcess } from "./process.js";
2
+ import type { SidecarProcessTransport } from "./sidecar-client.js";
3
+ import type { LiveEventFrame, LiveResponseFrame, LiveSidecarRequestHandler, ProtocolFramePayloadCodec } from "./protocol-frames.js";
4
+ import type { LiveOwnershipScope } from "./ownership.js";
5
+ import type { LiveRequestPayload } from "./request-payloads.js";
6
+ import type { LiveSidecarEventSelector } from "./event-buffer.js";
7
+ export declare const DEFAULT_SIDECAR_FRAME_TIMEOUT_MS = 120000;
8
+ export declare const DEFAULT_SIDECAR_EVENT_BUFFER_CAPACITY = 4096;
9
+ export declare const DEFAULT_SIDECAR_GRACEFUL_EXIT_MS = 5000;
10
+ export declare const DEFAULT_SIDECAR_FORCE_EXIT_MS = 2000;
11
+ export interface StdioSidecarProtocolClientSpawnOptions {
12
+ cwd?: string;
13
+ command?: string;
14
+ args?: string[];
15
+ frameTimeoutMs?: number;
16
+ eventBufferCapacity?: number;
17
+ gracefulExitMs?: number;
18
+ forceExitMs?: number;
19
+ disposedErrorMessage?: string;
20
+ payloadCodec?: ProtocolFramePayloadCodec;
21
+ }
22
+ export declare class StdioSidecarProtocolClient implements SidecarProcessTransport {
23
+ readonly child: StdioSidecarProcess["child"];
24
+ private readonly sidecarProcess;
25
+ private readonly protocolClient;
26
+ private readonly gracefulExitMs;
27
+ private readonly forceExitMs;
28
+ private readonly disposedErrorMessage;
29
+ private constructor();
30
+ static spawn(options?: StdioSidecarProtocolClientSpawnOptions): StdioSidecarProtocolClient;
31
+ setSidecarRequestHandler(handler: LiveSidecarRequestHandler | null): void;
32
+ onEvent(handler: (event: LiveEventFrame) => void): () => void;
33
+ sendRequest(input: {
34
+ ownership: LiveOwnershipScope;
35
+ payload: LiveRequestPayload;
36
+ }): Promise<LiveResponseFrame>;
37
+ waitForEvent(matcher: LiveSidecarEventSelector | ((event: LiveEventFrame) => boolean), timeoutMs?: number, options?: {
38
+ signal?: AbortSignal;
39
+ }): Promise<LiveEventFrame>;
40
+ dispose(): Promise<void>;
41
+ failPermanently(error: Error): void;
42
+ }
@@ -0,0 +1,126 @@
1
+ import { resolvePublishedSidecarBinary } from "./binary.js";
2
+ import { SidecarProcessExited, StdioSidecarProcess, } from "./process.js";
3
+ import { SidecarProtocolClient } from "./protocol-client.js";
4
+ import { registerSidecarProcessSpawnFactory } from "./sidecar-process.js";
5
+ export const DEFAULT_SIDECAR_FRAME_TIMEOUT_MS = 120_000;
6
+ export const DEFAULT_SIDECAR_EVENT_BUFFER_CAPACITY = 4_096;
7
+ export const DEFAULT_SIDECAR_GRACEFUL_EXIT_MS = 5_000;
8
+ export const DEFAULT_SIDECAR_FORCE_EXIT_MS = 2_000;
9
+ export class StdioSidecarProtocolClient {
10
+ child;
11
+ sidecarProcess;
12
+ protocolClient;
13
+ gracefulExitMs;
14
+ forceExitMs;
15
+ disposedErrorMessage;
16
+ constructor(sidecarProcess, options) {
17
+ this.sidecarProcess = sidecarProcess;
18
+ this.child = sidecarProcess.child;
19
+ this.gracefulExitMs = options.gracefulExitMs;
20
+ this.forceExitMs = options.forceExitMs;
21
+ this.disposedErrorMessage = options.disposedErrorMessage;
22
+ this.protocolClient = new SidecarProtocolClient({
23
+ stdin: this.child.stdin,
24
+ stdout: this.child.stdout,
25
+ frameTimeoutMs: options.frameTimeoutMs,
26
+ eventBufferCapacity: options.eventBufferCapacity,
27
+ payloadCodec: options.payloadCodec,
28
+ stderrText: () => this.sidecarProcess.stderrText(),
29
+ streamEndedError: () => this.sidecarProcess.currentExitError() ??
30
+ new SidecarProcessExited({
31
+ exitCode: this.child.exitCode,
32
+ signal: this.child.signalCode,
33
+ stderr: this.sidecarProcess.stderrText(),
34
+ }),
35
+ frameError: (error) => this.sidecarProcess.currentExitError() ?? error,
36
+ });
37
+ this.sidecarProcess.onExit((error) => {
38
+ this.failPermanently(error);
39
+ });
40
+ this.sidecarProcess.onError((error) => {
41
+ this.failPermanently(error);
42
+ });
43
+ }
44
+ static spawn(options = {}) {
45
+ return new StdioSidecarProtocolClient(StdioSidecarProcess.spawn({
46
+ command: options.command ?? resolvePublishedSidecarBinary(),
47
+ args: options.args ?? [],
48
+ cwd: options.cwd,
49
+ }), {
50
+ frameTimeoutMs: options.frameTimeoutMs ?? DEFAULT_SIDECAR_FRAME_TIMEOUT_MS,
51
+ eventBufferCapacity: options.eventBufferCapacity ??
52
+ DEFAULT_SIDECAR_EVENT_BUFFER_CAPACITY,
53
+ gracefulExitMs: options.gracefulExitMs ?? DEFAULT_SIDECAR_GRACEFUL_EXIT_MS,
54
+ forceExitMs: options.forceExitMs ?? DEFAULT_SIDECAR_FORCE_EXIT_MS,
55
+ disposedErrorMessage: options.disposedErrorMessage ?? "sidecar client disposed",
56
+ payloadCodec: options.payloadCodec ?? "bare",
57
+ });
58
+ }
59
+ setSidecarRequestHandler(handler) {
60
+ this.protocolClient.setSidecarRequestHandler(handler);
61
+ }
62
+ onEvent(handler) {
63
+ return this.protocolClient.onEvent(handler);
64
+ }
65
+ async sendRequest(input) {
66
+ return await this.protocolClient.sendRequest(input);
67
+ }
68
+ async waitForEvent(matcher, timeoutMs, options) {
69
+ return await this.protocolClient.waitForEvent(matcher, timeoutMs, options);
70
+ }
71
+ async dispose() {
72
+ this.protocolClient.failPermanently(new Error(this.disposedErrorMessage));
73
+ if (!this.child.stdin.destroyed) {
74
+ try {
75
+ this.child.stdin.end();
76
+ }
77
+ catch {
78
+ // Stdin may already be closing. The child exit watcher will catch up.
79
+ }
80
+ }
81
+ const exitCode = await this.sidecarProcess.waitForExit(this.gracefulExitMs);
82
+ if (exitCode === null) {
83
+ try {
84
+ this.child.kill("SIGKILL");
85
+ }
86
+ catch {
87
+ // The child may have exited between the timeout and the kill attempt.
88
+ }
89
+ await this.sidecarProcess.waitForExit(this.forceExitMs);
90
+ }
91
+ this.protocolClient.dispose();
92
+ try {
93
+ this.child.stdin.destroy();
94
+ }
95
+ catch {
96
+ // Best effort. The child is gone so the descriptor will close on its own.
97
+ }
98
+ try {
99
+ this.child.stdout.destroy();
100
+ }
101
+ catch {
102
+ // Best effort. The child is gone so the descriptor will close on its own.
103
+ }
104
+ try {
105
+ this.child.stderr.destroy();
106
+ }
107
+ catch {
108
+ // Best effort. The child is gone so the descriptor will close on its own.
109
+ }
110
+ if (exitCode !== null &&
111
+ exitCode !== 0 &&
112
+ this.child.signalCode === null) {
113
+ throw new Error(`sidecar exited with code ${exitCode}\nstderr:\n${this.sidecarProcess.stderrText()}`);
114
+ }
115
+ }
116
+ failPermanently(error) {
117
+ this.protocolClient.failPermanently(error, {
118
+ replaceExisting: (current, next) => current instanceof SidecarProcessExited &&
119
+ current.exitCode === null &&
120
+ current.signal === null &&
121
+ next instanceof SidecarProcessExited &&
122
+ (next.exitCode !== null || next.signal !== null),
123
+ });
124
+ }
125
+ }
126
+ registerSidecarProcessSpawnFactory((options) => StdioSidecarProtocolClient.spawn(options));
@@ -0,0 +1,117 @@
1
+ import { z } from "zod";
2
+ import type { NodeRuntimeCreateOptions } from "./node-runtime.js";
3
+ export declare const nodeRuntimePermissionsSchema: z.ZodObject<{
4
+ fs: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
5
+ allow: "allow";
6
+ deny: "deny";
7
+ }>, z.ZodObject<{
8
+ default: z.ZodOptional<z.ZodEnum<{
9
+ allow: "allow";
10
+ deny: "deny";
11
+ }>>;
12
+ rules: z.ZodArray<z.ZodObject<{
13
+ mode: z.ZodEnum<{
14
+ allow: "allow";
15
+ deny: "deny";
16
+ }>;
17
+ operations: z.ZodOptional<z.ZodArray<z.ZodString>>;
18
+ paths: z.ZodOptional<z.ZodArray<z.ZodString>>;
19
+ }, z.core.$strict>>;
20
+ }, z.core.$strict>]>>;
21
+ network: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
22
+ allow: "allow";
23
+ deny: "deny";
24
+ }>, z.ZodObject<{
25
+ default: z.ZodOptional<z.ZodEnum<{
26
+ allow: "allow";
27
+ deny: "deny";
28
+ }>>;
29
+ rules: z.ZodArray<z.ZodObject<{
30
+ mode: z.ZodEnum<{
31
+ allow: "allow";
32
+ deny: "deny";
33
+ }>;
34
+ operations: z.ZodOptional<z.ZodArray<z.ZodString>>;
35
+ patterns: z.ZodOptional<z.ZodArray<z.ZodString>>;
36
+ }, z.core.$strict>>;
37
+ }, z.core.$strict>]>>;
38
+ childProcess: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
39
+ allow: "allow";
40
+ deny: "deny";
41
+ }>, z.ZodObject<{
42
+ default: z.ZodOptional<z.ZodEnum<{
43
+ allow: "allow";
44
+ deny: "deny";
45
+ }>>;
46
+ rules: z.ZodArray<z.ZodObject<{
47
+ mode: z.ZodEnum<{
48
+ allow: "allow";
49
+ deny: "deny";
50
+ }>;
51
+ operations: z.ZodOptional<z.ZodArray<z.ZodString>>;
52
+ patterns: z.ZodOptional<z.ZodArray<z.ZodString>>;
53
+ }, z.core.$strict>>;
54
+ }, z.core.$strict>]>>;
55
+ process: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
56
+ allow: "allow";
57
+ deny: "deny";
58
+ }>, z.ZodObject<{
59
+ default: z.ZodOptional<z.ZodEnum<{
60
+ allow: "allow";
61
+ deny: "deny";
62
+ }>>;
63
+ rules: z.ZodArray<z.ZodObject<{
64
+ mode: z.ZodEnum<{
65
+ allow: "allow";
66
+ deny: "deny";
67
+ }>;
68
+ operations: z.ZodOptional<z.ZodArray<z.ZodString>>;
69
+ patterns: z.ZodOptional<z.ZodArray<z.ZodString>>;
70
+ }, z.core.$strict>>;
71
+ }, z.core.$strict>]>>;
72
+ env: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
73
+ allow: "allow";
74
+ deny: "deny";
75
+ }>, z.ZodObject<{
76
+ default: z.ZodOptional<z.ZodEnum<{
77
+ allow: "allow";
78
+ deny: "deny";
79
+ }>>;
80
+ rules: z.ZodArray<z.ZodObject<{
81
+ mode: z.ZodEnum<{
82
+ allow: "allow";
83
+ deny: "deny";
84
+ }>;
85
+ operations: z.ZodOptional<z.ZodArray<z.ZodString>>;
86
+ patterns: z.ZodOptional<z.ZodArray<z.ZodString>>;
87
+ }, z.core.$strict>>;
88
+ }, z.core.$strict>]>>;
89
+ binding: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
90
+ allow: "allow";
91
+ deny: "deny";
92
+ }>, z.ZodObject<{
93
+ default: z.ZodOptional<z.ZodEnum<{
94
+ allow: "allow";
95
+ deny: "deny";
96
+ }>>;
97
+ rules: z.ZodArray<z.ZodObject<{
98
+ mode: z.ZodEnum<{
99
+ allow: "allow";
100
+ deny: "deny";
101
+ }>;
102
+ operations: z.ZodOptional<z.ZodArray<z.ZodString>>;
103
+ patterns: z.ZodOptional<z.ZodArray<z.ZodString>>;
104
+ }, z.core.$strict>>;
105
+ }, z.core.$strict>]>>;
106
+ }, z.core.$strict>;
107
+ /**
108
+ * Runtime validation for the public `NodeRuntime.create(...)` API.
109
+ *
110
+ * This is the TS-side guard for the ergonomic options shape. The sidecar VM
111
+ * JSON it eventually produces is still validated by
112
+ * `crates/vm-config/src/lib.rs::CreateVmConfig` with `deny_unknown_fields`.
113
+ * Keep these in sync when adding high-level create options that translate into
114
+ * the Rust VM config.
115
+ */
116
+ export declare const nodeRuntimeCreateOptionsSchema: z.ZodType<NodeRuntimeCreateOptions>;
117
+ export declare function parseNodeRuntimeCreateOptions(options?: NodeRuntimeCreateOptions): NodeRuntimeCreateOptions;
@@ -0,0 +1,121 @@
1
+ import { z } from "zod";
2
+ const permissionModeSchema = z.enum(["allow", "deny"]);
3
+ const stringArray = z.array(z.string());
4
+ const fsPermissionRuleSchema = z
5
+ .object({
6
+ mode: permissionModeSchema,
7
+ operations: stringArray.optional(),
8
+ paths: stringArray.optional(),
9
+ })
10
+ .strict();
11
+ const patternPermissionRuleSchema = z
12
+ .object({
13
+ mode: permissionModeSchema,
14
+ operations: stringArray.optional(),
15
+ patterns: stringArray.optional(),
16
+ })
17
+ .strict();
18
+ const fsRulePermissionsSchema = z
19
+ .object({
20
+ default: permissionModeSchema.optional(),
21
+ rules: z.array(fsPermissionRuleSchema),
22
+ })
23
+ .strict();
24
+ const patternRulePermissionsSchema = z
25
+ .object({
26
+ default: permissionModeSchema.optional(),
27
+ rules: z.array(patternPermissionRuleSchema),
28
+ })
29
+ .strict();
30
+ const fsPermissionsSchema = z.union([permissionModeSchema, fsRulePermissionsSchema]);
31
+ const patternPermissionsSchema = z.union([
32
+ permissionModeSchema,
33
+ patternRulePermissionsSchema,
34
+ ]);
35
+ export const nodeRuntimePermissionsSchema = z
36
+ .object({
37
+ fs: fsPermissionsSchema.optional(),
38
+ network: patternPermissionsSchema.optional(),
39
+ childProcess: patternPermissionsSchema.optional(),
40
+ process: patternPermissionsSchema.optional(),
41
+ env: patternPermissionsSchema.optional(),
42
+ binding: patternPermissionsSchema.optional(),
43
+ })
44
+ .strict();
45
+ const uint8ArraySchema = z.custom((value) => value instanceof Uint8Array, { message: "Expected Uint8Array" });
46
+ const hostDirectoryMountSchema = z
47
+ .object({
48
+ guestPath: z.string(),
49
+ hostPath: z.string(),
50
+ readOnly: z.boolean().optional(),
51
+ })
52
+ .strict();
53
+ const nodeModulesMountSchema = z
54
+ .object({
55
+ hostPath: z.string(),
56
+ guestPath: z.string().optional(),
57
+ })
58
+ .strict();
59
+ const jsRuntimeSchema = z
60
+ .object({
61
+ platform: z.enum(["node", "browser", "neutral", "bare"]).optional(),
62
+ moduleResolution: z.enum(["node", "relative", "none"]).optional(),
63
+ allowedBuiltins: stringArray.optional(),
64
+ highResolutionTime: z.boolean().optional(),
65
+ })
66
+ .strict();
67
+ const bindingExampleSchema = z
68
+ .object({
69
+ description: z.string(),
70
+ input: z.unknown(),
71
+ })
72
+ .strict();
73
+ const bindingDefinitionSchema = z
74
+ .object({
75
+ description: z.string(),
76
+ inputSchema: z.custom((value) => typeof value === "object" && value !== null, { message: "Expected JSON Schema object" }),
77
+ timeoutMs: z.number().int().nonnegative().optional(),
78
+ examples: z.array(bindingExampleSchema).optional(),
79
+ commandAliases: stringArray.optional(),
80
+ handler: z.custom((value) => typeof value === "function", { message: "Expected function" }),
81
+ })
82
+ .strict();
83
+ /**
84
+ * Runtime validation for the public `NodeRuntime.create(...)` API.
85
+ *
86
+ * This is the TS-side guard for the ergonomic options shape. The sidecar VM
87
+ * JSON it eventually produces is still validated by
88
+ * `crates/vm-config/src/lib.rs::CreateVmConfig` with `deny_unknown_fields`.
89
+ * Keep these in sync when adding high-level create options that translate into
90
+ * the Rust VM config.
91
+ */
92
+ export const nodeRuntimeCreateOptionsSchema = z
93
+ .object({
94
+ env: z.record(z.string(), z.string()).optional(),
95
+ cwd: z.string().optional(),
96
+ permissions: nodeRuntimePermissionsSchema.optional(),
97
+ commandsDir: z.string().optional(),
98
+ wasmCommandDirs: stringArray.optional(),
99
+ sidecar: z
100
+ .custom((value) => typeof value === "object" && value !== null, {
101
+ message: "Expected SidecarProcess object",
102
+ })
103
+ .optional(),
104
+ onBootTiming: z
105
+ .custom((value) => typeof value === "function", { message: "Expected function" })
106
+ .optional(),
107
+ files: z
108
+ .record(z.string(), z.union([z.string(), uint8ArraySchema]))
109
+ .optional(),
110
+ mounts: z.array(hostDirectoryMountSchema).optional(),
111
+ nodeModules: z.union([z.string(), nodeModulesMountSchema]).optional(),
112
+ bindings: z.record(z.string(), bindingDefinitionSchema).optional(),
113
+ loopbackExemptPorts: z
114
+ .array(z.number().int().min(0).max(65535))
115
+ .optional(),
116
+ jsRuntime: jsRuntimeSchema.optional(),
117
+ })
118
+ .strict();
119
+ export function parseNodeRuntimeCreateOptions(options = {}) {
120
+ return nodeRuntimeCreateOptionsSchema.parse(options);
121
+ }