@sagentlab/navarch-runtime 0.1.159 → 0.1.160
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 +24 -3
- package/dist/prompt.cjs +1 -0
- package/dist/session.cjs +11 -0
- package/package.json +1 -1
package/dist/delivery.cjs
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
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.captureDeliveryBaseline = captureDeliveryBaseline;
|
|
24
25
|
exports.probeWorktreeDelivery = probeWorktreeDelivery;
|
|
25
26
|
exports.evaluateDelivery = evaluateDelivery;
|
|
26
27
|
exports.renderDeliveryCorrectionPrompt = renderDeliveryCorrectionPrompt;
|
|
@@ -28,6 +29,26 @@ exports.renderResumedDeliveryCorrectionPrompt = renderResumedDeliveryCorrectionP
|
|
|
28
29
|
const sandbox_cjs_1 = require("./sandbox.cjs");
|
|
29
30
|
const prompt_cjs_1 = require("./prompt.cjs");
|
|
30
31
|
const GIT_TIMEOUT_MS = 30_000;
|
|
32
|
+
/** Empty ownership commits carry no task changes and may disappear on rebase. */
|
|
33
|
+
async function captureDeliveryBaseline(worktreePath, runner = sandbox_cjs_1.nodeCommandRunner) {
|
|
34
|
+
const read = async (...args) => {
|
|
35
|
+
const result = await runner.run("git", ["-C", worktreePath, ...args], { timeoutMs: GIT_TIMEOUT_MS });
|
|
36
|
+
if (result.code !== 0)
|
|
37
|
+
throw new Error("Cannot capture delivery baseline");
|
|
38
|
+
return result.stdout.trim();
|
|
39
|
+
};
|
|
40
|
+
const head = await read("rev-parse", "HEAD");
|
|
41
|
+
if (await read("show", "-s", "--format=%s", "HEAD") === "chore(navarch): claim task branch") {
|
|
42
|
+
const parents = (await read("rev-list", "--parents", "-n", "1", "HEAD")).split(/\s+/).slice(1);
|
|
43
|
+
const parent = parents[0];
|
|
44
|
+
if (parents.length === 1 && parent) {
|
|
45
|
+
const trees = (await read("rev-parse", "HEAD^{tree}", "HEAD^1^{tree}")).split("\n");
|
|
46
|
+
if (trees.length === 2 && trees[0] === trees[1])
|
|
47
|
+
return parent;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return head;
|
|
51
|
+
}
|
|
31
52
|
/**
|
|
32
53
|
* Reads the worktree's delivery state.
|
|
33
54
|
*
|
|
@@ -65,12 +86,12 @@ async function probeWorktreeDelivery(args) {
|
|
|
65
86
|
const [branchRaw, statusRaw, aheadRaw, unpushedRaw] = await Promise.all([
|
|
66
87
|
git(["rev-parse", "--abbrev-ref", "HEAD"]),
|
|
67
88
|
git(["status", "--porcelain"]),
|
|
68
|
-
args.baseRef
|
|
69
|
-
? git(["rev-list", "--count", "--full-history", `${args.baseRef}..HEAD`, "--", "."])
|
|
89
|
+
(args.claimBaselineSha ?? args.baseRef)
|
|
90
|
+
? git(["rev-list", "--count", "--full-history", `${args.claimBaselineSha ?? args.baseRef}..HEAD`, "--", "."])
|
|
70
91
|
: Promise.resolve(null),
|
|
71
92
|
// Commits no origin ref carries. Independent of the base ref, so it still
|
|
72
93
|
// answers "was this pushed?" when the base cannot be resolved at all.
|
|
73
|
-
git(["rev-list", "--count", "--full-history", "HEAD", "--not", "--remotes=origin", "--", "."]),
|
|
94
|
+
git(["rev-list", "--count", "--full-history", "HEAD", ...(args.claimBaselineSha ? [`^${args.claimBaselineSha}`] : []), "--not", "--remotes=origin", "--", "."]),
|
|
74
95
|
]);
|
|
75
96
|
const branch = branchRaw?.trim() ?? "";
|
|
76
97
|
return {
|
package/dist/prompt.cjs
CHANGED
|
@@ -50,6 +50,7 @@ function renderPrompt(task, bundle) {
|
|
|
50
50
|
}
|
|
51
51
|
const sections = [];
|
|
52
52
|
sections.push(`# Task: ${task.summary}`);
|
|
53
|
+
sections.push(`Delivery contract: ${task.deliverable_kind ?? "code"}`);
|
|
53
54
|
sections.push(`Type: ${task.task_type} | Repo: ${task.repo} | Environment: ${task.environment_scope}`);
|
|
54
55
|
sections.push(PROCESS_GUIDANCE);
|
|
55
56
|
if (bundle.repository) {
|
package/dist/session.cjs
CHANGED
|
@@ -478,6 +478,7 @@ async function runClaimedSession(deps, claimed, sessionId, lifecycle) {
|
|
|
478
478
|
log.warn(`checkpoint failed for ${leaseId}: ${String(error)}; retaining ${gitWorktree.worktreePath} for recovery.`);
|
|
479
479
|
}
|
|
480
480
|
};
|
|
481
|
+
let deliveryBaselineSha;
|
|
481
482
|
const pollLease = () => {
|
|
482
483
|
if (leaseLost || sessionClosing)
|
|
483
484
|
return Promise.resolve();
|
|
@@ -750,6 +751,15 @@ async function runClaimedSession(deps, claimed, sessionId, lifecycle) {
|
|
|
750
751
|
}
|
|
751
752
|
steering?.start();
|
|
752
753
|
await gitWorktree.prepare();
|
|
754
|
+
// Capture once before agent work. The server returns the first baseline
|
|
755
|
+
// after a restart, so a retry cannot relabel inherited commits as output.
|
|
756
|
+
if (claimed.delivery_baseline_required) {
|
|
757
|
+
const initialHead = await (0, delivery_cjs_1.captureDeliveryBaseline)(gitWorktree.worktreePath);
|
|
758
|
+
const baseline = await api.heartbeatLease(leaseId, { delivery_baseline_sha: initialHead });
|
|
759
|
+
if (!baseline.delivery_baseline_sha)
|
|
760
|
+
throw new Error("The control plane did not persist the required delivery baseline");
|
|
761
|
+
deliveryBaselineSha = baseline.delivery_baseline_sha;
|
|
762
|
+
}
|
|
753
763
|
const { browserUse, playwrightSuites } = (0, browser_evidence_cjs_1.navarchBrowserTools)({
|
|
754
764
|
taskType: task.task_type, requiredCapabilities: task.required_capabilities, runtime,
|
|
755
765
|
platform: process.platform, sandboxMode: config.sandboxMode, mcpConfigPath: config.mcpConfigPath,
|
|
@@ -1271,6 +1281,7 @@ async function runClaimedSession(deps, claimed, sessionId, lifecycle) {
|
|
|
1271
1281
|
const probe = await (0, delivery_cjs_1.probeWorktreeDelivery)({
|
|
1272
1282
|
worktreePath: gitWorktree.worktreePath,
|
|
1273
1283
|
baseRef: await gitWorktree.resolveDeliveryBase(),
|
|
1284
|
+
claimBaselineSha: deliveryBaselineSha,
|
|
1274
1285
|
});
|
|
1275
1286
|
delivery = (0, delivery_cjs_1.evaluateDelivery)({ ...probe, pullRequestUrl, pullRequestLookupFailed });
|
|
1276
1287
|
}
|
package/package.json
CHANGED