@h-rig/isolation-plugin 0.0.6-alpha.157 → 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,43 @@
1
+ import type { SandboxConfig } from "@rig/contracts";
2
+ /**
3
+ * Resolve a path to its real (symlink-resolved) location.
4
+ * Falls back to `resolve()` if `realpathSync.native` fails (e.g. path does not exist).
5
+ */
6
+ export declare function toRealPath(path: string): string;
7
+ /**
8
+ * Walk up from a directory to find all `.git` directories,
9
+ * collecting them as a flat, deduplicated string array.
10
+ *
11
+ * Checks:
12
+ * 1. `projectRoot/.git`
13
+ * 2. `workspaceDir/../../.git` (two levels up — monorepo worktree layout)
14
+ * 3. `workspaceDir/.git` (if it exists)
15
+ * 4. `.git` for any additional readable host repo roots exposed via `projectRoot`
16
+ *
17
+ * Checks exactly these paths — no ancestor walk.
18
+ * Matches the original sandbox.ts behavior exactly.
19
+ */
20
+ export declare function resolveHostGitMetadataPaths(projectRoot: string, workspaceDir: string): string[];
21
+ /**
22
+ * Resolve additional host repo roots that must be readable inside the sandbox
23
+ * even when projectRoot exposes them through symlinks.
24
+ */
25
+ export declare function resolveHostRepoRootPaths(projectRoot: string): string[];
26
+ /**
27
+ * Resolve network access setting from policy config with optional env var override.
28
+ * Env var overrides log a warning when they differ from the policy value.
29
+ */
30
+ export declare function resolveNetworkWithPolicy(sandboxConfig: SandboxConfig, envOverride: string | undefined): boolean;
31
+ /**
32
+ * Parse a boolean-ish environment variable string.
33
+ * Recognizes: 1/true/yes/on as true, 0/false/no/off as false (case-insensitive).
34
+ * Returns `fallback` for undefined or unrecognized values.
35
+ */
36
+ export declare function parseBooleanEnv(raw: string | undefined, fallback: boolean): boolean;
37
+ /** Deduplicate a string array, preserving insertion order. */
38
+ export declare function uniq(values: string[]): string[];
39
+ /**
40
+ * Escape a string for use in a macOS seatbelt (.sb) profile literal.
41
+ * Wraps in double quotes, escaping backslashes and embedded quotes.
42
+ */
43
+ export declare function seatbeltString(value: string): string;
@@ -0,0 +1,94 @@
1
+ // @bun
2
+ // packages/isolation-plugin/src/sandbox/utils.ts
3
+ import { existsSync, readdirSync, realpathSync } from "fs";
4
+ import { resolve } from "path";
5
+ import { resolveMonorepoRoot } from "@rig/core/layout";
6
+ function toRealPath(path) {
7
+ if (!existsSync(path)) {
8
+ return resolve(path);
9
+ }
10
+ try {
11
+ return realpathSync.native(path);
12
+ } catch {
13
+ return resolve(path);
14
+ }
15
+ }
16
+ function resolveHostGitMetadataPaths(projectRoot, workspaceDir) {
17
+ const candidates = new Set;
18
+ const addPath = (candidate) => {
19
+ if (existsSync(candidate)) {
20
+ candidates.add(toRealPath(candidate));
21
+ }
22
+ };
23
+ addPath(resolve(projectRoot, ".git"));
24
+ addPath(resolve(workspaceDir, "..", "..", ".git"));
25
+ for (const repoRoot of resolveHostRepoRootPaths(projectRoot)) {
26
+ addPath(resolve(repoRoot, ".git"));
27
+ }
28
+ const workspaceGit = resolve(workspaceDir, ".git");
29
+ if (existsSync(workspaceGit)) {
30
+ addPath(workspaceGit);
31
+ }
32
+ return [...candidates];
33
+ }
34
+ function resolveHostRepoRootPaths(projectRoot) {
35
+ const candidates = new Set;
36
+ const addPath = (candidate) => {
37
+ if (existsSync(candidate)) {
38
+ candidates.add(toRealPath(candidate));
39
+ }
40
+ };
41
+ try {
42
+ const monorepoRoot = resolveMonorepoRoot(projectRoot);
43
+ if (toRealPath(monorepoRoot) !== toRealPath(projectRoot)) {
44
+ addPath(monorepoRoot);
45
+ }
46
+ } catch {}
47
+ const reposDir = resolve(projectRoot, "repos");
48
+ if (existsSync(reposDir)) {
49
+ for (const entry of readdirSync(reposDir, { withFileTypes: true })) {
50
+ if (entry.isDirectory() || entry.isSymbolicLink()) {
51
+ addPath(resolve(reposDir, entry.name));
52
+ }
53
+ }
54
+ }
55
+ return [...candidates];
56
+ }
57
+ function resolveNetworkWithPolicy(sandboxConfig, envOverride) {
58
+ if (envOverride) {
59
+ const envValue = parseBooleanEnv(envOverride, sandboxConfig.network);
60
+ if (envValue !== sandboxConfig.network) {
61
+ console.warn(`[sandbox] RIG_RUNTIME_SANDBOX_NETWORK=${envOverride} overrides policy sandbox.network=${sandboxConfig.network}`);
62
+ }
63
+ return envValue;
64
+ }
65
+ return sandboxConfig.network;
66
+ }
67
+ function parseBooleanEnv(raw, fallback) {
68
+ if (!raw) {
69
+ return fallback;
70
+ }
71
+ const normalized = raw.trim().toLowerCase();
72
+ if (normalized === "1" || normalized === "true" || normalized === "yes" || normalized === "on") {
73
+ return true;
74
+ }
75
+ if (normalized === "0" || normalized === "false" || normalized === "no" || normalized === "off") {
76
+ return false;
77
+ }
78
+ return fallback;
79
+ }
80
+ function uniq(values) {
81
+ return [...new Set(values)];
82
+ }
83
+ function seatbeltString(value) {
84
+ return `"${value.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`;
85
+ }
86
+ export {
87
+ uniq,
88
+ toRealPath,
89
+ seatbeltString,
90
+ resolveNetworkWithPolicy,
91
+ resolveHostRepoRootPaths,
92
+ resolveHostGitMetadataPaths,
93
+ parseBooleanEnv
94
+ };
@@ -2,12 +2,17 @@
2
2
  * service.ts — the concrete worktree isolation backend the runtime port
