@finalai/sandbox-router-final 0.0.0-stage → 0.2.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.
Files changed (67) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +4 -0
  3. package/README.md +38 -2
  4. package/dist/modules/frames.d.mts +18 -0
  5. package/dist/modules/frames.mjs +98 -0
  6. package/dist/modules/frames.mjs.map +7 -0
  7. package/dist/modules/images.d.mts +15 -0
  8. package/dist/modules/images.mjs +116 -0
  9. package/dist/modules/images.mjs.map +7 -0
  10. package/dist/modules/index.d.mts +4 -0
  11. package/dist/modules/index.mjs +16 -0
  12. package/dist/modules/index.mjs.map +7 -0
  13. package/dist/modules/limits.d.mts +6 -0
  14. package/dist/modules/limits.mjs +37 -0
  15. package/dist/modules/limits.mjs.map +7 -0
  16. package/dist/modules/options.d.mts +24 -0
  17. package/dist/modules/options.mjs +19 -0
  18. package/dist/modules/options.mjs.map +7 -0
  19. package/dist/modules/provider.d.mts +5 -0
  20. package/dist/modules/provider.mjs +647 -0
  21. package/dist/modules/provider.mjs.map +7 -0
  22. package/dist/modules/vm/api.d.mts +28 -0
  23. package/dist/modules/vm/api.mjs +94 -0
  24. package/dist/modules/vm/api.mjs.map +7 -0
  25. package/dist/modules/vm/client.d.mts +104 -0
  26. package/dist/modules/vm/client.mjs +186 -0
  27. package/dist/modules/vm/client.mjs.map +7 -0
  28. package/dist/modules/vm/clock.d.mts +5 -0
  29. package/dist/modules/vm/clock.mjs +11 -0
  30. package/dist/modules/vm/clock.mjs.map +7 -0
  31. package/dist/modules/vm/errors.d.mts +23 -0
  32. package/dist/modules/vm/errors.mjs +30 -0
  33. package/dist/modules/vm/errors.mjs.map +7 -0
  34. package/dist/modules/vm/exec.d.mts +47 -0
  35. package/dist/modules/vm/exec.mjs +292 -0
  36. package/dist/modules/vm/exec.mjs.map +7 -0
  37. package/dist/modules/vm/files.d.mts +18 -0
  38. package/dist/modules/vm/files.mjs +160 -0
  39. package/dist/modules/vm/files.mjs.map +7 -0
  40. package/dist/modules/vm/grants.d.mts +35 -0
  41. package/dist/modules/vm/grants.mjs +106 -0
  42. package/dist/modules/vm/grants.mjs.map +7 -0
  43. package/dist/modules/vm/ids.d.mts +3 -0
  44. package/dist/modules/vm/ids.mjs +35 -0
  45. package/dist/modules/vm/ids.mjs.map +7 -0
  46. package/dist/modules/vm/ingress.d.mts +99 -0
  47. package/dist/modules/vm/ingress.mjs +263 -0
  48. package/dist/modules/vm/ingress.mjs.map +7 -0
  49. package/dist/modules/vm/machines.d.mts +79 -0
  50. package/dist/modules/vm/machines.mjs +60 -0
  51. package/dist/modules/vm/machines.mjs.map +7 -0
  52. package/dist/modules/vm/network.d.mts +17 -0
  53. package/dist/modules/vm/network.mjs +44 -0
  54. package/dist/modules/vm/network.mjs.map +7 -0
  55. package/dist/modules/vm/sandbox.d.mts +75 -0
  56. package/dist/modules/vm/sandbox.mjs +175 -0
  57. package/dist/modules/vm/sandbox.mjs.map +7 -0
  58. package/dist/modules/vm/schemas.d.mts +1209 -0
  59. package/dist/modules/vm/schemas.mjs +289 -0
  60. package/dist/modules/vm/schemas.mjs.map +7 -0
  61. package/dist/modules/vm/wire.d.mts +3 -0
  62. package/dist/modules/vm/wire.mjs +9 -0
  63. package/dist/modules/vm/wire.mjs.map +7 -0
  64. package/dist/modules/vm/workload.d.mts +14 -0
  65. package/dist/modules/vm/workload.mjs +11 -0
  66. package/dist/modules/vm/workload.mjs.map +7 -0
  67. package/package.json +38 -4
