@h-rig/isolation-plugin 0.0.6-alpha.156 → 0.0.6-alpha.158

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 (77) hide show
  1. package/dist/src/embedded-native-assets.d.ts +7 -0
  2. package/dist/src/embedded-native-assets.js +6 -0
  3. package/dist/src/image-fingerprint-sidecar.d.ts +1 -0
  4. package/dist/src/image-fingerprint-sidecar.js +515 -0
  5. package/dist/src/image.d.ts +40 -0
  6. package/dist/src/image.js +1498 -0
  7. package/dist/src/index.js +4220 -20
  8. package/dist/src/isolation/binary-build-worker.d.ts +1 -0
  9. package/dist/src/isolation/binary-build-worker.js +323 -0
  10. package/dist/src/isolation/discovery.d.ts +7 -0
  11. package/dist/src/isolation/discovery.js +477 -0
  12. package/dist/src/isolation/git-native.d.ts +28 -0
  13. package/dist/src/isolation/git-native.js +598 -0
  14. package/dist/src/isolation/home.d.ts +25 -0
  15. package/dist/src/isolation/home.js +929 -0
  16. package/dist/src/isolation/index.d.ts +43 -0
  17. package/dist/src/isolation/index.js +4062 -0
  18. package/dist/src/isolation/provisioning-env.d.ts +1 -0
  19. package/dist/src/isolation/provisioning-env.js +6 -0
  20. package/dist/src/isolation/runner.d.ts +20 -0
  21. package/dist/src/isolation/runner.js +1881 -0
  22. package/dist/src/isolation/runtime-binary-build.d.ts +88 -0
  23. package/dist/src/isolation/runtime-binary-build.js +480 -0
  24. package/dist/src/isolation/shared.d.ts +29 -0
  25. package/dist/src/isolation/shared.js +283 -0
  26. package/dist/src/isolation/toolchain.d.ts +71 -0
  27. package/dist/src/isolation/toolchain.js +1348 -0
  28. package/dist/src/isolation/types.d.ts +15 -0
  29. package/dist/src/isolation/types.js +1 -0
  30. package/dist/src/isolation/worktree.d.ts +22 -0
  31. package/dist/src/isolation/worktree.js +353 -0
  32. package/dist/src/native-extract.d.ts +2 -0
  33. package/dist/src/native-extract.js +44 -0
  34. package/dist/src/plugin.d.ts +2 -2
  35. package/dist/src/plugin.js +4219 -19
  36. package/dist/src/runtime-config.d.ts +3 -0
  37. package/dist/src/runtime-config.js +215 -0
  38. package/dist/src/runtime-native-sidecar.d.ts +8 -0
  39. package/dist/src/runtime-native-sidecar.js +368 -0
  40. package/dist/src/runtime-native.d.ts +51 -0
  41. package/dist/src/runtime-native.js +485 -0
  42. package/dist/src/sandbox/backend-bwrap.d.ts +20 -0
  43. package/dist/src/sandbox/backend-bwrap.js +268 -0
  44. package/dist/src/sandbox/backend-none.d.ts +11 -0
  45. package/dist/src/sandbox/backend-none.js +20 -0
  46. package/dist/src/sandbox/backend-seatbelt.d.ts +13 -0
  47. package/dist/src/sandbox/backend-seatbelt.js +225 -0
  48. package/dist/src/sandbox/backend.d.ts +117 -0
  49. package/dist/src/sandbox/backend.js +864 -0
  50. package/dist/src/sandbox/orchestrator.d.ts +21 -0
  51. package/dist/src/sandbox/orchestrator.js +895 -0
  52. package/dist/src/sandbox/utils.d.ts +43 -0
  53. package/dist/src/sandbox/utils.js +94 -0
  54. package/dist/src/service.d.ts +10 -5
  55. package/dist/src/service.js +4145 -2
  56. package/dist/src/sidecar-arg.d.ts +7 -0
  57. package/dist/src/sidecar-arg.js +6 -0
  58. package/dist/src/sidecar-entrypoint.d.ts +9 -0
  59. package/dist/src/sidecar-entrypoint.js +401 -0
  60. package/dist/src/snapshot-sidecar.d.ts +2 -0
  61. package/dist/src/snapshot-sidecar.js +566 -0
  62. package/dist/src/snapshot.d.ts +64 -0
  63. package/dist/src/snapshot.js +515 -0
  64. package/dist/src/task-run-snapshot.d.ts +26 -0
  65. package/dist/src/task-run-snapshot.js +713 -0
  66. package/native/darwin-arm64/rig-git +0 -0
  67. package/native/darwin-arm64/rig-git.build-manifest.json +4 -0
  68. package/native/darwin-arm64/runtime-native.dylib +0 -0
  69. package/native/darwin-x64/rig-git +0 -0
  70. package/native/darwin-x64/runtime-native.dylib +0 -0
  71. package/native/linux-arm64/rig-git +0 -0
  72. package/native/linux-arm64/runtime-native.so +0 -0
  73. package/native/linux-x64/rig-git +0 -0
  74. package/native/linux-x64/runtime-native.so +0 -0
  75. package/native/win32-x64/rig-git.exe +0 -0
  76. package/native/win32-x64/runtime-native.dll +0 -0
  77. package/package.json +45 -5
