@sagentlab/navarch-runtime 0.1.19 → 0.1.20

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 CHANGED
@@ -290,9 +290,16 @@ unchanged across the deployment.
290
290
  ## Worktree boundary guard (host mode)
291
291
 
292
292
  A machine typically runs several sessions concurrently (`NAVARCH_MAX_SESSIONS`),
293
- each in its own git worktree. The runtime enforces the same boundary for both
293
+ each in its own git worktree. The runtime enforces the same boundary for all
294
294
  supported coding agents, using each CLI's native enforcement point:
295
295
 
296
+ Every adapter receives an empty, session-owned `GH_CONFIG_DIR` and, when the
297
+ project supplies GitHub credentials, the lease-scoped `GITHUB_TOKEN`. This
298
+ keeps `gh` independent of the operator's selected account and prevents tasks
299
+ from reading unrelated GitHub credentials. Docker already mounts the session
300
+ metadata directory; Gemini's nested host sandbox receives the `gh` directory
301
+ as an explicit read-only mount.
302
+
296
303
  - **Claude Code:** the runtime uses `--permission-mode auto`, which sends
297
304
  approval decisions through Claude Code's background safety classifier. It
298
305
  does not blanket-preapprove the lease-scoped Navarch MCP tools. A generated
@@ -307,19 +314,17 @@ supported coding agents, using each CLI's native enforcement point:
307
314
  Codex's OS sandbox grants read/write access only to the allowed roots and
308
315
  denies the surrounding multi-session workspace. Its network policy allows
309
316
  GitHub and GitHub-hosted content so authenticated `gh` and git operations
310
- required by the task stay inside the sandbox. `gh` reads from an empty,
311
- session-owned `GH_CONFIG_DIR` and authenticates with the lease-scoped token,
312
- so the operator's GitHub configuration and unrelated credentials remain
313
- inaccessible. Other destinations remain blocked and eligible escalations
314
- are decided by the automatic reviewer rather than waiting for human input.
317
+ required by the task stay inside the sandbox. Other destinations remain
318
+ blocked and eligible escalations are decided by the automatic reviewer
319
+ rather than waiting for human input.
315
320
  `--ignore-user-config` and an untrusted project-config override prevent a
316
321
  user or checked-in legacy `sandbox_mode` from silently disabling the
317
322
  generated profile; Codex authentication still comes from `CODEX_HOME`, and
318
323
  repository instructions such as `AGENTS.md` still load.
319
324
  - **Gemini:** the runtime uses Gemini CLI's native sandbox with only the
320
- current worktree, shared gitdir, and approved extra roots mounted. The
321
- lease MCP config is translated to a read-only temporary settings file;
322
- header values remain environment-variable references rather than literals.
325
+ current worktree, shared gitdir, session `gh` config, and approved extra
326
+ roots mounted. The `gh` config and lease MCP settings are read-only; header
327
+ values remain environment-variable references rather than literals.
323
328
  Docker-mode sessions disable Gemini's implicit YOLO sandbox to avoid nesting
324
329
  it inside Navarch's already isolated session container.
325
330
 
package/dist/session.cjs CHANGED
@@ -96,6 +96,9 @@ async function runSession(deps, claimed, sessionId) {
96
96
  };
97
97
  }
98
98
  const sessionEnv = toEnvMap(secrets, gitCredentialRefresh, config.gitAuthorName, config.gitAuthorEmail);
99
+ const ghConfigDir = (0, worktree_guard_cjs_1.sessionGhConfigDir)(workDir);
100
+ await node_fs_1.promises.mkdir(ghConfigDir, { recursive: true, mode: 0o700 });
101
+ sessionEnv.GH_CONFIG_DIR = ghConfigDir;
99
102
  const cloneUrl = bundle.repository?.clone_url ??
100
103
  (task.repo ? `https://github.com/${task.repo.replace(/\.git$/, "")}.git` : null);
101
104
  if (!cloneUrl) {
@@ -242,9 +245,6 @@ async function runSession(deps, claimed, sessionId) {
242
245
  }
243
246
  }
