pi-agy-acp 0.1.3 → 0.1.4

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 CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.4](https://github.com/fdkevin0/pi-agy-acp/compare/v0.1.3...v0.1.4) (2026-11-15)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * accept the flat mcp_pi_<tool> name agy 1.5.8 reports for Pi tools ([#23](https://github.com/fdkevin0/pi-agy-acp/issues/23)) ([d202134](https://github.com/fdkevin0/pi-agy-acp/commit/d2021349a4886ae34c5d4de7510da102f0e0c655))
9
+ * deliver harness system prompt in opening ACP prompt ([#24](https://github.com/fdkevin0/pi-agy-acp/issues/24)) ([#26](https://github.com/fdkevin0/pi-agy-acp/issues/26)) ([b8679b0](https://github.com/fdkevin0/pi-agy-acp/commit/b8679b0baa171d6447a1cb11195d82a949bb2adf))
10
+ * match quota groups to specific models and scope cache-warming veto ([#21](https://github.com/fdkevin0/pi-agy-acp/issues/21)) ([4f5bc7b](https://github.com/fdkevin0/pi-agy-acp/commit/4f5bc7b82f4e232ba36e2fcd3aa1e9ea5483e88b))
11
+ * preserve turn usage totals, pin CI baseline, and test permission probe timing ([#10](https://github.com/fdkevin0/pi-agy-acp/issues/10)) ([#27](https://github.com/fdkevin0/pi-agy-acp/issues/27)) ([148fb6a](https://github.com/fdkevin0/pi-agy-acp/commit/148fb6a2f9bf12b31cac4e854d22a652a72c4f3b))
12
+
3
13
  ## [0.1.3]
4
14
 
5
15
  - Default quota display to `used` across the status bar, quota panel, and warnings, with `/agy-acp quota [used|remaining]` persistence in `settings.json` and `PI_AGY_QUOTA_DISPLAY` startup override.
@@ -16,9 +16,11 @@ pi -e ./index.ts
16
16
 
17
17
  1. The extension registers `antigravity-acp` with Pi. The first request starts
18
18
  `agy acp --process-per-session` and a loopback MCP bridge.
19
- 2. Pi messages and tool definitions are converted into an ACP prompt. The runtime
20
- reuses a session when its history prefix still matches; otherwise it replays
21
- the available history into a new session.
19
+ 2. Session creation appends only a static MCP tool-routing preamble to `agy`'s
20
+ system prompt; Pi's system prompt, compacted initial tool schemas, and any
21
+ replayed history travel in the session's opening prompt within the 160 KB
22
+ replay budget. Later turns on an intact history prefix reuse the session and
23
+ send only new input (plus any dynamic tool deltas).
22
24
  3. Model tool calls reach the bridge and remain pending while Pi executes them.
23
25
  Pi receives a `toolUse` result, then supplies tool results on its next request.
24
26
  4. Those results resolve the pending MCP requests, allowing the same ACP turn to
@@ -33,6 +35,11 @@ pi -e ./index.ts
33
35
  caller's wait; shared discovery still closes its session and cleans its files.
34
36
  - **Session lifecycle:** The bridge binds to `127.0.0.1`, uses per-session bearer
35
37
  credentials, and validates structured tool identity before granting permissions.
38
+ Live `agy 1.5.9` sessions issue `session/request_permission` only inside an
39
+ active `session/prompt` turn (never during `session/new` or
40
+ `session/set_config_option`), so session creation and idle pre-/post-turn
41
+ windows remain fail-closed (`cancelled` before `session/new` completes;
42
+ `reject_once` when no live turn owns the session, even after MCP handshake).
36
43
  Tree navigation and compaction close conversation sessions and their files,
37
44
  retaining the process, bridge, and caches. `session_start` (`new`, `resume`, or
38
45
  `fork`) uses the same light reset if the runtime survives; `session_shutdown`
@@ -46,8 +53,8 @@ pi -e ./index.ts
46
53
  over buffered output, and turn/tenant identities guard all async callbacks.
47
54
  - **Quota and TUI:** Settled checks share the reader's TTL and in-flight request
48
55
  without blocking Pi. Model selection reads memory only. UI generation checks
49
- discard stale background results; warning keys include bucket, reset time, and
50
- threshold. An explicit quota query can discover uncached account tiers through
56
+ discard stale background results; warning keys include group, bucket, reset
57
+ time, and threshold. An explicit quota query can discover uncached account tiers through
51
58
  one tool-less ACP session per runtime, persisting the tier in `catalog.json`.
52
59
  Email lookup reads at most the last 64 KiB of each candidate login log and uses
53
60
  the last match in the first matching file. Runtime warnings stay off stderr to
@@ -114,21 +121,39 @@ npm pack --dry-run
114
121
 
115
122
  ## CI and releases
116
123
 
117
- `ci.yml` checks pull requests and pushes to `main`. `release.yml` runs only for
118
- version-tag pushes or manual runs on an existing tag, so ordinary commits do not
119
- run a second test suite or trigger publication. CI tests Node.js 22.19.0 and 24;
120
- releases use Node.js 24. There is no committed lockfile, so dependency
121
- installation uses `npm install`.
124
+ `ci.yml` checks pull requests and pushes to `main`. `release.yml` runs on pushes
125
+ to `main` (to run `release-please`), version-tag pushes, or manual runs on an
126
+ existing tag, so ordinary commits do not trigger the `publish` job. CI tests the
127
+ pinned `devDependencies` baseline on Node.js 22.19.0 and 24, plus a `pi-compat`
128
+ matrix across `@earendil-works/pi-*` `1.5.0` and latest `1.5`; releases use
129
+ Node.js 24. `.npmrc` sets `package-lock=false` so dependency installation stays
130
+ lockfile-free via `npm install`.
122
131
 
123
132
  All changes to `main` require a pull request, passing CI on both Node versions,
124
133
  and resolved review discussions. Squash merge after CI passes; no second-person
125
134
  approval is required.
126
135
 
127
- To release, bump `package.json` through a pull request, merge it, and tag the
128
- merged commit with its matching `vX.Y.Z` tag, then push the tag. The workflow
129
- accepts stable versions only; publish one version at a time and never move a published tag. It validates the tag and version, then
130
- checks, tests, and packs before publishing. Only a registry 404 means the version
131
- is absent; network, authentication, and server errors stop the job.
136
+ Releases are automated with `release-please` (`release-please-config.json` and
137
+ `.release-please-manifest.json`):
138
+ - Merging Conventional Commits (`feat:`, `fix:`, etc.) to `main` opens or updates
139
+ a release PR that bumps `package.json` and updates `CHANGELOG.md` and
140
+ `.release-please-manifest.json`.
141
+ - Squash-merging that release PR (preserving its `chore(main): release X.Y.Z`
142
+ title) creates the `vX.Y.Z` tag and GitHub Release, then triggers the
143
+ `publish` job in `release.yml` to check, test, pack, and publish to npm.
144
+ - Enable **Allow GitHub Actions to create and approve pull requests** in
145
+ repository Settings → Actions → General. Without a `RELEASE_PLEASE_TOKEN` PAT
146
+ (with `contents: write` and `pull-requests: write`) in repository secrets,
147
+ `GITHUB_TOKEN` is used; in that case, close and reopen the release PR after
148
+ its final update to trigger `ci.yml` when branch protection requires it.
149
+ - To recover a failed `publish` job, choose **Re-run failed jobs** on that
150
+ workflow run (re-running all jobs on a `main` run skips `publish` once the tag
151
+ exists) or run `gh workflow run release.yml --ref vX.Y.Z`. Manual tag pushes
152
+ (`vX.Y.Z`) also trigger `publish` but bypass `release-please`, leaving
153
+ `CHANGELOG.md` and `.release-please-manifest.json` out of sync.
154
+ - The workflow accepts stable versions only, publishes one version at a time,
155
+ and never moves a published tag. Only a registry 404 means the version is
156
+ absent; network, authentication, and server errors stop the job.
132
157
 
133
158
  Configure npm [Trusted Publishing](https://docs.npmjs.com/trusted-publishers/)
134
159
  for owner `fdkevin0`, repository `pi-agy-acp`, and workflow filename `release.yml`.
package/docs/reference.md CHANGED
@@ -77,22 +77,25 @@ isolated. Cached plans and login logs can be stale after an account change.
77
77
  ### Quota status and warnings
78
78
 
79
79
  When a run using `antigravity-acp` fully settles, the extension checks `/usage`
80
- in the background and shows a compact status such as `AGY 20%` (or `AGY 80%`
81
- in `remaining` mode). It uses the lowest remaining window in the selected model
82
- family's group, falling back to the lowest remaining quota across groups when
83
- the family cannot be matched. Failed checks stay silent. Successful results and
84
- failures both respect the two-minute quota TTL, and overlapping background
85
- checks are skipped.
86
-
87
- At 20% and 5% remaining (80% and 95% used), a warning appears once per bucket,
88
- reset time, and threshold. `/agy-acp quota` explicitly refreshes quota and updates
89
- the status; `/agy-acp status` uses fresh cached quota only. Neither session start
90
- nor model selection launches a quota command. Selecting another provider hides the
91
- status; returning to Antigravity uses only a fresh in-memory snapshot. Reset and
92
- shutdown clear the status.
93
-
94
- While loaded, this extension vetoes Pi's automatic prompt-cache warming to avoid
95
- idle requests consuming quota. It does not alter explicit model requests.
80
+ in the background and shows a compact status indicator such as `AGY 20%` (or
81
+ `AGY 80%` in `remaining` mode). It uses the lowest known remaining window across
82
+ the selected model's matching quota group(s) (or an unambiguous generic family
83
+ group), and omits the status indicator and low-quota warning when group ownership is
84
+ unknown or ambiguous. Failed background checks stay silent. Successful results
85
+ and failures both respect the two-minute quota TTL, and concurrent background
86
+ checks share the in-flight query.
87
+
88
+ At or below 20% and 5% remaining (≥80% and ≥95% used), a warning appears once
89
+ per group, quota window, reset time, and threshold. `/agy-acp quota` explicitly
90
+ refreshes quota and updates the status indicator; `/agy-acp status` uses fresh
91
+ cached quota only. Neither session start nor model selection launches a quota
92
+ command. Selecting another provider hides the status indicator; returning to
93
+ Antigravity uses only a fresh in-memory snapshot. `/agy-acp reset` clears the
94
+ status indicator and warning history; shutdown clears the status indicator.
95
+
96
+ When the active model belongs to `antigravity-acp`, this extension vetoes Pi's
97
+ automatic prompt-cache warming to avoid background warming requests consuming
98
+ quota. Other providers' warming decisions are left unchanged.
96
99
 
97
100
  ## Configuration
98
101
 
@@ -148,14 +151,28 @@ older history can be omitted to fit, and historical images become text placehold
148
151
 
149
152
  ## Usage and costs
150
153
 
151
- Usage comes only from the ACP `session/prompt` result. Parked tool steps have no
152
- separate usage report; statistics arrive when the full ACP turn finishes.
153
- For turns spanning multiple model steps, input token buckets use the upstream
154
- implementation's averaging method. They are not an exact per-step measurement.
154
+ Usage comes from the ACP session rather than per-step API headers. Parked `toolUse`
155
+ steps emit zero usage; statistics arrive on the final step when the full ACP turn
156
+ finishes (accumulated across any automatic `max_tokens` continuations).
157
+
158
+ The extension separates cumulative token consumption from final-call context
159
+ occupancy:
160
+
161
+ - `input`, `output`, `cacheRead`, and `cacheWrite` preserve unscaled cumulative
162
+ turn totals from `session/prompt`, so Pi's session totals and flat pricing
163
+ overrides reflect full multi-step consumption.
164
+ - `totalTokens` (which feeds Pi's context meter and auto-compaction threshold via
165
+ `calculateContextTokens`) uses the final model call's live `usage_update.used`
166
+ count when `agy` provides it. When `usage_update` is absent, it falls back to
167
+ averaging the final `session/prompt` segment's prompt tokens across that
168
+ segment's model calls plus final-segment output tokens; this fallback is an
169
+ estimate rather than an exact per-step measurement.
155
170
 
156
171
  Default model prices are zero because pricing is unavailable. If you configure
157
- Pi model pricing overrides, reported usage is priced using those rates. These
158
- estimates are not an invoice amount or a promise of free access.
172
+ Pi model pricing overrides, flat per-million rates price the cumulative turn
173
+ buckets accurately; tiered `inputTokensAbove` rules evaluate against cumulative
174
+ turn prompt tokens rather than per-call prompt sizes. These estimates are not
175
+ an invoice amount or a promise of free access.
159
176
 
160
177
  The extension does not inspect agy's private databases or invoke or distribute
161
178
  binary patch scripts.
@@ -163,9 +180,11 @@ binary patch scripts.
163
180
  ## Compatibility limits
164
181
 
165
182
  This version targets the `@earendil-works/*` Pi packages at version 1.5.x.
166
- Host peer dependencies use `*` as required by Pi package conventions; development
167
- dependencies constrain CI to Pi 1.5.x, which requires Node.js >= 22.19.0. Compatibility with older
168
- `@mariozechner/*` interfaces is not claimed.
183
+ Host `peerDependencies` use `*` as required by Pi package conventions;
184
+ `devDependencies` pin a reproducible CI baseline (`1.5.2`), and CI validates
185
+ both that baseline (on Node.js 22.19.0 and 24) and the `1.5.x` host range
186
+ (`1.5.0` and latest `1.5`), which requires Node.js >= 22.19.0. Compatibility
187
+ with older `@mariozechner/*` interfaces is not claimed.
169
188
 
170
189
  Sampling parameters, output limits, forced `toolChoice`, and provider-scoped
171
190
  environment overrides are not mapped to ACP. See
package/index.ts CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  type ProviderModelConfig,
5
5
  type ExtensionContext,
6
6
  } from '@earendil-works/pi-coding-agent'
7
- import { AntigravityRuntime } from './src/runtime.ts'
7
+ import { AntigravityRuntime, type RuntimeHost } from './src/runtime.ts'
8
8
  import {
9
9
  asQuotaDisplay,
10
10
  DEFAULT_QUOTA_DISPLAY,
@@ -24,7 +24,10 @@ import {
24
24
  } from './src/format.ts'
25
25
  import type { QuotaSnapshot } from './src/quota.ts'
26
26
 
27
- export default function (pi: ExtensionAPI) {
27
+ export default function (
28
+ pi: ExtensionAPI,
29
+ host: Partial<Pick<RuntimeHost, 'runCommand'>> = {},
30
+ ) {
28
31
  const envQuotaDisplay = asQuotaDisplay(process.env.PI_AGY_QUOTA_DISPLAY)
29
32
  const config = {
30
33
  ...defaults,
@@ -36,16 +39,17 @@ export default function (pi: ExtensionAPI) {
36
39
  new AntigravityRuntime({
37
40
  config,
38
41
  spawnAcp,
39
- runCommand,
42
+ runCommand: host.runCommand ?? runCommand,
40
43
  log: { info: () => {}, warn: () => {} },
41
44
  onModelsChanged: () => {
42
45
  if (refreshDepth === 0) register()
43
46
  },
44
47
  })
45
48
  let runtime = createRuntime()
49
+ const home = runtime.status().home
46
50
  let quotaDisplay: QuotaDisplay =
47
51
  envQuotaDisplay ??
48
- readQuotaDisplayPreference(runtime.status().home) ??
52
+ readQuotaDisplayPreference(home) ??
49
53
  DEFAULT_QUOTA_DISPLAY
50
54
  const models = (): ProviderModelConfig[] =>
51
55
  runtime.catalog.list().map((m) => {
@@ -98,92 +102,171 @@ export default function (pi: ExtensionAPI) {
98
102
  })
99
103
  register()
100
104
  let uiEpoch = 0
101
- let checkingQuota = false
105
+ let shutDown = false
106
+ let activeRuntime: AntigravityRuntime | undefined = runtime
107
+ let resetting: Promise<void> | undefined
108
+ interface PendingSettle {
109
+ runtime: AntigravityRuntime
110
+ epoch: number
111
+ ctx: ExtensionContext
112
+ model: ExtensionContext['model']
113
+ }
114
+ let pendingSettle: PendingSettle | undefined
102
115
  const warned = new Set<string>()
103
116
  const clearStatus = (ctx?: ExtensionContext) => {
104
117
  uiEpoch++
105
- if (ctx?.hasUI) ctx.ui.setStatus(config.provider, undefined)
118
+ pendingSettle = undefined
119
+ if (!shutDown && ctx?.hasUI) ctx.ui.setStatus(config.provider, undefined)
106
120
  }
107
121
  const updateStatus = (
108
122
  ctx: ExtensionContext,
109
123
  snapshot?: QuotaSnapshot,
110
- explicit = false,
111
124
  model = ctx.model,
112
125
  ) => {
113
- if (ctx.hasUI && (explicit || model?.provider === config.provider))
126
+ if (!shutDown && activeRuntime && ctx.hasUI && model?.provider === config.provider)
114
127
  ctx.ui.setStatus(
115
128
  config.provider,
116
129
  snapshot
117
- ? formatQuotaStatus(snapshot, model?.id, quotaDisplay)
130
+ ? formatQuotaStatus(snapshot, model, quotaDisplay)
118
131
  : undefined,
119
132
  )
120
133
  }
121
- const reset = async () => {
134
+ const reset = () => {
122
135
  uiEpoch++
123
136
  warned.clear()
124
- await runtime.dispose()
125
- runtime = createRuntime()
137
+ pendingSettle = undefined
138
+ activeRuntime = undefined
139
+ if (resetting) return resetting
140
+ const previous = runtime
141
+ resetting = (async () => {
142
+ try {
143
+ await previous.dispose()
144
+ if (shutDown) return
145
+ runtime = activeRuntime = createRuntime()
146
+ } finally {
147
+ resetting = undefined
148
+ }
149
+ })()
150
+ return resetting
126
151
  }
127
- pi.on('session_tree', () => runtime.resetConversations())
128
- pi.on('session_compact', () => runtime.resetConversations())
152
+ pi.on('session_tree', () => activeRuntime?.resetConversations())
153
+ pi.on('session_compact', () => activeRuntime?.resetConversations())
129
154
  pi.on('session_start', async (event, ctx) => {
130
155
  clearStatus(ctx)
156
+ const epoch = uiEpoch
157
+ if (resetting) await resetting.catch(() => {})
158
+ if (shutDown) return
131
159
  if (['new', 'resume', 'fork'].includes(event.reason))
132
- await runtime.resetConversations()
133
- updateStatus(ctx, runtime.quota.peek())
160
+ await activeRuntime?.resetConversations()
161
+ if (!shutDown && epoch === uiEpoch)
162
+ updateStatus(ctx, activeRuntime?.quota.peek())
134
163
  })
135
164
  pi.on('session_shutdown', async (_event, ctx) => {
136
165
  clearStatus(ctx)
166
+ shutDown = true
167
+ activeRuntime = undefined
168
+ pendingSettle = undefined
169
+ if (resetting) await resetting.catch(() => {})
137
170
  await runtime.dispose()
138
171
  })
139
- pi.on('cache_warming_decision', () => ({ action: 'stop' }))
172
+ pi.on('cache_warming_decision', (_event, ctx) =>
173
+ ctx.model?.provider === config.provider ? { action: 'stop' } : undefined,
174
+ )
140
175
  pi.on('model_select', (event, ctx) => {
176
+ const retarget =
177
+ pendingSettle &&
178
+ pendingSettle.runtime === activeRuntime &&
179
+ pendingSettle.epoch === uiEpoch &&
180
+ event.model?.provider === config.provider
181
+ ? pendingSettle
182
+ : undefined
141
183
  clearStatus(ctx)
142
- updateStatus(ctx, runtime.quota.peek(), false, event.model)
184
+ if (retarget) {
185
+ retarget.epoch = uiEpoch
186
+ retarget.ctx = ctx
187
+ retarget.model = event.model
188
+ pendingSettle = retarget
189
+ }
190
+ updateStatus(ctx, activeRuntime?.quota.peek(), event.model)
143
191
  })
144
192
  pi.on('agent_settled', (_event, ctx) => {
145
193
  // Pi 1.5.2 AgentSession._emitAgentSettled runs after tools and the run finish.
146
194
  runtime.settleSession(ctx.sessionManager.getSessionId())
147
- if (
148
- ctx.model?.provider !== config.provider ||
149
- checkingQuota ||
150
- runtime.quota.pending
151
- )
195
+ const current = activeRuntime
196
+ if (!current || !ctx.hasUI || ctx.model?.provider !== config.provider) return
197
+ if (pendingSettle?.runtime === current) {
198
+ pendingSettle.epoch = uiEpoch
199
+ pendingSettle.ctx = ctx
200
+ pendingSettle.model = ctx.model
152
201
  return
153
- const current = runtime
154
- const epoch = uiEpoch
155
- checkingQuota = true
202
+ }
203
+ const state: PendingSettle = {
204
+ runtime: current,
205
+ epoch: uiEpoch,
206
+ ctx,
207
+ model: ctx.model,
208
+ }
209
+ pendingSettle = state
156
210
  void current.quota
157
211
  .read(false)
158
212
  .then((snapshot) => {
159
213
  if (
160
- current !== runtime ||
161
- epoch !== uiEpoch ||
214
+ shutDown ||
215
+ pendingSettle !== state ||
216
+ state.runtime !== activeRuntime ||
217
+ state.epoch !== uiEpoch ||
162
218
  snapshot.status !== 'ok'
163
219
  )
164
220
  return
165
- updateStatus(ctx, snapshot)
166
- if (!ctx.hasUI || ctx.model?.provider !== config.provider) return
167
- const quota = quotaForModel(snapshot, ctx.model.id)
221
+ const targetCtx = state.ctx
222
+ const model = state.model
223
+ if (!targetCtx.hasUI || model?.provider !== config.provider) return
224
+ updateStatus(targetCtx, snapshot, model)
225
+ const quota = quotaForModel(snapshot, model)
168
226
  if (!quota || quota.fraction > 0.2) return
169
227
  const threshold = quota.fraction <= 0.05 ? 5 : 20
170
- const key = `${quota.group.name}:${quota.bucket.id}:${quota.bucket.window}:${quota.bucket.resetTime || 'none'}:${threshold}`
228
+ const groupName = quota.group.name || 'Unnamed model group'
229
+ const windowLabel =
230
+ quota.bucket.window ||
231
+ quota.bucket.name ||
232
+ quota.bucket.id ||
233
+ 'quota'
234
+ const key = `${groupName}:${quota.bucket.id}:${windowLabel}:${quota.bucket.resetTime || 'none'}:${threshold}`
171
235
  if (warned.has(key)) return
172
236
  warned.add(key)
173
237
  const percent = Math.round(
174
238
  displayFraction(quota.fraction, quotaDisplay) * 100,
175
239
  )
176
240
  const metric = `${percent}% ${quotaDisplay}`
177
- ctx.ui.notify(
178
- `Antigravity quota low: ${metric} (${quota.group.name}, ${quota.bucket.window}).`,
241
+ targetCtx.ui.notify(
242
+ `Antigravity quota low: ${metric} (${groupName}, ${windowLabel}).`,
179
243
  'warning',
180
244
  )
181
245
  })
182
246
  .catch(() => {})
183
247
  .finally(() => {
184
- checkingQuota = false
248
+ if (pendingSettle === state) pendingSettle = undefined
185
249
  })
186
250
  })
251
+ const readQuotaSafe = async (): Promise<QuotaSnapshot> => {
252
+ if (!activeRuntime)
253
+ return {
254
+ status: 'error',
255
+ updatedAt: new Date().toISOString(),
256
+ groups: [],
257
+ error: 'Antigravity ACP runtime is disposed.',
258
+ }
259
+ try {
260
+ return await activeRuntime.readQuota(true)
261
+ } catch (err) {
262
+ return {
263
+ status: 'error',
264
+ updatedAt: new Date().toISOString(),
265
+ groups: [],
266
+ error: err instanceof Error ? err.message : String(err),
267
+ }
268
+ }
269
+ }
187
270
  pi.registerCommand('agy-acp', {
188
271
  description: 'Antigravity ACP status, quota, or reset',
189
272
  getArgumentCompletions: (prefix) => {
@@ -200,6 +283,7 @@ export default function (pi: ExtensionAPI) {
200
283
  return items.length > 0 ? items : null
201
284
  },
202
285
  handler: async (args, ctx) => {
286
+ if (shutDown) return
203
287
  const tokens = args.trim().split(/\s+/).filter(Boolean)
204
288
  const command = tokens[0] ?? ''
205
289
  const requestedDisplay =
@@ -209,7 +293,7 @@ export default function (pi: ExtensionAPI) {
209
293
  if (command === 'reset' && tokens.length === 1) {
210
294
  clearStatus(ctx)
211
295
  await reset()
212
- ctx.ui.notify('Antigravity ACP sessions reset', 'info')
296
+ if (!shutDown) ctx.ui.notify('Antigravity ACP sessions reset', 'info')
213
297
  return
214
298
  }
215
299
  const isStatus =
@@ -226,7 +310,7 @@ export default function (pi: ExtensionAPI) {
226
310
  }
227
311
  if (requestedDisplay !== undefined) {
228
312
  quotaDisplay = requestedDisplay
229
- writeQuotaDisplayPreference(runtime.status().home, quotaDisplay)
313
+ writeQuotaDisplayPreference(home, quotaDisplay)
230
314
  }
231
315
  let snapshot: QuotaSnapshot | null = null
232
316
  const epoch = uiEpoch
@@ -241,17 +325,17 @@ export default function (pi: ExtensionAPI) {
241
325
  'Fetching Antigravity quota...',
242
326
  )
243
327
  loader.onAbort = () => done(null)
244
- // QuotaReader returns error snapshots, so failures also close the loader.
245
- void runtime.readQuota(true).then((result) => {
328
+ // readQuotaSafe converts runtime errors into snapshots so loaders always close cleanly.
329
+ void readQuotaSafe().then((result) => {
246
330
  if (!loader.signal.aborted) done(result)
247
331
  })
248
332
  return loader
249
333
  },
250
334
  )
251
- : await runtime.readQuota(true)
335
+ : await readQuotaSafe()
336
+ if (shutDown) return
252
337
  if (snapshot === null) {
253
- if (epoch === uiEpoch)
254
- updateStatus(ctx, runtime.quota.peek(), true)
338
+ if (epoch === uiEpoch) updateStatus(ctx, activeRuntime?.quota.peek())
255
339
  ctx.ui.notify('Quota check cancelled', 'info')
256
340
  return
257
341
  }
@@ -260,7 +344,7 @@ export default function (pi: ExtensionAPI) {
260
344
  ? formatQuota(snapshot, undefined, quotaDisplay)
261
345
  : formatStatus(runtime.status())
262
346
  if (epoch === uiEpoch)
263
- updateStatus(ctx, snapshot ?? runtime.quota.peek(), true)
347
+ updateStatus(ctx, snapshot ?? activeRuntime?.quota.peek())
264
348
  ctx.ui.notify(notice.text, notice.level)
265
349
  },
266
350
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-agy-acp",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Google Antigravity ACP provider extension for Pi Coding Agent",
@@ -39,11 +39,11 @@
39
39
  "check": "tsc --noEmit"
40
40
  },
41
41
  "devDependencies": {
42
- "typescript": "^5.9.0",
43
- "@types/node": "^22.0.0",
44
- "@earendil-works/pi-ai": "~1.5.0",
45
- "@earendil-works/pi-coding-agent": "~1.5.0",
46
- "@earendil-works/pi-tui": "~1.5.0"
42
+ "typescript": "7.0.2",
43
+ "@types/node": "22.20.5",
44
+ "@earendil-works/pi-ai": "1.5.2",
45
+ "@earendil-works/pi-coding-agent": "1.5.2",
46
+ "@earendil-works/pi-tui": "1.5.2"
47
47
  },
48
48
  "keywords": [
49
49
  "pi-package",
@@ -36,6 +36,7 @@ export interface AcpSessionUpdate {
36
36
  sessionUpdate: string
37
37
  content?: { type: string; text?: string }
38
38
  toolCallId?: string
39
+ name?: string
39
40
  title?: string
40
41
  status?: string
41
42
  kind?: string
@@ -74,6 +75,7 @@ export interface AcpPermissionRequest {
74
75
  sessionId: string
75
76
  toolCall?: {
76
77
  toolCallId?: string
78
+ name?: string
77
79
  title?: string
78
80
  kind?: string
79
81
  rawInput?: unknown