pi-agy-acp 0.2.5 → 0.2.6
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 +1 -1
- package/docs/architecture.md +9 -6
- package/docs/development.md +1 -1
- package/docs/reference.md +7 -6
- package/package.json +1 -1
- package/src/acp-process.ts +1 -0
- package/src/config.ts +1 -1
- package/src/conversation.ts +18 -14
- package/src/format.ts +3 -3
- package/src/preflight.ts +2 -2
- package/src/quota.ts +8 -8
- package/src/runtime.ts +14 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.2.6](https://github.com/fdkevin0/pi-agy-acp/compare/v0.2.5...v0.2.6) (2026-12-03)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **agy:** adapt to agy 1.5.23 usage subcommand, retry notices, and -32002 errors ([#62](https://github.com/fdkevin0/pi-agy-acp/issues/62)) ([5f9c705](https://github.com/fdkevin0/pi-agy-acp/commit/5f9c705e83ecc4798cb6d7b705dddd33464f1b2e))
|
|
9
|
+
|
|
3
10
|
## [0.2.5](https://github.com/fdkevin0/pi-agy-acp/compare/v0.2.4...v0.2.5) (2026-11-28)
|
|
4
11
|
|
|
5
12
|
|
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ parallel tool calls.
|
|
|
12
12
|
|
|
13
13
|
- Node.js >= 22.19.0.
|
|
14
14
|
- Pi (`@earendil-works/pi-coding-agent`) 1.5.x.
|
|
15
|
-
- The official `agy` CLI >= 1.5.
|
|
15
|
+
- The official `agy` CLI >= 1.5.23, signed in with your Google account.
|
|
16
16
|
Run `agy` (or `agy acp --login` in headless/SSH terminals) to complete sign-in
|
|
17
17
|
before using the extension.
|
|
18
18
|
|
package/docs/architecture.md
CHANGED
|
@@ -93,8 +93,9 @@ Working directory is `<PI_AGY_HOME>/workspace`. ACP JSON-RPC timeouts:
|
|
|
93
93
|
`tier`, `contextWindows`, and the subprocess-free binary fingerprint
|
|
94
94
|
(`${realpath}:${dev}:${ino}:${size}:${mtimeNs}`).
|
|
95
95
|
- Both `agy --version` (30 s timeout) and ACP `initialize` (`agentInfo.version`)
|
|
96
|
-
enforce `MIN_AGY_VERSION` (`1.5.
|
|
97
|
-
|
|
96
|
+
enforce `MIN_AGY_VERSION` (`1.5.23`, which adds `agy usage`, standardizes
|
|
97
|
+
`-32002` unknown-session errors across ACP methods, and updates combined
|
|
98
|
+
reasoning+output retry guidance).
|
|
98
99
|
- Non-forced refreshes reuse `catalog.json` without spawning `agy` whenever
|
|
99
100
|
cached models match the current binary fingerprint. Loading a cache with a
|
|
100
101
|
mismatched fingerprint drops cached `contextWindows` while keeping models
|
|
@@ -133,7 +134,9 @@ Working directory is `<PI_AGY_HOME>/workspace`. ACP JSON-RPC timeouts:
|
|
|
133
134
|
tenant, re-applies model/effort via `select()`, and sends only the delta
|
|
134
135
|
input. Any `JsonRpcRemoteError` from `session/resume` (including `-32603` and
|
|
135
136
|
`-32002`) or history divergence cleans the dormant DB and falls back to
|
|
136
|
-
`session/new` + `replayPrompt()`.
|
|
137
|
+
`session/new` + `replayPrompt()`. Unknown-session `-32002` errors from
|
|
138
|
+
`session/set_config_option` or `session/prompt` mark the conversation dirty
|
|
139
|
+
so the next turn rebuilds cleanly. Explicit teardown (`resetConversations()`,
|
|
137
140
|
`dispose()`, binary upgrade, LRU eviction) deletes dormant DBs immediately.
|
|
138
141
|
- **Pi lifecycle resets:** Compaction, tree navigation, and `session_start`
|
|
139
142
|
(`new`, `resume`, `fork`) perform a light reset (closing conversation sessions
|
|
@@ -220,14 +223,14 @@ Working directory is `<PI_AGY_HOME>/workspace`. ACP JSON-RPC timeouts:
|
|
|
220
223
|
- Gates streaming reads with cached context window / positive `usage_update`
|
|
221
224
|
checks and `(mtimeNs, size)` stamps across `.db`, `.db-wal`, and
|
|
222
225
|
`.db-journal`. `gen_metadata.data` remains the authoritative per-model
|
|
223
|
-
`max_context_tokens` source in `agy` 1.5.
|
|
226
|
+
`max_context_tokens` source in `agy` 1.5.23 because `usage_update.size` still
|
|
224
227
|
reports a fixed `1048576` rather than per-model limits. `gen_metadata` scans
|
|
225
228
|
are bounded (`LIMIT 64`) and advance `metaFloorIdx` on mid-session model
|
|
226
229
|
switches so prior context windows cannot bleed across models.
|
|
227
230
|
- On `end_turn` and `refusal`, inspects the newest terminal `steps` row
|
|
228
231
|
(`step_type = 17`, cross-checked against `step_type = 15` model reachability)
|
|
229
232
|
to surface hidden API errors while preserving pure safety refusals. This
|
|
230
|
-
remains necessary in `agy` 1.5.
|
|
233
|
+
remains necessary in `agy` 1.5.23 because certain API errors (such as
|
|
231
234
|
`INVALID_ARGUMENT (code 400)` on malformed images) still complete
|
|
232
235
|
`session/prompt` with `stopReason: "end_turn"`:
|
|
233
236
|
- `QUOTA_EXHAUSTED` → `QUOTA` (extracts reset timestamp/delay)
|
|
@@ -268,7 +271,7 @@ tool-heavy or continued turns:
|
|
|
268
271
|
|
|
269
272
|
## Quota reader and Pi stream contracts
|
|
270
273
|
|
|
271
|
-
- **Quota reader (`src/quota.ts`):** Runs `agy
|
|
274
|
+
- **Quota reader (`src/quota.ts`):** Runs `agy usage --output-format json`
|
|
272
275
|
with closed `stdin`, a 1 MiB `stdout` cap, a 45 s timeout, and early abort if
|
|
273
276
|
`stderr` matches `Authentication required`. Uses a monotonic clock
|
|
274
277
|
(`performance.now()`) for its 2-minute TTL, filters `disabled === true`
|
package/docs/development.md
CHANGED
|
@@ -47,7 +47,7 @@ SQLite telemetry, and transport boundary invariants.
|
|
|
47
47
|
| `src/acp-process.ts`, `src/jsonrpc.ts`, `src/mcp-bridge.ts` | ACP stdio transport, NDJSON JSON-RPC peer, loopback MCP HTTP/SSE bridge, schema compression, and tool deltas. |
|
|
48
48
|
| `src/config.ts` | Default runtime thresholds, effort/display types, and atomic `settings.json` persistence. |
|
|
49
49
|
| `src/host.ts`, `src/preflight.ts`, `src/session-db.ts` | Subprocess management and env/stderr hardening, binary discovery/fingerprinting/OAuth sync, and read-only session SQLite telemetry/error inspection and artifact cleanup. |
|
|
50
|
-
| `src/catalog.ts`, `src/quota.ts`, `src/format.ts`, `src/util.ts` | Model catalog persistence,
|
|
50
|
+
| `src/catalog.ts`, `src/quota.ts`, `src/format.ts`, `src/util.ts` | Model catalog persistence, `agy usage` quota reader and login-log email lookup, TUI notice formatting and model-to-group matching, and shared utilities. |
|
|
51
51
|
| `src/version.ts` | Package version read from `package.json` for ACP/MCP handshakes. |
|
|
52
52
|
| `tests/` | Scripted local `agy` fixture (`fake-agy.mjs`), unit tests, and Pi integration tests. |
|
|
53
53
|
|
package/docs/reference.md
CHANGED
|
@@ -21,7 +21,7 @@ In interactive TUI mode, `/agy-acp quota` (`Fetching Antigravity quota...`) and
|
|
|
21
21
|
`/agy-acp refresh` (`Refreshing Antigravity models...`) display a cancellable
|
|
22
22
|
loader. Pressing Escape returns to the editor: `/agy-acp refresh` cancels the
|
|
23
23
|
caller's wait, while `/agy-acp quota` hides the pending panel even if the
|
|
24
|
-
underlying
|
|
24
|
+
underlying `agy usage` query finishes updating the cache. Non-TUI modes run
|
|
25
25
|
directly without a loader.
|
|
26
26
|
|
|
27
27
|
### Status panel
|
|
@@ -41,7 +41,7 @@ healthy runtime uses a warning.
|
|
|
41
41
|
|
|
42
42
|
### Quota panel
|
|
43
43
|
|
|
44
|
-
Quota is read through `agy
|
|
44
|
+
Quota is read through `agy usage --output-format json`. Disabled quota
|
|
45
45
|
buckets are excluded. Each model group renders one row per usable quota window
|
|
46
46
|
with a 12-cell bar, a rounded percentage, and a relative reset countdown:
|
|
47
47
|
|
|
@@ -95,7 +95,7 @@ unavailable fields:
|
|
|
95
95
|
|
|
96
96
|
### Quota status and warnings
|
|
97
97
|
|
|
98
|
-
After an `antigravity-acp` run settles, the extension refreshes
|
|
98
|
+
After an `antigravity-acp` run settles, the extension refreshes `agy usage` in the
|
|
99
99
|
background (sharing any in-flight request and respecting the 2-minute TTL) and
|
|
100
100
|
displays a compact status bar indicator such as `AGY 20%` (or `AGY 80%` in
|
|
101
101
|
`remaining` mode):
|
|
@@ -164,7 +164,7 @@ session databases).
|
|
|
164
164
|
refusing symlinked paths. Sync failures warn rather than aborting startup. A
|
|
165
165
|
custom `PI_AGY_HOME` stays isolated and never copies tokens from default `agy`
|
|
166
166
|
directories.
|
|
167
|
-
- **Global quota scope:** `agy
|
|
167
|
+
- **Global quota scope:** `agy usage` does not accept `--gemini-dir`, so
|
|
168
168
|
quota queries always reflect the global `agy` CLI account. Do not commit or
|
|
169
169
|
share `PI_AGY_HOME`.
|
|
170
170
|
|
|
@@ -225,8 +225,9 @@ or invokes/distributes binary patches.
|
|
|
225
225
|
## Compatibility limits
|
|
226
226
|
|
|
227
227
|
- Requires Node.js >= 22.19.0, Pi (`@earendil-works/*`) 1.5.x, and `agy` >=
|
|
228
|
-
1.5.
|
|
229
|
-
|
|
228
|
+
1.5.23 (which adds the standalone `agy usage` subcommand, standardizes
|
|
229
|
+
`-32002` unknown-session ACP errors, and updates combined reasoning+output
|
|
230
|
+
retry handling). Older `@mariozechner/*` Pi interfaces are not supported.
|
|
230
231
|
- Sampling parameters, output limits, forced `toolChoice`, and provider-scoped
|
|
231
232
|
environment overrides are not mapped to ACP.
|
|
232
233
|
|
package/package.json
CHANGED
package/src/acp-process.ts
CHANGED
package/src/config.ts
CHANGED
|
@@ -38,7 +38,7 @@ export interface Config {
|
|
|
38
38
|
relayAfterMs: number
|
|
39
39
|
/** Automatic continuations after an output-length stop (long decode). */
|
|
40
40
|
longDecodeContinuations: number
|
|
41
|
-
/** Minimum interval between quota refreshes through `agy
|
|
41
|
+
/** Minimum interval between quota refreshes through `agy usage`. */
|
|
42
42
|
quotaTtlMs: number
|
|
43
43
|
}
|
|
44
44
|
|
package/src/conversation.ts
CHANGED
|
@@ -33,12 +33,11 @@ import { AsyncQueue, deferred, type Deferred } from './util.ts'
|
|
|
33
33
|
|
|
34
34
|
/** Agent-side transport retry notice streamed as message text, e.g. `⚠ API error (attempt 1): …`. */
|
|
35
35
|
const AGENT_RETRY_NOTICE = /^\s*⚠\s*API error \(attempt \d+\)/
|
|
36
|
-
/**
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
'please continue from where you left off, keeping your response shorter'
|
|
36
|
+
/** Discarded-attempt prefix agy 1.5.23+ emits on retryable generation failures (`%s\n%s\nRetries remaining: %d`). */
|
|
37
|
+
const DISCARDED_ATTEMPT_PREFIX = 'a response attempt was discarded'
|
|
38
|
+
/** Standalone retry guidance agy 1.5.23+ pairs with combined reasoning+output limit discards. */
|
|
39
|
+
const REASONING_OUTPUT_LIMIT_TAIL =
|
|
40
|
+
'please keep your reasoning and response shorter'
|
|
42
41
|
/** Internal retry notice agy emits when an upstream stream is interrupted mid-turn. */
|
|
43
42
|
const STREAM_INTERRUPTED =
|
|
44
43
|
'the stream was interrupted. please continue the task you were working on.'
|
|
@@ -49,7 +48,7 @@ const EMPTY_MODEL_OUTPUT_BODY =
|
|
|
49
48
|
'model output must contain either output text or tool calls, these cannot both be empty, please try again'
|
|
50
49
|
/** Generic retry notice prefix paired with a trailing `Retries remaining: <N>`. */
|
|
51
50
|
const PROBLEM_RETRY_PREFIX = 'there was a problem'
|
|
52
|
-
/** Cap on held characters while waiting for `Retries remaining: <N>` after
|
|
51
|
+
/** Cap on held characters while waiting for `Retries remaining: <N>` after a generic retry prefix. */
|
|
53
52
|
const MAX_PROBLEM_NOTICE_CHARS = 512
|
|
54
53
|
|
|
55
54
|
/** Collapse agy's warning mark, line-leading `Error:`, and line breaks so notices match across chunks. */
|
|
@@ -87,11 +86,9 @@ export function classifyOutputLimitNotice(
|
|
|
87
86
|
if (/^retries remaining:\s*[1-9]\d*$/i.test(text)) return 'drop'
|
|
88
87
|
return /^retries remaining:\s*$/i.test(text) ? 'hold' : 'emit'
|
|
89
88
|
}
|
|
90
|
-
const
|
|
89
|
+
const normalized = stripped.replace(/\./g, '').replace(/\s+/g, ' ').trim()
|
|
91
90
|
if (
|
|
92
|
-
|
|
93
|
-
stripped === OUTPUT_LIMIT_HEAD ||
|
|
94
|
-
stripped === OUTPUT_LIMIT_TAIL ||
|
|
91
|
+
normalized === REASONING_OUTPUT_LIMIT_TAIL ||
|
|
95
92
|
stripped === STREAM_INTERRUPTED ||
|
|
96
93
|
stripped === EMPTY_MODEL_OUTPUT ||
|
|
97
94
|
stripped === EMPTY_MODEL_OUTPUT_BODY
|
|
@@ -100,11 +97,18 @@ export function classifyOutputLimitNotice(
|
|
|
100
97
|
return 'drop'
|
|
101
98
|
return /^retries remaining:\s*$/i.test(retry) ? 'hold' : 'emit'
|
|
102
99
|
}
|
|
103
|
-
if (
|
|
100
|
+
if (/^a response attempt was discarded\b/.test(text)) {
|
|
101
|
+
if (/\bretries remaining:\s*[1-9]\d*$/.test(text)) return 'drop'
|
|
102
|
+
return text.length <= MAX_PROBLEM_NOTICE_CHARS ? 'hold' : 'emit'
|
|
103
|
+
}
|
|
104
|
+
if (
|
|
105
|
+
DISCARDED_ATTEMPT_PREFIX.startsWith(text) &&
|
|
106
|
+
text.startsWith('a response attempt')
|
|
107
|
+
)
|
|
104
108
|
return 'hold'
|
|
105
109
|
if (
|
|
106
|
-
|
|
107
|
-
|
|
110
|
+
REASONING_OUTPUT_LIMIT_TAIL.startsWith(normalized) &&
|
|
111
|
+
normalized.startsWith('please keep your reasoning')
|
|
108
112
|
)
|
|
109
113
|
return 'hold'
|
|
110
114
|
if (
|
package/src/format.ts
CHANGED
|
@@ -22,13 +22,13 @@ function formatAccount(account?: AccountInfo): string {
|
|
|
22
22
|
return [account?.email, account?.plan].filter(Boolean).join(' · ')
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
/** Active model identity from Pi (`id` plus optional display `name` for
|
|
25
|
+
/** Active model identity from Pi (`id` plus optional display `name` for `agy usage` labels such as `Orchestrator (Carbon)`). */
|
|
26
26
|
export interface QuotaModelRef {
|
|
27
27
|
readonly id: string
|
|
28
28
|
readonly name?: string
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
// `agy
|
|
31
|
+
// `agy usage` prefixes closed, exhaustive member lists with "Models within this group:";
|
|
32
32
|
// unprefixed descriptions are free-form prose notes.
|
|
33
33
|
const EXPLICIT_MEMBERS_PREFIX = /^\s*models within this group:\s*/i
|
|
34
34
|
const CLAUSE_SPLIT = /[,;\n/|&+]+|\b(?:and|or)\b/i
|
|
@@ -40,7 +40,7 @@ const EFFORT_QUALIFIER_PATTERN = [
|
|
|
40
40
|
'extra[-_]low',
|
|
41
41
|
...[...EFFORTS].sort((a, b) => b.length - a.length),
|
|
42
42
|
].join('|')
|
|
43
|
-
// Effort or thinking-mode suffixes in model IDs (`-thinking`) and
|
|
43
|
+
// Effort or thinking-mode suffixes in model IDs (`-thinking`) and `agy usage` labels (`(Thinking)`).
|
|
44
44
|
const ID_QUALIFIER_SUFFIX = new RegExp(
|
|
45
45
|
`[-_](?:(${EFFORT_QUALIFIER_PATTERN})(?:[-_]effort)?|(thinking))$`,
|
|
46
46
|
'i',
|
package/src/preflight.ts
CHANGED
|
@@ -33,8 +33,8 @@ export { atomicWriteFile }
|
|
|
33
33
|
|
|
34
34
|
/** Agent id installed in the isolated home. */
|
|
35
35
|
export const BRIDGE_AGENT = 'pi-bridge'
|
|
36
|
-
/** Minimum official CLI version supported (`agy 1.5.
|
|
37
|
-
export const MIN_AGY_VERSION: readonly [number, number, number] = [1, 5,
|
|
36
|
+
/** Minimum official CLI version supported (`agy 1.5.23+`). */
|
|
37
|
+
export const MIN_AGY_VERSION: readonly [number, number, number] = [1, 5, 23]
|
|
38
38
|
|
|
39
39
|
/** Output of one finished helper command. */
|
|
40
40
|
export interface CommandOutput {
|
package/src/quota.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Plan quota read through the official CLI's local
|
|
3
|
-
* reports each model group's weekly and five-hour windows without
|
|
4
|
-
* model request.
|
|
2
|
+
* Plan quota read through the official CLI's local `agy usage` command, which
|
|
3
|
+
* reports each model group's weekly and five-hour windows without starting a
|
|
4
|
+
* conversation or sending a model request.
|
|
5
5
|
* @module pi-agy-acp/quota
|
|
6
6
|
*/
|
|
7
7
|
|
|
@@ -216,7 +216,7 @@ function parseBucket(raw: unknown): QuotaBucket | undefined {
|
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
/**
|
|
219
|
-
* Parse `agy
|
|
219
|
+
* Parse `agy usage --output-format json` output.
|
|
220
220
|
* @param stdout - command stdout.
|
|
221
221
|
* @returns the quota groups.
|
|
222
222
|
*/
|
|
@@ -235,7 +235,7 @@ export function parseUsage(stdout: string): QuotaGroup[] {
|
|
|
235
235
|
? (data as { groups?: unknown }).groups
|
|
236
236
|
: undefined
|
|
237
237
|
if (!Array.isArray(groups))
|
|
238
|
-
throw new Error('agy
|
|
238
|
+
throw new Error('agy usage returned no quota groups')
|
|
239
239
|
return groups
|
|
240
240
|
.filter(
|
|
241
241
|
(raw): raw is Record<string, unknown> =>
|
|
@@ -309,7 +309,7 @@ export class QuotaReader {
|
|
|
309
309
|
try {
|
|
310
310
|
const binary = this.binary()
|
|
311
311
|
const result = await this.run(
|
|
312
|
-
[binary, '
|
|
312
|
+
[binary, 'usage', '--output-format', 'json'],
|
|
313
313
|
45_000,
|
|
314
314
|
{
|
|
315
315
|
maxStdoutBytes: USAGE_MAX_STDOUT_BYTES,
|
|
@@ -326,12 +326,12 @@ export class QuotaReader {
|
|
|
326
326
|
}
|
|
327
327
|
if (result.abortedBy === 'maxStdout') {
|
|
328
328
|
throw new Error(
|
|
329
|
-
`agy
|
|
329
|
+
`agy usage stdout exceeded ${USAGE_MAX_STDOUT_BYTES} bytes`,
|
|
330
330
|
)
|
|
331
331
|
}
|
|
332
332
|
if (result.code !== 0)
|
|
333
333
|
throw new Error(
|
|
334
|
-
`agy
|
|
334
|
+
`agy usage failed (exit ${result.code}): ${result.stderr.trim() || result.stdout.trim()}`,
|
|
335
335
|
)
|
|
336
336
|
const snapshot: QuotaSnapshot = {
|
|
337
337
|
status: 'ok',
|
package/src/runtime.ts
CHANGED
|
@@ -399,6 +399,13 @@ export class AntigravityRuntime {
|
|
|
399
399
|
}
|
|
400
400
|
return result
|
|
401
401
|
} catch (error) {
|
|
402
|
+
if (
|
|
403
|
+
error instanceof JsonRpcRemoteError &&
|
|
404
|
+
error.rpc.code === -32002 &&
|
|
405
|
+
this.owns(proc, conv, sessionId)
|
|
406
|
+
) {
|
|
407
|
+
conv.dirty = true
|
|
408
|
+
}
|
|
402
409
|
if (!harvested) {
|
|
403
410
|
this.harvestSessionTurnData(conv, sessionId, model, modelFloor, {
|
|
404
411
|
turn,
|
|
@@ -1443,6 +1450,13 @@ export class AntigravityRuntime {
|
|
|
1443
1450
|
const configOptions = await proc
|
|
1444
1451
|
.setConfigOption(sessionId, optionId, value)
|
|
1445
1452
|
.catch((error: unknown) => {
|
|
1453
|
+
if (
|
|
1454
|
+
error instanceof JsonRpcRemoteError &&
|
|
1455
|
+
error.rpc.code === -32002 &&
|
|
1456
|
+
this.owns(proc, conv, sessionId)
|
|
1457
|
+
) {
|
|
1458
|
+
conv.dirty = true
|
|
1459
|
+
}
|
|
1446
1460
|
throw mapError(error)
|
|
1447
1461
|
})
|
|
1448
1462
|
this.assertOwner(proc, conv, sessionId)
|