@@ -0,0 +1,79 @@
1
+ import * as z from 'zod';
2
+ import { type ApiTransport } from "./api.mjs";
3
+ export declare enum MachineSort {
4
+ Price = "price",
5
+ Order = "order"
6
+ }
7
+ export interface MachineOptionsIface {
8
+ types?: string[];
9
+ cpuFamilies?: string[];
10
+ sort?: MachineSort;
11
+ maxPricePerHour?: string;
12
+ }
13
+ export declare const machineBody: (options: MachineOptionsIface | undefined) => {
14
+ types: string[] | undefined;
15
+ cpu_families: string[] | undefined;
16
+ sort: MachineSort | undefined;
17
+ max_price_per_hour: string | undefined;
18
+ } | undefined;
19
+ declare const machineTypeSchema: z.ZodPipe<z.ZodObject<{
20
+ machine_type: z.ZodString;
21
+ hardware: z.ZodObject<{
22
+ provider: z.ZodString;
23
+ cpu_model: z.ZodString;
24
+ cpu_family: z.ZodString;
25
+ }, z.core.$strip>;
26
+ price: z.ZodObject<{
27
+ currency: z.ZodString;
28
+ hourly: z.ZodOptional<z.ZodNullable<z.ZodObject<{
29
+ baseline: z.ZodString;
30
+ ceiling: z.ZodString;
31
+ }, z.core.$strip>>>;
32
+ rates: z.ZodObject<{
33
+ disk_gib_month: z.ZodOptional<z.ZodNullable<z.ZodString>>;
34
+ }, z.core.$strip>;
35
+ }, z.core.$strip>;
36
+ }, z.core.$strip>, z.ZodTransform<{
37
+ machineType: string;
38
+ hardware: {
39
+ provider: string;
40
+ cpuModel: string;
41
+ cpuFamily: string;
42
+ };
43
+ price: {
44
+ currency: string;
45
+ hourly: {
46
+ baseline: string;
47
+ ceiling: string;
48
+ } | null;
49
+ diskGibMonth: string | null;
50
+ };
51
+ }, {
52
+ machine_type: string;
53
+ hardware: {
54
+ provider: string;
55
+ cpu_model: string;
56
+ cpu_family: string;
57
+ };
58
+ price: {
59
+ currency: string;
60
+ rates: {
61
+ disk_gib_month?: string | null | undefined;
62
+ };
63
+ hourly?: {
64
+ baseline: string;
65
+ ceiling: string;
66
+ } | null | undefined;
67
+ };
68
+ }>>;
69
+ export type MachineTypeIface = z.output<typeof machineTypeSchema>;
70
+ export interface MachineSizeIface {
71
+ cpu?: [request: number, limit: number];
72
+ memory?: [request: number, limit: number];
73
+ diskGb?: number;
74
+ }
75
+ export interface MachineTypesIface {
76
+ list: (size?: MachineSizeIface) => Promise<MachineTypeIface[]>;
77
+ }
78
+ export declare const createMachineTypesApi: (api: ApiTransport) => MachineTypesIface;
79
+ export {};
@@ -0,0 +1,60 @@
1
+ import * as z from "zod";
2
+ import { HttpMethod } from "./api.mjs";
3
+ var MachineSort = /* @__PURE__ */ ((MachineSort2) => {
4
+ MachineSort2["Price"] = "price";
5
+ MachineSort2["Order"] = "order";
6
+ return MachineSort2;
7
+ })(MachineSort || {});
8
+ const machineBody = (options) => options == null ? void 0 : {
9
+ types: options.types,
10
+ cpu_families: options.cpuFamilies,
11
+ sort: options.sort,
12
+ max_price_per_hour: options.maxPricePerHour
13
+ };
14
+ const machineTypeSchema = z.object({
15
+ machine_type: z.string(),
16
+ hardware: z.object({
17
+ provider: z.string(),
18
+ cpu_model: z.string(),
19
+ cpu_family: z.string()
20
+ }),
21
+ price: z.object({
22
+ currency: z.string(),
23
+ hourly: z.object({ baseline: z.string(), ceiling: z.string() }).nullable().optional(),
24
+ rates: z.object({ disk_gib_month: z.string().nullish() })
25
+ })
26
+ }).transform((value) => ({
27
+ machineType: value.machine_type,
28
+ hardware: {
29
+ provider: value.hardware.provider,
30
+ cpuModel: value.hardware.cpu_model,
31
+ cpuFamily: value.hardware.cpu_family
32
+ },
33
+ price: {
34
+ currency: value.price.currency,
35
+ // One running hour of the size: idle at its CPU and memory requests (`baseline`), and
36
+ // with every CPU busy and all memory used up to the limits (`ceiling`).
37
+ hourly: value.price.hourly ?? null,
38
+ diskGibMonth: value.price.rates.disk_gib_month ?? null
39
+ }
40
+ }));
41
+ const createMachineTypesApi = (api) => ({
42
+ list: async (size = {}) => (await api({
43
+ method: HttpMethod.Get,
44
+ path: "/machine-types",
45
+ query: {
46
+ cpu_request: size.cpu?.[0],
47
+ cpu_limit: size.cpu?.[1],
48
+ memory_request: size.memory?.[0],
49
+ memory_limit: size.memory?.[1],
50
+ disk_gb: size.diskGb
51
+ },
52
+ schema: z.object({ machine_types: z.array(machineTypeSchema) })
53
+ })).machine_types
54
+ });
55
+ export {
56
+ MachineSort,
57
+ createMachineTypesApi,
58
+ machineBody
59
+ };
60
+ //# sourceMappingURL=machines.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/vm/machines.ts"],
4
+ "sourcesContent": ["import * as z from 'zod';\nimport { HttpMethod, type ApiTransport } from \"./api.mjs\";\n\n// Machine types a sandbox can run on. Money is decimal strings in the price's currency.\n\nexport enum MachineSort {\n // Lowest price for the sandbox's size first.\n Price = 'price',\n // The order of `types`.\n Order = 'order',\n}\n\nexport interface MachineOptionsIface {\n // Only these machine types; one pins it to that type.\n types?: string[];\n // Only these CPU microarchitectures.\n cpuFamilies?: string[];\n // Default `price`; `order` needs `types`.\n sort?: MachineSort;\n // The most one running hour may cost (USD), with every CPU busy up to the size's limit.\n maxPricePerHour?: string;\n}\n\nexport const machineBody = (options: MachineOptionsIface | undefined) =>\n options == null\n ? undefined\n : {\n types: options.types,\n cpu_families: options.cpuFamilies,\n sort: options.sort,\n max_price_per_hour: options.maxPricePerHour,\n };\n\nconst machineTypeSchema = z\n .object({\n machine_type: z.string(),\n hardware: z.object({\n provider: z.string(),\n cpu_model: z.string(),\n cpu_family: z.string(),\n }),\n price: z.object({\n currency: z.string(),\n hourly: z.object({ baseline: z.string(), ceiling: z.string() }).nullable().optional(),\n rates: z.object({ disk_gib_month: z.string().nullish() }),\n }),\n })\n .transform((value) => ({\n machineType: value.machine_type,\n hardware: {\n provider: value.hardware.provider,\n cpuModel: value.hardware.cpu_model,\n cpuFamily: value.hardware.cpu_family,\n },\n price: {\n currency: value.price.currency,\n // One running hour of the size: idle at its CPU and memory requests (`baseline`), and\n // with every CPU busy and all memory used up to the limits (`ceiling`).\n hourly: value.price.hourly ?? null,\n diskGibMonth: value.price.rates.disk_gib_month ?? null,\n },\n }));\n\nexport type MachineTypeIface = z.output<typeof machineTypeSchema>;\n\nexport interface MachineSizeIface {\n cpu?: [request: number, limit: number];\n // MiB.\n memory?: [request: number, limit: number];\n diskGb?: number;\n}\n\nexport interface MachineTypesIface {\n // Where new sandboxes can run now; with a size, each carries that size's price, cheapest\n // first.\n list: (size?: MachineSizeIface) => Promise<MachineTypeIface[]>;\n}\n\nexport const createMachineTypesApi = (api: ApiTransport): MachineTypesIface => ({\n list: async (size = {}) =>\n (\n await api({\n method: HttpMethod.Get,\n path: '/machine-types',\n query: {\n cpu_request: size.cpu?.[0],\n cpu_limit: size.cpu?.[1],\n memory_request: size.memory?.[0],\n memory_limit: size.memory?.[1],\n disk_gb: size.diskGb,\n },\n schema: z.object({ machine_types: z.array(machineTypeSchema) }),\n })\n ).machine_types,\n});\n"],
5
+ "mappings": "AAAA,YAAY,OAAO;AACnB,SAAS,kBAAqC;AAIvC,IAAK,cAAL,kBAAKA,iBAAL;AAEL,EAAAA,aAAA,WAAQ;AAER,EAAAA,aAAA,WAAQ;AAJE,SAAAA;AAAA,GAAA;AAkBL,MAAM,cAAc,CAAC,YAC1B,WAAW,OACP,SACA;AAAA,EACE,OAAO,QAAQ;AAAA,EACf,cAAc,QAAQ;AAAA,EACtB,MAAM,QAAQ;AAAA,EACd,oBAAoB,QAAQ;AAC9B;AAEN,MAAM,oBAAoB,EACvB,OAAO;AAAA,EACN,cAAc,EAAE,OAAO;AAAA,EACvB,UAAU,EAAE,OAAO;AAAA,IACjB,UAAU,EAAE,OAAO;AAAA,IACnB,WAAW,EAAE,OAAO;AAAA,IACpB,YAAY,EAAE,OAAO;AAAA,EACvB,CAAC;AAAA,EACD,OAAO,EAAE,OAAO;AAAA,IACd,UAAU,EAAE,OAAO;AAAA,IACnB,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,GAAG,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,SAAS;AAAA,IACpF,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;AAAA,EAC1D,CAAC;AACH,CAAC,EACA,UAAU,CAAC,WAAW;AAAA,EACrB,aAAa,MAAM;AAAA,EACnB,UAAU;AAAA,IACR,UAAU,MAAM,SAAS;AAAA,IACzB,UAAU,MAAM,SAAS;AAAA,IACzB,WAAW,MAAM,SAAS;AAAA,EAC5B;AAAA,EACA,OAAO;AAAA,IACL,UAAU,MAAM,MAAM;AAAA;AAAA;AAAA,IAGtB,QAAQ,MAAM,MAAM,UAAU;AAAA,IAC9B,cAAc,MAAM,MAAM,MAAM,kBAAkB;AAAA,EACpD;AACF,EAAE;AAiBG,MAAM,wBAAwB,CAAC,SAA0C;AAAA,EAC9E,MAAM,OAAO,OAAO,CAAC,OAEjB,MAAM,IAAI;AAAA,IACR,QAAQ,WAAW;AAAA,IACnB,MAAM;AAAA,IACN,OAAO;AAAA,MACL,aAAa,KAAK,MAAM,CAAC;AAAA,MACzB,WAAW,KAAK,MAAM,CAAC;AAAA,MACvB,gBAAgB,KAAK,SAAS,CAAC;AAAA,MAC/B,cAAc,KAAK,SAAS,CAAC;AAAA,MAC7B,SAAS,KAAK;AAAA,IAChB;AAAA,IACA,QAAQ,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,EAAE,CAAC;AAAA,EAChE,CAAC,GACD;AACN;",
6
+ "names": ["MachineSort"]
7
+ }
@@ -0,0 +1,17 @@
1
+ import { type ApiTransport } from "./api.mjs";
2
+ export interface NetworkPolicyIface {
3
+ allowInternet: boolean;
4
+ allowCidrs?: string[];
5
+ denyCidrs?: string[];
6
+ allowDomains?: string[];
7
+ }
8
+ export interface NetworkStatusIface {
9
+ policy: NetworkPolicyIface;
10
+ revision: number | null;
11
+ applied: boolean;
12
+ }
13
+ export interface NetworkIface {
14
+ get: () => Promise<NetworkStatusIface>;
15
+ set: (policy: NetworkPolicyIface) => Promise<NetworkStatusIface>;
16
+ }
17
+ export declare const createNetworkHandle: (api: ApiTransport, id: string) => NetworkIface;
@@ -0,0 +1,44 @@
1
+ import * as z from "zod";
2
+ import { HttpMethod } from "./api.mjs";
3
+ const statusSchema = z.object({
4
+ policy: z.object({
5
+ allow_internet: z.boolean(),
6
+ allow_cidrs: z.array(z.string()),
7
+ deny_cidrs: z.array(z.string()),
8
+ allow_domains: z.array(z.string())
9
+ }),
10
+ revision: z.number().int().positive().nullable(),
11
+ applied: z.boolean()
12
+ }).transform(
13
+ ({ policy, ...status }) => ({
14
+ ...status,
15
+ policy: {
16
+ allowInternet: policy.allow_internet,
17
+ allowCidrs: policy.allow_cidrs,
18
+ denyCidrs: policy.deny_cidrs,
19
+ allowDomains: policy.allow_domains
20
+ }
21
+ })
22
+ );
23
+ const createNetworkHandle = (api, id) => ({
24
+ get: () => api({
25
+ method: HttpMethod.Get,
26
+ path: `/sandboxes/${encodeURIComponent(id)}/network`,
27
+ schema: statusSchema
28
+ }),
29
+ set: (policy) => api({
30
+ method: HttpMethod.Put,
31
+ path: `/sandboxes/${encodeURIComponent(id)}/network`,
32
+ schema: statusSchema,
33
+ body: {
34
+ allow_internet: policy.allowInternet,
35
+ allow_cidrs: policy.allowCidrs ?? [],
36
+ deny_cidrs: policy.denyCidrs ?? [],
37
+ allow_domains: policy.allowDomains ?? []
38
+ }
39
+ })
40
+ });
41
+ export {
42
+ createNetworkHandle
43
+ };
44
+ //# sourceMappingURL=network.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/vm/network.ts"],
4
+ "sourcesContent": ["import * as z from 'zod';\nimport { HttpMethod, type ApiTransport } from \"./api.mjs\";\n\nexport interface NetworkPolicyIface {\n allowInternet: boolean;\n allowCidrs?: string[];\n denyCidrs?: string[];\n allowDomains?: string[];\n}\n\nexport interface NetworkStatusIface {\n policy: NetworkPolicyIface;\n revision: number | null;\n applied: boolean;\n}\n\nexport interface NetworkIface {\n get: () => Promise<NetworkStatusIface>;\n set: (policy: NetworkPolicyIface) => Promise<NetworkStatusIface>;\n}\n\nconst statusSchema = z\n .object({\n policy: z.object({\n allow_internet: z.boolean(),\n allow_cidrs: z.array(z.string()),\n deny_cidrs: z.array(z.string()),\n allow_domains: z.array(z.string()),\n }),\n revision: z.number().int().positive().nullable(),\n applied: z.boolean(),\n })\n .transform(\n ({ policy, ...status }): NetworkStatusIface => ({\n ...status,\n policy: {\n allowInternet: policy.allow_internet,\n allowCidrs: policy.allow_cidrs,\n denyCidrs: policy.deny_cidrs,\n allowDomains: policy.allow_domains,\n },\n }),\n );\n\nexport const createNetworkHandle = (api: ApiTransport, id: string): NetworkIface => ({\n get: () =>\n api({\n method: HttpMethod.Get,\n path: `/sandboxes/${encodeURIComponent(id)}/network`,\n schema: statusSchema,\n }),\n set: (policy) =>\n api({\n method: HttpMethod.Put,\n path: `/sandboxes/${encodeURIComponent(id)}/network`,\n schema: statusSchema,\n body: {\n allow_internet: policy.allowInternet,\n allow_cidrs: policy.allowCidrs ?? [],\n deny_cidrs: policy.denyCidrs ?? [],\n allow_domains: policy.allowDomains ?? [],\n },\n }),\n});\n"],
5
+ "mappings": "AAAA,YAAY,OAAO;AACnB,SAAS,kBAAqC;AAoB9C,MAAM,eAAe,EAClB,OAAO;AAAA,EACN,QAAQ,EAAE,OAAO;AAAA,IACf,gBAAgB,EAAE,QAAQ;AAAA,IAC1B,aAAa,EAAE,MAAM,EAAE,OAAO,CAAC;AAAA,IAC/B,YAAY,EAAE,MAAM,EAAE,OAAO,CAAC;AAAA,IAC9B,eAAe,EAAE,MAAM,EAAE,OAAO,CAAC;AAAA,EACnC,CAAC;AAAA,EACD,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS;AAAA,EAC/C,SAAS,EAAE,QAAQ;AACrB,CAAC,EACA;AAAA,EACC,CAAC,EAAE,QAAQ,GAAG,OAAO,OAA2B;AAAA,IAC9C,GAAG;AAAA,IACH,QAAQ;AAAA,MACN,eAAe,OAAO;AAAA,MACtB,YAAY,OAAO;AAAA,MACnB,WAAW,OAAO;AAAA,MAClB,cAAc,OAAO;AAAA,IACvB;AAAA,EACF;AACF;AAEK,MAAM,sBAAsB,CAAC,KAAmB,QAA8B;AAAA,EACnF,KAAK,MACH,IAAI;AAAA,IACF,QAAQ,WAAW;AAAA,IACnB,MAAM,cAAc,mBAAmB,EAAE,CAAC;AAAA,IAC1C,QAAQ;AAAA,EACV,CAAC;AAAA,EACH,KAAK,CAAC,WACJ,IAAI;AAAA,IACF,QAAQ,WAAW;AAAA,IACnB,MAAM,cAAc,mBAAmB,EAAE,CAAC;AAAA,IAC1C,QAAQ;AAAA,IACR,MAAM;AAAA,MACJ,gBAAgB,OAAO;AAAA,MACvB,aAAa,OAAO,cAAc,CAAC;AAAA,MACnC,YAAY,OAAO,aAAa,CAAC;AAAA,MACjC,eAAe,OAAO,gBAAgB,CAAC;AAAA,IACzC;AAAA,EACF,CAAC;AACL;",
6
+ "names": []
7
+ }
@@ -0,0 +1,75 @@
1
+ import { type NetworkIface } from "./network.mjs";
2
+ import { type ApiTransport } from "./api.mjs";
3
+ import type { ClockIface } from "./clock.mjs";
4
+ import { type AttachOptionsIface, type ExecOptionsIface, type ExecProcessIface } from "./exec.mjs";
5
+ import { type FileStatIface, type ReadOptionsIface, type RunOptionsIface, type RunResultIface, type WriteOptionsIface } from "./ingress.mjs";
6
+ import { type ConnectGrantIface, type SandboxInfoIface, type SandboxOpResultIface } from "./schemas.mjs";
7
+ export interface SandboxContextIface {
8
+ api: ApiTransport;
9
+ fetch: typeof fetch;
10
+ clock: ClockIface;
11
+ previewDomain: string;
12
+ }
13
+ export interface SandboxIface {
14
+ network: NetworkIface;
15
+ id: string;
16
+ info: () => SandboxInfoIface;
17
+ refresh: () => Promise<SandboxInfoIface>;
18
+ pause: () => Promise<SandboxOpResultIface>;
19
+ resume: () => Promise<SandboxOpResultIface>;
20
+ stop: () => Promise<SandboxOpResultIface>;
21
+ start: () => Promise<SandboxOpResultIface>;
22
+ delete: () => Promise<SandboxOpResultIface>;
23
+ checkpoint: (options?: {
24
+ name?: string;
25
+ timeoutMs?: number;
26
+ }) => Promise<{
27
+ snapshotId: string;
28
+ }>;
29
+ fork: (count: number) => Promise<{
30
+ snapshotId: string;
31
+ children: SandboxIface[];
32
+ }>;
33
+ setTimeout: (wallClockLimitS: number) => Promise<SandboxOpResultIface>;
34
+ updateLabels: (labels: Record<string, string>) => Promise<Record<string, string>>;
35
+ connect: () => Promise<ConnectGrantIface>;
36
+ run: (cmd: string, options?: RunOptionsIface) => Promise<RunResultIface>;
37
+ exec: (options: ExecOptionsIface) => Promise<ExecProcessIface>;
38
+ attach: (options: AttachOptionsIface) => Promise<ExecProcessIface>;
39
+ files: {
40
+ read: (path: string, options?: ReadOptionsIface) => Promise<Uint8Array>;
41
+ write: (path: string, data: Uint8Array | string, options?: WriteOptionsIface) => Promise<{
42
+ bytesWritten: number;
43
+ }>;
44
+ stat: (path: string, options?: {
45
+ signal?: AbortSignal;
46
+ }) => Promise<FileStatIface | null>;
47
+ list: (path: string, options?: {
48
+ signal?: AbortSignal;
49
+ }) => Promise<{
50
+ entries: FileStatIface[];
51
+ truncated: boolean;
52
+ }>;
53
+ mkdir: (path: string, options?: {
54
+ parents?: boolean;
55
+ }) => Promise<void>;
56
+ remove: (path: string, options?: {
57
+ recursive?: boolean;
58
+ }) => Promise<void>;
59
+ };
60
+ previewUrl: (port: number) => Promise<string>;
61
+ listPorts: () => Promise<{
62
+ port: number;
63
+ public: boolean;
64
+ }[]>;
65
+ createPreviewToken: (port: number, options?: {
66
+ ttlS?: number;
67
+ }) => Promise<{
68
+ token: string;
69
+ expiresAt: Date;
70
+ }>;
71
+ }
72
+ export declare const createSandboxHandle: (ctx: SandboxContextIface, initial: SandboxInfoIface, initialGrant?: {
73
+ grant: ConnectGrantIface | null;
74
+ requestedAt: number;
75
+ }) => SandboxIface;
@@ -0,0 +1,175 @@
1
+ import * as z from "zod";
2
+ import { createFileReader } from "./files.mjs";
3
+ import { createNetworkHandle } from "./network.mjs";
4
+ import { HttpMethod } from "./api.mjs";
5
+ import { vmError, VmErrorSource } from "./errors.mjs";
6
+ import {
7
+ attachExec,
8
+ startExec
9
+ } from "./exec.mjs";
10
+ import { createGrantSource } from "./grants.mjs";
11
+ import {
12
+ createIngress,
13
+ makeDirectory,
14
+ removeFile,
15
+ runCommand,
16
+ writeFile
17
+ } from "./ingress.mjs";
18
+ import {
19
+ checkpointSchema,
20
+ snapshotSchema,
21
+ connectGrantSchema,
22
+ forkSchema,
23
+ labelsAnswerSchema,
24
+ portSchema,
25
+ previewTokenSchema,
26
+ sandboxInfoSchema,
27
+ sandboxOpSchema
28
+ } from "./schemas.mjs";
29
+ const CHECKPOINT_DURABLE_TIMEOUT_MS = 10 * 6e4;
30
+ const CHECKPOINT_POLL_MS = 500;
31
+ const path = (id, action) => `/sandboxes/${encodeURIComponent(id)}${action == null ? "" : `/${action}`}`;
32
+ const createSandboxHandle = (ctx, initial, initialGrant) => {
33
+ let info = initial;
34
+ const id = initial.id;
35
+ const mintGrant = (signal, refusedByHost) => ctx.api({
36
+ method: HttpMethod.Post,
37
+ path: path(id, "connect"),
38
+ body: { refused_by_host: refusedByHost },
39
+ idempotent: true,
40
+ schema: connectGrantSchema,
41
+ signal
42
+ });
43
+ const grants = createGrantSource({
44
+ mint: (signal, refusedByHost) => mintGrant(signal, refusedByHost),
45
+ clock: ctx.clock
46
+ });
47
+ const ingress = createIngress({
48
+ grants,
49
+ fetch: ctx.fetch,
50
+ clock: ctx.clock
51
+ });
52
+ const fileReader = createFileReader({ api: ctx.api, sandboxId: id });
53
+ const execTransport = { grants, clock: ctx.clock };
54
+ const seed = (grant, requestedAt) => {
55
+ if (grant != null) grants.seed(grant, requestedAt);
56
+ };
57
+ if (initialGrant != null) seed(initialGrant.grant, initialGrant.requestedAt);
58
+ const lifecycle = async (action, method = HttpMethod.Post, body) => {
59
+ const requestedAt = ctx.clock.now();
60
+ const result = await ctx.api({
61
+ method,
62
+ path: path(id, action ?? void 0),
63
+ body,
64
+ schema: sandboxOpSchema,
65
+ // State commands: a repeat finds the state already reached.
66
+ idempotent: true
67
+ });
68
+ grants.clear();
69
+ seed(result.connect, requestedAt);
70
+ info = result.sandbox;
71
+ return result;
72
+ };
73
+ return {
74
+ network: createNetworkHandle(ctx.api, id),
75
+ id,
76
+ info: () => info,
77
+ refresh: async () => {
78
+ info = await ctx.api({ method: HttpMethod.Get, path: path(id), schema: sandboxInfoSchema });
79
+ return info;
80
+ },
81
+ pause: () => lifecycle("pause"),
82
+ // Explicit lifecycle actions recheck the caller's current authority with the API.
83
+ resume: () => lifecycle("resume"),
84
+ stop: () => lifecycle("stop"),
85
+ start: () => lifecycle("start"),
86
+ delete: () => lifecycle(null, HttpMethod.Delete),
87
+ setTimeout: (wallClockLimitS) => lifecycle("timeout", HttpMethod.Post, { wall_clock_limit_s: wallClockLimitS }),
88
+ updateLabels: async (labels) => {
89
+ const result = await ctx.api({
90
+ method: HttpMethod.Patch,
91
+ path: path(id, "labels"),
92
+ body: { labels },
93
+ schema: labelsAnswerSchema
94
+ });
95
+ info = { ...info, labels: result.labels };
96
+ return result.labels;
97
+ },
98
+ checkpoint: async (options = {}) => {
99
+ const taken = await ctx.api({
100
+ method: HttpMethod.Post,
101
+ path: path(id, "checkpoint"),
102
+ body: { name: options.name },
103
+ schema: checkpointSchema
104
+ });
105
+ const deadline = ctx.clock.now() + (options.timeoutMs ?? CHECKPOINT_DURABLE_TIMEOUT_MS);
106
+ for (; ; ) {
107
+ const snapshot = await ctx.api({
108
+ method: HttpMethod.Get,
109
+ path: `/snapshots/${encodeURIComponent(taken.snapshotId)}`,
110
+ schema: snapshotSchema
111
+ });
112
+ if (snapshot.durableAt != null) return taken;
113
+ if (ctx.clock.now() >= deadline) {
114
+ throw vmError({
115
+ source: VmErrorSource.Api,
116
+ status: null,
117
+ code: "timeout",
118
+ message: `snapshot ${taken.snapshotId} is not durable yet`
119
+ });
120
+ }
121
+ await ctx.clock.sleep(CHECKPOINT_POLL_MS);
122
+ }
123
+ },
124
+ fork: async (count) => {
125
+ const requestedAt = ctx.clock.now();
126
+ const result = await ctx.api({
127
+ method: HttpMethod.Post,
128
+ path: path(id, "fork"),
129
+ body: { count },
130
+ schema: forkSchema
131
+ });
132
+ return {
133
+ snapshotId: result.snapshotId,
134
+ children: result.children.map(
135
+ ({ connect, ...child }) => createSandboxHandle(ctx, child, { grant: connect, requestedAt })
136
+ )
137
+ };
138
+ },
139
+ connect: () => mintGrant(),
140
+ run: (cmd, options) => runCommand(ingress, cmd, options),
141
+ exec: (options) => startExec(execTransport, options),
142
+ attach: (options) => attachExec(execTransport, options),
143
+ files: {
144
+ read: fileReader.read,
145
+ write: (filePath, data, options) => writeFile(ingress, filePath, data, options),
146
+ stat: fileReader.stat,
147
+ list: fileReader.list,
148
+ mkdir: (filePath, options) => makeDirectory(ingress, filePath, options),
149
+ remove: (filePath, options) => removeFile(ingress, filePath, options)
150
+ },
151
+ previewUrl: async (port) => {
152
+ if (!Number.isInteger(port) || port < 1 || port > 65535) {
153
+ throw new RangeError("port must be an integer between 1 and 65535");
154
+ }
155
+ const grant = await grants.get();
156
+ return `https://${port}-${grant.sandboxUuid.replaceAll("-", "")}.${ctx.previewDomain}`;
157
+ },
158
+ listPorts: async () => (await ctx.api({
159
+ method: HttpMethod.Get,
160
+ path: path(id, "ports"),
161
+ schema: z.object({ ports: z.array(portSchema) })
162
+ })).ports,
163
+ createPreviewToken: (port, options = {}) => ctx.api({
164
+ method: HttpMethod.Post,
165
+ path: path(id, "preview-tokens"),
166
+ body: { port, ttl_s: options.ttlS },
167
+ idempotent: true,
168
+ schema: previewTokenSchema
169
+ })
170
+ };
171
+ };
172
+ export {
173
+ createSandboxHandle
174
+ };
175
+ //# sourceMappingURL=sandbox.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/vm/sandbox.ts"],
4
+ "sourcesContent": ["import * as z from 'zod';\nimport { createFileReader } from \"./files.mjs\";\nimport { createNetworkHandle, type NetworkIface } from \"./network.mjs\";\nimport { HttpMethod, type ApiTransport } from \"./api.mjs\";\nimport type { ClockIface } from \"./clock.mjs\";\nimport { vmError, VmErrorSource } from \"./errors.mjs\";\nimport {\n attachExec,\n startExec,\n type AttachOptionsIface,\n type ExecOptionsIface,\n type ExecProcessIface,\n} from \"./exec.mjs\";\nimport { createGrantSource, type GrantSourceIface } from \"./grants.mjs\";\nimport {\n createIngress,\n makeDirectory,\n removeFile,\n runCommand,\n writeFile,\n type FileStatIface,\n type IngressIface,\n type ReadOptionsIface,\n type RunOptionsIface,\n type RunResultIface,\n type WriteOptionsIface,\n} from \"./ingress.mjs\";\nimport {\n checkpointSchema,\n snapshotSchema,\n connectGrantSchema,\n forkSchema,\n labelsAnswerSchema,\n portSchema,\n previewTokenSchema,\n sandboxInfoSchema,\n sandboxOpSchema,\n type ConnectGrantIface,\n type SandboxInfoIface,\n type SandboxOpResultIface,\n} from \"./schemas.mjs\";\n\n// Lifecycle and file reads use the API. Commands and file writes use the data plane with a\n// connect grant the handle keeps fresh.\n\n// How long `checkpoint` waits for the snapshot's layers to be durable, and how often it looks.\nconst CHECKPOINT_DURABLE_TIMEOUT_MS = 10 * 60_000;\nconst CHECKPOINT_POLL_MS = 500;\n\nexport interface SandboxContextIface {\n api: ApiTransport;\n fetch: typeof fetch;\n clock: ClockIface;\n previewDomain: string;\n}\n\nexport interface SandboxIface {\n network: NetworkIface;\n // The wire id (`sbx_\u2026`).\n id: string;\n // As of the last answer about this sandbox.\n info: () => SandboxInfoIface;\n refresh: () => Promise<SandboxInfoIface>;\n pause: () => Promise<SandboxOpResultIface>;\n resume: () => Promise<SandboxOpResultIface>;\n stop: () => Promise<SandboxOpResultIface>;\n start: () => Promise<SandboxOpResultIface>;\n delete: () => Promise<SandboxOpResultIface>;\n // Returns once the snapshot is durable.\n checkpoint: (options?: { name?: string; timeoutMs?: number }) => Promise<{ snapshotId: string }>;\n // `count` running copies; this sandbox keeps running.\n fork: (count: number) => Promise<{ snapshotId: string; children: SandboxIface[] }>;\n setTimeout: (wallClockLimitS: number) => Promise<SandboxOpResultIface>;\n // Merges these labels into the sandbox's (at most 64 in all) and answers the result.\n updateLabels: (labels: Record<string, string>) => Promise<Record<string, string>>;\n // A new grant for the data plane, for callers that connect on their own.\n connect: () => Promise<ConnectGrantIface>;\n run: (cmd: string, options?: RunOptionsIface) => Promise<RunResultIface>;\n exec: (options: ExecOptionsIface) => Promise<ExecProcessIface>;\n attach: (options: AttachOptionsIface) => Promise<ExecProcessIface>;\n files: {\n read: (path: string, options?: ReadOptionsIface) => Promise<Uint8Array>;\n write: (\n path: string,\n data: Uint8Array | string,\n options?: WriteOptionsIface,\n ) => Promise<{ bytesWritten: number }>;\n stat: (path: string, options?: { signal?: AbortSignal }) => Promise<FileStatIface | null>;\n list: (\n path: string,\n options?: { signal?: AbortSignal },\n ) => Promise<{ entries: FileStatIface[]; truncated: boolean }>;\n mkdir: (path: string, options?: { parents?: boolean }) => Promise<void>;\n remove: (path: string, options?: { recursive?: boolean }) => Promise<void>;\n };\n // `https://<port>-<uuid hex>.<preview domain>`. Private unless the port is public; pass a\n // preview token (`createPreviewToken`) with the request.\n previewUrl: (port: number) => Promise<string>;\n // Ports with an explicit visibility (published at create or with `setPortPublic`).\n listPorts: () => Promise<{ port: number; public: boolean }[]>;\n createPreviewToken: (\n port: number,\n options?: { ttlS?: number },\n ) => Promise<{ token: string; expiresAt: Date }>;\n}\n\nconst path = (id: string, action?: string) =>\n `/sandboxes/${encodeURIComponent(id)}${action == null ? '' : `/${action}`}`;\n\nexport const createSandboxHandle = (\n ctx: SandboxContextIface,\n initial: SandboxInfoIface,\n // A grant that came with the answer that made or found this sandbox, and when it was asked.\n initialGrant?: { grant: ConnectGrantIface | null; requestedAt: number },\n): SandboxIface => {\n let info = initial;\n const id = initial.id;\n const mintGrant = (signal?: AbortSignal, refusedByHost?: string) =>\n ctx.api({\n method: HttpMethod.Post,\n path: path(id, 'connect'),\n body: { refused_by_host: refusedByHost },\n idempotent: true,\n schema: connectGrantSchema,\n signal,\n });\n const grants: GrantSourceIface = createGrantSource({\n mint: (signal, refusedByHost) => mintGrant(signal, refusedByHost),\n clock: ctx.clock,\n });\n const ingress: IngressIface = createIngress({\n grants,\n fetch: ctx.fetch,\n clock: ctx.clock,\n });\n const fileReader = createFileReader({ api: ctx.api, sandboxId: id });\n const execTransport = { grants, clock: ctx.clock };\n // The API's answers carry grants for the default scopes, which this client asks for too.\n const seed = (grant: ConnectGrantIface | null, requestedAt: number) => {\n if (grant != null) grants.seed(grant, requestedAt);\n };\n if (initialGrant != null) seed(initialGrant.grant, initialGrant.requestedAt);\n\n // A transition the API ran bumped the generation, so the grant in hand would be `moved`.\n const lifecycle = async (\n action: string | null,\n method = HttpMethod.Post,\n body?: { wall_clock_limit_s: number },\n ) => {\n const requestedAt = ctx.clock.now();\n const result = await ctx.api({\n method,\n path: path(id, action ?? undefined),\n body,\n schema: sandboxOpSchema,\n // State commands: a repeat finds the state already reached.\n idempotent: true,\n });\n grants.clear();\n seed(result.connect, requestedAt);\n info = result.sandbox;\n return result;\n };\n\n return {\n network: createNetworkHandle(ctx.api, id),\n id,\n info: () => info,\n refresh: async () => {\n info = await ctx.api({ method: HttpMethod.Get, path: path(id), schema: sandboxInfoSchema });\n return info;\n },\n pause: () => lifecycle('pause'),\n // Explicit lifecycle actions recheck the caller's current authority with the API.\n resume: () => lifecycle('resume'),\n stop: () => lifecycle('stop'),\n start: () => lifecycle('start'),\n delete: () => lifecycle(null, HttpMethod.Delete),\n setTimeout: (wallClockLimitS) =>\n lifecycle('timeout', HttpMethod.Post, { wall_clock_limit_s: wallClockLimitS }),\n updateLabels: async (labels) => {\n const result = await ctx.api({\n method: HttpMethod.Patch,\n path: path(id, 'labels'),\n body: { labels },\n schema: labelsAnswerSchema,\n });\n info = { ...info, labels: result.labels };\n return result.labels;\n },\n checkpoint: async (options = {}) => {\n const taken = await ctx.api({\n method: HttpMethod.Post,\n path: path(id, 'checkpoint'),\n body: { name: options.name },\n schema: checkpointSchema,\n });\n // The API answers once the snapshot is taken; its layers upload after. Restoring it (a\n // create from it) needs it durable, which is what this promises.\n const deadline = ctx.clock.now() + (options.timeoutMs ?? CHECKPOINT_DURABLE_TIMEOUT_MS);\n for (;;) {\n const snapshot = await ctx.api({\n method: HttpMethod.Get,\n path: `/snapshots/${encodeURIComponent(taken.snapshotId)}`,\n schema: snapshotSchema,\n });\n if (snapshot.durableAt != null) return taken;\n if (ctx.clock.now() >= deadline) {\n throw vmError({\n source: VmErrorSource.Api,\n status: null,\n code: 'timeout',\n message: `snapshot ${taken.snapshotId} is not durable yet`,\n });\n }\n await ctx.clock.sleep(CHECKPOINT_POLL_MS);\n }\n },\n fork: async (count) => {\n const requestedAt = ctx.clock.now();\n const result = await ctx.api({\n method: HttpMethod.Post,\n path: path(id, 'fork'),\n body: { count },\n schema: forkSchema,\n });\n return {\n snapshotId: result.snapshotId,\n children: result.children.map(({ connect, ...child }) =>\n createSandboxHandle(ctx, child, { grant: connect, requestedAt }),\n ),\n };\n },\n connect: () => mintGrant(),\n run: (cmd, options) => runCommand(ingress, cmd, options),\n exec: (options) => startExec(execTransport, options),\n attach: (options) => attachExec(execTransport, options),\n files: {\n read: fileReader.read,\n write: (filePath, data, options) => writeFile(ingress, filePath, data, options),\n stat: fileReader.stat,\n list: fileReader.list,\n mkdir: (filePath, options) => makeDirectory(ingress, filePath, options),\n remove: (filePath, options) => removeFile(ingress, filePath, options),\n },\n previewUrl: async (port) => {\n if (!Number.isInteger(port) || port < 1 || port > 65_535) {\n throw new RangeError('port must be an integer between 1 and 65535');\n }\n const grant = await grants.get();\n return `https://${port}-${grant.sandboxUuid.replaceAll('-', '')}.${ctx.previewDomain}`;\n },\n listPorts: async () =>\n (\n await ctx.api({\n method: HttpMethod.Get,\n path: path(id, 'ports'),\n schema: z.object({ ports: z.array(portSchema) }),\n })\n ).ports,\n createPreviewToken: (port, options = {}) =>\n ctx.api({\n method: HttpMethod.Post,\n path: path(id, 'preview-tokens'),\n body: { port, ttl_s: options.ttlS },\n idempotent: true,\n schema: previewTokenSchema,\n }),\n };\n};\n"],
5
+ "mappings": "AAAA,YAAY,OAAO;AACnB,SAAS,wBAAwB;AACjC,SAAS,2BAA8C;AACvD,SAAS,kBAAqC;AAE9C,SAAS,SAAS,qBAAqB;AACvC;AAAA,EACE;AAAA,EACA;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