@sagentlab/navarch-runtime 0.1.175 → 0.1.176
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/dist/adapters/acp.cjs +3 -2
- package/dist/adapters/antigravity.cjs +3 -2
- package/dist/adapters/claude.cjs +4 -3
- package/dist/adapters/codex.cjs +3 -2
- package/dist/adapters/conversation-process.cjs +2 -1
- package/dist/adapters/muse.cjs +2 -1
- package/dist/adapters/opencode.cjs +3 -2
- package/dist/adapters/pi.cjs +3 -2
- package/dist/adapters/qoder.cjs +2 -1
- package/dist/git-worktree.cjs +15 -8
- package/dist/github-credential.cjs +29 -1
- package/dist/sandbox.cjs +3 -1
- package/dist/session.cjs +37 -26
- package/package.json +1 -1
package/dist/adapters/acp.cjs
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.acpAdapter = void 0;
|
|
7
7
|
exports.runAcpAdapter = runAcpAdapter;
|
|
8
8
|
exports.probeAcpSteering = probeAcpSteering;
|
|
9
|
+
const github_credential_cjs_1 = require("../github-credential.cjs");
|
|
9
10
|
const node_child_process_1 = require("node:child_process");
|
|
10
11
|
const node_fs_1 = require("node:fs");
|
|
11
12
|
const node_os_1 = __importDefault(require("node:os"));
|
|
@@ -320,7 +321,7 @@ function resolveEnvReference(value, env) {
|
|
|
320
321
|
return resolved;
|
|
321
322
|
}
|
|
322
323
|
function spawnAcpAgent(options) {
|
|
323
|
-
const env =
|
|
324
|
+
const env = (0, github_credential_cjs_1.repositoryAgentEnv)(options.env);
|
|
324
325
|
if (!options.dockerExec) {
|
|
325
326
|
return (0, node_child_process_1.spawn)(options.bin, options.extraArgs, {
|
|
326
327
|
detached: process.platform !== "win32",
|
|
@@ -406,7 +407,7 @@ async function speaksAcpV1(context) {
|
|
|
406
407
|
// No session exists yet, so an agent that writes state at startup writes it
|
|
407
408
|
// in the temporary directory, not in the runtime's working directory.
|
|
408
409
|
cwd: node_os_1.default.tmpdir(),
|
|
409
|
-
env:
|
|
410
|
+
env: (0, github_credential_cjs_1.repositoryAgentEnv)(context.env),
|
|
410
411
|
stdio: ["pipe", "pipe", "ignore"],
|
|
411
412
|
});
|
|
412
413
|
const exited = new Promise((resolve) => {
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.antigravityAdapter = exports.ANTIGRAVITY_PROCESS_WRAPPER = void 0;
|
|
7
7
|
exports.runAntigravityAdapter = runAntigravityAdapter;
|
|
8
8
|
exports.normalizeAntigravityOutput = normalizeAntigravityOutput;
|
|
9
|
+
const github_credential_cjs_1 = require("../github-credential.cjs");
|
|
9
10
|
const node_child_process_1 = require("node:child_process");
|
|
10
11
|
const node_path_1 = __importDefault(require("node:path"));
|
|
11
12
|
const node_string_decoder_1 = require("node:string_decoder");
|
|
@@ -268,7 +269,7 @@ async function runProcess(options, args, input) {
|
|
|
268
269
|
return new Promise((resolve) => {
|
|
269
270
|
let stdout = "", stderr = "", timedOut = false, killedByLeaseLoss = false;
|
|
270
271
|
const stdoutDecoder = new node_string_decoder_1.StringDecoder("utf8"), stderrDecoder = new node_string_decoder_1.StringDecoder("utf8");
|
|
271
|
-
const child = (0, node_child_process_1.spawn)(options.bin, args, { cwd: options.cwd, detached: process.platform !== "win32", env: agentEnvironment(
|
|
272
|
+
const child = (0, node_child_process_1.spawn)(options.bin, args, { cwd: options.cwd, detached: process.platform !== "win32", env: agentEnvironment((0, github_credential_cjs_1.repositoryAgentEnv)(options.env)) });
|
|
272
273
|
child.stdin?.on("error", () => undefined);
|
|
273
274
|
child.stdin?.end(input);
|
|
274
275
|
options.onProcessStarted?.(child.pid);
|
|
@@ -328,7 +329,7 @@ async function runDocker(options, args, input) {
|
|
|
328
329
|
return failure("", { exitCode: null, timedOut, killedByLeaseLoss });
|
|
329
330
|
const command = `[ -f /tmp/session.env ] && . /tmp/session.env; cd ${quote(options.cwd)} && exec ${["node", "-e", exports.ANTIGRAVITY_PROCESS_WRAPPER, options.bin, ...args].map(quote).join(" ")}`;
|
|
330
331
|
const result = await runner.run("docker", ["exec", "-i", ...Object.keys(options.env).flatMap((name) => ["--env", name]), containerName, "sh", "-c", command], {
|
|
331
|
-
input, env: agentEnvironment(
|
|
332
|
+
input, env: agentEnvironment((0, github_credential_cjs_1.repositoryAgentEnv)(options.env)), signal: abort.signal,
|
|
332
333
|
onActivity: options.onActivity, onStdout: (chunk) => options.onOutput?.("stdout", chunk), onStderr: (chunk) => options.onOutput?.("stderr", chunk),
|
|
333
334
|
});
|
|
334
335
|
await killing;
|
package/dist/adapters/claude.cjs
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.claudeCodeAdapter = void 0;
|
|
4
4
|
exports.runClaudeCodeAdapter = runClaudeCodeAdapter;
|
|
5
5
|
exports.probeClaudeSteering = probeClaudeSteering;
|
|
6
|
+
const github_credential_cjs_1 = require("../github-credential.cjs");
|
|
6
7
|
const node_child_process_1 = require("node:child_process");
|
|
7
8
|
const node_crypto_1 = require("node:crypto");
|
|
8
9
|
const exit_conditions_cjs_1 = require("../exit-conditions.cjs");
|
|
@@ -307,7 +308,7 @@ async function runOnHost(options, args) {
|
|
|
307
308
|
const child = (0, node_child_process_1.spawn)(options.bin, args, {
|
|
308
309
|
detached: process.platform !== "win32",
|
|
309
310
|
cwd: options.cwd,
|
|
310
|
-
env:
|
|
311
|
+
env: (0, github_credential_cjs_1.repositoryAgentEnv)(options.env),
|
|
311
312
|
});
|
|
312
313
|
// `claude -p` reads the whole prompt from stdin and starts at EOF. A
|
|
313
314
|
// child that exits before reading surfaces through `close`; ignore the
|
|
@@ -401,7 +402,7 @@ async function runOnHostStreaming(options, args, live) {
|
|
|
401
402
|
const child = (0, node_child_process_1.spawn)(options.bin, args, {
|
|
402
403
|
detached: process.platform !== "win32",
|
|
403
404
|
cwd: options.cwd,
|
|
404
|
-
env:
|
|
405
|
+
env: (0, github_credential_cjs_1.repositoryAgentEnv)(options.env),
|
|
405
406
|
});
|
|
406
407
|
let attached = false;
|
|
407
408
|
const detach = () => {
|
|
@@ -646,7 +647,7 @@ function readClaudeHelp(bin, env) {
|
|
|
646
647
|
clearTimeout(timer);
|
|
647
648
|
resolve(text);
|
|
648
649
|
};
|
|
649
|
-
const child = (0, node_child_process_1.spawn)(bin, ["--help"], { env:
|
|
650
|
+
const child = (0, node_child_process_1.spawn)(bin, ["--help"], { env: (0, github_credential_cjs_1.repositoryAgentEnv)(env), stdio: ["ignore", "pipe", "ignore"] });
|
|
650
651
|
const timer = setTimeout(() => {
|
|
651
652
|
child.kill("SIGKILL");
|
|
652
653
|
done("");
|
package/dist/adapters/codex.cjs
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.codexAdapter = void 0;
|
|
4
4
|
exports.runCodexAdapter = runCodexAdapter;
|
|
5
5
|
exports.hasExplicitPermissionPolicy = hasExplicitPermissionPolicy;
|
|
6
|
+
const github_credential_cjs_1 = require("../github-credential.cjs");
|
|
6
7
|
const codex_conversation_cjs_1 = require("./codex-conversation.cjs");
|
|
7
8
|
const node_child_process_1 = require("node:child_process");
|
|
8
9
|
const node_fs_1 = require("node:fs");
|
|
@@ -269,7 +270,7 @@ async function runOnHost(options, args) {
|
|
|
269
270
|
const child = (0, node_child_process_1.spawn)(options.bin, args, {
|
|
270
271
|
detached: process.platform !== "win32",
|
|
271
272
|
cwd: options.cwd,
|
|
272
|
-
env:
|
|
273
|
+
env: (0, github_credential_cjs_1.repositoryAgentEnv)(options.env),
|
|
273
274
|
});
|
|
274
275
|
// `codex exec -` reads the whole prompt from stdin and starts at EOF, so
|
|
275
276
|
// end the pipe after writing it. A child that exits before reading
|
|
@@ -339,7 +340,7 @@ async function runViaDocker(options, args) {
|
|
|
339
340
|
onStdout: (chunk) => options.onOutput?.("stdout", chunk),
|
|
340
341
|
onStderr: (chunk) => options.onOutput?.("stderr", chunk),
|
|
341
342
|
signal: options.signal,
|
|
342
|
-
env:
|
|
343
|
+
env: (0, github_credential_cjs_1.repositoryAgentEnv)(options.env),
|
|
343
344
|
});
|
|
344
345
|
return {
|
|
345
346
|
exitCode: result.code,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runConversationProcess = runConversationProcess;
|
|
4
|
+
const github_credential_cjs_1 = require("../github-credential.cjs");
|
|
4
5
|
const node_child_process_1 = require("node:child_process");
|
|
5
6
|
const node_perf_hooks_1 = require("node:perf_hooks");
|
|
6
7
|
const kill_agent_cjs_1 = require("../kill-agent.cjs");
|
|
@@ -35,7 +36,7 @@ async function runConversationProcess(options, args, makeParser) {
|
|
|
35
36
|
const child = (0, node_child_process_1.spawn)(options.bin, args, {
|
|
36
37
|
detached: process.platform !== "win32",
|
|
37
38
|
cwd: options.cwd,
|
|
38
|
-
env: options.env,
|
|
39
|
+
env: (0, github_credential_cjs_1.repositoryAgentEnv)(options.env, {}),
|
|
39
40
|
stdio: ["pipe", "pipe", "pipe"],
|
|
40
41
|
});
|
|
41
42
|
child.stdin?.on("error", () => undefined);
|
package/dist/adapters/muse.cjs
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.museAdapter = exports.MUSE_HOST_GUARD_MESSAGE = void 0;
|
|
7
7
|
exports.runMuseAdapter = runMuseAdapter;
|
|
8
8
|
exports.sumMuseSessionCost = sumMuseSessionCost;
|
|
9
|
+
const github_credential_cjs_1 = require("../github-credential.cjs");
|
|
9
10
|
const node_child_process_1 = require("node:child_process");
|
|
10
11
|
const node_fs_1 = require("node:fs");
|
|
11
12
|
const node_path_1 = __importDefault(require("node:path"));
|
|
@@ -461,7 +462,7 @@ async function readMcpServers(configPath, env) {
|
|
|
461
462
|
return result;
|
|
462
463
|
}
|
|
463
464
|
function spawnMuse(options) {
|
|
464
|
-
const env =
|
|
465
|
+
const env = (0, github_credential_cjs_1.repositoryAgentEnv)(options.env);
|
|
465
466
|
delete env.MUSE_PERMISSION_PROFILE_FAIL_OPEN;
|
|
466
467
|
const args = ["serve", ...options.extraArgs];
|
|
467
468
|
if (!options.dockerExec)
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.openCodeAdapter = void 0;
|
|
7
7
|
exports.runOpenCodeAdapter = runOpenCodeAdapter;
|
|
8
8
|
exports.resetOpenCodeLogLevelCache = resetOpenCodeLogLevelCache;
|
|
9
|
+
const github_credential_cjs_1 = require("../github-credential.cjs");
|
|
9
10
|
const node_child_process_1 = require("node:child_process");
|
|
10
11
|
const node_fs_1 = require("node:fs");
|
|
11
12
|
const node_os_1 = __importDefault(require("node:os"));
|
|
@@ -423,7 +424,7 @@ async function runOnHost(options, args, input = "") {
|
|
|
423
424
|
const child = (0, node_child_process_1.spawn)(options.bin, args, {
|
|
424
425
|
detached: process.platform !== "win32",
|
|
425
426
|
cwd: options.cwd,
|
|
426
|
-
env:
|
|
427
|
+
env: (0, github_credential_cjs_1.repositoryAgentEnv)(options.env),
|
|
427
428
|
});
|
|
428
429
|
let capacityError;
|
|
429
430
|
const monitor = capacityMonitor((detail) => {
|
|
@@ -505,7 +506,7 @@ async function runViaDocker(options, args, input) {
|
|
|
505
506
|
signal: controller.signal,
|
|
506
507
|
onStdout: (chunk) => { streamed.stdout = true; monitor.push("stdout", chunk); options.onOutput?.("stdout", chunk); },
|
|
507
508
|
onStderr: (chunk) => { streamed.stderr = true; monitor.push("stderr", chunk); options.onOutput?.("stderr", chunk); },
|
|
508
|
-
env:
|
|
509
|
+
env: (0, github_credential_cjs_1.repositoryAgentEnv)(options.env),
|
|
509
510
|
});
|
|
510
511
|
// Also inspect runners that only return buffered output.
|
|
511
512
|
if (!streamed.stdout)
|
package/dist/adapters/pi.cjs
CHANGED
|
@@ -11,6 +11,7 @@ exports.parsePiJsonEvents = parsePiJsonEvents;
|
|
|
11
11
|
exports.attachPiOutput = attachPiOutput;
|
|
12
12
|
exports.runPiAdapter = runPiAdapter;
|
|
13
13
|
exports.runOnHost = runOnHost;
|
|
14
|
+
const github_credential_cjs_1 = require("../github-credential.cjs");
|
|
14
15
|
const node_child_process_1 = require("node:child_process");
|
|
15
16
|
const node_fs_1 = require("node:fs");
|
|
16
17
|
const node_os_1 = __importDefault(require("node:os"));
|
|
@@ -326,7 +327,7 @@ async function runOnHost(options, args, local = false) {
|
|
|
326
327
|
const child = (0, node_child_process_1.spawn)(options.bin, boundedArgs, {
|
|
327
328
|
detached: process.platform !== "win32",
|
|
328
329
|
cwd: options.cwd,
|
|
329
|
-
env:
|
|
330
|
+
env: (0, github_credential_cjs_1.repositoryAgentEnv)(env),
|
|
330
331
|
});
|
|
331
332
|
// Ignore EPIPE from a child that exits before reading; `close` reports it.
|
|
332
333
|
child.stdin?.on("error", () => undefined);
|
|
@@ -416,7 +417,7 @@ async function runViaDocker(options, args) {
|
|
|
416
417
|
onStdout: (chunk) => options.onOutput?.("stdout", chunk),
|
|
417
418
|
onStderr: (chunk) => options.onOutput?.("stderr", chunk),
|
|
418
419
|
signal: options.signal,
|
|
419
|
-
env:
|
|
420
|
+
env: (0, github_credential_cjs_1.repositoryAgentEnv)(options.env),
|
|
420
421
|
});
|
|
421
422
|
return {
|
|
422
423
|
exitCode: result.code,
|
package/dist/adapters/qoder.cjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.qoderAdapter = void 0;
|
|
4
4
|
exports.runQoderAdapter = runQoderAdapter;
|
|
5
|
+
const github_credential_cjs_1 = require("../github-credential.cjs");
|
|
5
6
|
const node_child_process_1 = require("node:child_process");
|
|
6
7
|
const exit_conditions_cjs_1 = require("../exit-conditions.cjs");
|
|
7
8
|
const kill_agent_cjs_1 = require("../kill-agent.cjs");
|
|
@@ -83,7 +84,7 @@ async function runOnHost(options, args) {
|
|
|
83
84
|
const child = (0, node_child_process_1.spawn)(options.bin, args, {
|
|
84
85
|
detached: process.platform !== "win32",
|
|
85
86
|
cwd: options.cwd,
|
|
86
|
-
env:
|
|
87
|
+
env: (0, github_credential_cjs_1.repositoryAgentEnv)(options.env),
|
|
87
88
|
});
|
|
88
89
|
// `qoder -p` reads the whole prompt from stdin and starts at EOF. A child
|
|
89
90
|
// that exits before reading surfaces through `close`; ignore the EPIPE.
|
package/dist/git-worktree.cjs
CHANGED
|
@@ -7,6 +7,7 @@ exports.GitWorktree = void 0;
|
|
|
7
7
|
exports.proxyCloneUrl = proxyCloneUrl;
|
|
8
8
|
exports.branchSlug = branchSlug;
|
|
9
9
|
exports.hostedCheckpointRef = hostedCheckpointRef;
|
|
10
|
+
const github_credential_cjs_1 = require("./github-credential.cjs");
|
|
10
11
|
const node_path_1 = __importDefault(require("node:path"));
|
|
11
12
|
const abort_cjs_1 = require("./abort.cjs");
|
|
12
13
|
const worktree_janitor_cjs_1 = require("./worktree-janitor.cjs");
|
|
@@ -61,6 +62,7 @@ class GitWorktree {
|
|
|
61
62
|
seedRepositoryPath;
|
|
62
63
|
cloneUrl;
|
|
63
64
|
githubToken;
|
|
65
|
+
credentialUsername;
|
|
64
66
|
githubTokenProvider;
|
|
65
67
|
repoLocalTokenInstalled = false;
|
|
66
68
|
gitGrant;
|
|
@@ -118,14 +120,15 @@ class GitWorktree {
|
|
|
118
120
|
this.runner = options.runner ?? sandbox_cjs_1.nodeCommandRunner;
|
|
119
121
|
this.authRetryDelaysMs = options.authRetryDelaysMs ?? DEFAULT_AUTH_RETRY_DELAYS_MS;
|
|
120
122
|
this.sleep = options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
121
|
-
this.
|
|
122
|
-
this.
|
|
123
|
-
|
|
123
|
+
this.credentialUsername = options.credentialUsername;
|
|
124
|
+
this.gitGrant = options.credentialUsername !== undefined ? undefined : options.gitGrant;
|
|
125
|
+
this.cloneUrl = this.gitGrant
|
|
126
|
+
? proxyCloneUrl(options.cloneUrl, this.gitGrant.proxyBaseUrl)
|
|
124
127
|
: options.cloneUrl;
|
|
125
|
-
this.githubToken =
|
|
126
|
-
this.githubTokenProvider =
|
|
128
|
+
this.githubToken = this.gitGrant ? undefined : options.githubToken;
|
|
129
|
+
this.githubTokenProvider = this.gitGrant ? undefined : options.githubTokenProvider;
|
|
127
130
|
this.workingBranch = options.workingBranch?.trim() || null;
|
|
128
|
-
this.repoLocalGithubToken = options.repoLocalGithubToken;
|
|
131
|
+
this.repoLocalGithubToken = options.credentialUsername !== undefined ? undefined : options.repoLocalGithubToken;
|
|
129
132
|
this.prContinuation = options.prContinuation ?? false;
|
|
130
133
|
this.ownershipCommitIdentity = options.ownershipCommitIdentity ?? { name: "Navarch", email: "runtime@navarch.local" };
|
|
131
134
|
this.hostedCheckpointRef = options.restoreHostedCheckpoint ? hostedCheckpointRef(options.taskId) : null;
|
|
@@ -896,13 +899,17 @@ class GitWorktree {
|
|
|
896
899
|
"-c",
|
|
897
900
|
"credential.helper=",
|
|
898
901
|
"-c",
|
|
899
|
-
|
|
902
|
+
this.credentialUsername !== undefined
|
|
903
|
+
? `credential.helper=${github_credential_cjs_1.REPOSITORY_CREDENTIAL_HELPER}`
|
|
904
|
+
: 'credential.helper=!f() { echo username=x-access-token; echo "password=$GITHUB_TOKEN"; }; f',
|
|
900
905
|
]
|
|
901
906
|
: [];
|
|
902
907
|
const result = await this.runner.run("git", [...credentialArgs, ...args], {
|
|
903
908
|
...options,
|
|
904
909
|
env: githubToken
|
|
905
|
-
?
|
|
910
|
+
? this.credentialUsername !== undefined
|
|
911
|
+
? { ...gitEnvWithoutGithubTokens(), ...(0, github_credential_cjs_1.repositoryCredentialEnv)(this.credentialUsername, githubToken), GIT_TERMINAL_PROMPT: "0" }
|
|
912
|
+
: { ...process.env, GITHUB_TOKEN: githubToken, GIT_TERMINAL_PROMPT: "0" }
|
|
906
913
|
: { ...process.env, GIT_TERMINAL_PROMPT: "0" },
|
|
907
914
|
});
|
|
908
915
|
if (result.code !== 0) {
|
|
@@ -3,8 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.GithubTokenFileRefresher = exports.GITHUB_TOKEN_FILENAME = exports.GITHUB_TOKEN_FILE_RETRY_MS = exports.GITHUB_TOKEN_FILE_REFRESH_MS = exports.GITHUB_CREDENTIAL_SECRET_NAME = void 0;
|
|
6
|
+
exports.REPOSITORY_CREDENTIAL_HELPER = exports.GithubTokenFileRefresher = exports.GITHUB_TOKEN_FILENAME = exports.GITHUB_TOKEN_FILE_RETRY_MS = exports.GITHUB_TOKEN_FILE_REFRESH_MS = exports.GITHUB_CREDENTIAL_SECRET_NAME = void 0;
|
|
7
7
|
exports.githubCredentialDenialSummary = githubCredentialDenialSummary;
|
|
8
|
+
exports.repositoryCloneUrl = repositoryCloneUrl;
|
|
9
|
+
exports.repositoryCredentialEnv = repositoryCredentialEnv;
|
|
10
|
+
exports.repositoryAgentEnv = repositoryAgentEnv;
|
|
8
11
|
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
9
12
|
const node_path_1 = __importDefault(require("node:path"));
|
|
10
13
|
const git_grant_cjs_1 = require("./git-grant.cjs");
|
|
@@ -139,3 +142,28 @@ class GithubTokenFileRefresher {
|
|
|
139
142
|
}
|
|
140
143
|
}
|
|
141
144
|
exports.GithubTokenFileRefresher = GithubTokenFileRefresher;
|
|
145
|
+
/** Resolve the repository URL without a GitHub fallback for Codeup leases. */
|
|
146
|
+
function repositoryCloneUrl(repository, repo) {
|
|
147
|
+
if (repository?.credential_username !== undefined && !repository.clone_url) {
|
|
148
|
+
throw new Error("codeup_clone_url_missing: repository.clone_url is required");
|
|
149
|
+
}
|
|
150
|
+
return repository?.clone_url ?? (repo ? `https://github.com/${repo.replace(/\.git$/, "")}.git` : null);
|
|
151
|
+
}
|
|
152
|
+
/** Codeup credentials use dedicated env names, never GitHub token aliases. */
|
|
153
|
+
exports.REPOSITORY_CREDENTIAL_HELPER = '!f() { printf "%s\\n" "username=$NAVARCH_GIT_CREDENTIAL_USERNAME" "password=$NAVARCH_GIT_CREDENTIAL_TOKEN"; }; f';
|
|
154
|
+
function repositoryCredentialEnv(username, token) {
|
|
155
|
+
if (!username || /[\r\n\0]/.test(username))
|
|
156
|
+
throw new Error("invalid_repository_credential_username");
|
|
157
|
+
if (/[\r\n\0]/.test(token))
|
|
158
|
+
throw new Error("invalid_repository_credential_token");
|
|
159
|
+
return { NAVARCH_GIT_CREDENTIAL_USERNAME: username, NAVARCH_GIT_CREDENTIAL_TOKEN: token };
|
|
160
|
+
}
|
|
161
|
+
/** Merge per-session auth without inheriting GitHub credentials for Codeup. */
|
|
162
|
+
function repositoryAgentEnv(overrides, parent = process.env) {
|
|
163
|
+
const env = { ...parent, ...overrides };
|
|
164
|
+
if (overrides.NAVARCH_GIT_CREDENTIAL_USERNAME !== undefined) {
|
|
165
|
+
delete env.GH_TOKEN;
|
|
166
|
+
delete env.GITHUB_TOKEN;
|
|
167
|
+
}
|
|
168
|
+
return env;
|
|
169
|
+
}
|
package/dist/sandbox.cjs
CHANGED
|
@@ -216,7 +216,9 @@ class DockerSandbox {
|
|
|
216
216
|
* running anything that needs the values.
|
|
217
217
|
*/
|
|
218
218
|
async injectEnv(env) {
|
|
219
|
-
const
|
|
219
|
+
const codeup = env.NAVARCH_GIT_CREDENTIAL_USERNAME !== undefined;
|
|
220
|
+
const lines = (codeup ? "unset GH_TOKEN GITHUB_TOKEN\n" : "") + Object.entries(env)
|
|
221
|
+
.filter(([name]) => !codeup || (name !== "GH_TOKEN" && name !== "GITHUB_TOKEN"))
|
|
220
222
|
.map(([k, v]) => `export ${k}=${shellQuote(v)}`)
|
|
221
223
|
.join("\n");
|
|
222
224
|
const result = await this.runner.run("docker", ["exec", "-i", this.name, "sh", "-c", "cat > /tmp/session.env"], { input: lines });
|
package/dist/session.cjs
CHANGED
|
@@ -128,7 +128,7 @@ async function runSession(deps, claimed, sessionId) {
|
|
|
128
128
|
// explicit pre-start signal. Otherwise it waits for expiry and bypasses
|
|
129
129
|
// the repeat/backoff policy entirely.
|
|
130
130
|
const { api, config } = deps;
|
|
131
|
-
const { lease_id: leaseId
|
|
131
|
+
const { lease_id: leaseId } = claimed;
|
|
132
132
|
const runtime = claimed.runtime ?? config.agentType;
|
|
133
133
|
const execution = resolveSessionExecution(config, claimed);
|
|
134
134
|
const crashDetail = describeCompletionError(err).slice(0, 1800);
|
|
@@ -195,6 +195,9 @@ async function runClaimedSession(deps, claimed, sessionId, lifecycle) {
|
|
|
195
195
|
// otherwise the grant endpoint decides (409 git_proxy_disabled = mode off).
|
|
196
196
|
// The runtime parent fetches and refreshes the grant; the agent never sees
|
|
197
197
|
// the machine token or a GitHub token in these modes.
|
|
198
|
+
const credentialUsername = bundle.repository?.credential_username;
|
|
199
|
+
const codeup = credentialUsername !== undefined;
|
|
200
|
+
const cloneUrl = (0, github_credential_cjs_1.repositoryCloneUrl)(bundle.repository, task.repo);
|
|
198
201
|
const bundleGitMode = bundle.repository?.git_proxy_mode;
|
|
199
202
|
// Codex's worktree guard is an OS sandbox around the whole agent, git's
|
|
200
203
|
// credential helper included: it denies the session dir and allows only
|
|
@@ -205,7 +208,7 @@ async function runClaimedSession(deps, claimed, sessionId, lifecycle) {
|
|
|
205
208
|
const credentialConsumer = {};
|
|
206
209
|
let gitGrantRefresher;
|
|
207
210
|
let gitGrantEnv;
|
|
208
|
-
if (bundleGitMode !== "off") {
|
|
211
|
+
if (!codeup && bundleGitMode !== "off") {
|
|
209
212
|
const grantPaths = (0, git_grant_cjs_1.gitGrantPaths)(workDir);
|
|
210
213
|
const refresher = new git_grant_cjs_1.GitGrantRefresher({
|
|
211
214
|
api,
|
|
@@ -275,7 +278,7 @@ async function runClaimedSession(deps, claimed, sessionId, lifecycle) {
|
|
|
275
278
|
}
|
|
276
279
|
}
|
|
277
280
|
let gitCredentialRefresh;
|
|
278
|
-
if (!gitGrantMode && managedGithubCredential && secrets["github-pat"]) {
|
|
281
|
+
if (!codeup && !gitGrantMode && managedGithubCredential && secrets["github-pat"]) {
|
|
279
282
|
await node_fs_1.promises.mkdir(gitCredentialDir, { recursive: true, mode: 0o700 });
|
|
280
283
|
const helperPath = node_path_1.default.join(gitCredentialDir, GIT_CREDENTIAL_HELPER_FILENAME);
|
|
281
284
|
await node_fs_1.promises.copyFile(node_path_1.default.resolve(__dirname, "../bin/git-credential-navarch.cjs"), helperPath);
|
|
@@ -289,7 +292,7 @@ async function runClaimedSession(deps, claimed, sessionId, lifecycle) {
|
|
|
289
292
|
await githubTokenRefresher.start(secrets["github-pat"]);
|
|
290
293
|
gitCredentialRefresh = { helperPath, tokenFile };
|
|
291
294
|
}
|
|
292
|
-
const sessionEnv = toEnvMap(secrets, gitCredentialRefresh, config.gitAuthorName, config.gitAuthorEmail, gitGrantEnv);
|
|
295
|
+
const sessionEnv = toEnvMap(secrets, gitCredentialRefresh, config.gitAuthorName, config.gitAuthorEmail, gitGrantEnv, codeup ? { username: credentialUsername, secretName: bundle.repository.credential_secret_name } : undefined);
|
|
293
296
|
// Proxied projects (CX-3.7): the control-plane identity replaces the
|
|
294
297
|
// NAVARCH_GIT_AUTHOR_* default for this session; mode `off` sends none.
|
|
295
298
|
const commitIdentity = (0, commit_attribution_cjs_1.parseCommitIdentity)(bundle.repository?.commit_identity);
|
|
@@ -313,8 +316,6 @@ async function runClaimedSession(deps, claimed, sessionId, lifecycle) {
|
|
|
313
316
|
sessionEnv.GITHUB_TOKEN = "";
|
|
314
317
|
sessionEnv.GH_TOKEN = "";
|
|
315
318
|
}
|
|
316
|
-
const cloneUrl = bundle.repository?.clone_url ??
|
|
317
|
-
(task.repo ? `https://github.com/${task.repo.replace(/\.git$/, "")}.git` : null);
|
|
318
319
|
if (!cloneUrl) {
|
|
319
320
|
const failureSummary = `Project ${task.project_id} has no GitHub repository URL. Set it in Project settings before dispatching work.`;
|
|
320
321
|
await api.completeLease(leaseId, {
|
|
@@ -360,12 +361,13 @@ async function runClaimedSession(deps, claimed, sessionId, lifecycle) {
|
|
|
360
361
|
} } : {}),
|
|
361
362
|
cloneUrl,
|
|
362
363
|
githubToken,
|
|
364
|
+
credentialUsername,
|
|
363
365
|
githubTokenProvider: githubTokenRefresher ? () => githubTokenRefresher.current : undefined,
|
|
364
366
|
workingBranch: bundle.repository?.working_branch,
|
|
365
367
|
deliveryBinding,
|
|
366
368
|
// Grant modes never expose a GitHub token, so the Codex repo-local
|
|
367
369
|
// github-pat bootstrap is not installed.
|
|
368
|
-
repoLocalGithubToken: gitGrantMode ? undefined : secrets["github-pat"],
|
|
370
|
+
repoLocalGithubToken: codeup || gitGrantMode ? undefined : secrets["github-pat"],
|
|
369
371
|
gitGrant: gitGrantEnv
|
|
370
372
|
? {
|
|
371
373
|
proxyBaseUrl: gitGrantEnv.proxyBaseUrl,
|
|
@@ -393,7 +395,7 @@ async function runClaimedSession(deps, claimed, sessionId, lifecycle) {
|
|
|
393
395
|
if (!sha || !/^[a-f0-9]{40}$/i.test(sha))
|
|
394
396
|
throw new Error("Invalid QA run commit");
|
|
395
397
|
for (const args of [["fetch", "origin", sha], ["checkout", "--detach", sha]]) {
|
|
396
|
-
const result = await sandbox_cjs_1.nodeCommandRunner.run("git", args, { cwd: gitWorktree.worktreePath, env:
|
|
398
|
+
const result = await sandbox_cjs_1.nodeCommandRunner.run("git", args, { cwd: gitWorktree.worktreePath, env: (0, github_credential_cjs_1.repositoryAgentEnv)(sessionEnv), signal });
|
|
397
399
|
if (result.code !== 0)
|
|
398
400
|
throw new Error("QA run commit checkout failed");
|
|
399
401
|
}
|
|
@@ -631,7 +633,7 @@ async function runClaimedSession(deps, claimed, sessionId, lifecycle) {
|
|
|
631
633
|
if (issued.length > 0) {
|
|
632
634
|
const merged = (0, user_mcp_servers_cjs_1.mergeUserMcpServers)(sessionMcpConfig, issued, {
|
|
633
635
|
runtime,
|
|
634
|
-
existingEnv:
|
|
636
|
+
existingEnv: (0, github_credential_cjs_1.repositoryAgentEnv)(sessionEnv),
|
|
635
637
|
envReferenced: runtime === "opencode",
|
|
636
638
|
});
|
|
637
639
|
registry.registerAll(merged.secretValues);
|
|
@@ -833,7 +835,7 @@ async function runClaimedSession(deps, claimed, sessionId, lifecycle) {
|
|
|
833
835
|
gitCredentialDir,
|
|
834
836
|
...(gitGrantEnv ? [(0, git_grant_cjs_1.gitGrantPaths)(workDir).dir] : []),
|
|
835
837
|
],
|
|
836
|
-
networkHosts: gitGrantEnv ? [gitGrantEnv.proxyHost] : [],
|
|
838
|
+
networkHosts: codeup ? [new URL(cloneUrl).hostname] : gitGrantEnv ? [gitGrantEnv.proxyHost] : [],
|
|
837
839
|
});
|
|
838
840
|
}
|
|
839
841
|
const restoredCheckpoint = gitWorktree.restoredHostedCheckpoint;
|
|
@@ -1269,20 +1271,21 @@ async function runClaimedSession(deps, claimed, sessionId, lifecycle) {
|
|
|
1269
1271
|
log.warn(`worktree HEAD lookup failed for ${leaseId}: ${String(err)}`);
|
|
1270
1272
|
}
|
|
1271
1273
|
let pullRequestUrl = null;
|
|
1272
|
-
let pullRequestLookupFailed =
|
|
1274
|
+
let pullRequestLookupFailed = codeup;
|
|
1273
1275
|
try {
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1276
|
+
if (!codeup)
|
|
1277
|
+
pullRequestUrl = await (0, github_pr_cjs_1.findHeadBranchPullRequestUrl)({
|
|
1278
|
+
repository: bundle.repository?.full_name ?? task.repo,
|
|
1279
|
+
headBranch,
|
|
1280
|
+
headSha,
|
|
1281
|
+
// Keep SHA verification on the exact branch, but do not adopt a
|
|
1282
|
+
// foreign-branch PR as delivery evidence for a root task.
|
|
1283
|
+
allowShaFallback: allowBranchRename,
|
|
1284
|
+
githubToken: gitGrantMode ? gitGrantRefresher?.current?.grant : githubTokenRefresher?.current ?? githubToken,
|
|
1285
|
+
// Grant modes read through the proxy and never use the host's own gh login.
|
|
1286
|
+
apiBaseUrl: gitGrantEnv ? `${gitGrantEnv.proxyBaseUrl.replace(/\/+$/, "")}/api/v3` : undefined,
|
|
1287
|
+
hostTokenProvider: gitGrantMode ? async () => undefined : undefined,
|
|
1288
|
+
});
|
|
1286
1289
|
if (pullRequestUrl)
|
|
1287
1290
|
mapping.evidenceUrls.push(pullRequestUrl);
|
|
1288
1291
|
}
|
|
@@ -1792,7 +1795,7 @@ function gitGrantCredentialHelper(config) {
|
|
|
1792
1795
|
/** Secret names (lowercased, non-alphanumerics as `_`) that are raw GitHub credentials. */
|
|
1793
1796
|
const GITHUB_CREDENTIAL_SECRETS = new Set(["github_pat", "github_token", "gh_token"]);
|
|
1794
1797
|
/** Uppercases + sanitizes secret names into shell-safe env var names for injectEnv(). */
|
|
1795
|
-
function toEnvMap(secrets, credentialRefreshOrAuthorName, gitAuthorNameOrEmail = "sagentlab", gitAuthorEmail = "z@sagentlab.com", gitGrant) {
|
|
1798
|
+
function toEnvMap(secrets, credentialRefreshOrAuthorName, gitAuthorNameOrEmail = "sagentlab", gitAuthorEmail = "z@sagentlab.com", gitGrant, repositoryCredential) {
|
|
1796
1799
|
// Keep the existing `(secrets, authorName, authorEmail)` call shape while
|
|
1797
1800
|
// accepting a refresh config before the author identity for managed repos.
|
|
1798
1801
|
const gitCredentialRefresh = typeof credentialRefreshOrAuthorName === "string"
|
|
@@ -1806,7 +1809,7 @@ function toEnvMap(secrets, credentialRefreshOrAuthorName, gitAuthorNameOrEmail =
|
|
|
1806
1809
|
: gitAuthorEmail;
|
|
1807
1810
|
const out = {};
|
|
1808
1811
|
for (const [name, value] of Object.entries(secrets)) {
|
|
1809
|
-
if (gitGrant && GITHUB_CREDENTIAL_SECRETS.has(name.toLowerCase().replace(/[^a-z0-9]/g, "_")))
|
|
1812
|
+
if ((gitGrant || repositoryCredential) && GITHUB_CREDENTIAL_SECRETS.has(name.toLowerCase().replace(/[^a-z0-9]/g, "_")))
|
|
1810
1813
|
continue;
|
|
1811
1814
|
out[name.toUpperCase().replace(/[^A-Z0-9_]/g, "_")] = value;
|
|
1812
1815
|
}
|
|
@@ -1835,7 +1838,15 @@ function toEnvMap(secrets, credentialRefreshOrAuthorName, gitAuthorNameOrEmail =
|
|
|
1835
1838
|
["user.name", gitAuthorName],
|
|
1836
1839
|
["user.email", resolvedGitAuthorEmail],
|
|
1837
1840
|
];
|
|
1838
|
-
if (
|
|
1841
|
+
if (repositoryCredential) {
|
|
1842
|
+
const token = secrets[repositoryCredential.secretName];
|
|
1843
|
+
if (!token)
|
|
1844
|
+
throw new Error("repository_credential_missing");
|
|
1845
|
+
Object.assign(out, (0, github_credential_cjs_1.repositoryCredentialEnv)(repositoryCredential.username, token));
|
|
1846
|
+
out.GIT_TERMINAL_PROMPT = "0";
|
|
1847
|
+
gitConfig.unshift(["credential.helper", ""], ["credential.helper", github_credential_cjs_1.REPOSITORY_CREDENTIAL_HELPER]);
|
|
1848
|
+
}
|
|
1849
|
+
if (!repositoryCredential && secrets["github-pat"] && (!out.GITHUB_TOKEN || (gitCredentialRefresh && "tokenFile" in gitCredentialRefresh))) {
|
|
1839
1850
|
out.GITHUB_TOKEN = secrets["github-pat"];
|
|
1840
1851
|
if (gitCredentialRefresh) {
|
|
1841
1852
|
if ("tokenFile" in gitCredentialRefresh) {
|
package/package.json
CHANGED