@h-rig/runtime 0.0.6-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -0
- package/dist/bin/rig-agent-dispatch.js +9615 -0
- package/dist/bin/rig-agent.js +9512 -0
- package/dist/bin/rig-browser-tool.js +269 -0
- package/dist/src/agent-mode.js +48 -0
- package/dist/src/baked-secrets.js +121 -0
- package/dist/src/binary-build-worker.js +312 -0
- package/dist/src/binary-run.js +540 -0
- package/dist/src/boundaries.js +1 -0
- package/dist/src/build-time-config.js +25 -0
- package/dist/src/control-plane/agent-roles.js +27 -0
- package/dist/src/control-plane/agent-wrapper.js +9621 -0
- package/dist/src/control-plane/authority-files.js +582 -0
- package/dist/src/control-plane/browser-contract.js +135 -0
- package/dist/src/control-plane/controlled-bash.js +1111 -0
- package/dist/src/control-plane/errors.js +13 -0
- package/dist/src/control-plane/harness-main.js +10828 -0
- package/dist/src/control-plane/hook-materializer.js +75 -0
- package/dist/src/control-plane/hooks/audit-trail.js +353 -0
- package/dist/src/control-plane/hooks/completion-verification.js +7552 -0
- package/dist/src/control-plane/hooks/import-guard.js +890 -0
- package/dist/src/control-plane/hooks/inject-context.js +4189 -0
- package/dist/src/control-plane/hooks/post-edit-lint.js +43 -0
- package/dist/src/control-plane/hooks/safety-guard.js +910 -0
- package/dist/src/control-plane/hooks/scope-guard.js +907 -0
- package/dist/src/control-plane/hooks/shared.js +44 -0
- package/dist/src/control-plane/hooks/submodule-branch.js +7797 -0
- package/dist/src/control-plane/hooks/task-runtime-start.js +7799 -0
- package/dist/src/control-plane/hooks/test-integrity-guard.js +891 -0
- package/dist/src/control-plane/materialize-task-config.js +453 -0
- package/dist/src/control-plane/memory-sync/cli.js +2019 -0
- package/dist/src/control-plane/memory-sync/db.js +753 -0
- package/dist/src/control-plane/memory-sync/embed.js +281 -0
- package/dist/src/control-plane/memory-sync/index.js +2049 -0
- package/dist/src/control-plane/memory-sync/query.js +294 -0
- package/dist/src/control-plane/memory-sync/read.js +784 -0
- package/dist/src/control-plane/memory-sync/types.js +6 -0
- package/dist/src/control-plane/memory-sync/write.js +1547 -0
- package/dist/src/control-plane/native/git-native.js +490 -0
- package/dist/src/control-plane/native/git-ops.js +2860 -0
- package/dist/src/control-plane/native/harness-cli.js +9721 -0
- package/dist/src/control-plane/native/pr-automation.js +373 -0
- package/dist/src/control-plane/native/profile-ops.js +481 -0
- package/dist/src/control-plane/native/repo-ops.js +2342 -0
- package/dist/src/control-plane/native/root-resolver.js +66 -0
- package/dist/src/control-plane/native/run-ops.js +3281 -0
- package/dist/src/control-plane/native/runtime-native-sidecar.js +299 -0
- package/dist/src/control-plane/native/runtime-native.js +392 -0
- package/dist/src/control-plane/native/scope-rules.js +17 -0
- package/dist/src/control-plane/native/task-ops.js +6320 -0
- package/dist/src/control-plane/native/task-state.js +1512 -0
- package/dist/src/control-plane/native/utils.js +535 -0
- package/dist/src/control-plane/native/validator-binaries.js +889 -0
- package/dist/src/control-plane/native/validator.js +2197 -0
- package/dist/src/control-plane/native/verifier.js +3249 -0
- package/dist/src/control-plane/native/workspace-ops.js +1635 -0
- package/dist/src/control-plane/plugin-host-context.js +334 -0
- package/dist/src/control-plane/project-main-pre-run-sync.js +630 -0
- package/dist/src/control-plane/provider/claude-stream-records.js +158 -0
- package/dist/src/control-plane/provider/codex-app-server.js +885 -0
- package/dist/src/control-plane/provider/codex-exec-records.js +203 -0
- package/dist/src/control-plane/provider/rig-task-run-skill.js +39 -0
- package/dist/src/control-plane/provider/runtime-instructions.js +96 -0
- package/dist/src/control-plane/remote.js +854 -0
- package/dist/src/control-plane/repos/index.js +473 -0
- package/dist/src/control-plane/repos/layout.js +124 -0
- package/dist/src/control-plane/repos/mirror/bootstrap.js +268 -0
- package/dist/src/control-plane/repos/mirror/refresh.js +398 -0
- package/dist/src/control-plane/repos/mirror/state.js +167 -0
- package/dist/src/control-plane/repos/registry.js +77 -0
- package/dist/src/control-plane/repos/types.js +1 -0
- package/dist/src/control-plane/runtime/agent-mode.js +48 -0
- package/dist/src/control-plane/runtime/baked-secrets.js +120 -0
- package/dist/src/control-plane/runtime/claude-tool-router-binary.js +343 -0
- package/dist/src/control-plane/runtime/claude-tool-router.js +520 -0
- package/dist/src/control-plane/runtime/context.js +216 -0
- package/dist/src/control-plane/runtime/events.js +218 -0
- package/dist/src/control-plane/runtime/guard-types.js +6 -0
- package/dist/src/control-plane/runtime/guard.js +880 -0
- package/dist/src/control-plane/runtime/image/fingerprint-sidecar.js +1194 -0
- package/dist/src/control-plane/runtime/image/index.js +2255 -0
- package/dist/src/control-plane/runtime/image-fingerprint-sidecar.js +1191 -0
- package/dist/src/control-plane/runtime/image.js +2255 -0
- package/dist/src/control-plane/runtime/index.js +8511 -0
- package/dist/src/control-plane/runtime/isolation/discovery.js +599 -0
- package/dist/src/control-plane/runtime/isolation/home.js +1217 -0
- package/dist/src/control-plane/runtime/isolation/index.js +8193 -0
- package/dist/src/control-plane/runtime/isolation/runner.js +2651 -0
- package/dist/src/control-plane/runtime/isolation/shared.js +501 -0
- package/dist/src/control-plane/runtime/isolation/toolchain.js +1892 -0
- package/dist/src/control-plane/runtime/isolation/types.js +1 -0
- package/dist/src/control-plane/runtime/isolation/worktree.js +509 -0
- package/dist/src/control-plane/runtime/isolation.js +8193 -0
- package/dist/src/control-plane/runtime/overlay.js +67 -0
- package/dist/src/control-plane/runtime/plugin-mode.js +41 -0
- package/dist/src/control-plane/runtime/plugins.js +1131 -0
- package/dist/src/control-plane/runtime/provisioning-env.js +220 -0
- package/dist/src/control-plane/runtime/queue.js +8358 -0
- package/dist/src/control-plane/runtime/rig-shell.js +205 -0
- package/dist/src/control-plane/runtime/rig-tools.js +182 -0
- package/dist/src/control-plane/runtime/runner-context.js +1 -0
- package/dist/src/control-plane/runtime/runtime-paths.js +184 -0
- package/dist/src/control-plane/runtime/sandbox/backend-bwrap.js +311 -0
- package/dist/src/control-plane/runtime/sandbox/backend-none.js +21 -0
- package/dist/src/control-plane/runtime/sandbox/backend-seatbelt.js +268 -0
- package/dist/src/control-plane/runtime/sandbox/backend.js +1718 -0
- package/dist/src/control-plane/runtime/sandbox/orchestrator.js +1745 -0
- package/dist/src/control-plane/runtime/sandbox/utils.js +137 -0
- package/dist/src/control-plane/runtime/sandbox-backend-bwrap.js +311 -0
- package/dist/src/control-plane/runtime/sandbox-backend-none.js +21 -0
- package/dist/src/control-plane/runtime/sandbox-backend-seatbelt.js +268 -0
- package/dist/src/control-plane/runtime/sandbox-backend.js +1718 -0
- package/dist/src/control-plane/runtime/sandbox-orchestrator.js +1745 -0
- package/dist/src/control-plane/runtime/sandbox-utils.js +137 -0
- package/dist/src/control-plane/runtime/snapshot/index.js +454 -0
- package/dist/src/control-plane/runtime/snapshot/sidecar.js +502 -0
- package/dist/src/control-plane/runtime/snapshot/task-run.js +1578 -0
- package/dist/src/control-plane/runtime/snapshot-sidecar.js +498 -0
- package/dist/src/control-plane/runtime/snapshot.js +454 -0
- package/dist/src/control-plane/runtime/task-run-snapshot.js +1578 -0
- package/dist/src/control-plane/runtime/tool-gateway.js +422 -0
- package/dist/src/control-plane/runtime/tooling/browser-tools.js +32 -0
- package/dist/src/control-plane/runtime/tooling/claude-router-binary.js +343 -0
- package/dist/src/control-plane/runtime/tooling/claude-router.js +524 -0
- package/dist/src/control-plane/runtime/tooling/file-tools.js +182 -0
- package/dist/src/control-plane/runtime/tooling/gateway.js +422 -0
- package/dist/src/control-plane/runtime/tooling/index.js +1290 -0
- package/dist/src/control-plane/runtime/tooling/shell.js +205 -0
- package/dist/src/control-plane/runtime/types.js +1 -0
- package/dist/src/control-plane/setup-version.js +14 -0
- package/dist/src/control-plane/state-sync/index.js +1509 -0
- package/dist/src/control-plane/state-sync/read.js +856 -0
- package/dist/src/control-plane/state-sync/reconcile.js +260 -0
- package/dist/src/control-plane/state-sync/repo.js +302 -0
- package/dist/src/control-plane/state-sync/types.js +111 -0
- package/dist/src/control-plane/state-sync/write.js +1469 -0
- package/dist/src/control-plane/task-fields.js +38 -0
- package/dist/src/control-plane/task-source-bootstrap.js +46 -0
- package/dist/src/control-plane/task-source.js +30 -0
- package/dist/src/control-plane/tasks/legacy-task-config-source.js +130 -0
- package/dist/src/control-plane/tasks/plugin-task-source.js +103 -0
- package/dist/src/control-plane/tasks/source-aware-task-config-source.js +611 -0
- package/dist/src/control-plane/tasks/source-lifecycle.js +1093 -0
- package/dist/src/control-plane/tasks/task-record-reader.js +9 -0
- package/dist/src/control-plane/validators/boundary/public-apis.js +107 -0
- package/dist/src/control-plane/validators/integration/_shared.js +51 -0
- package/dist/src/control-plane/validators/integration/adm-audit-http.js +85 -0
- package/dist/src/control-plane/validators/integration/adm-auth-http.js +78 -0
- package/dist/src/control-plane/validators/integration/adm-issuer-http.js +80 -0
- package/dist/src/control-plane/validators/integration/adm-migration.js +78 -0
- package/dist/src/control-plane/validators/integration/adm-scaffold.js +78 -0
- package/dist/src/control-plane/validators/runtime-registration.js +64 -0
- package/dist/src/control-plane/validators/shared.js +683 -0
- package/dist/src/events.js +218 -0
- package/dist/src/execution.js +35 -0
- package/dist/src/index.js +1633 -0
- package/dist/src/layout.js +145 -0
- package/dist/src/local-server.js +202 -0
- package/dist/src/plugins.js +329 -0
- package/dist/src/remote-http.js +83 -0
- package/dist/src/runtime-context.js +216 -0
- package/dist/src/types.js +1 -0
- package/native/darwin-arm64/bin/rig-git +0 -0
- package/native/darwin-arm64/bin/rig-shell +0 -0
- package/native/darwin-arm64/bin/rig-tools +0 -0
- package/native/darwin-arm64/lib/runtime-native-darwin-arm64.dylib +0 -0
- package/native/darwin-arm64/lib/runtime-native.dylib +0 -0
- package/native/darwin-arm64/manifest.json +1 -0
- package/native/linux-x64/bin/rig-git +0 -0
- package/native/linux-x64/bin/rig-shell +0 -0
- package/native/linux-x64/bin/rig-tools +0 -0
- package/native/linux-x64/lib/runtime-native-linux-x64.so +0 -0
- package/native/linux-x64/lib/runtime-native.so +0 -0
- package/native/linux-x64/manifest.json +1 -0
- package/package.json +74 -0
- package/skills/rig-task-run.md +71 -0
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/runtime/src/control-plane/runtime/sandbox/backend-seatbelt.ts
|
|
3
|
+
import { mkdirSync, writeFileSync } from "fs";
|
|
4
|
+
import { resolve as resolve3 } from "path";
|
|
5
|
+
|
|
6
|
+
// packages/runtime/src/control-plane/runtime/sandbox/utils.ts
|
|
7
|
+
import { existsSync as existsSync2, readdirSync, realpathSync } from "fs";
|
|
8
|
+
import { resolve as resolve2 } from "path";
|
|
9
|
+
|
|
10
|
+
// packages/runtime/src/layout.ts
|
|
11
|
+
import { existsSync } from "fs";
|
|
12
|
+
import { basename, dirname, resolve } from "path";
|
|
13
|
+
function resolveMonorepoRoot(projectRoot) {
|
|
14
|
+
const normalizedProjectRoot = resolve(projectRoot);
|
|
15
|
+
const explicit = process.env.MONOREPO_ROOT?.trim();
|
|
16
|
+
if (explicit) {
|
|
17
|
+
const explicitRoot = resolve(explicit);
|
|
18
|
+
const explicitParent = dirname(explicitRoot);
|
|
19
|
+
if (basename(explicitParent) === ".worktrees") {
|
|
20
|
+
const owner = dirname(explicitParent);
|
|
21
|
+
const ownerHasGit = existsSync(resolve(owner, ".git"));
|
|
22
|
+
const ownerHasTaskConfig = existsSync(resolve(owner, ".rig", "task-config.json"));
|
|
23
|
+
const ownerHasRigConfig = existsSync(resolve(owner, "rig.config.ts"));
|
|
24
|
+
if (ownerHasGit && (ownerHasTaskConfig || ownerHasRigConfig)) {
|
|
25
|
+
return owner;
|
|
26
|
+
}
|
|
27
|
+
throw new Error(`MONOREPO_ROOT points to worktree ${explicitRoot}, but the owner checkout is incomplete at ${owner}.`);
|
|
28
|
+
}
|
|
29
|
+
if (!existsSync(resolve(explicitRoot, ".git"))) {
|
|
30
|
+
throw new Error(`MONOREPO_ROOT points to ${explicitRoot}, but no git checkout was found there.`);
|
|
31
|
+
}
|
|
32
|
+
const hasTaskConfig = existsSync(resolve(explicitRoot, ".rig", "task-config.json"));
|
|
33
|
+
const hasRigConfig = existsSync(resolve(explicitRoot, "rig.config.ts"));
|
|
34
|
+
if (!hasTaskConfig && !hasRigConfig) {
|
|
35
|
+
throw new Error(`MONOREPO_ROOT points to ${explicitRoot}, but neither .rig/task-config.json nor rig.config.ts exists there.`);
|
|
36
|
+
}
|
|
37
|
+
return explicitRoot;
|
|
38
|
+
}
|
|
39
|
+
const projectParent = dirname(normalizedProjectRoot);
|
|
40
|
+
if (basename(projectParent) === ".worktrees") {
|
|
41
|
+
const worktreeOwner = dirname(projectParent);
|
|
42
|
+
const ownerHasGit = existsSync(resolve(worktreeOwner, ".git"));
|
|
43
|
+
const ownerHasTaskConfig = existsSync(resolve(worktreeOwner, ".rig", "task-config.json"));
|
|
44
|
+
const ownerHasRigConfig = existsSync(resolve(worktreeOwner, "rig.config.ts"));
|
|
45
|
+
if (ownerHasGit && (ownerHasTaskConfig || ownerHasRigConfig)) {
|
|
46
|
+
return worktreeOwner;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return normalizedProjectRoot;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// packages/runtime/src/control-plane/runtime/sandbox/utils.ts
|
|
53
|
+
function toRealPath(path) {
|
|
54
|
+
if (!existsSync2(path)) {
|
|
55
|
+
return resolve2(path);
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
return realpathSync.native(path);
|
|
59
|
+
} catch {
|
|
60
|
+
return resolve2(path);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function resolveHostGitMetadataPaths(projectRoot, workspaceDir) {
|
|
64
|
+
const candidates = new Set;
|
|
65
|
+
const addPath = (candidate) => {
|
|
66
|
+
if (existsSync2(candidate)) {
|
|
67
|
+
candidates.add(toRealPath(candidate));
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
addPath(resolve2(projectRoot, ".git"));
|
|
71
|
+
addPath(resolve2(workspaceDir, "..", "..", ".git"));
|
|
72
|
+
for (const repoRoot of resolveHostRepoRootPaths(projectRoot)) {
|
|
73
|
+
addPath(resolve2(repoRoot, ".git"));
|
|
74
|
+
}
|
|
75
|
+
const workspaceGit = resolve2(workspaceDir, ".git");
|
|
76
|
+
if (existsSync2(workspaceGit)) {
|
|
77
|
+
addPath(workspaceGit);
|
|
78
|
+
}
|
|
79
|
+
return [...candidates];
|
|
80
|
+
}
|
|
81
|
+
function resolveHostRepoRootPaths(projectRoot) {
|
|
82
|
+
const candidates = new Set;
|
|
83
|
+
const addPath = (candidate) => {
|
|
84
|
+
if (existsSync2(candidate)) {
|
|
85
|
+
candidates.add(toRealPath(candidate));
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
try {
|
|
89
|
+
const monorepoRoot = resolveMonorepoRoot(projectRoot);
|
|
90
|
+
if (toRealPath(monorepoRoot) !== toRealPath(projectRoot)) {
|
|
91
|
+
addPath(monorepoRoot);
|
|
92
|
+
}
|
|
93
|
+
} catch {}
|
|
94
|
+
const reposDir = resolve2(projectRoot, "repos");
|
|
95
|
+
if (existsSync2(reposDir)) {
|
|
96
|
+
for (const entry of readdirSync(reposDir, { withFileTypes: true })) {
|
|
97
|
+
if (entry.isDirectory() || entry.isSymbolicLink()) {
|
|
98
|
+
addPath(resolve2(reposDir, entry.name));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return [...candidates];
|
|
103
|
+
}
|
|
104
|
+
function resolveNetworkWithPolicy(sandboxConfig, envOverride) {
|
|
105
|
+
if (envOverride) {
|
|
106
|
+
const envValue = parseBooleanEnv(envOverride, sandboxConfig.network);
|
|
107
|
+
if (envValue !== sandboxConfig.network) {
|
|
108
|
+
console.warn(`[sandbox] RIG_RUNTIME_SANDBOX_NETWORK=${envOverride} overrides policy sandbox.network=${sandboxConfig.network}`);
|
|
109
|
+
}
|
|
110
|
+
return envValue;
|
|
111
|
+
}
|
|
112
|
+
return sandboxConfig.network;
|
|
113
|
+
}
|
|
114
|
+
function parseBooleanEnv(raw, fallback) {
|
|
115
|
+
if (!raw) {
|
|
116
|
+
return fallback;
|
|
117
|
+
}
|
|
118
|
+
const normalized = raw.trim().toLowerCase();
|
|
119
|
+
if (normalized === "1" || normalized === "true" || normalized === "yes" || normalized === "on") {
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
if (normalized === "0" || normalized === "false" || normalized === "no" || normalized === "off") {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
return fallback;
|
|
126
|
+
}
|
|
127
|
+
function uniq(values) {
|
|
128
|
+
return [...new Set(values)];
|
|
129
|
+
}
|
|
130
|
+
function seatbeltString(value) {
|
|
131
|
+
return `"${value.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// packages/runtime/src/control-plane/runtime/sandbox/backend-seatbelt.ts
|
|
135
|
+
class SeatbeltBackend {
|
|
136
|
+
kind = "macos-seatbelt";
|
|
137
|
+
binaryPath;
|
|
138
|
+
config;
|
|
139
|
+
ctx;
|
|
140
|
+
resolvedPaths;
|
|
141
|
+
constructor(binaryPath, config, ctx, resolvedPaths) {
|
|
142
|
+
this.binaryPath = binaryPath;
|
|
143
|
+
this.config = config;
|
|
144
|
+
this.ctx = ctx;
|
|
145
|
+
this.resolvedPaths = resolvedPaths;
|
|
146
|
+
}
|
|
147
|
+
wrap(options) {
|
|
148
|
+
const profilePath = this.writeSeatbeltProfile(options);
|
|
149
|
+
return {
|
|
150
|
+
command: [this.binaryPath, "-f", profilePath, ...options.command],
|
|
151
|
+
enabled: true,
|
|
152
|
+
backend: "macos-seatbelt",
|
|
153
|
+
profilePath
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
writeSeatbeltProfile(options) {
|
|
157
|
+
const sandboxDir = resolve3(options.runtime.rootDir, "sandbox");
|
|
158
|
+
mkdirSync(sandboxDir, { recursive: true });
|
|
159
|
+
const profilePath = resolve3(sandboxDir, "seatbelt.sb");
|
|
160
|
+
const profile = this.renderProfile(options);
|
|
161
|
+
writeFileSync(profilePath, `${profile}
|
|
162
|
+
`, "utf-8");
|
|
163
|
+
return profilePath;
|
|
164
|
+
}
|
|
165
|
+
renderProfile(options) {
|
|
166
|
+
const { runtime, projectRoot } = options;
|
|
167
|
+
const { ctx, resolvedPaths, config } = this;
|
|
168
|
+
const workspaceReal = ctx.realPath(runtime.workspaceDir);
|
|
169
|
+
const runtimeRootReal = ctx.realPath(runtime.rootDir);
|
|
170
|
+
const homeReal = ctx.realPath(runtime.homeDir);
|
|
171
|
+
const tmpReal = ctx.realPath(runtime.tmpDir);
|
|
172
|
+
const cacheReal = ctx.realPath(runtime.cacheDir);
|
|
173
|
+
const hostGitDirs = resolveHostGitMetadataPaths(projectRoot, runtime.workspaceDir);
|
|
174
|
+
const hostRepoRoots = resolveHostRepoRootPaths(projectRoot).map((repoRoot) => ctx.realPath(repoRoot));
|
|
175
|
+
const bunDir = ctx.realPath(resolvedPaths.bunDir);
|
|
176
|
+
const claudeDir = resolvedPaths.claudeDir ? ctx.realPath(resolvedPaths.claudeDir) : null;
|
|
177
|
+
const allowNetwork = resolveNetworkWithPolicy(config, process.env.RIG_RUNTIME_SANDBOX_NETWORK);
|
|
178
|
+
const lines = [
|
|
179
|
+
"(version 1)",
|
|
180
|
+
"(deny default)",
|
|
181
|
+
'(import "system.sb")',
|
|
182
|
+
"(allow process*)",
|
|
183
|
+
"(allow process-info*)",
|
|
184
|
+
"(allow signal)",
|
|
185
|
+
"(allow sysctl-read)",
|
|
186
|
+
"(allow file-read-metadata)"
|
|
187
|
+
];
|
|
188
|
+
if (allowNetwork) {
|
|
189
|
+
lines.push("(allow network*)");
|
|
190
|
+
}
|
|
191
|
+
for (const sysPath of [
|
|
192
|
+
"/usr/lib",
|
|
193
|
+
"/usr/bin",
|
|
194
|
+
"/usr/sbin",
|
|
195
|
+
"/usr/share",
|
|
196
|
+
"/bin",
|
|
197
|
+
"/sbin",
|
|
198
|
+
"/System",
|
|
199
|
+
"/Library",
|
|
200
|
+
"/Library/Frameworks",
|
|
201
|
+
"/Library/Developer",
|
|
202
|
+
"/Library/Apple",
|
|
203
|
+
"/Applications",
|
|
204
|
+
"/private/var/db",
|
|
205
|
+
"/opt/homebrew"
|
|
206
|
+
]) {
|
|
207
|
+
lines.push(`(allow file-read* (subpath ${seatbeltString(sysPath)}))`);
|
|
208
|
+
}
|
|
209
|
+
lines.push(`(allow file-read* (subpath ${seatbeltString(bunDir)}))`);
|
|
210
|
+
if (claudeDir) {
|
|
211
|
+
lines.push(`(allow file-read* (subpath ${seatbeltString(claudeDir)}))`);
|
|
212
|
+
}
|
|
213
|
+
if (resolvedPaths.nodeDir) {
|
|
214
|
+
lines.push(`(allow file-read* (subpath ${seatbeltString(resolvedPaths.nodeDir)}))`);
|
|
215
|
+
}
|
|
216
|
+
for (const depPath of resolvedPaths.depRoots) {
|
|
217
|
+
lines.push(`(allow file-read* (subpath ${seatbeltString(depPath)}))`);
|
|
218
|
+
}
|
|
219
|
+
for (const rwPath of uniq([
|
|
220
|
+
workspaceReal,
|
|
221
|
+
runtimeRootReal,
|
|
222
|
+
homeReal,
|
|
223
|
+
tmpReal,
|
|
224
|
+
cacheReal
|
|
225
|
+
])) {
|
|
226
|
+
lines.push(`(allow file-read* (subpath ${seatbeltString(rwPath)}))`);
|
|
227
|
+
lines.push(`(allow file-write* (subpath ${seatbeltString(rwPath)}))`);
|
|
228
|
+
}
|
|
229
|
+
for (const gitPath of hostGitDirs) {
|
|
230
|
+
lines.push(`(allow file-read* (subpath ${seatbeltString(gitPath)}))`);
|
|
231
|
+
lines.push(`(allow file-write* (subpath ${seatbeltString(gitPath)}))`);
|
|
232
|
+
}
|
|
233
|
+
const projectRootReal = ctx.realPath(projectRoot);
|
|
234
|
+
if (projectRootReal !== workspaceReal && !projectRootReal.startsWith(workspaceReal + "/")) {
|
|
235
|
+
lines.push(`(allow file-read* (subpath ${seatbeltString(projectRootReal)}))`);
|
|
236
|
+
}
|
|
237
|
+
for (const repoRoot of hostRepoRoots) {
|
|
238
|
+
if (!ctx.pathExists(repoRoot) || repoRoot === workspaceReal || repoRoot.startsWith(workspaceReal + "/") || repoRoot === projectRootReal || repoRoot.startsWith(projectRootReal + "/")) {
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
lines.push(`(allow file-read* (subpath ${seatbeltString(repoRoot)}))`);
|
|
242
|
+
}
|
|
243
|
+
const realHome = process.env.HOME?.trim();
|
|
244
|
+
if (realHome) {
|
|
245
|
+
for (const binSubdir of [".local/bin", ".cargo/bin"]) {
|
|
246
|
+
const binPath = resolve3(realHome, binSubdir);
|
|
247
|
+
if (ctx.pathExists(binPath)) {
|
|
248
|
+
lines.push(`(allow file-read* (subpath ${seatbeltString(ctx.realPath(binPath))}))`);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
for (const tempPath of [
|
|
253
|
+
"/dev",
|
|
254
|
+
"/tmp",
|
|
255
|
+
"/private/tmp",
|
|
256
|
+
"/var/folders",
|
|
257
|
+
"/private/var/folders"
|
|
258
|
+
]) {
|
|
259
|
+
lines.push(`(allow file-read* (subpath ${seatbeltString(tempPath)}))`);
|
|
260
|
+
lines.push(`(allow file-write* (subpath ${seatbeltString(tempPath)}))`);
|
|
261
|
+
}
|
|
262
|
+
return lines.join(`
|
|
263
|
+
`);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
export {
|
|
267
|
+
SeatbeltBackend
|
|
268
|
+
};
|