disk 1.8.0 → 1.10.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.
- package/README.md +32 -0
- package/dist/cli.mjs +27 -7
- package/dist/{disk-iq-QAbnz.d.cts → disk-DZkPOSQD.d.cts} +65 -2
- package/dist/{disk-iq-QAbnz.d.mts → disk-DZkPOSQD.d.mts} +65 -2
- package/dist/index.cjs +141 -8
- package/dist/index.d.cts +24 -5
- package/dist/index.d.mts +24 -5
- package/dist/index.mjs +1 -1
- package/dist/internal/tools.cjs +2 -2
- package/dist/internal/tools.d.cts +1 -1
- package/dist/internal/tools.d.mts +1 -1
- package/dist/internal/tools.mjs +2 -2
- package/dist/sandbox-cli.mjs +2 -46
- package/dist/{common-CCIBdgS1.mjs → sandbox-options-DV7SSadf.mjs} +46 -2
- package/dist/{src-c7xI3gpo.mjs → src-BND_QqPx.mjs} +141 -8
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -703,6 +703,38 @@ A delegation has no ID of its own — it is identified by the
|
|
|
703
703
|
connected to the disk. `path` is resolved best-effort by the server and may be
|
|
704
704
|
absent.
|
|
705
705
|
|
|
706
|
+
## Branches
|
|
707
|
+
|
|
708
|
+
A branch is an independent, writable fork of a disk that starts from a
|
|
709
|
+
committed checkpoint. Writes on a branch don't affect its source. Create a
|
|
710
|
+
checkpoint from a mounted disk with `archil checkpoints create <mountpoint> <name>`,
|
|
711
|
+
then branch from it:
|
|
712
|
+
|
|
713
|
+
```ts
|
|
714
|
+
const disk = await archil.disks.get("dsk-0123456789abcdef");
|
|
715
|
+
|
|
716
|
+
const branch = await disk.createBranch({ name: "experiment", fromCheckpoint: "nightly" });
|
|
717
|
+
// { branch_name, filesystem_id, from_checkpoint_name, created_at, ... }
|
|
718
|
+
|
|
719
|
+
// Branch from a checkpoint taken on another branch:
|
|
720
|
+
await disk.createBranch({ name: "experiment-2", fromCheckpoint: "cp1", fromBranch: "experiment" });
|
|
721
|
+
|
|
722
|
+
await disk.listBranches();
|
|
723
|
+
await disk.getBranch("experiment");
|
|
724
|
+
```
|
|
725
|
+
|
|
726
|
+
Branch names are 1-100 letters, digits, hyphens, or underscores, and are unique
|
|
727
|
+
across the disk. `createBranch` rejects with a 409 `ArchilApiError` when the
|
|
728
|
+
name is taken or the checkpoint isn't committed yet. The SDK's own retries are
|
|
729
|
+
safe: it sends the same idempotency key on every attempt. To retry a create
|
|
730
|
+
yourself, pass your own key and reuse it, so a retry of a create that already
|
|
731
|
+
succeeded returns that branch instead of a 409:
|
|
732
|
+
|
|
733
|
+
```ts
|
|
734
|
+
const idempotencyKey = crypto.randomUUID(); // store it alongside the job
|
|
735
|
+
await disk.createBranch({ name: "experiment", fromCheckpoint: "nightly", idempotencyKey });
|
|
736
|
+
```
|
|
737
|
+
|
|
706
738
|
A `Workspace` is a full filesystem in its own right — it has the same object API
|
|
707
739
|
a `Disk` does (`getObject` / `putObject` / `deleteObject` / `listObjects` /
|
|
708
740
|
`grep` / `exec`; both implement the `FileSystem` interface), so you can use it
|
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as deleteApiKey, k as ArchilApiError, l as listApiKeys, n as createApiKey, r as createDisk, s as getDisk, t as configure, u as listDisks } from "./src-
|
|
3
|
-
import { a as
|
|
2
|
+
import { a as deleteApiKey, k as ArchilApiError, l as listApiKeys, n as createApiKey, r as createDisk, s as getDisk, t as configure, u as listDisks } from "./src-BND_QqPx.mjs";
|
|
3
|
+
import { a as addGlobalOptions, c as resolveProgramCredentials, l as renderTable, o as addProfileCommands, s as isProfileCommand, t as optionalInteger } from "./sandbox-options-DV7SSadf.mjs";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import { Command } from "commander";
|
|
6
6
|
//#region bin/cli.ts
|
|
@@ -173,8 +173,14 @@ program.command("exec <id|name> <command...>").description("Run a command in a c
|
|
|
173
173
|
fail(err);
|
|
174
174
|
}
|
|
175
175
|
});
|
|
176
|
-
program.command("grep <pattern> <target>").description("Constant-time parallel server-side grep across a disk. <target> is <id|name>[/<path>] — the path after the first '/' is the directory to search (defaults to the disk root). Accepts a disk id or name.").option("--no-recursive", "Search only the given directory, not its subdirectories (recursive is the default)").option("--max-duration <seconds>", "Wall-clock deadline for the whole search"
|
|
176
|
+
program.command("grep <pattern> <target>").description("Constant-time parallel server-side grep across a disk. <target> is <id|name>[/<path>] — the path after the first '/' is the directory to search (defaults to the disk root). Accepts a disk id or name.").option("--no-recursive", "Search only the given directory, not its subdirectories (recursive is the default)").option("--max-duration <seconds>", "Wall-clock deadline for the whole search").option("--concurrency <n>", "Max parallel grep workers (clamped to fleet capacity)").option("--max-results <n>", "Stop once this many matches are collected").option("-i, --ignore-case", "Match case-insensitively").option("-U, --multiline", "Let matches span lines").option("-g, --glob <glob>", "Include files matching the glob, or exclude with a leading ! (repeatable)", (value, previous) => [...previous, value], []).option("-t, --type <type>", "Only search files of this type, e.g. py (repeatable)", (value, previous) => [...previous, value], []).option("-T, --type-not <type>", "Skip files of this type (repeatable)", (value, previous) => [...previous, value], []).option("-A, --after-context <n>", "Lines of context after each match (max 10)").option("-B, --before-context <n>", "Lines of context before each match (max 10)").option("-C, --context <n>", "Lines of context before and after each match (max 10)").option("-o, --output <format>", "Output format: text | json", "text").action(async (pattern, target, opts) => {
|
|
177
177
|
try {
|
|
178
|
+
const context = optionalInteger(opts.context, "Context", 0, 10);
|
|
179
|
+
const contextBefore = optionalInteger(opts.beforeContext, "Before context", 0, 10) ?? context;
|
|
180
|
+
const contextAfter = optionalInteger(opts.afterContext, "After context", 0, 10) ?? context;
|
|
181
|
+
const maxDurationSeconds = optionalInteger(opts.maxDuration, "Max duration", 1, 30);
|
|
182
|
+
const concurrency = optionalInteger(opts.concurrency, "Concurrency", 1, 100);
|
|
183
|
+
const maxResults = optionalInteger(opts.maxResults, "Max results", 1, 1e4);
|
|
178
184
|
const slash = target.indexOf("/");
|
|
179
185
|
const idOrName = slash === -1 ? target : target.slice(0, slash);
|
|
180
186
|
const directory = slash === -1 ? "" : target.slice(slash + 1);
|
|
@@ -182,13 +188,27 @@ program.command("grep <pattern> <target>").description("Constant-time parallel s
|
|
|
182
188
|
directory,
|
|
183
189
|
pattern,
|
|
184
190
|
recursive: opts.recursive !== false,
|
|
185
|
-
maxDurationSeconds
|
|
186
|
-
concurrency
|
|
187
|
-
maxResults
|
|
191
|
+
maxDurationSeconds,
|
|
192
|
+
concurrency,
|
|
193
|
+
maxResults,
|
|
194
|
+
ignoreCase: opts.ignoreCase,
|
|
195
|
+
multiline: opts.multiline,
|
|
196
|
+
globs: opts.glob,
|
|
197
|
+
types: opts.type,
|
|
198
|
+
typesNot: opts.typeNot,
|
|
199
|
+
contextBefore,
|
|
200
|
+
contextAfter
|
|
188
201
|
});
|
|
189
202
|
if (opts.output === "json") console.log(JSON.stringify(res, null, 2));
|
|
190
203
|
else {
|
|
191
|
-
|
|
204
|
+
if (res.groups) res.groups.forEach((g, i) => {
|
|
205
|
+
if (i > 0) console.log("--");
|
|
206
|
+
for (const l of g.lines) {
|
|
207
|
+
const sep = l.match ? ":" : "-";
|
|
208
|
+
console.log(`${g.file}${sep}${l.line}${sep}${l.text}`);
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
else for (const m of res.matches) m.text.split("\n").forEach((text, k) => console.log(`${m.file}:${m.line + k}:${text}`));
|
|
192
212
|
console.error(`${res.matches.length} match${res.matches.length === 1 ? "" : "es"} · ${res.filesScanned} files scanned · ${res.containersDispatched} containers · ${res.durationMs}ms · ${res.stoppedReason}`);
|
|
193
213
|
if (res.stoppedReason !== "completed") console.error(`warning: search did not complete (${res.stoppedReason}); results may be partial`);
|
|
194
214
|
}
|
|
@@ -61,6 +61,7 @@ type R2Mount = components["schemas"]["R2Mount"];
|
|
|
61
61
|
type S3CompatibleMount = components["schemas"]["S3CompatibleMount"];
|
|
62
62
|
type AzureBlobMount = components["schemas"]["AzureBlobMount"];
|
|
63
63
|
type Delegation = components["schemas"]["DelegationEntry"];
|
|
64
|
+
type Branch = components["schemas"]["BranchResponse"];
|
|
64
65
|
type DiskUser = components["schemas"]["DiskUser"];
|
|
65
66
|
type TokenUser = components["schemas"]["TokenUser"];
|
|
66
67
|
type AwsStsUser = components["schemas"]["AwsStsUser"];
|
|
@@ -70,6 +71,8 @@ type ExecDiskResult = components["schemas"]["ExecDiskResult"];
|
|
|
70
71
|
type ExecRequest = components["schemas"]["ExecRequest"];
|
|
71
72
|
type GrepDiskResult = components["schemas"]["GrepDiskResult"];
|
|
72
73
|
type GrepMatch = components["schemas"]["GrepMatch"];
|
|
74
|
+
type GrepGroup = components["schemas"]["GrepGroup"];
|
|
75
|
+
type GrepGroupLine = components["schemas"]["GrepGroupLine"];
|
|
73
76
|
type GrepStoppedReason = components["schemas"]["GrepStoppedReason"];
|
|
74
77
|
type DiskStatus = DiskResponse["status"];
|
|
75
78
|
//#endregion
|
|
@@ -80,6 +83,21 @@ interface MountOptions {
|
|
|
80
83
|
serverAddress?: string;
|
|
81
84
|
insecure?: boolean;
|
|
82
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
|
+
}
|
|
83
101
|
type ExecResult = ExecDiskResult;
|
|
84
102
|
type GrepResult = GrepDiskResult;
|
|
85
103
|
interface GrepOptions {
|
|
@@ -88,7 +106,10 @@ interface GrepOptions {
|
|
|
88
106
|
* string or "/" means the disk root.
|
|
89
107
|
*/
|
|
90
108
|
directory: string;
|
|
91
|
-
/**
|
|
109
|
+
/**
|
|
110
|
+
* Regular expression in ripgrep syntax. A newline separates alternative
|
|
111
|
+
* patterns, except with `multiline`, where it matches a line break.
|
|
112
|
+
*/
|
|
92
113
|
pattern: string;
|
|
93
114
|
/** Walk subdirectories breadth-first. Defaults to false. */
|
|
94
115
|
recursive?: boolean;
|
|
@@ -107,6 +128,36 @@ interface GrepOptions {
|
|
|
107
128
|
* lexicographically first N. Defaults to 1000.
|
|
108
129
|
*/
|
|
109
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;
|
|
110
161
|
}
|
|
111
162
|
interface ShareUrlOptions {
|
|
112
163
|
/**
|
|
@@ -438,6 +489,18 @@ declare class Disk implements FileSystem {
|
|
|
438
489
|
* ```
|
|
439
490
|
*/
|
|
440
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>;
|
|
441
504
|
getAllowedIPs(): Promise<string[]>;
|
|
442
505
|
setAllowedIPs(allowedIps: string[]): Promise<string[]>;
|
|
443
506
|
addAllowedIP(ip: string): Promise<string[]>;
|
|
@@ -718,4 +781,4 @@ declare class DiskMultipart {
|
|
|
718
781
|
*/
|
|
719
782
|
declare function effectiveUploadPartSize(totalBytes: number, requestedPartSize: number): number;
|
|
720
783
|
//#endregion
|
|
721
|
-
export {
|
|
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 };
|
|
@@ -61,6 +61,7 @@ type R2Mount = components["schemas"]["R2Mount"];
|
|
|
61
61
|
type S3CompatibleMount = components["schemas"]["S3CompatibleMount"];
|
|
62
62
|
type AzureBlobMount = components["schemas"]["AzureBlobMount"];
|
|
63
63
|
type Delegation = components["schemas"]["DelegationEntry"];
|
|
64
|
+
type Branch = components["schemas"]["BranchResponse"];
|
|
64
65
|
type DiskUser = components["schemas"]["DiskUser"];
|
|
65
66
|
type TokenUser = components["schemas"]["TokenUser"];
|
|
66
67
|
type AwsStsUser = components["schemas"]["AwsStsUser"];
|
|
@@ -70,6 +71,8 @@ type ExecDiskResult = components["schemas"]["ExecDiskResult"];
|
|
|
70
71
|
type ExecRequest = components["schemas"]["ExecRequest"];
|
|
71
72
|
type GrepDiskResult = components["schemas"]["GrepDiskResult"];
|
|
72
73
|
type GrepMatch = components["schemas"]["GrepMatch"];
|
|
74
|
+
type GrepGroup = components["schemas"]["GrepGroup"];
|
|
75
|
+
type GrepGroupLine = components["schemas"]["GrepGroupLine"];
|
|
73
76
|
type GrepStoppedReason = components["schemas"]["GrepStoppedReason"];
|
|
74
77
|
type DiskStatus = DiskResponse["status"];
|
|
75
78
|
//#endregion
|
|
@@ -80,6 +83,21 @@ interface MountOptions {
|
|
|
80
83
|
serverAddress?: string;
|
|
81
84
|
insecure?: boolean;
|
|
82
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
|
+
}
|
|
83
101
|
type ExecResult = ExecDiskResult;
|
|
84
102
|
type GrepResult = GrepDiskResult;
|
|
85
103
|
interface GrepOptions {
|
|
@@ -88,7 +106,10 @@ interface GrepOptions {
|
|
|
88
106
|
* string or "/" means the disk root.
|
|
89
107
|
*/
|
|
90
108
|
directory: string;
|
|
91
|
-
/**
|
|
109
|
+
/**
|
|
110
|
+
* Regular expression in ripgrep syntax. A newline separates alternative
|
|
111
|
+
* patterns, except with `multiline`, where it matches a line break.
|
|
112
|
+
*/
|
|
92
113
|
pattern: string;
|
|
93
114
|
/** Walk subdirectories breadth-first. Defaults to false. */
|
|
94
115
|
recursive?: boolean;
|
|
@@ -107,6 +128,36 @@ interface GrepOptions {
|
|
|
107
128
|
* lexicographically first N. Defaults to 1000.
|
|
108
129
|
*/
|
|
109
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;
|
|
110
161
|
}
|
|
111
162
|
interface ShareUrlOptions {
|
|
112
163
|
/**
|
|
@@ -438,6 +489,18 @@ declare class Disk implements FileSystem {
|
|
|
438
489
|
* ```
|
|
439
490
|
*/
|
|
440
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>;
|
|
441
504
|
getAllowedIPs(): Promise<string[]>;
|
|
442
505
|
setAllowedIPs(allowedIps: string[]): Promise<string[]>;
|
|
443
506
|
addAllowedIP(ip: string): Promise<string[]>;
|
|
@@ -718,4 +781,4 @@ declare class DiskMultipart {
|
|
|
718
781
|
*/
|
|
719
782
|
declare function effectiveUploadPartSize(totalBytes: number, requestedPartSize: number): number;
|
|
720
783
|
//#endregion
|
|
721
|
-
export {
|
|
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 };
|
package/dist/index.cjs
CHANGED
|
@@ -163,7 +163,7 @@ function deriveS3BaseUrl(controlBaseUrl) {
|
|
|
163
163
|
}
|
|
164
164
|
//#endregion
|
|
165
165
|
//#region src/version.ts
|
|
166
|
-
const VERSION = "1.
|
|
166
|
+
const VERSION = "1.10.0";
|
|
167
167
|
const USER_AGENT = `archil-js/${VERSION}`;
|
|
168
168
|
//#endregion
|
|
169
169
|
//#region src/client.ts
|
|
@@ -499,6 +499,38 @@ var Disk = class {
|
|
|
499
499
|
}
|
|
500
500
|
}), "connect"));
|
|
501
501
|
}
|
|
502
|
+
/**
|
|
503
|
+
* Create a branch: an independent, writable fork of this disk that starts
|
|
504
|
+
* from a committed checkpoint. Writes on the branch don't affect its source.
|
|
505
|
+
*
|
|
506
|
+
* Fails with a 409 if a branch with this name already exists or the
|
|
507
|
+
* checkpoint is not yet committed, and a 404 if the checkpoint or
|
|
508
|
+
* `fromBranch` doesn't exist.
|
|
509
|
+
*/
|
|
510
|
+
async createBranch(options) {
|
|
511
|
+
const idempotencyKey = options.idempotencyKey ?? globalThis.crypto.randomUUID();
|
|
512
|
+
return unwrap(retryApiRequest(() => this._client.POST("/api/disks/{id}/branches", {
|
|
513
|
+
params: {
|
|
514
|
+
path: { id: this.id },
|
|
515
|
+
header: { "Idempotency-Key": idempotencyKey }
|
|
516
|
+
},
|
|
517
|
+
body: {
|
|
518
|
+
branch_name: options.name,
|
|
519
|
+
from_checkpoint_name: options.fromCheckpoint,
|
|
520
|
+
from_branch: options.fromBranch
|
|
521
|
+
}
|
|
522
|
+
}), "transient"));
|
|
523
|
+
}
|
|
524
|
+
/** List every branch of this disk, including branches of branches, in no particular order. */
|
|
525
|
+
async listBranches() {
|
|
526
|
+
return unwrap(retryApiRequest(() => this._client.GET("/api/disks/{id}/branches", { params: { path: { id: this.id } } }), "transient"));
|
|
527
|
+
}
|
|
528
|
+
async getBranch(name) {
|
|
529
|
+
return unwrap(retryApiRequest(() => this._client.GET("/api/disks/{id}/branches/{name}", { params: { path: {
|
|
530
|
+
id: this.id,
|
|
531
|
+
name
|
|
532
|
+
} } }), "transient"));
|
|
533
|
+
}
|
|
502
534
|
async getAllowedIPs() {
|
|
503
535
|
return (await unwrap(retryApiRequest(() => this._client.GET("/api/disks/{id}/allowed-ips", { params: { path: { id: this.id } } }), "transient"))).allowedIps;
|
|
504
536
|
}
|
|
@@ -549,7 +581,14 @@ var Disk = class {
|
|
|
549
581
|
recursive: opts.recursive ?? false,
|
|
550
582
|
maxDurationSeconds: opts.maxDurationSeconds ?? 30,
|
|
551
583
|
concurrency: opts.concurrency ?? 50,
|
|
552
|
-
maxResults: opts.maxResults ?? 1e3
|
|
584
|
+
maxResults: opts.maxResults ?? 1e3,
|
|
585
|
+
ignoreCase: opts.ignoreCase,
|
|
586
|
+
multiline: opts.multiline,
|
|
587
|
+
globs: opts.globs,
|
|
588
|
+
types: opts.types,
|
|
589
|
+
typesNot: opts.typesNot,
|
|
590
|
+
contextBefore: opts.contextBefore ?? 0,
|
|
591
|
+
contextAfter: opts.contextAfter ?? 0
|
|
553
592
|
}
|
|
554
593
|
}), "transient"));
|
|
555
594
|
}
|
|
@@ -2336,6 +2375,30 @@ var Tokens = class {
|
|
|
2336
2375
|
function isExecMountSpec$1(m) {
|
|
2337
2376
|
return typeof m === "object" && m !== null && "disk" in m;
|
|
2338
2377
|
}
|
|
2378
|
+
/** Keep groups up to the one holding the `maxResults`-th match, and end that
|
|
2379
|
+
* group after up to `after` more lines, which become context so the groups
|
|
2380
|
+
* hold exactly the kept matches. With multiline, a run of matching lines is
|
|
2381
|
+
* one match. Mirrors the controlplane's truncation of a single disk's groups. */
|
|
2382
|
+
function truncateGroups(groups, maxResults, after, multiline) {
|
|
2383
|
+
let seen = 0;
|
|
2384
|
+
for (let i = 0; i < groups.length; i++) {
|
|
2385
|
+
const lines = groups[i].lines;
|
|
2386
|
+
for (let j = 0; j < lines.length; j++) {
|
|
2387
|
+
if (lines[j].match && !(multiline && j > 0 && lines[j - 1].match)) seen++;
|
|
2388
|
+
if (seen === maxResults && !(multiline && j + 1 < lines.length && lines[j + 1].match)) {
|
|
2389
|
+
const kept = lines.slice(0, Math.min(j + 1 + after, lines.length)).map((l, k) => k > j ? {
|
|
2390
|
+
...l,
|
|
2391
|
+
match: false
|
|
2392
|
+
} : l);
|
|
2393
|
+
return [...groups.slice(0, i), {
|
|
2394
|
+
...groups[i],
|
|
2395
|
+
lines: kept
|
|
2396
|
+
}];
|
|
2397
|
+
}
|
|
2398
|
+
}
|
|
2399
|
+
}
|
|
2400
|
+
return groups;
|
|
2401
|
+
}
|
|
2339
2402
|
/**
|
|
2340
2403
|
* A key-routed filesystem spanning several Archil disks. Each disk is mounted
|
|
2341
2404
|
* under a name and addressed as the first segment of a key (`<name>/...`);
|
|
@@ -2432,6 +2495,46 @@ var Workspace = class {
|
|
|
2432
2495
|
rel: this.diskKey(entry, segs.slice(1).join("/"))
|
|
2433
2496
|
}];
|
|
2434
2497
|
}
|
|
2498
|
+
/** Route grep globs written against the workspace root to the mounts they
|
|
2499
|
+
* can match. A glob that starts with a mount's name goes to that mount without
|
|
2500
|
+
* the name. One with no `/`, or that starts with `**` + `/` with or without a
|
|
2501
|
+
* leading `/`, goes to every mount as written, and also applies to a mount it
|
|
2502
|
+
* names exactly, like `!cache` or `**` + `/logs/**`. Mount names are matched
|
|
2503
|
+
* literally, so `!l*` doesn't skip a `logs` mount. Leaves out a mount whose
|
|
2504
|
+
* directory an exclude names, or that no include reaches, and throws for any
|
|
2505
|
+
* other glob with a `/`. */
|
|
2506
|
+
rootGlobs(globs) {
|
|
2507
|
+
const routed = new Map([...this.mounts.keys()].map((name) => [name, []]));
|
|
2508
|
+
const excluded = /* @__PURE__ */ new Set();
|
|
2509
|
+
for (const glob of globs) {
|
|
2510
|
+
const exclude = glob.startsWith("!");
|
|
2511
|
+
let body = exclude ? glob.slice(1) : glob;
|
|
2512
|
+
const dirOnly = body.endsWith("/");
|
|
2513
|
+
if (dirOnly) body = body.slice(0, -1);
|
|
2514
|
+
const anchored = body.startsWith("/");
|
|
2515
|
+
if (anchored) body = body.slice(1);
|
|
2516
|
+
const everywhere = !anchored && !body.includes("/") || body === "**" || body.startsWith("**/");
|
|
2517
|
+
if (everywhere) for (const mountGlobs of routed.values()) mountGlobs.push(glob);
|
|
2518
|
+
const path = everywhere && body.startsWith("**/") ? body.slice(3) : body;
|
|
2519
|
+
const slash = path.indexOf("/");
|
|
2520
|
+
const name = slash < 0 ? path : path.slice(0, slash);
|
|
2521
|
+
const rest = slash < 0 ? "" : path.slice(slash + 1);
|
|
2522
|
+
const mountGlobs = routed.get(name);
|
|
2523
|
+
if (!mountGlobs) {
|
|
2524
|
+
if (everywhere) continue;
|
|
2525
|
+
throw new Error(`At the workspace root, a glob with a '/' must start with a mount name (${this.diskNames().map((n) => `${n}/`).join(", ")}) or '**/'; got '${glob}'. To search below one mount, set directory to it.`);
|
|
2526
|
+
}
|
|
2527
|
+
if (rest === "") {
|
|
2528
|
+
if (exclude) excluded.add(name);
|
|
2529
|
+
else excluded.delete(name);
|
|
2530
|
+
continue;
|
|
2531
|
+
}
|
|
2532
|
+
mountGlobs.push(`${exclude ? "!" : ""}${rest.includes("/") ? rest : `/${rest}`}${dirOnly ? "/" : ""}`);
|
|
2533
|
+
}
|
|
2534
|
+
const hasInclude = globs.some((glob) => !glob.startsWith("!"));
|
|
2535
|
+
for (const [name, mountGlobs] of routed) if (excluded.has(name) || hasInclude && mountGlobs.every((glob) => glob.startsWith("!"))) routed.delete(name);
|
|
2536
|
+
return routed;
|
|
2537
|
+
}
|
|
2435
2538
|
/** Map a workspace-relative key to the disk's key, applying the mount's subdirectory. */
|
|
2436
2539
|
diskKey(entry, rel) {
|
|
2437
2540
|
const trimmed = rel.replace(/^\/+/, "");
|
|
@@ -2502,13 +2605,38 @@ var Workspace = class {
|
|
|
2502
2605
|
keyCount
|
|
2503
2606
|
};
|
|
2504
2607
|
}
|
|
2608
|
+
/**
|
|
2609
|
+
* Grep the disks `directory` covers in parallel and merge their results. At
|
|
2610
|
+
* the workspace root, a glob with a `/` must start with a mount name, like
|
|
2611
|
+
* `data/src/**`, which applies to that mount only, or with `**` + `/`. A glob
|
|
2612
|
+
* with no `/`, like `*.ts`, or one starting with `**` + `/` with or without a
|
|
2613
|
+
* leading `/`, applies inside every mount, and also to a mount it names
|
|
2614
|
+
* exactly, so `!cache` skips the cache mount. Mount names are matched
|
|
2615
|
+
* literally, not as patterns: `!l*` applies inside every mount, but doesn't
|
|
2616
|
+
* skip a mount named `logs`.
|
|
2617
|
+
*/
|
|
2505
2618
|
async grep(opts) {
|
|
2506
|
-
const
|
|
2507
|
-
const
|
|
2619
|
+
const directory = opts.directory ?? "";
|
|
2620
|
+
const rootGlobs = require_paths.toSegments(directory).length === 0 && opts.globs?.length ? this.rootGlobs(opts.globs) : void 0;
|
|
2621
|
+
const covered = this.covered(directory).flatMap((c) => {
|
|
2622
|
+
if (rootGlobs === void 0) return [{
|
|
2623
|
+
...c,
|
|
2624
|
+
globs: opts.globs
|
|
2625
|
+
}];
|
|
2626
|
+
const globs = rootGlobs.get(c.name);
|
|
2627
|
+
return globs === void 0 ? [] : [{
|
|
2628
|
+
...c,
|
|
2629
|
+
globs
|
|
2630
|
+
}];
|
|
2631
|
+
});
|
|
2632
|
+
const results = await Promise.allSettled(covered.map(({ entry, rel, globs }) => entry.disk.grep({
|
|
2508
2633
|
...opts,
|
|
2509
|
-
directory: rel
|
|
2634
|
+
directory: rel,
|
|
2635
|
+
globs
|
|
2510
2636
|
})));
|
|
2637
|
+
for (const settled of results) if (settled.status === "rejected" && settled.reason instanceof ArchilApiError && settled.reason.status === 400) throw settled.reason;
|
|
2511
2638
|
const matches = [];
|
|
2639
|
+
const groups = [];
|
|
2512
2640
|
let filesScanned = 0;
|
|
2513
2641
|
let containersDispatched = 0;
|
|
2514
2642
|
let computeSecondsUsed = 0;
|
|
@@ -2531,9 +2659,12 @@ var Workspace = class {
|
|
|
2531
2659
|
grepMs = Math.max(grepMs, r.grepMs ?? 0);
|
|
2532
2660
|
reasons.add(r.stoppedReason);
|
|
2533
2661
|
for (const m of r.matches) matches.push({
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2662
|
+
...m,
|
|
2663
|
+
file: this.abs(name, entry, m.file)
|
|
2664
|
+
});
|
|
2665
|
+
for (const g of r.groups ?? []) groups.push({
|
|
2666
|
+
...g,
|
|
2667
|
+
file: this.abs(name, entry, g.file)
|
|
2537
2668
|
});
|
|
2538
2669
|
});
|
|
2539
2670
|
const cap = opts.maxResults ?? 1e3;
|
|
@@ -2545,8 +2676,10 @@ var Workspace = class {
|
|
|
2545
2676
|
"max_results"
|
|
2546
2677
|
];
|
|
2547
2678
|
const stoppedReason = [...reasons].every((x) => x === "completed") ? "completed" : priority.find((x) => reasons.has(x)) ?? "completed";
|
|
2679
|
+
const withGroups = (opts.contextBefore ?? 0) > 0 || (opts.contextAfter ?? 0) > 0;
|
|
2548
2680
|
return {
|
|
2549
2681
|
matches: matches.slice(0, cap),
|
|
2682
|
+
...withGroups && { groups: matches.length > cap ? truncateGroups(groups, cap, opts.contextAfter ?? 0, opts.multiline ?? false) : groups },
|
|
2550
2683
|
stoppedReason,
|
|
2551
2684
|
filesScanned,
|
|
2552
2685
|
containersDispatched,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as MountResponse, A as effectiveUploadPartSize, B as DiskMetrics, C as PosixCreateAttrs, D as ShareUrlOptions, E as S3Object, F as Branch, G as ExecRequest, H as DiskStatus, I as ConnectedClient, J as GrepGroupLine, K as GCSMount, L as CreateApiTokenRequest, M as AuthorizedUser, N as AwsStsUser, O as ShareUrlResult, P as AzureBlobMount, Q as MountConfigResponse, R as CreateDiskRequest, S as PartListing, T as PutObjectResult, U as DiskUser, V as DiskResponse, W as ExecDiskResult, X as GrepStoppedReason, Y as GrepMatch, Z as MountConfig, _ as MultipartUpload, a as DeleteObjectsOptions, at as FileSystem, b as ObjectMetadata, c as DiskMultipart, d as GrepResult, et as R2Mount, f as ListMultipartUploadsOptions, g as MountOptions, h as ListPartsOptions, i as DeleteObjectsError, it as TokenUser, j as ApiTokenResponse, k as UploadPart, l as ExecResult, m as ListObjectsResult, n as CompletedMultipartUpload, nt as S3CompatibleMount, o as DeleteObjectsResult, ot as ApiClient, p as ListObjectsOptions, q as GrepGroup, r as CreateBranchOptions, rt as S3Mount, s as Disk, st as ArchilTlsOptions, t as AppendObjectOptions, tt as RootAttrs, u as GrepOptions, v as MultipartUploadListing, w as PutObjectOptions, x as PartInfo, y as MultipartUploadSummary, z as Delegation } from "./disk-DZkPOSQD.cjs";
|
|
2
2
|
import { components } from "@archildata/api-types";
|
|
3
3
|
|
|
4
4
|
//#region src/disks.d.ts
|
|
@@ -560,6 +560,15 @@ declare class Workspace implements FileSystem {
|
|
|
560
560
|
private route;
|
|
561
561
|
/** Mounts touched by a key prefix; an empty prefix fans out to all of them. */
|
|
562
562
|
private covered;
|
|
563
|
+
/** Route grep globs written against the workspace root to the mounts they
|
|
564
|
+
* can match. A glob that starts with a mount's name goes to that mount without
|
|
565
|
+
* the name. One with no `/`, or that starts with `**` + `/` with or without a
|
|
566
|
+
* leading `/`, goes to every mount as written, and also applies to a mount it
|
|
567
|
+
* names exactly, like `!cache` or `**` + `/logs/**`. Mount names are matched
|
|
568
|
+
* literally, so `!l*` doesn't skip a `logs` mount. Leaves out a mount whose
|
|
569
|
+
* directory an exclude names, or that no include reaches, and throws for any
|
|
570
|
+
* other glob with a `/`. */
|
|
571
|
+
private rootGlobs;
|
|
563
572
|
/** Map a workspace-relative key to the disk's key, applying the mount's subdirectory. */
|
|
564
573
|
private diskKey;
|
|
565
574
|
/** Map a disk key back to its workspace key (`<name>/...`), stripping the mount subdirectory. */
|
|
@@ -568,6 +577,16 @@ declare class Workspace implements FileSystem {
|
|
|
568
577
|
putObject(key: string, body: string | Uint8Array | ArrayBuffer, options?: string | PutObjectOptions): Promise<PutObjectResult>;
|
|
569
578
|
deleteObject(key: string): Promise<void>;
|
|
570
579
|
listObjects(prefix?: string, opts?: ListObjectsOptions): Promise<ListObjectsResult>;
|
|
580
|
+
/**
|
|
581
|
+
* Grep the disks `directory` covers in parallel and merge their results. At
|
|
582
|
+
* the workspace root, a glob with a `/` must start with a mount name, like
|
|
583
|
+
* `data/src/**`, which applies to that mount only, or with `**` + `/`. A glob
|
|
584
|
+
* with no `/`, like `*.ts`, or one starting with `**` + `/` with or without a
|
|
585
|
+
* leading `/`, applies inside every mount, and also to a mount it names
|
|
586
|
+
* exactly, so `!cache` skips the cache mount. Mount names are matched
|
|
587
|
+
* literally, not as patterns: `!l*` applies inside every mount, but doesn't
|
|
588
|
+
* skip a mount named `logs`.
|
|
589
|
+
*/
|
|
571
590
|
grep(opts: GrepOptions): Promise<GrepResult>;
|
|
572
591
|
exec(command: string): Promise<ExecResult>;
|
|
573
592
|
}
|
|
@@ -611,9 +630,9 @@ interface ExecMountSpec {
|
|
|
611
630
|
*/
|
|
612
631
|
readOnly?: boolean;
|
|
613
632
|
/**
|
|
614
|
-
* When true, mount the disk in conditional mode,
|
|
615
|
-
*
|
|
616
|
-
*
|
|
633
|
+
* When true, mount the disk in conditional mode, which lets this mount
|
|
634
|
+
* write without a delegation checkout. This enables concurrent writes from
|
|
635
|
+
* multiple clients to the same disk.
|
|
617
636
|
* Defaults to false.
|
|
618
637
|
*/
|
|
619
638
|
conditional?: boolean;
|
|
@@ -756,4 +775,4 @@ declare function exec(opts: ExecOptions): Promise<ExecDiskResult>;
|
|
|
756
775
|
*/
|
|
757
776
|
declare function workspace(mounts: Record<string, ExecMount>): Workspace;
|
|
758
777
|
//#endregion
|
|
759
|
-
export { type ApiTokenResponse, type AppendObjectOptions, Archil, ArchilApiError, ArchilError, type ArchilOptions, ArchilS3Error, type ArchilTlsOptions, type AuthorizedUser, type AwsStsUser, type AzureBlobMount, type BuildImageOptions, type BuildImageRequest, type CompletedMultipartUpload, type ConnectedClient, type CreateApiTokenRequest, type CreateDiskRequest, type CreateDiskResult, type CreateSandboxPortTokenOptions, type CreateSandboxRequest, type CreatedSandboxPortToken, type Delegation, type DeleteObjectsError, type DeleteObjectsOptions, type DeleteObjectsResult, Disk, type DiskListPage, type DiskMetrics, DiskMultipart, type DiskResponse, type DiskStatus, type DiskUser, Disks, type ExecMount, type ExecMountSpec, type ExecOptions, type ExecRequest, type ExecResult, type FileSystem, type GCSMount, type GrepMatch, type GrepOptions, type GrepResult, type GrepStoppedReason, type Image, ImageBuildError, type ImageFailureReason, type ImageStatus, Images, type ListDisksOptions, type ListMultipartUploadsOptions, type ListObjectsOptions, type ListObjectsResult, type ListPartsOptions, type ListSandboxPortTokensOptions, type ListSandboxesOptions, type ListTokensOptions, type MountConfig, type MountConfigResponse, type MountOptions, type MountResponse, type MultipartUpload, type MultipartUploadListing, type MultipartUploadSummary, type ObjectMetadata, type PartInfo, type PartListing, type PosixCreateAttrs, type PutObjectOptions, type PutObjectResult, type R2Mount, type RegistryAuth, type RootAttrs, type S3CompatibleMount, type S3Mount, type S3Object, Sandbox, type SandboxEgressPolicy, type SandboxEgressRule, type SandboxEgressTransform, type SandboxEndpoint, type SandboxFileSource, SandboxFileTransferError, type SandboxFileUploadOptions, type SandboxFileWriter, SandboxFiles, type SandboxForkOptions, type SandboxMount, type SandboxMountSpec, type SandboxNetwork, type SandboxNetworkAction, SandboxPauseError, type SandboxPortToken, type SandboxPortTokenPage, SandboxProcess, type SandboxProcessConnectOptions, type SandboxProcessOutput, type SandboxProcessOutputHandler, type SandboxProcessResult, type SandboxProcessStartOptions, type SandboxProcessStatus, type SandboxProcessStream, SandboxProcesses, type SandboxResponse, type SandboxStartOptions, type SandboxStatus, type SandboxTerminalOptions, type SandboxTimeoutOptions, type SandboxWaitOptions, Sandboxes, type ShareUrlOptions, type ShareUrlResult, type TokenUser, Tokens, USER_AGENT, type UploadPart, VERSION, Workspace, configure, createApiKey, createDisk, createSandbox, deleteApiKey, effectiveUploadPartSize, exec, getDisk, getSandbox, listApiKeys, listDisks, listSandboxes, workspace };
|
|
778
|
+
export { type ApiTokenResponse, type AppendObjectOptions, Archil, ArchilApiError, ArchilError, type ArchilOptions, ArchilS3Error, type ArchilTlsOptions, type AuthorizedUser, type AwsStsUser, type AzureBlobMount, type Branch, type BuildImageOptions, type BuildImageRequest, type CompletedMultipartUpload, type ConnectedClient, type CreateApiTokenRequest, type CreateBranchOptions, type CreateDiskRequest, type CreateDiskResult, type CreateSandboxPortTokenOptions, type CreateSandboxRequest, type CreatedSandboxPortToken, type Delegation, type DeleteObjectsError, type DeleteObjectsOptions, type DeleteObjectsResult, Disk, type DiskListPage, type DiskMetrics, DiskMultipart, type DiskResponse, type DiskStatus, type DiskUser, Disks, type ExecMount, type ExecMountSpec, type ExecOptions, type ExecRequest, type ExecResult, type FileSystem, type GCSMount, type GrepGroup, type GrepGroupLine, type GrepMatch, type GrepOptions, type GrepResult, type GrepStoppedReason, type Image, ImageBuildError, type ImageFailureReason, type ImageStatus, Images, type ListDisksOptions, type ListMultipartUploadsOptions, type ListObjectsOptions, type ListObjectsResult, type ListPartsOptions, type ListSandboxPortTokensOptions, type ListSandboxesOptions, type ListTokensOptions, type MountConfig, type MountConfigResponse, type MountOptions, type MountResponse, type MultipartUpload, type MultipartUploadListing, type MultipartUploadSummary, type ObjectMetadata, type PartInfo, type PartListing, type PosixCreateAttrs, type PutObjectOptions, type PutObjectResult, type R2Mount, type RegistryAuth, type RootAttrs, type S3CompatibleMount, type S3Mount, type S3Object, Sandbox, type SandboxEgressPolicy, type SandboxEgressRule, type SandboxEgressTransform, type SandboxEndpoint, type SandboxFileSource, SandboxFileTransferError, type SandboxFileUploadOptions, type SandboxFileWriter, SandboxFiles, type SandboxForkOptions, type SandboxMount, type SandboxMountSpec, type SandboxNetwork, type SandboxNetworkAction, SandboxPauseError, type SandboxPortToken, type SandboxPortTokenPage, SandboxProcess, type SandboxProcessConnectOptions, type SandboxProcessOutput, type SandboxProcessOutputHandler, type SandboxProcessResult, type SandboxProcessStartOptions, type SandboxProcessStatus, type SandboxProcessStream, SandboxProcesses, type SandboxResponse, type SandboxStartOptions, type SandboxStatus, type SandboxTerminalOptions, type SandboxTimeoutOptions, type SandboxWaitOptions, Sandboxes, type ShareUrlOptions, type ShareUrlResult, type TokenUser, Tokens, USER_AGENT, type UploadPart, VERSION, Workspace, configure, createApiKey, createDisk, createSandbox, deleteApiKey, effectiveUploadPartSize, exec, getDisk, getSandbox, listApiKeys, listDisks, listSandboxes, workspace };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as MountResponse, A as effectiveUploadPartSize, B as DiskMetrics, C as PosixCreateAttrs, D as ShareUrlOptions, E as S3Object, F as Branch, G as ExecRequest, H as DiskStatus, I as ConnectedClient, J as GrepGroupLine, K as GCSMount, L as CreateApiTokenRequest, M as AuthorizedUser, N as AwsStsUser, O as ShareUrlResult, P as AzureBlobMount, Q as MountConfigResponse, R as CreateDiskRequest, S as PartListing, T as PutObjectResult, U as DiskUser, V as DiskResponse, W as ExecDiskResult, X as GrepStoppedReason, Y as GrepMatch, Z as MountConfig, _ as MultipartUpload, a as DeleteObjectsOptions, at as FileSystem, b as ObjectMetadata, c as DiskMultipart, d as GrepResult, et as R2Mount, f as ListMultipartUploadsOptions, g as MountOptions, h as ListPartsOptions, i as DeleteObjectsError, it as TokenUser, j as ApiTokenResponse, k as UploadPart, l as ExecResult, m as ListObjectsResult, n as CompletedMultipartUpload, nt as S3CompatibleMount, o as DeleteObjectsResult, ot as ApiClient, p as ListObjectsOptions, q as GrepGroup, r as CreateBranchOptions, rt as S3Mount, s as Disk, st as ArchilTlsOptions, t as AppendObjectOptions, tt as RootAttrs, u as GrepOptions, v as MultipartUploadListing, w as PutObjectOptions, x as PartInfo, y as MultipartUploadSummary, z as Delegation } from "./disk-DZkPOSQD.mjs";
|
|
2
2
|
import { components } from "@archildata/api-types";
|
|
3
3
|
|
|
4
4
|
//#region src/disks.d.ts
|
|
@@ -560,6 +560,15 @@ declare class Workspace implements FileSystem {
|
|
|
560
560
|
private route;
|
|
561
561
|
/** Mounts touched by a key prefix; an empty prefix fans out to all of them. */
|
|
562
562
|
private covered;
|
|
563
|
+
/** Route grep globs written against the workspace root to the mounts they
|
|
564
|
+
* can match. A glob that starts with a mount's name goes to that mount without
|
|
565
|
+
* the name. One with no `/`, or that starts with `**` + `/` with or without a
|
|
566
|
+
* leading `/`, goes to every mount as written, and also applies to a mount it
|
|
567
|
+
* names exactly, like `!cache` or `**` + `/logs/**`. Mount names are matched
|
|
568
|
+
* literally, so `!l*` doesn't skip a `logs` mount. Leaves out a mount whose
|
|
569
|
+
* directory an exclude names, or that no include reaches, and throws for any
|
|
570
|
+
* other glob with a `/`. */
|
|
571
|
+
private rootGlobs;
|
|
563
572
|
/** Map a workspace-relative key to the disk's key, applying the mount's subdirectory. */
|
|
564
573
|
private diskKey;
|
|
565
574
|
/** Map a disk key back to its workspace key (`<name>/...`), stripping the mount subdirectory. */
|
|
@@ -568,6 +577,16 @@ declare class Workspace implements FileSystem {
|
|
|
568
577
|
putObject(key: string, body: string | Uint8Array | ArrayBuffer, options?: string | PutObjectOptions): Promise<PutObjectResult>;
|
|
569
578
|
deleteObject(key: string): Promise<void>;
|
|
570
579
|
listObjects(prefix?: string, opts?: ListObjectsOptions): Promise<ListObjectsResult>;
|
|
580
|
+
/**
|
|
581
|
+
* Grep the disks `directory` covers in parallel and merge their results. At
|
|
582
|
+
* the workspace root, a glob with a `/` must start with a mount name, like
|
|
583
|
+
* `data/src/**`, which applies to that mount only, or with `**` + `/`. A glob
|
|
584
|
+
* with no `/`, like `*.ts`, or one starting with `**` + `/` with or without a
|
|
585
|
+
* leading `/`, applies inside every mount, and also to a mount it names
|
|
586
|
+
* exactly, so `!cache` skips the cache mount. Mount names are matched
|
|
587
|
+
* literally, not as patterns: `!l*` applies inside every mount, but doesn't
|
|
588
|
+
* skip a mount named `logs`.
|
|
589
|
+
*/
|
|
571
590
|
grep(opts: GrepOptions): Promise<GrepResult>;
|
|
572
591
|
exec(command: string): Promise<ExecResult>;
|
|
573
592
|
}
|
|
@@ -611,9 +630,9 @@ interface ExecMountSpec {
|
|
|
611
630
|
*/
|
|
612
631
|
readOnly?: boolean;
|
|
613
632
|
/**
|
|
614
|
-
* When true, mount the disk in conditional mode,
|
|
615
|
-
*
|
|
616
|
-
*
|
|
633
|
+
* When true, mount the disk in conditional mode, which lets this mount
|
|
634
|
+
* write without a delegation checkout. This enables concurrent writes from
|
|
635
|
+
* multiple clients to the same disk.
|
|
617
636
|
* Defaults to false.
|
|
618
637
|
*/
|
|
619
638
|
conditional?: boolean;
|
|
@@ -756,4 +775,4 @@ declare function exec(opts: ExecOptions): Promise<ExecDiskResult>;
|
|
|
756
775
|
*/
|
|
757
776
|
declare function workspace(mounts: Record<string, ExecMount>): Workspace;
|
|
758
777
|
//#endregion
|
|
759
|
-
export { type ApiTokenResponse, type AppendObjectOptions, Archil, ArchilApiError, ArchilError, type ArchilOptions, ArchilS3Error, type ArchilTlsOptions, type AuthorizedUser, type AwsStsUser, type AzureBlobMount, type BuildImageOptions, type BuildImageRequest, type CompletedMultipartUpload, type ConnectedClient, type CreateApiTokenRequest, type CreateDiskRequest, type CreateDiskResult, type CreateSandboxPortTokenOptions, type CreateSandboxRequest, type CreatedSandboxPortToken, type Delegation, type DeleteObjectsError, type DeleteObjectsOptions, type DeleteObjectsResult, Disk, type DiskListPage, type DiskMetrics, DiskMultipart, type DiskResponse, type DiskStatus, type DiskUser, Disks, type ExecMount, type ExecMountSpec, type ExecOptions, type ExecRequest, type ExecResult, type FileSystem, type GCSMount, type GrepMatch, type GrepOptions, type GrepResult, type GrepStoppedReason, type Image, ImageBuildError, type ImageFailureReason, type ImageStatus, Images, type ListDisksOptions, type ListMultipartUploadsOptions, type ListObjectsOptions, type ListObjectsResult, type ListPartsOptions, type ListSandboxPortTokensOptions, type ListSandboxesOptions, type ListTokensOptions, type MountConfig, type MountConfigResponse, type MountOptions, type MountResponse, type MultipartUpload, type MultipartUploadListing, type MultipartUploadSummary, type ObjectMetadata, type PartInfo, type PartListing, type PosixCreateAttrs, type PutObjectOptions, type PutObjectResult, type R2Mount, type RegistryAuth, type RootAttrs, type S3CompatibleMount, type S3Mount, type S3Object, Sandbox, type SandboxEgressPolicy, type SandboxEgressRule, type SandboxEgressTransform, type SandboxEndpoint, type SandboxFileSource, SandboxFileTransferError, type SandboxFileUploadOptions, type SandboxFileWriter, SandboxFiles, type SandboxForkOptions, type SandboxMount, type SandboxMountSpec, type SandboxNetwork, type SandboxNetworkAction, SandboxPauseError, type SandboxPortToken, type SandboxPortTokenPage, SandboxProcess, type SandboxProcessConnectOptions, type SandboxProcessOutput, type SandboxProcessOutputHandler, type SandboxProcessResult, type SandboxProcessStartOptions, type SandboxProcessStatus, type SandboxProcessStream, SandboxProcesses, type SandboxResponse, type SandboxStartOptions, type SandboxStatus, type SandboxTerminalOptions, type SandboxTimeoutOptions, type SandboxWaitOptions, Sandboxes, type ShareUrlOptions, type ShareUrlResult, type TokenUser, Tokens, USER_AGENT, type UploadPart, VERSION, Workspace, configure, createApiKey, createDisk, createSandbox, deleteApiKey, effectiveUploadPartSize, exec, getDisk, getSandbox, listApiKeys, listDisks, listSandboxes, workspace };
|
|
778
|
+
export { type ApiTokenResponse, type AppendObjectOptions, Archil, ArchilApiError, ArchilError, type ArchilOptions, ArchilS3Error, type ArchilTlsOptions, type AuthorizedUser, type AwsStsUser, type AzureBlobMount, type Branch, type BuildImageOptions, type BuildImageRequest, type CompletedMultipartUpload, type ConnectedClient, type CreateApiTokenRequest, type CreateBranchOptions, type CreateDiskRequest, type CreateDiskResult, type CreateSandboxPortTokenOptions, type CreateSandboxRequest, type CreatedSandboxPortToken, type Delegation, type DeleteObjectsError, type DeleteObjectsOptions, type DeleteObjectsResult, Disk, type DiskListPage, type DiskMetrics, DiskMultipart, type DiskResponse, type DiskStatus, type DiskUser, Disks, type ExecMount, type ExecMountSpec, type ExecOptions, type ExecRequest, type ExecResult, type FileSystem, type GCSMount, type GrepGroup, type GrepGroupLine, type GrepMatch, type GrepOptions, type GrepResult, type GrepStoppedReason, type Image, ImageBuildError, type ImageFailureReason, type ImageStatus, Images, type ListDisksOptions, type ListMultipartUploadsOptions, type ListObjectsOptions, type ListObjectsResult, type ListPartsOptions, type ListSandboxPortTokensOptions, type ListSandboxesOptions, type ListTokensOptions, type MountConfig, type MountConfigResponse, type MountOptions, type MountResponse, type MultipartUpload, type MultipartUploadListing, type MultipartUploadSummary, type ObjectMetadata, type PartInfo, type PartListing, type PosixCreateAttrs, type PutObjectOptions, type PutObjectResult, type R2Mount, type RegistryAuth, type RootAttrs, type S3CompatibleMount, type S3Mount, type S3Object, Sandbox, type SandboxEgressPolicy, type SandboxEgressRule, type SandboxEgressTransform, type SandboxEndpoint, type SandboxFileSource, SandboxFileTransferError, type SandboxFileUploadOptions, type SandboxFileWriter, SandboxFiles, type SandboxForkOptions, type SandboxMount, type SandboxMountSpec, type SandboxNetwork, type SandboxNetworkAction, SandboxPauseError, type SandboxPortToken, type SandboxPortTokenPage, SandboxProcess, type SandboxProcessConnectOptions, type SandboxProcessOutput, type SandboxProcessOutputHandler, type SandboxProcessResult, type SandboxProcessStartOptions, type SandboxProcessStatus, type SandboxProcessStream, SandboxProcesses, type SandboxResponse, type SandboxStartOptions, type SandboxStatus, type SandboxTerminalOptions, type SandboxTimeoutOptions, type SandboxWaitOptions, Sandboxes, type ShareUrlOptions, type ShareUrlResult, type TokenUser, Tokens, USER_AGENT, type UploadPart, VERSION, Workspace, configure, createApiKey, createDisk, createSandbox, deleteApiKey, effectiveUploadPartSize, exec, getDisk, getSandbox, listApiKeys, listDisks, listSandboxes, workspace };
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as ArchilError, C as Disk, D as VERSION, E as USER_AGENT, M as ImageBuildError, N as SandboxFileTransferError, P as SandboxPauseError, S as Disks, T as effectiveUploadPartSize, _ as Sandbox, a as deleteApiKey, b as SandboxProcesses, c as getSandbox, d as listSandboxes, f as workspace, g as Sandboxes, h as Tokens, i as createSandbox, j as ArchilS3Error, k as ArchilApiError, l as listApiKeys, m as Workspace, n as createApiKey, o as exec, p as Archil, r as createDisk, s as getDisk, t as configure, u as listDisks, v as SandboxFiles, w as DiskMultipart, x as Images, y as SandboxProcess } from "./src-
|
|
1
|
+
import { A as ArchilError, C as Disk, D as VERSION, E as USER_AGENT, M as ImageBuildError, N as SandboxFileTransferError, P as SandboxPauseError, S as Disks, T as effectiveUploadPartSize, _ as Sandbox, a as deleteApiKey, b as SandboxProcesses, c as getSandbox, d as listSandboxes, f as workspace, g as Sandboxes, h as Tokens, i as createSandbox, j as ArchilS3Error, k as ArchilApiError, l as listApiKeys, m as Workspace, n as createApiKey, o as exec, p as Archil, r as createDisk, s as getDisk, t as configure, u as listDisks, v as SandboxFiles, w as DiskMultipart, x as Images, y as SandboxProcess } from "./src-BND_QqPx.mjs";
|
|
2
2
|
export { Archil, ArchilApiError, ArchilError, ArchilS3Error, Disk, DiskMultipart, Disks, ImageBuildError, Images, Sandbox, SandboxFileTransferError, SandboxFiles, SandboxPauseError, SandboxProcess, SandboxProcesses, Sandboxes, Tokens, USER_AGENT, VERSION, Workspace, configure, createApiKey, createDisk, createSandbox, deleteApiKey, effectiveUploadPartSize, exec, getDisk, getSandbox, listApiKeys, listDisks, listSandboxes, workspace };
|
package/dist/internal/tools.cjs
CHANGED
|
@@ -250,9 +250,9 @@ const SPECS = [
|
|
|
250
250
|
}),
|
|
251
251
|
defineSpec({
|
|
252
252
|
name: "grep",
|
|
253
|
-
description: "Search file contents for
|
|
253
|
+
description: "Search file contents for a regular expression and return matching lines as path:line: text. Searches recursively by default.",
|
|
254
254
|
schema: zod.z.object({
|
|
255
|
-
pattern: zod.z.string().describe("
|
|
255
|
+
pattern: zod.z.string().describe("Regex in ripgrep (Rust) syntax, without lookaround or backreferences."),
|
|
256
256
|
path: zod.z.string().optional().describe("Directory to search (optional)."),
|
|
257
257
|
recursive: zod.z.boolean().optional().describe("Search subdirectories (default true)."),
|
|
258
258
|
maxResults: zod.z.number().int().optional().describe("Cap on matches (default 200).")
|
package/dist/internal/tools.mjs
CHANGED
|
@@ -249,9 +249,9 @@ const SPECS = [
|
|
|
249
249
|
}),
|
|
250
250
|
defineSpec({
|
|
251
251
|
name: "grep",
|
|
252
|
-
description: "Search file contents for
|
|
252
|
+
description: "Search file contents for a regular expression and return matching lines as path:line: text. Searches recursively by default.",
|
|
253
253
|
schema: z.object({
|
|
254
|
-
pattern: z.string().describe("
|
|
254
|
+
pattern: z.string().describe("Regex in ripgrep (Rust) syntax, without lookaround or backreferences."),
|
|
255
255
|
path: z.string().optional().describe("Directory to search (optional)."),
|
|
256
256
|
recursive: z.boolean().optional().describe("Search subdirectories (default true)."),
|
|
257
257
|
maxResults: z.number().int().optional().describe("Cap on matches (default 200).")
|
package/dist/sandbox-cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { k as ArchilApiError, p as Archil } from "./src-
|
|
3
|
-
import { a as
|
|
2
|
+
import { k as ArchilApiError, p as Archil } from "./src-BND_QqPx.mjs";
|
|
3
|
+
import { a as addGlobalOptions, c as resolveProgramCredentials, i as validateSandboxName, l as renderTable, n as parseCreateSandboxOptions, o as addProfileCommands, r as parseRunOptions, s as isProfileCommand } from "./sandbox-options-DV7SSadf.mjs";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import { Command } from "commander";
|
|
6
6
|
import { spinner } from "@clack/prompts";
|
|
@@ -64,50 +64,6 @@ function formatSandbox(sandbox, format) {
|
|
|
64
64
|
return renderTable(rows.filter(([, value]) => value !== ""));
|
|
65
65
|
}
|
|
66
66
|
//#endregion
|
|
67
|
-
//#region src/cli/sandbox-options.ts
|
|
68
|
-
function validateSandboxName(name) {
|
|
69
|
-
if (name === void 0) return void 0;
|
|
70
|
-
const value = name.trim();
|
|
71
|
-
if (!/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/.test(value)) throw new Error("Name must be 1–63 lowercase letters, numbers, or hyphens and cannot start or end with a hyphen");
|
|
72
|
-
return value;
|
|
73
|
-
}
|
|
74
|
-
function optionalInteger(value, label, min, max) {
|
|
75
|
-
if (value === void 0) return void 0;
|
|
76
|
-
const parsed = Number(value);
|
|
77
|
-
if (!Number.isInteger(parsed) || parsed < min || parsed > max) throw new Error(`${label} must be an integer from ${min} to ${max}`);
|
|
78
|
-
return parsed;
|
|
79
|
-
}
|
|
80
|
-
function parseEnvironment(entries) {
|
|
81
|
-
if (entries.length === 0) return void 0;
|
|
82
|
-
const environment = {};
|
|
83
|
-
for (const entry of entries) {
|
|
84
|
-
const separator = entry.indexOf("=");
|
|
85
|
-
if (separator <= 0) throw new Error(`Invalid environment entry '${entry}'; use NAME=value`);
|
|
86
|
-
const name = entry.slice(0, separator);
|
|
87
|
-
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name)) throw new Error(`Invalid environment variable name '${name}'`);
|
|
88
|
-
environment[name] = entry.slice(separator + 1);
|
|
89
|
-
}
|
|
90
|
-
return environment;
|
|
91
|
-
}
|
|
92
|
-
function parseCreateSandboxOptions(name, options) {
|
|
93
|
-
return {
|
|
94
|
-
name: validateSandboxName(name),
|
|
95
|
-
vcpuCount: optionalInteger(options.vcpuCount, "CPU count", 1, 32),
|
|
96
|
-
memSizeMiB: optionalInteger(options.memSizeMib, "Memory", 256, 65536),
|
|
97
|
-
baseImage: options.baseImage,
|
|
98
|
-
maxTtlSeconds: optionalInteger(options.maxTtlSeconds, "Max TTL", 1, 2147483647),
|
|
99
|
-
idleTtlSeconds: optionalInteger(options.idleTtlSeconds, "Idle TTL", 0, 86400),
|
|
100
|
-
maxConcurrentExecs: optionalInteger(options.maxConcurrentProcesses, "Max concurrent processes", 1, 1024),
|
|
101
|
-
env: parseEnvironment(options.env)
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
function parseRunOptions(options) {
|
|
105
|
-
return {
|
|
106
|
-
env: parseEnvironment(options.env),
|
|
107
|
-
timeoutSeconds: optionalInteger(options.timeout, "Timeout", 1, 2147483647)
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
//#endregion
|
|
111
67
|
//#region src/cli/sandbox-shell.ts
|
|
112
68
|
async function runSandboxShell(options) {
|
|
113
69
|
const stdin = options.stdin ?? process.stdin;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { O as REGION_URLS, p as Archil } from "./src-
|
|
1
|
+
import { O as REGION_URLS, p as Archil } from "./src-BND_QqPx.mjs";
|
|
2
2
|
import { Option } from "commander";
|
|
3
3
|
import { isCancel, password, spinner } from "@clack/prompts";
|
|
4
4
|
import { chmod, mkdir, open, readFile, rename, rm, stat } from "node:fs/promises";
|
|
@@ -303,4 +303,48 @@ function addProfileCommands(program, validateCredential = validateCredentialAndR
|
|
|
303
303
|
});
|
|
304
304
|
}
|
|
305
305
|
//#endregion
|
|
306
|
-
|
|
306
|
+
//#region src/cli/sandbox-options.ts
|
|
307
|
+
function validateSandboxName(name) {
|
|
308
|
+
if (name === void 0) return void 0;
|
|
309
|
+
const value = name.trim();
|
|
310
|
+
if (!/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/.test(value)) throw new Error("Name must be 1–63 lowercase letters, numbers, or hyphens and cannot start or end with a hyphen");
|
|
311
|
+
return value;
|
|
312
|
+
}
|
|
313
|
+
function optionalInteger(value, label, min, max) {
|
|
314
|
+
if (value === void 0) return void 0;
|
|
315
|
+
const parsed = Number(value);
|
|
316
|
+
if (!Number.isInteger(parsed) || parsed < min || parsed > max) throw new Error(`${label} must be an integer from ${min} to ${max}`);
|
|
317
|
+
return parsed;
|
|
318
|
+
}
|
|
319
|
+
function parseEnvironment(entries) {
|
|
320
|
+
if (entries.length === 0) return void 0;
|
|
321
|
+
const environment = {};
|
|
322
|
+
for (const entry of entries) {
|
|
323
|
+
const separator = entry.indexOf("=");
|
|
324
|
+
if (separator <= 0) throw new Error(`Invalid environment entry '${entry}'; use NAME=value`);
|
|
325
|
+
const name = entry.slice(0, separator);
|
|
326
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name)) throw new Error(`Invalid environment variable name '${name}'`);
|
|
327
|
+
environment[name] = entry.slice(separator + 1);
|
|
328
|
+
}
|
|
329
|
+
return environment;
|
|
330
|
+
}
|
|
331
|
+
function parseCreateSandboxOptions(name, options) {
|
|
332
|
+
return {
|
|
333
|
+
name: validateSandboxName(name),
|
|
334
|
+
vcpuCount: optionalInteger(options.vcpuCount, "CPU count", 1, 32),
|
|
335
|
+
memSizeMiB: optionalInteger(options.memSizeMib, "Memory", 256, 65536),
|
|
336
|
+
baseImage: options.baseImage,
|
|
337
|
+
maxTtlSeconds: optionalInteger(options.maxTtlSeconds, "Max TTL", 1, 2147483647),
|
|
338
|
+
idleTtlSeconds: optionalInteger(options.idleTtlSeconds, "Idle TTL", 0, 86400),
|
|
339
|
+
maxConcurrentExecs: optionalInteger(options.maxConcurrentProcesses, "Max concurrent processes", 1, 1024),
|
|
340
|
+
env: parseEnvironment(options.env)
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
function parseRunOptions(options) {
|
|
344
|
+
return {
|
|
345
|
+
env: parseEnvironment(options.env),
|
|
346
|
+
timeoutSeconds: optionalInteger(options.timeout, "Timeout", 1, 2147483647)
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
//#endregion
|
|
350
|
+
export { addGlobalOptions as a, resolveProgramCredentials as c, validateSandboxName as i, renderTable as l, parseCreateSandboxOptions as n, addProfileCommands as o, parseRunOptions as r, isProfileCommand as s, optionalInteger as t };
|
|
@@ -140,7 +140,7 @@ function deriveS3BaseUrl(controlBaseUrl) {
|
|
|
140
140
|
}
|
|
141
141
|
//#endregion
|
|
142
142
|
//#region src/version.ts
|
|
143
|
-
const VERSION = "1.
|
|
143
|
+
const VERSION = "1.10.0";
|
|
144
144
|
const USER_AGENT = `archil-js/${VERSION}`;
|
|
145
145
|
//#endregion
|
|
146
146
|
//#region src/client.ts
|
|
@@ -476,6 +476,38 @@ var Disk = class {
|
|
|
476
476
|
}
|
|
477
477
|
}), "connect"));
|
|
478
478
|
}
|
|
479
|
+
/**
|
|
480
|
+
* Create a branch: an independent, writable fork of this disk that starts
|
|
481
|
+
* from a committed checkpoint. Writes on the branch don't affect its source.
|
|
482
|
+
*
|
|
483
|
+
* Fails with a 409 if a branch with this name already exists or the
|
|
484
|
+
* checkpoint is not yet committed, and a 404 if the checkpoint or
|
|
485
|
+
* `fromBranch` doesn't exist.
|
|
486
|
+
*/
|
|
487
|
+
async createBranch(options) {
|
|
488
|
+
const idempotencyKey = options.idempotencyKey ?? globalThis.crypto.randomUUID();
|
|
489
|
+
return unwrap(retryApiRequest(() => this._client.POST("/api/disks/{id}/branches", {
|
|
490
|
+
params: {
|
|
491
|
+
path: { id: this.id },
|
|
492
|
+
header: { "Idempotency-Key": idempotencyKey }
|
|
493
|
+
},
|
|
494
|
+
body: {
|
|
495
|
+
branch_name: options.name,
|
|
496
|
+
from_checkpoint_name: options.fromCheckpoint,
|
|
497
|
+
from_branch: options.fromBranch
|
|
498
|
+
}
|
|
499
|
+
}), "transient"));
|
|
500
|
+
}
|
|
501
|
+
/** List every branch of this disk, including branches of branches, in no particular order. */
|
|
502
|
+
async listBranches() {
|
|
503
|
+
return unwrap(retryApiRequest(() => this._client.GET("/api/disks/{id}/branches", { params: { path: { id: this.id } } }), "transient"));
|
|
504
|
+
}
|
|
505
|
+
async getBranch(name) {
|
|
506
|
+
return unwrap(retryApiRequest(() => this._client.GET("/api/disks/{id}/branches/{name}", { params: { path: {
|
|
507
|
+
id: this.id,
|
|
508
|
+
name
|
|
509
|
+
} } }), "transient"));
|
|
510
|
+
}
|
|
479
511
|
async getAllowedIPs() {
|
|
480
512
|
return (await unwrap(retryApiRequest(() => this._client.GET("/api/disks/{id}/allowed-ips", { params: { path: { id: this.id } } }), "transient"))).allowedIps;
|
|
481
513
|
}
|
|
@@ -526,7 +558,14 @@ var Disk = class {
|
|
|
526
558
|
recursive: opts.recursive ?? false,
|
|
527
559
|
maxDurationSeconds: opts.maxDurationSeconds ?? 30,
|
|
528
560
|
concurrency: opts.concurrency ?? 50,
|
|
529
|
-
maxResults: opts.maxResults ?? 1e3
|
|
561
|
+
maxResults: opts.maxResults ?? 1e3,
|
|
562
|
+
ignoreCase: opts.ignoreCase,
|
|
563
|
+
multiline: opts.multiline,
|
|
564
|
+
globs: opts.globs,
|
|
565
|
+
types: opts.types,
|
|
566
|
+
typesNot: opts.typesNot,
|
|
567
|
+
contextBefore: opts.contextBefore ?? 0,
|
|
568
|
+
contextAfter: opts.contextAfter ?? 0
|
|
530
569
|
}
|
|
531
570
|
}), "transient"));
|
|
532
571
|
}
|
|
@@ -2313,6 +2352,30 @@ var Tokens = class {
|
|
|
2313
2352
|
function isExecMountSpec$1(m) {
|
|
2314
2353
|
return typeof m === "object" && m !== null && "disk" in m;
|
|
2315
2354
|
}
|
|
2355
|
+
/** Keep groups up to the one holding the `maxResults`-th match, and end that
|
|
2356
|
+
* group after up to `after` more lines, which become context so the groups
|
|
2357
|
+
* hold exactly the kept matches. With multiline, a run of matching lines is
|
|
2358
|
+
* one match. Mirrors the controlplane's truncation of a single disk's groups. */
|
|
2359
|
+
function truncateGroups(groups, maxResults, after, multiline) {
|
|
2360
|
+
let seen = 0;
|
|
2361
|
+
for (let i = 0; i < groups.length; i++) {
|
|
2362
|
+
const lines = groups[i].lines;
|
|
2363
|
+
for (let j = 0; j < lines.length; j++) {
|
|
2364
|
+
if (lines[j].match && !(multiline && j > 0 && lines[j - 1].match)) seen++;
|
|
2365
|
+
if (seen === maxResults && !(multiline && j + 1 < lines.length && lines[j + 1].match)) {
|
|
2366
|
+
const kept = lines.slice(0, Math.min(j + 1 + after, lines.length)).map((l, k) => k > j ? {
|
|
2367
|
+
...l,
|
|
2368
|
+
match: false
|
|
2369
|
+
} : l);
|
|
2370
|
+
return [...groups.slice(0, i), {
|
|
2371
|
+
...groups[i],
|
|
2372
|
+
lines: kept
|
|
2373
|
+
}];
|
|
2374
|
+
}
|
|
2375
|
+
}
|
|
2376
|
+
}
|
|
2377
|
+
return groups;
|
|
2378
|
+
}
|
|
2316
2379
|
/**
|
|
2317
2380
|
* A key-routed filesystem spanning several Archil disks. Each disk is mounted
|
|
2318
2381
|
* under a name and addressed as the first segment of a key (`<name>/...`);
|
|
@@ -2409,6 +2472,46 @@ var Workspace = class {
|
|
|
2409
2472
|
rel: this.diskKey(entry, segs.slice(1).join("/"))
|
|
2410
2473
|
}];
|
|
2411
2474
|
}
|
|
2475
|
+
/** Route grep globs written against the workspace root to the mounts they
|
|
2476
|
+
* can match. A glob that starts with a mount's name goes to that mount without
|
|
2477
|
+
* the name. One with no `/`, or that starts with `**` + `/` with or without a
|
|
2478
|
+
* leading `/`, goes to every mount as written, and also applies to a mount it
|
|
2479
|
+
* names exactly, like `!cache` or `**` + `/logs/**`. Mount names are matched
|
|
2480
|
+
* literally, so `!l*` doesn't skip a `logs` mount. Leaves out a mount whose
|
|
2481
|
+
* directory an exclude names, or that no include reaches, and throws for any
|
|
2482
|
+
* other glob with a `/`. */
|
|
2483
|
+
rootGlobs(globs) {
|
|
2484
|
+
const routed = new Map([...this.mounts.keys()].map((name) => [name, []]));
|
|
2485
|
+
const excluded = /* @__PURE__ */ new Set();
|
|
2486
|
+
for (const glob of globs) {
|
|
2487
|
+
const exclude = glob.startsWith("!");
|
|
2488
|
+
let body = exclude ? glob.slice(1) : glob;
|
|
2489
|
+
const dirOnly = body.endsWith("/");
|
|
2490
|
+
if (dirOnly) body = body.slice(0, -1);
|
|
2491
|
+
const anchored = body.startsWith("/");
|
|
2492
|
+
if (anchored) body = body.slice(1);
|
|
2493
|
+
const everywhere = !anchored && !body.includes("/") || body === "**" || body.startsWith("**/");
|
|
2494
|
+
if (everywhere) for (const mountGlobs of routed.values()) mountGlobs.push(glob);
|
|
2495
|
+
const path = everywhere && body.startsWith("**/") ? body.slice(3) : body;
|
|
2496
|
+
const slash = path.indexOf("/");
|
|
2497
|
+
const name = slash < 0 ? path : path.slice(0, slash);
|
|
2498
|
+
const rest = slash < 0 ? "" : path.slice(slash + 1);
|
|
2499
|
+
const mountGlobs = routed.get(name);
|
|
2500
|
+
if (!mountGlobs) {
|
|
2501
|
+
if (everywhere) continue;
|
|
2502
|
+
throw new Error(`At the workspace root, a glob with a '/' must start with a mount name (${this.diskNames().map((n) => `${n}/`).join(", ")}) or '**/'; got '${glob}'. To search below one mount, set directory to it.`);
|
|
2503
|
+
}
|
|
2504
|
+
if (rest === "") {
|
|
2505
|
+
if (exclude) excluded.add(name);
|
|
2506
|
+
else excluded.delete(name);
|
|
2507
|
+
continue;
|
|
2508
|
+
}
|
|
2509
|
+
mountGlobs.push(`${exclude ? "!" : ""}${rest.includes("/") ? rest : `/${rest}`}${dirOnly ? "/" : ""}`);
|
|
2510
|
+
}
|
|
2511
|
+
const hasInclude = globs.some((glob) => !glob.startsWith("!"));
|
|
2512
|
+
for (const [name, mountGlobs] of routed) if (excluded.has(name) || hasInclude && mountGlobs.every((glob) => glob.startsWith("!"))) routed.delete(name);
|
|
2513
|
+
return routed;
|
|
2514
|
+
}
|
|
2412
2515
|
/** Map a workspace-relative key to the disk's key, applying the mount's subdirectory. */
|
|
2413
2516
|
diskKey(entry, rel) {
|
|
2414
2517
|
const trimmed = rel.replace(/^\/+/, "");
|
|
@@ -2479,13 +2582,38 @@ var Workspace = class {
|
|
|
2479
2582
|
keyCount
|
|
2480
2583
|
};
|
|
2481
2584
|
}
|
|
2585
|
+
/**
|
|
2586
|
+
* Grep the disks `directory` covers in parallel and merge their results. At
|
|
2587
|
+
* the workspace root, a glob with a `/` must start with a mount name, like
|
|
2588
|
+
* `data/src/**`, which applies to that mount only, or with `**` + `/`. A glob
|
|
2589
|
+
* with no `/`, like `*.ts`, or one starting with `**` + `/` with or without a
|
|
2590
|
+
* leading `/`, applies inside every mount, and also to a mount it names
|
|
2591
|
+
* exactly, so `!cache` skips the cache mount. Mount names are matched
|
|
2592
|
+
* literally, not as patterns: `!l*` applies inside every mount, but doesn't
|
|
2593
|
+
* skip a mount named `logs`.
|
|
2594
|
+
*/
|
|
2482
2595
|
async grep(opts) {
|
|
2483
|
-
const
|
|
2484
|
-
const
|
|
2596
|
+
const directory = opts.directory ?? "";
|
|
2597
|
+
const rootGlobs = toSegments(directory).length === 0 && opts.globs?.length ? this.rootGlobs(opts.globs) : void 0;
|
|
2598
|
+
const covered = this.covered(directory).flatMap((c) => {
|
|
2599
|
+
if (rootGlobs === void 0) return [{
|
|
2600
|
+
...c,
|
|
2601
|
+
globs: opts.globs
|
|
2602
|
+
}];
|
|
2603
|
+
const globs = rootGlobs.get(c.name);
|
|
2604
|
+
return globs === void 0 ? [] : [{
|
|
2605
|
+
...c,
|
|
2606
|
+
globs
|
|
2607
|
+
}];
|
|
2608
|
+
});
|
|
2609
|
+
const results = await Promise.allSettled(covered.map(({ entry, rel, globs }) => entry.disk.grep({
|
|
2485
2610
|
...opts,
|
|
2486
|
-
directory: rel
|
|
2611
|
+
directory: rel,
|
|
2612
|
+
globs
|
|
2487
2613
|
})));
|
|
2614
|
+
for (const settled of results) if (settled.status === "rejected" && settled.reason instanceof ArchilApiError && settled.reason.status === 400) throw settled.reason;
|
|
2488
2615
|
const matches = [];
|
|
2616
|
+
const groups = [];
|
|
2489
2617
|
let filesScanned = 0;
|
|
2490
2618
|
let containersDispatched = 0;
|
|
2491
2619
|
let computeSecondsUsed = 0;
|
|
@@ -2508,9 +2636,12 @@ var Workspace = class {
|
|
|
2508
2636
|
grepMs = Math.max(grepMs, r.grepMs ?? 0);
|
|
2509
2637
|
reasons.add(r.stoppedReason);
|
|
2510
2638
|
for (const m of r.matches) matches.push({
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2639
|
+
...m,
|
|
2640
|
+
file: this.abs(name, entry, m.file)
|
|
2641
|
+
});
|
|
2642
|
+
for (const g of r.groups ?? []) groups.push({
|
|
2643
|
+
...g,
|
|
2644
|
+
file: this.abs(name, entry, g.file)
|
|
2514
2645
|
});
|
|
2515
2646
|
});
|
|
2516
2647
|
const cap = opts.maxResults ?? 1e3;
|
|
@@ -2522,8 +2653,10 @@ var Workspace = class {
|
|
|
2522
2653
|
"max_results"
|
|
2523
2654
|
];
|
|
2524
2655
|
const stoppedReason = [...reasons].every((x) => x === "completed") ? "completed" : priority.find((x) => reasons.has(x)) ?? "completed";
|
|
2656
|
+
const withGroups = (opts.contextBefore ?? 0) > 0 || (opts.contextAfter ?? 0) > 0;
|
|
2525
2657
|
return {
|
|
2526
2658
|
matches: matches.slice(0, cap),
|
|
2659
|
+
...withGroups && { groups: matches.length > cap ? truncateGroups(groups, cap, opts.contextAfter ?? 0, opts.multiline ?? false) : groups },
|
|
2527
2660
|
stoppedReason,
|
|
2528
2661
|
filesScanned,
|
|
2529
2662
|
containersDispatched,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "disk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "Pure-JS client and CLIs for Archil disks and sandboxes",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"archil",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"LICENSE"
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@archildata/api-types": "^0.0.
|
|
43
|
+
"@archildata/api-types": "^0.0.69",
|
|
44
44
|
"@clack/prompts": "^1.7.0",
|
|
45
45
|
"commander": "^14.0.3",
|
|
46
46
|
"fast-xml-parser": "^5.7.0",
|