zcode-acp-server 0.65.1 → 0.67.0

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.
Files changed (60) hide show
  1. package/README.md +27 -2
  2. package/dist/backend/resolve.js +3 -3
  3. package/dist/backend/resolve.js.map +1 -1
  4. package/dist/bin/quota.js +2 -2
  5. package/dist/code-fingerprint.json +2 -2
  6. package/dist/config/settings.d.ts +2 -0
  7. package/dist/config/settings.d.ts.map +1 -1
  8. package/dist/config/settings.js +7 -0
  9. package/dist/config/settings.js.map +1 -1
  10. package/dist/config/user-config.d.ts +3 -1
  11. package/dist/config/user-config.d.ts.map +1 -1
  12. package/dist/config/user-config.js +7 -0
  13. package/dist/config/user-config.js.map +1 -1
  14. package/dist/goal-loop/driver.d.ts.map +1 -1
  15. package/dist/goal-loop/driver.js +3 -13
  16. package/dist/goal-loop/driver.js.map +1 -1
  17. package/dist/handlers/account.d.ts +20 -0
  18. package/dist/handlers/account.d.ts.map +1 -1
  19. package/dist/handlers/account.js +18 -3
  20. package/dist/handlers/account.js.map +1 -1
  21. package/dist/handlers/dispatch.d.ts.map +1 -1
  22. package/dist/handlers/dispatch.js +5 -0
  23. package/dist/handlers/dispatch.js.map +1 -1
  24. package/dist/handlers/io.d.ts +14 -1
  25. package/dist/handlers/io.d.ts.map +1 -1
  26. package/dist/handlers/io.js +15 -2
  27. package/dist/handlers/io.js.map +1 -1
  28. package/dist/handlers/prompt-content.d.ts +22 -0
  29. package/dist/handlers/prompt-content.d.ts.map +1 -0
  30. package/dist/handlers/prompt-content.js +193 -0
  31. package/dist/handlers/prompt-content.js.map +1 -0
  32. package/dist/handlers/session.d.ts +3 -2
  33. package/dist/handlers/session.d.ts.map +1 -1
  34. package/dist/handlers/session.js +50 -17
  35. package/dist/handlers/session.js.map +1 -1
  36. package/dist/quota/ollama-cloud/client.d.ts +13 -4
  37. package/dist/quota/ollama-cloud/client.d.ts.map +1 -1
  38. package/dist/quota/ollama-cloud/client.js +14 -5
  39. package/dist/quota/ollama-cloud/client.js.map +1 -1
  40. package/dist/quota/ollama-cloud/format.d.ts +3 -2
  41. package/dist/quota/ollama-cloud/format.d.ts.map +1 -1
  42. package/dist/quota/ollama-cloud/format.js +22 -2
  43. package/dist/quota/ollama-cloud/format.js.map +1 -1
  44. package/dist/quota/ollama-cloud/index.d.ts +17 -1
  45. package/dist/quota/ollama-cloud/index.d.ts.map +1 -1
  46. package/dist/quota/ollama-cloud/index.js +92 -43
  47. package/dist/quota/ollama-cloud/index.js.map +1 -1
  48. package/dist/quota/ollama-cloud/types.d.ts +32 -8
  49. package/dist/quota/ollama-cloud/types.d.ts.map +1 -1
  50. package/dist/quota/ollama-cloud/types.js +13 -5
  51. package/dist/quota/ollama-cloud/types.js.map +1 -1
  52. package/dist/server.d.ts.map +1 -1
  53. package/dist/server.js +5 -3
  54. package/dist/server.js.map +1 -1
  55. package/docs/ARCHITECTURE.md +1 -1
  56. package/docs/CLI.md +15 -12
  57. package/docs/PROTOCOL.md +9 -0
  58. package/docs/REMOTE-CLIENTS.md +17 -9
  59. package/docs/REPLAY-GUIDE.md +16 -5
  60. package/package.json +1 -1
package/docs/CLI.md CHANGED
@@ -136,10 +136,10 @@ Without credentials, the default multi-provider mode silently shows GLM only
136
136
  ## Ollama Cloud setup
137
137
 
138
138
  Ollama Cloud exposes an (undocumented) usage endpoint at
