@secure-exec/core 0.0.0-main.bccb3a2

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 (271) 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/expand +0 -0
  38. package/commands/expr +0 -0
  39. package/commands/factor +0 -0
  40. package/commands/false +0 -0
  41. package/commands/fd +0 -0
  42. package/commands/fgrep +0 -0
  43. package/commands/file +0 -0
  44. package/commands/find +0 -0
  45. package/commands/fmt +0 -0
  46. package/commands/fold +0 -0
  47. package/commands/git +0 -0
  48. package/commands/grep +0 -0
  49. package/commands/groups +0 -0
  50. package/commands/gunzip +0 -0
  51. package/commands/gzip +0 -0
  52. package/commands/head +0 -0
  53. package/commands/hostid +0 -0
  54. package/commands/hostname +0 -0
  55. package/commands/http-test +0 -0
  56. package/commands/id +0 -0
  57. package/commands/install +0 -0
  58. package/commands/join +0 -0
  59. package/commands/jq +0 -0
  60. package/commands/kill +0 -0
  61. package/commands/link +0 -0
  62. package/commands/ln +0 -0
  63. package/commands/logname +0 -0
  64. package/commands/ls +0 -0
  65. package/commands/md5sum +0 -0
  66. package/commands/mkdir +0 -0
  67. package/commands/mkfifo +0 -0
  68. package/commands/mknod +0 -0
  69. package/commands/mktemp +0 -0
  70. package/commands/more +0 -0
  71. package/commands/mv +0 -0
  72. package/commands/nice +0 -0
  73. package/commands/nl +0 -0
  74. package/commands/nohup +0 -0
  75. package/commands/nproc +0 -0
  76. package/commands/numfmt +0 -0
  77. package/commands/od +0 -0
  78. package/commands/paste +0 -0
  79. package/commands/pathchk +0 -0
  80. package/commands/pinky +0 -0
  81. package/commands/printenv +0 -0
  82. package/commands/printf +0 -0
  83. package/commands/ptx +0 -0
  84. package/commands/pwd +0 -0
  85. package/commands/readlink +0 -0
  86. package/commands/realpath +0 -0
  87. package/commands/rev +0 -0
  88. package/commands/rg +0 -0
  89. package/commands/rm +0 -0
  90. package/commands/rmdir +0 -0
  91. package/commands/runcon +0 -0
  92. package/commands/sed +0 -0
  93. package/commands/seq +0 -0
  94. package/commands/sh +0 -0
  95. package/commands/sha1sum +0 -0
  96. package/commands/sha224sum +0 -0
  97. package/commands/sha256sum +0 -0
  98. package/commands/sha384sum +0 -0
  99. package/commands/sha512sum +0 -0
  100. package/commands/shred +0 -0
  101. package/commands/shuf +0 -0
  102. package/commands/sleep +0 -0
  103. package/commands/sort +0 -0
  104. package/commands/spawn-test-host +0 -0
  105. package/commands/split +0 -0
  106. package/commands/stat +0 -0
  107. package/commands/stdbuf +0 -0
  108. package/commands/strings +0 -0
  109. package/commands/stty +0 -0
  110. package/commands/sum +0 -0
  111. package/commands/sync +0 -0
  112. package/commands/tac +0 -0
  113. package/commands/tail +0 -0
  114. package/commands/tar +0 -0
  115. package/commands/tee +0 -0
  116. package/commands/test +0 -0
  117. package/commands/timeout +0 -0
  118. package/commands/touch +0 -0
  119. package/commands/tr +0 -0
  120. package/commands/tree +0 -0
  121. package/commands/true +0 -0
  122. package/commands/truncate +0 -0
  123. package/commands/tsort +0 -0
  124. package/commands/tty +0 -0
  125. package/commands/uname +0 -0
  126. package/commands/unexpand +0 -0
  127. package/commands/uniq +0 -0
  128. package/commands/unlink +0 -0
  129. package/commands/uptime +0 -0
  130. package/commands/users +0 -0
  131. package/commands/vdir +0 -0
  132. package/commands/wc +0 -0
  133. package/commands/which +0 -0
  134. package/commands/who +0 -0
  135. package/commands/whoami +0 -0
  136. package/commands/xargs +0 -0
  137. package/commands/xu +0 -0
  138. package/commands/yes +0 -0
  139. package/commands/yq +0 -0
  140. package/commands/zcat +0 -0
  141. package/dist/binary.d.ts +4 -0
  142. package/dist/binary.js +25 -0
  143. package/dist/bytes.d.ts +2 -0
  144. package/dist/bytes.js +6 -0
  145. package/dist/callbacks.d.ts +41 -0
  146. package/dist/callbacks.js +94 -0
  147. package/dist/cargo.d.ts +2 -0
  148. package/dist/cargo.js +142 -0
  149. package/dist/correlation.d.ts +10 -0
  150. package/dist/correlation.js +49 -0
  151. package/dist/descriptors.d.ts +34 -0
  152. package/dist/descriptors.js +37 -0
  153. package/dist/event-buffer.d.ts +90 -0
  154. package/dist/event-buffer.js +313 -0
  155. package/dist/ext.d.ts +7 -0
  156. package/dist/ext.js +13 -0
  157. package/dist/filesystem.d.ts +41 -0
  158. package/dist/filesystem.js +70 -0
  159. package/dist/frame-payload-codec.d.ts +8 -0
  160. package/dist/frame-payload-codec.js +14 -0
  161. package/dist/frame-rpc.d.ts +38 -0
  162. package/dist/frame-rpc.js +73 -0
  163. package/dist/frame-stream.d.ts +27 -0
  164. package/dist/frame-stream.js +99 -0
  165. package/dist/framing.d.ts +7 -0
  166. package/dist/framing.js +22 -0
  167. package/dist/generated/AcpLimitsConfig.d.ts +4 -0
  168. package/dist/generated/AcpLimitsConfig.js +2 -0
  169. package/dist/generated/CreateVmConfig.d.ts +19 -0
  170. package/dist/generated/CreateVmConfig.js +1 -0
  171. package/dist/generated/FsPermissionRule.d.ts +6 -0
  172. package/dist/generated/FsPermissionRule.js +1 -0
  173. package/dist/generated/FsPermissionRuleSet.d.ts +6 -0
  174. package/dist/generated/FsPermissionRuleSet.js +1 -0
  175. package/dist/generated/FsPermissionScope.d.ts +3 -0
  176. package/dist/generated/FsPermissionScope.js +1 -0
  177. package/dist/generated/HttpLimitsConfig.d.ts +3 -0
  178. package/dist/generated/HttpLimitsConfig.js +2 -0
  179. package/dist/generated/JsModuleResolution.d.ts +1 -0
  180. package/dist/generated/JsModuleResolution.js +2 -0
  181. package/dist/generated/JsRuntimeConfig.d.ts +26 -0
  182. package/dist/generated/JsRuntimeConfig.js +1 -0
  183. package/dist/generated/JsRuntimeLimitsConfig.d.ts +8 -0
  184. package/dist/generated/JsRuntimeLimitsConfig.js +2 -0
  185. package/dist/generated/JsRuntimePlatform.d.ts +1 -0
  186. package/dist/generated/JsRuntimePlatform.js +2 -0
  187. package/dist/generated/MountPluginDescriptor.d.ts +4 -0
  188. package/dist/generated/MountPluginDescriptor.js +2 -0
  189. package/dist/generated/NativeRootFilesystemConfig.d.ts +5 -0
  190. package/dist/generated/NativeRootFilesystemConfig.js +1 -0
  191. package/dist/generated/PatternPermissionRule.d.ts +6 -0
  192. package/dist/generated/PatternPermissionRule.js +1 -0
  193. package/dist/generated/PatternPermissionRuleSet.d.ts +6 -0
  194. package/dist/generated/PatternPermissionRuleSet.js +1 -0
  195. package/dist/generated/PatternPermissionScope.d.ts +3 -0
  196. package/dist/generated/PatternPermissionScope.js +1 -0
  197. package/dist/generated/PermissionMode.d.ts +1 -0
  198. package/dist/generated/PermissionMode.js +2 -0
  199. package/dist/generated/PermissionsPolicy.d.ts +10 -0
  200. package/dist/generated/PermissionsPolicy.js +1 -0
  201. package/dist/generated/PluginLimitsConfig.d.ts +4 -0
  202. package/dist/generated/PluginLimitsConfig.js +2 -0
  203. package/dist/generated/PythonLimitsConfig.d.ts +6 -0
  204. package/dist/generated/PythonLimitsConfig.js +2 -0
  205. package/dist/generated/ResourceLimitsConfig.d.ts +22 -0
  206. package/dist/generated/ResourceLimitsConfig.js +2 -0
  207. package/dist/generated/RootFilesystemConfig.d.ts +9 -0
  208. package/dist/generated/RootFilesystemConfig.js +1 -0
  209. package/dist/generated/RootFilesystemEntry.d.ts +13 -0
  210. package/dist/generated/RootFilesystemEntry.js +1 -0
  211. package/dist/generated/RootFilesystemEntryEncoding.d.ts +1 -0
  212. package/dist/generated/RootFilesystemEntryEncoding.js +2 -0
  213. package/dist/generated/RootFilesystemEntryKind.d.ts +1 -0
  214. package/dist/generated/RootFilesystemEntryKind.js +2 -0
  215. package/dist/generated/RootFilesystemLowerDescriptor.d.ts +7 -0
  216. package/dist/generated/RootFilesystemLowerDescriptor.js +1 -0
  217. package/dist/generated/RootFilesystemMode.d.ts +1 -0
  218. package/dist/generated/RootFilesystemMode.js +2 -0
  219. package/dist/generated/ToolLimitsConfig.d.ts +10 -0
  220. package/dist/generated/ToolLimitsConfig.js +2 -0
  221. package/dist/generated/VmDnsConfig.d.ts +6 -0
  222. package/dist/generated/VmDnsConfig.js +2 -0
  223. package/dist/generated/VmLimitsConfig.d.ts +18 -0
  224. package/dist/generated/VmLimitsConfig.js +1 -0
  225. package/dist/generated/VmListenPolicyConfig.d.ts +5 -0
  226. package/dist/generated/VmListenPolicyConfig.js +2 -0
  227. package/dist/generated/WasmLimitsConfig.d.ts +5 -0
  228. package/dist/generated/WasmLimitsConfig.js +2 -0
  229. package/dist/generated-protocol.d.ts +1037 -0
  230. package/dist/generated-protocol.js +2887 -0
  231. package/dist/index.d.ts +26 -0
  232. package/dist/index.js +25 -0
  233. package/dist/json.d.ts +2 -0
  234. package/dist/json.js +20 -0
  235. package/dist/kernel-proxy.d.ts +151 -0
  236. package/dist/kernel-proxy.js +1737 -0
  237. package/dist/native-client.d.ts +41 -0
  238. package/dist/native-client.js +124 -0
  239. package/dist/node-runtime.d.ts +516 -0
  240. package/dist/node-runtime.js +794 -0
  241. package/dist/numbers.d.ts +1 -0
  242. package/dist/numbers.js +8 -0
  243. package/dist/ownership.d.ts +18 -0
  244. package/dist/ownership.js +77 -0
  245. package/dist/permissions.d.ts +29 -0
  246. package/dist/permissions.js +68 -0
  247. package/dist/process.d.ts +35 -0
  248. package/dist/process.js +125 -0
  249. package/dist/protocol-client.d.ts +46 -0
  250. package/dist/protocol-client.js +180 -0
  251. package/dist/protocol-frames.d.ts +68 -0
  252. package/dist/protocol-frames.js +139 -0
  253. package/dist/protocol-maps.d.ts +28 -0
  254. package/dist/protocol-maps.js +217 -0
  255. package/dist/protocol-schema.d.ts +10 -0
  256. package/dist/protocol-schema.js +11 -0
  257. package/dist/request-payloads.d.ts +137 -0
  258. package/dist/request-payloads.js +210 -0
  259. package/dist/response-payloads.d.ts +107 -0
  260. package/dist/response-payloads.js +161 -0
  261. package/dist/sidecar-client.d.ts +242 -0
  262. package/dist/sidecar-client.js +797 -0
  263. package/dist/state.d.ts +40 -0
  264. package/dist/state.js +44 -0
  265. package/dist/test-runtime.d.ts +534 -0
  266. package/dist/test-runtime.js +2146 -0
  267. package/dist/vm-config.d.ts +31 -0
  268. package/dist/vm-config.js +1 -0
  269. package/fixtures/alpine-defaults.json +520 -0
  270. package/fixtures/base-filesystem.json +528 -0
  271. package/package.json +197 -0
