@agentuity/sandbox 3.0.12 → 3.1.1

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 (122) hide show
  1. package/AGENTS.md +3 -3
  2. package/dist/api-reference.d.ts +1221 -0
  3. package/dist/api-reference.d.ts.map +1 -0
  4. package/dist/api-reference.js +1046 -0
  5. package/dist/api-reference.js.map +1 -0
  6. package/dist/base64.d.ts +2 -0
  7. package/dist/base64.d.ts.map +1 -0
  8. package/dist/base64.js +14 -0
  9. package/dist/base64.js.map +1 -0
  10. package/dist/client.d.ts +431 -0
  11. package/dist/client.d.ts.map +1 -0
  12. package/dist/client.js +632 -0
  13. package/dist/client.js.map +1 -0
  14. package/dist/create.d.ts +203 -0
  15. package/dist/create.d.ts.map +1 -0
  16. package/dist/create.js +235 -0
  17. package/dist/create.js.map +1 -0
  18. package/dist/destroy.d.ts +23 -0
  19. package/dist/destroy.d.ts.map +1 -0
  20. package/dist/destroy.js +30 -0
  21. package/dist/destroy.js.map +1 -0
  22. package/dist/disk-checkpoint.d.ts +108 -0
  23. package/dist/disk-checkpoint.d.ts.map +1 -0
  24. package/dist/disk-checkpoint.js +124 -0
  25. package/dist/disk-checkpoint.js.map +1 -0
  26. package/dist/events.d.ts +56 -0
  27. package/dist/events.d.ts.map +1 -0
  28. package/dist/events.js +54 -0
  29. package/dist/events.js.map +1 -0
  30. package/dist/execute.d.ts +99 -0
  31. package/dist/execute.d.ts.map +1 -0
  32. package/dist/execute.js +138 -0
  33. package/dist/execute.js.map +1 -0
  34. package/dist/execution.d.ts +150 -0
  35. package/dist/execution.d.ts.map +1 -0
  36. package/dist/execution.js +120 -0
  37. package/dist/execution.js.map +1 -0
  38. package/dist/files.d.ts +283 -0
  39. package/dist/files.d.ts.map +1 -0
  40. package/dist/files.js +471 -0
  41. package/dist/files.js.map +1 -0
  42. package/dist/get.d.ts +288 -0
  43. package/dist/get.d.ts.map +1 -0
  44. package/dist/get.js +256 -0
  45. package/dist/get.js.map +1 -0
  46. package/dist/getStatus.d.ts +23 -0
  47. package/dist/getStatus.d.ts.map +1 -0
  48. package/dist/getStatus.js +53 -0
  49. package/dist/getStatus.js.map +1 -0
  50. package/dist/index.d.ts +42 -1
  51. package/dist/index.d.ts.map +1 -1
  52. package/dist/index.js +22 -1
  53. package/dist/index.js.map +1 -1
  54. package/dist/job.d.ts +227 -0
  55. package/dist/job.d.ts.map +1 -0
  56. package/dist/job.js +109 -0
  57. package/dist/job.js.map +1 -0
  58. package/dist/list.d.ts +330 -0
  59. package/dist/list.d.ts.map +1 -0
  60. package/dist/list.js +209 -0
  61. package/dist/list.js.map +1 -0
  62. package/dist/pause.d.ts +39 -0
  63. package/dist/pause.d.ts.map +1 -0
  64. package/dist/pause.js +48 -0
  65. package/dist/pause.js.map +1 -0
  66. package/dist/resolve.d.ts +75 -0
  67. package/dist/resolve.d.ts.map +1 -0
  68. package/dist/resolve.js +76 -0
  69. package/dist/resolve.js.map +1 -0
  70. package/dist/resume.d.ts +23 -0
  71. package/dist/resume.d.ts.map +1 -0
  72. package/dist/resume.js +30 -0
  73. package/dist/resume.js.map +1 -0
  74. package/dist/run.d.ts +73 -0
  75. package/dist/run.d.ts.map +1 -0
  76. package/dist/run.js +568 -0
  77. package/dist/run.js.map +1 -0
  78. package/dist/runtime.d.ts +94 -0
  79. package/dist/runtime.d.ts.map +1 -0
  80. package/dist/runtime.js +82 -0
  81. package/dist/runtime.js.map +1 -0
  82. package/dist/snapshot-build.d.ts +48 -0
  83. package/dist/snapshot-build.d.ts.map +1 -0
  84. package/dist/snapshot-build.js +72 -0
  85. package/dist/snapshot-build.js.map +1 -0
  86. package/dist/snapshot.d.ts +596 -0
  87. package/dist/snapshot.d.ts.map +1 -0
  88. package/dist/snapshot.js +612 -0
  89. package/dist/snapshot.js.map +1 -0
  90. package/dist/types.d.ts +1010 -0
  91. package/dist/types.d.ts.map +1 -0
  92. package/dist/types.js +853 -0
  93. package/dist/types.js.map +1 -0
  94. package/dist/util.d.ts +296 -0
  95. package/dist/util.d.ts.map +1 -0
  96. package/dist/util.js +234 -0
  97. package/dist/util.js.map +1 -0
  98. package/package.json +7 -2
  99. package/src/api-reference.ts +1094 -0
  100. package/src/base64.ts +14 -0
  101. package/src/client.ts +998 -0
  102. package/src/create.ts +273 -0
  103. package/src/destroy.ts +43 -0
  104. package/src/disk-checkpoint.ts +184 -0
  105. package/src/events.ts +72 -0
  106. package/src/execute.ts +167 -0
  107. package/src/execution.ts +152 -0
  108. package/src/files.ts +637 -0
  109. package/src/get.ts +291 -0
  110. package/src/getStatus.ts +72 -0
  111. package/src/index.ts +252 -18
  112. package/src/job.ts +161 -0
  113. package/src/list.ts +239 -0
  114. package/src/pause.ts +75 -0
  115. package/src/resolve.ts +96 -0
  116. package/src/resume.ts +41 -0
  117. package/src/run.ts +783 -0
  118. package/src/runtime.ts +106 -0
  119. package/src/snapshot-build.ts +94 -0
  120. package/src/snapshot.ts +791 -0
  121. package/src/types.ts +1033 -0
  122. package/src/util.ts +280 -0