244
247
  else if (runtime === "codex") {
245
- const ghConfigDir = (0, worktree_guard_cjs_1.codexGhConfigDir)(workDir);
246
- await node_fs_1.promises.mkdir(ghConfigDir, { recursive: true, mode: 0o700 });
247
- sessionEnv.GH_CONFIG_DIR = ghConfigDir;
248
248
  codexGuardArgs = (0, worktree_guard_cjs_1.codexWorktreeGuardArgs)({
249
249
  workDir,
250
250
  worktreePath: gitWorktree.worktreePath,
@@ -7,14 +7,14 @@ exports.guardHookScriptPath = guardHookScriptPath;
7
7
  exports.readClaudeApiKeyHelper = readClaudeApiKeyHelper;
8
8
  exports.prepareWorktreeGuard = prepareWorktreeGuard;
9
9
  exports.codexToolReadRoots = codexToolReadRoots;
10
- exports.codexGhConfigDir = codexGhConfigDir;
10
+ exports.sessionGhConfigDir = sessionGhConfigDir;
11
11
  exports.codexWorktreeGuardArgs = codexWorktreeGuardArgs;
12
12
  exports.geminiSandboxMounts = geminiSandboxMounts;
13
13
  const node_path_1 = __importDefault(require("node:path"));
14
14
  const node_fs_1 = require("node:fs");
15
15
  const node_os_1 = __importDefault(require("node:os"));
16
16
  const CODEX_GUARD_PROFILE = "navarch-worktree";
17
- const CODEX_GH_CONFIG_DIRNAME = "gh-config";
17
+ const SESSION_GH_CONFIG_DIRNAME = "gh-config";
18
18
  const CODEX_GITHUB_NETWORK_DOMAINS = {
19
19
  "**.github.com": "allow",
20
20
  "**.githubusercontent.com": "allow",
@@ -129,15 +129,15 @@ function codexToolReadRoots(env = process.env) {
129
129
  ];
130
130
  }
131
131
  /**
132
- * Isolated gh configuration root for one Codex session.
132
+ * Isolated gh configuration root for one coding-agent session.
133
133
  *
134
134
  * `gh` reads its config file before it considers `GITHUB_TOKEN`. Pointing it
135
135
  * at this empty, session-owned directory lets the CLI use the lease token
136
136
  * without granting the agent read access to the operator's ~/.config/gh,
137
137
  * which may contain unrelated account credentials.
138
138
  */
139
- function codexGhConfigDir(workDir) {
140
- return node_path_1.default.join(workDir, CODEX_GH_CONFIG_DIRNAME);
139
+ function sessionGhConfigDir(workDir) {
140
+ return node_path_1.default.join(workDir, SESSION_GH_CONFIG_DIRNAME);
141
141
  }
142
142
  /**
143
143
  * Builds one-off Codex permission-profile arguments for a host session.
@@ -161,7 +161,7 @@ function codexWorktreeGuardArgs(options) {
161
161
  [node_path_1.default.resolve(options.workspaceRoot)]: "deny",
162
162
  [node_path_1.default.resolve(options.worktreePath)]: "write",
163
163
  [node_path_1.default.resolve(options.repositoryPath)]: "write",
164
- [codexGhConfigDir(options.workDir)]: "read",
164
+ [sessionGhConfigDir(options.workDir)]: "read",
165
165
  };
166
166
  for (const root of codexToolReadRoots()) {
167
167
  const resolved = node_path_1.default.resolve(root);
@@ -204,8 +204,9 @@ function codexWorktreeGuardArgs(options) {
204
204
  }
205
205
  /**
206
206
  * Mounts only the current session roots into Gemini CLI's native sandbox.
207
- * Gemini mounts cwd itself; explicit same-path mounts keep the shared gitdir
208
- * and approved external roots reachable without exposing sibling sessions.
207
+ * Gemini mounts cwd itself; explicit same-path mounts keep the shared gitdir,
208
+ * isolated gh config, and approved external roots reachable without exposing
209
+ * sibling sessions.
209
210
  */
210
211
  function geminiSandboxMounts(options) {
211
212
  const workspaceRoot = node_path_1.default.resolve(options.workspaceRoot);
@@ -215,7 +216,9 @@ function geminiSandboxMounts(options) {
215
216
  if (!isPathInside(resolved, workspaceRoot))
216
217
  roots.push(resolved);
217
218
  }
218
- return [...new Set(roots.map((root) => node_path_1.default.resolve(root)))].map((root) => `${root}:${root}:rw`);
219
+ const writableMounts = [...new Set(roots.map((root) => node_path_1.default.resolve(root)))].map((root) => `${root}:${root}:rw`);
220
+ const ghConfigDir = sessionGhConfigDir(options.workDir);
221
+ return [...writableMounts, `${ghConfigDir}:${ghConfigDir}:ro`];
219
222
  }
220
223
  function isPathInside(candidate, root) {
221
224
  const relative = node_path_1.default.relative(root, candidate);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sagentlab/navarch-runtime",
3
- "version": "0.1.19",
3
+ "version": "0.1.20",
4
4
  "description": "Navarch machine-side session manager: claims delivery tasks and runs them through Claude Code, Codex, or Gemini CLI.",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",