@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.
Files changed (70) hide show
  1. package/README.md +63 -6
  2. package/dist/modules/claims.d.mts +3 -0
  3. package/dist/modules/claims.mjs +24 -0
  4. package/dist/modules/claims.mjs.map +7 -0
  5. package/dist/modules/computer.d.mts +7 -0
  6. package/dist/modules/computer.mjs +57 -0
  7. package/dist/modules/computer.mjs.map +7 -0
  8. package/dist/modules/images.d.mts +23 -3
  9. package/dist/modules/images.mjs +48 -23
  10. package/dist/modules/images.mjs.map +3 -3
  11. package/dist/modules/lifecycle.d.mts +25 -0
  12. package/dist/modules/lifecycle.mjs +46 -0
  13. package/dist/modules/lifecycle.mjs.map +7 -0
  14. package/dist/modules/limits.d.mts +1 -0
  15. package/dist/modules/limits.mjs +20 -1
  16. package/dist/modules/limits.mjs.map +2 -2
  17. package/dist/modules/options.d.mts +8 -5
  18. package/dist/modules/options.mjs +8 -6
  19. package/dist/modules/options.mjs.map +2 -2
  20. package/dist/modules/provider.mjs +1016 -127
  21. package/dist/modules/provider.mjs.map +2 -2
  22. package/dist/modules/service.d.mts +12 -0
  23. package/dist/modules/service.mjs +49 -0
  24. package/dist/modules/service.mjs.map +7 -0
  25. package/dist/modules/usage.d.mts +7 -0
  26. package/dist/modules/usage.mjs +50 -0
  27. package/dist/modules/usage.mjs.map +7 -0
  28. package/dist/modules/vm/api.d.mts +2 -1
  29. package/dist/modules/vm/api.mjs +11 -3
  30. package/dist/modules/vm/api.mjs.map +2 -2
  31. package/dist/modules/vm/client.d.mts +85 -4
  32. package/dist/modules/vm/client.mjs +142 -6
  33. package/dist/modules/vm/client.mjs.map +2 -2
  34. package/dist/modules/vm/errors.d.mts +2 -0
  35. package/dist/modules/vm/errors.mjs +2 -1
  36. package/dist/modules/vm/errors.mjs.map +2 -2
  37. package/dist/modules/vm/exec.d.mts +1 -0
  38. package/dist/modules/vm/exec.mjs +2 -0
  39. package/dist/modules/vm/exec.mjs.map +2 -2
  40. package/dist/modules/vm/files.d.mts +8 -0
  41. package/dist/modules/vm/files.mjs +47 -0
  42. package/dist/modules/vm/files.mjs.map +2 -2
  43. package/dist/modules/vm/ids.d.mts +1 -0
  44. package/dist/modules/vm/ids.mjs +2 -0
  45. package/dist/modules/vm/ids.mjs.map +2 -2
  46. package/dist/modules/vm/ingress.d.mts +5 -0
  47. package/dist/modules/vm/ingress.mjs +21 -0
  48. package/dist/modules/vm/ingress.mjs.map +2 -2
  49. package/dist/modules/vm/network.d.mts +3 -1
  50. package/dist/modules/vm/network.mjs +3 -2
  51. package/dist/modules/vm/network.mjs.map +2 -2
  52. package/dist/modules/vm/resources.d.mts +251 -0
  53. package/dist/modules/vm/resources.mjs +210 -0
  54. package/dist/modules/vm/resources.mjs.map +7 -0
  55. package/dist/modules/vm/routes.d.mts +55 -0
  56. package/dist/modules/vm/routes.mjs +61 -0
  57. package/dist/modules/vm/routes.mjs.map +7 -0
  58. package/dist/modules/vm/sandbox.d.mts +92 -3
  59. package/dist/modules/vm/sandbox.mjs +234 -4
  60. package/dist/modules/vm/sandbox.mjs.map +2 -2
  61. package/dist/modules/vm/schemas.d.mts +219 -0
  62. package/dist/modules/vm/schemas.mjs +34 -3
  63. package/dist/modules/vm/schemas.mjs.map +2 -2
  64. package/dist/modules/vm/size.d.mts +10 -0
  65. package/dist/modules/vm/size.mjs +7 -0
  66. package/dist/modules/vm/size.mjs.map +7 -0
  67. package/dist/modules/vm/wire.d.mts +3 -0
  68. package/dist/modules/vm/wire.mjs +6 -0
  69. package/dist/modules/vm/wire.mjs.map +2 -2
  70. package/package.json +2 -2
