@insforge/instabox-sdk 0.3.0 → 0.4.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 +12 -19
- package/dist/index.cjs +1 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -35
- package/dist/index.d.ts +4 -35
- package/dist/index.js +1 -29
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/skills/instabox/SKILL.md +11 -11
package/dist/index.d.cts
CHANGED
|
@@ -79,10 +79,6 @@ interface Machine {
|
|
|
79
79
|
snapshot?: {
|
|
80
80
|
id: string;
|
|
81
81
|
};
|
|
82
|
-
forkedFrom?: {
|
|
83
|
-
machineId: string;
|
|
84
|
-
snapshotSeq: number;
|
|
85
|
-
};
|
|
86
82
|
spec: MachineSpec;
|
|
87
83
|
storage: {
|
|
88
84
|
sizeGiB: number;
|
|
@@ -162,7 +158,7 @@ interface MachineList {
|
|
|
162
158
|
interface Operation {
|
|
163
159
|
id: string;
|
|
164
160
|
machineId: string;
|
|
165
|
-
type: 'create' | 'start' | 'stop' | 'suspend' | 'resume' | 'delete'
|
|
161
|
+
type: 'create' | 'start' | 'stop' | 'suspend' | 'resume' | 'delete';
|
|
166
162
|
state: 'queued' | 'running' | 'succeeded' | 'failed';
|
|
167
163
|
phase?: string;
|
|
168
164
|
error: ApiError | null;
|
|
@@ -232,7 +228,7 @@ interface ConnectionOptions {
|
|
|
232
228
|
apiUrl?: string;
|
|
233
229
|
/** Timeout of a single HTTP request in ms. Default 60 000; exec defaults to its command timeout plus 30 000. */
|
|
234
230
|
requestTimeoutMs?: number;
|
|
235
|
-
/** Max time to wait for a lifecycle operation (create, pause, resume,
|
|
231
|
+
/** Max time to wait for a lifecycle operation (create, pause, resume, kill) in ms. Default 600 000. */
|
|
236
232
|
operationTimeoutMs?: number;
|
|
237
233
|
/** Custom fetch implementation (tests, proxies). Default: global `fetch`. */
|
|
238
234
|
fetch?: typeof fetch;
|
|
@@ -515,31 +511,6 @@ interface SandboxInfo {
|
|
|
515
511
|
/** The raw machine object from the API. */
|
|
516
512
|
machine: Machine;
|
|
517
513
|
}
|
|
518
|
-
interface ForkOpts {
|
|
519
|
-
/** Name of the new sandbox. Default `<name>-fork-<random>`. */
|
|
520
|
-
name?: string;
|
|
521
|
-
vcpus?: number;
|
|
522
|
-
memMiB?: number;
|
|
523
|
-
/** May only grow. */
|
|
524
|
-
diskGiB?: number;
|
|
525
|
-
/** Root disk size in GiB; may only grow. */
|
|
526
|
-
rootDiskGiB?: number;
|
|
527
|
-
/** Timeout of the copy, as in `SandboxOpts.timeoutMs`. Default: none (the source's is not copied). */
|
|
528
|
-
timeoutMs?: number;
|
|
529
|
-
onTimeout?: OnTimeout;
|
|
530
|
-
/** Idle pause of the copy, as in `SandboxOpts.autoSuspendMs`. Default: 30 minutes (the source's is not copied); `0`: never. */
|
|
531
|
-
autoSuspendMs?: number;
|
|
532
|
-
/** Metadata of the copy. Default: the source's; `{}` for none. */
|
|
533
|
-
metadata?: Record<string, string>;
|
|
534
|
-
/** `false`: the copy never gets the account's Vault items (a copy of a sandbox without the Vault never does). */
|
|
535
|
-
vault?: boolean;
|
|
536
|
-
/**
|
|
537
|
-
* A fork needs a stopped source. When true (default), `fork()` stops the source first if needed
|
|
538
|
-
* (running processes end, `/data` is kept) and leaves it stopped; call `resume()` to start it again.
|
|
539
|
-
* When false, a source that is not stopped makes the call fail.
|
|
540
|
-
*/
|
|
541
|
-
stopSource?: boolean;
|
|
542
|
-
}
|
|
543
514
|
interface CreateSnapshotOpts {
|
|
544
515
|
name: string;
|
|
545
516
|
description?: string;
|
|
@@ -641,8 +612,6 @@ declare class Sandbox {
|
|
|
641
612
|
private wake;
|
|
642
613
|
/** Stops the sandbox (guest shutdown; processes end, `/data` is kept). */
|
|
643
614
|
stop(): Promise<void>;
|
|
644
|
-
/** Copies this sandbox (root disk and `/data`) into a new sandbox and waits until it runs. */
|
|
645
|
-
fork(opts?: ForkOpts): Promise<Sandbox>;
|
|
646
615
|
/** Deletes the sandbox and its disks. Returns false if it was already gone. */
|
|
647
616
|
kill(): Promise<boolean>;
|
|
648
617
|
/**
|
|
@@ -662,7 +631,7 @@ declare class Sandbox {
|
|
|
662
631
|
private settle;
|
|
663
632
|
/**
|
|
664
633
|
* Waits until a stopped sandbox's disks are in object storage (`storage.synced`). A stop returns
|
|
665
|
-
* once the host has the snapshot and uploads it after, so a
|
|
634
|
+
* once the host has the snapshot and uploads it after, so a snapshot right after a stop
|
|
666
635
|
* was refused ("not uploaded to object storage"), which took long enough after a pause and resume
|
|
667
636
|
* to fail every time. Only a stopped sandbox is waited for; the server says what else is wrong.
|
|
668
637
|
*/
|
|
@@ -670,4 +639,4 @@ declare class Sandbox {
|
|
|
670
639
|
private mutate;
|
|
671
640
|
}
|
|
672
641
|
|
|
673
|
-
export { type ApiError, CommandExitError, type CommandHandle, type CommandOptions, type CommandResult, Commands, type Connection, type ConnectionOptions, type CreateSnapshotOpts, DEFAULT_API_URL, DEFAULT_TEMPLATE, DESKTOP_DISPLAY, Desktop, type DesktopStatus, type DesktopStream, type EntryInfo, type ExecResponse, FALLBACK_TEMPLATE, Files, type
|
|
642
|
+
export { type ApiError, CommandExitError, type CommandHandle, type CommandOptions, type CommandResult, Commands, type Connection, type ConnectionOptions, type CreateSnapshotOpts, DEFAULT_API_URL, DEFAULT_TEMPLATE, DESKTOP_DISPLAY, Desktop, type DesktopStatus, type DesktopStream, type EntryInfo, type ExecResponse, FALLBACK_TEMPLATE, Files, type HostTrust, InstaboxAuthError, InstaboxError, type InstaboxErrorInit, InstaboxQuotaError, InstaboxTimeoutError, MAX_FILE_BYTES, MAX_STDIN_BYTES, type Machine, type MachineList, type MachineSpec, type MachineState, type MachineVault, type MachineVaultItem, type MouseButton, type OnTimeout, type Operation, Sandbox, type SandboxConnectOpts, type SandboxInfo, type SandboxListOpts, type SandboxOpts, type ScrollDirection, type Snapshot, type SnapshotList, type SshCredentials, type Template, type TemplateRef, type VaultApplied, type VaultFile, type VaultKept, type WriteInfo };
|
package/dist/index.d.ts
CHANGED
|
@@ -79,10 +79,6 @@ interface Machine {
|
|
|
79
79
|
snapshot?: {
|
|
80
80
|
id: string;
|
|
81
81
|
};
|
|
82
|
-
forkedFrom?: {
|
|
83
|
-
machineId: string;
|
|
84
|
-
snapshotSeq: number;
|
|
85
|
-
};
|
|
86
82
|
spec: MachineSpec;
|
|
87
83
|
storage: {
|
|
88
84
|
sizeGiB: number;
|
|
@@ -162,7 +158,7 @@ interface MachineList {
|
|
|
162
158
|
interface Operation {
|
|
163
159
|
id: string;
|
|
164
160
|
machineId: string;
|
|
165
|
-
type: 'create' | 'start' | 'stop' | 'suspend' | 'resume' | 'delete'
|
|
161
|
+
type: 'create' | 'start' | 'stop' | 'suspend' | 'resume' | 'delete';
|
|
166
162
|
state: 'queued' | 'running' | 'succeeded' | 'failed';
|
|
167
163
|
phase?: string;
|
|
168
164
|
error: ApiError | null;
|
|
@@ -232,7 +228,7 @@ interface ConnectionOptions {
|
|
|
232
228
|
apiUrl?: string;
|
|
233
229
|
/** Timeout of a single HTTP request in ms. Default 60 000; exec defaults to its command timeout plus 30 000. */
|
|
234
230
|
requestTimeoutMs?: number;
|
|
235
|
-
/** Max time to wait for a lifecycle operation (create, pause, resume,
|
|
231
|
+
/** Max time to wait for a lifecycle operation (create, pause, resume, kill) in ms. Default 600 000. */
|
|
236
232
|
operationTimeoutMs?: number;
|
|
237
233
|
/** Custom fetch implementation (tests, proxies). Default: global `fetch`. */
|
|
238
234
|
fetch?: typeof fetch;
|
|
@@ -515,31 +511,6 @@ interface SandboxInfo {
|
|
|
515
511
|
/** The raw machine object from the API. */
|
|
516
512
|
machine: Machine;
|
|
517
513
|
}
|
|
518
|
-
interface ForkOpts {
|
|
519
|
-
/** Name of the new sandbox. Default `<name>-fork-<random>`. */
|
|
520
|
-
name?: string;
|
|
521
|
-
vcpus?: number;
|
|
522
|
-
memMiB?: number;
|
|
523
|
-
/** May only grow. */
|
|
524
|
-
diskGiB?: number;
|
|
525
|
-
/** Root disk size in GiB; may only grow. */
|
|
526
|
-
rootDiskGiB?: number;
|
|
527
|
-
/** Timeout of the copy, as in `SandboxOpts.timeoutMs`. Default: none (the source's is not copied). */
|
|
528
|
-
timeoutMs?: number;
|
|
529
|
-
onTimeout?: OnTimeout;
|
|
530
|
-
/** Idle pause of the copy, as in `SandboxOpts.autoSuspendMs`. Default: 30 minutes (the source's is not copied); `0`: never. */
|
|
531
|
-
autoSuspendMs?: number;
|
|
532
|
-
/** Metadata of the copy. Default: the source's; `{}` for none. */
|
|
533
|
-
metadata?: Record<string, string>;
|
|
534
|
-
/** `false`: the copy never gets the account's Vault items (a copy of a sandbox without the Vault never does). */
|
|
535
|
-
vault?: boolean;
|
|
536
|
-
/**
|
|
537
|
-
* A fork needs a stopped source. When true (default), `fork()` stops the source first if needed
|
|
538
|
-
* (running processes end, `/data` is kept) and leaves it stopped; call `resume()` to start it again.
|
|
539
|
-
* When false, a source that is not stopped makes the call fail.
|
|
540
|
-
*/
|
|
541
|
-
stopSource?: boolean;
|
|
542
|
-
}
|
|
543
514
|
interface CreateSnapshotOpts {
|
|
544
515
|
name: string;
|
|
545
516
|
description?: string;
|
|
@@ -641,8 +612,6 @@ declare class Sandbox {
|
|
|
641
612
|
private wake;
|
|
642
613
|
/** Stops the sandbox (guest shutdown; processes end, `/data` is kept). */
|
|
643
614
|
stop(): Promise<void>;
|
|
644
|
-
/** Copies this sandbox (root disk and `/data`) into a new sandbox and waits until it runs. */
|
|
645
|
-
fork(opts?: ForkOpts): Promise<Sandbox>;
|
|
646
615
|
/** Deletes the sandbox and its disks. Returns false if it was already gone. */
|
|
647
616
|
kill(): Promise<boolean>;
|
|
648
617
|
/**
|
|
@@ -662,7 +631,7 @@ declare class Sandbox {
|
|
|
662
631
|
private settle;
|
|
663
632
|
/**
|
|
664
633
|
* Waits until a stopped sandbox's disks are in object storage (`storage.synced`). A stop returns
|
|
665
|
-
* once the host has the snapshot and uploads it after, so a
|
|
634
|
+
* once the host has the snapshot and uploads it after, so a snapshot right after a stop
|
|
666
635
|
* was refused ("not uploaded to object storage"), which took long enough after a pause and resume
|
|
667
636
|
* to fail every time. Only a stopped sandbox is waited for; the server says what else is wrong.
|
|
668
637
|
*/
|
|
@@ -670,4 +639,4 @@ declare class Sandbox {
|
|
|
670
639
|
private mutate;
|
|
671
640
|
}
|
|
672
641
|
|
|
673
|
-
export { type ApiError, CommandExitError, type CommandHandle, type CommandOptions, type CommandResult, Commands, type Connection, type ConnectionOptions, type CreateSnapshotOpts, DEFAULT_API_URL, DEFAULT_TEMPLATE, DESKTOP_DISPLAY, Desktop, type DesktopStatus, type DesktopStream, type EntryInfo, type ExecResponse, FALLBACK_TEMPLATE, Files, type
|
|
642
|
+
export { type ApiError, CommandExitError, type CommandHandle, type CommandOptions, type CommandResult, Commands, type Connection, type ConnectionOptions, type CreateSnapshotOpts, DEFAULT_API_URL, DEFAULT_TEMPLATE, DESKTOP_DISPLAY, Desktop, type DesktopStatus, type DesktopStream, type EntryInfo, type ExecResponse, FALLBACK_TEMPLATE, Files, type HostTrust, InstaboxAuthError, InstaboxError, type InstaboxErrorInit, InstaboxQuotaError, InstaboxTimeoutError, MAX_FILE_BYTES, MAX_STDIN_BYTES, type Machine, type MachineList, type MachineSpec, type MachineState, type MachineVault, type MachineVaultItem, type MouseButton, type OnTimeout, type Operation, Sandbox, type SandboxConnectOpts, type SandboxInfo, type SandboxListOpts, type SandboxOpts, type ScrollDirection, type Snapshot, type SnapshotList, type SshCredentials, type Template, type TemplateRef, type VaultApplied, type VaultFile, type VaultKept, type WriteInfo };
|
package/dist/index.js
CHANGED
|
@@ -899,34 +899,6 @@ var Sandbox = class _Sandbox {
|
|
|
899
899
|
if (this.machine.state === "suspended") await this.mutate("POST", "start");
|
|
900
900
|
await this.mutate("POST", "stop");
|
|
901
901
|
}
|
|
902
|
-
/** Copies this sandbox (root disk and `/data`) into a new sandbox and waits until it runs. */
|
|
903
|
-
async fork(opts = {}) {
|
|
904
|
-
if (opts.timeoutMs !== void 0) toSeconds(opts.timeoutMs);
|
|
905
|
-
if (opts.autoSuspendMs !== void 0) toIdleSeconds(opts.autoSuspendMs);
|
|
906
|
-
await this.settle();
|
|
907
|
-
if (this.machine.state !== "stopped") {
|
|
908
|
-
if (opts.stopSource === false) {
|
|
909
|
-
throw new InstaboxError(`fork needs a stopped sandbox; ${this.sandboxId} is ${this.machine.state}`, {
|
|
910
|
-
code: "operation_conflict"
|
|
911
|
-
});
|
|
912
|
-
}
|
|
913
|
-
await this.stop();
|
|
914
|
-
}
|
|
915
|
-
await this.untilSynced();
|
|
916
|
-
const body = { name: opts.name ?? `${this.machine.name}-fork-${randomSuffix(4)}` };
|
|
917
|
-
if (opts.vcpus !== void 0) body.vcpus = opts.vcpus;
|
|
918
|
-
if (opts.memMiB !== void 0) body.memMiB = opts.memMiB;
|
|
919
|
-
if (opts.diskGiB !== void 0) body.persistentDiskGiB = opts.diskGiB;
|
|
920
|
-
if (opts.rootDiskGiB !== void 0) body.rootDiskGiB = opts.rootDiskGiB;
|
|
921
|
-
if (opts.timeoutMs !== void 0) body.timeoutSeconds = toSeconds(opts.timeoutMs);
|
|
922
|
-
if (opts.onTimeout) body.onTimeout = opts.onTimeout;
|
|
923
|
-
if (opts.autoSuspendMs !== void 0) body.autoSuspendAfterSeconds = toIdleSeconds(opts.autoSuspendMs);
|
|
924
|
-
if (opts.metadata) body.metadata = opts.metadata;
|
|
925
|
-
if (opts.vault === false) body.vault = false;
|
|
926
|
-
const op = await this.http.request("POST", `/v1/machines/${enc2(this.sandboxId)}/fork`, { body });
|
|
927
|
-
const done = await this.http.waitForOperation(op);
|
|
928
|
-
return new _Sandbox(this.http, await getMachine(this.http, done.machineId));
|
|
929
|
-
}
|
|
930
902
|
/** Deletes the sandbox and its disks. Returns false if it was already gone. */
|
|
931
903
|
async kill() {
|
|
932
904
|
return killMachine(this.http, this.sandboxId);
|
|
@@ -973,7 +945,7 @@ var Sandbox = class _Sandbox {
|
|
|
973
945
|
}
|
|
974
946
|
/**
|
|
975
947
|
* Waits until a stopped sandbox's disks are in object storage (`storage.synced`). A stop returns
|
|
976
|
-
* once the host has the snapshot and uploads it after, so a
|
|
948
|
+
* once the host has the snapshot and uploads it after, so a snapshot right after a stop
|
|
977
949
|
* was refused ("not uploaded to object storage"), which took long enough after a pause and resume
|
|
978
950
|
* to fail every time. Only a stopped sandbox is waited for; the server says what else is wrong.
|
|
979
951
|
*/
|