@@ -0,0 +1,139 @@
1
+ import { toExactUint8Array } from "./bytes.js";
2
+ import { decodeJsonFramePayload, encodeJsonFramePayload, } from "./frame-payload-codec.js";
3
+ import { errorSidecarResponsePayload, fromGeneratedSidecarRequestPayload, isMatchingSidecarResponsePayload, toGeneratedSidecarResponsePayload, } from "./callbacks.js";
4
+ import { fromGeneratedEventPayload, } from "./event-buffer.js";
5
+ import * as protocol from "./generated-protocol.js";
6
+ import { bigIntToSafeNumber } from "./numbers.js";
7
+ import { fromGeneratedOwnershipScope, toGeneratedOwnershipScope, } from "./ownership.js";
8
+ import { SIDECAR_PROTOCOL_SCHEMA, validateSidecarProtocolSchema, } from "./protocol-schema.js";
9
+ import { toGeneratedRequestPayload, } from "./request-payloads.js";
10
+ import { fromGeneratedResponsePayload, } from "./response-payloads.js";
11
+ export class HostProtocolFrameFactory {
12
+ nextRequestId = 1;
13
+ createRequestFrame(input) {
14
+ return {
15
+ frame_type: "request",
16
+ schema: SIDECAR_PROTOCOL_SCHEMA,
17
+ request_id: this.nextRequestId++,
18
+ ownership: input.ownership,
19
+ payload: input.payload,
20
+ };
21
+ }
22
+ createSidecarResponseFrame(input) {
23
+ return {
24
+ frame_type: "sidecar_response",
25
+ schema: SIDECAR_PROTOCOL_SCHEMA,
26
+ request_id: input.request.request_id,
27
+ ownership: input.request.ownership,
28
+ payload: input.payload,
29
+ };
30
+ }
31
+ }
32
+ export async function resolveSidecarRequestFramePayload(request, handler) {
33
+ try {
34
+ if (!handler) {
35
+ throw new Error(`no sidecar request handler registered for ${request.payload.type}`);
36
+ }
37
+ const payload = await handler(request);
38
+ if (!isMatchingSidecarResponsePayload(request.payload, payload)) {
39
+ throw new Error(`sidecar handler returned ${payload.type} for ${request.payload.type}`);
40
+ }
41
+ return payload;
42
+ }
43
+ catch (error) {
44
+ return errorSidecarResponsePayload(request.payload, error);
45
+ }
46
+ }
47
+ export function toGeneratedProtocolFrame(frame) {
48
+ switch (frame.frame_type) {
49
+ case "request":
50
+ return {
51
+ tag: "RequestFrame",
52
+ val: {
53
+ schema: frame.schema,
54
+ requestId: BigInt(frame.request_id),
55
+ ownership: toGeneratedOwnershipScope(frame.ownership),
56
+ payload: toGeneratedRequestPayload(frame.payload),
57
+ },
58
+ };
59
+ case "sidecar_response":
60
+ return {
61
+ tag: "SidecarResponseFrame",
62
+ val: {
63
+ schema: frame.schema,
64
+ requestId: BigInt(frame.request_id),
65
+ ownership: toGeneratedOwnershipScope(frame.ownership),
66
+ payload: toGeneratedSidecarResponsePayload(frame.payload),
67
+ },
68
+ };
69
+ case "response":
70
+ case "event":
71
+ case "sidecar_request":
72
+ throw new Error(`BARE encoding is only implemented for host-written frames, received ${frame.frame_type}`);
73
+ }
74
+ }
75
+ export function encodeBareProtocolFrame(frame) {
76
+ return Buffer.from(protocol.encodeProtocolFrame(toGeneratedProtocolFrame(frame)));
77
+ }
78
+ export function decodeBareProtocolFrame(payload) {
79
+ return fromGeneratedSidecarWrittenProtocolFrame(protocol.decodeProtocolFrame(toExactUint8Array(payload)));
80
+ }
81
+ export function encodeProtocolFramePayload(frame, codec) {
82
+ if (codec === "json") {
83
+ return encodeJsonFramePayload(frame);
84
+ }
85
+ return encodeBareProtocolFrame(frame);
86
+ }
87
+ export function decodeProtocolFramePayload(payload, codec) {
88
+ if (codec === "json") {
89
+ return decodeJsonFramePayload(payload);
90
+ }
91
+ return decodeBareProtocolFrame(payload);
92
+ }
93
+ export function classifySidecarWrittenProtocolFrame(frame) {
94
+ switch (frame.frame_type) {
95
+ case "response":
96
+ return {
97
+ kind: "response",
98
+ requestId: frame.request_id,
99
+ frame,
100
+ };
101
+ case "event":
102
+ return { kind: "event", frame };
103
+ case "sidecar_request":
104
+ return { kind: "sidecarRequest", frame };
105
+ }
106
+ }
107
+ export function fromGeneratedSidecarWrittenProtocolFrame(frame) {
108
+ switch (frame.tag) {
109
+ case "ResponseFrame":
110
+ return {
111
+ frame_type: "response",
112
+ schema: toLiveProtocolSchema(frame.val.schema),
113
+ request_id: bigIntToSafeNumber(frame.val.requestId, "response request id"),
114
+ ownership: fromGeneratedOwnershipScope(frame.val.ownership),
115
+ payload: fromGeneratedResponsePayload(frame.val.payload),
116
+ };
117
+ case "EventFrame":
118
+ return {
119
+ frame_type: "event",
120
+ schema: toLiveProtocolSchema(frame.val.schema),
121
+ ownership: fromGeneratedOwnershipScope(frame.val.ownership),
122
+ payload: fromGeneratedEventPayload(frame.val.payload),
123
+ };
124
+ case "SidecarRequestFrame":
125
+ return {
126
+ frame_type: "sidecar_request",
127
+ schema: toLiveProtocolSchema(frame.val.schema),
128
+ request_id: bigIntToSafeNumber(frame.val.requestId, "sidecar request id"),
129
+ ownership: fromGeneratedOwnershipScope(frame.val.ownership),
130
+ payload: fromGeneratedSidecarRequestPayload(frame.val.payload),
131
+ };
132
+ case "RequestFrame":
133
+ case "SidecarResponseFrame":
134
+ throw new Error(`unsupported BARE protocol frame tag: ${frame.tag}`);
135
+ }
136
+ }
137
+ export function toLiveProtocolSchema(schema) {
138
+ return validateSidecarProtocolSchema(schema);
139
+ }
@@ -0,0 +1,28 @@
1
+ import * as protocol from "./generated-protocol.js";
2
+ export type LiveGuestRuntimeKind = "java_script" | "python" | "web_assembly";
3
+ export type LiveDisposeReason = "requested" | "connection_closed" | "host_shutdown";
4
+ export type LiveRootFilesystemMode = "ephemeral" | "read_only";
5
+ export type LiveRootFilesystemEntryKind = "file" | "directory" | "symlink";
6
+ export type LiveRootFilesystemEntryEncoding = "utf8" | "base64";
7
+ export type LiveWasmPermissionTier = "full" | "read-write" | "read-only" | "isolated";
8
+ export type LivePermissionMode = "allow" | "ask" | "deny";
9
+ export type LiveGuestFilesystemOperation = "read_file" | "write_file" | "create_dir" | "mkdir" | "exists" | "stat" | "lstat" | "read_dir" | "remove_file" | "remove_dir" | "rename" | "realpath" | "symlink" | "read_link" | "link" | "chmod" | "chown" | "utimes" | "truncate" | "pread";
10
+ export type LiveVmLifecycleState = "creating" | "ready" | "disposing" | "disposed" | "failed";
11
+ export type LiveStreamChannel = "stdout" | "stderr";
12
+ export type LiveProcessSnapshotStatus = "running" | "exited" | "stopped";
13
+ export type LiveSignalDispositionAction = "default" | "ignore" | "user";
14
+ export declare function toGeneratedPermissionMode(mode: LivePermissionMode): protocol.PermissionMode;
15
+ export declare function toGeneratedGuestRuntimeKind(runtime: LiveGuestRuntimeKind): protocol.GuestRuntimeKind;
16
+ export declare function toGeneratedDisposeReason(reason: LiveDisposeReason): protocol.DisposeReason;
17
+ export declare function toGeneratedRootFilesystemMode(mode: LiveRootFilesystemMode): protocol.RootFilesystemMode;
18
+ export declare function toGeneratedRootFilesystemEntryKind(kind: LiveRootFilesystemEntryKind): protocol.RootFilesystemEntryKind;
19
+ export declare function toGeneratedRootFilesystemEntryEncoding(encoding: LiveRootFilesystemEntryEncoding): protocol.RootFilesystemEntryEncoding;
20
+ export declare function toGeneratedWasmPermissionTier(tier: LiveWasmPermissionTier): protocol.WasmPermissionTier;
21
+ export declare function toGeneratedGuestFilesystemOperation(operation: LiveGuestFilesystemOperation): protocol.GuestFilesystemOperation;
22
+ export declare function fromGeneratedVmLifecycleState(state: protocol.VmLifecycleState): LiveVmLifecycleState;
23
+ export declare function fromGeneratedStreamChannel(channel: protocol.StreamChannel): LiveStreamChannel;
24
+ export declare function fromGeneratedProcessSnapshotStatus(status: protocol.ProcessSnapshotStatus): LiveProcessSnapshotStatus;
25
+ export declare function fromGeneratedSignalDispositionAction(action: protocol.SignalDispositionAction): LiveSignalDispositionAction;
26
+ export declare function fromGeneratedRootFilesystemEntryKind(kind: protocol.RootFilesystemEntryKind): LiveRootFilesystemEntryKind;
27
+ export declare function fromGeneratedRootFilesystemEntryEncoding(encoding: protocol.RootFilesystemEntryEncoding): LiveRootFilesystemEntryEncoding;
28
+ export declare function fromGeneratedGuestFilesystemOperation(operation: protocol.GuestFilesystemOperation): LiveGuestFilesystemOperation;
@@ -0,0 +1,217 @@
1
+ import * as protocol from "./generated-protocol.js";
2
+ export function toGeneratedPermissionMode(mode) {
3
+ switch (mode) {
4
+ case "allow":
5
+ return protocol.PermissionMode.Allow;
6
+ case "ask":
7
+ return protocol.PermissionMode.Ask;
8
+ case "deny":
9
+ return protocol.PermissionMode.Deny;
10
+ }
11
+ }
12
+ export function toGeneratedGuestRuntimeKind(runtime) {
13
+ switch (runtime) {
14
+ case "java_script":
15
+ return protocol.GuestRuntimeKind.JavaScript;
16
+ case "python":
17
+ return protocol.GuestRuntimeKind.Python;
18
+ case "web_assembly":
19
+ return protocol.GuestRuntimeKind.WebAssembly;
20
+ }
21
+ }
22
+ export function toGeneratedDisposeReason(reason) {
23
+ switch (reason) {
24
+ case "requested":
25
+ return protocol.DisposeReason.Requested;
26
+ case "connection_closed":
27
+ return protocol.DisposeReason.ConnectionClosed;
28
+ case "host_shutdown":
29
+ return protocol.DisposeReason.HostShutdown;
30
+ }
31
+ }
32
+ export function toGeneratedRootFilesystemMode(mode) {
33
+ switch (mode) {
34
+ case "ephemeral":
35
+ return protocol.RootFilesystemMode.Ephemeral;
36
+ case "read_only":
37
+ return protocol.RootFilesystemMode.ReadOnly;
38
+ }
39
+ }
40
+ export function toGeneratedRootFilesystemEntryKind(kind) {
41
+ switch (kind) {
42
+ case "file":
43
+ return protocol.RootFilesystemEntryKind.File;
44
+ case "directory":
45
+ return protocol.RootFilesystemEntryKind.Directory;
46
+ case "symlink":
47
+ return protocol.RootFilesystemEntryKind.Symlink;
48
+ }
49
+ }
50
+ export function toGeneratedRootFilesystemEntryEncoding(encoding) {
51
+ switch (encoding) {
52
+ case "utf8":
53
+ return protocol.RootFilesystemEntryEncoding.UtF8;
54
+ case "base64":
55
+ return protocol.RootFilesystemEntryEncoding.BasE64;
56
+ }
57
+ }
58
+ export function toGeneratedWasmPermissionTier(tier) {
59
+ switch (tier) {
60
+ case "full":
61
+ return protocol.WasmPermissionTier.Full;
62
+ case "read-write":
63
+ return protocol.WasmPermissionTier.ReadWrite;
64
+ case "read-only":
65
+ return protocol.WasmPermissionTier.ReadOnly;
66
+ case "isolated":
67
+ return protocol.WasmPermissionTier.Isolated;
68
+ }
69
+ }
70
+ export function toGeneratedGuestFilesystemOperation(operation) {
71
+ switch (operation) {
72
+ case "read_file":
73
+ return protocol.GuestFilesystemOperation.ReadFile;
74
+ case "write_file":
75
+ return protocol.GuestFilesystemOperation.WriteFile;
76
+ case "create_dir":
77
+ return protocol.GuestFilesystemOperation.CreateDir;
78
+ case "mkdir":
79
+ return protocol.GuestFilesystemOperation.Mkdir;
80
+ case "exists":
81
+ return protocol.GuestFilesystemOperation.Exists;
82
+ case "stat":
83
+ return protocol.GuestFilesystemOperation.Stat;
84
+ case "lstat":
85
+ return protocol.GuestFilesystemOperation.Lstat;
86
+ case "read_dir":
87
+ return protocol.GuestFilesystemOperation.ReadDir;
88
+ case "remove_file":
89
+ return protocol.GuestFilesystemOperation.RemoveFile;
90
+ case "remove_dir":
91
+ return protocol.GuestFilesystemOperation.RemoveDir;
92
+ case "rename":
93
+ return protocol.GuestFilesystemOperation.Rename;
94
+ case "realpath":
95
+ return protocol.GuestFilesystemOperation.Realpath;
96
+ case "symlink":
97
+ return protocol.GuestFilesystemOperation.Symlink;
98
+ case "read_link":
99
+ return protocol.GuestFilesystemOperation.ReadLink;
100
+ case "link":
101
+ return protocol.GuestFilesystemOperation.Link;
102
+ case "chmod":
103
+ return protocol.GuestFilesystemOperation.Chmod;
104
+ case "chown":
105
+ return protocol.GuestFilesystemOperation.Chown;
106
+ case "utimes":
107
+ return protocol.GuestFilesystemOperation.Utimes;
108
+ case "truncate":
109
+ return protocol.GuestFilesystemOperation.Truncate;
110
+ case "pread":
111
+ return protocol.GuestFilesystemOperation.Pread;
112
+ }
113
+ }
114
+ export function fromGeneratedVmLifecycleState(state) {
115
+ switch (state) {
116
+ case protocol.VmLifecycleState.Creating:
117
+ return "creating";
118
+ case protocol.VmLifecycleState.Ready:
119
+ return "ready";
120
+ case protocol.VmLifecycleState.Disposing:
121
+ return "disposing";
122
+ case protocol.VmLifecycleState.Disposed:
123
+ return "disposed";
124
+ case protocol.VmLifecycleState.Failed:
125
+ return "failed";
126
+ }
127
+ }
128
+ export function fromGeneratedStreamChannel(channel) {
129
+ switch (channel) {
130
+ case protocol.StreamChannel.Stdout:
131
+ return "stdout";
132
+ case protocol.StreamChannel.Stderr:
133
+ return "stderr";
134
+ }
135
+ }
136
+ export function fromGeneratedProcessSnapshotStatus(status) {
137
+ switch (status) {
138
+ case protocol.ProcessSnapshotStatus.Running:
139
+ return "running";
140
+ case protocol.ProcessSnapshotStatus.Exited:
141
+ return "exited";
142
+ case protocol.ProcessSnapshotStatus.Stopped:
143
+ return "stopped";
144
+ }
145
+ }
146
+ export function fromGeneratedSignalDispositionAction(action) {
147
+ switch (action) {
148
+ case protocol.SignalDispositionAction.Default:
149
+ return "default";
150
+ case protocol.SignalDispositionAction.Ignore:
151
+ return "ignore";
152
+ case protocol.SignalDispositionAction.User:
153
+ return "user";
154
+ }
155
+ }
156
+ export function fromGeneratedRootFilesystemEntryKind(kind) {
157
+ switch (kind) {
158
+ case protocol.RootFilesystemEntryKind.File:
159
+ return "file";
160
+ case protocol.RootFilesystemEntryKind.Directory:
161
+ return "directory";
162
+ case protocol.RootFilesystemEntryKind.Symlink:
163
+ return "symlink";
164
+ }
165
+ }
166
+ export function fromGeneratedRootFilesystemEntryEncoding(encoding) {
167
+ switch (encoding) {
168
+ case protocol.RootFilesystemEntryEncoding.UtF8:
169
+ return "utf8";
170
+ case protocol.RootFilesystemEntryEncoding.BasE64:
171
+ return "base64";
172
+ }
173
+ }
174
+ export function fromGeneratedGuestFilesystemOperation(operation) {
175
+ switch (operation) {
176
+ case protocol.GuestFilesystemOperation.ReadFile:
177
+ return "read_file";
178
+ case protocol.GuestFilesystemOperation.WriteFile:
179
+ return "write_file";
180
+ case protocol.GuestFilesystemOperation.CreateDir:
181
+ return "create_dir";
182
+ case protocol.GuestFilesystemOperation.Mkdir:
183
+ return "mkdir";
184
+ case protocol.GuestFilesystemOperation.Exists:
185
+ return "exists";
186
+ case protocol.GuestFilesystemOperation.Stat:
187
+ return "stat";
188
+ case protocol.GuestFilesystemOperation.Lstat:
189
+ return "lstat";
190
+ case protocol.GuestFilesystemOperation.ReadDir:
191
+ return "read_dir";
192
+ case protocol.GuestFilesystemOperation.RemoveFile:
193
+ return "remove_file";
194
+ case protocol.GuestFilesystemOperation.RemoveDir:
195
+ return "remove_dir";
196
+ case protocol.GuestFilesystemOperation.Rename:
197
+ return "rename";
198
+ case protocol.GuestFilesystemOperation.Realpath:
199
+ return "realpath";
200
+ case protocol.GuestFilesystemOperation.Symlink:
201
+ return "symlink";
202
+ case protocol.GuestFilesystemOperation.ReadLink:
203
+ return "read_link";
204
+ case protocol.GuestFilesystemOperation.Link:
205
+ return "link";
206
+ case protocol.GuestFilesystemOperation.Chmod:
207
+ return "chmod";
208
+ case protocol.GuestFilesystemOperation.Chown:
209
+ return "chown";
210
+ case protocol.GuestFilesystemOperation.Utimes:
211
+ return "utimes";
212
+ case protocol.GuestFilesystemOperation.Truncate:
213
+ return "truncate";
214
+ case protocol.GuestFilesystemOperation.Pread:
215
+ return "pread";
216
+ }
217
+ }
@@ -0,0 +1,10 @@
1
+ export declare const SIDECAR_PROTOCOL_SCHEMA: {
2
+ readonly name: "secure-exec-sidecar";
3
+ readonly version: 7;
4
+ };
5
+ export type LiveProtocolSchema = typeof SIDECAR_PROTOCOL_SCHEMA;
6
+ export type ProtocolSchemaLike = {
7
+ name: string;
8
+ version: number;
9
+ };
10
+ export declare function validateSidecarProtocolSchema(schema: ProtocolSchemaLike): LiveProtocolSchema;
@@ -0,0 +1,11 @@
1
+ export const SIDECAR_PROTOCOL_SCHEMA = {
2
+ name: "secure-exec-sidecar",
3
+ version: 7,
4
+ };
5
+ export function validateSidecarProtocolSchema(schema) {
6
+ if (schema.name !== SIDECAR_PROTOCOL_SCHEMA.name ||
7
+ schema.version !== SIDECAR_PROTOCOL_SCHEMA.version) {
8
+ throw new Error(`unsupported sidecar protocol schema ${schema.name}@${schema.version}`);
9
+ }
10
+ return SIDECAR_PROTOCOL_SCHEMA;
11
+ }
@@ -0,0 +1,137 @@
1
+ import { type LiveMountDescriptor, type LiveProjectedModuleDescriptor, type LiveSidecarPlacement, type LiveSoftwareDescriptor } from "./descriptors.js";
2
+ import { type LiveExtEnvelope } from "./ext.js";
3
+ import { type LiveRootFilesystemEntry, type LiveRootFilesystemEntryEncoding } from "./filesystem.js";
4
+ import type * as protocol from "./generated-protocol.js";
5
+ import type { CreateVmConfig } from "./generated/CreateVmConfig.js";
6
+ import { type LivePermissionsPolicy } from "./permissions.js";
7
+ import { type LiveDisposeReason, type LiveGuestFilesystemOperation, type LiveGuestRuntimeKind, type LiveRootFilesystemMode, type LiveWasmPermissionTier } from "./protocol-maps.js";
8
+ export interface LiveRegisteredHostCallbackExample {
9
+ description: string;
10
+ input: unknown;
11
+ }
12
+ export interface LiveRegisteredHostCallbackDefinition {
13
+ description: string;
14
+ input_schema: unknown;
15
+ timeout_ms?: number;
16
+ examples?: LiveRegisteredHostCallbackExample[];
17
+ }
18
+ export type LiveRequestPayload = {
19
+ type: "authenticate";
20
+ client_name: string;
21
+ auth_token: string;
22
+ protocol_version: number;
23
+ bridge_version: number;
24
+ } | {
25
+ type: "open_session";
26
+ placement: LiveSidecarPlacement;
27
+ metadata: Record<string, string>;
28
+ } | {
29
+ type: "create_vm";
30
+ runtime: LiveGuestRuntimeKind;
31
+ config: CreateVmConfig;
32
+ } | {
33
+ type: "configure_vm";
34
+ mounts: LiveMountDescriptor[];
35
+ software: LiveSoftwareDescriptor[];
36
+ permissions?: LivePermissionsPolicy;
37
+ module_access_cwd?: string;
38
+ instructions: string[];
39
+ projected_modules: LiveProjectedModuleDescriptor[];
40
+ command_permissions: Record<string, LiveWasmPermissionTier>;
41
+ loopback_exempt_ports?: number[];
42
+ } | {
43
+ type: "register_host_callbacks";
44
+ name: string;
45
+ description: string;
46
+ command_aliases?: string[];
47
+ registry_command_aliases?: string[];
48
+ callbacks: Record<string, LiveRegisteredHostCallbackDefinition>;
49
+ } | {
50
+ type: "dispose_vm";
51
+ reason: LiveDisposeReason;
52
+ } | {
53
+ type: "bootstrap_root_filesystem";
54
+ entries: LiveRootFilesystemEntry[];
55
+ } | {
56
+ type: "create_layer";
57
+ } | {
58
+ type: "seal_layer";
59
+ layer_id: string;
60
+ } | {
61
+ type: "import_snapshot";
62
+ entries: LiveRootFilesystemEntry[];
63
+ } | {
64
+ type: "export_snapshot";
65
+ layer_id: string;
66
+ } | {
67
+ type: "create_overlay";
68
+ mode?: LiveRootFilesystemMode;
69
+ upper_layer_id?: string;
70
+ lower_layer_ids: string[];
71
+ } | {
72
+ type: "snapshot_root_filesystem";
73
+ } | {
74
+ type: "guest_filesystem_call";
75
+ operation: LiveGuestFilesystemOperation;
76
+ path: string;
77
+ destination_path?: string;
78
+ target?: string;
79
+ content?: string;
80
+ encoding?: LiveRootFilesystemEntryEncoding;
81
+ recursive?: boolean;
82
+ mode?: number;
83
+ uid?: number;
84
+ gid?: number;
85
+ atime_ms?: number;
86
+ mtime_ms?: number;
87
+ len?: number;
88
+ offset?: number;
89
+ } | {
90
+ type: "execute";
91
+ process_id: string;
92
+ command?: string;
93
+ runtime?: LiveGuestRuntimeKind;
94
+ entrypoint?: string;
95
+ args: string[];
96
+ env?: Record<string, string>;
97
+ cwd?: string;
98
+ wasm_permission_tier?: LiveWasmPermissionTier;
99
+ } | {
100
+ type: "write_stdin";
101
+ process_id: string;
102
+ chunk: Uint8Array;
103
+ } | {
104
+ type: "close_stdin";
105
+ process_id: string;
106
+ } | {
107
+ type: "kill_process";
108
+ process_id: string;
109
+ signal: string;
110
+ } | {
111
+ type: "get_process_snapshot";
112
+ } | {
113
+ type: "find_listener";
114
+ host?: string;
115
+ port?: number;
116
+ path?: string;
117
+ } | {
118
+ type: "find_bound_udp";
119
+ host?: string;
120
+ port?: number;
121
+ } | {
122
+ type: "vm_fetch";
123
+ port: number;
124
+ method: string;
125
+ path: string;
126
+ headers_json: string;
127
+ body?: string;
128
+ } | {
129
+ type: "get_signal_state";
130
+ process_id: string;
131
+ } | {
132
+ type: "get_zombie_timer_count";
133
+ } | {
134
+ type: "ext";
135
+ envelope: LiveExtEnvelope;
136
+ };
137
+ export declare function toGeneratedRequestPayload(payload: LiveRequestPayload): protocol.RequestPayload;