@@ -7,18 +7,21 @@ export interface FinalCredentialsIface {
7
7
  export interface FinalProviderOptionsIface {
8
8
  fetch?: typeof fetch;
9
9
  previewDomain?: string;
10
+ defaultWallClockLimitS?: number;
10
11
  }
11
12
  export interface FinalOptionsIface {
12
13
  projectId?: string;
13
- cpuLimit?: number;
14
- memoryLimitMib?: number;
15
14
  machine?: {
16
- types?: string[];
17
- cpuFamilies?: string[];
18
15
  sort?: MachineSort;
19
16
  maxPricePerHour?: string;
20
17
  };
21
- publicPorts?: number[];
22
18
  tools?: string[];
19
+ owner?: 'self';
20
+ retentionExempt?: boolean;
21
+ platformEgress?: boolean;
22
+ cpuPool?: string;
23
+ sandboxId?: string;
24
+ ephemeral?: boolean;
25
+ pausedRetentionS?: number;
23
26
  }
24
27
  export declare const finalOptionsSchema: z.ZodType<FinalOptionsIface>;
@@ -2,16 +2,18 @@ import { MachineSort } from "./vm/machines.mjs";
2
2
  import * as z from "zod";
3
3
  const finalOptionsSchema = z.object({
4
4
  projectId: z.string().min(1).optional(),
5
- cpuLimit: z.number().positive().max(32).optional(),
6
- memoryLimitMib: z.number().int().min(256).max(65536).optional(),
7
5
  machine: z.object({
8
- types: z.array(z.string().min(1)).optional(),
9
- cpuFamilies: z.array(z.string().min(1)).optional(),
10
6
  sort: z.nativeEnum(MachineSort).optional(),
11
7
  maxPricePerHour: z.string().regex(/^\d+(?:\.\d{1,9})?$/).optional()
12
8
  }).strict().optional(),
13
- publicPorts: z.array(z.number().int().min(1).max(65535)).max(32).optional(),
14
- tools: z.array(z.string().min(1)).optional()
9
+ tools: z.array(z.string().min(1)).optional(),
10
+ owner: z.literal("self").optional(),
11
+ retentionExempt: z.boolean().optional(),
12
+ platformEgress: z.boolean().optional(),
13
+ pausedRetentionS: z.number().int().min(60).max(2147483647).optional(),
14
+ sandboxId: z.union([z.string().regex(/^sbx_[A-Za-z0-9]+$/), z.string().uuid()]).optional(),
15
+ ephemeral: z.boolean().optional(),
16
+ cpuPool: z.string().min(1).optional()
15
17
  }).strict();
16
18
  export {
17
19
  finalOptionsSchema
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/options.ts"],
4
- "sourcesContent": ["import { MachineSort } from \"./vm/machines.mjs\";\nimport * as z from 'zod';\n\nexport interface FinalCredentialsIface {\n // A Final API key with edit access to the project sandboxes are created in.\n apiKey: string;\n // The API's base URL; the public API by default.\n apiUrl?: string;\n}\n\nexport interface FinalProviderOptionsIface {\n fetch?: typeof fetch;\n // The domain port URLs are served under, for an API other than the public one.\n previewDomain?: string;\n}\n\n// This provider's entry of `providerOptions`.\nexport interface FinalOptionsIface {\n // The project (`prj_\u2026`) to create in; the API key's own project by default.\n projectId?: string;\n // Burst limits above the spec's size (the spec's `cpu` and `memoryMib` stay the guaranteed\n // request). Without them the size is fixed.\n cpuLimit?: number;\n memoryLimitMib?: number;\n // The machines the sandbox may run on, kept for every wake and move.\n machine?: {\n types?: string[];\n cpuFamilies?: string[];\n sort?: MachineSort;\n maxPricePerHour?: string;\n };\n // Ports published at create: reachable by anyone with the URL.\n publicPorts?: number[];\n // Platform tools to run in the sandbox (`docker`).\n tools?: string[];\n}\n\nexport const finalOptionsSchema: z.ZodType<FinalOptionsIface> = z\n .object({\n projectId: z.string().min(1).optional(),\n cpuLimit: z.number().positive().max(32).optional(),\n memoryLimitMib: z.number().int().min(256).max(65_536).optional(),\n machine: z\n .object({\n types: z.array(z.string().min(1)).optional(),\n cpuFamilies: z.array(z.string().min(1)).optional(),\n sort: z.nativeEnum(MachineSort).optional(),\n maxPricePerHour: z\n .string()\n .regex(/^\\d+(?:\\.\\d{1,9})?$/)\n .optional(),\n })\n .strict()\n .optional(),\n publicPorts: z.array(z.number().int().min(1).max(65_535)).max(32).optional(),\n tools: z.array(z.string().min(1)).optional(),\n })\n .strict();\n"],
5
- "mappings": "AAAA,SAAS,mBAAmB;AAC5B,YAAY,OAAO;AAoCZ,MAAM,qBAAmD,EAC7D,OAAO;AAAA,EACN,WAAW,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS;AAAA,EACtC,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,SAAS;AAAA,EACjD,gBAAgB,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,GAAG,EAAE,IAAI,KAAM,EAAE,SAAS;AAAA,EAC/D,SAAS,EACN,OAAO;AAAA,IACN,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,EAAE,SAAS;AAAA,IAC3C,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,EAAE,SAAS;AAAA,IACjD,MAAM,EAAE,WAAW,WAAW,EAAE,SAAS;AAAA,IACzC,iBAAiB,EACd,OAAO,EACP,MAAM,qBAAqB,EAC3B,SAAS;AAAA,EACd,CAAC,EACA,OAAO,EACP,SAAS;AAAA,EACZ,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,IAAI,KAAM,CAAC,EAAE,IAAI,EAAE,EAAE,SAAS;AAAA,EAC3E,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,EAAE,SAAS;AAC7C,CAAC,EACA,OAAO;",
4
+ "sourcesContent": ["import { MachineSort } from \"./vm/machines.mjs\";\nimport * as z from 'zod';\n\nexport interface FinalCredentialsIface {\n // A Final API key with edit access to the project sandboxes are created in.\n apiKey: string;\n // The API's base URL; the public API by default.\n apiUrl?: string;\n}\n\nexport interface FinalProviderOptionsIface {\n fetch?: typeof fetch;\n // The domain port URLs are served under, for an API other than the public one.\n previewDomain?: string;\n // The maximum lifetime, in seconds, of a sandbox whose lifecycle leaves `max` out: it then\n // takes the idle action (a pause unless the lifecycle says otherwise). Default one year, which\n // the platform caps at the plan's maximum (30 days by default).\n defaultWallClockLimitS?: number;\n}\n\n// This provider's entry of `providerOptions`.\nexport interface FinalOptionsIface {\n // The project (`prj_\u2026`) to create in; the API key's own project by default.\n projectId?: string;\n // How the machine is chosen among those `spec.placement` allows.\n machine?: {\n sort?: MachineSort;\n maxPricePerHour?: string;\n };\n // Platform tools to run in the sandbox (`docker`), and in templates built for it.\n tools?: string[];\n // Only the creating API key may change, capture or copy the sandbox.\n owner?: 'self';\n // The next three are granted only to entitled organizations; the API refuses them otherwise.\n // Never deleted by the organization's retention policy.\n retentionExempt?: boolean;\n // Egress through the platform's own network.\n platformEgress?: boolean;\n // The CPU pool to place the sandbox in.\n cpuPool?: string;\n // The id to create the sandbox under: a sandbox id (`sbx_\u2026`) or the UUID it encodes.\n sandboxId?: string;\n // Keep no durable copy of the sandbox's disk.\n ephemeral?: boolean;\n // How long, in seconds, the sandbox stays paused before it stops; at most (and by default) the\n // organization's paused retention, 7 days unless set otherwise.\n pausedRetentionS?: number;\n}\n\nexport const finalOptionsSchema: z.ZodType<FinalOptionsIface> = z\n .object({\n projectId: z.string().min(1).optional(),\n machine: z\n .object({\n sort: z.nativeEnum(MachineSort).optional(),\n maxPricePerHour: z\n .string()\n .regex(/^\\d+(?:\\.\\d{1,9})?$/)\n .optional(),\n })\n .strict()\n .optional(),\n tools: z.array(z.string().min(1)).optional(),\n owner: z.literal('self').optional(),\n retentionExempt: z.boolean().optional(),\n platformEgress: z.boolean().optional(),\n pausedRetentionS: z.number().int().min(60).max(2_147_483_647).optional(),\n sandboxId: z.union([z.string().regex(/^sbx_[A-Za-z0-9]+$/), z.string().uuid()]).optional(),\n ephemeral: z.boolean().optional(),\n cpuPool: z.string().min(1).optional(),\n })\n .strict();\n"],
5
+ "mappings": "AAAA,SAAS,mBAAmB;AAC5B,YAAY,OAAO;AAgDZ,MAAM,qBAAmD,EAC7D,OAAO;AAAA,EACN,WAAW,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS;AAAA,EACtC,SAAS,EACN,OAAO;AAAA,IACN,MAAM,EAAE,WAAW,WAAW,EAAE,SAAS;AAAA,IACzC,iBAAiB,EACd,OAAO,EACP,MAAM,qBAAqB,EAC3B,SAAS;AAAA,EACd,CAAC,EACA,OAAO,EACP,SAAS;AAAA,EACZ,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,EAAE,SAAS;AAAA,EAC3C,OAAO,EAAE,QAAQ,MAAM,EAAE,SAAS;AAAA,EAClC,iBAAiB,EAAE,QAAQ,EAAE,SAAS;AAAA,EACtC,gBAAgB,EAAE,QAAQ,EAAE,SAAS;AAAA,EACrC,kBAAkB,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,IAAI,UAAa,EAAE,SAAS;AAAA,EACvE,WAAW,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,oBAAoB,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,EAAE,SAAS;AAAA,EACzF,WAAW,EAAE,QAAQ,EAAE,SAAS;AAAA,EAChC,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS;AACtC,CAAC,EACA,OAAO;",
6
6
  "names": []
7
7
  }