@finalai/sandbox-router-final 0.2.1 → 0.2.2
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 +63 -6
- package/dist/modules/claims.d.mts +3 -0
- package/dist/modules/claims.mjs +24 -0
- package/dist/modules/claims.mjs.map +7 -0
- package/dist/modules/computer.d.mts +7 -0
- package/dist/modules/computer.mjs +57 -0
- package/dist/modules/computer.mjs.map +7 -0
- package/dist/modules/images.d.mts +23 -3
- package/dist/modules/images.mjs +48 -23
- package/dist/modules/images.mjs.map +3 -3
- package/dist/modules/lifecycle.d.mts +25 -0
- package/dist/modules/lifecycle.mjs +46 -0
- package/dist/modules/lifecycle.mjs.map +7 -0
- package/dist/modules/limits.d.mts +1 -0
- package/dist/modules/limits.mjs +20 -1
- package/dist/modules/limits.mjs.map +2 -2
- package/dist/modules/options.d.mts +8 -5
- package/dist/modules/options.mjs +8 -6
- package/dist/modules/options.mjs.map +2 -2
- package/dist/modules/provider.mjs +1016 -127
- package/dist/modules/provider.mjs.map +2 -2
- package/dist/modules/service.d.mts +12 -0
- package/dist/modules/service.mjs +49 -0
- package/dist/modules/service.mjs.map +7 -0
- package/dist/modules/usage.d.mts +7 -0
- package/dist/modules/usage.mjs +50 -0
- package/dist/modules/usage.mjs.map +7 -0
- package/dist/modules/vm/api.d.mts +2 -1
- package/dist/modules/vm/api.mjs +11 -3
- package/dist/modules/vm/api.mjs.map +2 -2
- package/dist/modules/vm/client.d.mts +85 -4
- package/dist/modules/vm/client.mjs +142 -6
- package/dist/modules/vm/client.mjs.map +2 -2
- package/dist/modules/vm/errors.d.mts +2 -0
- package/dist/modules/vm/errors.mjs +2 -1
- package/dist/modules/vm/errors.mjs.map +2 -2
- package/dist/modules/vm/exec.d.mts +1 -0
- package/dist/modules/vm/exec.mjs +2 -0
- package/dist/modules/vm/exec.mjs.map +2 -2
- package/dist/modules/vm/files.d.mts +8 -0
- package/dist/modules/vm/files.mjs +47 -0
- package/dist/modules/vm/files.mjs.map +2 -2
- package/dist/modules/vm/ids.d.mts +1 -0
- package/dist/modules/vm/ids.mjs +2 -0
- package/dist/modules/vm/ids.mjs.map +2 -2
- package/dist/modules/vm/ingress.d.mts +5 -0
- package/dist/modules/vm/ingress.mjs +21 -0
- package/dist/modules/vm/ingress.mjs.map +2 -2
- package/dist/modules/vm/network.d.mts +3 -1
- package/dist/modules/vm/network.mjs +3 -2
- package/dist/modules/vm/network.mjs.map +2 -2
- package/dist/modules/vm/resources.d.mts +251 -0
- package/dist/modules/vm/resources.mjs +210 -0
- package/dist/modules/vm/resources.mjs.map +7 -0
- package/dist/modules/vm/routes.d.mts +55 -0
- package/dist/modules/vm/routes.mjs +61 -0
- package/dist/modules/vm/routes.mjs.map +7 -0
- package/dist/modules/vm/sandbox.d.mts +92 -3
- package/dist/modules/vm/sandbox.mjs +234 -4
- package/dist/modules/vm/sandbox.mjs.map +2 -2
- package/dist/modules/vm/schemas.d.mts +219 -0
- package/dist/modules/vm/schemas.mjs +34 -3
- package/dist/modules/vm/schemas.mjs.map +2 -2
- package/dist/modules/vm/size.d.mts +10 -0
- package/dist/modules/vm/size.mjs +7 -0
- package/dist/modules/vm/size.mjs.map +7 -0
- package/dist/modules/vm/wire.d.mts +3 -0
- package/dist/modules/vm/wire.mjs +6 -0
- package/dist/modules/vm/wire.mjs.map +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -23,11 +23,16 @@ await sandbox.delete();
|
|
|
23
23
|
- `options.fetch`: a `fetch` implementation.
|
|
24
24
|
- `options.previewDomain`: the domain port URLs are served under, for an API other than the
|
|
25
25
|
public one.
|
|
26
|
+
- `options.defaultWallClockLimitS`: the maximum lifetime of a sandbox whose lifecycle leaves
|
|
27
|
+
`max` out (default one year, which the platform caps at the plan's maximum, 30 days by
|
|
28
|
+
default). It ends the sandbox with the idle action.
|
|
26
29
|
|
|
27
|
-
`providerOptions.final` (`finalOptionsSchema`): `projectId`; `
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
(`
|
|
30
|
+
`providerOptions.final` (`finalOptionsSchema`): `projectId`; `machine` (`sort`,
|
|
31
|
+
`maxPricePerHour`, among the machines `spec.placement` allows); `tools` (`docker`, also run in
|
|
32
|
+
templates built for the sandbox); `ephemeral` (no durable copy of the disk); a reserved `sandboxId`
|
|
33
|
+
(`sbx_…`, or the UUID it encodes); and `owner: 'self'` (only the creating API key may change,
|
|
34
|
+
capture or copy the sandbox); `pausedRetentionS` (see [Lifecycle](#lifecycle)). Organizations entitled to them may also set `retentionExempt`,
|
|
35
|
+
`platformEgress` and `cpuPool`; the API refuses them otherwise.
|
|
31
36
|
|
|
32
37
|
The provider's `prices` reads the API's machine types for the spec's size.
|
|
33
38
|
|
|
@@ -35,5 +40,57 @@ The package also exports `capabilities`, `regions`, `limits` and `MachineSort`.
|
|
|
35
40
|
|
|
36
41
|
## Capabilities
|
|
37
42
|
|
|
38
|
-
|
|
39
|
-
|
|
43
|
+
| Capability | How |
|
|
44
|
+
| --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
45
|
+
| `labels` | Sandbox labels; `setLabels` replaces them (this adapter's `name` label is kept unless the new set names one). |
|
|
46
|
+
| `pause`, `resume`, `stop` | Pause keeps memory; stop keeps files. |
|
|
47
|
+
| `idleTimeout`, `idleStop`, `maxLifetime` | See [Lifecycle](#lifecycle). |
|
|
48
|
+
| `autoResume` | A paused or stopped sandbox wakes on a command, port request or file write (the default); `exec` and `processes.list` with `autoResume: false` fail instead. |
|
|
49
|
+
| `coldFiles` | File reads, listings and stats go through the API, which reads a paused or stopped sandbox's saved disk without waking it. |
|
|
50
|
+
| `burst` | `cpuLimit` and `memoryLimitMib` above the guaranteed request. |
|
|
51
|
+
| `publicPorts`, `portTokens` | Ports are private unless public; `ports.setPublic` changes it. Private ports answer to preview tokens, which can be minted, listed (revoked ones on request) and revoked. The desktop's editor port (3210) answers only to a one-time link: `ports.url` returns it with `auth: 'url'`, to open within a minute, which starts a 15-minute browser session (`ttlS` changes neither). Port 9910 is reserved by the platform. |
|
|
52
|
+
| `processList` | Commands started through `exec` since the last boot, running or ended, with working directory, user, exit codes and times. |
|
|
53
|
+
| `directConnect` | A data-plane grant, optionally limited to scopes and a lifetime (60 s to 24 h). |
|
|
54
|
+
| `service` | The sandbox's supervised workload: restarted when it exits (`on-failure` too), health-checked over HTTP. Stopping replaces it with one that exits at once. Restarts are not counted. |
|
|
55
|
+
| `placement` | Placement groups, machine types and CPU families. |
|
|
56
|
+
| `caches` | Entries by scope and key, uploaded and read through presigned URLs, listed by scope prefix and deleted. A scope and key together take at most 1,023 bytes and cannot hold U+001F: they are stored as one platform key, so the platform lists by scope prefix itself. |
|
|
57
|
+
| `telemetry` | Recorded as the sandbox's telemetry resource. |
|
|
58
|
+
| `desktop`, `computerUse` | The platform's desktop image (`image.desktop()`), its screen session, screenshots and input. |
|
|
59
|
+
| `metrics` | CPU (a share of the CPU limit), memory and its limit, and traffic, per bucket from the platform's one-minute usage windows. Buckets are rounded up to whole minutes and refused over a day; the platform answers at most 1,440 points and reaches back 30 days. |
|
|
60
|
+
| `ingress` | Hostnames routed to the healthy sandboxes of the API key's project that carry the target labels. `prepareOnly` claims the hostname and its certificate without routing; `retarget` changes labels and port in one step, failing with `conflict` if the claim changed meanwhile. A hostname another project holds fails with `already_exists`. |
|
|
61
|
+
| `volumes` | Created, mounted at create or attached at runtime (once per sandbox), committed and detached; listed by name or label. |
|
|
62
|
+
| `customDomains` | Hostnames routed to a port, with the DNS record to create. The platform serves domains only for public ports, so adding one makes its port public. |
|
|
63
|
+
| `snapshot`, `fork`, `pty`, `image`, `networkPolicy` | Named snapshots are kept until deleted and carry labels; they can be read and listed by label. |
|
|
64
|
+
|
|
65
|
+
## Lifecycle
|
|
66
|
+
|
|
67
|
+
The idle action (pause, stop or delete) applies after the idle timeout. A maximum lifetime stops or
|
|
68
|
+
deletes the sandbox a time after its latest start (create being the first), in any state. Without
|
|
69
|
+
one, a wall-clock limit applies the idle action to a sandbox that has run that long since it last
|
|
70
|
+
started or resumed.
|
|
71
|
+
|
|
72
|
+
- `idle` left out or `null`: no idle timeout. The platform's own default, a pause after five
|
|
73
|
+
minutes, is left for callers to ask for.
|
|
74
|
+
- `max` left out: no maximum lifetime, but the wall-clock limit `options.defaultWallClockLimitS`
|
|
75
|
+
(ending with the idle action, a pause unless `idle` says otherwise). `max: null`: neither, for
|
|
76
|
+
organizations entitled to run without a limit (the API refuses it otherwise). A maximum above
|
|
77
|
+
the plan's longest wall-clock limit is refused unless the organization is so entitled.
|
|
78
|
+
- `autoResume` left out: the platform wakes the sandbox when used.
|
|
79
|
+
- `setLifecycle` replaces the whole policy with the same rules.
|
|
80
|
+
|
|
81
|
+
`get` and `create` report the lifecycle in force: fields at the platform's default, and a
|
|
82
|
+
wall-clock limit that pauses, are left out; a maximum lifetime counted from create (a time to
|
|
83
|
+
live) reads like one from the latest start; the wall-clock limit is reported as the platform keeps
|
|
84
|
+
it, capped at the plan's maximum. A paused sandbox stops after its paused retention
|
|
85
|
+
(`providerOptions.final.pausedRetentionS`, at most and by default the organization's, 7 days) and a
|
|
86
|
+
stopped one is deleted after the stopped retention (14 days).
|
|
87
|
+
|
|
88
|
+
Appends (`write` with `append`) keep the file's mode, so `append` with `mode` is refused.
|
|
89
|
+
|
|
90
|
+
`setEnv` replaces the boot environment, and `resize` changes CPU, memory, their limits and disk
|
|
91
|
+
(which only grows). The platform makes both changes only to a stopped sandbox: a running one
|
|
92
|
+
restarts (memory is lost, files kept) and a paused one is left stopped. `resize` is implemented but
|
|
93
|
+
not offered yet: a sandbox restarted on the platform does not yet fork reliably.
|
|
94
|
+
|
|
95
|
+
`charges` reports what the platform billed a sandbox over a window, one line per priced resource
|
|
96
|
+
(reserved and burst CPU and memory, disk, egress), amounts exact to the micro-dollar.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const STATES = {
|
|
2
|
+
pending: "pending",
|
|
3
|
+
active: "active",
|
|
4
|
+
failed: "failed"
|
|
5
|
+
};
|
|
6
|
+
const TLS_STATES = {
|
|
7
|
+
pending: "pending",
|
|
8
|
+
active: "issued",
|
|
9
|
+
failed: "failed"
|
|
10
|
+
};
|
|
11
|
+
const claimOf = (route) => ({
|
|
12
|
+
hostname: route.hostname,
|
|
13
|
+
port: route.port,
|
|
14
|
+
targetLabels: route.selector?.labels ?? {},
|
|
15
|
+
state: STATES[route.tls.state] ?? "pending",
|
|
16
|
+
records: route.records,
|
|
17
|
+
// The platform does not report the certificate's expiry.
|
|
18
|
+
tls: { state: TLS_STATES[route.tls.state] ?? "pending", expiresAt: null },
|
|
19
|
+
error: route.tls.error ?? null
|
|
20
|
+
});
|
|
21
|
+
export {
|
|
22
|
+
claimOf
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=claims.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/claims.ts"],
|
|
4
|
+
"sourcesContent": ["import type { DomainClaimIface } from '@finalai/sandbox-router/provider';\nimport type { IngressRouteIface } from \"./vm/routes.mjs\";\n\n// A router domain claim from a platform ingress route. A route without a selector (a claim made\n// with `prepareOnly`) routes nothing and reads as targeting no labels.\n\nconst STATES: Record<string, DomainClaimIface['state']> = {\n pending: 'pending',\n active: 'active',\n failed: 'failed',\n};\n\nconst TLS_STATES: Record<string, 'pending' | 'issued' | 'failed'> = {\n pending: 'pending',\n active: 'issued',\n failed: 'failed',\n};\n\nexport const claimOf = (route: IngressRouteIface): DomainClaimIface => ({\n hostname: route.hostname,\n port: route.port,\n targetLabels: route.selector?.labels ?? {},\n state: STATES[route.tls.state] ?? 'pending',\n records: route.records,\n // The platform does not report the certificate's expiry.\n tls: { state: TLS_STATES[route.tls.state] ?? 'pending', expiresAt: null },\n error: route.tls.error ?? null,\n});\n"],
|
|
5
|
+
"mappings": "AAMA,MAAM,SAAoD;AAAA,EACxD,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AACV;AAEA,MAAM,aAA8D;AAAA,EAClE,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AACV;AAEO,MAAM,UAAU,CAAC,WAAgD;AAAA,EACtE,UAAU,MAAM;AAAA,EAChB,MAAM,MAAM;AAAA,EACZ,cAAc,MAAM,UAAU,UAAU,CAAC;AAAA,EACzC,OAAO,OAAO,MAAM,IAAI,KAAK,KAAK;AAAA,EAClC,SAAS,MAAM;AAAA;AAAA,EAEf,KAAK,EAAE,OAAO,WAAW,MAAM,IAAI,KAAK,KAAK,WAAW,WAAW,KAAK;AAAA,EACxE,OAAO,MAAM,IAAI,SAAS;AAC5B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ComputerActionIface } from '@finalai/sandbox-router/provider';
|
|
2
|
+
export declare const DISPLAY_ENV: {
|
|
3
|
+
DISPLAY: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const SCREENSHOT_COMMAND = "exec ffmpeg -nostdin -v error -f x11grab -i :0 -frames:v 1 -f image2pipe -vcodec png pipe:1";
|
|
6
|
+
export declare const xdotoolArgs: (action: ComputerActionIface) => string[];
|
|
7
|
+
export declare const xdotoolCommand: (action: ComputerActionIface) => string | null;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { shellQuote } from "@finalai/sandbox-router/provider";
|
|
2
|
+
const DISPLAY_ENV = { DISPLAY: ":0" };
|
|
3
|
+
const SCREENSHOT_COMMAND = "exec ffmpeg -nostdin -v error -f x11grab -i :0 -frames:v 1 -f image2pipe -vcodec png pipe:1";
|
|
4
|
+
const BUTTONS = { left: 1, middle: 2, right: 3 };
|
|
5
|
+
const scrollClicks = (delta, negative, positive) => delta === 0 ? [] : [
|
|
6
|
+
"click",
|
|
7
|
+
"--repeat",
|
|
8
|
+
String(Math.min(Math.abs(Math.round(delta)), 100)),
|
|
9
|
+
String(delta < 0 ? negative : positive)
|
|
10
|
+
];
|
|
11
|
+
const point = (x, y) => [String(Math.round(x)), String(Math.round(y))];
|
|
12
|
+
const xdotoolArgs = (action) => {
|
|
13
|
+
switch (action.type) {
|
|
14
|
+
case "click":
|
|
15
|
+
return [
|
|
16
|
+
"mousemove",
|
|
17
|
+
...point(action.x, action.y),
|
|
18
|
+
"click",
|
|
19
|
+
...action.double === true ? ["--repeat", "2"] : [],
|
|
20
|
+
String(BUTTONS[action.button ?? "left"])
|
|
21
|
+
];
|
|
22
|
+
case "move":
|
|
23
|
+
return ["mousemove", ...point(action.x, action.y)];
|
|
24
|
+
case "drag": {
|
|
25
|
+
const [first, ...rest] = action.path;
|
|
26
|
+
if (first == null) return [];
|
|
27
|
+
return [
|
|
28
|
+
"mousemove",
|
|
29
|
+
...point(first.x, first.y),
|
|
30
|
+
"mousedown",
|
|
31
|
+
"1",
|
|
32
|
+
...rest.flatMap((step) => ["mousemove", ...point(step.x, step.y)]),
|
|
33
|
+
"mouseup",
|
|
34
|
+
"1"
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
case "type":
|
|
38
|
+
return ["type", "--delay", "12", "--", action.text];
|
|
39
|
+
case "key":
|
|
40
|
+
return ["key", "--", action.keys.join("+")];
|
|
41
|
+
case "scroll": {
|
|
42
|
+
const clicks = [...scrollClicks(action.dy, 4, 5), ...scrollClicks(action.dx, 6, 7)];
|
|
43
|
+
return ["mousemove", ...point(action.x, action.y), ...clicks];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const xdotoolCommand = (action) => {
|
|
48
|
+
const args = xdotoolArgs(action);
|
|
49
|
+
return args.length === 0 ? null : `exec xdotool ${args.map(shellQuote).join(" ")}`;
|
|
50
|
+
};
|
|
51
|
+
export {
|
|
52
|
+
DISPLAY_ENV,
|
|
53
|
+
SCREENSHOT_COMMAND,
|
|
54
|
+
xdotoolArgs,
|
|
55
|
+
xdotoolCommand
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=computer.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/computer.ts"],
|
|
4
|
+
"sourcesContent": ["import { shellQuote, type ComputerActionIface } from '@finalai/sandbox-router/provider';\n\n// Computer use on the desktop's display, through commands in the sandbox: ffmpeg captures the\n// screen, xdotool sends input. The platform's desktop image carries both.\n\nexport const DISPLAY_ENV = { DISPLAY: ':0' };\n\nexport const SCREENSHOT_COMMAND =\n 'exec ffmpeg -nostdin -v error -f x11grab -i :0 -frames:v 1 -f image2pipe -vcodec png pipe:1';\n\nconst BUTTONS = { left: 1, middle: 2, right: 3 } as const;\n\n// X scroll buttons: 4 up, 5 down, 6 left, 7 right; one click per unit.\nconst scrollClicks = (delta: number, negative: number, positive: number): string[] =>\n delta === 0\n ? []\n : [\n 'click',\n '--repeat',\n String(Math.min(Math.abs(Math.round(delta)), 100)),\n String(delta < 0 ? negative : positive),\n ];\n\nconst point = (x: number, y: number) => [String(Math.round(x)), String(Math.round(y))];\n\n// The xdotool arguments for an action.\nexport const xdotoolArgs = (action: ComputerActionIface): string[] => {\n switch (action.type) {\n case 'click':\n return [\n 'mousemove',\n ...point(action.x, action.y),\n 'click',\n ...(action.double === true ? ['--repeat', '2'] : []),\n String(BUTTONS[action.button ?? 'left']),\n ];\n case 'move':\n return ['mousemove', ...point(action.x, action.y)];\n case 'drag': {\n const [first, ...rest] = action.path;\n if (first == null) return [];\n return [\n 'mousemove',\n ...point(first.x, first.y),\n 'mousedown',\n '1',\n ...rest.flatMap((step) => ['mousemove', ...point(step.x, step.y)]),\n 'mouseup',\n '1',\n ];\n }\n case 'type':\n return ['type', '--delay', '12', '--', action.text];\n case 'key':\n // The keys are pressed together.\n return ['key', '--', action.keys.join('+')];\n case 'scroll': {\n const clicks = [...scrollClicks(action.dy, 4, 5), ...scrollClicks(action.dx, 6, 7)];\n return ['mousemove', ...point(action.x, action.y), ...clicks];\n }\n }\n};\n\nexport const xdotoolCommand = (action: ComputerActionIface): string | null => {\n const args = xdotoolArgs(action);\n return args.length === 0 ? null : `exec xdotool ${args.map(shellQuote).join(' ')}`;\n};\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,kBAA4C;AAK9C,MAAM,cAAc,EAAE,SAAS,KAAK;AAEpC,MAAM,qBACX;AAEF,MAAM,UAAU,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,EAAE;AAG/C,MAAM,eAAe,CAAC,OAAe,UAAkB,aACrD,UAAU,IACN,CAAC,IACD;AAAA,EACE;AAAA,EACA;AAAA,EACA,OAAO,KAAK,IAAI,KAAK,IAAI,KAAK,MAAM,KAAK,CAAC,GAAG,GAAG,CAAC;AAAA,EACjD,OAAO,QAAQ,IAAI,WAAW,QAAQ;AACxC;AAEN,MAAM,QAAQ,CAAC,GAAW,MAAc,CAAC,OAAO,KAAK,MAAM,CAAC,CAAC,GAAG,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC;AAG9E,MAAM,cAAc,CAAC,WAA0C;AACpE,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK;AACH,aAAO;AAAA,QACL;AAAA,QACA,GAAG,MAAM,OAAO,GAAG,OAAO,CAAC;AAAA,QAC3B;AAAA,QACA,GAAI,OAAO,WAAW,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;AAAA,QAClD,OAAO,QAAQ,OAAO,UAAU,MAAM,CAAC;AAAA,MACzC;AAAA,IACF,KAAK;AACH,aAAO,CAAC,aAAa,GAAG,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC;AAAA,IACnD,KAAK,QAAQ;AACX,YAAM,CAAC,OAAO,GAAG,IAAI,IAAI,OAAO;AAChC,UAAI,SAAS,KAAM,QAAO,CAAC;AAC3B,aAAO;AAAA,QACL;AAAA,QACA,GAAG,MAAM,MAAM,GAAG,MAAM,CAAC;AAAA,QACzB;AAAA,QACA;AAAA,QACA,GAAG,KAAK,QAAQ,CAAC,SAAS,CAAC,aAAa,GAAG,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC;AAAA,QACjE;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,IACA,KAAK;AACH,aAAO,CAAC,QAAQ,WAAW,MAAM,MAAM,OAAO,IAAI;AAAA,IACpD,KAAK;AAEH,aAAO,CAAC,OAAO,MAAM,OAAO,KAAK,KAAK,GAAG,CAAC;AAAA,IAC5C,KAAK,UAAU;AACb,YAAM,SAAS,CAAC,GAAG,aAAa,OAAO,IAAI,GAAG,CAAC,GAAG,GAAG,aAAa,OAAO,IAAI,GAAG,CAAC,CAAC;AAClF,aAAO,CAAC,aAAa,GAAG,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,GAAG,MAAM;AAAA,IAC9D;AAAA,EACF;AACF;AAEO,MAAM,iBAAiB,CAAC,WAA+C;AAC5E,QAAM,OAAO,YAAY,MAAM;AAC/B,SAAO,KAAK,WAAW,IAAI,OAAO,gBAAgB,KAAK,IAAI,UAAU,EAAE,KAAK,GAAG,CAAC;AAClF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,15 +1,35 @@
|
|
|
1
1
|
import { ImageStrategy, type ImageBaseIface, type ImageSpecIface, type ResultIface, type VendorArtifactIface } from '@finalai/sandbox-router/provider';
|
|
2
2
|
import type { VmClientIface } from "./vm/client.mjs";
|
|
3
3
|
import type { ClockIface } from "./vm/clock.mjs";
|
|
4
|
-
export declare
|
|
4
|
+
export declare enum PlatformLineage {
|
|
5
|
+
Base = "base",
|
|
6
|
+
Desktop = "desktop"
|
|
7
|
+
}
|
|
8
|
+
export type BaseSourceIface = {
|
|
9
|
+
lineage: PlatformLineage;
|
|
10
|
+
} | {
|
|
11
|
+
reference: string;
|
|
12
|
+
} | null;
|
|
13
|
+
export declare const baseSource: (base: ImageBaseIface) => BaseSourceIface;
|
|
5
14
|
export declare const imageStrategy: (spec: ImageSpecIface) => ImageStrategy | null;
|
|
6
15
|
interface ImageContextIface {
|
|
7
16
|
client: VmClientIface;
|
|
8
17
|
clock: ClockIface;
|
|
9
18
|
signal?: AbortSignal;
|
|
10
19
|
}
|
|
11
|
-
export declare const ensureImage: (context: ImageContextIface,
|
|
20
|
+
export declare const ensureImage: (context: ImageContextIface, source: {
|
|
21
|
+
lineage: PlatformLineage;
|
|
22
|
+
} | {
|
|
23
|
+
reference: string;
|
|
24
|
+
}) => Promise<ResultIface<string>>;
|
|
25
|
+
export interface BuildOptionsIface {
|
|
26
|
+
resources: {
|
|
27
|
+
cpu: number;
|
|
28
|
+
memoryMib: number;
|
|
29
|
+
} | null;
|
|
30
|
+
tools: string[];
|
|
31
|
+
}
|
|
12
32
|
export declare const buildImage: (context: ImageContextIface & {
|
|
13
33
|
onLog?: (line: string) => void;
|
|
14
|
-
}, spec: ImageSpecIface) => Promise<ResultIface<VendorArtifactIface>>;
|
|
34
|
+
}, spec: ImageSpecIface, options: BuildOptionsIface) => Promise<ResultIface<VendorArtifactIface>>;
|
|
15
35
|
export {};
|
package/dist/modules/images.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
canonicalJson,
|
|
2
3
|
DEFAULT_CPU,
|
|
3
4
|
DEFAULT_MEMORY_MIB,
|
|
4
5
|
fail,
|
|
@@ -8,28 +9,41 @@ import {
|
|
|
8
9
|
ok,
|
|
9
10
|
readyCommand,
|
|
10
11
|
SandboxRouterErrorCode,
|
|
12
|
+
sha256Hex,
|
|
11
13
|
shellQuote
|
|
12
14
|
} from "@finalai/sandbox-router/provider";
|
|
13
15
|
import { ImageState, TemplateState } from "./vm/schemas.mjs";
|
|
14
16
|
const BUILD_TIMEOUT_MS = 20 * 6e4;
|
|
15
17
|
const POLL_MS = 2e3;
|
|
16
18
|
const DEFAULT_UBUNTU = "24.04";
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
var PlatformLineage = /* @__PURE__ */ ((PlatformLineage2) => {
|
|
20
|
+
PlatformLineage2["Base"] = "base";
|
|
21
|
+
PlatformLineage2["Desktop"] = "desktop";
|
|
22
|
+
return PlatformLineage2;
|
|
23
|
+
})(PlatformLineage || {});
|
|
24
|
+
const baseSource = (base) => {
|
|
25
|
+
if (base.kind === "default") return { lineage: "base" /* Base */ };
|
|
26
|
+
if (base.kind === "oci")
|
|
27
|
+
return base.registryCredential == null ? { reference: base.reference } : null;
|
|
20
28
|
switch (base.name) {
|
|
21
29
|
case ImagePreset.Ubuntu:
|
|
22
|
-
return base.version === DEFAULT_UBUNTU ?
|
|
30
|
+
return base.version === DEFAULT_UBUNTU ? { lineage: "base" /* Base */ } : { reference: `docker.io/library/ubuntu:${base.version}` };
|
|
23
31
|
case ImagePreset.Node:
|
|
24
|
-
return `docker.io/library/node:${base.version}
|
|
32
|
+
return { reference: `docker.io/library/node:${base.version}` };
|
|
25
33
|
case ImagePreset.Python:
|
|
26
|
-
return `docker.io/library/python:${base.version}
|
|
34
|
+
return { reference: `docker.io/library/python:${base.version}` };
|
|
35
|
+
case ImagePreset.Desktop:
|
|
36
|
+
return base.version === "latest" ? { lineage: "desktop" /* Desktop */ } : null;
|
|
37
|
+
default:
|
|
38
|
+
return null;
|
|
27
39
|
}
|
|
28
40
|
};
|
|
29
41
|
const imageStrategy = (spec) => {
|
|
30
|
-
|
|
42
|
+
const source = baseSource(spec.base);
|
|
43
|
+
if (source == null) return null;
|
|
31
44
|
if (spec.steps.length > 0) return ImageStrategy.Bake;
|
|
32
|
-
if (
|
|
45
|
+
if ("lineage" in source && spec.start == null && spec.warmup == null)
|
|
46
|
+
return ImageStrategy.Runtime;
|
|
33
47
|
return ImageStrategy.Build;
|
|
34
48
|
};
|
|
35
49
|
const deadlineError = (what) => fail(
|
|
@@ -55,12 +69,13 @@ const waitForImage = async (context, image) => {
|
|
|
55
69
|
current = await context.client.images.get(current.id);
|
|
56
70
|
}
|
|
57
71
|
};
|
|
58
|
-
const ensureImage = async (context,
|
|
72
|
+
const ensureImage = async (context, source) => {
|
|
59
73
|
const images = await context.client.images.list();
|
|
60
|
-
if (
|
|
61
|
-
const platform = images.find((image) => image.platform && image.lineage ===
|
|
62
|
-
return platform == null ? fail(SandboxRouterErrorCode.ProviderError,
|
|
74
|
+
if ("lineage" in source) {
|
|
75
|
+
const platform = images.find((image) => image.platform && image.lineage === source.lineage);
|
|
76
|
+
return platform == null ? fail(SandboxRouterErrorCode.ProviderError, `the platform has no ${source.lineage} image`) : ok(platform.id);
|
|
63
77
|
}
|
|
78
|
+
const { reference } = source;
|
|
64
79
|
const existing = images.filter(
|
|
65
80
|
(image) => !image.platform && image.reference === reference && image.state !== ImageState.Failed
|
|
66
81
|
).sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime())[0];
|
|
@@ -73,24 +88,33 @@ const templateStart = (spec, command) => {
|
|
|
73
88
|
const cd = spec.workdir == null ? "" : `mkdir -p ${shellQuote(spec.workdir)} && cd ${shellQuote(spec.workdir)} && `;
|
|
74
89
|
return `${exports.join("")}${cd}exec sh -c ${shellQuote(command)}`;
|
|
75
90
|
};
|
|
76
|
-
const templateName = async (spec) => `router-${(await imageKey(spec)).slice(
|
|
77
|
-
const buildImage = async (context, spec) => {
|
|
78
|
-
const
|
|
91
|
+
const templateName = async (spec, options) => `router-${(await sha256Hex(canonicalJson({ image: await imageKey(spec), ...options }))).slice(0, 32)}`;
|
|
92
|
+
const buildImage = async (context, spec, options) => {
|
|
93
|
+
const source = baseSource(spec.base);
|
|
94
|
+
if (source == null)
|
|
95
|
+
return fail(SandboxRouterErrorCode.UnsupportedByProvider, "final cannot run this base");
|
|
96
|
+
const image = await ensureImage(context, source);
|
|
79
97
|
if (!image.ok) return image;
|
|
80
98
|
const exportable = Object.keys(spec.env).every((name2) => /^[A-Za-z_][A-Za-z0-9_]*$/.test(name2));
|
|
81
|
-
if (spec.start == null || spec.user != null || !exportable)
|
|
99
|
+
if (spec.start == null && spec.warmup == null || spec.user != null || !exportable)
|
|
82
100
|
return ok({ kind: "image", id: image.value, startsOnBoot: false });
|
|
83
|
-
const
|
|
101
|
+
const readyCheck = spec.start?.ready ?? spec.ready;
|
|
102
|
+
const name = await templateName(spec, options);
|
|
84
103
|
const existing = (await context.client.templates.list()).find(
|
|
85
104
|
(template2) => template2.name === name && template2.state !== TemplateState.Failed
|
|
86
105
|
);
|
|
106
|
+
const cpu = options.resources?.cpu ?? DEFAULT_CPU;
|
|
107
|
+
const memoryMib = options.resources?.memoryMib ?? DEFAULT_MEMORY_MIB;
|
|
87
108
|
let template = existing ?? await context.client.templates.create({
|
|
88
109
|
name,
|
|
89
110
|
imageId: image.value,
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
111
|
+
// Without a start command the template captures the image booted and warmed up.
|
|
112
|
+
startCmd: spec.start == null ? void 0 : templateStart(spec, spec.start.command),
|
|
113
|
+
readyCmd: readyCheck == null ? void 0 : readyCommand(readyCheck, 0.5),
|
|
114
|
+
warmupCmd: spec.warmup == null ? void 0 : templateStart(spec, spec.warmup),
|
|
115
|
+
cpu: [cpu, cpu],
|
|
116
|
+
memory: [memoryMib, memoryMib],
|
|
117
|
+
tools: options.tools.length === 0 ? void 0 : options.tools
|
|
94
118
|
});
|
|
95
119
|
if (existing == null) {
|
|
96
120
|
context.onLog?.(`building template ${template.id}`);
|
|
@@ -99,7 +123,7 @@ const buildImage = async (context, spec) => {
|
|
|
99
123
|
const deadline = context.clock.now() + BUILD_TIMEOUT_MS;
|
|
100
124
|
for (; ; ) {
|
|
101
125
|
if (template.state === TemplateState.Ready)
|
|
102
|
-
return ok({ kind: "template", id: template.id, startsOnBoot:
|
|
126
|
+
return ok({ kind: "template", id: template.id, startsOnBoot: spec.start != null });
|
|
103
127
|
if (template.state === TemplateState.Failed)
|
|
104
128
|
return fail(SandboxRouterErrorCode.InvalidRequest, `template ${template.id} failed to build`);
|
|
105
129
|
if (context.clock.now() >= deadline) return deadlineError(`building template ${template.id}`);
|
|
@@ -108,7 +132,8 @@ const buildImage = async (context, spec) => {
|
|
|
108
132
|
}
|
|
109
133
|
};
|
|
110
134
|
export {
|
|
111
|
-
|
|
135
|
+
PlatformLineage,
|
|
136
|
+
baseSource,
|
|
112
137
|
buildImage,
|
|
113
138
|
ensureImage,
|
|
114
139
|
imageStrategy
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/images.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n DEFAULT_CPU,\n DEFAULT_MEMORY_MIB,\n fail,\n ImagePreset,\n ImageStrategy,\n imageKey,\n ok,\n readyCommand,\n SandboxRouterErrorCode,\n shellQuote,\n type ImageBaseIface,\n type ImageSpecIface,\n type ResultIface,\n type VendorArtifactIface,\n} from '@finalai/sandbox-router/provider';\nimport type { VmClientIface } from \"./vm/client.mjs\";\nimport type { ClockIface } from \"./vm/clock.mjs\";\nimport { ImageState, TemplateState, type ImageIface } from \"./vm/schemas.mjs\";\n\n// How specs become Final VMs images: a base is an imported container image
|
|
5
|
-
"mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAKK;AAGP,SAAS,YAAY,qBAAsC;
|
|
6
|
-
"names": ["name", "template"]
|
|
4
|
+
"sourcesContent": ["import {\n canonicalJson,\n DEFAULT_CPU,\n DEFAULT_MEMORY_MIB,\n fail,\n ImagePreset,\n ImageStrategy,\n imageKey,\n ok,\n readyCommand,\n SandboxRouterErrorCode,\n sha256Hex,\n shellQuote,\n type ImageBaseIface,\n type ImageSpecIface,\n type ResultIface,\n type VendorArtifactIface,\n} from '@finalai/sandbox-router/provider';\nimport type { VmClientIface } from \"./vm/client.mjs\";\nimport type { ClockIface } from \"./vm/clock.mjs\";\nimport { ImageState, TemplateState, type ImageIface } from \"./vm/schemas.mjs\";\n\n// How specs become Final VMs images: a base is an imported container image or one of the\n// platform's own images (the default, or the desktop); a spec with a start command or a warmup\n// and no steps becomes a template, which boots the image once, runs the start command until the\n// ready check passes, runs the warmup and saves the running VM. Specs with steps are baked by\n// the router (create, run the steps, snapshot).\n\nconst BUILD_TIMEOUT_MS = 20 * 60_000;\nconst POLL_MS = 2_000;\n\n// The platform's default image is Ubuntu 24.04 with the router's baseline tools (and more).\nconst DEFAULT_UBUNTU = '24.04';\n\n// The platform's own images, by lineage.\nexport enum PlatformLineage {\n Base = 'base',\n Desktop = 'desktop',\n}\n\n// What a base is here: one of the platform's images, a container image to import, or nothing\n// this provider can run.\nexport type BaseSourceIface = { lineage: PlatformLineage } | { reference: string } | null;\n\nexport const baseSource = (base: ImageBaseIface): BaseSourceIface => {\n if (base.kind === 'default') return { lineage: PlatformLineage.Base };\n if (base.kind === 'oci')\n // A registry credential is the name of a secret this adapter cannot read.\n return base.registryCredential == null ? { reference: base.reference } : null;\n switch (base.name) {\n case ImagePreset.Ubuntu:\n return base.version === DEFAULT_UBUNTU\n ? { lineage: PlatformLineage.Base }\n : { reference: `docker.io/library/ubuntu:${base.version}` };\n case ImagePreset.Node:\n return { reference: `docker.io/library/node:${base.version}` };\n case ImagePreset.Python:\n return { reference: `docker.io/library/python:${base.version}` };\n case ImagePreset.Desktop:\n // The platform keeps one current desktop image.\n return base.version === 'latest' ? { lineage: PlatformLineage.Desktop } : null;\n default:\n return null;\n }\n};\n\nexport const imageStrategy = (spec: ImageSpecIface): ImageStrategy | null => {\n const source = baseSource(spec.base);\n if (source == null) return null;\n if (spec.steps.length > 0) return ImageStrategy.Bake;\n if ('lineage' in source && spec.start == null && spec.warmup == null)\n return ImageStrategy.Runtime;\n return ImageStrategy.Build;\n};\n\ninterface ImageContextIface {\n client: VmClientIface;\n clock: ClockIface;\n signal?: AbortSignal;\n}\n\nconst deadlineError = (what: string) =>\n fail(\n SandboxRouterErrorCode.Timeout,\n `${what} took longer than ${BUILD_TIMEOUT_MS / 60_000} min`,\n {\n retryable: true,\n },\n );\n\nconst waitForImage = async (\n context: ImageContextIface,\n image: ImageIface,\n): Promise<ResultIface<string>> => {\n const deadline = context.clock.now() + BUILD_TIMEOUT_MS;\n let current = image;\n for (;;) {\n if (current.state === ImageState.Ready) return ok(current.id);\n if (current.state === ImageState.Failed)\n return fail(\n SandboxRouterErrorCode.InvalidRequest,\n `importing ${current.reference} failed: ${current.errorCode ?? 'no code'}`,\n { nativeError: current.errorClass ?? current.errorCode },\n );\n if (context.clock.now() >= deadline) return deadlineError(`importing ${current.reference}`);\n await context.clock.sleep(POLL_MS, context.signal);\n current = await context.client.images.get(current.id);\n }\n};\n\n// The platform image of a lineage, or an imported image of a reference, reusing one the project\n// already has.\nexport const ensureImage = async (\n context: ImageContextIface,\n source: { lineage: PlatformLineage } | { reference: string },\n): Promise<ResultIface<string>> => {\n const images = await context.client.images.list();\n if ('lineage' in source) {\n const platform = images.find((image) => image.platform && image.lineage === source.lineage);\n return platform == null\n ? fail(SandboxRouterErrorCode.ProviderError, `the platform has no ${source.lineage} image`)\n : ok(platform.id);\n }\n const { reference } = source;\n const existing = images\n .filter(\n (image) =>\n !image.platform && image.reference === reference && image.state !== ImageState.Failed,\n )\n .sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime())[0];\n return waitForImage(context, existing ?? (await context.client.images.create({ reference })));\n};\n\n// The template's start command carries the spec's environment and working directory: a\n// template starts its service once, before any sandbox's own environment exists. Variables\n// already set (a create's own environment) keep their values.\nconst templateStart = (spec: ImageSpecIface, command: string): string => {\n const exports = Object.entries(spec.env).map(\n ([name, value]) => `[ -n \"\\${${name}+x}\" ] || ${name}=${shellQuote(value)}; export ${name}; `,\n );\n const cd =\n spec.workdir == null\n ? ''\n : `mkdir -p ${shellQuote(spec.workdir)} && cd ${shellQuote(spec.workdir)} && `;\n return `${exports.join('')}${cd}exec sh -c ${shellQuote(command)}`;\n};\n\nexport interface BuildOptionsIface {\n // The size its sandboxes get: a template keeps the size it was captured at.\n resources: { cpu: number; memoryMib: number } | null;\n // Platform tools its build and its sandboxes run.\n tools: string[];\n}\n\n// One template per image, size and tool set.\nconst templateName = async (spec: ImageSpecIface, options: BuildOptionsIface) =>\n `router-${(await sha256Hex(canonicalJson({ image: await imageKey(spec), ...options }))).slice(0, 32)}`;\n\nexport const buildImage = async (\n context: ImageContextIface & { onLog?: (line: string) => void },\n spec: ImageSpecIface,\n options: BuildOptionsIface,\n): Promise<ResultIface<VendorArtifactIface>> => {\n const source = baseSource(spec.base);\n if (source == null)\n return fail(SandboxRouterErrorCode.UnsupportedByProvider, 'final cannot run this base');\n const image = await ensureImage(context, source);\n if (!image.ok) return image;\n // A start command run as another user, or with variables a shell cannot export, is left to\n // the router at create.\n const exportable = Object.keys(spec.env).every((name) => /^[A-Za-z_][A-Za-z0-9_]*$/.test(name));\n if ((spec.start == null && spec.warmup == null) || spec.user != null || !exportable)\n return ok({ kind: 'image', id: image.value, startsOnBoot: false });\n // Without a start command, the image's own check (something its init starts).\n const readyCheck = spec.start?.ready ?? spec.ready;\n const name = await templateName(spec, options);\n const existing = (await context.client.templates.list()).find(\n (template) => template.name === name && template.state !== TemplateState.Failed,\n );\n const cpu = options.resources?.cpu ?? DEFAULT_CPU;\n const memoryMib = options.resources?.memoryMib ?? DEFAULT_MEMORY_MIB;\n let template =\n existing ??\n (await context.client.templates.create({\n name,\n imageId: image.value,\n // Without a start command the template captures the image booted and warmed up.\n startCmd: spec.start == null ? undefined : templateStart(spec, spec.start.command),\n readyCmd: readyCheck == null ? undefined : readyCommand(readyCheck, 0.5),\n warmupCmd: spec.warmup == null ? undefined : templateStart(spec, spec.warmup),\n cpu: [cpu, cpu],\n memory: [memoryMib, memoryMib],\n tools: options.tools.length === 0 ? undefined : options.tools,\n }));\n if (existing == null) {\n context.onLog?.(`building template ${template.id}`);\n await context.client.templates.build(template.id);\n }\n const deadline = context.clock.now() + BUILD_TIMEOUT_MS;\n for (;;) {\n if (template.state === TemplateState.Ready)\n return ok({ kind: 'template', id: template.id, startsOnBoot: spec.start != null });\n if (template.state === TemplateState.Failed)\n return fail(SandboxRouterErrorCode.InvalidRequest, `template ${template.id} failed to build`);\n if (context.clock.now() >= deadline) return deadlineError(`building template ${template.id}`);\n await context.clock.sleep(POLL_MS, context.signal);\n template = await context.client.templates.get(template.id);\n }\n};\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["PlatformLineage", "name", "template"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type LifecycleIface } from '@finalai/sandbox-router/provider';
|
|
2
|
+
import { IdlePolicy, type MaxLifetimeBodyIface } from "./vm/resources.mjs";
|
|
3
|
+
export declare const DEFAULT_WALL_CLOCK_S: number;
|
|
4
|
+
export interface LifecycleFieldsIface {
|
|
5
|
+
idleTimeoutS: number | null;
|
|
6
|
+
idlePolicy: IdlePolicy | undefined;
|
|
7
|
+
autoResume: boolean | undefined;
|
|
8
|
+
wallClockLimitS: number | null | undefined;
|
|
9
|
+
maxLifetime: MaxLifetimeBodyIface | null;
|
|
10
|
+
}
|
|
11
|
+
export declare const lifecycleFields: (lifecycle: LifecycleIface, defaultWallClockS?: number) => LifecycleFieldsIface;
|
|
12
|
+
export interface LifecycleStateIface {
|
|
13
|
+
idleTimeoutS: number | null;
|
|
14
|
+
idleTimeoutDisabled: boolean;
|
|
15
|
+
idlePolicy: IdlePolicy;
|
|
16
|
+
autoResume: boolean;
|
|
17
|
+
maxLifetime: {
|
|
18
|
+
afterS: number;
|
|
19
|
+
action: 'stop' | 'delete';
|
|
20
|
+
} | null;
|
|
21
|
+
wallClockLimitS: number | null;
|
|
22
|
+
wallClockDeadlineAt: Date | null;
|
|
23
|
+
running: boolean;
|
|
24
|
+
}
|
|
25
|
+
export declare const lifecycleOf: (state: LifecycleStateIface) => LifecycleIface;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { IdleAction, MaxAction } from "@finalai/sandbox-router/provider";
|
|
2
|
+
import { IdlePolicy, MaxLifetimeFrom } from "./vm/resources.mjs";
|
|
3
|
+
const DEFAULT_WALL_CLOCK_S = 365 * 24 * 60 * 60;
|
|
4
|
+
const IDLE_POLICIES = {
|
|
5
|
+
[IdleAction.Pause]: IdlePolicy.Pause,
|
|
6
|
+
[IdleAction.Stop]: IdlePolicy.Stop,
|
|
7
|
+
[IdleAction.Delete]: IdlePolicy.Delete
|
|
8
|
+
};
|
|
9
|
+
const lifecycleFields = (lifecycle, defaultWallClockS = DEFAULT_WALL_CLOCK_S) => {
|
|
10
|
+
const { idle, max } = lifecycle;
|
|
11
|
+
return {
|
|
12
|
+
idleTimeoutS: idle?.afterS ?? null,
|
|
13
|
+
idlePolicy: idle == null ? void 0 : IDLE_POLICIES[idle.action],
|
|
14
|
+
autoResume: lifecycle.autoResume,
|
|
15
|
+
wallClockLimitS: max === void 0 ? defaultWallClockS : max === null ? null : void 0,
|
|
16
|
+
maxLifetime: max == null ? null : { after_s: max.afterS, action: max.action, from: MaxLifetimeFrom.Start }
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
const IDLE_ACTIONS = {
|
|
20
|
+
[IdlePolicy.Pause]: IdleAction.Pause,
|
|
21
|
+
[IdlePolicy.Stop]: IdleAction.Stop,
|
|
22
|
+
[IdlePolicy.Delete]: IdleAction.Delete
|
|
23
|
+
};
|
|
24
|
+
const MAX_ACTIONS = {
|
|
25
|
+
[IdlePolicy.Stop]: MaxAction.Stop,
|
|
26
|
+
[IdlePolicy.Delete]: MaxAction.Delete
|
|
27
|
+
};
|
|
28
|
+
const lifecycleOf = (state) => {
|
|
29
|
+
const idle = state.idleTimeoutDisabled ? null : state.idleTimeoutS == null ? void 0 : { afterS: state.idleTimeoutS, action: IDLE_ACTIONS[state.idlePolicy] };
|
|
30
|
+
const wallClockAction = MAX_ACTIONS[state.idlePolicy];
|
|
31
|
+
const max = state.maxLifetime != null ? {
|
|
32
|
+
afterS: state.maxLifetime.afterS,
|
|
33
|
+
action: state.maxLifetime.action === "stop" ? MaxAction.Stop : MaxAction.Delete
|
|
34
|
+
} : state.wallClockLimitS != null ? wallClockAction == null ? void 0 : { afterS: state.wallClockLimitS, action: wallClockAction } : state.running && state.wallClockDeadlineAt == null ? null : void 0;
|
|
35
|
+
return {
|
|
36
|
+
...idle === void 0 ? {} : { idle },
|
|
37
|
+
...max === void 0 ? {} : { max },
|
|
38
|
+
autoResume: state.autoResume
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export {
|
|
42
|
+
DEFAULT_WALL_CLOCK_S,
|
|
43
|
+
lifecycleFields,
|
|
44
|
+
lifecycleOf
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=lifecycle.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/lifecycle.ts"],
|
|
4
|
+
"sourcesContent": ["import { IdleAction, MaxAction, type LifecycleIface } from '@finalai/sandbox-router/provider';\nimport { IdlePolicy, MaxLifetimeFrom, type MaxLifetimeBodyIface } from \"./vm/resources.mjs\";\n\n// A lifecycle in the platform's terms. The idle policy answers to idleness. A max lifetime stops\n// or deletes the sandbox a time after its latest start (create being the first), in any state,\n// and replaces the wall-clock limit; without one, the wall-clock limit applies the idle policy to\n// a sandbox that has run that long since it last started or resumed.\n\n// This adapter's default for a lifecycle that leaves `max` out: a wall-clock limit of one year,\n// which create caps at the plan's maximum (30 days by default). The platform's own default is a\n// day.\nexport const DEFAULT_WALL_CLOCK_S = 365 * 24 * 60 * 60;\n\nconst IDLE_POLICIES: Record<IdleAction, IdlePolicy> = {\n [IdleAction.Pause]: IdlePolicy.Pause,\n [IdleAction.Stop]: IdlePolicy.Stop,\n [IdleAction.Delete]: IdlePolicy.Delete,\n};\n\nexport interface LifecycleFieldsIface {\n // Null: no idle timeout. This adapter has none by default (the platform's is five minutes).\n idleTimeoutS: number | null;\n // Undefined: the platform's default (pause).\n idlePolicy: IdlePolicy | undefined;\n // Undefined: the platform's default (wakes).\n autoResume: boolean | undefined;\n // Null: none, for organizations entitled to run without one. Undefined: a max lifetime\n // replaces it.\n wallClockLimitS: number | null | undefined;\n // Undefined: none to set (create) or keep; null removes one.\n maxLifetime: MaxLifetimeBodyIface | null;\n}\n\nexport const lifecycleFields = (\n lifecycle: LifecycleIface,\n defaultWallClockS: number = DEFAULT_WALL_CLOCK_S,\n): LifecycleFieldsIface => {\n const { idle, max } = lifecycle;\n return {\n idleTimeoutS: idle?.afterS ?? null,\n idlePolicy: idle == null ? undefined : IDLE_POLICIES[idle.action],\n autoResume: lifecycle.autoResume,\n wallClockLimitS: max === undefined ? defaultWallClockS : max === null ? null : undefined,\n maxLifetime:\n max == null ? null : { after_s: max.afterS, action: max.action, from: MaxLifetimeFrom.Start },\n };\n};\n\nconst IDLE_ACTIONS: Record<IdlePolicy, IdleAction> = {\n [IdlePolicy.Pause]: IdleAction.Pause,\n [IdlePolicy.Stop]: IdleAction.Stop,\n [IdlePolicy.Delete]: IdleAction.Delete,\n};\n\nconst MAX_ACTIONS: Partial<Record<IdlePolicy, MaxAction>> = {\n [IdlePolicy.Stop]: MaxAction.Stop,\n [IdlePolicy.Delete]: MaxAction.Delete,\n};\n\nexport interface LifecycleStateIface {\n // As set; null when the platform's default applies or the timer is off.\n idleTimeoutS: number | null;\n idleTimeoutDisabled: boolean;\n idlePolicy: IdlePolicy;\n autoResume: boolean;\n // Its own lifetime (a create's time to live reads as a delete from create).\n maxLifetime: { afterS: number; action: 'stop' | 'delete' } | null;\n wallClockLimitS: number | null;\n // Set while running unless the wall-clock limit is off or replaced.\n wallClockDeadlineAt: Date | null;\n running: boolean;\n}\n\n// The lifecycle in force, as far as the API shows it. A field at the platform's default is left\n// out (the API does not say what the default is), and so is a wall-clock limit that pauses,\n// which has no router equivalent. A lifetime counted from create is reported as a maximum like\n// one counted from the latest start. The wall-clock limit is reported as kept, capped at the\n// plan's maximum.\nexport const lifecycleOf = (state: LifecycleStateIface): LifecycleIface => {\n const idle = state.idleTimeoutDisabled\n ? null\n : state.idleTimeoutS == null\n ? undefined\n : { afterS: state.idleTimeoutS, action: IDLE_ACTIONS[state.idlePolicy] };\n const wallClockAction = MAX_ACTIONS[state.idlePolicy];\n const max =\n state.maxLifetime != null\n ? {\n afterS: state.maxLifetime.afterS,\n action: state.maxLifetime.action === 'stop' ? MaxAction.Stop : MaxAction.Delete,\n }\n : state.wallClockLimitS != null\n ? wallClockAction == null\n ? undefined\n : { afterS: state.wallClockLimitS, action: wallClockAction }\n : state.running && state.wallClockDeadlineAt == null\n ? null\n : undefined;\n return {\n ...(idle === undefined ? {} : { idle }),\n ...(max === undefined ? {} : { max }),\n autoResume: state.autoResume,\n };\n};\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,YAAY,iBAAsC;AAC3D,SAAS,YAAY,uBAAkD;AAUhE,MAAM,uBAAuB,MAAM,KAAK,KAAK;AAEpD,MAAM,gBAAgD;AAAA,EACpD,CAAC,WAAW,KAAK,GAAG,WAAW;AAAA,EAC/B,CAAC,WAAW,IAAI,GAAG,WAAW;AAAA,EAC9B,CAAC,WAAW,MAAM,GAAG,WAAW;AAClC;AAgBO,MAAM,kBAAkB,CAC7B,WACA,oBAA4B,yBACH;AACzB,QAAM,EAAE,MAAM,IAAI,IAAI;AACtB,SAAO;AAAA,IACL,cAAc,MAAM,UAAU;AAAA,IAC9B,YAAY,QAAQ,OAAO,SAAY,cAAc,KAAK,MAAM;AAAA,IAChE,YAAY,UAAU;AAAA,IACtB,iBAAiB,QAAQ,SAAY,oBAAoB,QAAQ,OAAO,OAAO;AAAA,IAC/E,aACE,OAAO,OAAO,OAAO,EAAE,SAAS,IAAI,QAAQ,QAAQ,IAAI,QAAQ,MAAM,gBAAgB,MAAM;AAAA,EAChG;AACF;AAEA,MAAM,eAA+C;AAAA,EACnD,CAAC,WAAW,KAAK,GAAG,WAAW;AAAA,EAC/B,CAAC,WAAW,IAAI,GAAG,WAAW;AAAA,EAC9B,CAAC,WAAW,MAAM,GAAG,WAAW;AAClC;AAEA,MAAM,cAAsD;AAAA,EAC1D,CAAC,WAAW,IAAI,GAAG,UAAU;AAAA,EAC7B,CAAC,WAAW,MAAM,GAAG,UAAU;AACjC;AAqBO,MAAM,cAAc,CAAC,UAA+C;AACzE,QAAM,OAAO,MAAM,sBACf,OACA,MAAM,gBAAgB,OACpB,SACA,EAAE,QAAQ,MAAM,cAAc,QAAQ,aAAa,MAAM,UAAU,EAAE;AAC3E,QAAM,kBAAkB,YAAY,MAAM,UAAU;AACpD,QAAM,MACJ,MAAM,eAAe,OACjB;AAAA,IACE,QAAQ,MAAM,YAAY;AAAA,IAC1B,QAAQ,MAAM,YAAY,WAAW,SAAS,UAAU,OAAO,UAAU;AAAA,EAC3E,IACA,MAAM,mBAAmB,OACvB,mBAAmB,OACjB,SACA,EAAE,QAAQ,MAAM,iBAAiB,QAAQ,gBAAgB,IAC3D,MAAM,WAAW,MAAM,uBAAuB,OAC5C,OACA;AACV,SAAO;AAAA,IACL,GAAI,SAAS,SAAY,CAAC,IAAI,EAAE,KAAK;AAAA,IACrC,GAAI,QAAQ,SAAY,CAAC,IAAI,EAAE,IAAI;AAAA,IACnC,YAAY,MAAM;AAAA,EACpB;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -3,4 +3,5 @@ export declare const PROVIDER = "final";
|
|
|
3
3
|
export declare const regions: string[];
|
|
4
4
|
export declare const capabilities: Capability[];
|
|
5
5
|
export declare const DEFAULT_DISK_GIB = 10;
|
|
6
|
+
export declare const DEFAULT_VOLUME_GIB = 10;
|
|
6
7
|
export declare const limits: ProviderLimitsIface;
|
package/dist/modules/limits.mjs
CHANGED
|
@@ -14,9 +14,27 @@ const capabilities = [
|
|
|
14
14
|
Capability.PublicPorts,
|
|
15
15
|
Capability.DirectConnect,
|
|
16
16
|
Capability.IdleTimeout,
|
|
17
|
-
Capability.
|
|
17
|
+
Capability.IdleStop,
|
|
18
|
+
Capability.MaxLifetime,
|
|
19
|
+
Capability.AutoResume,
|
|
20
|
+
Capability.Burst,
|
|
21
|
+
Capability.PortTokens,
|
|
22
|
+
Capability.ProcessList,
|
|
23
|
+
Capability.Service,
|
|
24
|
+
Capability.Placement,
|
|
25
|
+
Capability.Caches,
|
|
26
|
+
Capability.Telemetry,
|
|
27
|
+
Capability.Desktop,
|
|
28
|
+
Capability.ComputerUse,
|
|
29
|
+
Capability.CustomDomains,
|
|
30
|
+
Capability.ColdFiles,
|
|
31
|
+
// Pending live verification on dev (the platform's routes are not deployed yet).
|
|
32
|
+
Capability.Metrics,
|
|
33
|
+
Capability.Ingress,
|
|
34
|
+
Capability.Volumes
|
|
18
35
|
];
|
|
19
36
|
const DEFAULT_DISK_GIB = 10;
|
|
37
|
+
const DEFAULT_VOLUME_GIB = 10;
|
|
20
38
|
const limits = {
|
|
21
39
|
minCpu: 0.25,
|
|
22
40
|
maxCpu: 32,
|
|
@@ -29,6 +47,7 @@ const limits = {
|
|
|
29
47
|
};
|
|
30
48
|
export {
|
|
31
49
|
DEFAULT_DISK_GIB,
|
|
50
|
+
DEFAULT_VOLUME_GIB,
|
|
32
51
|
PROVIDER,
|
|
33
52
|
capabilities,
|
|
34
53
|
limits,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/limits.ts"],
|
|
4
|
-
"sourcesContent": ["import { Capability, type ProviderLimitsIface } from '@finalai/sandbox-router/provider';\n\nexport const PROVIDER = 'final';\n\nexport const regions = ['us-west'];\n\nexport const capabilities: Capability[] = [\n Capability.Labels,\n Capability.Pause,\n Capability.Resume,\n Capability.Stop,\n Capability.Snapshot,\n Capability.Fork,\n Capability.Pty,\n Capability.Image,\n Capability.NetworkPolicy,\n Capability.PublicPorts,\n Capability.DirectConnect,\n Capability.IdleTimeout,\n Capability.MaxLifetime,\n];\n\n// The disk a sandbox gets when the spec names none.\nexport const DEFAULT_DISK_GIB = 10;\n\nexport const limits: ProviderLimitsIface = {\n minCpu: 0.25,\n maxCpu: 32,\n minMemoryMib: 256,\n maxMemoryMib: 65_536,\n memoryStepMib: 1,\n maxDiskGib: 2_048,\n // Enforced by this adapter: a process that writes more ends with `output_cap`.\n maxOutputBytes: 16 * 1024 * 1024,\n};\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,kBAA4C;AAE9C,MAAM,WAAW;AAEjB,MAAM,UAAU,CAAC,SAAS;AAE1B,MAAM,eAA6B;AAAA,EACxC,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AACb;AAGO,MAAM,mBAAmB;
|
|
4
|
+
"sourcesContent": ["import { Capability, type ProviderLimitsIface } from '@finalai/sandbox-router/provider';\n\nexport const PROVIDER = 'final';\n\nexport const regions = ['us-west'];\n\nexport const capabilities: Capability[] = [\n Capability.Labels,\n Capability.Pause,\n Capability.Resume,\n Capability.Stop,\n Capability.Snapshot,\n Capability.Fork,\n Capability.Pty,\n Capability.Image,\n Capability.NetworkPolicy,\n Capability.PublicPorts,\n Capability.DirectConnect,\n Capability.IdleTimeout,\n Capability.IdleStop,\n Capability.MaxLifetime,\n Capability.AutoResume,\n Capability.Burst,\n Capability.PortTokens,\n Capability.ProcessList,\n Capability.Service,\n Capability.Placement,\n Capability.Caches,\n Capability.Telemetry,\n Capability.Desktop,\n Capability.ComputerUse,\n Capability.CustomDomains,\n Capability.ColdFiles,\n // Pending live verification on dev (the platform's routes are not deployed yet).\n Capability.Metrics,\n Capability.Ingress,\n Capability.Volumes,\n];\n\n// The disk a sandbox gets when the spec names none.\nexport const DEFAULT_DISK_GIB = 10;\n\n// The size a volume gets when its create names none.\nexport const DEFAULT_VOLUME_GIB = 10;\n\nexport const limits: ProviderLimitsIface = {\n minCpu: 0.25,\n maxCpu: 32,\n minMemoryMib: 256,\n maxMemoryMib: 65_536,\n memoryStepMib: 1,\n maxDiskGib: 2_048,\n // Enforced by this adapter: a process that writes more ends with `output_cap`.\n maxOutputBytes: 16 * 1024 * 1024,\n};\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,kBAA4C;AAE9C,MAAM,WAAW;AAEjB,MAAM,UAAU,CAAC,SAAS;AAE1B,MAAM,eAA6B;AAAA,EACxC,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA;AAAA,EAEX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AACb;AAGO,MAAM,mBAAmB;AAGzB,MAAM,qBAAqB;AAE3B,MAAM,SAA8B;AAAA,EACzC,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,cAAc;AAAA,EACd,cAAc;AAAA,EACd,eAAe;AAAA,EACf,YAAY;AAAA;AAAA,EAEZ,gBAAgB,KAAK,OAAO;AAC9B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|