@sagentlab/navarch-runtime 0.1.180 → 0.1.182
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/delivery.cjs +28 -0
- package/dist/git-worktree.cjs +11 -0
- package/dist/session.cjs +31 -9
- package/package.json +1 -1
package/dist/delivery.cjs
CHANGED
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
// gate existed. A verification mechanism that fails good sessions when its own
|
|
22
22
|
// dependency is unavailable is worse than no mechanism.
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.codeupBuildStopLine = codeupBuildStopLine;
|
|
25
|
+
exports.evaluateCodeupDelivery = evaluateCodeupDelivery;
|
|
24
26
|
exports.captureDeliveryBaseline = captureDeliveryBaseline;
|
|
25
27
|
exports.probeWorktreeDelivery = probeWorktreeDelivery;
|
|
26
28
|
exports.evaluateDelivery = evaluateDelivery;
|
|
@@ -29,6 +31,32 @@ exports.renderResumedDeliveryCorrectionPrompt = renderResumedDeliveryCorrectionP
|
|
|
29
31
|
const sandbox_cjs_1 = require("./sandbox.cjs");
|
|
30
32
|
const prompt_cjs_1 = require("./prompt.cjs");
|
|
31
33
|
const GIT_TIMEOUT_MS = 30_000;
|
|
34
|
+
/** Match the root-build stop markers accepted by lib/navarch/build-outcome.ts. */
|
|
35
|
+
function codeupBuildStopLine(report) {
|
|
36
|
+
return report.split(/\r?\n/).map((line) => line.trim()).find((line) => /^Build outcome:[*_`~]*\s*[*_`~]*(?:SUPERSEDED|PLATFORM[ _-]CONFIG)(?![a-z0-9])/i.test(line.replace(/^(?:#{1,6}\s+|>\s*|[*_`~]+\s*)+/, "")));
|
|
37
|
+
}
|
|
38
|
+
async function evaluateCodeupDelivery(probe, requiredBranch) {
|
|
39
|
+
if (probe.dirty) {
|
|
40
|
+
return { status: "incomplete", reason: "the worktree still has uncommitted changes" };
|
|
41
|
+
}
|
|
42
|
+
if (!requiredBranch)
|
|
43
|
+
return { status: "no_changes" };
|
|
44
|
+
const { name, headSha, readRemoteTip } = requiredBranch;
|
|
45
|
+
if (!headSha) {
|
|
46
|
+
return { status: "incomplete", reason: `the local HEAD of Codeup task branch \`${name}\` could not be resolved` };
|
|
47
|
+
}
|
|
48
|
+
let remoteSha;
|
|
49
|
+
try {
|
|
50
|
+
remoteSha = await readRemoteTip();
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return { status: "incomplete", reason: `the remote tip of Codeup task branch \`${name}\` could not be read` };
|
|
54
|
+
}
|
|
55
|
+
if (remoteSha !== headSha.toLowerCase()) {
|
|
56
|
+
return { status: "incomplete", reason: `push Codeup task branch \`${name}\` to origin so it points to local HEAD ${headSha}` };
|
|
57
|
+
}
|
|
58
|
+
return { status: "branch_delivered", evidence: `Pushed branch: ${name}\nPushed commit: ${remoteSha}` };
|
|
59
|
+
}
|
|
32
60
|
/** Empty ownership commits carry no task changes and may disappear on rebase. */
|
|
33
61
|
async function captureDeliveryBaseline(worktreePath, runner = sandbox_cjs_1.nodeCommandRunner) {
|
|
34
62
|
const read = async (...args) => {
|
package/dist/git-worktree.cjs
CHANGED
|
@@ -805,6 +805,17 @@ class GitWorktree {
|
|
|
805
805
|
}
|
|
806
806
|
return { branch: this.branch, sha: head.sha };
|
|
807
807
|
}
|
|
808
|
+
/** Read the allocated branch on the repository configured for this lease. */
|
|
809
|
+
async readRemoteTaskBranchTip() {
|
|
810
|
+
const ref = `refs/heads/${this.branch}`;
|
|
811
|
+
const { stdout } = await this.runGit(["-C", this.worktreePath, "ls-remote", "--refs", this.cloneUrl, ref], true, { timeoutMs: 30_000 });
|
|
812
|
+
for (const line of stdout.trimEnd().split("\n")) {
|
|
813
|
+
const [sha, name] = line.split("\t");
|
|
814
|
+
if (name === ref && sha && /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/i.test(sha))
|
|
815
|
+
return sha.toLowerCase();
|
|
816
|
+
}
|
|
817
|
+
return null;
|
|
818
|
+
}
|
|
808
819
|
/** Save recoverable code, never the repository config or broker credentials. */
|
|
809
820
|
async saveCheckpoint() {
|
|
810
821
|
await node_fs_1.promises.mkdir(this.checkpointRoot, { recursive: true, mode: 0o700 });
|
package/dist/session.cjs
CHANGED
|
@@ -81,7 +81,7 @@ function resolveSessionExecution(config, claimed) {
|
|
|
81
81
|
const runtime = claimed.runtime ?? config.agentType;
|
|
82
82
|
const execution = claimed.context_bundle.execution ?? {
|
|
83
83
|
profile: claimed.task.execution_profile ?? "standard",
|
|
84
|
-
model: runtime === "codex" ? "gpt-6-
|
|
84
|
+
model: runtime === "codex" ? "gpt-6.2-sol"
|
|
85
85
|
: runtime === "pi-local" ? "qwen3.8-flash-next-iq2_xs"
|
|
86
86
|
: runtime === "gemini" ? "auto"
|
|
87
87
|
: runtime === "antigravity" || runtime === "opencode" || runtime === "acp" || runtime === "qoder" || runtime === "muse" ? "default"
|
|
@@ -200,6 +200,8 @@ async function runClaimedSession(deps, claimed, sessionId, lifecycle) {
|
|
|
200
200
|
// the machine token or a GitHub token in these modes.
|
|
201
201
|
const credentialUsername = bundle.repository?.credential_username;
|
|
202
202
|
const codeup = credentialUsername !== undefined;
|
|
203
|
+
const codeupBuild = codeup && task.task_type === "build" && !task.review_of_task_id &&
|
|
204
|
+
(task.deliverable_kind == null || task.deliverable_kind === "code" || task.deliverable_kind === "video");
|
|
203
205
|
const cloneUrl = (0, github_credential_cjs_1.repositoryCloneUrl)(bundle.repository, task.repo);
|
|
204
206
|
const bundleGitMode = bundle.repository?.git_proxy_mode;
|
|
205
207
|
// Codex's worktree guard is an OS sandbox around the whole agent, git's
|
|
@@ -974,7 +976,7 @@ async function runClaimedSession(deps, claimed, sessionId, lifecycle) {
|
|
|
974
976
|
const resumedTask = { id: task.id, summary: task.summary };
|
|
975
977
|
let completionRemediationRetries = 0;
|
|
976
978
|
let deliveryCorrectionRetries = 0;
|
|
977
|
-
let
|
|
979
|
+
let delivered = false;
|
|
978
980
|
let antigravityResume;
|
|
979
981
|
let museSessionId;
|
|
980
982
|
while (true) {
|
|
@@ -1283,7 +1285,7 @@ async function runClaimedSession(deps, claimed, sessionId, lifecycle) {
|
|
|
1283
1285
|
log.warn(`worktree HEAD lookup failed for ${leaseId}: ${String(err)}`);
|
|
1284
1286
|
}
|
|
1285
1287
|
let pullRequestUrl = null;
|
|
1286
|
-
let pullRequestLookupFailed =
|
|
1288
|
+
let pullRequestLookupFailed = false;
|
|
1287
1289
|
try {
|
|
1288
1290
|
if (!codeup)
|
|
1289
1291
|
pullRequestUrl = await (0, github_pr_cjs_1.findHeadBranchPullRequestUrl)({
|
|
@@ -1333,7 +1335,7 @@ async function runClaimedSession(deps, claimed, sessionId, lifecycle) {
|
|
|
1333
1335
|
try {
|
|
1334
1336
|
const probe = await (0, delivery_cjs_1.probeWorktreeDelivery)({
|
|
1335
1337
|
worktreePath: gitWorktree.worktreePath,
|
|
1336
|
-
baseRef: await gitWorktree.resolveDeliveryBase(),
|
|
1338
|
+
baseRef: codeup ? undefined : await gitWorktree.resolveDeliveryBase(),
|
|
1337
1339
|
claimBaselineSha: deliveryBaselineSha,
|
|
1338
1340
|
// A verify or review agent may check the reviewed PR's head out,
|
|
1339
1341
|
// onto its task branch or the PR's own branch. Those commits are
|
|
@@ -1346,12 +1348,32 @@ async function runClaimedSession(deps, claimed, sessionId, lifecycle) {
|
|
|
1346
1348
|
? { inheritRemoteCommitsExcept: gitWorktree.branch }
|
|
1347
1349
|
: {}),
|
|
1348
1350
|
});
|
|
1349
|
-
|
|
1351
|
+
if (codeup) {
|
|
1352
|
+
const stopLine = codeupBuild ? (0, delivery_cjs_1.codeupBuildStopLine)(previousTurnReport()) : undefined;
|
|
1353
|
+
delivery = await (0, delivery_cjs_1.evaluateCodeupDelivery)(probe, codeupBuild && !stopLine ? {
|
|
1354
|
+
name: gitWorktree.branch,
|
|
1355
|
+
headSha: headBranch === gitWorktree.branch ? headSha : undefined,
|
|
1356
|
+
readRemoteTip: () => gitWorktree.readRemoteTaskBranchTip(),
|
|
1357
|
+
} : undefined);
|
|
1358
|
+
if (delivery.status === "branch_delivered") {
|
|
1359
|
+
// The control plane parses these lines before storing the summary.
|
|
1360
|
+
mapping.reportSummary = `${delivery.evidence}\n\n${mapping.reportSummary}`;
|
|
1361
|
+
}
|
|
1362
|
+
else if (stopLine && delivery.status === "no_changes") {
|
|
1363
|
+
mapping.reportSummary = `${stopLine.slice(0, 500)}\n\n${mapping.reportSummary}`;
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
else {
|
|
1367
|
+
delivery = (0, delivery_cjs_1.evaluateDelivery)({ ...probe, pullRequestUrl, pullRequestLookupFailed }, deliveryBinding);
|
|
1368
|
+
}
|
|
1350
1369
|
}
|
|
1351
1370
|
catch (err) {
|
|
1352
|
-
delivery = {
|
|
1371
|
+
delivery = {
|
|
1372
|
+
status: deliveryBinding || codeupBuild ? "incomplete" : "unknown",
|
|
1373
|
+
reason: `the delivery probe failed: ${String(err)}`,
|
|
1374
|
+
};
|
|
1353
1375
|
}
|
|
1354
|
-
|
|
1376
|
+
delivered = delivery.status === "delivered" || delivery.status === "branch_delivered";
|
|
1355
1377
|
if (delivery.status === "unknown") {
|
|
1356
1378
|
log.warn(`delivery for ${leaseId} could not be verified: ${delivery.reason}; completing anyway.`);
|
|
1357
1379
|
}
|
|
@@ -1479,8 +1501,8 @@ async function runClaimedSession(deps, claimed, sessionId, lifecycle) {
|
|
|
1479
1501
|
completingLease = true;
|
|
1480
1502
|
if (await sendCompletion() === "steering_turn")
|
|
1481
1503
|
continue;
|
|
1482
|
-
if (
|
|
1483
|
-
// The
|
|
1504
|
+
if (delivered && completion.status === "completed" && gitWorktree.restoredHostedCheckpoint) {
|
|
1505
|
+
// The remote carries the hosted attempt's work now; a later
|
|
1484
1506
|
// hosted attempt must not resume the stale snapshot.
|
|
1485
1507
|
await gitWorktree.deleteRestoredHostedCheckpoint().catch((err) => {
|
|
1486
1508
|
log.warn(`hosted checkpoint cleanup failed for ${leaseId}: ${(0, redact_cjs_1.redactText)(String(err), knownSecrets)}`);
|
package/package.json
CHANGED