3
3
  * resolves and consumes.
4
4
  *
5
- * CONFIG-LIGHT: this module top-level-imports the in-runtime worktree
6
- * provisioning primitive. It is loaded LAZILY by the capability `run()` in
7
- * plugin.ts (`(await import("./service")).svc`), so merely evaluating
8
- * rig.config.ts never drags the provisioning impl into scope.
5
+ * CONFIG-LIGHT: this module top-level-imports the now-owned isolation tree (the
6
+ * worktree provisioning + execution primitives). It is loaded LAZILY by the
7
+ * capability `run()` in plugin.ts (`(await import("./service")).svc`), so merely
8
+ * evaluating rig.config.ts never drags the provisioning impl into scope.
9
+ *
10
+ * The backend exposes the full `IsolationBackend` seam (provisioning + execution
11
+ * helpers) so the runtime substrate (queue, agent-wrapper) reaches these
12
+ * plugin-owned functions through the resolved port — never via a direct import —
13
+ * keeping the substrate->plugin dependency edge absent.
9
14
  */
10
- import type { IsolationBackend } from "@rig/runtime/control-plane/isolation-backend-port";
15
+ import type { IsolationBackend } from "@rig/contracts";
11
16
  /** The concrete worktree isolation backend the runtime port resolves. */
12
17
  export declare const svc: IsolationBackend;
13
18
  /** Back-compat alias. */