@secure-exec/core 0.0.0-split-runtime-preview.7b0dded
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/dist/binary.d.ts +4 -0
- package/dist/binary.js +25 -0
- package/dist/bytes.d.ts +2 -0
- package/dist/bytes.js +6 -0
- package/dist/callbacks.d.ts +41 -0
- package/dist/callbacks.js +94 -0
- package/dist/cargo.d.ts +2 -0
- package/dist/cargo.js +142 -0
- package/dist/correlation.d.ts +10 -0
- package/dist/correlation.js +49 -0
- package/dist/descriptors.d.ts +34 -0
- package/dist/descriptors.js +37 -0
- package/dist/event-buffer.d.ts +90 -0
- package/dist/event-buffer.js +313 -0
- package/dist/ext.d.ts +7 -0
- package/dist/ext.js +13 -0
- package/dist/filesystem.d.ts +41 -0
- package/dist/filesystem.js +70 -0
- package/dist/frame-payload-codec.d.ts +8 -0
- package/dist/frame-payload-codec.js +14 -0
- package/dist/frame-rpc.d.ts +38 -0
- package/dist/frame-rpc.js +73 -0
- package/dist/frame-stream.d.ts +27 -0
- package/dist/frame-stream.js +99 -0
- package/dist/framing.d.ts +7 -0
- package/dist/framing.js +22 -0
- package/dist/generated-protocol.d.ts +1038 -0
- package/dist/generated-protocol.js +2879 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +23 -0
- package/dist/json.d.ts +2 -0
- package/dist/json.js +20 -0
- package/dist/kernel-proxy.d.ts +137 -0
- package/dist/kernel-proxy.js +1725 -0
- package/dist/native-client.d.ts +41 -0
- package/dist/native-client.js +124 -0
- package/dist/numbers.d.ts +1 -0
- package/dist/numbers.js +8 -0
- package/dist/ownership.d.ts +18 -0
- package/dist/ownership.js +77 -0
- package/dist/permissions.d.ts +29 -0
- package/dist/permissions.js +68 -0
- package/dist/process.d.ts +35 -0
- package/dist/process.js +125 -0
- package/dist/protocol-client.d.ts +46 -0
- package/dist/protocol-client.js +180 -0
- package/dist/protocol-frames.d.ts +68 -0
- package/dist/protocol-frames.js +139 -0
- package/dist/protocol-maps.d.ts +28 -0
- package/dist/protocol-maps.js +217 -0
- package/dist/protocol-schema.d.ts +10 -0
- package/dist/protocol-schema.js +11 -0
- package/dist/request-payloads.d.ts +139 -0
- package/dist/request-payloads.js +213 -0
- package/dist/response-payloads.d.ts +107 -0
- package/dist/response-payloads.js +161 -0
- package/dist/sidecar-client.d.ts +250 -0
- package/dist/sidecar-client.js +802 -0
- package/dist/state.d.ts +40 -0
- package/dist/state.js +44 -0
- package/dist/test-runtime.d.ts +483 -0
- package/dist/test-runtime.js +1985 -0
- package/fixtures/alpine-defaults.json +520 -0
- package/fixtures/base-filesystem.json +528 -0
- package/package.json +188 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { type LiveMountDescriptor, type LiveProjectedModuleDescriptor, type LiveSidecarPlacement, type LiveSoftwareDescriptor } from "./descriptors.js";
|
|
2
|
+
import { type LiveExtEnvelope } from "./ext.js";
|
|
3
|
+
import { type LiveRootFilesystemDescriptor, type LiveRootFilesystemEntry, type LiveRootFilesystemEntryEncoding } from "./filesystem.js";
|
|
4
|
+
import type * as protocol from "./generated-protocol.js";
|
|
5
|
+
import { type LivePermissionsPolicy } from "./permissions.js";
|
|
6
|
+
import { type LiveDisposeReason, type LiveGuestFilesystemOperation, type LiveGuestRuntimeKind, type LiveRootFilesystemMode, type LiveWasmPermissionTier } from "./protocol-maps.js";
|
|
7
|
+
export interface LiveRegisteredHostCallbackExample {
|
|
8
|
+
description: string;
|
|
9
|
+
input: unknown;
|
|
10
|
+
}
|
|
11
|
+
export interface LiveRegisteredHostCallbackDefinition {
|
|
12
|
+
description: string;
|
|
13
|
+
input_schema: unknown;
|
|
14
|
+
timeout_ms?: number;
|
|
15
|
+
examples?: LiveRegisteredHostCallbackExample[];
|
|
16
|
+
}
|
|
17
|
+
export type LiveRequestPayload = {
|
|
18
|
+
type: "authenticate";
|
|
19
|
+
client_name: string;
|
|
20
|
+
auth_token: string;
|
|
21
|
+
protocol_version: number;
|
|
22
|
+
bridge_version: number;
|
|
23
|
+
} | {
|
|
24
|
+
type: "open_session";
|
|
25
|
+
placement: LiveSidecarPlacement;
|
|
26
|
+
metadata: Record<string, string>;
|
|
27
|
+
} | {
|
|
28
|
+
type: "create_vm";
|
|
29
|
+
runtime: LiveGuestRuntimeKind;
|
|
30
|
+
metadata: Record<string, string>;
|
|
31
|
+
root_filesystem: LiveRootFilesystemDescriptor;
|
|
32
|
+
permissions?: LivePermissionsPolicy;
|
|
33
|
+
} | {
|
|
34
|
+
type: "configure_vm";
|
|
35
|
+
mounts: LiveMountDescriptor[];
|
|
36
|
+
software: LiveSoftwareDescriptor[];
|
|
37
|
+
permissions?: LivePermissionsPolicy;
|
|
38
|
+
module_access_cwd?: string;
|
|
39
|
+
instructions: string[];
|
|
40
|
+
projected_modules: LiveProjectedModuleDescriptor[];
|
|
41
|
+
command_permissions: Record<string, LiveWasmPermissionTier>;
|
|
42
|
+
allowed_node_builtins?: string[];
|
|
43
|
+
loopback_exempt_ports?: number[];
|
|
44
|
+
} | {
|
|
45
|
+
type: "register_host_callbacks";
|
|
46
|
+
name: string;
|
|
47
|
+
description: string;
|
|
48
|
+
command_aliases?: string[];
|
|
49
|
+
registry_command_aliases?: string[];
|
|
50
|
+
callbacks: Record<string, LiveRegisteredHostCallbackDefinition>;
|
|
51
|
+
} | {
|
|
52
|
+
type: "dispose_vm";
|
|
53
|
+
reason: LiveDisposeReason;
|
|
54
|
+
} | {
|
|
55
|
+
type: "bootstrap_root_filesystem";
|
|
56
|
+
entries: LiveRootFilesystemEntry[];
|
|
57
|
+
} | {
|
|
58
|
+
type: "create_layer";
|
|
59
|
+
} | {
|
|
60
|
+
type: "seal_layer";
|
|
61
|
+
layer_id: string;
|
|
62
|
+
} | {
|
|
63
|
+
type: "import_snapshot";
|
|
64
|
+
entries: LiveRootFilesystemEntry[];
|
|
65
|
+
} | {
|
|
66
|
+
type: "export_snapshot";
|
|
67
|
+
layer_id: string;
|
|
68
|
+
} | {
|
|
69
|
+
type: "create_overlay";
|
|
70
|
+
mode?: LiveRootFilesystemMode;
|
|
71
|
+
upper_layer_id?: string;
|
|
72
|
+
lower_layer_ids: string[];
|
|
73
|
+
} | {
|
|
74
|
+
type: "snapshot_root_filesystem";
|
|
75
|
+
} | {
|
|
76
|
+
type: "guest_filesystem_call";
|
|
77
|
+
operation: LiveGuestFilesystemOperation;
|
|
78
|
+
path: string;
|
|
79
|
+
destination_path?: string;
|
|
80
|
+
target?: string;
|
|
81
|
+
content?: string;
|
|
82
|
+
encoding?: LiveRootFilesystemEntryEncoding;
|
|
83
|
+
recursive?: boolean;
|
|
84
|
+
mode?: number;
|
|
85
|
+
uid?: number;
|
|
86
|
+
gid?: number;
|
|
87
|
+
atime_ms?: number;
|
|
88
|
+
mtime_ms?: number;
|
|
89
|
+
len?: number;
|
|
90
|
+
offset?: number;
|
|
91
|
+
} | {
|
|
92
|
+
type: "execute";
|
|
93
|
+
process_id: string;
|
|
94
|
+
command?: string;
|
|
95
|
+
runtime?: LiveGuestRuntimeKind;
|
|
96
|
+
entrypoint?: string;
|
|
97
|
+
args: string[];
|
|
98
|
+
env?: Record<string, string>;
|
|
99
|
+
cwd?: string;
|
|
100
|
+
wasm_permission_tier?: LiveWasmPermissionTier;
|
|
101
|
+
} | {
|
|
102
|
+
type: "write_stdin";
|
|
103
|
+
process_id: string;
|
|
104
|
+
chunk: Uint8Array;
|
|
105
|
+
} | {
|
|
106
|
+
type: "close_stdin";
|
|
107
|
+
process_id: string;
|
|
108
|
+
} | {
|
|
109
|
+
type: "kill_process";
|
|
110
|
+
process_id: string;
|
|
111
|
+
signal: string;
|
|
112
|
+
} | {
|
|
113
|
+
type: "get_process_snapshot";
|
|
114
|
+
} | {
|
|
115
|
+
type: "find_listener";
|
|
116
|
+
host?: string;
|
|
117
|
+
port?: number;
|
|
118
|
+
path?: string;
|
|
119
|
+
} | {
|
|
120
|
+
type: "find_bound_udp";
|
|
121
|
+
host?: string;
|
|
122
|
+
port?: number;
|
|
123
|
+
} | {
|
|
124
|
+
type: "vm_fetch";
|
|
125
|
+
port: number;
|
|
126
|
+
method: string;
|
|
127
|
+
path: string;
|
|
128
|
+
headers_json: string;
|
|
129
|
+
body?: string;
|
|
130
|
+
} | {
|
|
131
|
+
type: "get_signal_state";
|
|
132
|
+
process_id: string;
|
|
133
|
+
} | {
|
|
134
|
+
type: "get_zombie_timer_count";
|
|
135
|
+
} | {
|
|
136
|
+
type: "ext";
|
|
137
|
+
envelope: LiveExtEnvelope;
|
|
138
|
+
};
|
|
139
|
+
export declare function toGeneratedRequestPayload(payload: LiveRequestPayload): protocol.RequestPayload;
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { toExactArrayBuffer } from "./bytes.js";
|
|
2
|
+
import { toGeneratedMountDescriptor, toGeneratedProjectedModuleDescriptor, toGeneratedSidecarPlacement, toGeneratedSoftwareDescriptor, } from "./descriptors.js";
|
|
3
|
+
import { toGeneratedExtEnvelope } from "./ext.js";
|
|
4
|
+
import { toGeneratedRootFilesystemDescriptor, toGeneratedRootFilesystemEntry, } from "./filesystem.js";
|
|
5
|
+
import { stringifyJsonUtf8 } from "./json.js";
|
|
6
|
+
import { toGeneratedPermissionsPolicy, } from "./permissions.js";
|
|
7
|
+
import { toGeneratedDisposeReason, toGeneratedGuestFilesystemOperation, toGeneratedGuestRuntimeKind, toGeneratedRootFilesystemEntryEncoding, toGeneratedRootFilesystemMode, toGeneratedWasmPermissionTier, } from "./protocol-maps.js";
|
|
8
|
+
export function toGeneratedRequestPayload(payload) {
|
|
9
|
+
switch (payload.type) {
|
|
10
|
+
case "authenticate":
|
|
11
|
+
return {
|
|
12
|
+
tag: "AuthenticateRequest",
|
|
13
|
+
val: {
|
|
14
|
+
clientName: payload.client_name,
|
|
15
|
+
authToken: payload.auth_token,
|
|
16
|
+
protocolVersion: payload.protocol_version,
|
|
17
|
+
bridgeVersion: payload.bridge_version,
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
case "open_session":
|
|
21
|
+
return {
|
|
22
|
+
tag: "OpenSessionRequest",
|
|
23
|
+
val: {
|
|
24
|
+
placement: toGeneratedSidecarPlacement(payload.placement),
|
|
25
|
+
metadata: new Map(Object.entries(payload.metadata ?? {})),
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
case "create_vm":
|
|
29
|
+
return {
|
|
30
|
+
tag: "CreateVmRequest",
|
|
31
|
+
val: {
|
|
32
|
+
runtime: toGeneratedGuestRuntimeKind(payload.runtime),
|
|
33
|
+
metadata: new Map(Object.entries(payload.metadata ?? {})),
|
|
34
|
+
rootFilesystem: toGeneratedRootFilesystemDescriptor(payload.root_filesystem),
|
|
35
|
+
permissions: toGeneratedPermissionsPolicy(payload.permissions),
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
case "dispose_vm":
|
|
39
|
+
return {
|
|
40
|
+
tag: "DisposeVmRequest",
|
|
41
|
+
val: { reason: toGeneratedDisposeReason(payload.reason) },
|
|
42
|
+
};
|
|
43
|
+
case "bootstrap_root_filesystem":
|
|
44
|
+
return {
|
|
45
|
+
tag: "BootstrapRootFilesystemRequest",
|
|
46
|
+
val: { entries: payload.entries.map(toGeneratedRootFilesystemEntry) },
|
|
47
|
+
};
|
|
48
|
+
case "configure_vm":
|
|
49
|
+
return {
|
|
50
|
+
tag: "ConfigureVmRequest",
|
|
51
|
+
val: {
|
|
52
|
+
mounts: (payload.mounts ?? []).map(toGeneratedMountDescriptor),
|
|
53
|
+
software: (payload.software ?? []).map(toGeneratedSoftwareDescriptor),
|
|
54
|
+
permissions: toGeneratedPermissionsPolicy(payload.permissions),
|
|
55
|
+
moduleAccessCwd: payload.module_access_cwd ?? null,
|
|
56
|
+
instructions: payload.instructions ?? [],
|
|
57
|
+
projectedModules: (payload.projected_modules ?? []).map(toGeneratedProjectedModuleDescriptor),
|
|
58
|
+
commandPermissions: new Map(Object.entries(payload.command_permissions ?? {}).map(([name, tier]) => [name, toGeneratedWasmPermissionTier(tier)])),
|
|
59
|
+
allowedNodeBuiltins: payload.allowed_node_builtins ?? [],
|
|
60
|
+
loopbackExemptPorts: new Uint16Array(payload.loopback_exempt_ports ?? []),
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
case "register_host_callbacks":
|
|
64
|
+
return {
|
|
65
|
+
tag: "RegisterHostCallbacksRequest",
|
|
66
|
+
val: {
|
|
67
|
+
name: payload.name,
|
|
68
|
+
description: payload.description,
|
|
69
|
+
commandAliases: payload.command_aliases ?? [],
|
|
70
|
+
registryCommandAliases: payload.registry_command_aliases ?? [],
|
|
71
|
+
callbacks: new Map(Object.entries(payload.callbacks).map(([name, callback]) => [
|
|
72
|
+
name,
|
|
73
|
+
{
|
|
74
|
+
description: callback.description,
|
|
75
|
+
inputSchema: stringifyJsonUtf8(callback.input_schema, "register_host_callbacks.callback.input_schema"),
|
|
76
|
+
timeoutMs: callback.timeout_ms === undefined
|
|
77
|
+
? null
|
|
78
|
+
: BigInt(callback.timeout_ms),
|
|
79
|
+
examples: (callback.examples ?? []).map((example) => ({
|
|
80
|
+
description: example.description,
|
|
81
|
+
input: stringifyJsonUtf8(example.input, "register_host_callbacks.callback.example.input"),
|
|
82
|
+
})),
|
|
83
|
+
},
|
|
84
|
+
])),
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
case "create_layer":
|
|
88
|
+
return { tag: "CreateLayerRequest", val: null };
|
|
89
|
+
case "seal_layer":
|
|
90
|
+
return { tag: "SealLayerRequest", val: { layerId: payload.layer_id } };
|
|
91
|
+
case "import_snapshot":
|
|
92
|
+
return {
|
|
93
|
+
tag: "ImportSnapshotRequest",
|
|
94
|
+
val: { entries: payload.entries.map(toGeneratedRootFilesystemEntry) },
|
|
95
|
+
};
|
|
96
|
+
case "export_snapshot":
|
|
97
|
+
return {
|
|
98
|
+
tag: "ExportSnapshotRequest",
|
|
99
|
+
val: { layerId: payload.layer_id },
|
|
100
|
+
};
|
|
101
|
+
case "create_overlay":
|
|
102
|
+
return {
|
|
103
|
+
tag: "CreateOverlayRequest",
|
|
104
|
+
val: {
|
|
105
|
+
mode: toGeneratedRootFilesystemMode(payload.mode ?? "ephemeral"),
|
|
106
|
+
upperLayerId: payload.upper_layer_id ?? null,
|
|
107
|
+
lowerLayerIds: payload.lower_layer_ids ?? [],
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
case "guest_filesystem_call":
|
|
111
|
+
return {
|
|
112
|
+
tag: "GuestFilesystemCallRequest",
|
|
113
|
+
val: {
|
|
114
|
+
operation: toGeneratedGuestFilesystemOperation(payload.operation),
|
|
115
|
+
path: payload.path,
|
|
116
|
+
destinationPath: payload.destination_path ?? null,
|
|
117
|
+
target: payload.target ?? null,
|
|
118
|
+
content: payload.content ?? null,
|
|
119
|
+
encoding: payload.encoding === undefined
|
|
120
|
+
? null
|
|
121
|
+
: toGeneratedRootFilesystemEntryEncoding(payload.encoding),
|
|
122
|
+
recursive: payload.recursive ?? false,
|
|
123
|
+
mode: payload.mode ?? null,
|
|
124
|
+
uid: payload.uid ?? null,
|
|
125
|
+
gid: payload.gid ?? null,
|
|
126
|
+
atimeMs: toGeneratedOptionalU64(payload.atime_ms),
|
|
127
|
+
mtimeMs: toGeneratedOptionalU64(payload.mtime_ms),
|
|
128
|
+
len: toGeneratedOptionalU64(payload.len),
|
|
129
|
+
offset: toGeneratedOptionalU64(payload.offset),
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
case "snapshot_root_filesystem":
|
|
133
|
+
return { tag: "SnapshotRootFilesystemRequest", val: null };
|
|
134
|
+
case "execute":
|
|
135
|
+
return {
|
|
136
|
+
tag: "ExecuteRequest",
|
|
137
|
+
val: {
|
|
138
|
+
processId: payload.process_id,
|
|
139
|
+
command: payload.command ?? null,
|
|
140
|
+
runtime: payload.runtime === undefined
|
|
141
|
+
? null
|
|
142
|
+
: toGeneratedGuestRuntimeKind(payload.runtime),
|
|
143
|
+
entrypoint: payload.entrypoint ?? null,
|
|
144
|
+
args: payload.args ?? [],
|
|
145
|
+
env: new Map(Object.entries(payload.env ?? {})),
|
|
146
|
+
cwd: payload.cwd ?? null,
|
|
147
|
+
wasmPermissionTier: payload.wasm_permission_tier === undefined
|
|
148
|
+
? null
|
|
149
|
+
: toGeneratedWasmPermissionTier(payload.wasm_permission_tier),
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
case "write_stdin":
|
|
153
|
+
return {
|
|
154
|
+
tag: "WriteStdinRequest",
|
|
155
|
+
val: {
|
|
156
|
+
processId: payload.process_id,
|
|
157
|
+
chunk: toExactArrayBuffer(payload.chunk),
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
case "close_stdin":
|
|
161
|
+
return {
|
|
162
|
+
tag: "CloseStdinRequest",
|
|
163
|
+
val: { processId: payload.process_id },
|
|
164
|
+
};
|
|
165
|
+
case "kill_process":
|
|
166
|
+
return {
|
|
167
|
+
tag: "KillProcessRequest",
|
|
168
|
+
val: { processId: payload.process_id, signal: payload.signal },
|
|
169
|
+
};
|
|
170
|
+
case "get_process_snapshot":
|
|
171
|
+
return { tag: "GetProcessSnapshotRequest", val: null };
|
|
172
|
+
case "find_listener":
|
|
173
|
+
return {
|
|
174
|
+
tag: "FindListenerRequest",
|
|
175
|
+
val: {
|
|
176
|
+
host: payload.host ?? null,
|
|
177
|
+
port: payload.port ?? null,
|
|
178
|
+
path: payload.path ?? null,
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
case "find_bound_udp":
|
|
182
|
+
return {
|
|
183
|
+
tag: "FindBoundUdpRequest",
|
|
184
|
+
val: { host: payload.host ?? null, port: payload.port ?? null },
|
|
185
|
+
};
|
|
186
|
+
case "vm_fetch":
|
|
187
|
+
return {
|
|
188
|
+
tag: "VmFetchRequest",
|
|
189
|
+
val: {
|
|
190
|
+
port: payload.port,
|
|
191
|
+
method: payload.method,
|
|
192
|
+
path: payload.path,
|
|
193
|
+
headersJson: payload.headers_json,
|
|
194
|
+
body: payload.body ?? null,
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
case "get_signal_state":
|
|
198
|
+
return {
|
|
199
|
+
tag: "GetSignalStateRequest",
|
|
200
|
+
val: { processId: payload.process_id },
|
|
201
|
+
};
|
|
202
|
+
case "get_zombie_timer_count":
|
|
203
|
+
return { tag: "GetZombieTimerCountRequest", val: null };
|
|
204
|
+
case "ext":
|
|
205
|
+
return {
|
|
206
|
+
tag: "ExtEnvelope",
|
|
207
|
+
val: toGeneratedExtEnvelope(payload.envelope),
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
function toGeneratedOptionalU64(value) {
|
|
212
|
+
return value === undefined ? null : BigInt(value);
|
|
213
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { type LiveRootFilesystemEntry, type LiveRootFilesystemEntryEncoding } from "./filesystem.js";
|
|
2
|
+
import { type LiveExtEnvelope } from "./ext.js";
|
|
3
|
+
import type * as protocol from "./generated-protocol.js";
|
|
4
|
+
import { type LiveGuestFilesystemOperation, type LiveSignalDispositionAction } from "./protocol-maps.js";
|
|
5
|
+
import { type LiveGuestFilesystemStat, type LiveProcessSnapshotEntry, type LiveSocketStateEntry } from "./state.js";
|
|
6
|
+
export interface LiveSignalHandlerRegistration {
|
|
7
|
+
action: LiveSignalDispositionAction;
|
|
8
|
+
mask: number[];
|
|
9
|
+
flags: number;
|
|
10
|
+
}
|
|
11
|
+
export type LiveResponsePayload = {
|
|
12
|
+
type: "authenticated";
|
|
13
|
+
sidecar_id: string;
|
|
14
|
+
connection_id: string;
|
|
15
|
+
max_frame_bytes: number;
|
|
16
|
+
} | {
|
|
17
|
+
type: "session_opened";
|
|
18
|
+
session_id: string;
|
|
19
|
+
owner_connection_id: string;
|
|
20
|
+
} | {
|
|
21
|
+
type: "vm_created";
|
|
22
|
+
vm_id: string;
|
|
23
|
+
} | {
|
|
24
|
+
type: "vm_configured";
|
|
25
|
+
applied_mounts: number;
|
|
26
|
+
applied_software: number;
|
|
27
|
+
} | {
|
|
28
|
+
type: "host_callbacks_registered";
|
|
29
|
+
registration: string;
|
|
30
|
+
command_count: number;
|
|
31
|
+
} | {
|
|
32
|
+
type: "layer_created";
|
|
33
|
+
layer_id: string;
|
|
34
|
+
} | {
|
|
35
|
+
type: "layer_sealed";
|
|
36
|
+
layer_id: string;
|
|
37
|
+
} | {
|
|
38
|
+
type: "snapshot_imported";
|
|
39
|
+
layer_id: string;
|
|
40
|
+
} | {
|
|
41
|
+
type: "snapshot_exported";
|
|
42
|
+
layer_id: string;
|
|
43
|
+
entries: LiveRootFilesystemEntry[];
|
|
44
|
+
} | {
|
|
45
|
+
type: "overlay_created";
|
|
46
|
+
layer_id: string;
|
|
47
|
+
} | {
|
|
48
|
+
type: "root_filesystem_bootstrapped";
|
|
49
|
+
entry_count: number;
|
|
50
|
+
} | {
|
|
51
|
+
type: "guest_filesystem_result";
|
|
52
|
+
operation: LiveGuestFilesystemOperation;
|
|
53
|
+
path: string;
|
|
54
|
+
content?: string;
|
|
55
|
+
encoding?: LiveRootFilesystemEntryEncoding;
|
|
56
|
+
entries?: string[];
|
|
57
|
+
stat?: LiveGuestFilesystemStat;
|
|
58
|
+
exists?: boolean;
|
|
59
|
+
target?: string;
|
|
60
|
+
} | {
|
|
61
|
+
type: "root_filesystem_snapshot";
|
|
62
|
+
entries: LiveRootFilesystemEntry[];
|
|
63
|
+
} | {
|
|
64
|
+
type: "vm_disposed";
|
|
65
|
+
vm_id: string;
|
|
66
|
+
} | {
|
|
67
|
+
type: "process_started";
|
|
68
|
+
process_id: string;
|
|
69
|
+
pid?: number;
|
|
70
|
+
} | {
|
|
71
|
+
type: "stdin_written";
|
|
72
|
+
process_id: string;
|
|
73
|
+
accepted_bytes: number;
|
|
74
|
+
} | {
|
|
75
|
+
type: "stdin_closed";
|
|
76
|
+
process_id: string;
|
|
77
|
+
} | {
|
|
78
|
+
type: "process_killed";
|
|
79
|
+
process_id: string;
|
|
80
|
+
} | {
|
|
81
|
+
type: "process_snapshot";
|
|
82
|
+
processes: LiveProcessSnapshotEntry[];
|
|
83
|
+
} | {
|
|
84
|
+
type: "listener_snapshot";
|
|
85
|
+
listener?: LiveSocketStateEntry;
|
|
86
|
+
} | {
|
|
87
|
+
type: "bound_udp_snapshot";
|
|
88
|
+
socket?: LiveSocketStateEntry;
|
|
89
|
+
} | {
|
|
90
|
+
type: "vm_fetch_result";
|
|
91
|
+
response_json: string;
|
|
92
|
+
} | {
|
|
93
|
+
type: "signal_state";
|
|
94
|
+
process_id: string;
|
|
95
|
+
handlers: Record<string, LiveSignalHandlerRegistration>;
|
|
96
|
+
} | {
|
|
97
|
+
type: "zombie_timer_count";
|
|
98
|
+
count: number;
|
|
99
|
+
} | {
|
|
100
|
+
type: "rejected";
|
|
101
|
+
code: string;
|
|
102
|
+
message: string;
|
|
103
|
+
} | {
|
|
104
|
+
type: "ext_result";
|
|
105
|
+
envelope: LiveExtEnvelope;
|
|
106
|
+
};
|
|
107
|
+
export declare function fromGeneratedResponsePayload(payload: protocol.ResponsePayload): LiveResponsePayload;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { fromGeneratedRootFilesystemEntry, } from "./filesystem.js";
|
|
2
|
+
import { fromGeneratedExtEnvelope } from "./ext.js";
|
|
3
|
+
import { bigIntToSafeNumber } from "./numbers.js";
|
|
4
|
+
import { fromGeneratedGuestFilesystemOperation, fromGeneratedRootFilesystemEntryEncoding, fromGeneratedSignalDispositionAction, } from "./protocol-maps.js";
|
|
5
|
+
import { fromGeneratedGuestFilesystemStat, fromGeneratedProcessSnapshotEntry, fromGeneratedSocketStateEntry, } from "./state.js";
|
|
6
|
+
export function fromGeneratedResponsePayload(payload) {
|
|
7
|
+
switch (payload.tag) {
|
|
8
|
+
case "AuthenticatedResponse":
|
|
9
|
+
return {
|
|
10
|
+
type: "authenticated",
|
|
11
|
+
sidecar_id: payload.val.sidecarId,
|
|
12
|
+
connection_id: payload.val.connectionId,
|
|
13
|
+
max_frame_bytes: payload.val.maxFrameBytes,
|
|
14
|
+
};
|
|
15
|
+
case "SessionOpenedResponse":
|
|
16
|
+
return {
|
|
17
|
+
type: "session_opened",
|
|
18
|
+
session_id: payload.val.sessionId,
|
|
19
|
+
owner_connection_id: payload.val.ownerConnectionId,
|
|
20
|
+
};
|
|
21
|
+
case "VmCreatedResponse":
|
|
22
|
+
return { type: "vm_created", vm_id: payload.val.vmId };
|
|
23
|
+
case "VmDisposedResponse":
|
|
24
|
+
return { type: "vm_disposed", vm_id: payload.val.vmId };
|
|
25
|
+
case "RootFilesystemBootstrappedResponse":
|
|
26
|
+
return {
|
|
27
|
+
type: "root_filesystem_bootstrapped",
|
|
28
|
+
entry_count: payload.val.entryCount,
|
|
29
|
+
};
|
|
30
|
+
case "VmConfiguredResponse":
|
|
31
|
+
return {
|
|
32
|
+
type: "vm_configured",
|
|
33
|
+
applied_mounts: payload.val.appliedMounts,
|
|
34
|
+
applied_software: payload.val.appliedSoftware,
|
|
35
|
+
};
|
|
36
|
+
case "HostCallbacksRegisteredResponse":
|
|
37
|
+
return {
|
|
38
|
+
type: "host_callbacks_registered",
|
|
39
|
+
registration: payload.val.registration,
|
|
40
|
+
command_count: payload.val.commandCount,
|
|
41
|
+
};
|
|
42
|
+
case "LayerCreatedResponse":
|
|
43
|
+
return { type: "layer_created", layer_id: payload.val.layerId };
|
|
44
|
+
case "LayerSealedResponse":
|
|
45
|
+
return { type: "layer_sealed", layer_id: payload.val.layerId };
|
|
46
|
+
case "SnapshotImportedResponse":
|
|
47
|
+
return { type: "snapshot_imported", layer_id: payload.val.layerId };
|
|
48
|
+
case "SnapshotExportedResponse":
|
|
49
|
+
return {
|
|
50
|
+
type: "snapshot_exported",
|
|
51
|
+
layer_id: payload.val.layerId,
|
|
52
|
+
entries: payload.val.entries.map(fromGeneratedRootFilesystemEntry),
|
|
53
|
+
};
|
|
54
|
+
case "OverlayCreatedResponse":
|
|
55
|
+
return { type: "overlay_created", layer_id: payload.val.layerId };
|
|
56
|
+
case "GuestFilesystemResultResponse":
|
|
57
|
+
return {
|
|
58
|
+
type: "guest_filesystem_result",
|
|
59
|
+
operation: fromGeneratedGuestFilesystemOperation(payload.val.operation),
|
|
60
|
+
path: payload.val.path,
|
|
61
|
+
...(payload.val.content !== null
|
|
62
|
+
? { content: payload.val.content }
|
|
63
|
+
: {}),
|
|
64
|
+
...(payload.val.encoding !== null
|
|
65
|
+
? {
|
|
66
|
+
encoding: fromGeneratedRootFilesystemEntryEncoding(payload.val.encoding),
|
|
67
|
+
}
|
|
68
|
+
: {}),
|
|
69
|
+
...(payload.val.entries !== null
|
|
70
|
+
? { entries: [...payload.val.entries] }
|
|
71
|
+
: {}),
|
|
72
|
+
...(payload.val.stat !== null
|
|
73
|
+
? { stat: fromGeneratedGuestFilesystemStat(payload.val.stat) }
|
|
74
|
+
: {}),
|
|
75
|
+
...(payload.val.exists !== null ? { exists: payload.val.exists } : {}),
|
|
76
|
+
...(payload.val.target !== null ? { target: payload.val.target } : {}),
|
|
77
|
+
};
|
|
78
|
+
case "RootFilesystemSnapshotResponse":
|
|
79
|
+
return {
|
|
80
|
+
type: "root_filesystem_snapshot",
|
|
81
|
+
entries: payload.val.entries.map(fromGeneratedRootFilesystemEntry),
|
|
82
|
+
};
|
|
83
|
+
case "ProcessStartedResponse":
|
|
84
|
+
return {
|
|
85
|
+
type: "process_started",
|
|
86
|
+
process_id: payload.val.processId,
|
|
87
|
+
...(payload.val.pid !== null ? { pid: payload.val.pid } : {}),
|
|
88
|
+
};
|
|
89
|
+
case "StdinWrittenResponse":
|
|
90
|
+
return {
|
|
91
|
+
type: "stdin_written",
|
|
92
|
+
process_id: payload.val.processId,
|
|
93
|
+
accepted_bytes: bigIntToSafeNumber(payload.val.acceptedBytes, "stdin_written.accepted_bytes"),
|
|
94
|
+
};
|
|
95
|
+
case "StdinClosedResponse":
|
|
96
|
+
return { type: "stdin_closed", process_id: payload.val.processId };
|
|
97
|
+
case "ProcessKilledResponse":
|
|
98
|
+
return { type: "process_killed", process_id: payload.val.processId };
|
|
99
|
+
case "ProcessSnapshotResponse":
|
|
100
|
+
return {
|
|
101
|
+
type: "process_snapshot",
|
|
102
|
+
processes: payload.val.processes.map(fromGeneratedProcessSnapshotEntry),
|
|
103
|
+
};
|
|
104
|
+
case "ListenerSnapshotResponse":
|
|
105
|
+
return {
|
|
106
|
+
type: "listener_snapshot",
|
|
107
|
+
...(payload.val.listener !== null
|
|
108
|
+
? { listener: fromGeneratedSocketStateEntry(payload.val.listener) }
|
|
109
|
+
: {}),
|
|
110
|
+
};
|
|
111
|
+
case "BoundUdpSnapshotResponse":
|
|
112
|
+
return {
|
|
113
|
+
type: "bound_udp_snapshot",
|
|
114
|
+
...(payload.val.socket !== null
|
|
115
|
+
? { socket: fromGeneratedSocketStateEntry(payload.val.socket) }
|
|
116
|
+
: {}),
|
|
117
|
+
};
|
|
118
|
+
case "SignalStateResponse":
|
|
119
|
+
return {
|
|
120
|
+
type: "signal_state",
|
|
121
|
+
process_id: payload.val.processId,
|
|
122
|
+
handlers: Object.fromEntries([...payload.val.handlers].map(([signal, registration]) => [
|
|
123
|
+
String(signal),
|
|
124
|
+
{
|
|
125
|
+
action: fromGeneratedSignalDispositionAction(registration.action),
|
|
126
|
+
mask: Array.from(registration.mask),
|
|
127
|
+
flags: registration.flags,
|
|
128
|
+
},
|
|
129
|
+
])),
|
|
130
|
+
};
|
|
131
|
+
case "ZombieTimerCountResponse":
|
|
132
|
+
return {
|
|
133
|
+
type: "zombie_timer_count",
|
|
134
|
+
count: bigIntToSafeNumber(payload.val.count, "zombie_timer_count.count"),
|
|
135
|
+
};
|
|
136
|
+
case "FilesystemResultResponse":
|
|
137
|
+
throw new Error("unsupported bare response payload tag: filesystem_result");
|
|
138
|
+
case "PermissionDecisionResponse":
|
|
139
|
+
throw new Error("unsupported bare response payload tag: permission_decision");
|
|
140
|
+
case "PersistenceStateResponse":
|
|
141
|
+
throw new Error("unsupported bare response payload tag: persistence_state");
|
|
142
|
+
case "PersistenceFlushedResponse":
|
|
143
|
+
throw new Error("unsupported bare response payload tag: persistence_flushed");
|
|
144
|
+
case "RejectedResponse":
|
|
145
|
+
return {
|
|
146
|
+
type: "rejected",
|
|
147
|
+
code: payload.val.code,
|
|
148
|
+
message: payload.val.message,
|
|
149
|
+
};
|
|
150
|
+
case "VmFetchResponse":
|
|
151
|
+
return {
|
|
152
|
+
type: "vm_fetch_result",
|
|
153
|
+
response_json: payload.val.responseJson,
|
|
154
|
+
};
|
|
155
|
+
case "ExtEnvelope":
|
|
156
|
+
return {
|
|
157
|
+
type: "ext_result",
|
|
158
|
+
envelope: fromGeneratedExtEnvelope(payload.val),
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
}
|