nawabari 0.9.2 → 0.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/README.md +142 -803
  2. package/dist/cli-command-registry.js +46 -6
  3. package/dist/cli-command-registry.js.map +1 -1
  4. package/dist/cli.d.ts +5 -3
  5. package/dist/cli.js +157 -34
  6. package/dist/cli.js.map +1 -1
  7. package/dist/contract.js +11 -3
  8. package/dist/contract.js.map +1 -1
  9. package/dist/domain/compatibility-runtime-projection.d.ts +24 -0
  10. package/dist/domain/compatibility-runtime-projection.js +197 -0
  11. package/dist/domain/compatibility-runtime-projection.js.map +1 -0
  12. package/dist/domain/doctor.d.ts +2 -2
  13. package/dist/domain/doctor.js +72 -51
  14. package/dist/domain/doctor.js.map +1 -1
  15. package/dist/domain/errors.d.ts +1 -1
  16. package/dist/domain/errors.js +5 -1
  17. package/dist/domain/errors.js.map +1 -1
  18. package/dist/domain/fhs-development-runtime.d.ts +90 -0
  19. package/dist/domain/fhs-development-runtime.js +385 -0
  20. package/dist/domain/fhs-development-runtime.js.map +1 -0
  21. package/dist/domain/fhs-runtime.d.ts +36 -0
  22. package/dist/domain/fhs-runtime.js +776 -0
  23. package/dist/domain/fhs-runtime.js.map +1 -0
  24. package/dist/domain/landlock.d.ts +11 -4
  25. package/dist/domain/landlock.js +44 -21
  26. package/dist/domain/landlock.js.map +1 -1
  27. package/dist/domain/nix-runtime-closure.d.ts +70 -0
  28. package/dist/domain/nix-runtime-closure.js +449 -0
  29. package/dist/domain/nix-runtime-closure.js.map +1 -0
  30. package/dist/domain/pnpm-middleware-backend-materialization.d.ts +117 -0
  31. package/dist/domain/pnpm-middleware-backend-materialization.js +311 -0
  32. package/dist/domain/pnpm-middleware-backend-materialization.js.map +1 -0
  33. package/dist/domain/runtime-executable-projection.d.ts +33 -0
  34. package/dist/domain/runtime-executable-projection.js +204 -0
  35. package/dist/domain/runtime-executable-projection.js.map +1 -0
  36. package/dist/domain/runtime-file-identity.d.ts +37 -0
  37. package/dist/domain/runtime-file-identity.js +114 -0
  38. package/dist/domain/runtime-file-identity.js.map +1 -0
  39. package/dist/domain/runtime-profile.d.ts +66 -0
  40. package/dist/domain/runtime-profile.js +356 -0
  41. package/dist/domain/runtime-profile.js.map +1 -0
  42. package/dist/domain/runtime-projection.d.ts +101 -0
  43. package/dist/domain/runtime-projection.js +316 -0
  44. package/dist/domain/runtime-projection.js.map +1 -0
  45. package/dist/domain/runtime-provider-pnpm-middleware.d.ts +41 -0
  46. package/dist/domain/runtime-provider-pnpm-middleware.js +316 -0
  47. package/dist/domain/runtime-provider-pnpm-middleware.js.map +1 -0
  48. package/dist/domain/runtime-provider-tgrep.d.ts +60 -0
  49. package/dist/domain/runtime-provider-tgrep.js +537 -0
  50. package/dist/domain/runtime-provider-tgrep.js.map +1 -0
  51. package/dist/domain/runtime-resolution.d.ts +57 -0
  52. package/dist/domain/runtime-resolution.js +242 -0
  53. package/dist/domain/runtime-resolution.js.map +1 -0
  54. package/dist/domain/sandbox-launcher.d.ts +7 -0
  55. package/dist/domain/sandbox-launcher.js +380 -56
  56. package/dist/domain/sandbox-launcher.js.map +1 -1
  57. package/dist/domain/sandbox.d.ts +59 -4
  58. package/dist/domain/sandbox.js +100 -5
  59. package/dist/domain/sandbox.js.map +1 -1
  60. package/dist/domain/session-backend.js +20 -1
  61. package/dist/domain/session-backend.js.map +1 -1
  62. package/dist/domain/session.d.ts +3 -2
  63. package/dist/domain/session.js.map +1 -1
  64. package/dist/domain/tgrep-runtime-materialization.d.ts +61 -0
  65. package/dist/domain/tgrep-runtime-materialization.js +172 -0
  66. package/dist/domain/tgrep-runtime-materialization.js.map +1 -0
  67. package/dist/operation-authorization.d.ts +10 -0
  68. package/dist/operation-authorization.js +12 -1
  69. package/dist/operation-authorization.js.map +1 -1
  70. package/dist/presentation.js +6 -3
  71. package/dist/presentation.js.map +1 -1
  72. package/dist/session-registry.d.ts +11 -3
  73. package/dist/session-registry.js +61 -45
  74. package/dist/session-registry.js.map +1 -1
  75. package/package.json +3 -1
