disk 1.10.0 → 1.12.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.
@@ -1,784 +0,0 @@
1
- import { Client } from "openapi-fetch";
2
- import { components, paths } from "@archildata/api-types";
3
- import { ConnectionOptions } from "node:tls";
4
-
5
- //#region src/client.d.ts
6
- type ApiClient = Client<paths>;
7
- interface ArchilTlsOptions {
8
- /**
9
- * Trusted PEM CA certificates for this client's control-plane and S3 requests
10
- * (Node.js only). Replaces Node's default CA list; include those certificates
11
- * explicitly to retain them. Certificate and hostname verification stay enabled.
12
- */
13
- ca?: ConnectionOptions["ca"];
14
- }
15
- //#endregion
16
- //#region src/filesystem.d.ts
17
- /**
18
- * A key-addressable filesystem over one or more Archil disks — the existing
19
- * object API a {@link Disk} already exposes ({@link Disk.getObject},
20
- * `putObject`, `deleteObject`, `listObjects`, `grep`, `exec`), captured as a
21
- * contract so a multi-disk {@link Workspace} can be used anywhere a single disk
22
- * is.
23
- *
24
- * A single {@link Disk} is the one-disk case: keys are relative to the disk
25
- * root. A {@link Workspace} spans several disks, each mounted under a name, so
26
- * its keys carry that name as the first segment (e.g. `data/reports/q1.csv`)
27
- * and `listObjects`/`grep` fan out across every disk when the key/prefix
28
- * doesn't name one.
29
- *
30
- * Both `Disk` and `Workspace` implement this interface, which is what keeps the
31
- * two from drifting — adding a method here is a compile error until both do.
32
- */
33
- interface FileSystem {
34
- /** Read an object's full contents. Throws `ArchilS3Error` (404) if absent. */
35
- getObject(key: string): Promise<Uint8Array>;
36
- /** Create or overwrite an object. */
37
- putObject(key: string, body: string | Uint8Array | ArrayBuffer, options?: string | PutObjectOptions): Promise<PutObjectResult>;
38
- /** Delete an object (idempotent). */
39
- deleteObject(key: string): Promise<void>;
40
- /** List objects and common (directory) prefixes under a key prefix. */
41
- listObjects(prefix?: string, opts?: ListObjectsOptions): Promise<ListObjectsResult>;
42
- /** Constant-time parallel grep. */
43
- grep(opts: GrepOptions): Promise<GrepResult>;
44
- /** Run a command in a sandbox with the filesystem mounted. */
45
- exec(command: string): Promise<ExecResult>;
46
- }
47
- //#endregion
48
- //#region src/types.d.ts
49
- type DiskResponse = components["schemas"]["DiskResponse"];
50
- type MountResponse = components["schemas"]["MountResponse"];
51
- type MountConfigResponse = components["schemas"]["MountConfigResponse"];
52
- type DiskMetrics = components["schemas"]["DiskMetrics"];
53
- type ConnectedClient = components["schemas"]["ConnectedClient"];
54
- type AuthorizedUser = components["schemas"]["AuthorizedUser"];
55
- type CreateDiskRequest = components["schemas"]["CreateDiskRequest"];
56
- type RootAttrs = components["schemas"]["RootAttrs"];
57
- type MountConfig = components["schemas"]["MountConfig"];
58
- type S3Mount = components["schemas"]["S3Mount"];
59
- type GCSMount = components["schemas"]["GCSMount"];
60
- type R2Mount = components["schemas"]["R2Mount"];
61
- type S3CompatibleMount = components["schemas"]["S3CompatibleMount"];
62
- type AzureBlobMount = components["schemas"]["AzureBlobMount"];
63
- type Delegation = components["schemas"]["DelegationEntry"];
64
- type Branch = components["schemas"]["BranchResponse"];
65
- type DiskUser = components["schemas"]["DiskUser"];
66
- type TokenUser = components["schemas"]["TokenUser"];
67
- type AwsStsUser = components["schemas"]["AwsStsUser"];
68
- type CreateApiTokenRequest = components["schemas"]["CreateApiTokenRequest"];
69
- type ApiTokenResponse = components["schemas"]["ApiTokenResponse"];
70
- type ExecDiskResult = components["schemas"]["ExecDiskResult"];
71
- type ExecRequest = components["schemas"]["ExecRequest"];
72
- type GrepDiskResult = components["schemas"]["GrepDiskResult"];
73
- type GrepMatch = components["schemas"]["GrepMatch"];
74
- type GrepGroup = components["schemas"]["GrepGroup"];
75
- type GrepGroupLine = components["schemas"]["GrepGroupLine"];
76
- type GrepStoppedReason = components["schemas"]["GrepStoppedReason"];
77
- type DiskStatus = DiskResponse["status"];
78
- //#endregion
79
- //#region src/disk.d.ts
80
- interface MountOptions {
81
- authToken?: string;
82
- logLevel?: string;
83
- serverAddress?: string;
84
- insecure?: boolean;
85
- }
86
- interface CreateBranchOptions {
87
- /** 1-100 letters, digits, hyphens, or underscores. Unique across the disk. */
88
- name: string;
89
- /** Name of a committed checkpoint on the source. */
90
- fromCheckpoint: string;
91
- /** Branch the checkpoint was taken on. Omit to branch from the root disk. */
92
- fromBranch?: string;
93
- /**
94
- * UUID identifying this create. Pass the same key (and options) when you
95
- * retry a create yourself, so a retry of one that succeeded returns that
96
- * branch instead of a 409. Defaults to a fresh key per call; the SDK's own
97
- * retries always reuse it.
98
- */
99
- idempotencyKey?: string;
100
- }
101
- type ExecResult = ExecDiskResult;
102
- type GrepResult = GrepDiskResult;
103
- interface GrepOptions {
104
- /**
105
- * Directory on the disk to search, relative to the disk root. An empty
106
- * string or "/" means the disk root.
107
- */
108
- directory: string;
109
- /**
110
- * Regular expression in ripgrep syntax. A newline separates alternative
111
- * patterns, except with `multiline`, where it matches a line break.
112
- */
113
- pattern: string;
114
- /** Walk subdirectories breadth-first. Defaults to false. */
115
- recursive?: boolean;
116
- /** Wall-clock deadline for the entire request. Defaults to 30s. */
117
- maxDurationSeconds?: number;
118
- /**
119
- * Maximum number of parallel grep workers. Higher values finish larger
120
- * datasets within the deadline but consume more runtime capacity. The
121
- * controlplane clamps this to the fleet's currently-available capacity.
122
- * Defaults to 50.
123
- */
124
- concurrency?: number;
125
- /**
126
- * Stop scanning once the aggregator has this many matches. Returned
127
- * matches are a sample of whichever workers reported first, not the
128
- * lexicographically first N. Defaults to 1000.
129
- */
130
- maxResults?: number;
131
- /** Match the pattern case-insensitively (`rg -i`). Defaults to false. */
132
- ignoreCase?: boolean;
133
- /**
134
- * Let a match span lines (`rg -U`): `\n` in the pattern matches a line
135
- * break, and `.` matches one only after `(?s)`. Files with Windows line
136
- * endings need `\r?\n`. Matches on adjacent lines come back as one match
137
- * with `endLine` set, and count once toward `maxResults`. Defaults to false.
138
- */
139
- multiline?: boolean;
140
- /**
141
- * Path globs with ripgrep's `-g` rules, matched against paths relative to
142
- * `directory`. A leading `!` excludes. If any non-`!` glob is given, files
143
- * that match no glob are skipped. A file a glob matches is searched or
144
- * skipped regardless of `types` and `typesNot`.
145
- */
146
- globs?: string[];
147
- /** Only search files of these ripgrep types (for example `py`, `ts`). */
148
- types?: string[];
149
- /** Skip files of these ripgrep types. Takes precedence over `types`. */
150
- typesNot?: string[];
151
- /**
152
- * Lines of context to return before each match (`rg -B`), 0 to 10. When
153
- * either context field is set, the result includes `groups`.
154
- */
155
- contextBefore?: number;
156
- /**
157
- * Lines of context to return after each match (`rg -A`), 0 to 10. When
158
- * either context field is set, the result includes `groups`.
159
- */
160
- contextAfter?: number;
161
- }
162
- interface ShareUrlOptions {
163
- /**
164
- * Lifetime of the URL in seconds — any positive integer, up to 604800
165
- * (7 days). Defaults to 86400 (24 hours).
166
- */
167
- expiresIn?: number;
168
- }
169
- interface ShareUrlResult {
170
- /** Public, signed, time-limited URL that downloads the file. */
171
- url: string;
172
- /** Lifetime of the URL in seconds. */
173
- expiresIn: number;
174
- }
175
- interface ListObjectsOptions {
176
- /**
177
- * List the entire subtree under the prefix. When false (the default), only
178
- * the immediate level is returned — direct objects in `objects` and
179
- * subdirectory prefixes in `commonPrefixes`, like listing a single directory.
180
- * When true, every key under the prefix is returned flat (and
181
- * `commonPrefixes` is empty).
182
- */
183
- recursive?: boolean;
184
- /**
185
- * Return only the first page instead of auto-paginating. By default
186
- * listObjects follows continuation tokens until the listing is exhausted and
187
- * returns every matching key. With `singlePage: true` it makes one request
188
- * and the result carries `isTruncated` / `nextContinuationToken` so you can
189
- * page manually (pass the token back via `continuationToken`).
190
- */
191
- singlePage?: boolean;
192
- /**
193
- * Stop after this many objects total (only meaningful when auto-paginating).
194
- * The result's `isTruncated` is true if the cap cut the listing short.
195
- */
196
- limit?: number;
197
- /** Start listing from this continuation token (from a prior `nextContinuationToken`). */
198
- continuationToken?: string;
199
- /** Return keys lexicographically after this one. */
200
- startAfter?: string;
201
- }
202
- interface S3Object {
203
- /** Object key (path on the disk). */
204
- key: string;
205
- /** Size in bytes. */
206
- size: number;
207
- /** Entity tag (quoted MD5 for single-part objects). */
208
- etag?: string;
209
- /** Last-modified time, if reported by the server. */
210
- lastModified?: Date;
211
- }
212
- interface PutObjectResult {
213
- /** Entity tag the server assigned (quoted, per S3 — e.g. `"\"abc123\""`). */
214
- etag?: string;
215
- }
216
- interface ObjectMetadata {
217
- /** Size in bytes. */
218
- size: number;
219
- /** Entity tag (quoted MD5 for single-part objects). */
220
- etag?: string;
221
- /** MIME type the object was stored with, if any. */
222
- contentType?: string;
223
- /** Last-modified time, if reported by the server. */
224
- lastModified?: Date;
225
- }
226
- interface ListObjectsResult {
227
- /** Objects in this page. */
228
- objects: S3Object[];
229
- /** Directory-like prefixes rolled up by `delimiter` (empty if no delimiter). */
230
- commonPrefixes: string[];
231
- /** True if more keys exist beyond this page. */
232
- isTruncated: boolean;
233
- /** Token to pass as `continuationToken` to fetch the next page. */
234
- nextContinuationToken?: string;
235
- /** Number of keys returned in this page. */
236
- keyCount: number;
237
- /** The prefix the listing was filtered by, echoed back by the server. */
238
- prefix?: string;
239
- }
240
- /** A part to list in {@link Disk.completeMultipartUpload}. */
241
- interface UploadPart {
242
- /** 1-based part number (1..=10000), strictly increasing across the list. */
243
- partNumber: number;
244
- /** Entity tag returned by {@link Disk.uploadPart} for this part. */
245
- etag: string;
246
- }
247
- /** Handle to an in-progress multipart upload, returned by {@link Disk.createMultipartUpload}. */
248
- interface MultipartUpload {
249
- /** Server-assigned upload id; pass to uploadPart/complete/abort/listParts. */
250
- uploadId: string;
251
- /** The object key this upload targets. */
252
- key: string;
253
- /** The bucket (disk id) the upload lives in. */
254
- bucket: string;
255
- }
256
- /** The assembled object, returned by {@link Disk.completeMultipartUpload}. */
257
- interface CompletedMultipartUpload {
258
- /** Multipart entity tag — S3's `md5(concat(partMd5s))-N` form. */
259
- etag?: string;
260
- /** Resource path of the completed object. */
261
- location?: string;
262
- /** The bucket (disk id). */
263
- bucket?: string;
264
- /** The object key. */
265
- key?: string;
266
- }
267
- /** One part in a {@link Disk.listParts} listing. */
268
- interface PartInfo {
269
- /** 1-based part number. */
270
- partNumber: number;
271
- /** Entity tag the server assigned to this part. */
272
- etag?: string;
273
- /** Size in bytes. */
274
- size: number;
275
- /** Time the part was uploaded, if reported. */
276
- lastModified?: Date;
277
- }
278
- interface ListPartsOptions {
279
- /** Cap parts returned in one page (server clamps to 1000). */
280
- maxParts?: number;
281
- /** Return parts after this part number (for pagination). */
282
- partNumberMarker?: number;
283
- }
284
- interface PartListing {
285
- /** The bucket (disk id), echoed by the server. */
286
- bucket?: string;
287
- /** The object key, echoed by the server. */
288
- key?: string;
289
- /** The upload id, echoed by the server. */
290
- uploadId?: string;
291
- /** Parts in this page, ascending by part number. */
292
- parts: PartInfo[];
293
- /** True if more parts exist beyond this page. */
294
- isTruncated: boolean;
295
- /** The part-number marker this page started after. */
296
- partNumberMarker: number;
297
- /** Pass back as `partNumberMarker` to fetch the next page. */
298
- nextPartNumberMarker?: number;
299
- /** Max parts the server was asked to return. */
300
- maxParts: number;
301
- }
302
- /** One in-progress upload in a {@link Disk.listMultipartUploads} listing. */
303
- interface MultipartUploadSummary {
304
- /** The object key the upload targets. */
305
- key: string;
306
- /** The upload id. */
307
- uploadId: string;
308
- /** When the upload was initiated, if reported. */
309
- initiated?: Date;
310
- }
311
- interface ListMultipartUploadsOptions {
312
- /** Only list uploads whose key begins with this prefix. */
313
- prefix?: string;
314
- /** Roll keys up to this delimiter into `commonPrefixes` (S3 supports "/"). */
315
- delimiter?: string;
316
- /** Resume listing keys after this one (with `uploadIdMarker`). */
317
- keyMarker?: string;
318
- /** Resume listing uploads after this upload id (requires `keyMarker`). */
319
- uploadIdMarker?: string;
320
- /** Cap uploads returned in one page (server clamps to 1000). */
321
- maxUploads?: number;
322
- }
323
- interface MultipartUploadListing {
324
- /** The bucket (disk id), echoed by the server. */
325
- bucket?: string;
326
- /** In-progress uploads in this page. */
327
- uploads: MultipartUploadSummary[];
328
- /** Key prefixes rolled up by `delimiter` (empty if no delimiter). */
329
- commonPrefixes: string[];
330
- /** True if more uploads exist beyond this page. */
331
- isTruncated: boolean;
332
- /** The key marker this page started after, echoed back. */
333
- keyMarker?: string;
334
- /** The upload-id marker this page started after, echoed back. */
335
- uploadIdMarker?: string;
336
- /** Pass back as `keyMarker` (with `nextUploadIdMarker`) for the next page. */
337
- nextKeyMarker?: string;
338
- /** Pass back as `uploadIdMarker` (with `nextKeyMarker`) for the next page. */
339
- nextUploadIdMarker?: string;
340
- /** The prefix the listing was filtered by, echoed back. */
341
- prefix?: string;
342
- /** The delimiter used, echoed back. */
343
- delimiter?: string;
344
- /** Max uploads the server was asked to return. */
345
- maxUploads?: number;
346
- }
347
- interface DeleteObjectsOptions {
348
- /**
349
- * Quiet mode: the server omits the per-key success list and returns only
350
- * failures, so the result's `deleted` array is empty. Cuts response size on
351
- * large batches. Defaults to false.
352
- */
353
- quiet?: boolean;
354
- }
355
- /** A single per-key failure within a {@link Disk.deleteObjects} batch. */
356
- interface DeleteObjectsError {
357
- /** The key that failed to delete. */
358
- key: string;
359
- /** S3 error code (e.g. "AccessDenied", "OperationAborted"), if provided. */
360
- code?: string;
361
- /** Human-readable failure detail, if provided. */
362
- message?: string;
363
- }
364
- interface DeleteObjectsResult {
365
- /** Keys the server confirmed deleted (empty in quiet mode). */
366
- deleted: string[];
367
- /** Per-key failures; empty when every key was deleted. */
368
- errors: DeleteObjectsError[];
369
- }
370
- /**
371
- * POSIX attributes to set on a newly created object, sent to the S3 gateway as
372
- * `x-archil-*` headers. Missing parent directories inherit `uid` / `gid` and
373
- * use mode `0755`; existing directories are unchanged. All fields are optional
374
- * — new files default to `root:root 0644`, while directory markers default to
375
- * `root:root 0755`.
376
- */
377
- interface PosixCreateAttrs {
378
- /** POSIX mode bits for the created file or directory marker. Sent in octal. */
379
- mode?: number;
380
- /** Owning user id, e.g. `1000`. */
381
- uid?: number;
382
- /** Owning group id, e.g. `1000`. */
383
- gid?: number;
384
- }
385
- interface PutObjectOptions extends PosixCreateAttrs {
386
- /** MIME type to store the object with. Default "application/octet-stream". */
387
- contentType?: string;
388
- /**
389
- * Bodies larger than this take the multipart path; bodies at or below it take
390
- * a single PutObject. Defaults to `partSize` (16 MiB), so by default the
391
- * switch happens at the part size. Set it lower (e.g. 5 MiB) to start using
392
- * multipart sooner, or to `Infinity` to force a single PutObject.
393
- */
394
- multipartThreshold?: number;
395
- /**
396
- * Bytes per part on the multipart path. Clamped to a minimum of 5 MiB (the S3
397
- * floor for every part but the last). Default 16 MiB.
398
- */
399
- partSize?: number;
400
- /** Max parts uploaded in parallel on the multipart path. Default 4. */
401
- concurrency?: number;
402
- }
403
- interface AppendObjectOptions extends PosixCreateAttrs {
404
- /**
405
- * MIME type, applied only when the object is newly created. Default
406
- * "application/octet-stream".
407
- */
408
- contentType?: string;
409
- }
410
- /**
411
- * The S3 transport function {@link DiskMultipart} uses, supplied by the owning
412
- * {@link Disk} so the namespace shares the disk's credential and endpoint.
413
- * @internal
414
- */
415
- type S3RequestFn = (method: "GET" | "PUT" | "DELETE" | "HEAD" | "POST", key: string, opts?: {
416
- body?: string | Uint8Array | ArrayBuffer;
417
- contentType?: string;
418
- query?: Record<string, string | number>;
419
- retry?: boolean;
420
- extraHeaders?: Record<string, string>;
421
- }) => Promise<{
422
- ok: boolean;
423
- status: number;
424
- statusText: string;
425
- headers: Headers;
426
- body: Uint8Array;
427
- }>;
428
- declare class Disk implements FileSystem {
429
- readonly id: string;
430
- readonly name: string;
431
- readonly organization: string;
432
- readonly status: DiskStatus;
433
- readonly provider: string;
434
- readonly region: string;
435
- readonly createdAt: string;
436
- readonly fsHandlerStatus?: string;
437
- readonly lastAccessed?: string;
438
- readonly activeDataBytes?: number;
439
- readonly totalDataBytes?: number;
440
- /** @deprecated Use {@link activeDataBytes}. */
441
- readonly dataSize?: number;
442
- readonly monthlyUsage?: string;
443
- readonly mounts?: MountResponse[];
444
- readonly metrics?: DiskMetrics;
445
- readonly connectedClients?: ConnectedClient[];
446
- readonly authorizedUsers?: AuthorizedUser[];
447
- readonly allowedIps?: string[];
448
- /** Root-directory POSIX attributes recorded at creation, if any. */
449
- readonly rootAttrs?: RootAttrs;
450
- /** @internal */
451
- private readonly _client;
452
- /** @internal */
453
- private readonly _archilRegion;
454
- /** Base URL for the S3-compatible API (port 9000 ingress). Empty if unset. */
455
- private readonly _s3BaseUrl;
456
- /** Lazily-constructed multipart namespace (see {@link multipart}). @internal */
457
- private _multipart?;
458
- /** @internal */
459
- constructor(data: DiskResponse, client: ApiClient, archilRegion: string, s3BaseUrl?: string);
460
- toJSON(): DiskResponse;
461
- addUser(user: DiskUser): Promise<AuthorizedUser>;
462
- removeUser(userType: "token" | "awssts", identifier: string): Promise<void>;
463
- createToken(nickname: string): Promise<AuthorizedUser & {
464
- token: string;
465
- identifier: string;
466
- }>;
467
- removeTokenUser(identifier: string): Promise<void>;
468
- /**
469
- * List all delegations currently held on this disk. A delegation grants a
470
- * client exclusive write access to an inode; it has no ID of its own and is
471
- * identified by the (clientId, inodeId) pair — pass those to
472
- * `revokeDelegation` to release one. Entries with `isOrphaned: true` are
473
- * held by clients no longer connected to the disk (disconnected without
474
- * checking in). `path` is resolved best-effort by the server and may be
475
- * absent.
476
- */
477
- listDelegations(): Promise<Delegation[]>;
478
- /**
479
- * Forcibly revoke a delegation, reclaiming write access from a client that
480
- * is unreachable or crashed without checking its delegations in.
481
- *
482
- * Takes the `(clientId, inodeId)` pair identifying the delegation — pass an
483
- * entry from `listDelegations` directly:
484
- *
485
- * ```ts
486
- * for (const d of await disk.listDelegations()) {
487
- * if (d.isOrphaned) await disk.revokeDelegation(d);
488
- * }
489
- * ```
490
- */
491
- revokeDelegation(delegation: Pick<Delegation, "clientId" | "inodeId">): Promise<void>;
492
- /**
493
- * Create a branch: an independent, writable fork of this disk that starts
494
- * from a committed checkpoint. Writes on the branch don't affect its source.
495
- *
496
- * Fails with a 409 if a branch with this name already exists or the
497
- * checkpoint is not yet committed, and a 404 if the checkpoint or
498
- * `fromBranch` doesn't exist.
499
- */
500
- createBranch(options: CreateBranchOptions): Promise<Branch>;
501
- /** List every branch of this disk, including branches of branches, in no particular order. */
502
- listBranches(): Promise<Branch[]>;
503
- getBranch(name: string): Promise<Branch>;
504
- getAllowedIPs(): Promise<string[]>;
505
- setAllowedIPs(allowedIps: string[]): Promise<string[]>;
506
- addAllowedIP(ip: string): Promise<string[]>;
507
- removeAllowedIP(ip: string): Promise<string[]>;
508
- delete(): Promise<void>;
509
- /**
510
- * Execute a command in a container with this disk mounted.
511
- * Blocks until the command completes and returns stdout, stderr, and exit code.
512
- */
513
- exec(command: string): Promise<ExecResult>;
514
- /**
515
- * Constant-time parallel grep across files on this disk. Listing and
516
- * matching are fanned out across ephemeral exec containers; the request
517
- * finishes within the supplied time budget regardless of dataset size.
518
- *
519
- * The returned `stoppedReason` says whether the search ran to completion
520
- * or short-circuited on `maxResults` / `maxDurationSeconds`. When
521
- * stopping early, the matches returned are a sample (whichever workers
522
- * reported first), not the lexicographically first N.
523
- */
524
- grep(opts: GrepOptions): Promise<GrepResult>;
525
- /**
526
- * Create a signed, time-limited URL that lets anyone download a single file
527
- * from this disk without authentication. The returned URL embeds a
528
- * cryptographically signed token carrying the disk, the file's key, and an
529
- * expiry — share it directly; no API key is needed to redeem it.
530
- *
531
- * @param key Path to the file on the disk (e.g. "reports/2026-01/data.pdf").
532
- * @param opts `expiresIn` sets the URL lifetime in seconds (any positive
533
- * integer, max 604800 = 7 days). Defaults to 24h.
534
- */
535
- share(key: string, opts?: ShareUrlOptions): Promise<ShareUrlResult>;
536
- /**
537
- * Read an object from the disk via the S3-compatible GetObject API and return
538
- * its full contents as bytes. Throws `ArchilS3Error` if the object does not
539
- * exist (status 404, code "NoSuchKey") or the request is rejected; use
540
- * `headObject`/`objectExists` to check existence without throwing.
541
- *
542
- * @param key Path on the disk (e.g. "reports/2026-01/data.json")
543
- */
544
- getObject(key: string): Promise<Uint8Array>;
545
- /**
546
- * Fetch an object's metadata (size, etag, content type, last-modified) without
547
- * downloading its contents, via the S3-compatible HeadObject API. Returns
548
- * `null` if the object does not exist.
549
- *
550
- * @param key Path on the disk (e.g. "reports/2026-01/data.json")
551
- */
552
- headObject(key: string): Promise<ObjectMetadata | null>;
553
- /** Whether an object exists on the disk (a HeadObject that maps 404 → false). */
554
- objectExists(key: string): Promise<boolean>;
555
- /**
556
- * Write an object to the disk via the S3-compatible API. Handles any size:
557
- * bodies at or below `multipartThreshold` (defaults to `partSize`, i.e.
558
- * 16 MiB) go through a single PutObject request; larger bodies are uploaded as
559
- * a multipart upload — split into `partSize` parts, uploaded with bounded
560
- * `concurrency` (default 4), and assembled. A failed part aborts the upload so
561
- * nothing is left half-staged. For manual control over the multipart
562
- * lifecycle, use the {@link multipart} namespace.
563
- *
564
- * Faster than exec for large files — no container overhead, no command-length
565
- * limits. Returns the entity tag the server assigned (a multipart upload's tag
566
- * is S3's `md5(concat(partMd5s))-N` form rather than a plain MD5).
567
- *
568
- * Optional `mode` / `uid` / `gid` set the POSIX attributes of the published
569
- * file (e.g. `{ mode: 0o644, uid: 1000, gid: 1000 }` for a non-root agent
570
- * sandbox). Missing parent directories inherit `uid` / `gid` with mode
571
- * `0755`; existing directories remain unchanged. A key ending in `/` creates
572
- * an explicit directory marker whose leaf uses the requested attributes.
573
- * Defaults are `root:root 0644` for files and `root:root 0755` for directories.
574
- *
575
- * @param key Path on the disk (e.g. "reports/2026-01/data.json")
576
- * @param body Contents as a string, Uint8Array/Buffer, or ArrayBuffer
577
- * @param options Either a content-type string, or {@link PutObjectOptions}
578
- * (`contentType`, `multipartThreshold`, `partSize`,
579
- * `concurrency`, `mode`, `uid`, `gid`). Content type defaults
580
- * to "application/octet-stream".
581
- */
582
- putObject(key: string, body: string | Uint8Array | ArrayBuffer, options?: string | PutObjectOptions): Promise<PutObjectResult>;
583
- /**
584
- * Upload a large body through the multipart lifecycle: split into `partSize`
585
- * parts, upload them with bounded concurrency, then complete — aborting the
586
- * upload if any part fails so nothing is left half-staged. @internal
587
- */
588
- private _putMultipart;
589
- /**
590
- * Append bytes to an object via the S3-compatible PutObject append extension
591
- * (`?append=true`). If the object already exists the bytes are appended to it;
592
- * if it doesn't, it is created. Returns the entity tag of the full object
593
- * after the append.
594
- *
595
- * Each call may append at most 1 MiB — the server rejects a larger body with
596
- * `EntityTooLarge`. To grow an object past that, append in chunks (or use
597
- * {@link putObject} for a one-shot large write).
598
- *
599
- * Unlike most operations this is NOT auto-retried on a transient error:
600
- * append isn't idempotent, so retrying a succeeded-but-unacknowledged append
601
- * would duplicate the bytes. On a transient failure, re-append yourself only
602
- * after confirming the object's size.
603
- *
604
- * When the object does not yet exist, optional `mode` / `uid` / `gid` set the
605
- * POSIX attributes of the newly created file (same headers as
606
- * {@link putObject}); missing parents inherit `uid` / `gid` with mode `0755`.
607
- * Existing files and directories are unchanged.
608
- *
609
- * @param key Path on the disk (e.g. "logs/app.log")
610
- * @param body Bytes to append (string, Uint8Array/Buffer, or ArrayBuffer)
611
- * @param options Either a content-type string, or {@link AppendObjectOptions}
612
- * (`contentType`, `mode`, `uid`, `gid`). Content type defaults
613
- * to "application/octet-stream" and applies only when the
614
- * object is newly created.
615
- */
616
- appendObject(key: string, body: string | Uint8Array | ArrayBuffer, options?: string | AppendObjectOptions): Promise<PutObjectResult>;
617
- /**
618
- * Delete an object from the disk via the S3-compatible DeleteObject API.
619
- * Idempotent: deleting a key that doesn't exist resolves successfully, per
620
- * S3 semantics.
621
- *
622
- * @param key Path on the disk (e.g. "project/dist/server.cjs")
623
- */
624
- deleteObject(key: string): Promise<void>;
625
- /**
626
- * List objects on the disk via the S3-compatible ListObjectsV2 API. By
627
- * default this follows continuation tokens until the listing is exhausted and
628
- * returns every matching key. Use `limit` to cap the total, `singlePage` for a
629
- * single request, or {@link listObjectsPages} to stream pages without loading
630
- * everything into memory.
631
- *
632
- * @param prefix Only return keys beginning with this prefix (omit for all).
633
- * @param opts Listing and pagination options.
634
- */
635
- listObjects(prefix?: string, opts?: ListObjectsOptions): Promise<ListObjectsResult>;
636
- /**
637
- * Yield ListObjectsV2 pages lazily, following continuation tokens. A
638
- * memory-friendly way to process a large listing without materializing it:
639
- *
640
- * ```ts
641
- * for await (const page of disk.listObjectsPages("logs/")) {
642
- * for (const obj of page.objects) process(obj);
643
- * }
644
- * ```
645
- *
646
- * @param prefix Only return keys beginning with this prefix (omit for all).
647
- * @param opts Listing options (`limit` / `singlePage` are ignored here —
648
- * control your own loop).
649
- */
650
- listObjectsPages(prefix?: string, opts?: ListObjectsOptions): AsyncGenerator<ListObjectsResult>;
651
- /** Fetch a single ListObjectsV2 page. @internal */
652
- private _listObjectsPage;
653
- /**
654
- * Delete up to many objects in a single S3-compatible DeleteObjects request.
655
- * Unlike {@link deleteObject}, failures are reported per key rather than
656
- * thrown: the result's `deleted` lists the keys that were removed and
657
- * `errors` lists the ones that weren't (with the server's code/message). A
658
- * key that didn't exist still counts as deleted, per S3 semantics.
659
- *
660
- * The server caps a single request at 1000 keys; this method transparently
661
- * splits larger inputs into 1000-key batches and merges the results.
662
- *
663
- * @param keys Object keys to delete.
664
- * @param opts `quiet` suppresses the per-key success list server-side.
665
- */
666
- deleteObjects(keys: string[], opts?: DeleteObjectsOptions): Promise<DeleteObjectsResult>;
667
- /**
668
- * The advanced, opt-in multipart-upload API. Drive the raw lifecycle
669
- * yourself — `create` → `uploadPart` → `complete` (or `abort`), plus
670
- * `listParts` / `listUploads`. Most callers don't need this: {@link putObject}
671
- * runs the whole lifecycle automatically for large bodies. Reach for it only
672
- * when you need manual control (e.g. uploading parts from separate processes),
673
- * and note you then own part-size, memory, and concurrency management.
674
- */
675
- get multipart(): DiskMultipart;
676
- /**
677
- * Send a single request to the disk's S3-compatible endpoint. This reuses the
678
- * control-plane client purely for its credential and transport — the same
679
- * `Authorization` header is sent and verified by the same code server-side —
680
- * pointed at the S3 host. Returns the response status and fully-buffered body
681
- * so callers can inspect both regardless of the verb used.
682
- *
683
- * The S3 routes (`/{diskId}/{key}` for objects, `/{diskId}` for the bucket)
684
- * are not part of the typed control-plane API, so the path and per-request
685
- * options are passed untyped. An empty `key` targets the bucket itself (used
686
- * by listObjects).
687
- *
688
- * @internal
689
- */
690
- private _s3Request;
691
- /**
692
- * Connect to this disk's data plane via the native ArchilClient.
693
- *
694
- * Requires the native module to be available (platform-specific .node binary).
695
- */
696
- mount(opts?: MountOptions): Promise<unknown>;
697
- }
698
- /**
699
- * The advanced, opt-in multipart-upload namespace, reached via {@link Disk.multipart}.
700
- * Drives the raw S3 multipart lifecycle — `create` → `uploadPart` → `complete`
701
- * (or `abort`), plus `listParts` / `listUploads`. Prefer {@link Disk.putObject},
702
- * which runs this lifecycle automatically for large bodies; use this only when
703
- * you need manual control, in which case you own part-size, memory, and
704
- * concurrency management.
705
- */
706
- declare class DiskMultipart {
707
- private readonly diskId;
708
- private readonly s3Request;
709
- /** @internal */
710
- constructor(diskId: string, s3Request: S3RequestFn);
711
- /**
712
- * Start a multipart upload (CreateMultipartUpload) and return its `uploadId`.
713
- *
714
- * @param key Path on the disk the finished object will live at.
715
- * @param contentType MIME type to store the object with.
716
- * @param attrs Optional POSIX `mode` / `uid` / `gid` for the completed
717
- * object (see {@link PosixCreateAttrs}).
718
- */
719
- create(key: string, contentType?: string, attrs?: PosixCreateAttrs): Promise<MultipartUpload>;
720
- /**
721
- * Upload one part (UploadPart) and return its entity tag, which you must
722
- * collect (with its part number) and pass to {@link complete}. Every part
723
- * except the last must be at least 5 MiB.
724
- *
725
- * @param key The upload's object key.
726
- * @param uploadId The id from {@link create}.
727
- * @param partNumber 1-based part number (1..=10000).
728
- * @param body Part contents as a string, Uint8Array/Buffer, or ArrayBuffer.
729
- */
730
- uploadPart(key: string, uploadId: string, partNumber: number, body: string | Uint8Array | ArrayBuffer): Promise<UploadPart>;
731
- /**
732
- * Finish a multipart upload (CompleteMultipartUpload), assembling the listed
733
- * parts into one object. Parts are sorted by part number before submission
734
- * (the server requires strictly-increasing order).
735
- *
736
- * Unlike the other operations this is NOT auto-retried on a transient error:
737
- * the gateway isn't idempotent for completion, so a retry after a
738
- * successful-but-unacknowledged complete would return a spurious NoSuchUpload.
739
- * On a transient failure, re-drive completion yourself only after confirming
740
- * the object isn't already present.
741
- *
742
- * @param key The upload's object key.
743
- * @param uploadId The id from {@link create}.
744
- * @param parts The `{ partNumber, etag }` pairs from {@link uploadPart}.
745
- */
746
- complete(key: string, uploadId: string, parts: UploadPart[]): Promise<CompletedMultipartUpload>;
747
- /**
748
- * Abort a multipart upload (AbortMultipartUpload), discarding every staged
749
- * part. Idempotent against an upload that's already gone (404 / NoSuchUpload
750
- * resolves successfully).
751
- *
752
- * @param key The upload's object key.
753
- * @param uploadId The id from {@link create}.
754
- */
755
- abort(key: string, uploadId: string): Promise<void>;
756
- /**
757
- * List the parts already uploaded for an in-progress upload (ListParts).
758
- * Returns a single page; follow `nextPartNumberMarker` (when `isTruncated`)
759
- * to page through the rest.
760
- *
761
- * @param key The upload's object key.
762
- * @param uploadId The id from {@link create}.
763
- * @param opts `maxParts` / `partNumberMarker` pagination controls.
764
- */
765
- listParts(key: string, uploadId: string, opts?: ListPartsOptions): Promise<PartListing>;
766
- /**
767
- * List in-progress multipart uploads on the disk (ListMultipartUploads).
768
- * Returns a single page; follow `nextKeyMarker` / `nextUploadIdMarker` (when
769
- * `isTruncated`) for the rest.
770
- *
771
- * @param opts Prefix/delimiter filter and pagination markers.
772
- */
773
- listUploads(opts?: ListMultipartUploadsOptions): Promise<MultipartUploadListing>;
774
- }
775
- /**
776
- * Choose the part size for a `totalBytes` multipart upload. Returns
777
- * `requestedPartSize` unless splitting at that size would exceed the server's
778
- * 10,000-part cap, in which case it grows the part size (rounded up to a whole
779
- * MiB) so the body fits in ≤ 10,000 parts — mirroring boto3's chunk-size
780
- * adjustment. Parts only ever get larger, so they stay above the 5 MiB floor.
781
- */
782
- declare function effectiveUploadPartSize(totalBytes: number, requestedPartSize: number): number;
783
- //#endregion
784
- export { MountResponse as $, effectiveUploadPartSize as A, DiskMetrics as B, PosixCreateAttrs as C, ShareUrlOptions as D, S3Object as E, Branch as F, ExecRequest as G, DiskStatus as H, ConnectedClient as I, GrepGroupLine as J, GCSMount as K, CreateApiTokenRequest as L, AuthorizedUser as M, AwsStsUser as N, ShareUrlResult as O, AzureBlobMount as P, MountConfigResponse as Q, CreateDiskRequest as R, PartListing as S, PutObjectResult as T, DiskUser as U, DiskResponse as V, ExecDiskResult as W, GrepStoppedReason as X, GrepMatch as Y, MountConfig as Z, MultipartUpload as _, DeleteObjectsOptions as a, FileSystem as at, ObjectMetadata as b, DiskMultipart as c, GrepResult as d, R2Mount as et, ListMultipartUploadsOptions as f, MountOptions as g, ListPartsOptions as h, DeleteObjectsError as i, TokenUser as it, ApiTokenResponse as j, UploadPart as k, ExecResult as l, ListObjectsResult as m, CompletedMultipartUpload as n, S3CompatibleMount as nt, DeleteObjectsResult as o, ApiClient as ot, ListObjectsOptions as p, GrepGroup as q, CreateBranchOptions as r, S3Mount as rt, Disk as s, ArchilTlsOptions as st, AppendObjectOptions as t, RootAttrs as tt, GrepOptions as u, MultipartUploadListing as v, PutObjectOptions as w, PartInfo as x, MultipartUploadSummary as y, Delegation as z };