@juanbenjumea/pi-agy 0.6.10 → 0.6.11
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 +7 -0
- package/README.md +3 -1
- package/extensions/lib/cli.ts +10 -0
- package/extensions/lib/execute.ts +11 -1
- package/extensions/lib/render.ts +17 -0
- package/extensions/lib/stream.ts +70 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.11
|
|
4
|
+
|
|
5
|
+
- Parse agy 1.1.27+ `denied_actions` from nested stream results and top-level JSON envelopes, sanitizing, deduplicating, and bounding the untrusted action metadata.
|
|
6
|
+
- Reject `SUCCESS` envelopes that contain denied actions but no response instead of reporting a silent empty success; preserve the conversation id so the interrupted delegation remains resumable.
|
|
7
|
+
- Preserve explanatory responses that accompany denied actions while adding a visible model-facing warning, structured details, and non-duplicated native tool/receipt rendering.
|
|
8
|
+
- Document headless permission-denial behavior and add parser, execution, bounds, sanitization, and rendering regressions. Independent review found zero blockers; the full 204-test gate passes.
|
|
9
|
+
|
|
3
10
|
## 0.6.10
|
|
4
11
|
|
|
5
12
|
- 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.
|
package/README.md
CHANGED
|
@@ -184,7 +184,9 @@ Optional `$PI_CODING_AGENT_DIR/agy-config.json` (default
|
|
|
184
184
|
- `skipPermissions` (default `true`) — pass `--dangerously-skip-permissions`
|
|
185
185
|
for `accept-edits` runs. Set `false` to leave agy's own permission checks in
|
|
186
186
|
place; note print mode has no interactive approval path, so restricted
|
|
187
|
-
operations may
|
|
187
|
+
operations may be reported as `denied_actions` instead of prompting. The
|
|
188
|
+
extension rejects a denied run with no response and visibly warns when agy
|
|
189
|
+
returns an explanatory response alongside denied actions.
|
|
188
190
|
- `defaultModel` — alias used when `agy_execute` omits `model`/`tier`.
|
|
189
191
|
- `defaultModelCommand` — shell command whose stdout sets the default alias
|
|
190
192
|
when `defaultModel` is unset (an explicit `defaultModel` always wins).
|
package/extensions/lib/cli.ts
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
finalizeRunResult,
|
|
14
14
|
formatStepProgress,
|
|
15
15
|
parseStreamLine,
|
|
16
|
+
summarizeAgyDeniedActions,
|
|
16
17
|
type AgyProgressHandler,
|
|
17
18
|
type AgyRunResult,
|
|
18
19
|
type AgyStreamLine,
|
|
@@ -1177,6 +1178,15 @@ function spawnAgyInternal(
|
|
|
1177
1178
|
return;
|
|
1178
1179
|
}
|
|
1179
1180
|
|
|
1181
|
+
// Headless permission denials are intentionally nonfatal in agy and
|
|
1182
|
+
// can therefore arrive as SUCCESS with an empty response. Never turn
|
|
1183
|
+
// that incomplete delegation into a silent successful tool result.
|
|
1184
|
+
if (finalized.denied_actions?.length && !finalized.response.trim()) {
|
|
1185
|
+
const denied = summarizeAgyDeniedActions(finalized.denied_actions);
|
|
1186
|
+
reject(withConversationId(`agy denied tool actions: ${denied}`, finalized));
|
|
1187
|
+
return;
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1180
1190
|
// A fully delivered successful result outranks the kill: when
|
|
1181
1191
|
// cancellation or timeout lands after the response arrived, the work
|
|
1182
1192
|
// is done and the response must not be discarded.
|
|
@@ -18,7 +18,11 @@ import {
|
|
|
18
18
|
} from "./cli.js";
|
|
19
19
|
import { loadAgyConfig, resolveDefaultModel } from "./config.js";
|
|
20
20
|
import type { AgyContextMode } from "./context.js";
|
|
21
|
-
import
|
|
21
|
+
import {
|
|
22
|
+
summarizeAgyDeniedActions,
|
|
23
|
+
type AgyDeniedAction,
|
|
24
|
+
type AgyUsage,
|
|
25
|
+
} from "./stream.js";
|
|
22
26
|
import {
|
|
23
27
|
formatAgySubagentObservations,
|
|
24
28
|
type AgyObservedSubagent,
|
|
@@ -66,6 +70,8 @@ export interface AgyExecutionDetails {
|
|
|
66
70
|
duration_seconds?: number;
|
|
67
71
|
/** Stream observations only; entries do not imply a live controllable process. */
|
|
68
72
|
subagents?: AgyObservedSubagent[];
|
|
73
|
+
/** Bounded tool actions refused by agy's headless permission policy. */
|
|
74
|
+
denied_actions?: AgyDeniedAction[];
|
|
69
75
|
changed_files?: string[];
|
|
70
76
|
preexisting_files?: string[];
|
|
71
77
|
context_mode?: AgyContextMode;
|
|
@@ -249,6 +255,9 @@ export async function executeAgyTask(
|
|
|
249
255
|
}
|
|
250
256
|
|
|
251
257
|
let text = run.response;
|
|
258
|
+
if (run.denied_actions?.length) {
|
|
259
|
+
text = `${text}\n\n## agy denied actions\n${summarizeAgyDeniedActions(run.denied_actions)}`;
|
|
260
|
+
}
|
|
252
261
|
const subagentSummary = formatAgySubagentObservations(run.subagents);
|
|
253
262
|
if (subagentSummary) text = `${text}\n\n## ${subagentSummary}`;
|
|
254
263
|
const quotaSummary = quota?.models.length
|
|
@@ -290,6 +299,7 @@ export async function executeAgyTask(
|
|
|
290
299
|
usage: run.usage,
|
|
291
300
|
duration_seconds: run.duration_seconds,
|
|
292
301
|
subagents: run.subagents,
|
|
302
|
+
denied_actions: run.denied_actions,
|
|
293
303
|
changed_files: changedFiles,
|
|
294
304
|
preexisting_files: preexistingFiles,
|
|
295
305
|
context_mode: options.context ?? "none",
|
package/extensions/lib/render.ts
CHANGED
|
@@ -2,6 +2,10 @@ import { keyHint, type Theme } from "@earendil-works/pi-coding-agent";
|
|
|
2
2
|
import { stripTerminalSequences, Text, truncateToWidth } from "@earendil-works/pi-tui";
|
|
3
3
|
|
|
4
4
|
import type { AgyExecutionDetails } from "./execute.js";
|
|
5
|
+
import {
|
|
6
|
+
normalizeAgyDeniedActions,
|
|
7
|
+
summarizeAgyDeniedActions,
|
|
8
|
+
} from "./stream.js";
|
|
5
9
|
|
|
6
10
|
export const AGY_RUN_ENTRY_TYPE = "agy-run-receipt";
|
|
7
11
|
|
|
@@ -47,6 +51,7 @@ function firstText(content: unknown): string {
|
|
|
47
51
|
|
|
48
52
|
function stripSyntheticResultSections(value: string): string {
|
|
49
53
|
const markers = [
|
|
54
|
+
"\n\n## agy denied actions",
|
|
50
55
|
"\n\n## agy quota snapshot",
|
|
51
56
|
"\n\n## agy subagents observed",
|
|
52
57
|
"\n\n## git diff --stat",
|
|
@@ -140,6 +145,18 @@ function formatAgyResult(
|
|
|
140
145
|
}
|
|
141
146
|
if (metadata.length) lines.push(theme.fg("dim", metadata.join(" · ")));
|
|
142
147
|
|
|
148
|
+
const denied = normalizeAgyDeniedActions(details.denied_actions) ?? [];
|
|
149
|
+
if (denied.length) {
|
|
150
|
+
const count = `${denied.length} denied action${denied.length === 1 ? "" : "s"}`;
|
|
151
|
+
const summary = summarizeAgyDeniedActions(denied, 3);
|
|
152
|
+
lines.push(theme.fg("warning", `⚠ ${count}${summary ? ` · ${summary}` : ""}`));
|
|
153
|
+
if (expanded) {
|
|
154
|
+
for (const entry of denied) {
|
|
155
|
+
lines.push(theme.fg("toolOutput", `↳ denied ${summarizeAgyDeniedActions([entry], 1)}`));
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
143
160
|
const subagents = Array.isArray(details.subagents) ? details.subagents.slice(0, 32) : [];
|
|
144
161
|
if (subagents.length) {
|
|
145
162
|
const done = subagents.filter((entry) => entry?.status === "done").length;
|
package/extensions/lib/stream.ts
CHANGED
|
@@ -14,6 +14,11 @@ export interface AgyUsage {
|
|
|
14
14
|
total_tokens?: number;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
export interface AgyDeniedAction {
|
|
18
|
+
action?: string;
|
|
19
|
+
display_name?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
17
22
|
export interface AgyStepUpdate {
|
|
18
23
|
conversation_id?: string;
|
|
19
24
|
step_index?: number;
|
|
@@ -42,6 +47,7 @@ export interface AgyStreamLine {
|
|
|
42
47
|
status?: string;
|
|
43
48
|
response?: string;
|
|
44
49
|
error?: string;
|
|
50
|
+
denied_actions?: unknown;
|
|
45
51
|
duration_seconds?: number;
|
|
46
52
|
usage?: AgyUsage;
|
|
47
53
|
init?: { model?: string; cwd?: string };
|
|
@@ -51,6 +57,7 @@ export interface AgyStreamLine {
|
|
|
51
57
|
status?: string;
|
|
52
58
|
response?: string;
|
|
53
59
|
error?: string;
|
|
60
|
+
denied_actions?: unknown;
|
|
54
61
|
duration_seconds?: number;
|
|
55
62
|
usage?: AgyUsage;
|
|
56
63
|
};
|
|
@@ -64,6 +71,8 @@ export interface AgyRunResult {
|
|
|
64
71
|
terminal_status?: string;
|
|
65
72
|
/** Bounded terminal error detail from the result envelope. */
|
|
66
73
|
terminal_error?: string;
|
|
74
|
+
/** Bounded permission refusals reported by headless agy. */
|
|
75
|
+
denied_actions?: AgyDeniedAction[];
|
|
67
76
|
conversation_id?: string;
|
|
68
77
|
usage?: AgyUsage;
|
|
69
78
|
duration_seconds?: number;
|
|
@@ -222,6 +231,58 @@ function capTerminalError(error: string): string {
|
|
|
222
231
|
.slice(0, 2_000);
|
|
223
232
|
}
|
|
224
233
|
|
|
234
|
+
const MAX_DENIED_ACTIONS = 32;
|
|
235
|
+
const MAX_DENIED_ACTION_CHARS = 120;
|
|
236
|
+
|
|
237
|
+
function cleanDeniedActionField(value: unknown): string | undefined {
|
|
238
|
+
if (typeof value !== "string") return undefined;
|
|
239
|
+
const clean = stripTerminalSequences(value)
|
|
240
|
+
.replace(/[\u0000-\u001f\u007f-\u009f]/g, " ")
|
|
241
|
+
.replace(/\s+/g, " ")
|
|
242
|
+
.trim()
|
|
243
|
+
.slice(0, MAX_DENIED_ACTION_CHARS);
|
|
244
|
+
return clean || undefined;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export function normalizeAgyDeniedActions(value: unknown): AgyDeniedAction[] | undefined {
|
|
248
|
+
if (!Array.isArray(value)) return undefined;
|
|
249
|
+
const denied: AgyDeniedAction[] = [];
|
|
250
|
+
const seen = new Set<string>();
|
|
251
|
+
for (const item of value) {
|
|
252
|
+
let action: string | undefined;
|
|
253
|
+
let displayName: string | undefined;
|
|
254
|
+
if (typeof item === "string") {
|
|
255
|
+
action = cleanDeniedActionField(item);
|
|
256
|
+
} else if (typeof item === "object" && item !== null && !Array.isArray(item)) {
|
|
257
|
+
const record = item as Record<string, unknown>;
|
|
258
|
+
action = cleanDeniedActionField(record.action);
|
|
259
|
+
displayName = cleanDeniedActionField(record.display_name);
|
|
260
|
+
}
|
|
261
|
+
if (!action && !displayName) continue;
|
|
262
|
+
const key = `${action ?? ""}\u0000${displayName ?? ""}`;
|
|
263
|
+
if (seen.has(key)) continue;
|
|
264
|
+
seen.add(key);
|
|
265
|
+
denied.push({
|
|
266
|
+
...(action ? { action } : {}),
|
|
267
|
+
...(displayName ? { display_name: displayName } : {}),
|
|
268
|
+
});
|
|
269
|
+
if (denied.length >= MAX_DENIED_ACTIONS) break;
|
|
270
|
+
}
|
|
271
|
+
return denied.length ? denied : undefined;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export function summarizeAgyDeniedActions(value: unknown, max = 12): string {
|
|
275
|
+
const denied = normalizeAgyDeniedActions(value) ?? [];
|
|
276
|
+
const shown = denied.slice(0, Math.max(0, max));
|
|
277
|
+
const labels = shown.map(({ action, display_name: displayName }) =>
|
|
278
|
+
displayName && action && displayName !== action
|
|
279
|
+
? `${displayName} (${action})`
|
|
280
|
+
: displayName ?? action ?? "unknown action",
|
|
281
|
+
);
|
|
282
|
+
if (denied.length > shown.length) labels.push(`… ${denied.length - shown.length} more`);
|
|
283
|
+
return labels.join(", ");
|
|
284
|
+
}
|
|
285
|
+
|
|
225
286
|
export function accumulateRunResult(parsed: AgyStreamLine, current: AgyRunResult): AgyRunResult {
|
|
226
287
|
const next = { ...current };
|
|
227
288
|
|
|
@@ -238,6 +299,8 @@ export function accumulateRunResult(parsed: AgyStreamLine, current: AgyRunResult
|
|
|
238
299
|
next.response_complete = true;
|
|
239
300
|
}
|
|
240
301
|
if (typeof parsed.error === "string") next.terminal_error = capTerminalError(parsed.error);
|
|
302
|
+
const topLevelDenied = normalizeAgyDeniedActions(parsed.denied_actions);
|
|
303
|
+
if (topLevelDenied) next.denied_actions = topLevelDenied;
|
|
241
304
|
if (typeof parsed.duration_seconds === "number" && Number.isFinite(parsed.duration_seconds)) {
|
|
242
305
|
next.duration_seconds = parsed.duration_seconds;
|
|
243
306
|
}
|
|
@@ -264,6 +327,8 @@ export function accumulateRunResult(parsed: AgyStreamLine, current: AgyRunResult
|
|
|
264
327
|
if (typeof parsed.result.error === "string") {
|
|
265
328
|
next.terminal_error = capTerminalError(parsed.result.error);
|
|
266
329
|
}
|
|
330
|
+
const denied = normalizeAgyDeniedActions(parsed.result.denied_actions);
|
|
331
|
+
if (denied) next.denied_actions = denied;
|
|
267
332
|
if (typeof parsed.result.usage === "object" && parsed.result.usage !== null) {
|
|
268
333
|
next.usage = parsed.result.usage;
|
|
269
334
|
}
|
|
@@ -331,6 +396,11 @@ function mergeJsonEnvelope(parsed: unknown, current: AgyRunResult): AgyRunResult
|
|
|
331
396
|
next.terminal_error = capTerminalError(record.error);
|
|
332
397
|
found = true;
|
|
333
398
|
}
|
|
399
|
+
const denied = normalizeAgyDeniedActions(record.denied_actions);
|
|
400
|
+
if (denied) {
|
|
401
|
+
next.denied_actions = denied;
|
|
402
|
+
found = true;
|
|
403
|
+
}
|
|
334
404
|
if (typeof record.duration_seconds === "number") {
|
|
335
405
|
next.duration_seconds = record.duration_seconds;
|
|
336
406
|
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.11",
|
|
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",
|