139
- `ollama.com/api/usage` that the CLI queries with your API key. Create a key
140
- at [cloud.ollama.ai](https://cloud.ollama.ai) → API keys. The key comes from
141
- two sources, with the **config file taking precedence** over the environment
142
- variable:
139
+ `ollama.com/api/usage` that the CLI queries with your API key (the rolling
140
+ `30d` window). Create a key at [cloud.ollama.ai](https://cloud.ollama.ai) →
141
+ API keys. The key comes from two sources, with the **config file taking
142
+ precedence** over the environment variable:
143
143
 
144
144
  - **Config file** (`~/.config/zcode-acp/config.json`, `quota` section):
145
145
  ```json
@@ -150,14 +150,17 @@ variable:
150
150
  export OLLAMA_API_KEY="your_ollama_api_key"
151
151
  ```
152
152
 
153
- The card shows whatever usage windows the account's plan exposes — legacy
154
- plans get `5h` + `Week` bars, current credit plans get a `Month` bar. The
155
- server returns fractions only, so reset moments are derived client-side
156
- (epoch-aligned 5h buckets, Monday 00:00 UTC weeks, and for monthly the
157
- `/api/me` billing period end or — on new credit plans, which return only a
158
- `CreatedAt` — the next subscription-day anniversary). Without a key, the
159
- default mode silently skips the Ollama section; `zcode-acp quota oc` without
160
- a key prints a setup hint.
153
+ The API was rewritten upstream (2026-10): it now reports **spend analytics**
154
+ (`usage_usd`, request/token counts) and no longer exposes usage fractions or
155
+ plan limits. The card therefore derives the `Month` percent from the 30d
156
+ spend ÷ the plan's monthly credit (`/api/me` → `Plan`; credits from
157
+ ollama.com/pricing: Pro $60, Max $300, Team $1000 — unknown plans show the
158
+ spend line only, no bar) and shows a spend detail line
159
+ (`$1.57 of $60 · 246 req (30d)`) under the bars. The monthly reset is derived
160
+ from the `/api/me` billing period end or — on new credit plans, which return
161
+ only a `CreatedAt` — the next subscription-day anniversary. Without a key,
162
+ the default mode silently skips the Ollama section; `zcode-acp quota oc`
163
+ without a key prints a setup hint.
161
164
 
162
165
  ## Hub and server subcommands
163
166
 
package/docs/PROTOCOL.md CHANGED
@@ -164,6 +164,15 @@ through unchanged.
164
164
 
165
165
  Send a prompt.
166
166
 
167
+ ACP `resource` text is merged into `content`. Embedded PDF/image blobs and ACP
168
+ image blocks are forwarded in an optional native `attachments` array, with
169
+ `kind`, `filename`, `mimeType`, exact `sizeBytes`, and `dataBase64`. Supplied
170
+ bytes take precedence over URI metadata. Other binary resources use `kind:
171
+ "file"` and a private staged `localPath` instead of `dataBase64`; successful
172
+ staging survives bridge restarts so native tools can read it after resume.
173
+ See [README prompt attachments](../README.md#prompt-attachments) for limits and
174
+ retention. These resources are advertised by `promptCapabilities.embeddedContext`.
175
+
167
176
  **Request:**
168
177
 
169
178
  ```json
@@ -419,9 +419,15 @@ section — so clients can reproduce the CLI layout exactly:
419
419
  "ollama": {
420
420
  "kind": "success",
421
421
  "windows": [
422
- { "key": "session", "label": "5h", "usagePercent": 31 },
423
- { "key": "weekly", "label": "Week", "usagePercent": 67.5 }
424
- ]
422
+ { "key": "monthly", "label": "Month", "usagePercent": 2.6,
423
+ "resetsAt": 1729071480308 }
424
+ ],
425
+ "usage": {
426
+ "plan": "pro", "usageUsd": 1.5747, "creditUsd": 60,
427
+ "requestCount": 246, "inputTokens": 14294081,
428
+ "cachedInputTokens": 12922504, "outputTokens": 940919,
429
+ "window": "30d"
430
+ }
425
431
  }
426
432
  } }
427
433
  ```
@@ -438,12 +444,14 @@ section — so clients can reproduce the CLI layout exactly:
438
444
  means the user never set OpenCode Go credentials — omit the section, like
439
445
  the CLI does.
440
446
  - `ollama` (`kind`: `success` | `not_configured` | `auth_error` |
441
- `unavailable`): on success, `windows` carries whichever entries the
442
- account's plan exposes — legacy plans: `session` (`5h`) + `weekly`
443
- (`Week`); current credit plans: `monthly` (`Month`) — each with
444
- `usagePercent` (0–100) and, when available, `resetsAt` (epoch ms,
445
- derived client-side: epoch-aligned 5h buckets / Monday 00:00 UTC weeks /
446
- the `/api/me` billing period or subscription-day anniversary for monthly).
447
+ `unavailable`): since the 2026-10 upstream API rewrite the endpoint reports
448
+ spend only, so on success `windows` carries the derived `monthly` (`Month`)
449
+ entry — 30d `usageUsd` ÷ the plan's monthly credit, absent when the plan's
450
+ credit is unknown — with `resetsAt` (epoch ms, from the `/api/me` billing
451
+ period or subscription-day anniversary) when available. The additive
452
+ `usage` object carries the raw analytics (`plan`, `usageUsd`,
453
+ `creditUsd?`, `requestCount`/token totals, `window: "30d"`) for clients
454
+ that want to render spend directly; older clients ignore it.
447
455
  `not_configured` means no
448
456
  Ollama API key is set — omit the section, like the CLI does.
449
457
  - Provider failures are per-section `kind` strings, not JSON-RPC errors —
@@ -128,7 +128,7 @@ update's `_meta`:
128
128
  too. These updates never collide with live tool_call ids (they carry the
129
129
  `histfold_` prefix).
130
130
 
131
- ## Turn running state (`replayMeta.turnActive` + `$/zcode/turnState`)
131
+ ## Turn running state (`replayMeta.turnActive` + turnState notifications)
132
132
 
133
133
  A turn may already be in flight when you attach — started by the editor or
134
134
  another remote client (the bridge runs it to completion regardless of who
@@ -137,16 +137,26 @@ prompted). Two signals cover it:
137
137
  - **Attach snapshot**: `session/load`'s `replayMeta.turnActive` (boolean) —
138
138
  `true` when any turn for this session is running at attach time. Seed your
139
139
  spinner/running state from it.
140
- - **Out-of-band updates**: the notification `$/zcode/turnState` with params
140
+ - **Out-of-band updates**: the turn-state notification with params
141
141
  `{ sessionId: string, running: boolean }` — emitted when a turn starts and
142
142
  when it ends (including failures, e.g. a failed subscribe). On preemption (a
143
143
  new prompt interrupts an in-flight one) the old turn's exit reports
144
144
  `running: true`: the preempting turn took over, so the session is still busy.
145
145
 
146
+ The notification is **dual-emitted under two names** (#311): the deprecated
147
+ `$/zcode/turnState` (LSP-style prefix) and the spec-compliant
148
+ `_zcode/turnState` (ACP reserves `_`-prefixed names for extension
149
+ notifications). Subscribe to exactly ONE of them — a client handling both
150
+ sees every transition twice. New clients should use `_zcode/turnState`; the
151
+ `$/` spelling remains for existing consumers (martty, zcode-acp-remote) and
152
+ will be removed once they migrate. Both names are advertised in
153
+ `initialize`'s `agentCapabilities._meta.zcode.turnState`.
154
+
146
155
  The client that sent `session/prompt` already knows its own turn via the
147
156
  request/response; these signals exist for the OTHER attached clients
148
157
  (re-attached mobile, second editor). Unknown notifications are ignorable —
149
- clients that don't handle `$/zcode/turnState` lose nothing (Zed ignores it).
158
+ clients that don't handle the turn-state notifications lose nothing (Zed
159
+ ignores them).
150
160
 
151
161
  ## Scroll-up pagination
152
162
 
@@ -202,8 +212,9 @@ Never parse the cursor — it is opaque. (For the curious it round-trips
202
212
  - [ ] `session/load` params include `cwd` and `mcpServers` (even `[]`).
203
213
  - [ ] Message list keyed/deduped by `messageId`; tool cards by `toolCallId`.
204
214
  - [ ] Pagination pages prepended, live updates appended.
205
- - [ ] Running state seeded from `replayMeta.turnActive` and updated from
206
- `$/zcode/turnState` notifications (covers other clients' turns).
215
+ - [ ] Running state seeded from `replayMeta.turnActive` and updated from the
216
+ turn-state notifications — `_zcode/turnState` (or the deprecated `$/`
217
+ spelling; pick ONE) — covering other clients' turns.
207
218
  - [ ] `"cursor expired"` handled by full re-attach.
208
219
  - [ ] Cursor stored per session, never parsed, never persisted across app
209
220
  runs (it is only meaningful to the bridge that minted it).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zcode-acp-server",
3
- "version": "0.65.1",
3
+ "version": "0.67.0",
4
4
  "description": "Agent Client Protocol (ACP) server bridging headless ZCode to editors like Zed and JetBrains.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",