@slicervm/sdk 0.1.8 → 0.1.9
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 +10 -2
- package/dist/index.cjs +33 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -2
- package/dist/index.d.ts +23 -2
- package/dist/index.js +33 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -320,11 +320,31 @@ interface VMForkNetworkPolicy {
|
|
|
320
320
|
/** Omit to inherit; pass an empty array to clear the drop list. */
|
|
321
321
|
drop?: string[];
|
|
322
322
|
}
|
|
323
|
+
type VMForkWait = 'agent' | 'none';
|
|
324
|
+
type VMForkTagMode = 'append' | 'replace';
|
|
325
|
+
type VMForkFixup = 'hostname' | 'machine-id' | 'ssh-host-keys';
|
|
323
326
|
interface VMForkOptions {
|
|
324
|
-
/**
|
|
327
|
+
/**
|
|
328
|
+
* Defaults to agent. None acknowledges launch only; the daemon removes the
|
|
329
|
+
* child if requested asynchronous finalisation later fails.
|
|
330
|
+
*/
|
|
331
|
+
wait?: VMForkWait;
|
|
332
|
+
/** Server-side agent/finalisation timeout in seconds when waiting. */
|
|
325
333
|
waitTimeoutSec?: number;
|
|
326
334
|
network?: VMForkNetworkPolicy;
|
|
335
|
+
/** Omit to inherit tags; provided tags append unless tagMode is replace. */
|
|
327
336
|
tags?: string[];
|
|
337
|
+
tagMode?: VMForkTagMode;
|
|
338
|
+
/** Omit to inherit grants; pass an empty array to clear and blot secrets. */
|
|
339
|
+
secrets?: string[];
|
|
340
|
+
/** Defaults to true; false makes the fork ephemeral. */
|
|
341
|
+
persistent?: boolean;
|
|
342
|
+
/** Omit for all correctness fix-ups; pass an empty array to disable them. */
|
|
343
|
+
fixups?: VMForkFixup[];
|
|
344
|
+
/** Child vCPU count, up to the source host-group limit. */
|
|
345
|
+
vcpu?: number;
|
|
346
|
+
/** Child RAM in bytes, up to the source host-group limit. */
|
|
347
|
+
ramBytes?: number;
|
|
328
348
|
}
|
|
329
349
|
interface VMForkResponse {
|
|
330
350
|
hostname: string;
|
|
@@ -334,6 +354,7 @@ interface VMForkResponse {
|
|
|
334
354
|
parentStatus?: string;
|
|
335
355
|
childStatus?: string;
|
|
336
356
|
mode: string;
|
|
357
|
+
persistent?: boolean;
|
|
337
358
|
}
|
|
338
359
|
interface VMNetworkPolicy {
|
|
339
360
|
allow: string[];
|
|
@@ -1088,4 +1109,4 @@ declare class SlicerShellSession {
|
|
|
1088
1109
|
private teardown;
|
|
1089
1110
|
}
|
|
1090
1111
|
|
|
1091
|
-
export { type AddProxyAllowRequest, type AddressMapping, type AgentHealth, type BgDeleteResponse, type BgExecInfo, type BgExecRequest, type BgExecResponse, type BgKillOptions, type BgKillResponse, type BgLogOptions, type BgWaitExitResponse, CommitsAPI, CommittedVM, type CreateProxyClientOptions, type CreateProxySecretRequest, type CreateSecretRequest, type CreateVMNetworkPolicy, type CreateVMOptions, type CreateVMRequest, type CreateVMResponse, type DeleteResponse, type ExecFrame, type ExecRequest, type ExecResult, type ExecResultBinary, type ExecStdio, ExecStdioBase64, ExecStdioText, FRAME_TYPE_DATA, FRAME_TYPE_HEARTBEAT, FRAME_TYPE_SESSION_CLOSE, FRAME_TYPE_SHUTDOWN, FRAME_TYPE_WINDOW_SIZE, type FSEntry, type FSMkdirRequest, type FSWatchEvent, type FSWatchEventType, type FSWatchRequest, Forwarder, type ForwarderListener, type ForwarderOptions, GiB, type HostGroup, HostGroupsAPI, type ListOptions, MiB, NonRootUser, ProxyAPI, type ProxyAllowRule, ProxyAllowsAPI, type ProxyClient, type ProxyClientCreated, ProxyClientsAPI, type ProxySecret, ProxySecretBasic, ProxySecretBearer, ProxySecretOAuthClientCredentials, type ProxySecretType, ProxySecretsAPI, type RemoveProxyAllowByTupleRequest, type Secret, SecretExistsError, SecretsAPI, type ShellSessionOptions, type ShutdownRequest, SlicerAPIError, SlicerClient, type SlicerClientOptions, type SlicerInfo, SlicerShellSession, type UpdateSecretRequest, VM, VMBg, type VMCommitDeleteResponse, type VMCommitInfo, type VMCommitListOptions, type VMCommitOptions, type VMCommitResponse, type VMDescription, VMFileSystem, type VMForkNetworkPolicy, type VMForkOptions, type VMForkResponse, type VMInfo, type VMInit, type VMLogs, type VMNetworkDescription, type VMNetworkPolicy, type VMSnapshot, type VMStat, VMsAPI, type WaitOptions, type XTermLike, encodeFrame, parseAddressMapping, parseFrame, resolveTransport };
|
|
1112
|
+
export { type AddProxyAllowRequest, type AddressMapping, type AgentHealth, type BgDeleteResponse, type BgExecInfo, type BgExecRequest, type BgExecResponse, type BgKillOptions, type BgKillResponse, type BgLogOptions, type BgWaitExitResponse, CommitsAPI, CommittedVM, type CreateProxyClientOptions, type CreateProxySecretRequest, type CreateSecretRequest, type CreateVMNetworkPolicy, type CreateVMOptions, type CreateVMRequest, type CreateVMResponse, type DeleteResponse, type ExecFrame, type ExecRequest, type ExecResult, type ExecResultBinary, type ExecStdio, ExecStdioBase64, ExecStdioText, FRAME_TYPE_DATA, FRAME_TYPE_HEARTBEAT, FRAME_TYPE_SESSION_CLOSE, FRAME_TYPE_SHUTDOWN, FRAME_TYPE_WINDOW_SIZE, type FSEntry, type FSMkdirRequest, type FSWatchEvent, type FSWatchEventType, type FSWatchRequest, Forwarder, type ForwarderListener, type ForwarderOptions, GiB, type HostGroup, HostGroupsAPI, type ListOptions, MiB, NonRootUser, ProxyAPI, type ProxyAllowRule, ProxyAllowsAPI, type ProxyClient, type ProxyClientCreated, ProxyClientsAPI, type ProxySecret, ProxySecretBasic, ProxySecretBearer, ProxySecretOAuthClientCredentials, type ProxySecretType, ProxySecretsAPI, type RemoveProxyAllowByTupleRequest, type Secret, SecretExistsError, SecretsAPI, type ShellSessionOptions, type ShutdownRequest, SlicerAPIError, SlicerClient, type SlicerClientOptions, type SlicerInfo, SlicerShellSession, type UpdateSecretRequest, VM, VMBg, type VMCommitDeleteResponse, type VMCommitInfo, type VMCommitListOptions, type VMCommitOptions, type VMCommitResponse, type VMDescription, VMFileSystem, type VMForkFixup, type VMForkNetworkPolicy, type VMForkOptions, type VMForkResponse, type VMForkTagMode, type VMForkWait, type VMInfo, type VMInit, type VMLogs, type VMNetworkDescription, type VMNetworkPolicy, type VMSnapshot, type VMStat, VMsAPI, type WaitOptions, type XTermLike, encodeFrame, parseAddressMapping, parseFrame, resolveTransport };
|
package/dist/index.d.ts
CHANGED
|
@@ -320,11 +320,31 @@ interface VMForkNetworkPolicy {
|
|
|
320
320
|
/** Omit to inherit; pass an empty array to clear the drop list. */
|
|
321
321
|
drop?: string[];
|
|
322
322
|
}
|
|
323
|
+
type VMForkWait = 'agent' | 'none';
|
|
324
|
+
type VMForkTagMode = 'append' | 'replace';
|
|
325
|
+
type VMForkFixup = 'hostname' | 'machine-id' | 'ssh-host-keys';
|
|
323
326
|
interface VMForkOptions {
|
|
324
|
-
/**
|
|
327
|
+
/**
|
|
328
|
+
* Defaults to agent. None acknowledges launch only; the daemon removes the
|
|
329
|
+
* child if requested asynchronous finalisation later fails.
|
|
330
|
+
*/
|
|
331
|
+
wait?: VMForkWait;
|
|
332
|
+
/** Server-side agent/finalisation timeout in seconds when waiting. */
|
|
325
333
|
waitTimeoutSec?: number;
|
|
326
334
|
network?: VMForkNetworkPolicy;
|
|
335
|
+
/** Omit to inherit tags; provided tags append unless tagMode is replace. */
|
|
327
336
|
tags?: string[];
|
|
337
|
+
tagMode?: VMForkTagMode;
|
|
338
|
+
/** Omit to inherit grants; pass an empty array to clear and blot secrets. */
|
|
339
|
+
secrets?: string[];
|
|
340
|
+
/** Defaults to true; false makes the fork ephemeral. */
|
|
341
|
+
persistent?: boolean;
|
|
342
|
+
/** Omit for all correctness fix-ups; pass an empty array to disable them. */
|
|
343
|
+
fixups?: VMForkFixup[];
|
|
344
|
+
/** Child vCPU count, up to the source host-group limit. */
|
|
345
|
+
vcpu?: number;
|
|
346
|
+
/** Child RAM in bytes, up to the source host-group limit. */
|
|
347
|
+
ramBytes?: number;
|
|
328
348
|
}
|
|
329
349
|
interface VMForkResponse {
|
|
330
350
|
hostname: string;
|
|
@@ -334,6 +354,7 @@ interface VMForkResponse {
|
|
|
334
354
|
parentStatus?: string;
|
|
335
355
|
childStatus?: string;
|
|
336
356
|
mode: string;
|
|
357
|
+
persistent?: boolean;
|
|
337
358
|
}
|
|
338
359
|
interface VMNetworkPolicy {
|
|
339
360
|
allow: string[];
|
|
@@ -1088,4 +1109,4 @@ declare class SlicerShellSession {
|
|
|
1088
1109
|
private teardown;
|
|
1089
1110
|
}
|
|
1090
1111
|
|
|
1091
|
-
export { type AddProxyAllowRequest, type AddressMapping, type AgentHealth, type BgDeleteResponse, type BgExecInfo, type BgExecRequest, type BgExecResponse, type BgKillOptions, type BgKillResponse, type BgLogOptions, type BgWaitExitResponse, CommitsAPI, CommittedVM, type CreateProxyClientOptions, type CreateProxySecretRequest, type CreateSecretRequest, type CreateVMNetworkPolicy, type CreateVMOptions, type CreateVMRequest, type CreateVMResponse, type DeleteResponse, type ExecFrame, type ExecRequest, type ExecResult, type ExecResultBinary, type ExecStdio, ExecStdioBase64, ExecStdioText, FRAME_TYPE_DATA, FRAME_TYPE_HEARTBEAT, FRAME_TYPE_SESSION_CLOSE, FRAME_TYPE_SHUTDOWN, FRAME_TYPE_WINDOW_SIZE, type FSEntry, type FSMkdirRequest, type FSWatchEvent, type FSWatchEventType, type FSWatchRequest, Forwarder, type ForwarderListener, type ForwarderOptions, GiB, type HostGroup, HostGroupsAPI, type ListOptions, MiB, NonRootUser, ProxyAPI, type ProxyAllowRule, ProxyAllowsAPI, type ProxyClient, type ProxyClientCreated, ProxyClientsAPI, type ProxySecret, ProxySecretBasic, ProxySecretBearer, ProxySecretOAuthClientCredentials, type ProxySecretType, ProxySecretsAPI, type RemoveProxyAllowByTupleRequest, type Secret, SecretExistsError, SecretsAPI, type ShellSessionOptions, type ShutdownRequest, SlicerAPIError, SlicerClient, type SlicerClientOptions, type SlicerInfo, SlicerShellSession, type UpdateSecretRequest, VM, VMBg, type VMCommitDeleteResponse, type VMCommitInfo, type VMCommitListOptions, type VMCommitOptions, type VMCommitResponse, type VMDescription, VMFileSystem, type VMForkNetworkPolicy, type VMForkOptions, type VMForkResponse, type VMInfo, type VMInit, type VMLogs, type VMNetworkDescription, type VMNetworkPolicy, type VMSnapshot, type VMStat, VMsAPI, type WaitOptions, type XTermLike, encodeFrame, parseAddressMapping, parseFrame, resolveTransport };
|
|
1112
|
+
export { type AddProxyAllowRequest, type AddressMapping, type AgentHealth, type BgDeleteResponse, type BgExecInfo, type BgExecRequest, type BgExecResponse, type BgKillOptions, type BgKillResponse, type BgLogOptions, type BgWaitExitResponse, CommitsAPI, CommittedVM, type CreateProxyClientOptions, type CreateProxySecretRequest, type CreateSecretRequest, type CreateVMNetworkPolicy, type CreateVMOptions, type CreateVMRequest, type CreateVMResponse, type DeleteResponse, type ExecFrame, type ExecRequest, type ExecResult, type ExecResultBinary, type ExecStdio, ExecStdioBase64, ExecStdioText, FRAME_TYPE_DATA, FRAME_TYPE_HEARTBEAT, FRAME_TYPE_SESSION_CLOSE, FRAME_TYPE_SHUTDOWN, FRAME_TYPE_WINDOW_SIZE, type FSEntry, type FSMkdirRequest, type FSWatchEvent, type FSWatchEventType, type FSWatchRequest, Forwarder, type ForwarderListener, type ForwarderOptions, GiB, type HostGroup, HostGroupsAPI, type ListOptions, MiB, NonRootUser, ProxyAPI, type ProxyAllowRule, ProxyAllowsAPI, type ProxyClient, type ProxyClientCreated, ProxyClientsAPI, type ProxySecret, ProxySecretBasic, ProxySecretBearer, ProxySecretOAuthClientCredentials, type ProxySecretType, ProxySecretsAPI, type RemoveProxyAllowByTupleRequest, type Secret, SecretExistsError, SecretsAPI, type ShellSessionOptions, type ShutdownRequest, SlicerAPIError, SlicerClient, type SlicerClientOptions, type SlicerInfo, SlicerShellSession, type UpdateSecretRequest, VM, VMBg, type VMCommitDeleteResponse, type VMCommitInfo, type VMCommitListOptions, type VMCommitOptions, type VMCommitResponse, type VMDescription, VMFileSystem, type VMForkFixup, type VMForkNetworkPolicy, type VMForkOptions, type VMForkResponse, type VMForkTagMode, type VMForkWait, type VMInfo, type VMInit, type VMLogs, type VMNetworkDescription, type VMNetworkPolicy, type VMSnapshot, type VMStat, VMsAPI, type WaitOptions, type XTermLike, encodeFrame, parseAddressMapping, parseFrame, resolveTransport };
|
package/dist/index.js
CHANGED
|
@@ -312,7 +312,8 @@ function vmForkFromWire(w) {
|
|
|
312
312
|
status: w.status,
|
|
313
313
|
...w.parent_status !== void 0 && { parentStatus: w.parent_status },
|
|
314
314
|
...w.child_status !== void 0 && { childStatus: w.child_status },
|
|
315
|
-
mode: w.mode ?? ""
|
|
315
|
+
mode: w.mode ?? "",
|
|
316
|
+
...w.persistent !== void 0 && { persistent: w.persistent }
|
|
316
317
|
};
|
|
317
318
|
}
|
|
318
319
|
function vmDescriptionFromWire(w) {
|
|
@@ -362,6 +363,31 @@ function secretFromWire(w) {
|
|
|
362
363
|
...w.modified_at !== void 0 && { modifiedAt: w.modified_at }
|
|
363
364
|
};
|
|
364
365
|
}
|
|
366
|
+
|
|
367
|
+
// src/fork.ts
|
|
368
|
+
function buildForkRequest(opts) {
|
|
369
|
+
const wait = opts.wait ?? "agent";
|
|
370
|
+
if (wait !== "agent" && wait !== "none") {
|
|
371
|
+
throw new Error(`invalid fork wait mode ${JSON.stringify(wait)}`);
|
|
372
|
+
}
|
|
373
|
+
const query = new URLSearchParams({ wait });
|
|
374
|
+
if (opts.waitTimeoutSec !== void 0 && opts.waitTimeoutSec > 0) {
|
|
375
|
+
query.set("timeout", `${opts.waitTimeoutSec}s`);
|
|
376
|
+
}
|
|
377
|
+
const body = {};
|
|
378
|
+
if (opts.network !== void 0) body.network = opts.network;
|
|
379
|
+
if (opts.tags !== void 0) body.tags = opts.tags;
|
|
380
|
+
if (opts.tagMode !== void 0) body.tag_mode = opts.tagMode;
|
|
381
|
+
if (opts.secrets !== void 0) body.secrets = opts.secrets;
|
|
382
|
+
if (opts.persistent !== void 0) body.persistent = opts.persistent;
|
|
383
|
+
if (opts.fixups !== void 0) body.fixups = opts.fixups;
|
|
384
|
+
if (opts.vcpu !== void 0) body.vcpu = opts.vcpu;
|
|
385
|
+
if (opts.ramBytes !== void 0) body.ram_bytes = opts.ramBytes;
|
|
386
|
+
return {
|
|
387
|
+
query: query.toString(),
|
|
388
|
+
...Object.keys(body).length > 0 && { body }
|
|
389
|
+
};
|
|
390
|
+
}
|
|
365
391
|
function looksLikeUnixSocketPath(s) {
|
|
366
392
|
if (!s) return false;
|
|
367
393
|
return s.startsWith("/") || s.startsWith("./") || s.startsWith("../") || s.includes("/");
|
|
@@ -1087,20 +1113,11 @@ function errMsg(e) {
|
|
|
1087
1113
|
}
|
|
1088
1114
|
async function forkPath(transport, commitId, opts) {
|
|
1089
1115
|
const id = validateCommitId(commitId);
|
|
1090
|
-
const
|
|
1091
|
-
q.set("wait", "agent");
|
|
1092
|
-
if (opts.waitTimeoutSec !== void 0 && opts.waitTimeoutSec > 0) {
|
|
1093
|
-
q.set("timeout", `${opts.waitTimeoutSec}s`);
|
|
1094
|
-
}
|
|
1095
|
-
const query = q.toString() ? `?${q.toString()}` : "";
|
|
1096
|
-
const body = opts.network !== void 0 || (opts.tags?.length ?? 0) > 0 ? {
|
|
1097
|
-
...opts.network !== void 0 && { network: opts.network },
|
|
1098
|
-
...(opts.tags?.length ?? 0) > 0 && { tags: opts.tags }
|
|
1099
|
-
} : void 0;
|
|
1116
|
+
const request = buildForkRequest(opts);
|
|
1100
1117
|
const wire = await transport.request(
|
|
1101
1118
|
"POST",
|
|
1102
|
-
`/vm/commits/${encodeURIComponent(id)}/fork
|
|
1103
|
-
body
|
|
1119
|
+
`/vm/commits/${encodeURIComponent(id)}/fork?${request.query}`,
|
|
1120
|
+
request.body
|
|
1104
1121
|
);
|
|
1105
1122
|
return vmForkFromWire(wire);
|
|
1106
1123
|
}
|
|
@@ -1401,18 +1418,11 @@ var CommitsAPI = class {
|
|
|
1401
1418
|
}
|
|
1402
1419
|
async fork(commitId, opts = {}) {
|
|
1403
1420
|
const id = validateCommitId2(commitId);
|
|
1404
|
-
const
|
|
1405
|
-
if (opts.waitTimeoutSec !== void 0 && opts.waitTimeoutSec > 0) {
|
|
1406
|
-
qs.set("timeout", `${opts.waitTimeoutSec}s`);
|
|
1407
|
-
}
|
|
1408
|
-
const body = opts.network !== void 0 || (opts.tags?.length ?? 0) > 0 ? {
|
|
1409
|
-
...opts.network !== void 0 && { network: opts.network },
|
|
1410
|
-
...(opts.tags?.length ?? 0) > 0 && { tags: opts.tags }
|
|
1411
|
-
} : void 0;
|
|
1421
|
+
const request = buildForkRequest(opts);
|
|
1412
1422
|
const wire = await this.transport.request(
|
|
1413
1423
|
"POST",
|
|
1414
|
-
`/vm/commits/${encodeURIComponent(id)}/fork?${
|
|
1415
|
-
body
|
|
1424
|
+
`/vm/commits/${encodeURIComponent(id)}/fork?${request.query}`,
|
|
1425
|
+
request.body
|
|
1416
1426
|
);
|
|
1417
1427
|
return vmForkFromWire(wire);
|
|
1418
1428
|
}
|