@sagentlab/navarch-runtime 0.1.55 → 0.1.56
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/exit-conditions.cjs +22 -1
- package/package.json +1 -1
package/dist/exit-conditions.cjs
CHANGED
|
@@ -6,6 +6,7 @@ exports.parseCodexJsonEvents = parseCodexJsonEvents;
|
|
|
6
6
|
exports.extractUsageFromCodexEvents = extractUsageFromCodexEvents;
|
|
7
7
|
exports.extractFinalMessageFromCodexEvents = extractFinalMessageFromCodexEvents;
|
|
8
8
|
exports.leadingVerificationVerdict = leadingVerificationVerdict;
|
|
9
|
+
exports.leadWithReviewFixMarker = leadWithReviewFixMarker;
|
|
9
10
|
exports.mapExitCondition = mapExitCondition;
|
|
10
11
|
/**
|
|
11
12
|
* Best-effort parse of `claude -p --output-format json` stdout into the
|
|
@@ -201,6 +202,26 @@ function leadingVerificationVerdict(report) {
|
|
|
201
202
|
const match = /^Verification verdict:\s*(PASS|FAIL|BLOCKED)\b/i.exec(firstLine ?? "");
|
|
202
203
|
return match?.[1] ? match[1].toLowerCase() : null;
|
|
203
204
|
}
|
|
205
|
+
const REVIEW_FIX_MARKER_LINE = /^[ \t]*Review fix delivered: [a-f0-9]{40}(?=\s|$)/im;
|
|
206
|
+
/**
|
|
207
|
+
* Moves a `Review fix delivered: <sha>` line to the top of the report. The
|
|
208
|
+
* control plane (lib/navarch/review-fix-marker.ts) accepts the marker at the
|
|
209
|
+
* start of any line, but summarize() collapses whitespace and truncates, so a
|
|
210
|
+
* marker below a sentence of preamble ends up mid-sentence or cut off and the
|
|
211
|
+
* review fix is rejected. Kept in step with leadWithReviewFixMarker there;
|
|
212
|
+
* this package cannot import it. A report without a marker is unchanged.
|
|
213
|
+
*/
|
|
214
|
+
function leadWithReviewFixMarker(report) {
|
|
215
|
+
const marker = REVIEW_FIX_MARKER_LINE.exec(report);
|
|
216
|
+
if (!marker || !report.slice(0, marker.index).trim())
|
|
217
|
+
return report;
|
|
218
|
+
const lineEnd = report.indexOf("\n", marker.index);
|
|
219
|
+
const line = report.slice(marker.index, lineEnd === -1 ? undefined : lineEnd).trim();
|
|
220
|
+
const rest = (report.slice(0, marker.index) + (lineEnd === -1 ? "" : report.slice(lineEnd + 1)))
|
|
221
|
+
.replace(/\n{3,}/g, "\n\n")
|
|
222
|
+
.trim();
|
|
223
|
+
return rest ? `${line}\n\n${rest}` : line;
|
|
224
|
+
}
|
|
204
225
|
function summarize(text, maxLen = 500) {
|
|
205
226
|
const trimmed = text.trim();
|
|
206
227
|
if (!trimmed)
|
|
@@ -292,7 +313,7 @@ function mapExitCondition(result) {
|
|
|
292
313
|
// falls back to raw stdout when neither is available (see
|
|
293
314
|
// parseClaudeJsonResult's doc comment).
|
|
294
315
|
const reportText = result.reportText ?? parsedJson?.result ?? result.stdout;
|
|
295
|
-
const reportSummary = summarize(reportText) || "Adapter completed with no report text.";
|
|
316
|
+
const reportSummary = summarize(leadWithReviewFixMarker(reportText)) || "Adapter completed with no report text.";
|
|
296
317
|
// A verify agent's FAIL/BLOCKED verdict is a successful agent run whose
|
|
297
318
|
// conclusion is that the delivery did not pass. The completion API only
|
|
298
319
|
// accepts those verdicts with a failed outcome, so map them to a failed
|
package/package.json
CHANGED