pi-agy-acp 0.2.1 → 0.2.3
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 +16 -0
- package/README.md +11 -7
- package/docs/architecture.md +262 -0
- package/docs/development.md +68 -156
- package/docs/reference.md +151 -128
- package/docs/releasing.md +56 -0
- package/index.ts +87 -22
- package/package.json +1 -1
- package/src/acp-process.ts +15 -1
- package/src/catalog.ts +66 -48
- package/src/config.ts +1 -1
- package/src/conversation.ts +66 -16
- package/src/format.ts +68 -23
- package/src/host.ts +148 -13
- package/src/jsonrpc.ts +38 -4
- package/src/mcp-bridge.ts +26 -2
- package/src/preflight.ts +296 -371
- package/src/quota.ts +39 -20
- package/src/runtime.ts +549 -244
- package/src/session-db.ts +670 -0
package/docs/reference.md
CHANGED
|
@@ -1,23 +1,35 @@
|
|
|
1
1
|
# Reference
|
|
2
2
|
|
|
3
|
-
For installation and your first request, start with the
|
|
3
|
+
For installation and your first request, start with the
|
|
4
|
+
[installation guide](../README.md#install). For internal protocol and runtime
|
|
5
|
+
details, see [architecture](architecture.md).
|
|
4
6
|
|
|
5
7
|
## Commands
|
|
6
8
|
|
|
7
9
|
| Command | Behavior |
|
|
8
10
|
| --- | --- |
|
|
9
|
-
| `/agy-acp` or `/agy-acp status` | Show a status panel with runtime state, paths, sessions, model reasoning levels, and the last turn. |
|
|
10
|
-
| `/agy-acp quota [used\|remaining]` | Show account details, grouped quota bars, and reset countdowns, optionally switching and
|
|
11
|
-
| `/agy-acp
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
| `/agy-acp` or `/agy-acp status` | Show a status panel with runtime state, paths, account details, sessions, model reasoning levels, and the last turn. |
|
|
12
|
+
| `/agy-acp quota [used\|remaining]` | Show account details, grouped quota bars, and reset countdowns, optionally switching and saving the display mode. |
|
|
13
|
+
| `/agy-acp refresh` | Force a live model catalog refresh from `agy` and update `catalog.json`. |
|
|
14
|
+
| `/agy-acp reset` | Dispose the ACP runtime (stopping `agy`), clear sessions, status indicator, quota cache, and warning history; the next request rebuilds from Pi's history. |
|
|
15
|
+
|
|
16
|
+
Subcommands support Tab completion (`status`, `quota`, `quota used`,
|
|
17
|
+
`quota remaining`, `refresh`, `reset`). Unknown arguments show
|
|
18
|
+
`Usage: /agy-acp [status|quota [used|remaining]|refresh|reset]` as a warning.
|
|
19
|
+
|
|
20
|
+
In interactive TUI mode, `/agy-acp quota` (`Fetching Antigravity quota...`) and
|
|
21
|
+
`/agy-acp refresh` (`Refreshing Antigravity models...`) display a cancellable
|
|
22
|
+
loader. Pressing Escape returns to the editor: `/agy-acp refresh` cancels the
|
|
23
|
+
caller's wait, while `/agy-acp quota` hides the pending panel even if the
|
|
24
|
+
underlying `/usage` query finishes updating the cache. Non-TUI modes run
|
|
25
|
+
directly without a loader.
|
|
15
26
|
|
|
16
27
|
### Status panel
|
|
17
28
|
|
|
18
|
-
The panel
|
|
19
|
-
|
|
20
|
-
|
|
29
|
+
The panel reports the runtime as `idle`, `starting`, `ready`, or `error`.
|
|
30
|
+
Viewing status never starts `agy`; before `agy` has been probed (by a turn,
|
|
31
|
+
`/agy-acp refresh`, or plan discovery), it shows the isolated home and notes
|
|
32
|
+
that `agy` starts lazily. Models list their supported reasoning levels,
|
|
21
33
|
including a fixed level where applicable.
|
|
22
34
|
|
|
23
35
|
Once a turn finishes, its summary shows the model, effort, outcome (`completed`,
|
|
@@ -29,16 +41,9 @@ healthy runtime uses a warning.
|
|
|
29
41
|
|
|
30
42
|
### Quota panel
|
|
31
43
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
will not appear after cancellation. Non-TUI modes query directly without a loader.
|
|
36
|
-
|
|
37
|
-
Quota is read through `agy -p /usage --output-format json`. Each model group has
|
|
38
|
-
one row per quota window, with a 12-cell bar, a rounded percentage, and a relative
|
|
39
|
-
reset time. By default (`used` mode), bars and percentages count up from `0%`; pass
|
|
40
|
-
`remaining` (`/agy-acp quota remaining`) to count down from `100%`. The last
|
|
41
|
-
selected mode is saved in `settings.json` inside `PI_AGY_HOME`. For example:
|
|
44
|
+
Quota is read through `agy -p /usage --output-format json`. Disabled quota
|
|
45
|
+
buckets are excluded. Each model group renders one row per usable quota window
|
|
46
|
+
with a 12-cell bar, a rounded percentage, and a relative reset countdown:
|
|
42
47
|
|
|
43
48
|
```text
|
|
44
49
|
Antigravity Quota
|
|
@@ -46,71 +51,88 @@ Antigravity Quota
|
|
|
46
51
|
|
|
47
52
|
Gemini Models
|
|
48
53
|
Gemini Flash, Gemini Pro
|
|
49
|
-
5h [░░░░░░░░░░░░] 0%
|
|
54
|
+
5h [░░░░░░░░░░░░] 0%
|
|
50
55
|
weekly [█░░░░░░░░░░░] 9% · resets in 6d 7h
|
|
51
56
|
```
|
|
52
57
|
|
|
53
|
-
|
|
54
|
-
|
|
58
|
+
- **Display mode:** Default is `used` (bars and percentages count up from `0%`).
|
|
59
|
+
Pass `remaining` (`/agy-acp quota remaining`) to count down from `100%`. When
|
|
60
|
+
a mode is passed, it is saved to `<PI_AGY_HOME>/settings.json` immediately,
|
|
61
|
+
even if the quota query is cancelled or fails.
|
|
62
|
+
- **Reset labels:** Untouched rolling windows at `0%` used (`100%` remaining)
|
|
63
|
+
whose reset time is still a full window away omit the countdown. Otherwise,
|
|
64
|
+
missing values show `n/a`, elapsed resets show `resetting soon`, unparseable
|
|
65
|
+
timestamps show `reset time unavailable`, and sub-minute windows show
|
|
66
|
+
`resets in <1m`.
|
|
67
|
+
- **Empty and stale responses:** A group with no usable windows shows
|
|
68
|
+
`No quota windows available.`, and an empty successful response shows
|
|
69
|
+
`No quota data available.`. Failed queries include the reason; if cached
|
|
70
|
+
groups exist, the title marks them `(stale)` and still renders their bars.
|
|
71
|
+
|
|
72
|
+
Notification severity uses the actual remaining fraction rather than the rounded
|
|
73
|
+
percentage:
|
|
55
74
|
|
|
56
75
|
| Condition | Notification |
|
|
57
76
|
| --- | --- |
|
|
58
77
|
| All known windows above 20% remaining (<80% used) | Info |
|
|
59
|
-
| Any window at or below 20% remaining (≥80% used),
|
|
78
|
+
| Any window at or below 20% remaining (≥80% used), none at or below 5% remaining | Warning |
|
|
60
79
|
| Any window at or below 5% remaining (≥95% used), or a failed quota query | Error |
|
|
61
80
|
|
|
62
|
-
Errors include the reason. If cached groups are available after a failed query,
|
|
63
|
-
the title marks them as `(stale)` and still displays their bars. An empty
|
|
64
|
-
successful response displays `No quota data available.`.
|
|
65
|
-
|
|
66
81
|
### Account details
|
|
67
82
|
|
|
68
|
-
Both panels
|
|
69
|
-
fields
|
|
70
|
-
it. This may start ACP but sends no model prompt; failure does not prevent quota
|
|
71
|
-
from appearing. Use `/agy-acp reset` to retry discovery. Viewing status never starts it.
|
|
83
|
+
Both panels display the email and subscription plan when known and omit
|
|
84
|
+
unavailable fields:
|
|
72
85
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
86
|
+
- **Plan:** If no plan is cached, the first `/agy-acp quota` query attempts
|
|
87
|
+
discovery using a temporary tool-less ACP session (stopped afterward if the
|
|
88
|
+
runtime was idle) without sending a model prompt. Failure does not block quota
|
|
89
|
+
display; use `/agy-acp reset` to retry discovery. Viewing status never probes
|
|
90
|
+
`agy`.
|
|
91
|
+
- **Email:** Read from `agy` login logs. With the default `PI_AGY_HOME`, the
|
|
92
|
+
extension also checks `ANTIGRAVITY_CLI_HOME`, `AGY_HOME`, and
|
|
93
|
+
`~/.gemini/antigravity-cli`; a custom `PI_AGY_HOME` stays isolated. Cached
|
|
94
|
+
plans and login logs can be stale after an account change.
|
|
79
95
|
|
|
80
96
|
### Quota status and warnings
|
|
81
97
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
per group,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
After an `antigravity-acp` run settles, the extension refreshes `/usage` in the
|
|
99
|
+
background (sharing any in-flight request and respecting the 2-minute TTL) and
|
|
100
|
+
displays a compact status bar indicator such as `AGY 20%` (or `AGY 80%` in
|
|
101
|
+
`remaining` mode):
|
|
102
|
+
|
|
103
|
+
- The percentage reflects the lowest known remaining window across the active
|
|
104
|
+
model's matching quota group(s). When group ownership is unknown or ambiguous
|
|
105
|
+
(including effort-capped pools without a known effort), the indicator and
|
|
106
|
+
low-quota warning are omitted.
|
|
107
|
+
- Background query failures stay silent and also respect the 2-minute TTL.
|
|
108
|
+
- Low-quota warnings fire once per group, window, reset time, and threshold at
|
|
109
|
+
or below 20% remaining (≥80% used) and 5% remaining (≥95% used).
|
|
110
|
+
- `/agy-acp quota` refreshes quota and updates the indicator; `/agy-acp status`
|
|
111
|
+
uses fresh cached quota only. Neither session start nor model selection starts
|
|
112
|
+
a quota command (switching between `antigravity-acp` models while a post-turn
|
|
113
|
+
check is already in flight retargets that check to the newly selected model).
|
|
114
|
+
- Selecting another provider hides the indicator; returning to Antigravity uses
|
|
115
|
+
only a fresh in-memory snapshot. `/agy-acp reset` clears the indicator and
|
|
116
|
+
warning history; shutdown clears the indicator.
|
|
117
|
+
|
|
118
|
+
Two automatic Pi safeguards also apply when `antigravity-acp` is the active
|
|
119
|
+
provider (other providers are untouched):
|
|
120
|
+
|
|
121
|
+
- **Prompt-cache warming veto:** Cancels Pi's automatic prompt-cache warming so
|
|
122
|
+
background warming requests do not consume Antigravity quota.
|
|
123
|
+
- **Auto-compaction threshold guard:** Cancels threshold-triggered compaction
|
|
124
|
+
while a model's context window is still unknown (`0`).
|
|
102
125
|
|
|
103
126
|
## Configuration
|
|
104
127
|
|
|
105
|
-
Set
|
|
128
|
+
Set environment variables before starting Pi:
|
|
106
129
|
|
|
107
130
|
| Variable | Purpose | Default |
|
|
108
131
|
| --- | --- | --- |
|
|
109
132
|
| `PI_AGY_COMMAND` | Absolute path to the `agy` executable. | Automatic discovery. |
|
|
110
|
-
| `PI_AGY_HOME` | Dedicated directory for this extension's
|
|
133
|
+
| `PI_AGY_HOME` | Dedicated directory for this extension's state. | `~/.pi/agent/cache/antigravity-acp` |
|
|
111
134
|
| `PI_AGY_QUOTA_DISPLAY` | Startup quota display mode (`used` or `remaining`), overriding `settings.json` for startup. Invalid values are ignored; `/agy-acp quota <mode>` overrides it for the active session. | `settings.json`, then `used` |
|
|
112
|
-
|
|
113
|
-
For example:
|
|
135
|
+
| `PI_AGY_DEBUG` | Set to `1` to print runtime warnings on `stderr` (silent by default to protect the TUI). | Unset (silent) |
|
|
114
136
|
|
|
115
137
|
```sh
|
|
116
138
|
PI_AGY_COMMAND=/absolute/path/to/agy pi -e ./index.ts
|
|
@@ -118,82 +140,83 @@ PI_AGY_COMMAND=/absolute/path/to/agy pi -e ./index.ts
|
|
|
118
140
|
|
|
119
141
|
### Stored data and authentication
|
|
120
142
|
|
|
121
|
-
|
|
122
|
-
plugins. It
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
143
|
+
`PI_AGY_HOME` isolates the bridge agent from your normal `agy` tools and
|
|
144
|
+
plugins. It stores the extension's `catalog.json`, `settings.json` (quota
|
|
145
|
+
display preference), ACP logs, and `agy/` (isolated `agy` state, settings, and
|
|
146
|
+
session databases).
|
|
147
|
+
|
|
148
|
+
- **Cleanup:** Temporary session artifacts and old logs are removed
|
|
149
|
+
automatically (best-effort if locked). Current logs, `catalog.json`,
|
|
150
|
+
`settings.json`, and authentication files are retained; sessions rebuild from
|
|
151
|
+
Pi's history. Use a separate `PI_AGY_HOME` for each concurrently running Pi
|
|
152
|
+
instance because startup cleanup assumes exclusive directory ownership.
|
|
153
|
+
- **OAuth sync:** With the default `PI_AGY_HOME` and file-backed auth, the
|
|
154
|
+
extension atomically syncs `antigravity-oauth-token` from your normal `agy`
|
|
155
|
+
directory (`ANTIGRAVITY_CLI_HOME`, `AGY_HOME`, or `~/.gemini/antigravity-cli`)
|
|
156
|
+
with `0600` permissions when the isolated copy is missing, empty, or older,
|
|
157
|
+
refusing symlinked paths. Sync failures warn rather than aborting startup. A
|
|
158
|
+
custom `PI_AGY_HOME` stays isolated and never copies tokens from default `agy`
|
|
159
|
+
directories.
|
|
160
|
+
- **Global quota scope:** `agy -p /usage` does not accept `--gemini-dir`, so
|
|
161
|
+
quota queries always reflect the global `agy` CLI account. Do not commit or
|
|
162
|
+
share `PI_AGY_HOME`; authentication and token refresh remain `agy`'s
|
|
163
|
+
responsibility.
|
|
134
164
|
|
|
135
165
|
## Models and context
|
|
136
166
|
|
|
137
|
-
Loading the extension restores
|
|
138
|
-
empty on a fresh install) without starting agy
|
|
139
|
-
`/model`)
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
167
|
+
- **Discovery and caching:** Loading the extension restores `catalog.json` (or
|
|
168
|
+
starts empty on a fresh install) without starting `agy`. Non-forced refreshes
|
|
169
|
+
(Pi startup or opening `/model`) reuse `catalog.json` without spawning `agy`
|
|
170
|
+
whenever cached models match the current `agy` binary fingerprint. Live ACP
|
|
171
|
+
discovery runs when no matching cache exists, on `/agy-acp refresh`, on the
|
|
172
|
+
first live request, or after an `agy` binary upgrade once refreshed or
|
|
173
|
+
restarted. Standalone discovery stops its temporary ACP process afterward,
|
|
174
|
+
and idle ACP processes shut down automatically after sessions expire.
|
|
175
|
+
- **Reasoning levels:** The `/model` selector exposes only the levels offered
|
|
176
|
+
for each model (`low`, `medium`, `high`, `xhigh`, `max`). Direct requests map
|
|
177
|
+
`minimal` to `low`, clamp requested levels to the nearest offered effort, and
|
|
178
|
+
treat `off` as the runtime default (`high`).
|
|
179
|
+
- **Context windows and replay:** Context windows start at `0` until learned
|
|
180
|
+
dynamically from session metadata and cached per model in `catalog.json`
|
|
181
|
+
against the `agy` binary fingerprint; upgrading `agy` invalidates cached
|
|
182
|
+
context windows. History replay uses a 160,000-byte budget—older turns can be
|
|
183
|
+
omitted to fit, and historical images become `[image]` placeholders.
|
|
153
184
|
|
|
154
185
|
## Usage and costs
|
|
155
186
|
|
|
156
|
-
Usage comes from the ACP session rather than per-step
|
|
157
|
-
steps emit zero usage; statistics arrive on the final step when the
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
`usage_update` (and same-turn `estimated_tokens_used` metadata when `usage_update`
|
|
161
|
-
is absent) supplies live token occupancy.
|
|
187
|
+
Usage comes from the ACP session rather than per-step HTTP headers. Parked
|
|
188
|
+
`toolUse` steps emit zero usage; statistics arrive on the final step when the
|
|
189
|
+
ACP turn completes (accumulated across any automatic `max_tokens` continuations)
|
|
190
|
+
whenever `session/prompt` reports usage.
|
|
162
191
|
|
|
163
|
-
The extension separates cumulative
|
|
192
|
+
The extension separates cumulative turn consumption from final-call context
|
|
164
193
|
occupancy:
|
|
165
194
|
|
|
166
|
-
- `input`, `output`, `cacheRead`, and `
|
|
167
|
-
turn totals
|
|
195
|
+
- `input`, `output`, `cacheRead`, `cacheWrite`, and `reasoning` preserve
|
|
196
|
+
unscaled cumulative turn totals, so Pi session totals and flat pricing
|
|
168
197
|
overrides reflect full multi-step consumption.
|
|
169
|
-
- `totalTokens` (
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
it never inspects your global `agy` databases or invokes or distributes binary patch
|
|
185
|
-
scripts.
|
|
198
|
+
- `totalTokens` (feeding Pi's context meter and auto-compaction threshold) uses
|
|
199
|
+
the final call's live token occupancy when reported by `agy`, falling back to
|
|
200
|
+
the same turn's session metadata estimate and then a final-segment average
|
|
201
|
+
estimate.
|
|
202
|
+
|
|
203
|
+
Default model prices are zero because upstream pricing is unavailable. With Pi
|
|
204
|
+
pricing overrides, flat per-million rates price cumulative turn buckets
|
|
205
|
+
accurately; tiered `inputTokensAbove` rules evaluate against cumulative turn
|
|
206
|
+
prompt tokens rather than per-call prompt sizes. These numbers are estimates,
|
|
207
|
+
not an invoice or a promise of free access.
|
|
208
|
+
|
|
209
|
+
Read-only SQLite inspection is restricted strictly to session-scoped databases
|
|
210
|
+
inside `PI_AGY_HOME` (for context windows, occupancy estimates, and hidden
|
|
211
|
+
terminal API error detection); the extension never reads global `agy` databases
|
|
212
|
+
or invokes/distributes binary patches.
|
|
186
213
|
|
|
187
214
|
## Compatibility limits
|
|
188
215
|
|
|
189
|
-
|
|
190
|
-
Pi
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
(
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
Sampling parameters, output limits, forced `toolChoice`, and provider-scoped
|
|
198
|
-
environment overrides are not mapped to ACP. See
|
|
199
|
-
[development checks](development.md#verification) for the scope of automated validation.
|
|
216
|
+
- Requires Node.js >= 22.19.0, Pi (`@earendil-works/*`) 1.5.x, and `agy` >=
|
|
217
|
+
1.5.10. Older `@mariozechner/*` Pi interfaces are not supported.
|
|
218
|
+
- Sampling parameters, output limits, forced `toolChoice`, and provider-scoped
|
|
219
|
+
environment overrides are not mapped to ACP.
|
|
220
|
+
|
|
221
|
+
See [verification](development.md#verification) for the automated test and
|
|
222
|
+
compatibility scope.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Releasing
|
|
2
|
+
|
|
3
|
+
Maintainer guide for automated releases and publishing recovery. For everyday
|
|
4
|
+
CI checks and pull request rules, see
|
|
5
|
+
[CI and pull requests](development.md#ci-and-pull-requests).
|
|
6
|
+
|
|
7
|
+
## Automated release flow
|
|
8
|
+
|
|
9
|
+
Releases are managed by `release-please` (`release-please-config.json` and
|
|
10
|
+
`.release-please-manifest.json`) via `.github/workflows/release.yml` on Node.js
|
|
11
|
+
24:
|
|
12
|
+
|
|
13
|
+
1. Merging Conventional Commits (`feat:`, `fix:`, etc.) to `main` runs the
|
|
14
|
+
`release-please` job, which opens or updates a release PR updating
|
|
15
|
+
`package.json`, `CHANGELOG.md`, and `.release-please-manifest.json`.
|
|
16
|
+
2. Squash-merging that release PR (preserving its `chore(main): release X.Y.Z`
|
|
17
|
+
title) creates the `vX.Y.Z` tag and GitHub Release, then triggers the
|
|
18
|
+
`publish` job to run `npm run check`, `npm test`, `npm pack --dry-run`, and
|
|
19
|
+
`npm publish --access public --provenance`.
|
|
20
|
+
|
|
21
|
+
Ordinary commits to `main` run `release-please` only and do not trigger
|
|
22
|
+
`publish`.
|
|
23
|
+
|
|
24
|
+
## Repository settings and credentials
|
|
25
|
+
|
|
26
|
+
- **GitHub Actions PR permissions:** Enable **Allow GitHub Actions to create and
|
|
27
|
+
approve pull requests** in Settings → Actions → General. Without a
|
|
28
|
+
`RELEASE_PLEASE_TOKEN` PAT (`contents: write` and `pull-requests: write`) in
|
|
29
|
+
repository secrets, `GITHUB_TOKEN` is used; close and reopen the release PR
|
|
30
|
+
after its final update to trigger `ci.yml` when branch protection requires it.
|
|
31
|
+
- **npm Trusted Publishing (OIDC):** Configure Trusted Publishing on npm for
|
|
32
|
+
owner `fdkevin0`, repository `pi-agy-acp`, and workflow `release.yml`. The
|
|
33
|
+
`publish` job grants `id-token: write` and updates npm to `^11.5.1`.
|
|
34
|
+
- **Token fallback:** An optional `NPM_TOKEN` repository secret supplies
|
|
35
|
+
`NODE_AUTH_TOKEN` (use a granular write token with 2FA bypass if needed).
|
|
36
|
+
|
|
37
|
+
## Guardrails and recovery
|
|
38
|
+
|
|
39
|
+
- The `publish` job accepts stable semver tags (`vX.Y.Z`) matching
|
|
40
|
+
`package.json` only, publishes one version at a time, and never moves an
|
|
41
|
+
existing tag. Branch-based `workflow_dispatch` runs are rejected.
|
|
42
|
+
- Only an npm registry HTTP `404` is treated as unpublished; HTTP `200` skips
|
|
43
|
+
republishing, and network, auth, or server errors stop the job.
|
|
44
|
+
- **Recovering a failed `publish` job** (or missing GitHub Release after npm
|
|
45
|
+
publication succeeded): choose **Re-run failed jobs** on that workflow run
|
|
46
|
+
(re-running all jobs on a `main` run skips `publish` once the tag exists), or
|
|
47
|
+
run:
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
gh workflow run release.yml --ref vX.Y.Z
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
GitHub Releases are created only for existing tags via
|
|
54
|
+
`gh release create --verify-tag`. Manual tag pushes (`vX.Y.Z`) also trigger
|
|
55
|
+
`publish` but bypass `release-please`, leaving `CHANGELOG.md` and
|
|
56
|
+
`.release-please-manifest.json` out of sync.
|
package/index.ts
CHANGED
|
@@ -26,9 +26,10 @@ import type { QuotaSnapshot } from './src/quota.ts'
|
|
|
26
26
|
|
|
27
27
|
export default function (
|
|
28
28
|
pi: ExtensionAPI,
|
|
29
|
-
host: Partial<Pick<RuntimeHost, 'runCommand' | 'spawnAcp'>> = {},
|
|
29
|
+
host: Partial<Pick<RuntimeHost, 'runCommand' | 'spawnAcp' | 'quotaNow'>> = {},
|
|
30
30
|
) {
|
|
31
31
|
const envQuotaDisplay = asQuotaDisplay(process.env.PI_AGY_QUOTA_DISPLAY)
|
|
32
|
+
const debug = process.env.PI_AGY_DEBUG === '1'
|
|
32
33
|
const config = {
|
|
33
34
|
...defaults,
|
|
34
35
|
command: process.env.PI_AGY_COMMAND || '',
|
|
@@ -40,7 +41,15 @@ export default function (
|
|
|
40
41
|
config,
|
|
41
42
|
spawnAcp: host.spawnAcp ?? spawnAcp,
|
|
42
43
|
runCommand: host.runCommand ?? runCommand,
|
|
43
|
-
|
|
44
|
+
quotaNow: host.quotaNow,
|
|
45
|
+
log: {
|
|
46
|
+
info: () => {},
|
|
47
|
+
warn: debug
|
|
48
|
+
? (message) => {
|
|
49
|
+
process.stderr.write(`[pi-agy-acp] ${message}\n`)
|
|
50
|
+
}
|
|
51
|
+
: () => {},
|
|
52
|
+
},
|
|
44
53
|
onModelsChanged: () => {
|
|
45
54
|
if (refreshDepth === 0) register()
|
|
46
55
|
},
|
|
@@ -276,8 +285,49 @@ export default function (
|
|
|
276
285
|
}
|
|
277
286
|
}
|
|
278
287
|
}
|
|
288
|
+
type RefreshOutcome =
|
|
289
|
+
| { status: 'ok'; count: number }
|
|
290
|
+
| { status: 'cancelled' }
|
|
291
|
+
| { status: 'error'; error: string }
|
|
292
|
+
const refreshModelsSafe = async (
|
|
293
|
+
signal?: AbortSignal,
|
|
294
|
+
): Promise<RefreshOutcome> => {
|
|
295
|
+
const current = activeRuntime
|
|
296
|
+
if (!current) {
|
|
297
|
+
return {
|
|
298
|
+
status: 'error',
|
|
299
|
+
error: 'Antigravity ACP runtime is disposed.',
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
try {
|
|
303
|
+
await current.warmup({ force: true, signal })
|
|
304
|
+
return { status: 'ok', count: current.catalog.list().length }
|
|
305
|
+
} catch (err) {
|
|
306
|
+
if (signal?.aborted) return { status: 'cancelled' }
|
|
307
|
+
return {
|
|
308
|
+
status: 'error',
|
|
309
|
+
error: err instanceof Error ? err.message : String(err),
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
const withLoader = <T>(
|
|
314
|
+
ctx: ExtensionContext,
|
|
315
|
+
label: string,
|
|
316
|
+
cancelled: T,
|
|
317
|
+
run: (signal?: AbortSignal) => Promise<T>,
|
|
318
|
+
): Promise<T> =>
|
|
319
|
+
ctx.mode === 'tui' && typeof ctx.ui.custom === 'function'
|
|
320
|
+
? ctx.ui.custom<T>((tui, theme, _kb, done) => {
|
|
321
|
+
const loader = new BorderedLoader(tui, theme, label)
|
|
322
|
+
loader.onAbort = () => done(cancelled)
|
|
323
|
+
void run(loader.signal).then((result) => {
|
|
324
|
+
if (!loader.signal.aborted) done(result)
|
|
325
|
+
})
|
|
326
|
+
return loader
|
|
327
|
+
})
|
|
328
|
+
: run()
|
|
279
329
|
pi.registerCommand('agy-acp', {
|
|
280
|
-
description: 'Antigravity ACP status, quota, or reset',
|
|
330
|
+
description: 'Antigravity ACP status, quota, refresh, or reset',
|
|
281
331
|
getArgumentCompletions: (prefix) => {
|
|
282
332
|
const normalized = prefix.trimStart()
|
|
283
333
|
const items = [
|
|
@@ -285,6 +335,7 @@ export default function (
|
|
|
285
335
|
'quota',
|
|
286
336
|
'quota used',
|
|
287
337
|
'quota remaining',
|
|
338
|
+
'refresh',
|
|
288
339
|
'reset',
|
|
289
340
|
]
|
|
290
341
|
.filter((command) => command.startsWith(normalized))
|
|
@@ -299,6 +350,31 @@ export default function (
|
|
|
299
350
|
command === 'quota' && tokens.length === 2
|
|
300
351
|
? asQuotaDisplay(tokens[1])
|
|
301
352
|
: undefined
|
|
353
|
+
if (command === 'refresh' && tokens.length === 1) {
|
|
354
|
+
const outcome = await withLoader<RefreshOutcome>(
|
|
355
|
+
ctx,
|
|
356
|
+
'Refreshing Antigravity models...',
|
|
357
|
+
{ status: 'cancelled' },
|
|
358
|
+
refreshModelsSafe,
|
|
359
|
+
)
|
|
360
|
+
if (shutDown) return
|
|
361
|
+
if (outcome.status === 'cancelled') {
|
|
362
|
+
ctx.ui.notify('Model refresh cancelled', 'info')
|
|
363
|
+
return
|
|
364
|
+
}
|
|
365
|
+
if (outcome.status === 'error') {
|
|
366
|
+
ctx.ui.notify(
|
|
367
|
+
`Antigravity model refresh failed: ${outcome.error}`,
|
|
368
|
+
'error',
|
|
369
|
+
)
|
|
370
|
+
return
|
|
371
|
+
}
|
|
372
|
+
ctx.ui.notify(
|
|
373
|
+
`Refreshed Antigravity catalog (${outcome.count} model${outcome.count === 1 ? '' : 's'})`,
|
|
374
|
+
'info',
|
|
375
|
+
)
|
|
376
|
+
return
|
|
377
|
+
}
|
|
302
378
|
if (command === 'reset' && tokens.length === 1) {
|
|
303
379
|
clearStatus(ctx)
|
|
304
380
|
await reset()
|
|
@@ -312,7 +388,7 @@ export default function (
|
|
|
312
388
|
(tokens.length === 1 || requestedDisplay !== undefined)
|
|
313
389
|
if (!isStatus && !isQuota) {
|
|
314
390
|
ctx.ui.notify(
|
|
315
|
-
'Usage: /agy-acp [status|quota [used|remaining]|reset]',
|
|
391
|
+
'Usage: /agy-acp [status|quota [used|remaining]|refresh|reset]',
|
|
316
392
|
'warning',
|
|
317
393
|
)
|
|
318
394
|
return
|
|
@@ -324,24 +400,13 @@ export default function (
|
|
|
324
400
|
let snapshot: QuotaSnapshot | null = null
|
|
325
401
|
const epoch = uiEpoch
|
|
326
402
|
if (command === 'quota') {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
'Fetching Antigravity quota...',
|
|
335
|
-
)
|
|
336
|
-
loader.onAbort = () => done(null)
|
|
337
|
-
// readQuotaSafe converts runtime errors into snapshots so loaders always close cleanly.
|
|
338
|
-
void readQuotaSafe().then((result) => {
|
|
339
|
-
if (!loader.signal.aborted) done(result)
|
|
340
|
-
})
|
|
341
|
-
return loader
|
|
342
|
-
},
|
|
343
|
-
)
|
|
344
|
-
: await readQuotaSafe()
|
|
403
|
+
// readQuotaSafe converts runtime errors into snapshots so loaders always close cleanly.
|
|
404
|
+
snapshot = await withLoader<QuotaSnapshot | null>(
|
|
405
|
+
ctx,
|
|
406
|
+
'Fetching Antigravity quota...',
|
|
407
|
+
null,
|
|
408
|
+
() => readQuotaSafe(),
|
|
409
|
+
)
|
|
345
410
|
if (shutDown) return
|
|
346
411
|
if (snapshot === null) {
|
|
347
412
|
if (epoch === uiEpoch) updateStatus(ctx, activeRuntime?.quota.peek())
|
package/package.json
CHANGED
package/src/acp-process.ts
CHANGED
|
@@ -167,6 +167,8 @@ export class AcpProcess {
|
|
|
167
167
|
private readonly listeners = new Map<string, AcpSessionListener>()
|
|
168
168
|
private child: AcpChild | undefined
|
|
169
169
|
private peer: JsonRpcPeer | undefined
|
|
170
|
+
private childExited = false
|
|
171
|
+
private childTerminated = false
|
|
170
172
|
private exitError: Error | undefined
|
|
171
173
|
private readonly exitListeners = new Set<(error: Error) => void>()
|
|
172
174
|
private readonly options: AcpProcessOptions
|
|
@@ -202,15 +204,21 @@ export class AcpProcess {
|
|
|
202
204
|
async start(timeoutMs: number): Promise<AcpInitializeResult | undefined> {
|
|
203
205
|
const child = this.options.spawn(this.options.argv, this.options.cwd)
|
|
204
206
|
this.child = child
|
|
207
|
+
this.childExited = false
|
|
208
|
+
this.childTerminated = false
|
|
205
209
|
const peer = new JsonRpcPeer(child.stdout, child.stdin, {
|
|
206
210
|
onRequest: (method, params) => this.onRequest(method, params),
|
|
207
211
|
onNotification: (method, params) => this.onNotification(method, params),
|
|
208
|
-
onClose: (error) =>
|
|
212
|
+
onClose: (error) => {
|
|
213
|
+
if (!this.childExited) this.terminateChild()
|
|
214
|
+
this.fail(error)
|
|
215
|
+
},
|
|
209
216
|
onProtocolError: (detail) =>
|
|
210
217
|
this.options.log?.(`acp: dropped frame: ${detail}`),
|
|
211
218
|
})
|
|
212
219
|
this.peer = peer
|
|
213
220
|
void child.exited.then(({ code, signal }) => {
|
|
221
|
+
this.childExited = true
|
|
214
222
|
const tail = child.stderrTail().trim().split('\n').slice(-5).join(' | ')
|
|
215
223
|
const error = new Error(
|
|
216
224
|
`agy acp exited (code=${code ?? 'null'} signal=${signal ?? 'null'})${tail ? `: ${tail}` : ''}`,
|
|
@@ -237,6 +245,12 @@ export class AcpProcess {
|
|
|
237
245
|
const error = new Error('ACP process stopped')
|
|
238
246
|
this.fail(error)
|
|
239
247
|
this.peer?.close(error)
|
|
248
|
+
this.terminateChild()
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
private terminateChild(): void {
|
|
252
|
+
if (this.childTerminated || this.childExited) return
|
|
253
|
+
this.childTerminated = true
|
|
240
254
|
this.child?.terminate()
|
|
241
255
|
}
|
|
242
256
|
|