package/src/runtime.ts ADDED
@@ -0,0 +1,106 @@
1
+ import {
2
+ ListRuntimesParamsSchema,
3
+ type ListRuntimesResponse,
4
+ type SandboxRuntime,
5
+ } from './types.ts';
6
+ import { z } from 'zod';
7
+ import { type APIClient, APIResponseSchema } from '@agentuity/api';
8
+ import { throwSandboxError } from './util.ts';
9
+
10
+ export const RuntimeRequirementsSchema = z
11
+ .object({
12
+ memory: z.string().optional().describe('Memory requirement (e.g., "1Gi")'),
13
+ cpu: z.string().optional().describe('CPU requirement (e.g., "1")'),
14
+ disk: z.string().optional().describe('Disk requirement (e.g., "500Mi")'),
15
+ networkEnabled: z.boolean().describe('Whether network access is enabled'),
16
+ })
17
+ .describe('Runtime resource requirements');
18
+
19
+ export const RuntimeInfoSchema = z
20
+ .object({
21
+ id: z.string().describe('Unique runtime identifier'),
22
+ name: z.string().describe('Runtime name (e.g., "bun:1", "python:3.14")'),
23
+ description: z.string().optional().describe('Optional description'),
24
+ iconUrl: z.string().optional().describe('URL for runtime icon'),
25
+ brandColor: z.string().optional().describe('Brand color for the runtime (hex color code)'),
26
+ url: z.string().optional().describe('URL for runtime documentation or homepage'),
27
+ tags: z.array(z.string()).optional().describe('Optional tags for categorization'),
28
+ requirements: RuntimeRequirementsSchema.optional().describe('Runtime resource requirements'),
29
+ readme: z.string().optional().describe('Readme content in markdown format'),
30
+ })
31
+ .describe('Information about a sandbox runtime');
32
+
33
+ export const ListRuntimesDataSchema = z
34
+ .object({
35
+ runtimes: z.array(RuntimeInfoSchema).describe('List of runtime entries'),
36
+ total: z.number().describe('Total number of runtimes'),
37
+ })
38
+ .describe('List of sandbox runtimes');
39
+
40
+ export const ListRuntimesResponseSchema = APIResponseSchema(ListRuntimesDataSchema);
41
+
42
+ export const RuntimeListParamsSchema = ListRuntimesParamsSchema.extend({
43
+ orgId: z.string().optional().describe('Optional org id for CLI auth context'),
44
+ });
45
+
46
+ export type RuntimeListParams = z.infer<typeof RuntimeListParamsSchema>;
47
+
48
+ /**
49
+ * Lists available sandbox runtimes with optional pagination.
50
+ *
51
+ * @param client - The API client to use for the request
52
+ * @param params - Optional parameters for pagination
53
+ * @returns List of runtimes with total count
54
+ * @throws {SandboxResponseError} If the request fails
55
+ */
56
+ export async function runtimeList(
57
+ client: APIClient,
58
+ params?: RuntimeListParams
59
+ ): Promise<ListRuntimesResponse> {
60
+ const queryParams = new URLSearchParams();
61
+
62
+ if (params?.orgId) {
63
+ queryParams.set('orgId', params.orgId);
64
+ }
65
+ if (params?.limit !== undefined) {
66
+ queryParams.set('limit', params.limit.toString());
67
+ }
68
+ if (params?.offset !== undefined) {
69
+ queryParams.set('offset', params.offset.toString());
70
+ }
71
+ if (params?.sort) {
72
+ queryParams.set('sort', params.sort);
73
+ }
74
+ if (params?.direction) {
75
+ queryParams.set('direction', params.direction);
76
+ }
77
+
78
+ const queryString = queryParams.toString();
79
+ const url = `/sandbox/runtimes${queryString ? `?${queryString}` : ''}`;
80
+
81
+ const resp = await client.get<z.infer<typeof ListRuntimesResponseSchema>>(
82
+ url,
83
+ ListRuntimesResponseSchema
84
+ );
85
+
86
+ if (resp.success) {
87
+ return {
88
+ runtimes: resp.data.runtimes.map(
89
+ (r): SandboxRuntime => ({
90
+ id: r.id,
91
+ name: r.name,
92
+ description: r.description,
93
+ iconUrl: r.iconUrl,
94
+ brandColor: r.brandColor,
95
+ url: r.url,
96
+ tags: r.tags,
97
+ requirements: r.requirements,
98
+ readme: r.readme,
99
+ })
100
+ ),
101
+ total: resp.data.total,
102
+ };
103
+ }
104
+
105
+ throwSandboxError(resp, {});
106
+ }
@@ -0,0 +1,94 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * Regex pattern for validating npm/bun package specifiers.
5
+ * Uses a blocklist approach: rejects shell injection characters while allowing
6
+ * all legitimate specifier formats (names, scoped packages, URLs, git refs, etc.).
7
+ *
8
+ * Valid examples: "typescript", "@types/node", "opencode-ai@1.2.3",
9
+ * "https://github.com/user/repo", "git+https://github.com/user/repo.git",
10
+ * "github:user/repo", "file:../local-pkg"
11
+ * Invalid examples: "foo bar", "pkg;rm -rf", "pkg|cat /etc/passwd", "$(evil)"
12
+ */
13
+ export const NPM_PACKAGE_NAME_PATTERN = /^[^\s;`|$]+$/;
14
+
15
+ /**
16
+ * Base schema for snapshot build configuration file (agentuity-snapshot.yaml)
17
+ * This is the canonical schema - used for JSON Schema generation.
18
+ */
19
+ export const SnapshotBuildFileBaseSchema = z
20
+ .object({
21
+ version: z.literal(1).describe('Schema version, must be 1'),
22
+ runtime: z
23
+ .string()
24
+ .describe('Runtime identifier (name:tag format, e.g., bun:1, node:20, python:3.12)'),
25
+ name: z
26
+ .string()
27
+ .regex(/^[a-zA-Z0-9_-]+$/)
28
+ .optional()
29
+ .describe('Snapshot name (alphanumeric, underscores, dashes only)'),
30
+ description: z.string().optional().describe('Human-readable description of the snapshot'),
31
+ dir: z
32
+ .string()
33
+ .optional()
34
+ .describe(
35
+ 'Subdirectory to use as the build context for file resolution (relative to the CLI directory argument)'
36
+ ),
37
+ dependencies: z
38
+ .array(z.string())
39
+ .optional()
40
+ .describe(
41
+ 'List of apt packages to install. Supports version pinning: package=version or package=version* for prefix matching'
42
+ ),
43
+ packages: z
44
+ .array(
45
+ z
46
+ .string()
47
+ .regex(
48
+ NPM_PACKAGE_NAME_PATTERN,
49
+ 'Invalid npm/bun package specifier: must not contain whitespace, semicolons, backticks, pipes, or dollar signs'
50
+ )
51
+ )
52
+ .optional()
53
+ .describe(
54
+ 'List of npm/bun packages to install globally via bun install -g. Example: opencode-ai, typescript'
55
+ ),
56
+ files: z
57
+ .array(z.string())
58
+ .optional()
59
+ .describe(
60
+ 'Glob patterns for files to include from the build context. Supports negative patterns with ! prefix for exclusions'
61
+ ),
62
+ env: z.record(z.string(), z.string()).optional().describe(
63
+ // biome-ignore lint/suspicious/noTemplateCurlyInString: describes the ${VAR} substitution syntax for users
64
+ 'Environment variables to set. Use ${VAR} syntax for build-time substitution via --env flag'
65
+ ),
66
+ metadata: z.record(z.string(), z.string()).optional().describe(
67
+ // biome-ignore lint/suspicious/noTemplateCurlyInString: describes the ${VAR} substitution syntax for users
68
+ 'User-defined metadata key-value pairs. Use ${VAR} syntax for build-time substitution via --metadata flag'
69
+ ),
70
+ public: z
71
+ .boolean()
72
+ .optional()
73
+ .describe('Whether to make the snapshot publicly accessible (default: false)'),
74
+ })
75
+ .describe('Agentuity Snapshot Build File - defines a reproducible sandbox environment');
76
+
77
+ /**
78
+ * Schema with validation refinement - use this for parsing/validation.
79
+ * Ensures at least one of dependencies, files, env, or packages is specified.
80
+ */
81
+ export const SnapshotBuildFileSchema = SnapshotBuildFileBaseSchema.refine(
82
+ (data) => {
83
+ const hasDependencies = data.dependencies && data.dependencies.length > 0;
84
+ const hasFiles = data.files && data.files.length > 0;
85
+ const hasEnv = data.env && Object.keys(data.env).length > 0;
86
+ const hasPackages = data.packages && data.packages.length > 0;
87
+ return hasDependencies || hasFiles || hasEnv || hasPackages;
88
+ },
89
+ {
90
+ message: 'At least one of dependencies, files, env, or packages must be specified',
91
+ }
92
+ );
93
+
94
+ export type SnapshotBuildFile = z.infer<typeof SnapshotBuildFileSchema>;