@@ -0,0 +1,537 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { DomainError, failure, success } from "./errors.js";
4
+ import { createRuntimeFile, inspectRuntimeFile } from "./runtime-file-identity.js";
5
+ import { CANONICAL_EXECUTABLE_ROOT, compileRuntimeExecutableProjection, runtimeExecutableProviderKey, } from "./runtime-executable-projection.js";
6
+ import { projectSessionRuntimeProjection, STRICT_RUNTIME_POLICY, } from "./runtime-projection.js";
7
+ import { TGREP_BACKEND_EVIDENCE, TGREP_BACKEND_PROVIDER, TGREP_BACKEND_REQUIREMENT, TGREP_NIX_INSTALLABLE, TGREP_NIXPKGS_REF, TGREP_RUNTIME_MATERIALIZATION_CONTRACT_ID, TGREP_RUNTIME_MATERIALIZATION_SCHEMA_VERSION, } from "./tgrep-runtime-materialization.js";
8
+ /** Versioned identity for the public projected rg adapter. */
9
+ export const TGREP_RG_PROVIDER_CONTRACT_ID = "nawabari.tgrep-rg-provider.v1";
10
+ export const TGREP_RG_PROVIDER_SCHEMA_VERSION = 1;
11
+ export const TGREP_RG_COMPATIBILITY_CONTRACT_ID = "nawabari.tgrep-rg-compatibility.v1";
12
+ export const TGREP_RG_COMPATIBILITY_SCHEMA_VERSION = 1;
13
+ /** The only public name supplied by this provider. There is deliberately no grep alias. */
14
+ export const TGREP_RG_ENTRYPOINT_NAME = "rg";
15
+ export const TGREP_RG_ADAPTER_TARGET = "/runtime/tgrep-rg-adapter/rg";
16
+ export const TGREP_RG_PROVIDER = Object.freeze({
17
+ id: "tgrep-rg-provider",
18
+ requirement_id: TGREP_BACKEND_REQUIREMENT.id,
19
+ });
20
+ const supported = (id, rg, backend = rg, value = "none", conflict_group) => Object.freeze({
21
+ id,
22
+ status: "supported",
23
+ rg: Object.freeze([...rg]),
24
+ backend: Object.freeze([...backend]),
25
+ value,
26
+ ...(conflict_group === undefined ? {} : { conflict_group }),
27
+ });
28
+ const rejected = (id, rg) => Object.freeze({
29
+ id,
30
+ status: "rejected",
31
+ rg: Object.freeze([...rg]),
32
+ backend: Object.freeze([]),
33
+ value: "none",
34
+ });
35
+ /**
36
+ * Closed compatibility authority. Every supported spelling has one canonical
37
+ * backend transformation; all other spellings are rejected before spawn.
38
+ */
39
+ export const TGREP_RG_COMPATIBILITY_MATRIX = Object.freeze([
40
+ supported("pattern-and-paths", ["<PATTERN>", "<PATH>..."], ["--", "<PATTERN>", "<PATH>..."]),
41
+ supported("files-mode", ["--files"]),
42
+ supported("ignore-case", ["-i", "--ignore-case"], ["--ignore-case"], "none", "case-mode"),
43
+ supported("case-sensitive", ["-s", "--case-sensitive"], ["--case-sensitive"], "none", "case-mode"),
44
+ supported("smart-case", ["-S", "--smart-case"], ["--smart-case"], "none", "case-mode"),
45
+ supported("fixed-strings", ["-F", "--fixed-strings"], ["--fixed-strings"]),
46
+ supported("word-regexp", ["-w", "--word-regexp"], ["--word-regexp"]),
47
+ supported("invert-match", ["-v", "--invert-match"], ["--invert-match"]),
48
+ supported("with-filename", ["-H", "--with-filename"], ["--with-filename"], "none", "filename-mode"),
49
+ supported("no-filename", ["-I", "--no-filename"], ["--no-filename"], "none", "filename-mode"),
50
+ supported("line-number", ["-n", "--line-number"], ["--line-number"], "none", "line-number-mode"),
51
+ supported("no-line-number", ["-N", "--no-line-number"], ["--no-line-number"], "none", "line-number-mode"),
52
+ supported("glob", ["-g", "--glob"], ["--glob"], "required"),
53
+ supported("iglob", ["--iglob"], ["--iglob"], "required"),
54
+ supported("hidden", ["--hidden"]),
55
+ supported("no-ignore", ["--no-ignore"]),
56
+ supported("no-messages", ["--no-messages"]),
57
+ supported("files-with-matches", ["-l", "--files-with-matches"], ["--files-with-matches"], "none", "file-result-mode"),
58
+ supported("files-without-match", ["--files-without-match"], ["--files-without-match"], "none", "file-result-mode"),
59
+ supported("count", ["-c", "--count"], ["--count"]),
60
+ supported("only-matching", ["-o", "--only-matching"], ["--only-matching"]),
61
+ supported("max-count", ["-m", "--max-count"], ["--max-count"], "required"),
62
+ supported("quiet", ["-q", "--quiet"], ["--quiet"]),
63
+ supported("max-depth", ["--max-depth"], ["--max-depth"], "required"),
64
+ rejected("unsupported-engine-and-rewrite", ["-P", "--pcre2", "--engine", "-r", "--replace"]),
65
+ rejected("unsupported-encoding-and-binary", ["-E", "--encoding", "--no-encoding", "-a", "--text", "--binary"]),
66
+ rejected("unsupported-output-rewrite", ["--json", "--vimgrep", "--color", "--colors", "--column", "--byte-offset"]),
67
+ rejected("unsupported-type-and-discovery", [
68
+ "-t",
69
+ "--type",
70
+ "--type-list",
71
+ "--type-add",
72
+ "--type-clear",
73
+ "--follow",
74
+ "-L",
75
+ "-u",
76
+ "--unrestricted",
77
+ ]),
78
+ rejected("unsupported-index-and-runtime-control", ["--index-path", "--no-index", "--stats", "--debug", "--trace"]),
79
+ rejected("unsupported-stdin", ["-"]),
80
+ ]);
81
+ const OPTION_SPECS = TGREP_RG_COMPATIBILITY_MATRIX.filter((entry) => entry.status === "supported" && entry.id !== "pattern-and-paths");
82
+ const MAX_ADAPTER_BYTES = 16 * 1024 * 1024;
83
+ class AdapterContentConflict extends Error {
84
+ constructor() {
85
+ super("the existing rg adapter artifact conflicts with the pinned materialization");
86
+ }
87
+ }
88
+ const OPTION_BY_SPELLING = new Map(OPTION_SPECS.flatMap((entry) => entry.rg.map((spelling) => [spelling, entry])));
89
+ function providerError(message, details = {}) {
90
+ return new DomainError("INVALID_ARGUMENT", message, {
91
+ provider: TGREP_RG_ENTRYPOINT_NAME,
92
+ compatibility_contract: TGREP_RG_COMPATIBILITY_CONTRACT_ID,
93
+ ...details,
94
+ });
95
+ }
96
+ function sourceIsCanonical(value) {
97
+ return (value.length > 0 &&
98
+ path.posix.isAbsolute(value) &&
99
+ !value.includes("\0") &&
100
+ path.posix.normalize(value) === value &&
101
+ value !== "/" &&
102
+ value !== CANONICAL_EXECUTABLE_ROOT &&
103
+ !value.startsWith(`${CANONICAL_EXECUTABLE_ROOT}/`));
104
+ }
105
+ function unsupportedOption(option, argv) {
106
+ return failure(providerError(`Projected rg rejects unsupported option '${option}' before invoking the pinned backend.`, {
107
+ option,
108
+ argv: [...argv],
109
+ supported: OPTION_SPECS.flatMap((entry) => entry.rg),
110
+ action: "remove the option or use only the closed compatibility subset",
111
+ }));
112
+ }
113
+ function missingOptionValue(option, argv) {
114
+ return failure(providerError(`Projected rg option '${option}' requires a value; the backend was not invoked.`, {
115
+ option,
116
+ argv: [...argv],
117
+ }));
118
+ }
119
+ function incompatibleOptions(left, right, argv) {
120
+ return failure(providerError(`Projected rg options '${left}' and '${right}' cannot be combined; the backend was not invoked.`, {
121
+ options: [left, right],
122
+ argv: [...argv],
123
+ }));
124
+ }
125
+ function isRepositoryRelativePath(value) {
126
+ if (value.length === 0 || path.posix.isAbsolute(value))
127
+ return false;
128
+ const normalized = path.posix.normalize(value);
129
+ return normalized !== ".." && !normalized.startsWith("../");
130
+ }
131
+ function validateRepositoryPaths(positionals, filesMode, argv) {
132
+ const paths = filesMode ? positionals : positionals.slice(1);
133
+ const invalid = paths.find((value) => !isRepositoryRelativePath(value));
134
+ if (invalid === undefined)
135
+ return success(null);
136
+ return failure(providerError(`Projected rg requires repository-relative paths; '${invalid}' is not allowed`, {
137
+ path: invalid,
138
+ argv: [...argv],
139
+ action: "use a path below the session worktree",
140
+ }));
141
+ }
142
+ /** Translate one raw rg argv using only the closed compatibility matrix. */
143
+ export function translateTgrepRgArguments(argv) {
144
+ const options = [];
145
+ const beforeDelimiter = [];
146
+ const afterDelimiter = [];
147
+ const seenGroups = new Map();
148
+ const seenOptions = new Set();
149
+ let delimiter = false;
150
+ let filesMode = false;
151
+ for (let index = 0; index < argv.length; index += 1) {
152
+ const token = argv[index];
153
+ if (delimiter) {
154
+ afterDelimiter.push(token);
155
+ continue;
156
+ }
157
+ if (token === "--") {
158
+ delimiter = true;
159
+ continue;
160
+ }
161
+ if (token === "-")
162
+ return unsupportedOption(token, argv);
163
+ if (!token.startsWith("-") || token === "") {
164
+ beforeDelimiter.push(token);
165
+ continue;
166
+ }
167
+ const equal = token.indexOf("=");
168
+ const spelling = equal === -1 ? token : token.slice(0, equal);
169
+ const inlineValue = equal === -1 ? null : token.slice(equal + 1);
170
+ const spec = OPTION_BY_SPELLING.get(spelling);
171
+ if (spec === undefined || spec.status !== "supported")
172
+ return unsupportedOption(spelling, argv);
173
+ if (inlineValue !== null && spec.value === "none") {
174
+ return failure(providerError(`Projected rg option '${spelling}' does not accept an inline value; the backend was not invoked.`, {
175
+ option: spelling,
176
+ argv: [...argv],
177
+ }));
178
+ }
179
+ if (spec.conflict_group !== undefined) {
180
+ const prior = seenGroups.get(spec.conflict_group);
181
+ if (prior !== undefined && prior.id !== spec.id)
182
+ return incompatibleOptions(prior.spelling, spelling, argv);
183
+ seenGroups.set(spec.conflict_group, { id: spec.id, spelling });
184
+ }
185
+ if (spec.id === "files-mode" && beforeDelimiter.length > 0) {
186
+ return failure(providerError("Projected rg --files must appear before search paths; the backend was not invoked.", {
187
+ option: "--files",
188
+ argv: [...argv],
189
+ }));
190
+ }
191
+ seenOptions.add(spec.id);
192
+ if (spec.id === "files-mode")
193
+ filesMode = true;
194
+ options.push(...spec.backend);
195
+ if (spec.value === "required") {
196
+ const value = inlineValue ?? argv[index + 1];
197
+ if (value === undefined || value.length === 0 || (inlineValue === null && value.startsWith("-"))) {
198
+ return missingOptionValue(spelling, argv);
199
+ }
200
+ if (inlineValue === null)
201
+ index += 1;
202
+ options.push(value);
203
+ }
204
+ }
205
+ const positionals = [...beforeDelimiter, ...afterDelimiter];
206
+ if (positionals.includes("-"))
207
+ return unsupportedOption("-", argv);
208
+ if (filesMode) {
209
+ const searchOnlyOption = [
210
+ "ignore-case",
211
+ "case-sensitive",
212
+ "smart-case",
213
+ "fixed-strings",
214
+ "word-regexp",
215
+ "invert-match",
216
+ "with-filename",
217
+ "no-filename",
218
+ "line-number",
219
+ "no-line-number",
220
+ "files-with-matches",
221
+ "files-without-match",
222
+ "count",
223
+ "only-matching",
224
+ "max-count",
225
+ "quiet",
226
+ ].find((id) => seenOptions.has(id));
227
+ if (searchOnlyOption !== undefined) {
228
+ const option = OPTION_SPECS.find((entry) => entry.id === searchOnlyOption)?.rg[0] ?? searchOnlyOption;
229
+ return incompatibleOptions("--files", option, argv);
230
+ }
231
+ const paths = validateRepositoryPaths(positionals, true, argv);
232
+ if (!paths.ok)
233
+ return paths;
234
+ return success({ argv: [...options, "--", ...positionals], options, positionals, files_mode: true });
235
+ }
236
+ if (positionals.length === 0) {
237
+ return failure(providerError("Projected rg requires a pattern before invoking the pinned backend.", {
238
+ argv: [...argv],
239
+ action: "provide <PATTERN> and optional <PATH> values",
240
+ }));
241
+ }
242
+ const paths = validateRepositoryPaths(positionals, false, argv);
243
+ if (!paths.ok)
244
+ return paths;
245
+ return success({ argv: [...options, "--", ...positionals], options, positionals, files_mode: false });
246
+ }
247
+ function materializationError(message, details = {}) {
248
+ return failure(new DomainError("RUNTIME_MATERIALIZATION_MISSING", message, {
249
+ requirement_id: TGREP_BACKEND_REQUIREMENT.id,
250
+ requirement_kind: TGREP_BACKEND_REQUIREMENT.kind,
251
+ ...details,
252
+ }));
253
+ }
254
+ function exactNodeSource(materialization) {
255
+ const nodePackage = materialization.closure.packages.find((candidate) => candidate.requirement_id === "node-runtime");
256
+ if (nodePackage === undefined) {
257
+ return materializationError("The rg adapter requires the selected exact node-runtime materialization.");
258
+ }
259
+ const source = path.posix.join(nodePackage.root, "bin", "node");
260
+ const projected = materialization.closure.projection.filesystem.some((entry) => entry.source === nodePackage.root && entry.target === nodePackage.root);
261
+ if (!projected || !sourceIsCanonical(source)) {
262
+ return materializationError("The selected node-runtime executable is not in the exact strict closure projection.", {
263
+ node_source: source,
264
+ });
265
+ }
266
+ try {
267
+ const inspected = inspectRuntimeFile(source, (_descriptor, stat) => {
268
+ if ((stat.mode & 73n) === 0n)
269
+ throw new Error("not executable");
270
+ return undefined;
271
+ });
272
+ const resolved = inspected.source;
273
+ const inClosure = materialization.closure.store_paths.some((storePath) => resolved === storePath || resolved.startsWith(`${storePath}/`));
274
+ if (!inClosure) {
275
+ return materializationError("The selected node-runtime executable is not a regular executable file.", {
276
+ node_source: source,
277
+ ...(inClosure ? {} : { resolved_source: resolved }),
278
+ });
279
+ }
280
+ }
281
+ catch {
282
+ return materializationError("The selected node-runtime executable is unavailable.", { node_source: source });
283
+ }
284
+ if (/\s/u.test(source)) {
285
+ return materializationError("The selected node-runtime executable cannot be used as a shebang path.", {
286
+ node_source: source,
287
+ });
288
+ }
289
+ return success(source);
290
+ }
291
+ function canonicalArtifactRoot(root) {
292
+ if (!sourceIsCanonical(root)) {
293
+ return materializationError("The rg adapter artifact root must be a canonical absolute directory.", {
294
+ artifact_root: root,
295
+ });
296
+ }
297
+ try {
298
+ fs.mkdirSync(root, { recursive: true, mode: 0o755 });
299
+ if (!fs.lstatSync(root).isDirectory() || fs.realpathSync.native(root) !== root) {
300
+ return materializationError("The rg adapter artifact root is not a canonical directory.", {
301
+ artifact_root: root,
302
+ });
303
+ }
304
+ }
305
+ catch {
306
+ return materializationError("The rg adapter artifact root is unavailable.", { artifact_root: root });
307
+ }
308
+ return success(root);
309
+ }
310
+ function renderAdapterSource(nodeSource, backendSource) {
311
+ const specs = JSON.stringify(OPTION_SPECS);
312
+ const contract = JSON.stringify(TGREP_RG_COMPATIBILITY_CONTRACT_ID);
313
+ const backend = JSON.stringify(backendSource);
314
+ return `#!${nodeSource}
315
+ import { spawn } from "node:child_process";
316
+ import { posix } from "node:path";
317
+
318
+ const CONTRACT = ${contract};
319
+ const BACKEND = ${backend};
320
+ const SPECS = ${specs};
321
+ const BY_SPELLING = new Map(SPECS.flatMap((spec) => spec.rg.map((spelling) => [spelling, spec])));
322
+
323
+ function reject(message, details = {}) {
324
+ const suffix = details.option === undefined ? "" : \` Option: \${details.option}.\`;
325
+ process.stderr.write(\`Projected rg rejected argv before backend execution (\${CONTRACT}): \${message}.\${suffix}\\n\`);
326
+ process.exitCode = 2;
327
+ return null;
328
+ }
329
+
330
+ function isRepositoryRelativePath(value) {
331
+ if (value.length === 0 || posix.isAbsolute(value)) return false;
332
+ const normalized = posix.normalize(value);
333
+ return normalized !== ".." && !normalized.startsWith("../");
334
+ }
335
+
336
+ function translate(argv) {
337
+ const options = [], before = [], after = [], groups = new Map(), seen = new Set();
338
+ let delimiter = false, filesMode = false;
339
+ for (let index = 0; index < argv.length; index += 1) {
340
+ const token = argv[index];
341
+ if (delimiter) { after.push(token); continue; }
342
+ if (token === "--") { delimiter = true; continue; }
343
+ if (token === "-") return reject("stdin search is unsupported", { option: token });
344
+ if (!token.startsWith("-") || token === "") { before.push(token); continue; }
345
+ const equal = token.indexOf("=");
346
+ const spelling = equal === -1 ? token : token.slice(0, equal);
347
+ const inlineValue = equal === -1 ? null : token.slice(equal + 1);
348
+ const spec = BY_SPELLING.get(spelling);
349
+ if (spec === undefined) return reject(\`unsupported option '\${spelling}'\`, { option: spelling });
350
+ if (inlineValue !== null && spec.value === "none") return reject(\`option '\${spelling}' does not accept an inline value\`, { option: spelling });
351
+ if (spec.conflict_group !== undefined) {
352
+ const prior = groups.get(spec.conflict_group);
353
+ if (prior !== undefined && prior.id !== spec.id) return reject(\`options '\${prior.spelling}' and '\${spelling}' are incompatible\`, { option: spelling });
354
+ groups.set(spec.conflict_group, { id: spec.id, spelling });
355
+ }
356
+ if (spec.id === "files-mode" && before.length > 0) return reject("--files must precede search paths", { option: "--files" });
357
+ seen.add(spec.id);
358
+ if (spec.id === "files-mode") filesMode = true;
359
+ options.push(...spec.backend);
360
+ if (spec.value === "required") {
361
+ const value = inlineValue ?? argv[index + 1];
362
+ if (value === undefined || value.length === 0 || (inlineValue === null && value.startsWith("-"))) return reject(\`option '\${spelling}' requires a value\`, { option: spelling });
363
+ if (inlineValue === null) index += 1;
364
+ options.push(value);
365
+ }
366
+ }
367
+ const positionals = [...before, ...after];
368
+ if (positionals.includes("-")) return reject("stdin search is unsupported", { option: "-" });
369
+ if (filesMode) {
370
+ const searchOnly = ["ignore-case", "case-sensitive", "smart-case", "fixed-strings", "word-regexp", "invert-match", "with-filename", "no-filename", "line-number", "no-line-number", "files-with-matches", "files-without-match", "count", "only-matching", "max-count", "quiet"].find((id) => seen.has(id));
371
+ if (searchOnly !== undefined) return reject(\`--files cannot be combined with '\${searchOnly}'\`, { option: "--files" });
372
+ }
373
+ if (!filesMode && positionals.length === 0) return reject("a search pattern is required");
374
+ const paths = filesMode ? positionals : positionals.slice(1);
375
+ const invalidPath = paths.find((value) => !isRepositoryRelativePath(value));
376
+ if (invalidPath !== undefined)
377
+ return reject(\`repository-relative paths only; '\${invalidPath}' is not allowed\`);
378
+ return [...options, "--", ...positionals];
379
+ }
380
+
381
+ const translated = translate(process.argv.slice(2));
382
+ if (translated !== null && process.exitCode !== 2) {
383
+ const child = spawn(BACKEND, translated, { shell: false, stdio: "inherit" });
384
+ let spawnFailed = false;
385
+ child.once("error", (error) => {
386
+ spawnFailed = true;
387
+ process.stderr.write(\`Projected rg could not start its pinned backend: \${error.message.slice(0, 200)}\\n\`);
388
+ process.exitCode = 127;
389
+ });
390
+ child.once("close", (code, signal) => {
391
+ if (spawnFailed) return;
392
+ if (signal !== null) {
393
+ process.kill(process.pid, signal);
394
+ return;
395
+ }
396
+ process.exitCode = code ?? 1;
397
+ });
398
+ }
399
+ `;
400
+ }
401
+ /**
402
+ * Generate the concrete launcher artifact and feed it into #293's existing
403
+ * filesystem/executable projection. The supplied #308 materialization is the
404
+ * sole source of the tgrep backend and is never re-resolved here.
405
+ */
406
+ export function materializeTgrepRgProvider(materialization, options) {
407
+ if (!options || typeof options.artifact_root !== "string") {
408
+ return materializationError("The rg provider requires an explicit artifact root.");
409
+ }
410
+ const policy = materialization.projection.policy;
411
+ if (policy.mode !== STRICT_RUNTIME_POLICY.mode ||
412
+ policy.host_visibility !== STRICT_RUNTIME_POLICY.host_visibility ||
413
+ policy.compatibility !== STRICT_RUNTIME_POLICY.compatibility ||
414
+ policy.unrestricted_host_fallback !== STRICT_RUNTIME_POLICY.unrestricted_host_fallback ||
415
+ materialization.projection.executables.length !== 0) {
416
+ return materializationError("The rg provider requires the strict #308 runtime materialization policy.");
417
+ }
418
+ if (materialization.contract_id !== TGREP_RUNTIME_MATERIALIZATION_CONTRACT_ID ||
419
+ materialization.schema_version !== TGREP_RUNTIME_MATERIALIZATION_SCHEMA_VERSION ||
420
+ materialization.backend !== "tgrep" ||
421
+ materialization.nixpkgs_ref !== TGREP_NIXPKGS_REF ||
422
+ materialization.nix_installable !== TGREP_NIX_INSTALLABLE ||
423
+ materialization.provider.id !== TGREP_BACKEND_PROVIDER.id ||
424
+ materialization.provider.requirement_id !== TGREP_BACKEND_PROVIDER.requirement_id ||
425
+ materialization.evidence.version !== TGREP_BACKEND_EVIDENCE.version ||
426
+ materialization.evidence.help_sha256 !== TGREP_BACKEND_EVIDENCE.help_sha256 ||
427
+ materialization.evidence.help_bytes !== TGREP_BACKEND_EVIDENCE.help_bytes) {
428
+ return materializationError("The supplied tgrep materialization is not the exact #308 artifact/evidence.");
429
+ }
430
+ const backendSource = materialization.executable_source;
431
+ if (materialization.executable_target !== backendSource ||
432
+ materialization.provider_materialization.source !== backendSource ||
433
+ materialization.provider_materialization.provider.id !== TGREP_BACKEND_PROVIDER.id ||
434
+ materialization.provider_materialization.provider.requirement_id !== TGREP_BACKEND_PROVIDER.requirement_id) {
435
+ return materializationError("The supplied tgrep provider materialization is not internally consistent.");
436
+ }
437
+ if (!sourceIsCanonical(backendSource)) {
438
+ return materializationError("The supplied tgrep executable source is not canonical or is recursion-prone.", {
439
+ backend_source: backendSource,
440
+ });
441
+ }
442
+ const tgrepPackage = materialization.closure.packages.find((candidate) => candidate.requirement_id === TGREP_BACKEND_REQUIREMENT.id);
443
+ if (tgrepPackage === undefined ||
444
+ backendSource !== path.posix.join(tgrepPackage.root, "bin", "tgrep") ||
445
+ !tgrepPackage.closure.every((storePath) => materialization.projection.filesystem.some((entry) => entry.source === storePath && entry.target === storePath))) {
446
+ return materializationError("The supplied tgrep executable is not backed by the exact #308 closure projection.");
447
+ }
448
+ const node = exactNodeSource(materialization);
449
+ if (!node.ok)
450
+ return node;
451
+ const artifactRoot = canonicalArtifactRoot(options.artifact_root);
452
+ if (!artifactRoot.ok)
453
+ return artifactRoot;
454
+ const adapterSource = path.join(artifactRoot.value, TGREP_RG_ENTRYPOINT_NAME);
455
+ const content = renderAdapterSource(node.value, backendSource);
456
+ try {
457
+ try {
458
+ inspectRuntimeFile(adapterSource, (descriptor, stat) => {
459
+ if (stat.size > BigInt(MAX_ADAPTER_BYTES))
460
+ throw new Error("the adapter exceeds the bounded size");
461
+ if (fs.readFileSync(descriptor, "utf8") !== content)
462
+ throw new AdapterContentConflict();
463
+ fs.fchmodSync(descriptor, 0o755);
464
+ return undefined;
465
+ }, { requireCanonicalPath: true });
466
+ }
467
+ catch (error) {
468
+ if (error.code !== "ENOENT")
469
+ throw error;
470
+ createRuntimeFile(adapterSource, (descriptor) => {
471
+ fs.writeFileSync(descriptor, content, { encoding: "utf8" });
472
+ fs.fchmodSync(descriptor, 0o755);
473
+ return undefined;
474
+ });
475
+ }
476
+ }
477
+ catch (error) {
478
+ if (error instanceof AdapterContentConflict) {
479
+ return materializationError("The existing rg adapter artifact conflicts with the pinned materialization.", {
480
+ adapter_source: adapterSource,
481
+ });
482
+ }
483
+ return materializationError("The rg adapter artifact could not be materialized.", {
484
+ adapter_source: adapterSource,
485
+ });
486
+ }
487
+ const projection = projectSessionRuntimeProjection({
488
+ ...materialization.projection,
489
+ filesystem: [
490
+ ...materialization.projection.filesystem,
491
+ {
492
+ source: adapterSource,
493
+ target: TGREP_RG_ADAPTER_TARGET,
494
+ access_mode: "read-only",
495
+ provenance: "package",
496
+ },
497
+ ],
498
+ executables: [
499
+ {
500
+ name: TGREP_RG_ENTRYPOINT_NAME,
501
+ target: TGREP_RG_ADAPTER_TARGET,
502
+ provider: TGREP_RG_PROVIDER,
503
+ provenance: "package",
504
+ },
505
+ ],
506
+ });
507
+ if (!projection.ok)
508
+ return failure(projection.error);
509
+ const providerMaterialization = Object.freeze({
510
+ provider: TGREP_RG_PROVIDER,
511
+ source: adapterSource,
512
+ });
513
+ // Exercise the same #293 materialization input used by consumers before
514
+ // returning the artifact, so a malformed provider cannot escape this API.
515
+ const compiled = compileRuntimeExecutableProjection(projection.value, new Map([[runtimeExecutableProviderKey(TGREP_RG_PROVIDER), providerMaterialization]]));
516
+ if (!compiled.ok) {
517
+ return materializationError("The generated rg provider did not satisfy the canonical executable projection.", {
518
+ reason: compiled.error.message,
519
+ });
520
+ }
521
+ return success(Object.freeze({
522
+ contract_id: TGREP_RG_PROVIDER_CONTRACT_ID,
523
+ schema_version: TGREP_RG_PROVIDER_SCHEMA_VERSION,
524
+ compatibility_contract_id: TGREP_RG_COMPATIBILITY_CONTRACT_ID,
525
+ compatibility_schema_version: TGREP_RG_COMPATIBILITY_SCHEMA_VERSION,
526
+ backend_source: backendSource,
527
+ node_source: node.value,
528
+ adapter_source: adapterSource,
529
+ adapter_target: TGREP_RG_ADAPTER_TARGET,
530
+ provider: TGREP_RG_PROVIDER,
531
+ provider_materialization: providerMaterialization,
532
+ projection: projection.value,
533
+ }));
534
+ }
535
+ export const materializeTgrepRgRuntime = materializeTgrepRgProvider;
536
+ export const projectTgrepRgRuntime = materializeTgrepRgProvider;
537
+ //# sourceMappingURL=runtime-provider-tgrep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-provider-tgrep.js","sourceRoot":"","sources":["../../src/domain/runtime-provider-tgrep.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAsC,MAAM,aAAa,CAAC;AAEhG,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACnF,OAAO,EACL,yBAAyB,EACzB,kCAAkC,EAClC,4BAA4B,GAC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F,CAAC,CAAC;IACH,IAAI,CAAC,UAAU,CAAC,EAAE;QAAE,OAAO,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACrD,MAAM,uBAAuB,GAA6C,MAAM,CAAC,MAAM,CAAC;QACtF,QAAQ,EAAE,iBAAiB;QAC3B,MAAM,EAAE,aAAa;KACtB,CAAC,CAAC;IACH,wEAAwE;IACxE,0EAA0E;IAC1E,MAAM,QAAQ,GAAG,kCAAkC,CACjD,UAAU,CAAC,KAAK,EAChB,IAAI,GAAG,CAAC,CAAC,CAAC,4BAA4B,CAAC,iBAAiB,CAAC,EAAE,uBAAuB,CAAC,CAAC,CAAC,CACtF,CAAC;IACF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,OAAO,oBAAoB,CAAC,gFAAgF,EAAE;YAC5G,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,OAAO;SAC/B,CAAC,CAAC;IACL,CAAC;IACD,OAAO,OAAO,CACZ,MAAM,CAAC,MAAM,CAAC;QACZ,WAAW,EAAE,6BAA6B;QAC1C,cAAc,EAAE,gCAAgC;QAChD,yBAAyB,EAAE,kCAAkC;QAC7D,4BAA4B,EAAE,qCAAqC;QACnE,cAAc,EAAE,aAAa;QAC7B,WAAW,EAAE,IAAI,CAAC,KAAK;QACvB,cAAc,EAAE,aAAa;QAC7B,cAAc,EAAE,uBAAuB;QACvC,QAAQ,EAAE,iBAAiB;QAC3B,wBAAwB,EAAE,uBAAuB;QACjD,UAAU,EAAE,UAAU,CAAC,KAAK;KAC7B,CAAC,CACH,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,yBAAyB,GAAG,0BAA0B,CAAC;AACpE,MAAM,CAAC,MAAM,qBAAqB,GAAG,0BAA0B,CAAC"}
@@ -0,0 +1,57 @@
1
+ import { type DomainResult } from "./errors.js";
2
+ import { type NixRuntimeClosureOptions } from "./nix-runtime-closure.js";
3
+ import { type ResolvedRuntimeProfile, type RuntimeProfileSelection } from "./runtime-profile.js";
4
+ import { type RuntimePolicy, type RuntimeProfileIdentity, type SessionRuntimeProjection } from "./runtime-projection.js";
5
+ import type { SandboxRuntimeLayout } from "./sandbox.js";
6
+ /** Materializer selected by the host layout, or the explicit compatibility path. */
7
+ export type RuntimeMaterializer = "nix" | "fhs" | "compatibility" | "provided";
8
+ /** Bounded evidence attached to a resolved protected execution request. */
9
+ export type RuntimeResolutionEvidence = Readonly<{
10
+ readonly policy: RuntimePolicy;
11
+ readonly profile: RuntimeProfileIdentity;
12
+ readonly materializer: RuntimeMaterializer;
13
+ }>;
14
+ export type RuntimeResolution = RuntimeResolutionEvidence & Readonly<{
15
+ readonly projection: SessionRuntimeProjection;
16
+ }>;
17
+ export type RuntimeResolutionFhsOptions = Readonly<{
18
+ /** Optional bounded ELF search paths forwarded to the canonical FHS resolver. */
19
+ readonly library_search_paths?: readonly string[];
20
+ }>;
21
+ export type RuntimeResolutionOptions = Readonly<{
22
+ readonly policy?: RuntimePolicy;
23
+ /** An already resolved internal profile may be supplied by a caller. */
24
+ readonly profile?: ResolvedRuntimeProfile;
25
+ readonly profile_selection?: RuntimeProfileSelection;
26
+ readonly platform: string;
27
+ readonly runtime_layout: SandboxRuntimeLayout;
28
+ readonly nix?: NixRuntimeClosureOptions;
29
+ readonly fhs?: RuntimeResolutionFhsOptions;
30
+ }>;
31
+ export type RuntimeMaterializerAvailability = Readonly<{
32
+ readonly selected: RuntimeMaterializer | null;
33
+ readonly available: readonly RuntimeMaterializer[];
34
+ readonly strict_ready: boolean;
35
+ readonly reason: string | null;
36
+ }>;
37
+ export type RuntimeDoctorReport = Readonly<RuntimeMaterializerAvailability & {
38
+ readonly default_policy: RuntimePolicy;
39
+ readonly default_profile: RuntimeProfileIdentity;
40
+ readonly compatibility_available: boolean;
41
+ readonly compatibility_policy: RuntimePolicy;
42
+ }>;
43
+ /**
44
+ * Select a materializer from explicit host-layout evidence. The selection is
45
+ * made once; callers must not retry a failed selected materializer with the
46
+ * other platform path.
47
+ */
48
+ export declare function runtimeMaterializerAvailability(platform: string, layout: SandboxRuntimeLayout): RuntimeMaterializerAvailability;
49
+ /** Diagnostic projection of the same deterministic materializer selection. */
50
+ export declare function runtimeDoctorReport(platform: string, layout: SandboxRuntimeLayout): RuntimeDoctorReport;
51
+ /**
52
+ * Compose the canonical runtime pipeline. This function has no fallback
53
+ * branch after a strict materializer is selected.
54
+ */
55
+ export declare function resolveRuntimeProjection(options: RuntimeResolutionOptions): DomainResult<RuntimeResolution>;
56
+ export declare const resolveRuntimeResolution: typeof resolveRuntimeProjection;
57
+ export declare const resolveSessionRuntimeProjection: typeof resolveRuntimeProjection;