@agentuity/server 0.1.16 → 0.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/api.d.ts +11 -6
- package/dist/api/api.d.ts.map +1 -1
- package/dist/api/api.js +19 -12
- package/dist/api/api.js.map +1 -1
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +1 -0
- package/dist/api/index.js.map +1 -1
- package/dist/api/org/env-delete.d.ts.map +1 -1
- package/dist/api/org/env-delete.js.map +1 -1
- package/dist/api/org/env-get.d.ts.map +1 -1
- package/dist/api/org/env-get.js.map +1 -1
- package/dist/api/org/env-update.d.ts.map +1 -1
- package/dist/api/org/env-update.js.map +1 -1
- package/dist/api/queue/analytics.d.ts +108 -0
- package/dist/api/queue/analytics.d.ts.map +1 -0
- package/dist/api/queue/analytics.js +245 -0
- package/dist/api/queue/analytics.js.map +1 -0
- package/dist/api/queue/destinations.d.ts +108 -0
- package/dist/api/queue/destinations.d.ts.map +1 -0
- package/dist/api/queue/destinations.js +238 -0
- package/dist/api/queue/destinations.js.map +1 -0
- package/dist/api/queue/dlq.d.ts +100 -0
- package/dist/api/queue/dlq.d.ts.map +1 -0
- package/dist/api/queue/dlq.js +204 -0
- package/dist/api/queue/dlq.js.map +1 -0
- package/dist/api/queue/index.d.ts +55 -0
- package/dist/api/queue/index.d.ts.map +1 -0
- package/dist/api/queue/index.js +86 -0
- package/dist/api/queue/index.js.map +1 -0
- package/dist/api/queue/messages.d.ts +332 -0
- package/dist/api/queue/messages.d.ts.map +1 -0
- package/dist/api/queue/messages.js +637 -0
- package/dist/api/queue/messages.js.map +1 -0
- package/dist/api/queue/queues.d.ts +153 -0
- package/dist/api/queue/queues.d.ts.map +1 -0
- package/dist/api/queue/queues.js +319 -0
- package/dist/api/queue/queues.js.map +1 -0
- package/dist/api/queue/sources.d.ts +132 -0
- package/dist/api/queue/sources.d.ts.map +1 -0
- package/dist/api/queue/sources.js +285 -0
- package/dist/api/queue/sources.js.map +1 -0
- package/dist/api/queue/types.d.ts +1129 -0
- package/dist/api/queue/types.d.ts.map +1 -0
- package/dist/api/queue/types.js +949 -0
- package/dist/api/queue/types.js.map +1 -0
- package/dist/api/queue/util.d.ts +262 -0
- package/dist/api/queue/util.d.ts.map +1 -0
- package/dist/api/queue/util.js +171 -0
- package/dist/api/queue/util.js.map +1 -0
- package/dist/api/queue/validation.d.ts +247 -0
- package/dist/api/queue/validation.d.ts.map +1 -0
- package/dist/api/queue/validation.js +513 -0
- package/dist/api/queue/validation.js.map +1 -0
- package/dist/api/sandbox/get.d.ts.map +1 -1
- package/dist/api/sandbox/get.js +5 -0
- package/dist/api/sandbox/get.js.map +1 -1
- package/dist/api/sandbox/index.d.ts +3 -3
- package/dist/api/sandbox/index.d.ts.map +1 -1
- package/dist/api/sandbox/index.js +1 -1
- package/dist/api/sandbox/index.js.map +1 -1
- package/dist/api/sandbox/run.d.ts.map +1 -1
- package/dist/api/sandbox/run.js +5 -2
- package/dist/api/sandbox/run.js.map +1 -1
- package/dist/api/sandbox/snapshot-build.d.ts +2 -0
- package/dist/api/sandbox/snapshot-build.d.ts.map +1 -1
- package/dist/api/sandbox/snapshot-build.js +4 -0
- package/dist/api/sandbox/snapshot-build.js.map +1 -1
- package/dist/api/sandbox/snapshot.d.ts +143 -1
- package/dist/api/sandbox/snapshot.d.ts.map +1 -1
- package/dist/api/sandbox/snapshot.js +183 -4
- package/dist/api/sandbox/snapshot.js.map +1 -1
- package/package.json +4 -4
- package/src/api/api.ts +62 -13
- package/src/api/index.ts +1 -0
- package/src/api/org/env-delete.ts +1 -4
- package/src/api/org/env-get.ts +1 -4
- package/src/api/org/env-update.ts +1 -4
- package/src/api/queue/analytics.ts +313 -0
- package/src/api/queue/destinations.ts +321 -0
- package/src/api/queue/dlq.ts +283 -0
- package/src/api/queue/index.ts +261 -0
- package/src/api/queue/messages.ts +875 -0
- package/src/api/queue/queues.ts +448 -0
- package/src/api/queue/sources.ts +384 -0
- package/src/api/queue/types.ts +1253 -0
- package/src/api/queue/util.ts +204 -0
- package/src/api/queue/validation.ts +560 -0
- package/src/api/sandbox/get.ts +5 -0
- package/src/api/sandbox/index.ts +13 -1
- package/src/api/sandbox/run.ts +5 -2
- package/src/api/sandbox/snapshot-build.ts +4 -0
- package/src/api/sandbox/snapshot.ts +223 -5
|
@@ -6,9 +6,28 @@ const SnapshotFileInfoSchema = z
|
|
|
6
6
|
.object({
|
|
7
7
|
path: z.string().describe('File path within the snapshot'),
|
|
8
8
|
size: z.number().describe('File size in bytes'),
|
|
9
|
+
sha256: z.string().describe('SHA256 hash of the file contents'),
|
|
10
|
+
contentType: z.string().describe('MIME type of the file'),
|
|
11
|
+
mode: z.number().describe('Unix file mode/permissions (e.g., 0o644)'),
|
|
9
12
|
})
|
|
10
13
|
.describe('Information about a file in a snapshot');
|
|
11
14
|
|
|
15
|
+
const SnapshotOrgInfoSchema = z
|
|
16
|
+
.object({
|
|
17
|
+
id: z.string().describe('Organization ID'),
|
|
18
|
+
name: z.string().describe('Organization name'),
|
|
19
|
+
slug: z.string().nullable().optional().describe('Organization slug for building full name'),
|
|
20
|
+
})
|
|
21
|
+
.describe('Organization information for public snapshots');
|
|
22
|
+
|
|
23
|
+
const SnapshotUserInfoSchema = z
|
|
24
|
+
.object({
|
|
25
|
+
id: z.string().describe('User ID'),
|
|
26
|
+
firstName: z.string().nullable().optional().describe('User first name'),
|
|
27
|
+
lastName: z.string().nullable().optional().describe('User last name'),
|
|
28
|
+
})
|
|
29
|
+
.describe('User information for private snapshots');
|
|
30
|
+
|
|
12
31
|
const SnapshotInfoSchema = z
|
|
13
32
|
.object({
|
|
14
33
|
snapshotId: z.string().describe('Unique identifier for the snapshot'),
|
|
@@ -22,7 +41,12 @@ const SnapshotInfoSchema = z
|
|
|
22
41
|
.describe(
|
|
23
42
|
'Display name for the snapshot (URL-safe: letters, numbers, underscores, dashes)'
|
|
24
43
|
),
|
|
44
|
+
fullName: z
|
|
45
|
+
.string()
|
|
46
|
+
.optional()
|
|
47
|
+
.describe('Full name with org slug for public snapshots (@slug/name:tag)'),
|
|
25
48
|
description: z.string().nullable().optional().describe('Description of the snapshot'),
|
|
49
|
+
message: z.string().nullable().optional().describe('Build message for the snapshot'),
|
|
26
50
|
tag: z.string().nullable().optional().describe('Tag for the snapshot (defaults to "latest")'),
|
|
27
51
|
sizeBytes: z.number().describe('Total size of the snapshot in bytes'),
|
|
28
52
|
fileCount: z.number().describe('Number of files in the snapshot'),
|
|
@@ -31,6 +55,15 @@ const SnapshotInfoSchema = z
|
|
|
31
55
|
.nullable()
|
|
32
56
|
.optional()
|
|
33
57
|
.describe('ID of the parent snapshot (for incremental snapshots)'),
|
|
58
|
+
public: z.boolean().optional().describe('Whether the snapshot is publicly accessible'),
|
|
59
|
+
orgName: z.string().optional().describe('Organization name (for public snapshots)'),
|
|
60
|
+
orgSlug: z.string().optional().describe('Organization slug (for public snapshots)'),
|
|
61
|
+
org: SnapshotOrgInfoSchema.nullable()
|
|
62
|
+
.optional()
|
|
63
|
+
.describe('Organization details (for public snapshots)'),
|
|
64
|
+
user: SnapshotUserInfoSchema.nullable()
|
|
65
|
+
.optional()
|
|
66
|
+
.describe('User who pushed the snapshot (for private snapshots)'),
|
|
34
67
|
createdAt: z.string().describe('ISO timestamp when the snapshot was created'),
|
|
35
68
|
downloadUrl: z.string().optional().describe('URL to download the snapshot archive'),
|
|
36
69
|
files: z
|
|
@@ -57,9 +90,50 @@ const SnapshotListDataSchema = z
|
|
|
57
90
|
const SnapshotListResponseSchema = APIResponseSchema(SnapshotListDataSchema);
|
|
58
91
|
const SnapshotDeleteResponseSchema = APIResponseSchemaNoData();
|
|
59
92
|
|
|
93
|
+
const SnapshotLineageEntrySchema = z
|
|
94
|
+
.object({
|
|
95
|
+
snapshotId: z.string().describe('Unique identifier for the snapshot'),
|
|
96
|
+
name: z
|
|
97
|
+
.string()
|
|
98
|
+
.describe(
|
|
99
|
+
'Display name for the snapshot (URL-safe: letters, numbers, underscores, dashes)'
|
|
100
|
+
),
|
|
101
|
+
fullName: z
|
|
102
|
+
.string()
|
|
103
|
+
.optional()
|
|
104
|
+
.describe('Full name with org slug for public snapshots (@slug/name:tag)'),
|
|
105
|
+
message: z.string().nullable().optional().describe('Build message for the snapshot'),
|
|
106
|
+
tag: z.string().nullable().optional().describe('Tag for the snapshot'),
|
|
107
|
+
parentSnapshotId: z
|
|
108
|
+
.string()
|
|
109
|
+
.nullable()
|
|
110
|
+
.optional()
|
|
111
|
+
.describe('ID of the parent snapshot in the lineage'),
|
|
112
|
+
public: z.boolean().describe('Whether the snapshot is publicly accessible'),
|
|
113
|
+
org: SnapshotOrgInfoSchema.nullable()
|
|
114
|
+
.optional()
|
|
115
|
+
.describe('Organization details (for public snapshots)'),
|
|
116
|
+
user: SnapshotUserInfoSchema.nullable()
|
|
117
|
+
.optional()
|
|
118
|
+
.describe('User who pushed the snapshot (for private snapshots)'),
|
|
119
|
+
createdAt: z.string().describe('ISO timestamp when the snapshot was created'),
|
|
120
|
+
})
|
|
121
|
+
.describe('A single entry in the snapshot lineage chain');
|
|
122
|
+
|
|
123
|
+
const SnapshotLineageDataSchema = z
|
|
124
|
+
.object({
|
|
125
|
+
lineage: z.array(SnapshotLineageEntrySchema).describe('Ordered list of snapshots in lineage'),
|
|
126
|
+
total: z.number().describe('Total number of snapshots in the lineage'),
|
|
127
|
+
})
|
|
128
|
+
.describe('Snapshot lineage response');
|
|
129
|
+
|
|
130
|
+
const SnapshotLineageResponseSchema = APIResponseSchema(SnapshotLineageDataSchema);
|
|
131
|
+
|
|
60
132
|
export type SnapshotFileInfo = z.infer<typeof SnapshotFileInfoSchema>;
|
|
61
133
|
export type SnapshotInfo = z.infer<typeof SnapshotInfoSchema>;
|
|
62
134
|
export type SnapshotListResponse = z.infer<typeof SnapshotListDataSchema>;
|
|
135
|
+
export type SnapshotLineageEntry = z.infer<typeof SnapshotLineageEntrySchema>;
|
|
136
|
+
export type SnapshotLineageResponse = z.infer<typeof SnapshotLineageDataSchema>;
|
|
63
137
|
|
|
64
138
|
const _SnapshotCreateParamsSchema = z
|
|
65
139
|
.object({
|
|
@@ -67,6 +141,10 @@ const _SnapshotCreateParamsSchema = z
|
|
|
67
141
|
name: z.string().optional().describe('Display name for the snapshot'),
|
|
68
142
|
description: z.string().optional().describe('Description of the snapshot'),
|
|
69
143
|
tag: z.string().optional().describe('Tag for the snapshot'),
|
|
144
|
+
public: z
|
|
145
|
+
.boolean()
|
|
146
|
+
.optional()
|
|
147
|
+
.describe('Whether to make the snapshot publicly accessible (default: false)'),
|
|
70
148
|
orgId: z.string().optional().describe('Organization ID'),
|
|
71
149
|
})
|
|
72
150
|
.describe('Parameters for creating a snapshot');
|
|
@@ -102,11 +180,31 @@ const _SnapshotTagParamsSchema = z
|
|
|
102
180
|
})
|
|
103
181
|
.describe('Parameters for tagging a snapshot');
|
|
104
182
|
|
|
183
|
+
const _SnapshotLineageParamsSchema = z
|
|
184
|
+
.object({
|
|
185
|
+
snapshot: z
|
|
186
|
+
.string()
|
|
187
|
+
.optional()
|
|
188
|
+
.describe('Snapshot ID or name:tag to start lineage from (e.g., "sss_xxx" or "myimage:v1")'),
|
|
189
|
+
name: z
|
|
190
|
+
.string()
|
|
191
|
+
.optional()
|
|
192
|
+
.describe('Snapshot name to start lineage from (uses latest if tag not specified)'),
|
|
193
|
+
tag: z.string().optional().describe('Tag to use with name parameter'),
|
|
194
|
+
limit: z
|
|
195
|
+
.number()
|
|
196
|
+
.optional()
|
|
197
|
+
.describe('Maximum number of snapshots to return in lineage (default: 100, max: 1000)'),
|
|
198
|
+
orgId: z.string().optional().describe('Organization ID'),
|
|
199
|
+
})
|
|
200
|
+
.describe('Parameters for getting snapshot lineage');
|
|
201
|
+
|
|
105
202
|
export type SnapshotCreateParams = z.infer<typeof _SnapshotCreateParamsSchema>;
|
|
106
203
|
export type SnapshotGetParams = z.infer<typeof _SnapshotGetParamsSchema>;
|
|
107
204
|
export type SnapshotListParams = z.infer<typeof _SnapshotListParamsSchema>;
|
|
108
205
|
export type SnapshotDeleteParams = z.infer<typeof _SnapshotDeleteParamsSchema>;
|
|
109
206
|
export type SnapshotTagParams = z.infer<typeof _SnapshotTagParamsSchema>;
|
|
207
|
+
export type SnapshotLineageParams = z.infer<typeof _SnapshotLineageParamsSchema>;
|
|
110
208
|
|
|
111
209
|
function buildQueryString(params: Record<string, string | number | undefined>): string {
|
|
112
210
|
const query = new URLSearchParams();
|
|
@@ -131,11 +229,11 @@ export async function snapshotCreate(
|
|
|
131
229
|
client: APIClient,
|
|
132
230
|
params: SnapshotCreateParams
|
|
133
231
|
): Promise<SnapshotInfo> {
|
|
134
|
-
const { sandboxId, name, description, tag, orgId } = params;
|
|
232
|
+
const { sandboxId, name, description, tag, public: isPublic, orgId } = params;
|
|
135
233
|
const queryString = buildQueryString({ orgId });
|
|
136
234
|
const url = `/sandbox/${API_VERSION}/${sandboxId}/snapshot${queryString}`;
|
|
137
235
|
|
|
138
|
-
const body: Record<string, string> = {};
|
|
236
|
+
const body: Record<string, string | boolean> = {};
|
|
139
237
|
if (name) {
|
|
140
238
|
body.name = name;
|
|
141
239
|
}
|
|
@@ -145,6 +243,9 @@ export async function snapshotCreate(
|
|
|
145
243
|
if (tag) {
|
|
146
244
|
body.tag = tag;
|
|
147
245
|
}
|
|
246
|
+
if (isPublic !== undefined) {
|
|
247
|
+
body.public = isPublic;
|
|
248
|
+
}
|
|
148
249
|
|
|
149
250
|
const resp = await client.post<z.infer<typeof SnapshotCreateResponseSchema>>(
|
|
150
251
|
url,
|
|
@@ -269,6 +370,49 @@ export async function snapshotTag(
|
|
|
269
370
|
throw new SandboxResponseError({ message: resp.message });
|
|
270
371
|
}
|
|
271
372
|
|
|
373
|
+
/**
|
|
374
|
+
* Gets the lineage (ancestry chain) of a snapshot.
|
|
375
|
+
*
|
|
376
|
+
* Returns an ordered list of snapshots from the specified snapshot (or latest by name)
|
|
377
|
+
* walking back through parentSnapshotId references to the root.
|
|
378
|
+
*
|
|
379
|
+
* @param client - The API client to use for the request
|
|
380
|
+
* @param params - Parameters specifying which snapshot to get lineage for
|
|
381
|
+
* @returns Ordered list of snapshots in the lineage (newest to oldest)
|
|
382
|
+
* @throws {SandboxResponseError} If the snapshot is not found or request fails
|
|
383
|
+
*
|
|
384
|
+
* @example
|
|
385
|
+
* // Get lineage starting from a specific snapshot ID
|
|
386
|
+
* const lineage = await snapshotLineage(client, { snapshot: 'snp_abc123' });
|
|
387
|
+
*
|
|
388
|
+
* @example
|
|
389
|
+
* // Get lineage starting from the latest snapshot with a given name
|
|
390
|
+
* const lineage = await snapshotLineage(client, { name: 'myapp' });
|
|
391
|
+
*
|
|
392
|
+
* @example
|
|
393
|
+
* // Get lineage starting from a specific name:tag
|
|
394
|
+
* const lineage = await snapshotLineage(client, { name: 'myapp', tag: 'v1.0.0' });
|
|
395
|
+
*/
|
|
396
|
+
export async function snapshotLineage(
|
|
397
|
+
client: APIClient,
|
|
398
|
+
params: SnapshotLineageParams
|
|
399
|
+
): Promise<SnapshotLineageResponse> {
|
|
400
|
+
const { snapshot, name, tag, limit, orgId } = params;
|
|
401
|
+
const queryString = buildQueryString({ snapshot, name, tag, limit, orgId });
|
|
402
|
+
const url = `/sandbox/${API_VERSION}/snapshots/lineage${queryString}`;
|
|
403
|
+
|
|
404
|
+
const resp = await client.get<z.infer<typeof SnapshotLineageResponseSchema>>(
|
|
405
|
+
url,
|
|
406
|
+
SnapshotLineageResponseSchema
|
|
407
|
+
);
|
|
408
|
+
|
|
409
|
+
if (resp.success) {
|
|
410
|
+
return resp.data;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
throw new SandboxResponseError({ message: resp.message });
|
|
414
|
+
}
|
|
415
|
+
|
|
272
416
|
// ===== Snapshot Build API =====
|
|
273
417
|
|
|
274
418
|
const _SnapshotBuildInitParamsSchema = z
|
|
@@ -283,6 +427,10 @@ const _SnapshotBuildInitParamsSchema = z
|
|
|
283
427
|
.describe('SHA-256 hash of snapshot content for change detection'),
|
|
284
428
|
force: z.boolean().optional().describe('Force rebuild even if content is unchanged'),
|
|
285
429
|
encrypt: z.boolean().optional().describe('Request encryption for the snapshot archive'),
|
|
430
|
+
public: z
|
|
431
|
+
.boolean()
|
|
432
|
+
.optional()
|
|
433
|
+
.describe('Make snapshot public (enables virus scanning, disables encryption)'),
|
|
286
434
|
orgId: z.string().optional().describe('Organization ID'),
|
|
287
435
|
})
|
|
288
436
|
.describe('Parameters for initializing a snapshot build');
|
|
@@ -293,8 +441,7 @@ const SnapshotBuildInitResponseSchema = z
|
|
|
293
441
|
uploadUrl: z
|
|
294
442
|
.string()
|
|
295
443
|
.optional()
|
|
296
|
-
.describe('Pre-signed URL for uploading the snapshot archive'),
|
|
297
|
-
s3Key: z.string().optional().describe('S3 key where the snapshot will be stored'),
|
|
444
|
+
.describe('Pre-signed URL for uploading the snapshot archive (private snapshots only)'),
|
|
298
445
|
publicKey: z
|
|
299
446
|
.string()
|
|
300
447
|
.optional()
|
|
@@ -340,7 +487,8 @@ export async function snapshotBuildInit(
|
|
|
340
487
|
client: APIClient,
|
|
341
488
|
params: SnapshotBuildInitParams
|
|
342
489
|
): Promise<SnapshotBuildInitResponse> {
|
|
343
|
-
const { runtime, name, description, tag, contentHash, force, encrypt, orgId } =
|
|
490
|
+
const { runtime, name, description, tag, contentHash, force, encrypt, public: isPublic, orgId } =
|
|
491
|
+
params;
|
|
344
492
|
const queryString = buildQueryString({ orgId });
|
|
345
493
|
const url = `/sandbox/${API_VERSION}/snapshots/build${queryString}`;
|
|
346
494
|
|
|
@@ -351,6 +499,7 @@ export async function snapshotBuildInit(
|
|
|
351
499
|
if (contentHash) body.contentHash = contentHash;
|
|
352
500
|
if (force) body.force = force;
|
|
353
501
|
if (encrypt) body.encrypt = encrypt;
|
|
502
|
+
if (isPublic !== undefined) body.public = isPublic;
|
|
354
503
|
|
|
355
504
|
const resp = await client.post<z.infer<typeof SnapshotBuildInitAPIResponseSchema>>(
|
|
356
505
|
url,
|
|
@@ -402,3 +551,72 @@ export async function snapshotBuildFinalize(
|
|
|
402
551
|
|
|
403
552
|
throw new SandboxResponseError({ message: resp.message });
|
|
404
553
|
}
|
|
554
|
+
|
|
555
|
+
// ===== Snapshot Upload API (for public snapshots) =====
|
|
556
|
+
|
|
557
|
+
const SnapshotUploadResponseSchema = z
|
|
558
|
+
.object({
|
|
559
|
+
success: z.boolean().describe('Whether the upload was successful'),
|
|
560
|
+
scanned: z.boolean().describe('Whether the upload was virus scanned'),
|
|
561
|
+
message: z.string().optional().describe('Optional message'),
|
|
562
|
+
})
|
|
563
|
+
.describe('Response from snapshot upload API');
|
|
564
|
+
|
|
565
|
+
const _SnapshotUploadAPIResponseSchema = APIResponseSchema(SnapshotUploadResponseSchema);
|
|
566
|
+
|
|
567
|
+
export type SnapshotUploadResponse = z.infer<typeof SnapshotUploadResponseSchema>;
|
|
568
|
+
|
|
569
|
+
export interface SnapshotUploadParams {
|
|
570
|
+
snapshotId: string;
|
|
571
|
+
body: Uint8Array | ArrayBuffer | ReadableStream<Uint8Array> | string | Blob;
|
|
572
|
+
contentLength: number;
|
|
573
|
+
orgId?: string;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* Upload a public snapshot archive via Catalyst (with virus scanning).
|
|
578
|
+
* This should only be used when snapshotBuildInit returns no uploadUrl.
|
|
579
|
+
*
|
|
580
|
+
* @param client - The API client to use for the request
|
|
581
|
+
* @param params - Parameters including snapshotId and the archive body
|
|
582
|
+
* @returns Upload result with scan status
|
|
583
|
+
* @throws {SandboxResponseError} If the upload fails or malware is detected
|
|
584
|
+
*/
|
|
585
|
+
export async function snapshotUpload(
|
|
586
|
+
client: APIClient,
|
|
587
|
+
params: SnapshotUploadParams
|
|
588
|
+
): Promise<SnapshotUploadResponse> {
|
|
589
|
+
const { snapshotId, body, contentLength, orgId } = params;
|
|
590
|
+
const queryString = buildQueryString({ orgId });
|
|
591
|
+
const url = `/sandbox/${API_VERSION}/snapshots/${snapshotId}/upload${queryString}`;
|
|
592
|
+
|
|
593
|
+
const response = await client.rawPut(url, body, 'application/gzip', undefined, {
|
|
594
|
+
'Content-Length': String(contentLength),
|
|
595
|
+
Accept: 'application/json',
|
|
596
|
+
});
|
|
597
|
+
|
|
598
|
+
if (!response.ok) {
|
|
599
|
+
const text = await response.text();
|
|
600
|
+
let message = `Upload failed: ${response.status} ${response.statusText}`;
|
|
601
|
+
try {
|
|
602
|
+
const json = JSON.parse(text);
|
|
603
|
+
if (json.message) {
|
|
604
|
+
message = json.message;
|
|
605
|
+
} else if (json.error) {
|
|
606
|
+
message = typeof json.error === 'string' ? json.error : JSON.stringify(json.error);
|
|
607
|
+
}
|
|
608
|
+
} catch {
|
|
609
|
+
if (text) {
|
|
610
|
+
message = text;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
throw new SandboxResponseError({ message });
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
const data = (await response.json()) as z.infer<typeof _SnapshotUploadAPIResponseSchema>;
|
|
617
|
+
if (data.success) {
|
|
618
|
+
return data.data;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
throw new SandboxResponseError({ message: data.message });
|
|
622
|
+
}
|