disk 1.9.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/dist/cli.mjs +27 -7
- package/dist/{disk-MmfqVyPo.d.cts → disk-DZkPOSQD.d.cts} +37 -2
- package/dist/{disk-MmfqVyPo.d.mts → disk-DZkPOSQD.d.mts} +37 -2
- package/dist/index.cjs +109 -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-Dl6NSqjY.mjs → sandbox-options-DV7SSadf.mjs} +46 -2
- package/dist/{src-vpVe_Scb.mjs → src-BND_QqPx.mjs} +109 -8
- package/package.json +2 -2
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
|
}
|
|
@@ -71,6 +71,8 @@ type ExecDiskResult = components["schemas"]["ExecDiskResult"];
|
|
|
71
71
|
type ExecRequest = components["schemas"]["ExecRequest"];
|
|
72
72
|
type GrepDiskResult = components["schemas"]["GrepDiskResult"];
|
|
73
73
|
type GrepMatch = components["schemas"]["GrepMatch"];
|
|
74
|
+
type GrepGroup = components["schemas"]["GrepGroup"];
|
|
75
|
+
type GrepGroupLine = components["schemas"]["GrepGroupLine"];
|
|
74
76
|
type GrepStoppedReason = components["schemas"]["GrepStoppedReason"];
|
|
75
77
|
type DiskStatus = DiskResponse["status"];
|
|
76
78
|
//#endregion
|
|
@@ -104,7 +106,10 @@ interface GrepOptions {
|
|
|
104
106
|
* string or "/" means the disk root.
|
|
105
107
|
*/
|
|
106
108
|
directory: string;
|
|
107
|
-
/**
|
|
109
|
+
/**
|
|
110
|
+
* Regular expression in ripgrep syntax. A newline separates alternative
|
|
111
|
+
* patterns, except with `multiline`, where it matches a line break.
|
|
112
|
+
*/
|
|
108
113
|
pattern: string;
|
|
109
114
|
/** Walk subdirectories breadth-first. Defaults to false. */
|
|
110
115
|
recursive?: boolean;
|
|
@@ -123,6 +128,36 @@ interface GrepOptions {
|
|
|
123
128
|
* lexicographically first N. Defaults to 1000.
|
|
124
129
|
*/
|
|
125
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;
|
|
126
161
|
}
|
|
127
162
|
interface ShareUrlOptions {
|
|
128
163
|
/**
|
|
@@ -746,4 +781,4 @@ declare class DiskMultipart {
|
|
|
746
781
|
*/
|
|
747
782
|
declare function effectiveUploadPartSize(totalBytes: number, requestedPartSize: number): number;
|
|
748
783
|
//#endregion
|
|
749
|
-
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 };
|
|
@@ -71,6 +71,8 @@ type ExecDiskResult = components["schemas"]["ExecDiskResult"];
|
|
|
71
71
|
type ExecRequest = components["schemas"]["ExecRequest"];
|
|
72
72
|
type GrepDiskResult = components["schemas"]["GrepDiskResult"];
|
|
73
73
|
type GrepMatch = components["schemas"]["GrepMatch"];
|
|
74
|
+
type GrepGroup = components["schemas"]["GrepGroup"];
|
|
75
|
+
type GrepGroupLine = components["schemas"]["GrepGroupLine"];
|
|
74
76
|
type GrepStoppedReason = components["schemas"]["GrepStoppedReason"];
|
|
75
77
|
type DiskStatus = DiskResponse["status"];
|
|
76
78
|
//#endregion
|
|
@@ -104,7 +106,10 @@ interface GrepOptions {
|
|
|
104
106
|
* string or "/" means the disk root.
|
|
105
107
|
*/
|
|
106
108
|
directory: string;
|
|
107
|
-
/**
|
|
109
|
+
/**
|
|
110
|
+
* Regular expression in ripgrep syntax. A newline separates alternative
|
|
111
|
+
* patterns, except with `multiline`, where it matches a line break.
|
|
112
|
+
*/
|
|
108
113
|
pattern: string;
|
|
109
114
|
/** Walk subdirectories breadth-first. Defaults to false. */
|
|
110
115
|
recursive?: boolean;
|
|
@@ -123,6 +128,36 @@ interface GrepOptions {
|
|
|
123
128
|
* lexicographically first N. Defaults to 1000.
|
|
124
129
|
*/
|
|
125
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;
|
|
126
161
|
}
|
|
127
162
|
interface ShareUrlOptions {
|
|
128
163
|
/**
|
|
@@ -746,4 +781,4 @@ declare class DiskMultipart {
|
|
|
746
781
|
*/
|
|
747
782
|
declare function effectiveUploadPartSize(totalBytes: number, requestedPartSize: number): number;
|
|
748
783
|
//#endregion
|
|
749
|
-
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
|
|
@@ -581,7 +581,14 @@ var Disk = class {
|
|
|
581
581
|
recursive: opts.recursive ?? false,
|
|
582
582
|
maxDurationSeconds: opts.maxDurationSeconds ?? 30,
|
|
583
583
|
concurrency: opts.concurrency ?? 50,
|
|
584
|
-
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
|
|
585
592
|
}
|
|
586
593
|
}), "transient"));
|
|
587
594
|
}
|
|
@@ -2368,6 +2375,30 @@ var Tokens = class {
|
|
|
2368
2375
|
function isExecMountSpec$1(m) {
|
|
2369
2376
|
return typeof m === "object" && m !== null && "disk" in m;
|
|
2370
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
|
+
}
|
|
2371
2402
|
/**
|
|
2372
2403
|
* A key-routed filesystem spanning several Archil disks. Each disk is mounted
|
|
2373
2404
|
* under a name and addressed as the first segment of a key (`<name>/...`);
|
|
@@ -2464,6 +2495,46 @@ var Workspace = class {
|
|
|
2464
2495
|
rel: this.diskKey(entry, segs.slice(1).join("/"))
|
|
2465
2496
|
}];
|
|
2466
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
|
+
}
|
|
2467
2538
|
/** Map a workspace-relative key to the disk's key, applying the mount's subdirectory. */
|
|
2468
2539
|
diskKey(entry, rel) {
|
|
2469
2540
|
const trimmed = rel.replace(/^\/+/, "");
|
|
@@ -2534,13 +2605,38 @@ var Workspace = class {
|
|
|
2534
2605
|
keyCount
|
|
2535
2606
|
};
|
|
2536
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
|
+
*/
|
|
2537
2618
|
async grep(opts) {
|
|
2538
|
-
const
|
|
2539
|
-
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({
|
|
2540
2633
|
...opts,
|
|
2541
|
-
directory: rel
|
|
2634
|
+
directory: rel,
|
|
2635
|
+
globs
|
|
2542
2636
|
})));
|
|
2637
|
+
for (const settled of results) if (settled.status === "rejected" && settled.reason instanceof ArchilApiError && settled.reason.status === 400) throw settled.reason;
|
|
2543
2638
|
const matches = [];
|
|
2639
|
+
const groups = [];
|
|
2544
2640
|
let filesScanned = 0;
|
|
2545
2641
|
let containersDispatched = 0;
|
|
2546
2642
|
let computeSecondsUsed = 0;
|
|
@@ -2563,9 +2659,12 @@ var Workspace = class {
|
|
|
2563
2659
|
grepMs = Math.max(grepMs, r.grepMs ?? 0);
|
|
2564
2660
|
reasons.add(r.stoppedReason);
|
|
2565
2661
|
for (const m of r.matches) matches.push({
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
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)
|
|
2569
2668
|
});
|
|
2570
2669
|
});
|
|
2571
2670
|
const cap = opts.maxResults ?? 1e3;
|
|
@@ -2577,8 +2676,10 @@ var Workspace = class {
|
|
|
2577
2676
|
"max_results"
|
|
2578
2677
|
];
|
|
2579
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;
|
|
2580
2680
|
return {
|
|
2581
2681
|
matches: matches.slice(0, cap),
|
|
2682
|
+
...withGroups && { groups: matches.length > cap ? truncateGroups(groups, cap, opts.contextAfter ?? 0, opts.multiline ?? false) : groups },
|
|
2582
2683
|
stoppedReason,
|
|
2583
2684
|
filesScanned,
|
|
2584
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 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 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 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 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
|
|
@@ -558,7 +558,14 @@ var Disk = class {
|
|
|
558
558
|
recursive: opts.recursive ?? false,
|
|
559
559
|
maxDurationSeconds: opts.maxDurationSeconds ?? 30,
|
|
560
560
|
concurrency: opts.concurrency ?? 50,
|
|
561
|
-
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
|
|
562
569
|
}
|
|
563
570
|
}), "transient"));
|
|
564
571
|
}
|
|
@@ -2345,6 +2352,30 @@ var Tokens = class {
|
|
|
2345
2352
|
function isExecMountSpec$1(m) {
|
|
2346
2353
|
return typeof m === "object" && m !== null && "disk" in m;
|
|
2347
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
|
+
}
|
|
2348
2379
|
/**
|
|
2349
2380
|
* A key-routed filesystem spanning several Archil disks. Each disk is mounted
|
|
2350
2381
|
* under a name and addressed as the first segment of a key (`<name>/...`);
|
|
@@ -2441,6 +2472,46 @@ var Workspace = class {
|
|
|
2441
2472
|
rel: this.diskKey(entry, segs.slice(1).join("/"))
|
|
2442
2473
|
}];
|
|
2443
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
|
+
}
|
|
2444
2515
|
/** Map a workspace-relative key to the disk's key, applying the mount's subdirectory. */
|
|
2445
2516
|
diskKey(entry, rel) {
|
|
2446
2517
|
const trimmed = rel.replace(/^\/+/, "");
|
|
@@ -2511,13 +2582,38 @@ var Workspace = class {
|
|
|
2511
2582
|
keyCount
|
|
2512
2583
|
};
|
|
2513
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
|
+
*/
|
|
2514
2595
|
async grep(opts) {
|
|
2515
|
-
const
|
|
2516
|
-
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({
|
|
2517
2610
|
...opts,
|
|
2518
|
-
directory: rel
|
|
2611
|
+
directory: rel,
|
|
2612
|
+
globs
|
|
2519
2613
|
})));
|
|
2614
|
+
for (const settled of results) if (settled.status === "rejected" && settled.reason instanceof ArchilApiError && settled.reason.status === 400) throw settled.reason;
|
|
2520
2615
|
const matches = [];
|
|
2616
|
+
const groups = [];
|
|
2521
2617
|
let filesScanned = 0;
|
|
2522
2618
|
let containersDispatched = 0;
|
|
2523
2619
|
let computeSecondsUsed = 0;
|
|
@@ -2540,9 +2636,12 @@ var Workspace = class {
|
|
|
2540
2636
|
grepMs = Math.max(grepMs, r.grepMs ?? 0);
|
|
2541
2637
|
reasons.add(r.stoppedReason);
|
|
2542
2638
|
for (const m of r.matches) matches.push({
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
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)
|
|
2546
2645
|
});
|
|
2547
2646
|
});
|
|
2548
2647
|
const cap = opts.maxResults ?? 1e3;
|
|
@@ -2554,8 +2653,10 @@ var Workspace = class {
|
|
|
2554
2653
|
"max_results"
|
|
2555
2654
|
];
|
|
2556
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;
|
|
2557
2657
|
return {
|
|
2558
2658
|
matches: matches.slice(0, cap),
|
|
2659
|
+
...withGroups && { groups: matches.length > cap ? truncateGroups(groups, cap, opts.contextAfter ?? 0, opts.multiline ?? false) : groups },
|
|
2559
2660
|
stoppedReason,
|
|
2560
2661
|
filesScanned,
|
|
2561
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",
|