@juanbenjumea/pi-agy 0.6.7 → 0.6.9
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 +14 -0
- package/README.md +10 -1
- package/extensions/lib/cli.ts +56 -5
- package/extensions/lib/stream.ts +33 -1
- package/package.json +5 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.9
|
|
4
|
+
|
|
5
|
+
- 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.
|
|
6
|
+
- Preserve terminal status/error metadata from both stream-json result events and top-level JSON envelopes. Failed status takes precedence over response completeness and delivered-result cancellation handling, while status-absent legacy output remains compatible.
|
|
7
|
+
- Keep terminal diagnostics bounded and control-safe, append bounded stderr so canonical `AGY_ERROR` retryability remains available, and retain conversation IDs on failure for resumable recovery.
|
|
8
|
+
- Add nested/top-level, `SUCCESS`/`OK`, failed/unknown/empty/malformed, exit-zero, and conversation-continuity regression coverage.
|
|
9
|
+
|
|
10
|
+
## 0.6.8
|
|
11
|
+
|
|
12
|
+
- Keep agy's internal `--print-timeout` five seconds behind Pi's hard parent deadline. agy 1.1.28+ returns partial output with exit code 0 when its own timeout fires, so Pi must win the race to classify the run as timed out and preserve resumable-conversation guidance.
|
|
13
|
+
- Recognize agy 1.2.6+ structured `AGY_ERROR` records with a top-level `retryable` boolean while retaining legacy status-text matching. Strict whole-line JSON parsing rejects malformed and user-controlled lookalikes, and canonical `retryable: false` overrides legacy patterns such as `429`.
|
|
14
|
+
- Add `npm run test:live`, an opt-in, zero-inference smoke for the installed CLI version, stable model aliases, custom-agent roster, quota schema, and doctor integration; refresh compile/test dependencies to Pi 0.86.1.
|
|
15
|
+
- Make CI and releases deterministic with `npm ci`, clean-tree and package checks, and isolate npm OIDC permissions in a publish-only job that runs only after unprivileged verification succeeds.
|
|
16
|
+
|
|
3
17
|
## 0.6.7
|
|
4
18
|
|
|
5
19
|
- Add custom-agent discovery health to `/agy doctor` using the same bounded, read-only `agy agents` path as `agy_agents` and `/agy agents`.
|
package/README.md
CHANGED
|
@@ -42,7 +42,11 @@ Auth is unchanged: existing `agy` OAuth (`~/.gemini/oauth_creds.json`).
|
|
|
42
42
|
`timeout_ms` (default 5m, max 10m) is a hard parent-side deadline — lock
|
|
43
43
|
waits, preflight probes, and post-run summaries all count against it. When
|
|
44
44
|
it fires, the full agy process group is killed so nested tools cannot
|
|
45
|
-
outlive the run.
|
|
45
|
+
outlive the run. agy's own `--print-timeout` is set five seconds later because
|
|
46
|
+
agy 1.1.28+ returns partial output with exit code 0 when that internal timer
|
|
47
|
+
fires; Pi therefore remains the authoritative timeout owner. Terminal result
|
|
48
|
+
envelopes also fail closed: when agy supplies a status, only `SUCCESS` and `OK`
|
|
49
|
+
are accepted, even if a failed result carries an empty response and exits 0.
|
|
46
50
|
|
|
47
51
|
Active tool updates show bounded intent (for example a tool action or async
|
|
48
52
|
threshold) but never echo full command lines, which may contain secrets.
|
|
@@ -207,6 +211,11 @@ npm test
|
|
|
207
211
|
npm run typecheck
|
|
208
212
|
```
|
|
209
213
|
|
|
214
|
+
With an installed, authenticated `agy`, run `npm run test:live` to verify the
|
|
215
|
+
CLI version, stable model catalog, custom-agent roster, quota schema, and doctor
|
|
216
|
+
integration against the real binary. The smoke uses read-only commands only and
|
|
217
|
+
does not start an inference turn or spend model tokens.
|
|
218
|
+
|
|
210
219
|
## License
|
|
211
220
|
|
|
212
221
|
MIT
|
package/extensions/lib/cli.ts
CHANGED
|
@@ -90,6 +90,10 @@ export interface AgyOptions {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
const PREFLIGHT_TIMEOUT_MS = 10_000;
|
|
93
|
+
// agy >= 1.1.28 returns partial output with exit 0 when its own print timeout
|
|
94
|
+
// fires. Keep that timeout behind Pi's hard parent deadline (and its 2s kill
|
|
95
|
+
// escalation) so a timed-out partial response can never be reported as success.
|
|
96
|
+
const PRINT_TIMEOUT_BUFFER_MS = 5_000;
|
|
93
97
|
// Raw stdout capture bound; only the non-streaming/parse-failure fallback —
|
|
94
98
|
// the stream-json path accumulates results incrementally and is not capped by
|
|
95
99
|
// it. Large enough that plain-text fallbacks rarely truncate.
|
|
@@ -236,9 +240,29 @@ export function supportsAgyEffort(model?: AgyModel, tier?: AgyOptions["tier"]):
|
|
|
236
240
|
const TRANSIENT_FAILURE_PATTERN =
|
|
237
241
|
/rate.?limit|resource[_ -]?exhausted|429|overloaded|temporarily unavailable|network|connection (reset|refused)|econnreset|etimedout|socket hang up|\b50[023]\b/i;
|
|
238
242
|
|
|
243
|
+
function parseStructuredRetryability(message: string): boolean | undefined {
|
|
244
|
+
for (const line of message.split(/\r?\n/)) {
|
|
245
|
+
const match = line.match(/^\s*AGY_ERROR:\s*(\{.*\})\s*$/);
|
|
246
|
+
if (!match) continue;
|
|
247
|
+
try {
|
|
248
|
+
const parsed: unknown = JSON.parse(match[1]);
|
|
249
|
+
if (
|
|
250
|
+
typeof parsed === "object" &&
|
|
251
|
+
parsed !== null &&
|
|
252
|
+
typeof (parsed as { retryable?: unknown }).retryable === "boolean"
|
|
253
|
+
) {
|
|
254
|
+
return (parsed as { retryable: boolean }).retryable;
|
|
255
|
+
}
|
|
256
|
+
} catch {
|
|
257
|
+
// Malformed structured diagnostics fall back to legacy text matching.
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return undefined;
|
|
261
|
+
}
|
|
262
|
+
|
|
239
263
|
/** Heuristic for transient agy failures that are safe to retry once. */
|
|
240
264
|
export function isTransientAgyFailure(message: string): boolean {
|
|
241
|
-
return TRANSIENT_FAILURE_PATTERN.test(message);
|
|
265
|
+
return parseStructuredRetryability(message) ?? TRANSIENT_FAILURE_PATTERN.test(message);
|
|
242
266
|
}
|
|
243
267
|
|
|
244
268
|
const MAX_AGENT_NAME_LENGTH = 128;
|
|
@@ -294,7 +318,7 @@ export function buildAgyArgs(options: AgyOptions): string[] {
|
|
|
294
318
|
|
|
295
319
|
const model = resolveAgyModelId(options.model, options.tier);
|
|
296
320
|
const agent = normalizeAgyAgentName(options.agent);
|
|
297
|
-
const timeoutSec = Math.ceil(options.timeout_ms / 1000);
|
|
321
|
+
const timeoutSec = Math.ceil((options.timeout_ms + PRINT_TIMEOUT_BUFFER_MS) / 1000);
|
|
298
322
|
const mode = options.mode ?? "accept-edits";
|
|
299
323
|
const writes = mode === "accept-edits";
|
|
300
324
|
const skipPermissions = options.skipPermissions ?? true;
|
|
@@ -1140,9 +1164,18 @@ function spawnAgyInternal(
|
|
|
1140
1164
|
runResult = processStreamLine(lineBuffer, runResult, onProgress);
|
|
1141
1165
|
}
|
|
1142
1166
|
|
|
1143
|
-
//
|
|
1144
|
-
//
|
|
1145
|
-
//
|
|
1167
|
+
// Terminal status is authoritative when present. agy can emit an
|
|
1168
|
+
// ERROR envelope with response: "" and even exit 0; response
|
|
1169
|
+
// completeness must never turn that failed turn into success.
|
|
1170
|
+
const terminalFailure = terminalFailureMessage(runResult, err);
|
|
1171
|
+
if (terminalFailure) {
|
|
1172
|
+
reject(withConversationId(terminalFailure, runResult));
|
|
1173
|
+
return;
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
// A fully delivered successful result outranks the kill: when
|
|
1177
|
+
// cancellation or timeout lands after the response arrived, the work
|
|
1178
|
+
// is done and the response must not be discarded.
|
|
1146
1179
|
if (runResult.response_complete) {
|
|
1147
1180
|
resolve(finalizeRunResult(out, runResult));
|
|
1148
1181
|
return;
|
|
@@ -1178,6 +1211,24 @@ function spawnAgyInternal(
|
|
|
1178
1211
|
});
|
|
1179
1212
|
}
|
|
1180
1213
|
|
|
1214
|
+
const SUCCESSFUL_TERMINAL_STATUSES = new Set(["SUCCESS", "OK"]);
|
|
1215
|
+
|
|
1216
|
+
function terminalFailureMessage(runResult: AgyRunResult, stderr: string): string | undefined {
|
|
1217
|
+
if (runResult.terminal_status === undefined) return undefined;
|
|
1218
|
+
const status = runResult.terminal_status
|
|
1219
|
+
.trim()
|
|
1220
|
+
.replace(/[\u0000-\u001f\u007f-\u009f]/g, "")
|
|
1221
|
+
.slice(0, 64);
|
|
1222
|
+
if (SUCCESSFUL_TERMINAL_STATUSES.has(status.toUpperCase())) return undefined;
|
|
1223
|
+
|
|
1224
|
+
const detail = runResult.terminal_error?.trim();
|
|
1225
|
+
let message = `agy reported terminal status ${status || "(empty)"}`;
|
|
1226
|
+
if (detail) message += `: ${detail}`;
|
|
1227
|
+
const stderrDetail = stderr.trim().slice(0, 2_000);
|
|
1228
|
+
if (stderrDetail && !message.includes(stderrDetail)) message += `\n${stderrDetail}`;
|
|
1229
|
+
return message;
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1181
1232
|
function withConversationId(message: string, runResult: AgyRunResult): Error {
|
|
1182
1233
|
const error = new Error(message) as Error & { conversation_id?: string };
|
|
1183
1234
|
if (runResult.conversation_id) error.conversation_id = runResult.conversation_id;
|
package/extensions/lib/stream.ts
CHANGED
|
@@ -39,7 +39,9 @@ export interface AgyStreamLine {
|
|
|
39
39
|
* Top-level `--output-format json` envelope fields — that mode emits one
|
|
40
40
|
* record without a result event, so the fields are honored directly.
|
|
41
41
|
*/
|
|
42
|
+
status?: string;
|
|
42
43
|
response?: string;
|
|
44
|
+
error?: string;
|
|
43
45
|
duration_seconds?: number;
|
|
44
46
|
usage?: AgyUsage;
|
|
45
47
|
init?: { model?: string; cwd?: string };
|
|
@@ -48,6 +50,7 @@ export interface AgyStreamLine {
|
|
|
48
50
|
conversation_id?: string;
|
|
49
51
|
status?: string;
|
|
50
52
|
response?: string;
|
|
53
|
+
error?: string;
|
|
51
54
|
duration_seconds?: number;
|
|
52
55
|
usage?: AgyUsage;
|
|
53
56
|
};
|
|
@@ -57,6 +60,10 @@ export interface AgyRunResult {
|
|
|
57
60
|
response: string;
|
|
58
61
|
/** Internal marker distinguishing a valid empty response from no response. */
|
|
59
62
|
response_complete?: boolean;
|
|
63
|
+
/** Authoritative terminal status when agy supplied one. */
|
|
64
|
+
terminal_status?: string;
|
|
65
|
+
/** Bounded terminal error detail from the result envelope. */
|
|
66
|
+
terminal_error?: string;
|
|
60
67
|
conversation_id?: string;
|
|
61
68
|
usage?: AgyUsage;
|
|
62
69
|
duration_seconds?: number;
|
|
@@ -209,6 +216,12 @@ function capResponse(response: string): string {
|
|
|
209
216
|
: response;
|
|
210
217
|
}
|
|
211
218
|
|
|
219
|
+
function capTerminalError(error: string): string {
|
|
220
|
+
return stripTerminalSequences(error)
|
|
221
|
+
.replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/g, " ")
|
|
222
|
+
.slice(0, 2_000);
|
|
223
|
+
}
|
|
224
|
+
|
|
212
225
|
export function accumulateRunResult(parsed: AgyStreamLine, current: AgyRunResult): AgyRunResult {
|
|
213
226
|
const next = { ...current };
|
|
214
227
|
|
|
@@ -217,10 +230,14 @@ export function accumulateRunResult(parsed: AgyStreamLine, current: AgyRunResult
|
|
|
217
230
|
// `--output-format json` produces one record with top-level envelope
|
|
218
231
|
// fields; honor them so non-streaming payloads of any size accumulate
|
|
219
232
|
// in-stream instead of falling back to the bounded raw capture.
|
|
233
|
+
if (Object.hasOwn(parsed, "status")) {
|
|
234
|
+
next.terminal_status = typeof parsed.status === "string" ? parsed.status : "(invalid)";
|
|
235
|
+
}
|
|
220
236
|
if (typeof parsed.response === "string") {
|
|
221
237
|
next.response = capResponse(parsed.response);
|
|
222
238
|
next.response_complete = true;
|
|
223
239
|
}
|
|
240
|
+
if (typeof parsed.error === "string") next.terminal_error = capTerminalError(parsed.error);
|
|
224
241
|
if (typeof parsed.duration_seconds === "number" && Number.isFinite(parsed.duration_seconds)) {
|
|
225
242
|
next.duration_seconds = parsed.duration_seconds;
|
|
226
243
|
}
|
|
@@ -236,10 +253,17 @@ export function accumulateRunResult(parsed: AgyStreamLine, current: AgyRunResult
|
|
|
236
253
|
if (typeof parsed.result.conversation_id === "string") {
|
|
237
254
|
next.conversation_id = parsed.result.conversation_id;
|
|
238
255
|
}
|
|
256
|
+
if (Object.hasOwn(parsed.result, "status")) {
|
|
257
|
+
next.terminal_status =
|
|
258
|
+
typeof parsed.result.status === "string" ? parsed.result.status : "(invalid)";
|
|
259
|
+
}
|
|
239
260
|
if (typeof parsed.result.response === "string") {
|
|
240
261
|
next.response = capResponse(parsed.result.response);
|
|
241
262
|
next.response_complete = true;
|
|
242
263
|
}
|
|
264
|
+
if (typeof parsed.result.error === "string") {
|
|
265
|
+
next.terminal_error = capTerminalError(parsed.result.error);
|
|
266
|
+
}
|
|
243
267
|
if (typeof parsed.result.usage === "object" && parsed.result.usage !== null) {
|
|
244
268
|
next.usage = parsed.result.usage;
|
|
245
269
|
}
|
|
@@ -287,11 +311,19 @@ function mergeJsonEnvelope(parsed: unknown, current: AgyRunResult): AgyRunResult
|
|
|
287
311
|
next.conversation_id = record.conversation_id;
|
|
288
312
|
found = true;
|
|
289
313
|
}
|
|
314
|
+
if (Object.hasOwn(record, "status")) {
|
|
315
|
+
next.terminal_status = typeof record.status === "string" ? record.status : "(invalid)";
|
|
316
|
+
found = true;
|
|
317
|
+
}
|
|
290
318
|
if (typeof record.response === "string") {
|
|
291
|
-
next.response = record.response;
|
|
319
|
+
next.response = capResponse(record.response);
|
|
292
320
|
next.response_complete = true;
|
|
293
321
|
found = true;
|
|
294
322
|
}
|
|
323
|
+
if (typeof record.error === "string") {
|
|
324
|
+
next.terminal_error = capTerminalError(record.error);
|
|
325
|
+
found = true;
|
|
326
|
+
}
|
|
295
327
|
if (typeof record.duration_seconds === "number") {
|
|
296
328
|
next.duration_seconds = record.duration_seconds;
|
|
297
329
|
found = true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juanbenjumea/pi-agy",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.9",
|
|
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",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"homepage": "https://github.com/huaxel/pi-agy#readme",
|
|
26
26
|
"scripts": {
|
|
27
27
|
"test": "node --import ./tests/resolve-hook.mjs --test tests/*.test.ts",
|
|
28
|
+
"test:live": "node --import ./tests/resolve-hook.mjs tests/live-smoke.ts",
|
|
28
29
|
"typecheck": "tsc --noEmit --pretty false",
|
|
29
30
|
"pack:check": "npm pack --dry-run --json"
|
|
30
31
|
},
|
|
@@ -49,9 +50,10 @@
|
|
|
49
50
|
"@sinclair/typebox": "*"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
|
52
|
-
"@earendil-works/pi-
|
|
53
|
+
"@earendil-works/pi-coding-agent": "^0.86.1",
|
|
54
|
+
"@earendil-works/pi-tui": "^0.86.1",
|
|
53
55
|
"@sinclair/typebox": "^0.34.41",
|
|
54
|
-
"@types/node": "^22.
|
|
56
|
+
"@types/node": "^22.20.4",
|
|
55
57
|
"typescript": "^5.0.0"
|
|
56
58
|
},
|
|
57
59
|
"engines": {
|