@juanbenjumea/pi-agy 0.6.9 → 0.6.10
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/CHANGELOG.md +6 -0
- package/extensions/lib/cli.ts +10 -7
- package/extensions/lib/stream.ts +14 -7
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.10
|
|
4
|
+
|
|
5
|
+
- Validate terminal status only after finalizing the complete captured result, so pretty-printed top-level JSON errors cannot bypass 0.6.9's fail-closed status handling.
|
|
6
|
+
- Recover one bounded trailing root JSON envelope after earlier lifecycle or diagnostic records, preserving terminal status, error, and conversation identity before cancellation, exit-code, or completed-response precedence is decided.
|
|
7
|
+
- Add compact and multiline top-level error regression coverage; independent review found zero blockers and the full 201-test gate passes.
|
|
8
|
+
|
|
3
9
|
## 0.6.9
|
|
4
10
|
|
|
5
11
|
- Fail closed on agy terminal result statuses: only `SUCCESS` and `OK` are accepted when a status is present. `ERROR`, `FAILURE`, `CANCELLED`, `TIMEOUT`, empty, malformed, and unknown statuses now reject even when agy includes `response: ""` and exits with code 0.
|
package/extensions/lib/cli.ts
CHANGED
|
@@ -1164,20 +1164,24 @@ function spawnAgyInternal(
|
|
|
1164
1164
|
runResult = processStreamLine(lineBuffer, runResult, onProgress);
|
|
1165
1165
|
}
|
|
1166
1166
|
|
|
1167
|
+
// Finalization also parses whole top-level JSON envelopes, including
|
|
1168
|
+
// pretty-printed output that cannot be consumed one line at a time.
|
|
1169
|
+
const finalized = finalizeRunResult(out, runResult);
|
|
1170
|
+
|
|
1167
1171
|
// Terminal status is authoritative when present. agy can emit an
|
|
1168
1172
|
// ERROR envelope with response: "" and even exit 0; response
|
|
1169
1173
|
// completeness must never turn that failed turn into success.
|
|
1170
|
-
const terminalFailure = terminalFailureMessage(
|
|
1174
|
+
const terminalFailure = terminalFailureMessage(finalized, err);
|
|
1171
1175
|
if (terminalFailure) {
|
|
1172
|
-
reject(withConversationId(terminalFailure,
|
|
1176
|
+
reject(withConversationId(terminalFailure, finalized));
|
|
1173
1177
|
return;
|
|
1174
1178
|
}
|
|
1175
1179
|
|
|
1176
1180
|
// A fully delivered successful result outranks the kill: when
|
|
1177
1181
|
// cancellation or timeout lands after the response arrived, the work
|
|
1178
1182
|
// is done and the response must not be discarded.
|
|
1179
|
-
if (
|
|
1180
|
-
resolve(
|
|
1183
|
+
if (finalized.response_complete) {
|
|
1184
|
+
resolve(finalized);
|
|
1181
1185
|
return;
|
|
1182
1186
|
}
|
|
1183
1187
|
|
|
@@ -1185,7 +1189,7 @@ function spawnAgyInternal(
|
|
|
1185
1189
|
reject(
|
|
1186
1190
|
withConversationId(
|
|
1187
1191
|
signal.aborted && !timedOut ? "agy was cancelled" : "agy timed out",
|
|
1188
|
-
|
|
1192
|
+
finalized,
|
|
1189
1193
|
),
|
|
1190
1194
|
);
|
|
1191
1195
|
return;
|
|
@@ -1193,13 +1197,12 @@ function spawnAgyInternal(
|
|
|
1193
1197
|
|
|
1194
1198
|
if (code !== 0) {
|
|
1195
1199
|
const detail = (err || out).slice(0, 2000).trim();
|
|
1196
|
-
reject(withConversationId(`agy exited with code ${code}:\n${detail || "(no output)"}`,
|
|
1200
|
+
reject(withConversationId(`agy exited with code ${code}:\n${detail || "(no output)"}`, finalized));
|
|
1197
1201
|
return;
|
|
1198
1202
|
}
|
|
1199
1203
|
|
|
1200
1204
|
// agy writes diagnostics to stderr even on successful runs. Keep it
|
|
1201
1205
|
// out of the response so JSON/stream parsing remains deterministic.
|
|
1202
|
-
const finalized = finalizeRunResult(out, runResult);
|
|
1203
1206
|
// Only responses served verbatim from the bounded raw capture can be
|
|
1204
1207
|
// incomplete; anything parsed from a record was delivered in full.
|
|
1205
1208
|
if (stdoutTruncated && !finalized.response_complete) {
|
package/extensions/lib/stream.ts
CHANGED
|
@@ -289,15 +289,22 @@ export function finalizeRunResult(rawStdout: string, current: AgyRunResult): Agy
|
|
|
289
289
|
}
|
|
290
290
|
}
|
|
291
291
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
292
|
+
const trimmed = rawStdout.trim();
|
|
293
|
+
const trailingRoot = trimmed.lastIndexOf("\n{");
|
|
294
|
+
const candidates = trailingRoot >= 0
|
|
295
|
+
? [trimmed, trimmed.slice(trailingRoot + 1)]
|
|
296
|
+
: [trimmed];
|
|
297
|
+
for (const candidate of candidates) {
|
|
298
|
+
try {
|
|
299
|
+
const parsed: unknown = JSON.parse(candidate);
|
|
300
|
+
const next = mergeJsonEnvelope(parsed, current);
|
|
301
|
+
if (next) return next;
|
|
302
|
+
} catch {
|
|
303
|
+
// Try the bounded trailing root object after earlier stream records.
|
|
304
|
+
}
|
|
298
305
|
}
|
|
299
306
|
|
|
300
|
-
return { ...current, response:
|
|
307
|
+
return { ...current, response: trimmed || "(empty response)" };
|
|
301
308
|
}
|
|
302
309
|
|
|
303
310
|
/** Preserve metadata from agy's non-stream JSON envelope when available. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juanbenjumea/pi-agy",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.10",
|
|
4
4
|
"description": "Reliable Antigravity delegation for Pi — quota-aware runs, resumable tasks, repo verification, cancellation, and trustworthy diff summaries.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|