@microsandbox/control-client 0.7.0
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 +115 -0
- package/dist/attempt.d.ts +19 -0
- package/dist/attempt.d.ts.map +1 -0
- package/dist/attempt.js +79 -0
- package/dist/attempt.js.map +1 -0
- package/dist/client.d.ts +9 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +11 -0
- package/dist/client.js.map +1 -0
- package/dist/connection.d.ts +32 -0
- package/dist/connection.d.ts.map +1 -0
- package/dist/connection.js +103 -0
- package/dist/connection.js.map +1 -0
- package/dist/dialer.d.ts +16 -0
- package/dist/dialer.d.ts.map +1 -0
- package/dist/dialer.js +2 -0
- package/dist/dialer.js.map +1 -0
- package/dist/error.d.ts +13 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/error.js +23 -0
- package/dist/error.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/json-client.d.ts +15 -0
- package/dist/json-client.d.ts.map +1 -0
- package/dist/json-client.js +22 -0
- package/dist/json-client.js.map +1 -0
- package/dist/json-reply.d.ts +18 -0
- package/dist/json-reply.d.ts.map +1 -0
- package/dist/json-reply.js +63 -0
- package/dist/json-reply.js.map +1 -0
- package/dist/json-session.d.ts +23 -0
- package/dist/json-session.d.ts.map +1 -0
- package/dist/json-session.js +128 -0
- package/dist/json-session.js.map +1 -0
- package/dist/json-value.d.ts +18 -0
- package/dist/json-value.d.ts.map +1 -0
- package/dist/json-value.js +138 -0
- package/dist/json-value.js.map +1 -0
- package/dist/legacy-request.d.ts +26 -0
- package/dist/legacy-request.d.ts.map +1 -0
- package/dist/legacy-request.js +77 -0
- package/dist/legacy-request.js.map +1 -0
- package/dist/node.d.ts +13 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +19 -0
- package/dist/node.js.map +1 -0
- package/dist/protocol.d.ts +13 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +65 -0
- package/dist/protocol.js.map +1 -0
- package/dist/records.d.ts +100 -0
- package/dist/records.d.ts.map +1 -0
- package/dist/records.js +110 -0
- package/dist/records.js.map +1 -0
- package/dist/request.d.ts +50 -0
- package/dist/request.d.ts.map +1 -0
- package/dist/request.js +86 -0
- package/dist/request.js.map +1 -0
- package/package.json +26 -0
package/dist/protocol.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { CborEnvelopeCodec, ClientError, encodeEnvelope, encodeFrame, encodeRecord, readExactly, } from "@microsandbox/protocol-client";
|
|
2
|
+
import { CONTROL_GENERATION, CONTROL_PROTOCOL, DEFAULT_MAX_IN_FLIGHT, DEFAULT_REQUEST_TIMEOUT_MS, DEFAULT_SETUP_TIMEOUT_MS, MAX_HANDSHAKE_FRAME_SIZE, decodeControlError, decodeWelcome, validateHello, } from "./records.js";
|
|
3
|
+
/** Explicit framed setup; discovery and JSON adaptation belong outside this engine. */
|
|
4
|
+
export class ControlProtocol {
|
|
5
|
+
async establish(transport, context) {
|
|
6
|
+
const hello = {
|
|
7
|
+
protocol: CONTROL_PROTOCOL, min_generation: CONTROL_GENERATION, max_generation: CONTROL_GENERATION,
|
|
8
|
+
max_frame_size: context.limits.maxFrameSize,
|
|
9
|
+
max_in_flight: Math.min(context.limits.maxInFlight, DEFAULT_MAX_IN_FLIGHT),
|
|
10
|
+
};
|
|
11
|
+
try {
|
|
12
|
+
validateHello(hello);
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
throw new ClientError("invalid_options");
|
|
16
|
+
}
|
|
17
|
+
await transport.write(encodeFrame({ id: 0, flags: 0, body: encodeEnvelope({
|
|
18
|
+
v: CONTROL_GENERATION, t: "control.hello", p: encodeRecord(hello),
|
|
19
|
+
}) }));
|
|
20
|
+
const prefix = await readExactly(transport, 4, context.signal);
|
|
21
|
+
const length = new DataView(prefix.buffer, prefix.byteOffset, prefix.byteLength).getUint32(0);
|
|
22
|
+
// Reject hostile opening lengths before allocating or waiting for the body.
|
|
23
|
+
if (length < 5 || length > MAX_HANDSHAKE_FRAME_SIZE)
|
|
24
|
+
throw new ClientError("invalid_data");
|
|
25
|
+
const header = await readExactly(transport, 5, context.signal);
|
|
26
|
+
const body = await readExactly(transport, length - 5, context.signal);
|
|
27
|
+
const codec = new CborEnvelopeCodec();
|
|
28
|
+
const { frame, welcome } = decodeOpening(codec, { id: new DataView(header.buffer).getUint32(0), flags: header[4], body }, hello);
|
|
29
|
+
return {
|
|
30
|
+
transport, codec, ids: { start: 1, endExclusive: 0x100000000 }, ready: { welcome, frame },
|
|
31
|
+
limits: {
|
|
32
|
+
...context.limits, maxFrameSize: welcome.max_frame_size, maxInFlight: welcome.max_in_flight,
|
|
33
|
+
incompleteFrameTimeoutMs: context.limits.incompleteFrameTimeoutMs ?? DEFAULT_SETUP_TIMEOUT_MS,
|
|
34
|
+
requestTimeoutMs: context.limits.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS,
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
prepare(ready, wireName) {
|
|
39
|
+
if (wireName === "control.hello" || wireName === "control.welcome")
|
|
40
|
+
throw new ClientError("unsupported_operation");
|
|
41
|
+
return { generation: ready.welcome.generation, flags: 0 };
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function decodeOpening(codec, raw, hello) {
|
|
45
|
+
try {
|
|
46
|
+
const frame = codec.decode(raw);
|
|
47
|
+
if (frame.id !== 0 || frame.flags !== 1 || frame.protocolVersion !== CONTROL_GENERATION)
|
|
48
|
+
throw new ClientError("invalid_data");
|
|
49
|
+
if (frame.type === "control.error") {
|
|
50
|
+
const refusal = decodeControlError(frame.payload);
|
|
51
|
+
throw new ClientError(refusal.code === "unsupported_generation" ? "unsupported_operation" : "invalid_data");
|
|
52
|
+
}
|
|
53
|
+
if (frame.type !== "control.welcome")
|
|
54
|
+
throw new ClientError("invalid_data");
|
|
55
|
+
return { frame, welcome: decodeWelcome(frame.payload, hello) };
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
// Decoder failures describe peer data, not socket I/O. Keep diagnostics
|
|
59
|
+
// sanitized and preserve an explicit unsupported-generation refusal.
|
|
60
|
+
if (error instanceof ClientError)
|
|
61
|
+
throw error;
|
|
62
|
+
throw new ClientError("invalid_data");
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,GAGvF,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,kBAAkB,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,0BAA0B,EACvF,wBAAwB,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,aAAa,EACrF,aAAa,GACd,MAAM,cAAc,CAAC;AAKtB,uFAAuF;AACvF,MAAM,OAAO,eAAe;IAC1B,KAAK,CAAC,SAAS,CAAC,SAAwB,EAAE,OAAyB;QACjE,MAAM,KAAK,GAAiB;YAC1B,QAAQ,EAAE,gBAAgB,EAAE,cAAc,EAAE,kBAAkB,EAAE,cAAc,EAAE,kBAAkB;YAClG,cAAc,EAAE,OAAO,CAAC,MAAM,CAAC,YAAY;YAC3C,aAAa,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,qBAAqB,CAAC;SAC3E,CAAC;QACF,IAAI,CAAC;YAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC;YAAC,MAAM,IAAI,WAAW,CAAC,iBAAiB,CAAC,CAAC;QAAC,CAAC;QACjF,MAAM,SAAS,CAAC,KAAK,CAAC,WAAW,C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EAAE,KAAK,EAAE,OAAO,EAAE,aAAa,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC;IACjE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,wEAAwE;QACxE,qEAAqE;QACrE,IAAI,KAAK,YAAY,WAAW;YAAE,MAAM,KAAK,CAAC;QAC9C,MAAM,IAAI,WAAW,CAAC,cAAc,CAAC,CAAC;IACxC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
export declare const CONTROL_GENERATION = 1;
|
|
2
|
+
export declare const CONTROL_PROTOCOL = "msb.control";
|
|
3
|
+
export declare const MAX_HANDSHAKE_FRAME_SIZE = 4096;
|
|
4
|
+
export declare const DEFAULT_MAX_IN_FLIGHT = 64;
|
|
5
|
+
export declare const DEFAULT_SETUP_TIMEOUT_MS = 10000;
|
|
6
|
+
export declare const DEFAULT_REQUEST_TIMEOUT_MS = 30000;
|
|
7
|
+
export type ControlHello = {
|
|
8
|
+
protocol: string;
|
|
9
|
+
min_generation: number;
|
|
10
|
+
max_generation: number;
|
|
11
|
+
max_frame_size: number;
|
|
12
|
+
max_in_flight: number;
|
|
13
|
+
};
|
|
14
|
+
export type ControlWelcome = {
|
|
15
|
+
protocol: string;
|
|
16
|
+
generation: number;
|
|
17
|
+
max_frame_size: number;
|
|
18
|
+
max_in_flight: number;
|
|
19
|
+
};
|
|
20
|
+
export type Capabilities = {
|
|
21
|
+
root_disk_grow?: boolean;
|
|
22
|
+
cpu_resize: boolean;
|
|
23
|
+
memory_resize: boolean;
|
|
24
|
+
secrets_update: boolean;
|
|
25
|
+
};
|
|
26
|
+
/** Every memory observation is bigint, including zero and small values. */
|
|
27
|
+
export type MemoryState = {
|
|
28
|
+
boot_mib: bigint;
|
|
29
|
+
target_mib: bigint;
|
|
30
|
+
current_mib: bigint;
|
|
31
|
+
max_mib: bigint;
|
|
32
|
+
};
|
|
33
|
+
export type MemoryTarget = {
|
|
34
|
+
total_mib: bigint;
|
|
35
|
+
};
|
|
36
|
+
export type CpuState = {
|
|
37
|
+
possible: number;
|
|
38
|
+
requested_online: number;
|
|
39
|
+
actual_online: number;
|
|
40
|
+
enforced: number;
|
|
41
|
+
};
|
|
42
|
+
export type CpuTarget = {
|
|
43
|
+
online: number;
|
|
44
|
+
};
|
|
45
|
+
export type SecretChange = {
|
|
46
|
+
change: "rotate";
|
|
47
|
+
name: string;
|
|
48
|
+
value: string;
|
|
49
|
+
} | {
|
|
50
|
+
change: "remove";
|
|
51
|
+
name: string;
|
|
52
|
+
} | {
|
|
53
|
+
change: "set_allowed_hosts";
|
|
54
|
+
name: string;
|
|
55
|
+
hosts: readonly string[];
|
|
56
|
+
};
|
|
57
|
+
export type SecretsUpdate = {
|
|
58
|
+
changes: readonly SecretChange[];
|
|
59
|
+
};
|
|
60
|
+
export type ErrorEffect = "none" | "unknown";
|
|
61
|
+
export type ControlError = {
|
|
62
|
+
code: string;
|
|
63
|
+
message: string;
|
|
64
|
+
effect: ErrorEffect;
|
|
65
|
+
};
|
|
66
|
+
export type SecretsResult = {
|
|
67
|
+
outcome: "complete";
|
|
68
|
+
applied_count: number;
|
|
69
|
+
} | {
|
|
70
|
+
outcome: "failed";
|
|
71
|
+
applied_count: number;
|
|
72
|
+
failed_index: number;
|
|
73
|
+
error: ControlError;
|
|
74
|
+
};
|
|
75
|
+
/** Names are a convenience; open native/encoded message names remain supported. */
|
|
76
|
+
export declare const ControlMessageType: {
|
|
77
|
+
readonly Hello: "control.hello";
|
|
78
|
+
readonly Welcome: "control.welcome";
|
|
79
|
+
readonly Capabilities: "control.capabilities";
|
|
80
|
+
readonly CapabilitiesResult: "control.capabilities.result";
|
|
81
|
+
readonly MemoryState: "control.memory.state";
|
|
82
|
+
readonly MemoryTarget: "control.memory.target";
|
|
83
|
+
readonly CpuState: "control.cpu.state";
|
|
84
|
+
readonly CpuTarget: "control.cpu.target";
|
|
85
|
+
readonly SecretsUpdate: "control.secrets.update";
|
|
86
|
+
readonly SecretsResult: "control.secrets.result";
|
|
87
|
+
readonly Error: "control.error";
|
|
88
|
+
};
|
|
89
|
+
/** Validate native quantities before conversion or encoding; never silently round. */
|
|
90
|
+
export declare function checkedUint(value: number | bigint, bits: 8 | 32 | 64): bigint;
|
|
91
|
+
export declare function validateHello(hello: ControlHello): void;
|
|
92
|
+
export declare function decodeHello(bytes: Uint8Array): ControlHello;
|
|
93
|
+
export declare function decodeWelcome(bytes: Uint8Array, hello?: ControlHello): ControlWelcome;
|
|
94
|
+
export declare function decodeCapabilities(bytes: Uint8Array): Capabilities;
|
|
95
|
+
export declare function decodeMemoryState(bytes: Uint8Array): MemoryState;
|
|
96
|
+
export declare function decodeCpuState(bytes: Uint8Array): CpuState;
|
|
97
|
+
export declare function decodeControlError(bytes: Uint8Array): ControlError;
|
|
98
|
+
export declare function decodeSecretsResult(bytes: Uint8Array): SecretsResult;
|
|
99
|
+
export declare function decodeSecretsUpdate(bytes: Uint8Array): SecretsUpdate;
|
|
100
|
+
//# sourceMappingURL=records.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"records.d.ts","sourceRoot":"","sources":["../src/records.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,kBAAkB,IAAI,CAAC;AACpC,eAAO,MAAM,gBAAgB,gBAAgB,CAAC;AAC9C,eAAO,MAAM,wBAAwB,OAAO,CAAC;AAC7C,eAAO,MAAM,qBAAqB,KAAK,CAAC;AACxC,eAAO,MAAM,wBAAwB,QAAS,CAAC;AAC/C,eAAO,MAAM,0BAA0B,QAAS,CAAC;AAEjD,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAC;IACjE,cAAc,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;CAC/C,CAAC;AACF,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,EAAE,MAAM,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
|
|
1
|
+
import { MAX_FRAME_SIZE, WireError, readArray, readBool, readRecord, readText, readUint, required, } from "@microsandbox/protocol-client";
|
|
2
|
+
export const CONTROL_GENERATION = 1;
|
|
3
|
+
export const CONTROL_PROTOCOL = "msb.control";
|
|
4
|
+
export const MAX_HANDSHAKE_FRAME_SIZE = 4096;
|
|
5
|
+
export const DEFAULT_MAX_IN_FLIGHT = 64;
|
|
6
|
+
export const DEFAULT_SETUP_TIMEOUT_MS = 10_000;
|
|
7
|
+
export const DEFAULT_REQUEST_TIMEOUT_MS = 30_000;
|
|
8
|
+
/** Names are a convenience; open native/encoded message names remain supported. */
|
|
9
|
+
export const ControlMessageType = {
|
|
10
|
+
Hello: "control.hello", Welcome: "control.welcome", Capabilities: "control.capabilities",
|
|
11
|
+
CapabilitiesResult: "control.capabilities.result", MemoryState: "control.memory.state",
|
|
12
|
+
MemoryTarget: "control.memory.target", CpuState: "control.cpu.state", CpuTarget: "control.cpu.target",
|
|
13
|
+
SecretsUpdate: "control.secrets.update", SecretsResult: "control.secrets.result", Error: "control.error",
|
|
14
|
+
};
|
|
15
|
+
const uint = (fields, name, bits = 32) => Number(readUint(required(fields, name), bits));
|
|
16
|
+
const text = (fields, name) => readText(required(fields, name));
|
|
17
|
+
/** Validate native quantities before conversion or encoding; never silently round. */
|
|
18
|
+
export function checkedUint(value, bits) {
|
|
19
|
+
if (typeof value !== "bigint" && (typeof value !== "number" || !Number.isSafeInteger(value)))
|
|
20
|
+
throw new WireError("invalid_record");
|
|
21
|
+
const integer = BigInt(value);
|
|
22
|
+
if (integer < 0n || integer >= (1n << BigInt(bits)))
|
|
23
|
+
throw new WireError("invalid_record");
|
|
24
|
+
return integer;
|
|
25
|
+
}
|
|
26
|
+
function validateLimits(frame, inFlight) {
|
|
27
|
+
checkedUint(frame, 32);
|
|
28
|
+
checkedUint(inFlight, 32);
|
|
29
|
+
if (frame < MAX_HANDSHAKE_FRAME_SIZE || frame > MAX_FRAME_SIZE || inFlight < 1)
|
|
30
|
+
throw new WireError("invalid_record");
|
|
31
|
+
}
|
|
32
|
+
export function validateHello(hello) {
|
|
33
|
+
checkedUint(hello.min_generation, 8);
|
|
34
|
+
checkedUint(hello.max_generation, 8);
|
|
35
|
+
validateLimits(hello.max_frame_size, hello.max_in_flight);
|
|
36
|
+
if (hello.protocol !== CONTROL_PROTOCOL || hello.min_generation < 1 || hello.min_generation > hello.max_generation)
|
|
37
|
+
throw new WireError("invalid_record");
|
|
38
|
+
}
|
|
39
|
+
export function decodeHello(bytes) {
|
|
40
|
+
const fields = readRecord(bytes);
|
|
41
|
+
const hello = {
|
|
42
|
+
protocol: text(fields, "protocol"), min_generation: uint(fields, "min_generation", 8),
|
|
43
|
+
max_generation: uint(fields, "max_generation", 8), max_frame_size: uint(fields, "max_frame_size"),
|
|
44
|
+
max_in_flight: uint(fields, "max_in_flight"),
|
|
45
|
+
};
|
|
46
|
+
validateHello(hello);
|
|
47
|
+
return hello;
|
|
48
|
+
}
|
|
49
|
+
export function decodeWelcome(bytes, hello) {
|
|
50
|
+
const fields = readRecord(bytes);
|
|
51
|
+
const welcome = {
|
|
52
|
+
protocol: text(fields, "protocol"), generation: uint(fields, "generation", 8),
|
|
53
|
+
max_frame_size: uint(fields, "max_frame_size"), max_in_flight: uint(fields, "max_in_flight"),
|
|
54
|
+
};
|
|
55
|
+
validateLimits(welcome.max_frame_size, welcome.max_in_flight);
|
|
56
|
+
if (welcome.protocol !== CONTROL_PROTOCOL || welcome.generation < 1)
|
|
57
|
+
throw new WireError("invalid_record");
|
|
58
|
+
if (hello && (welcome.generation < hello.min_generation || welcome.generation > hello.max_generation
|
|
59
|
+
|| welcome.max_frame_size > hello.max_frame_size || welcome.max_in_flight > hello.max_in_flight))
|
|
60
|
+
throw new WireError("invalid_record");
|
|
61
|
+
return welcome;
|
|
62
|
+
}
|
|
63
|
+
export function decodeCapabilities(bytes) {
|
|
64
|
+
const fields = readRecord(bytes);
|
|
65
|
+
return { ...(fields.has("root_disk_grow") ? { root_disk_grow: readBool(required(fields, "root_disk_grow")) } : {}), cpu_resize: readBool(required(fields, "cpu_resize")), memory_resize: readBool(required(fields, "memory_resize")), secrets_update: readBool(required(fields, "secrets_update")) };
|
|
66
|
+
}
|
|
67
|
+
export function decodeMemoryState(bytes) {
|
|
68
|
+
const fields = readRecord(bytes);
|
|
69
|
+
return {
|
|
70
|
+
boot_mib: readUint(required(fields, "boot_mib"), 64), target_mib: readUint(required(fields, "target_mib"), 64),
|
|
71
|
+
current_mib: readUint(required(fields, "current_mib"), 64), max_mib: readUint(required(fields, "max_mib"), 64),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export function decodeCpuState(bytes) {
|
|
75
|
+
const fields = readRecord(bytes);
|
|
76
|
+
return { possible: uint(fields, "possible"), requested_online: uint(fields, "requested_online"), actual_online: uint(fields, "actual_online"), enforced: uint(fields, "enforced") };
|
|
77
|
+
}
|
|
78
|
+
export function decodeControlError(bytes) {
|
|
79
|
+
const fields = readRecord(bytes);
|
|
80
|
+
const effect = text(fields, "effect");
|
|
81
|
+
if (effect !== "none" && effect !== "unknown")
|
|
82
|
+
throw new WireError("invalid_record");
|
|
83
|
+
return { code: text(fields, "code"), message: text(fields, "message"), effect };
|
|
84
|
+
}
|
|
85
|
+
export function decodeSecretsResult(bytes) {
|
|
86
|
+
const fields = readRecord(bytes), outcome = text(fields, "outcome"), applied_count = uint(fields, "applied_count");
|
|
87
|
+
if (outcome === "complete")
|
|
88
|
+
return { outcome, applied_count };
|
|
89
|
+
if (outcome !== "failed")
|
|
90
|
+
throw new WireError("invalid_record");
|
|
91
|
+
const failed_index = uint(fields, "failed_index");
|
|
92
|
+
if (failed_index !== applied_count)
|
|
93
|
+
throw new WireError("invalid_record");
|
|
94
|
+
// Check the actual nested record before a library decoder can collapse keys.
|
|
95
|
+
return { outcome, applied_count, failed_index, error: decodeControlError(required(fields, "error")) };
|
|
96
|
+
}
|
|
97
|
+
export function decodeSecretsUpdate(bytes) {
|
|
98
|
+
const fields = readRecord(bytes);
|
|
99
|
+
const changes = readArray(required(fields, "changes")).map(bytes => {
|
|
100
|
+
const entry = readRecord(bytes), change = text(entry, "change"), name = text(entry, "name");
|
|
101
|
+
switch (change) {
|
|
102
|
+
case "rotate": return { change, name, value: text(entry, "value") };
|
|
103
|
+
case "remove": return { change, name };
|
|
104
|
+
case "set_allowed_hosts": return { change, name, hosts: readArray(required(entry, "hosts")).map(readText) };
|
|
105
|
+
default: throw new WireError("invalid_record");
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
return { changes };
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=records.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"records.js","sourceRoot":"","sources":["../src/records.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,GACzF,MAAM,+BAA+B,CAAC;AAEvC,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AACpC,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAAC;AAC9C,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,CAAC;AAC7C,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,CAAC;AACxC,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC;AAC/C,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAC;AA0BjD,mFAAmF;AACnF,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,sBAAsB;IACxF,kBAAkB,EAAE,6BAA6B,EAAE,WAAW,EAAE,sBAAsB;IACtF,YAAY,EAAE,uBAAuB,EAAE,QAAQ,EAAE,mBAAmB,EAAE,SAAS,EAAE,oBAAoB;IACrG,aAAa,EAAE,wBAAwB,EAA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C,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC5G,OAAO,CAAC,CAAC,MAAM,IAAI,SAAS,CAAC,gBAAgB,CAAC,CAAC;QACjD,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,OAAO,EAAE,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type EncodedMessage, type InboundFrame } from "@microsandbox/protocol-client";
|
|
2
|
+
import type { Mebibytes } from "@microsandbox/types/size";
|
|
3
|
+
import { type JsonReply } from "./json-reply.js";
|
|
4
|
+
import { type CheckedControlRequest, type LegacyControlRequest } from "./legacy-request.js";
|
|
5
|
+
import { type Capabilities, type CpuState, type MemoryState, type SecretChange, type SecretsResult } from "./records.js";
|
|
6
|
+
/** Optional checked helpers only prepare records and decode replies; no SDK policy. */
|
|
7
|
+
export declare class GetCapabilities implements CheckedControlRequest<Capabilities> {
|
|
8
|
+
message(): EncodedMessage;
|
|
9
|
+
decode(frame: InboundFrame): Capabilities;
|
|
10
|
+
jsonRequest(): LegacyControlRequest;
|
|
11
|
+
decodeJson(reply: JsonReply): Capabilities;
|
|
12
|
+
}
|
|
13
|
+
export declare class GetMemoryState implements CheckedControlRequest<MemoryState> {
|
|
14
|
+
message(): EncodedMessage;
|
|
15
|
+
decode(frame: InboundFrame): MemoryState;
|
|
16
|
+
jsonRequest(): LegacyControlRequest;
|
|
17
|
+
decodeJson(reply: JsonReply): MemoryState;
|
|
18
|
+
}
|
|
19
|
+
export declare class SetMemoryTarget implements CheckedControlRequest<MemoryState> {
|
|
20
|
+
readonly total_mib: bigint;
|
|
21
|
+
/** Reuse SDK units; bigint also accepts a full-width wire quantity directly. */
|
|
22
|
+
constructor(size: Mebibytes | bigint);
|
|
23
|
+
message(): EncodedMessage;
|
|
24
|
+
decode(frame: InboundFrame): MemoryState;
|
|
25
|
+
jsonRequest(): LegacyControlRequest;
|
|
26
|
+
decodeJson(reply: JsonReply): MemoryState;
|
|
27
|
+
}
|
|
28
|
+
export declare class GetCpuState implements CheckedControlRequest<CpuState> {
|
|
29
|
+
message(): EncodedMessage;
|
|
30
|
+
decode(frame: InboundFrame): CpuState;
|
|
31
|
+
jsonRequest(): LegacyControlRequest;
|
|
32
|
+
decodeJson(reply: JsonReply): CpuState;
|
|
33
|
+
}
|
|
34
|
+
export declare class SetCpuTarget implements CheckedControlRequest<CpuState> {
|
|
35
|
+
readonly online: number;
|
|
36
|
+
constructor(online: number);
|
|
37
|
+
message(): EncodedMessage;
|
|
38
|
+
decode(frame: InboundFrame): CpuState;
|
|
39
|
+
jsonRequest(): LegacyControlRequest;
|
|
40
|
+
decodeJson(reply: JsonReply): CpuState;
|
|
41
|
+
}
|
|
42
|
+
export declare class UpdateSecrets implements CheckedControlRequest<SecretsResult> {
|
|
43
|
+
#private;
|
|
44
|
+
constructor(changes: readonly SecretChange[]);
|
|
45
|
+
message(): EncodedMessage;
|
|
46
|
+
jsonRequest(): LegacyControlRequest;
|
|
47
|
+
decodeJson(reply: JsonReply): SecretsResult;
|
|
48
|
+
decode(frame: InboundFrame): SecretsResult;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2C,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAChI,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EAAyC,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACxF,OAAO,EAAmB,KAAK,qBAAqB,EAAE,KAAK,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC7G,OAAO,EAGL,KAAK,YAAY,EAAE,KAAK,QAAQ,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,KAAK,aAAa,EAC1F,MAAM,cAAc,CAAC;AAct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qBAAqB,CAAC,aAAa,CAAC;;gBAE5D,OAAO,EAAE,SAAS,YAAY,EAAE;IAK5C,OAAO,IAAI,cAAc;IACzB,WAAW,IAAI,oBAAoB;IACnC,UAAU,CAAC,KAAK,EAAE,SAAS,GAAG,aAAa;IAG3C,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG,aAAa;CAO3C"}
|
package/dist/request.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { encodedMessage, encodeRecord, WireError } from "@microsandbox/protocol-client";
|
|
2
|
+
import { ControlClientError } from "./error.js";
|
|
3
|
+
import { jsonCapabilities, jsonCpu, jsonMemory } from "./json-reply.js";
|
|
4
|
+
import { snapshotChanges } from "./legacy-request.js";
|
|
5
|
+
import { CONTROL_GENERATION, checkedUint, decodeCapabilities, decodeControlError, decodeCpuState, decodeMemoryState, decodeSecretsResult, } from "./records.js";
|
|
6
|
+
function checked(frame, name, decode) {
|
|
7
|
+
const invalid = () => new ControlClientError("invalid_response", frame);
|
|
8
|
+
if (frame.protocolVersion !== CONTROL_GENERATION || frame.id === 0 || frame.flags !== 1)
|
|
9
|
+
throw invalid();
|
|
10
|
+
if (frame.type === "control.error") {
|
|
11
|
+
let error;
|
|
12
|
+
try {
|
|
13
|
+
error = decodeControlError(frame.payload);
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
throw invalid();
|
|
17
|
+
}
|
|
18
|
+
throw new ControlClientError("peer", frame, error);
|
|
19
|
+
}
|
|
20
|
+
if (frame.type !== name)
|
|
21
|
+
throw invalid();
|
|
22
|
+
try {
|
|
23
|
+
return decode(frame.payload);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
throw invalid();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/** Optional checked helpers only prepare records and decode replies; no SDK policy. */
|
|
30
|
+
export class GetCapabilities {
|
|
31
|
+
message() { return encodedMessage("control.capabilities", encodeRecord({})); }
|
|
32
|
+
decode(frame) { return checked(frame, "control.capabilities.result", decodeCapabilities); }
|
|
33
|
+
jsonRequest() { return { op: "capabilities" }; }
|
|
34
|
+
decodeJson(reply) { return reply.checked(value => jsonCapabilities(value.get("capabilities"))); }
|
|
35
|
+
}
|
|
36
|
+
export class GetMemoryState {
|
|
37
|
+
message() { return encodedMessage("control.memory.state", encodeRecord({})); }
|
|
38
|
+
decode(frame) { return checked(frame, "control.memory.state", decodeMemoryState); }
|
|
39
|
+
jsonRequest() { return { op: "memory_state" }; }
|
|
40
|
+
decodeJson(reply) { return reply.checked(value => jsonMemory(value.get("memory"))); }
|
|
41
|
+
}
|
|
42
|
+
export class SetMemoryTarget {
|
|
43
|
+
total_mib;
|
|
44
|
+
/** Reuse SDK units; bigint also accepts a full-width wire quantity directly. */
|
|
45
|
+
constructor(size) { this.total_mib = checkedUint(size, 64); }
|
|
46
|
+
message() { return encodedMessage("control.memory.target", encodeRecord({ total_mib: this.total_mib })); }
|
|
47
|
+
decode(frame) { return checked(frame, "control.memory.state", decodeMemoryState); }
|
|
48
|
+
jsonRequest() { return { op: "memory_target", total_mib: this.total_mib }; }
|
|
49
|
+
decodeJson(reply) { return new GetMemoryState().decodeJson(reply); }
|
|
50
|
+
}
|
|
51
|
+
export class GetCpuState {
|
|
52
|
+
message() { return encodedMessage("control.cpu.state", encodeRecord({})); }
|
|
53
|
+
decode(frame) { return checked(frame, "control.cpu.state", decodeCpuState); }
|
|
54
|
+
jsonRequest() { return { op: "cpu_state" }; }
|
|
55
|
+
decodeJson(reply) { return reply.checked(value => jsonCpu(value.get("cpu"))); }
|
|
56
|
+
}
|
|
57
|
+
export class SetCpuTarget {
|
|
58
|
+
online;
|
|
59
|
+
constructor(online) { this.online = Number(checkedUint(online, 32)); }
|
|
60
|
+
message() { return encodedMessage("control.cpu.target", encodeRecord({ online: this.online })); }
|
|
61
|
+
decode(frame) { return checked(frame, "control.cpu.state", decodeCpuState); }
|
|
62
|
+
jsonRequest() { return { op: "cpu_target", online: this.online }; }
|
|
63
|
+
decodeJson(reply) { return new GetCpuState().decodeJson(reply); }
|
|
64
|
+
}
|
|
65
|
+
export class UpdateSecrets {
|
|
66
|
+
#changes;
|
|
67
|
+
constructor(changes) {
|
|
68
|
+
// Snapshot the prepared batch so caller mutation cannot change the sent
|
|
69
|
+
// entries or invalidate interpretation of partial progress after admission.
|
|
70
|
+
this.#changes = snapshotChanges(changes);
|
|
71
|
+
}
|
|
72
|
+
message() { return encodedMessage("control.secrets.update", encodeRecord({ changes: this.#changes })); }
|
|
73
|
+
jsonRequest() { return { op: "secrets_update", changes: snapshotChanges(this.#changes) }; }
|
|
74
|
+
decodeJson(reply) {
|
|
75
|
+
return reply.checked(() => ({ outcome: "complete", applied_count: this.#changes.length }));
|
|
76
|
+
}
|
|
77
|
+
decode(frame) {
|
|
78
|
+
return checked(frame, "control.secrets.result", bytes => {
|
|
79
|
+
const result = decodeSecretsResult(bytes);
|
|
80
|
+
if (result.outcome === "complete" ? result.applied_count !== this.#changes.length : result.failed_index >= this.#changes.length)
|
|
81
|
+
throw new WireError("invalid_record");
|
|
82
|
+
return result;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../src/request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,SAAS,EAA0C,MAAM,+BAA+B,CAAC;AAEhI,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,UAAU,EAAkB,MAAM,iBAAiB,CAAC;AACxF,OAAO,EAAE,eAAe,EAAyD,MAAM,qBAAqB,CAAC;AAC7G,OAAO,EACL,kBAAkB,EAAE,WAAW,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,cAAc,EACvF,iBAAiB,EAAE,mBAAmB,GAEvC,MAAM,cAAc,CAAC;AAEt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;IAC3C,CAAC;IACD,OAAO,KAAqB,OAAO,cAAc,CAAC,wBAAwB,EAAE,YAAY,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACxH,WAAW,KAA2B,OAAO,EAAE,EAAE,EAAE,gBAAgB,EAAE,OAAO,EAAE,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;IACjH,UAAU,CAAC,KAAgB;QACzB,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAC7F,CAAC;IACD,MAAM,CAAC,KAAmB;QACxB,OAAO,OAAO,CAAC,KAAK,EAAE,wBAAwB,EAAE,KAAK,CAAC,EAAE;YACtD,MAAM,MAAM,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;YAC1C,IAAI,MAAM,CAAC,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,KAAK,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM;gBAAE,MAAM,IAAI,SAAS,CAAC,gBAAgB,CAAC,CAAC;YACvK,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@microsandbox/control-client",
|
|
3
|
+
"version": "0.7.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"engines": { "node": ">=22" },
|
|
7
|
+
"exports": {
|
|
8
|
+
".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" },
|
|
9
|
+
"./node": { "types": "./dist/node.d.ts", "import": "./dist/node.js" }
|
|
10
|
+
},
|
|
11
|
+
"files": ["dist", "README.md"],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc -p tsconfig.json",
|
|
14
|
+
"typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p tsconfig.test.json",
|
|
15
|
+
"test": "vitest run tests --no-file-parallelism"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@microsandbox/protocol-client": "0.7.0",
|
|
19
|
+
"@microsandbox/types": "0.7.0"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@types/node": "^25.5.2",
|
|
23
|
+
"typescript": "^5.6",
|
|
24
|
+
"vitest": "^4.1"
|
|
25
|
+
}
|
|
26
|
+
}
|