@@ -0,0 +1,7 @@
1
+ /**
2
+ * argv[2] sentinel that routes a self-exec of the compiled `rig` binary to the
3
+ * isolation-owned runtime-native sidecar handler. Kept side-effect-free so seed
4
+ * entrypoints can match it without importing `runtime-native.ts` and dlopening the
5
+ * Zig library on every invocation.
6
+ */
7
+ export declare const RIG_NATIVE_RUNTIME_SIDECAR_ARG = "__rig_native_runtime_sidecar";
@@ -0,0 +1,6 @@
1
+ // @bun
2
+ // packages/isolation-plugin/src/sidecar-arg.ts
3
+ var RIG_NATIVE_RUNTIME_SIDECAR_ARG = "__rig_native_runtime_sidecar";
4
+ export {
5
+ RIG_NATIVE_RUNTIME_SIDECAR_ARG
6
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Shared compiled-binary sentinel router. Every self-exec role entrypoint must
3
+ * check this before parsing its own args because the runtime native sidecar
4
+ * re-execs process.execPath, which can be `rig`, `rig-run`, or a hardlinked role.
5
+ *
6
+ * Lives in @rig/isolation-plugin (the fs-snapshot/provisioning domain) because it
7
+ * routes to the snapshot runtime-native sidecar handler and owns the sentinel.
8
+ */
9
+ export declare function runRuntimeNativeSidecarEntrypoint(arg?: string | undefined, rawRequest?: string | undefined): Promise<boolean>;
@@ -0,0 +1,401 @@
1
+ // @bun
2
+ var __defProp = Object.defineProperty;
3
+ var __returnValue = (v) => v;
4
+ function __exportSetter(name, newValue) {
5
+ this[name] = __returnValue.bind(null, newValue);
6
+ }
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true,
12
+ configurable: true,
13
+ set: __exportSetter.bind(all, name)
14
+ });
15
+ };
16
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
17
+
18
+ // packages/isolation-plugin/src/sidecar-arg.ts
19
+ var RIG_NATIVE_RUNTIME_SIDECAR_ARG = "__rig_native_runtime_sidecar";
20
+
21
+ // packages/isolation-plugin/src/embedded-native-assets.ts
22
+ var embeddedNatives = null;
23
+
24
+ // packages/isolation-plugin/src/native-extract.ts
25
+ import { existsSync, mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from "fs";
26
+ import { tmpdir } from "os";
27
+ import { resolve } from "path";
28
+ function extractEmbeddedNative(name) {
29
+ if (name in extractionCache) {
30
+ return extractionCache[name] ?? null;
31
+ }
32
+ const entry = embeddedNatives?.[name];
33
+ if (!entry) {
34
+ extractionCache[name] = null;
35
+ return null;
36
+ }
37
+ try {
38
+ const targetPath = resolve(sharedNativeOutputDir, entry.fileName);
39
+ mkdirSync(sharedNativeOutputDir, { recursive: true });
40
+ const upToDate = existsSync(targetPath) && statSync(targetPath).size === entry.size;
41
+ if (!upToDate) {
42
+ const bytes = readFileSync(entry.filePath);
43
+ const tempPath = `${targetPath}.${process.pid}.${Date.now()}.tmp`;
44
+ writeFileSync(tempPath, bytes, { mode: 493 });
45
+ renameSync(tempPath, targetPath);
46
+ }
47
+ extractionCache[name] = targetPath;
48
+ } catch {
49
+ extractionCache[name] = null;
50
+ }
51
+ return extractionCache[name] ?? null;
52
+ }
53
+ var sharedNativeOutputDir, extractionCache;
54
+ var init_native_extract = __esm(() => {
55
+ sharedNativeOutputDir = resolve(tmpdir(), "rig-native");
56
+ extractionCache = {};
57
+ });
58
+
59
+ // packages/isolation-plugin/src/runtime-native.ts
60
+ import { dlopen, ptr, suffix, toBuffer } from "bun:ffi";
61
+ import { copyFileSync, existsSync as existsSync2, mkdirSync as mkdirSync2, renameSync as renameSync2, rmSync, statSync as statSync2 } from "fs";
62
+ import { tmpdir as tmpdir2 } from "os";
63
+ import { dirname, resolve as resolve2 } from "path";
64
+ function requireNativeRuntimeLibrary(feature) {
65
+ if (!nativeRuntimeLibrary) {
66
+ throw new Error(`Native Zig runtime is required for ${feature}`);
67
+ }
68
+ return nativeRuntimeLibrary;
69
+ }
70
+ function runtimePrepareTrackedPathsInProcess(input) {
71
+ const runtimeLibrary = requireNativeRuntimeLibrary("runtime dependency layer linking");
72
+ const logsDir = Buffer.from(input.logsDir, "utf8");
73
+ const stateDir = Buffer.from(input.stateDir, "utf8");
74
+ const sessionDir = Buffer.from(input.sessionDir, "utf8");
75
+ const eventsFile = Buffer.from(input.eventsFile, "utf8");
76
+ const controlledBashLogFile = Buffer.from(input.controlledBashLogFile, "utf8");
77
+ const resultPtr = runtimeLibrary.symbols.runtime_prepare_paths(Number(ptr(logsDir)), logsDir.byteLength, Number(ptr(stateDir)), stateDir.byteLength, Number(ptr(sessionDir)), sessionDir.byteLength, Number(ptr(eventsFile)), eventsFile.byteLength, Number(ptr(controlledBashLogFile)), controlledBashLogFile.byteLength);
78
+ if (!resultPtr) {
79
+ throw new Error("runtime_prepare_paths returned null");
80
+ }
81
+ try {
82
+ const view = viewAt(resultPtr, OPERATION_RESULT_SIZE);
83
+ throwIfOperationError(view, "runtime_prepare_paths");
84
+ } finally {
85
+ runtimeLibrary.symbols.snapshot_release(resultPtr);
86
+ }
87
+ }
88
+ function runtimeLinkDependencyLayerInProcess(sourceDir, targetDir) {
89
+ const runtimeLibrary = requireNativeRuntimeLibrary("runtime worktree discovery");
90
+ const sourceBuffer = Buffer.from(sourceDir, "utf8");
91
+ const targetBuffer = Buffer.from(targetDir, "utf8");
92
+ const resultPtr = runtimeLibrary.symbols.runtime_link_dependency_layer(Number(ptr(sourceBuffer)), sourceBuffer.byteLength, Number(ptr(targetBuffer)), targetBuffer.byteLength);
93
+ if (!resultPtr) {
94
+ throw new Error("runtime_link_dependency_layer returned null");
95
+ }
96
+ try {
97
+ const view = viewAt(resultPtr, OPERATION_RESULT_SIZE);
98
+ throwIfOperationError(view, "runtime_link_dependency_layer");
99
+ } finally {
100
+ runtimeLibrary.symbols.snapshot_release(resultPtr);
101
+ }
102
+ }
103
+ function runtimeScanWorktreesInProcess(worktreesRoot) {
104
+ const runtimeLibrary = requireNativeRuntimeLibrary("runtime worktree discovery");
105
+ const rootBuffer = Buffer.from(worktreesRoot, "utf8");
106
+ const resultPtr = runtimeLibrary.symbols.runtime_scan_worktrees(Number(ptr(rootBuffer)), rootBuffer.byteLength);
107
+ if (!resultPtr) {
108
+ throw new Error(`runtime_scan_worktrees returned null for ${worktreesRoot}`);
109
+ }
110
+ try {
111
+ const view = viewAt(resultPtr, RUNTIME_SCAN_RESULT_SIZE);
112
+ throwIfScanError(view, "runtime_scan_worktrees");
113
+ const entriesPtr = readU64(view, 8);
114
+ const entriesLen = readU64(view, 16);
115
+ const entries = [];
116
+ for (let index = 0;index < entriesLen; index += 1) {
117
+ const entryView = viewAt(entriesPtr + index * RUNTIME_SCAN_ENTRY_SIZE, RUNTIME_SCAN_ENTRY_SIZE);
118
+ entries.push({
119
+ workspaceDir: readString(readU64(entryView, 0), readU64(entryView, 8)),
120
+ runtimeDir: readString(readU64(entryView, 16), readU64(entryView, 24)),
121
+ contextPath: readString(readU64(entryView, 32), readU64(entryView, 40)),
122
+ metadataPath: readString(readU64(entryView, 48), readU64(entryView, 56))
123
+ });
124
+ }
125
+ return entries;
126
+ } finally {
127
+ runtimeLibrary.symbols.snapshot_release(resultPtr);
128
+ }
129
+ }
130
+ async function ensureNativeRuntimeLibraryPath(outputPath = sharedNativeRuntimeOutputPath, options = {}) {
131
+ const explicitLib = process.env.RIG_NATIVE_RUNTIME_LIB?.trim();
132
+ if (explicitLib && existsSync2(explicitLib)) {
133
+ return explicitLib;
134
+ }
135
+ const embeddedPath = extractEmbeddedNative("snapshot");
136
+ if (embeddedPath) {
137
+ return embeddedPath;
138
+ }
139
+ if (await buildNativeRuntimeLibrary(outputPath, options)) {
140
+ return outputPath;
141
+ }
142
+ return !options.force && existsSync2(outputPath) ? outputPath : null;
143
+ }
144
+ async function loadNativeRuntimeLibrary() {
145
+ if (process.env.RIG_DISABLE_ZIG_NATIVE === "1") {
146
+ return null;
147
+ }
148
+ const explicitLib = process.env.RIG_NATIVE_RUNTIME_LIB?.trim();
149
+ if (explicitLib && existsSync2(explicitLib)) {
150
+ const loaded = tryDlopenNativeRuntimeLibrary(explicitLib);
151
+ if (loaded) {
152
+ return loaded;
153
+ }
154
+ }
155
+ const embeddedPath = extractEmbeddedNative("snapshot");
156
+ if (embeddedPath) {
157
+ const loaded = tryDlopenNativeRuntimeLibrary(embeddedPath);
158
+ if (loaded) {
159
+ return loaded;
160
+ }
161
+ }
162
+ for (const candidate of nativeRuntimeLibraryCandidates()) {
163
+ if (!candidate || !existsSync2(candidate)) {
164
+ continue;
165
+ }
166
+ const loaded = tryDlopenNativeRuntimeLibrary(candidate);
167
+ if (loaded) {
168
+ return loaded;
169
+ }
170
+ }
171
+ const builtLibraryPath = await ensureNativeRuntimeLibraryPath(sharedNativeRuntimeOutputPath, { force: true });
172
+ if (!builtLibraryPath) {
173
+ return null;
174
+ }
175
+ return tryDlopenNativeRuntimeLibrary(builtLibraryPath);
176
+ }
177
+ function nativePackageLibraryCandidates(fromDir, names) {
178
+ const candidates = [];
179
+ let cursor = resolve2(fromDir);
180
+ for (let index = 0;index < 8; index += 1) {
181
+ for (const name of names) {
182
+ candidates.push(resolve2(cursor, "native", `${process.platform}-${process.arch}`, name), resolve2(cursor, "native", `${process.platform}-${process.arch}`, "lib", name), resolve2(cursor, "native", name), resolve2(cursor, "native", "lib", name));
183
+ }
184
+ const parent = dirname(cursor);
185
+ if (parent === cursor)
186
+ break;
187
+ cursor = parent;
188
+ }
189
+ return candidates;
190
+ }
191
+ function nativeRuntimeLibraryCandidates() {
192
+ const explicit = process.env.RIG_NATIVE_RUNTIME_LIB?.trim() || "";
193
+ const execDir = process.execPath?.trim() ? dirname(process.execPath.trim()) : "";
194
+ const platformSpecific = `runtime-native-${process.platform}-${process.arch}.${suffix}`;
195
+ return [...new Set([
196
+ explicit,
197
+ ...nativePackageLibraryCandidates(import.meta.dir, [colocatedNativeRuntimeFileName, platformSpecific]),
198
+ execDir ? resolve2(execDir, colocatedNativeRuntimeFileName) : "",
199
+ execDir ? resolve2(execDir, platformSpecific) : "",
200
+ execDir ? resolve2(execDir, "..", colocatedNativeRuntimeFileName) : "",
201
+ execDir ? resolve2(execDir, "..", platformSpecific) : "",
202
+ execDir ? resolve2(execDir, "lib", colocatedNativeRuntimeFileName) : "",
203
+ execDir ? resolve2(execDir, "..", "lib", colocatedNativeRuntimeFileName) : "",
204
+ sharedNativeRuntimeOutputPath
205
+ ].filter(Boolean))];
206
+ }
207
+ function resolveNativeRuntimeSourcePath() {
208
+ const explicit = process.env.RIG_NATIVE_RUNTIME_SOURCE?.trim();
209
+ if (explicit && existsSync2(explicit)) {
210
+ return explicit;
211
+ }
212
+ const bundled = resolve2(import.meta.dir, "../native/snapshot.zig");
213
+ return existsSync2(bundled) ? bundled : null;
214
+ }
215
+ async function buildNativeRuntimeLibrary(outputPath, options = {}) {
216
+ if (process.env.RIG_DISABLE_ZIG_NATIVE === "1") {
217
+ return false;
218
+ }
219
+ const zigBinary = Bun.which("zig");
220
+ const sourcePath = resolveNativeRuntimeSourcePath();
221
+ if (!zigBinary || !sourcePath) {
222
+ return false;
223
+ }
224
+ const tempOutputPath = `${outputPath}.${process.pid}.${Date.now()}.${Math.random().toString(36).slice(2)}.tmp`;
225
+ try {
226
+ mkdirSync2(dirname(outputPath), { recursive: true });
227
+ const needsBuild = options.force === true || !existsSync2(outputPath) || statSync2(sourcePath).mtimeMs > statSync2(outputPath).mtimeMs;
228
+ if (!needsBuild) {
229
+ return true;
230
+ }
231
+ const build = Bun.spawn([
232
+ zigBinary,
233
+ "build-lib",
234
+ sourcePath,
235
+ "-dynamic",
236
+ "-O",
237
+ "ReleaseFast",
238
+ `-femit-bin=${tempOutputPath}`
239
+ ], {
240
+ cwd: import.meta.dir,
241
+ stdout: "pipe",
242
+ stderr: "pipe"
243
+ });
244
+ const exitCode = await build.exited;
245
+ if (exitCode !== 0 || !existsSync2(tempOutputPath)) {
246
+ rmSync(tempOutputPath, { force: true });
247
+ return false;
248
+ }
249
+ renameSync2(tempOutputPath, outputPath);
250
+ return true;
251
+ } catch {
252
+ rmSync(tempOutputPath, { force: true });
253
+ return false;
254
+ }
255
+ }
256
+ function tryDlopenNativeRuntimeLibrary(outputPath) {
257
+ try {
258
+ return dlopen(outputPath, {
259
+ rig_scope_match: {
260
+ args: ["ptr", "ptr"],
261
+ returns: "u8"
262
+ },
263
+ snapshot_capture: {
264
+ args: ["ptr", "u64", "ptr", "u64"],
265
+ returns: "ptr"
266
+ },
267
+ snapshot_delta: {
268
+ args: ["ptr", "ptr"],
269
+ returns: "ptr"
270
+ },
271
+ snapshot_store_delta: {
272
+ args: ["ptr", "ptr", "ptr", "u64", "ptr", "u64", "ptr", "u64", "ptr", "u64"],
273
+ returns: "ptr"
274
+ },
275
+ snapshot_inspect_delta: {
276
+ args: ["ptr", "u64"],
277
+ returns: "ptr"
278
+ },
279
+ snapshot_apply_delta: {
280
+ args: ["ptr", "u64", "ptr", "u64"],
281
+ returns: "ptr"
282
+ },
283
+ snapshot_release: {
284
+ args: ["ptr"],
285
+ returns: "void"
286
+ },
287
+ runtime_hash_file: {
288
+ args: ["ptr", "u64"],
289
+ returns: "ptr"
290
+ },
291
+ runtime_hash_tree: {
292
+ args: ["ptr", "u64"],
293
+ returns: "ptr"
294
+ },
295
+ runtime_prepare_paths: {
296
+ args: ["ptr", "u64", "ptr", "u64", "ptr", "u64", "ptr", "u64", "ptr", "u64"],
297
+ returns: "ptr"
298
+ },
299
+ runtime_link_dependency_layer: {
300
+ args: ["ptr", "u64", "ptr", "u64"],
301
+ returns: "ptr"
302
+ },
303
+ runtime_scan_worktrees: {
304
+ args: ["ptr", "u64"],
305
+ returns: "ptr"
306
+ }
307
+ });
308
+ } catch {
309
+ return null;
310
+ }
311
+ }
312
+ function viewAt(address, size) {
313
+ return Buffer.from(toBuffer(address, 0, size));
314
+ }
315
+ function readU64(view, offset) {
316
+ return Number(view.readBigUInt64LE(offset));
317
+ }
318
+ function readString(address, length) {
319
+ if (!address || !length) {
320
+ return "";
321
+ }
322
+ return Buffer.from(toBuffer(address, 0, length)).toString("utf8");
323
+ }
324
+ function throwIfOperationError(view, opName) {
325
+ const errorPtr = readU64(view, 8);
326
+ const errorLen = readU64(view, 16);
327
+ if (!errorPtr || errorLen === 0) {
328
+ return;
329
+ }
330
+ throw new Error(`${opName} failed: ${readString(errorPtr, errorLen)}`);
331
+ }
332
+ function throwIfScanError(view, opName) {
333
+ const errorPtr = readU64(view, 24);
334
+ const errorLen = readU64(view, 32);
335
+ if (!errorPtr || errorLen === 0) {
336
+ return;
337
+ }
338
+ throw new Error(`${opName} failed: ${readString(errorPtr, errorLen)}`);
339
+ }
340
+ var sharedNativeRuntimeOutputDir, sharedNativeRuntimeOutputPath, colocatedNativeRuntimeFileName, OPERATION_RESULT_SIZE = 24, RUNTIME_SCAN_ENTRY_SIZE = 64, RUNTIME_SCAN_RESULT_SIZE = 40, nativeRuntimeLibrary;
341
+ var init_runtime_native = __esm(async () => {
342
+ init_native_extract();
343
+ sharedNativeRuntimeOutputDir = resolve2(tmpdir2(), "rig-native");
344
+ sharedNativeRuntimeOutputPath = resolve2(sharedNativeRuntimeOutputDir, `runtime-native-${process.platform}-${process.arch}.${suffix}`);
345
+ colocatedNativeRuntimeFileName = `runtime-native.${suffix}`;
346
+ nativeRuntimeLibrary = await loadNativeRuntimeLibrary();
347
+ });
348
+
349
+ // packages/isolation-plugin/src/runtime-native-sidecar.ts
350
+ var exports_runtime_native_sidecar = {};
351
+ __export(exports_runtime_native_sidecar, {
352
+ runRuntimeNativeSidecarCli: () => runRuntimeNativeSidecarCli
353
+ });
354
+ function runRuntimeNativeSidecarCli(rawRequest) {
355
+ if (!rawRequest) {
356
+ console.error("usage: runtime-native-sidecar <request-json>");
357
+ process.exit(2);
358
+ }
359
+ try {
360
+ const request = JSON.parse(rawRequest);
361
+ const response = handleRequest(request);
362
+ process.stdout.write(`${JSON.stringify(response)}
363
+ `);
364
+ process.exit(0);
365
+ } catch (error) {
366
+ const message = error instanceof Error ? error.message : String(error);
367
+ process.stdout.write(`${JSON.stringify({ ok: false, error: message })}
368
+ `);
369
+ process.exit(1);
370
+ }
371
+ }
372
+ function handleRequest(request) {
373
+ switch (request.op) {
374
+ case "prepare-paths":
375
+ runtimePrepareTrackedPathsInProcess(request.input);
376
+ return { ok: true };
377
+ case "link-dependency-layer":
378
+ runtimeLinkDependencyLayerInProcess(request.input.sourceDir, request.input.targetDir);
379
+ return { ok: true };
380
+ case "scan-worktrees":
381
+ return { ok: true, entries: runtimeScanWorktreesInProcess(request.input.worktreesRoot) };
382
+ default:
383
+ return { ok: false, error: `Unsupported runtime native sidecar op: ${request.op ?? "<missing>"}` };
384
+ }
385
+ }
386
+ var init_runtime_native_sidecar = __esm(async () => {
387
+ await init_runtime_native();
388
+ if (false) {}
389
+ });
390
+
391
+ // packages/isolation-plugin/src/sidecar-entrypoint.ts
392
+ async function runRuntimeNativeSidecarEntrypoint(arg = process.argv[2], rawRequest = process.argv[3]) {
393
+ if (arg !== RIG_NATIVE_RUNTIME_SIDECAR_ARG)
394
+ return false;
395
+ const { runRuntimeNativeSidecarCli: runRuntimeNativeSidecarCli2 } = await init_runtime_native_sidecar().then(() => exports_runtime_native_sidecar);
396
+ runRuntimeNativeSidecarCli2(rawRequest);
397
+ return true;
398
+ }
399
+ export {
400
+ runRuntimeNativeSidecarEntrypoint
401
+ };
@@ -0,0 +1,2 @@
1
+ export declare function resolveRuntimeSnapshotArtifactDir(workspaceDir: string, taskId: string): string;
2
+ export declare function runRuntimeSnapshotSidecar(argv?: string[]): Promise<void>;