@hotcell/daemon 0.1.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/dist/agent-check.d.ts +1 -0
- package/dist/agent-check.js +105 -0
- package/dist/agent-check.js.map +1 -0
- package/dist/api/server.d.ts +64 -0
- package/dist/api/server.js +1368 -0
- package/dist/api/server.js.map +1 -0
- package/dist/api/ws.d.ts +14 -0
- package/dist/api/ws.js +214 -0
- package/dist/api/ws.js.map +1 -0
- package/dist/applevz-check.d.ts +1 -0
- package/dist/applevz-check.js +280 -0
- package/dist/applevz-check.js.map +1 -0
- package/dist/backups.d.ts +29 -0
- package/dist/backups.js +76 -0
- package/dist/backups.js.map +1 -0
- package/dist/capacity.d.ts +63 -0
- package/dist/capacity.js +95 -0
- package/dist/capacity.js.map +1 -0
- package/dist/config.d.ts +241 -0
- package/dist/config.js +152 -0
- package/dist/config.js.map +1 -0
- package/dist/cost.d.ts +9 -0
- package/dist/cost.js +19 -0
- package/dist/cost.js.map +1 -0
- package/dist/density-bench.d.ts +1 -0
- package/dist/density-bench.js +97 -0
- package/dist/density-bench.js.map +1 -0
- package/dist/driver/agent-driver.d.ts +67 -0
- package/dist/driver/agent-driver.js +197 -0
- package/dist/driver/agent-driver.js.map +1 -0
- package/dist/driver/agent.d.ts +94 -0
- package/dist/driver/agent.js +319 -0
- package/dist/driver/agent.js.map +1 -0
- package/dist/driver/applevz.d.ts +95 -0
- package/dist/driver/applevz.js +527 -0
- package/dist/driver/applevz.js.map +1 -0
- package/dist/driver/container.d.ts +99 -0
- package/dist/driver/container.js +733 -0
- package/dist/driver/container.js.map +1 -0
- package/dist/driver/fc-api.d.ts +85 -0
- package/dist/driver/fc-api.js +173 -0
- package/dist/driver/fc-api.js.map +1 -0
- package/dist/driver/firecracker.d.ts +126 -0
- package/dist/driver/firecracker.js +560 -0
- package/dist/driver/firecracker.js.map +1 -0
- package/dist/driver/index.d.ts +17 -0
- package/dist/driver/index.js +61 -0
- package/dist/driver/index.js.map +1 -0
- package/dist/driver/router.d.ts +82 -0
- package/dist/driver/router.js +159 -0
- package/dist/driver/router.js.map +1 -0
- package/dist/driver/types.d.ts +234 -0
- package/dist/driver/types.js +2 -0
- package/dist/driver/types.js.map +1 -0
- package/dist/driver/unsupported.d.ts +50 -0
- package/dist/driver/unsupported.js +81 -0
- package/dist/driver/unsupported.js.map +1 -0
- package/dist/driver/vz-image.d.ts +35 -0
- package/dist/driver/vz-image.js +75 -0
- package/dist/driver/vz-image.js.map +1 -0
- package/dist/e2e-harness.d.ts +1 -0
- package/dist/e2e-harness.js +99 -0
- package/dist/e2e-harness.js.map +1 -0
- package/dist/egress-check.d.ts +8 -0
- package/dist/egress-check.js +317 -0
- package/dist/egress-check.js.map +1 -0
- package/dist/fc-check.d.ts +1 -0
- package/dist/fc-check.js +113 -0
- package/dist/fc-check.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +114 -0
- package/dist/index.js.map +1 -0
- package/dist/kernels.d.ts +22 -0
- package/dist/kernels.js +134 -0
- package/dist/kernels.js.map +1 -0
- package/dist/lifecycle.d.ts +49 -0
- package/dist/lifecycle.js +111 -0
- package/dist/lifecycle.js.map +1 -0
- package/dist/logger.d.ts +16 -0
- package/dist/logger.js +67 -0
- package/dist/logger.js.map +1 -0
- package/dist/metrics.d.ts +46 -0
- package/dist/metrics.js +92 -0
- package/dist/metrics.js.map +1 -0
- package/dist/net/firewall.d.ts +4 -0
- package/dist/net/firewall.js +80 -0
- package/dist/net/firewall.js.map +1 -0
- package/dist/pricing.d.ts +36 -0
- package/dist/pricing.js +81 -0
- package/dist/pricing.js.map +1 -0
- package/dist/proxy/allowlist-default.d.ts +23 -0
- package/dist/proxy/allowlist-default.js +53 -0
- package/dist/proxy/allowlist-default.js.map +1 -0
- package/dist/proxy/allowlist.d.ts +43 -0
- package/dist/proxy/allowlist.js +87 -0
- package/dist/proxy/allowlist.js.map +1 -0
- package/dist/proxy/egress.d.ts +49 -0
- package/dist/proxy/egress.js +599 -0
- package/dist/proxy/egress.js.map +1 -0
- package/dist/proxy/ratelimit.d.ts +49 -0
- package/dist/proxy/ratelimit.js +74 -0
- package/dist/proxy/ratelimit.js.map +1 -0
- package/dist/proxy/server.d.ts +26 -0
- package/dist/proxy/server.js +202 -0
- package/dist/proxy/server.js.map +1 -0
- package/dist/router-check.d.ts +1 -0
- package/dist/router-check.js +97 -0
- package/dist/router-check.js.map +1 -0
- package/dist/smoke-fc.d.ts +1 -0
- package/dist/smoke-fc.js +183 -0
- package/dist/smoke-fc.js.map +1 -0
- package/dist/smoke-microvm.d.ts +1 -0
- package/dist/smoke-microvm.js +187 -0
- package/dist/smoke-microvm.js.map +1 -0
- package/dist/smoke-remote.d.ts +20 -0
- package/dist/smoke-remote.js +155 -0
- package/dist/smoke-remote.js.map +1 -0
- package/dist/smoke-vz.d.ts +1 -0
- package/dist/smoke-vz.js +161 -0
- package/dist/smoke-vz.js.map +1 -0
- package/dist/smoke.d.ts +7 -0
- package/dist/smoke.js +962 -0
- package/dist/smoke.js.map +1 -0
- package/dist/store.d.ts +124 -0
- package/dist/store.js +578 -0
- package/dist/store.js.map +1 -0
- package/dist/tracing.d.ts +45 -0
- package/dist/tracing.js +144 -0
- package/dist/tracing.js.map +1 -0
- package/dist/types.d.ts +274 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/util.d.ts +27 -0
- package/dist/util.js +63 -0
- package/dist/util.js.map +1 -0
- package/dist/warmpool-check.d.ts +1 -0
- package/dist/warmpool-check.js +83 -0
- package/dist/warmpool-check.js.map +1 -0
- package/dist/web/dashboard.d.ts +1 -0
- package/dist/web/dashboard.js +456 -0
- package/dist/web/dashboard.js.map +1 -0
- package/package.json +53 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import Docker from "dockerode";
|
|
2
|
+
import type { ExecEvent, ExecOptions, FileChangeEvent, FileInfo, ListFilesOptions, MkdirOptions, ReadFileOptions, StartProcessOptions, WaitForPortOptions, WatchOptions, WriteFileOptions } from "../types.js";
|
|
3
|
+
import type { CreateOptions, Driver, ProcessLiveness, HostInfo, SandboxStats, StartProcessResult, TcpBridge, TerminalOptions, TerminalSession } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Container driver — backs each sandbox with a long-lived OCI container via the
|
|
6
|
+
* Docker Engine API. Maximum density and works identically on Linux and macOS
|
|
7
|
+
* (Docker Desktop / colima / Apple `container`'s Docker-compatible endpoint).
|
|
8
|
+
*
|
|
9
|
+
* The container is named deterministically from the sandbox id and kept alive
|
|
10
|
+
* (`sleep infinity` / image default) so the daemon can `exec` into it on demand
|
|
11
|
+
* — the same model Docker exec gives us for free in Phase 0, standing in for the
|
|
12
|
+
* dedicated in-sandbox agent that the microVM drivers will need.
|
|
13
|
+
*/
|
|
14
|
+
/** Egress-enforcement network settings, passed in from config by the driver factory. */
|
|
15
|
+
export interface EgressNetConfig {
|
|
16
|
+
enforce: boolean;
|
|
17
|
+
network: string;
|
|
18
|
+
subnet: string;
|
|
19
|
+
/** Pinned DNS resolver IP, or "" for Docker's embedded resolver. */
|
|
20
|
+
dns: string;
|
|
21
|
+
}
|
|
22
|
+
export declare class ContainerDriver implements Driver {
|
|
23
|
+
readonly name = "container";
|
|
24
|
+
private docker;
|
|
25
|
+
private ensured;
|
|
26
|
+
private egress?;
|
|
27
|
+
private egressNetReady;
|
|
28
|
+
constructor(docker?: Docker, egress?: EgressNetConfig);
|
|
29
|
+
private containerName;
|
|
30
|
+
/** Deterministic name for the sandbox's persistent workspace volume. */
|
|
31
|
+
private volumeName;
|
|
32
|
+
ping(): Promise<void>;
|
|
33
|
+
hostInfo(): Promise<HostInfo>;
|
|
34
|
+
/**
|
|
35
|
+
* Create the egress-enforcement bridge network if missing (idempotent). Uses the
|
|
36
|
+
* configured subnet so the host firewall's `-s <subnet>` rules match, with the
|
|
37
|
+
* gateway pinned to `.1`. Safe to call repeatedly; a 409 (already exists) is fine.
|
|
38
|
+
*/
|
|
39
|
+
private ensureEgressNetwork;
|
|
40
|
+
/** Create the workspace volume if it does not already exist (idempotent). */
|
|
41
|
+
private ensureVolume;
|
|
42
|
+
/** Pull the image if it is not already present locally. */
|
|
43
|
+
private ensureImage;
|
|
44
|
+
create(opts: CreateOptions): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Clone a git repo into `/workspace` at create time so an agent comes up with
|
|
47
|
+
* the code in place. Installs git first if the image lacks it (the default
|
|
48
|
+
* slim image), then shallow-clones into a subdir named after the repo. A
|
|
49
|
+
* failure throws — unlike best-effort `setup`, the agent needs the code.
|
|
50
|
+
*/
|
|
51
|
+
private cloneRepo;
|
|
52
|
+
/**
|
|
53
|
+
* Run declarative setup commands in order, once, after the container starts.
|
|
54
|
+
* Best-effort: a non-zero exit is logged but does not fail create. Kept out of
|
|
55
|
+
* `launchContainer` on purpose so it does not re-fire on `start()`/resume.
|
|
56
|
+
*/
|
|
57
|
+
private runSetup;
|
|
58
|
+
start(opts: CreateOptions): Promise<void>;
|
|
59
|
+
stop(id: string): Promise<void>;
|
|
60
|
+
/** Shared create/start path: ensure image (+volume), then run the container. */
|
|
61
|
+
private launchContainer;
|
|
62
|
+
exec(id: string, command: string, opts: ExecOptions, onEvent: (e: ExecEvent) => void): Promise<number>;
|
|
63
|
+
/**
|
|
64
|
+
* Run a non-interactive command and capture its streams + exit code. Never
|
|
65
|
+
* throws on a non-zero exit — callers decide what a failure means.
|
|
66
|
+
*/
|
|
67
|
+
private execCapture;
|
|
68
|
+
/**
|
|
69
|
+
* Run a non-interactive command and return its stdout as a UTF-8 string.
|
|
70
|
+
* Throws if the command exits non-zero.
|
|
71
|
+
*/
|
|
72
|
+
private runAndCapture;
|
|
73
|
+
writeFile(id: string, opts: WriteFileOptions): Promise<void>;
|
|
74
|
+
readFile(id: string, opts: ReadFileOptions): Promise<string>;
|
|
75
|
+
mkdir(id: string, opts: MkdirOptions): Promise<void>;
|
|
76
|
+
listFiles(id: string, opts: ListFilesOptions): Promise<FileInfo[]>;
|
|
77
|
+
watchFiles(id: string, path: string, opts: WatchOptions & {
|
|
78
|
+
signal: AbortSignal;
|
|
79
|
+
}, onEvent: (e: FileChangeEvent) => void): Promise<void>;
|
|
80
|
+
startProcess(id: string, procId: string, command: string, opts: StartProcessOptions): Promise<StartProcessResult>;
|
|
81
|
+
listProcesses(id: string, procs: Array<{
|
|
82
|
+
procId: string;
|
|
83
|
+
pid: number;
|
|
84
|
+
}>): Promise<ProcessLiveness[]>;
|
|
85
|
+
killProcess(id: string, pid: number, signal?: string): Promise<void>;
|
|
86
|
+
streamProcessLogs(id: string, logPath: string, opts: {
|
|
87
|
+
follow: boolean;
|
|
88
|
+
signal: AbortSignal;
|
|
89
|
+
}, onData: (chunk: string) => void): Promise<void>;
|
|
90
|
+
waitForPort(id: string, port: number, opts: WaitForPortOptions): Promise<boolean>;
|
|
91
|
+
openTcpBridge(id: string, port: number, host: string): Promise<TcpBridge>;
|
|
92
|
+
openTerminal(id: string, opts: TerminalOptions): Promise<TerminalSession>;
|
|
93
|
+
createBackup(id: string, tarPath: string): Promise<{
|
|
94
|
+
bytes: number;
|
|
95
|
+
}>;
|
|
96
|
+
restoreBackup(id: string, tarPath: string): Promise<void>;
|
|
97
|
+
stats(id: string): Promise<SandboxStats>;
|
|
98
|
+
destroy(id: string): Promise<void>;
|
|
99
|
+
}
|