pi-zro-provider 1.0.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.
@@ -0,0 +1,4 @@
1
+ github: monotykamary
2
+ ko_fi: monotykamary
3
+ buy_me_a_coffee: monotykamary
4
+ polar: monotykamary
package/AGENTS.md ADDED
@@ -0,0 +1,58 @@
1
+ # AGENTS.md
2
+
3
+ ## DO NOT EDIT — Auto-generated Files
4
+
5
+ The following files are **idempotent** and regenerated by `scripts/update-models.js`. Never edit them directly — your changes will be overwritten on the next model sync.
6
+
7
+ | File | Why it's auto-generated |
8
+ |------|------------------------|
9
+ | `models.json` | Built from the Zro model catalog. `update-models.js` fetches `/api/cli/models`, preserves curated data for known IDs, and writes this file. |
10
+ | `deprecated-models.json` | Graveyard for models the API delisted. update-models.js stamps them with deprecatedAt and pi keeps serving them for a 2-week grace period, then evicts them. Never edit by hand. |
11
+ | `README.md` (model table) | The table under `## Available Models` is replaced in-place by `update-models.js` after merging base models → patch → custom models. |
12
+
13
+ ## Correct Files to Edit
14
+
15
+ When a model needs overrides, new properties, or corrections, edit the appropriate source file below. These are the **source of truth** that the update script reads but never writes.
16
+
17
+ | File | Purpose |
18
+ |------|---------|
19
+ | `patch.json` | Per-model overrides keyed by model ID. Add reasoning flags, compat settings, pricing corrections, thinking level maps, etc. Applied on top of `models.json` at runtime and for README generation. |
20
+ | `custom-models.json` | Models that don't exist in the provider API (hidden models, router endpoints, cross-provider aliases). Merged after patch. Format: array of full model objects (same schema as `models.json` entries). |
21
+ | `index.ts` | Provider extension code: model sync, streaming wrapper, footer-status wiring. |
22
+ | `status.ts` | Footer-status presentation: config schema, USD/token formatters, progressive-disclosure tiers, width-aware widget. Pure module — no pi imports; exercised by `tests/status.smoke.ts`. |
23
+ | `scripts/update-models.js` | The sync script itself (edit only if changing how models are fetched/transformed). |
24
+
25
+ ## Data Flow
26
+
27
+ ```
28
+ Zro catalog ──fetch──► models.json ──apply──► patch.json ──merge──► custom-models.json
29
+ │ │ │
30
+ └────────────────────────────┴──────────────────────┘
31
+
32
+ README model table
33
+ ```
34
+
35
+ 1. `models.json` — base data from the provider API (auto-generated, DO NOT EDIT)
36
+ 2. `patch.json` — overrides applied on top (EDIT THIS for corrections/enrichments)
37
+ 3. `custom-models.json` — additional models not in the API (EDIT THIS for new models)
38
+ 4. README table — rendered from the merged result of all three (auto-generated, DO NOT EDIT)
39
+
40
+ ## Common Tasks
41
+
42
+ ### Add a compat setting or override pricing for an existing model
43
+ → Edit `patch.json`. Add an entry keyed by the model's `id`.
44
+
45
+ ### Add a model not available in the provider API
46
+ → Edit `custom-models.json`. Add a full model object to the array.
47
+
48
+ ### Update models from the provider API
49
+ → Run `node scripts/update-models.js` (requires `ZRO_API_KEY` or a stored `zro login`).
50
+
51
+ ### Regenerate the README model table
52
+ → Run `node scripts/update-models.js` — it updates both `models.json` and the README table.
53
+
54
+ ## TL;DR
55
+
56
+ - **Never edit `models.json`** — edit `patch.json` instead.
57
+ - **Never edit the README model table** — run the update script instead.
58
+ - `patch.json` and `custom-models.json` are the source files you should modify.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,232 @@
1
+ <div align="center">
2
+
3
+ # ✨ pi-zro-provider
4
+
5
+ **3+ models through [Zro](https://zro.moonmath.ai)**
6
+
7
+ _GLM-5.2, Kimi K3, and DeepSeek V4 Flash — run through the Zro inference endpoint with [pi](https://github.com/earendil-works/pi-coding-agent)._
8
+
9
+ [![pi extension](https://img.shields.io/badge/pi-extension-blueviolet)](https://github.com/earendil-works/pi-coding-agent)
10
+ [![license](https://img.shields.io/badge/license-MIT-blue)](./LICENSE)
11
+
12
+ </div>
13
+
14
+ ---
15
+
16
+ ## Features
17
+
18
+ - **3+ AI Models** — GLM-5.2 (default), Kimi K3, and DeepSeek V4 Flash, straight from Zro's production catalog
19
+ - **Native reasoning effort** — every model ships its published `piLevel` → level-id map (`glm-5.2`: `off`/`high`/`max`, `kimi-k3`: `low`/`high`/`max`, `deepseek-v4-flash-0731`: `off`/`high`), so `/thinking high` etc. maps exactly to what the Zro proxy expects
20
+ - **OpenAI-compatible API** at `https://zro.moonmath.ai/v1`
21
+ - **Official catalog sync** from Zro's `/api/cli/models` endpoint — same one `zro models` uses
22
+ - **Zro login reuse** — if you've run `zro login`, the extension picks up `~/.config/zro/credentials.json` automatically (no duplicated keys)
23
+ - **Footer status widget** — session spend/tokens and account plan / available spend / usage packs / 30-day activity at a glance
24
+
25
+ ## Available Models
26
+
27
+ | Model | Type | Context | Max Tokens | Input Cost | Output Cost |
28
+ |-------|------|---------|------------|------------|-------------|
29
+ | DeepSeek V4 Flash | Text | 1.0M | 384K | — | — |
30
+ | GLM-5.2 | Text | 524K | 64K | — | — |
31
+ | Kimi K3 | Text | 1.0M | 1.0M | — | — |
32
+ *Costs are per million tokens. Billing is metered by your Zro plan and usage packs — see [zro.moonmath.ai](https://zro.moonmath.ai) for pricing.*
33
+
34
+ ## Installation
35
+
36
+ ### Option 1: Using `pi install` (Recommended)
37
+
38
+ Install from npm:
39
+
40
+ ```bash
41
+ pi install npm:pi-zro-provider
42
+ ```
43
+
44
+ Or directly from GitHub:
45
+
46
+ ```bash
47
+ pi install https://github.com/monotykamary/pi-zro-provider
48
+ ```
49
+
50
+ Then make sure you're logged in (or set a key) and run pi:
51
+ ```bash
52
+ # Recommended: reuse your zro CLI login
53
+ zro login
54
+
55
+ # Or set as environment variable
56
+ export ZRO_API_KEY=your-api-key-here
57
+
58
+ pi
59
+ ```
60
+
61
+ Get your API key from [zro.moonmath.ai](https://zro.moonmath.ai).
62
+
63
+ ### Option 2: Manual Clone
64
+
65
+ 1. Clone this repository:
66
+ ```bash
67
+ git clone https://github.com/monotykamary/pi-zro-provider.git
68
+ cd pi-zro-provider
69
+ ```
70
+
71
+ 2. Make sure you have a Zro credential (any of the [Authentication](#authentication) options).
72
+
73
+ 3. Run pi with the extension:
74
+ ```bash
75
+ pi -e /path/to/pi-zro-provider
76
+ ```
77
+
78
+ ## Usage
79
+
80
+ After loading the extension, select a model with:
81
+
82
+ ```
83
+ /model zro glm-5.2
84
+ ```
85
+
86
+ Or start pi directly with a Zro model:
87
+
88
+ ```bash
89
+ pi --provider zro --model glm-5.2
90
+ ```
91
+
92
+ ### Reasoning Effort
93
+
94
+ All Zro models are reasoning models. Control thinking depth with `/thinking` or the CLI:
95
+
96
+ ```bash
97
+ pi --provider zro --model glm-5.2 --thinking xhigh
98
+ ```
99
+
100
+ The available levels are model-specific and come straight from Zro's catalog:
101
+
102
+ | Model | pi levels | Sent as `reasoning_effort` |
103
+ |-------|-----------|----------------------------|
104
+ | `glm-5.2` | `off`, `high`, `xhigh` | `none`, `high`, `max` |
105
+ | `kimi-k3` | `low`, `high`, `xhigh` | `low`, `high`, `max` |
106
+ | `deepseek-v4-flash-0731` | `off`, `high` | `none`, `high` |
107
+
108
+ Levels map one-to-one through `thinkingLevelMap`, so `off` sends Zro's `none` token instead of silently dropping the field.
109
+
110
+ ### Footer Status
111
+
112
+ A Neuralwatt-style status line sits below the editor. It appears after the
113
+ session's first Zro turn completes (never before — no half-empty line on
114
+ fresh sessions or other providers), refreshes its balance when the agent run
115
+ fully settles, and makes no status-related API calls in sessions that never
116
+ use Zro:
117
+
118
+ ```
119
+ ⚡ $0.42 · 7 req Pro ◆ $12.34 avail · $2.50 pack · 1.2k req/30d
120
+ └─ session spend+requests ─┘ └─ plan · available spend · packs · activity ──┘
121
+ ```
122
+
123
+ The left side tracks what the current session has sent/spent — tokens always,
124
+ plus a cost extension when the response exposes one (no polling). The right
125
+ side shows your plan name, total available spend, usage-pack balance, and
126
+ 30-day request/token activity from Zro's `/api/cli/status` endpoint — the
127
+ same account view `zro status` prints — plus a request-rate atom from
128
+ response headers when present. The right side compresses progressively as
129
+ the terminal narrows, and turns to a warning color at/below the
130
+ `lowBalanceUsd` threshold.
131
+
132
+ ### Configuration
133
+
134
+ Edit `~/.pi/agent/extensions/zro.json` or run `/zro-status`:
135
+
136
+ | Setting | Values | Default |
137
+ |---------|--------|---------|
138
+ | `session` | `widget` \| `statusbar` \| `off` | `widget` |
139
+ | `account` | `widget` \| `statusbar` \| `off` | `widget` |
140
+ | `hideOnOtherProvider` | `true` \| `false` | `true` |
141
+ | `lowBalanceUsd` | number \| `null` | `10` |
142
+
143
+ Non-interactive toggles:
144
+
145
+ ```
146
+ /zro-status session widget|statusbar|off
147
+ /zro-status account widget|statusbar|off
148
+ /zro-status hide true|false
149
+ /zro-status lowBalance 25|off
150
+ /zro-status refresh
151
+ /zro-status reset
152
+ ```
153
+
154
+
155
+ ## Authentication
156
+
157
+ The Zro API key can be configured in multiple ways (resolved in this order):
158
+
159
+ 1. **`auth.json`** (recommended) — Add to `~/.pi/agent/auth.json`:
160
+ ```json
161
+ { "zro": { "type": "api_key", "key": "your-api-key" } }
162
+ ```
163
+ The `key` field supports literal values, env var names, and shell commands (prefix with `!`). See [pi's auth file docs](https://github.com/badlogic/pi-mono) for details.
164
+ 2. **Environment variable** — Set `ZRO_API_KEY`
165
+ 3. **`zro login` reuse** — If you've already run `zro login`, the extension reads `~/.config/zro/credentials.json` (`XDG_CONFIG_HOME` aware) automatically. No extra configuration needed.
166
+ 4. **Runtime override** — Use the `--api-key` CLI flag
167
+
168
+ Get your API key from [zro.moonmath.ai](https://zro.moonmath.ai).
169
+
170
+ ## Environment Variables
171
+
172
+ | Variable | Required | Description |
173
+ |----------|----------|-------------|
174
+ | `ZRO_API_KEY` | No | Your Zro API key (env var fallback) |
175
+ | `ZRO_ENDPOINT_ROOT` | No | Override the endpoint root (default `https://zro.moonmath.ai`) |
176
+ | `ZRO_AUTH_URL` | No | Override the authentication/API host (used by `zro login`; the extension resolves catalog/status from it too) |
177
+
178
+ ## Configuration
179
+
180
+ Add to your pi configuration for automatic loading:
181
+
182
+ ```json
183
+ {
184
+ "extensions": [
185
+ "/path/to/pi-zro-provider"
186
+ ]
187
+ }
188
+ ```
189
+
190
+ ### Catalog and Compat Settings
191
+
192
+ Model metadata matches the transform Zro's own pi adapter applies to its
193
+ `/api/cli/models` catalog:
194
+
195
+ - canonical ids, display names, context windows, and output caps
196
+ - `thinkingLevelMap` built from each model's published reasoning levels
197
+ (`piLevel` → provider level id)
198
+ - `compat.supportsReasoningEffort: true` and `maxTokensField: "max_tokens"`
199
+ (plain `openai-completions`, no custom `thinkingFormat`)
200
+ - `supportsDeveloperRole: false`
201
+ - all text-only inputs
202
+
203
+ `patch.json` is reserved only for a verified provider regression and is
204
+ currently empty.
205
+
206
+ ### Patch Overrides
207
+
208
+ `patch.json` is applied on top of `models.json` only for verified endpoint
209
+ corrections. It is currently empty because every live field comes from Zro's
210
+ canonical model catalog.
211
+
212
+ ## Updating Models
213
+
214
+ Run the update script to fetch the latest models from the Zro catalog:
215
+
216
+ ```bash
217
+ node scripts/update-models.js # uses zro login credentials
218
+ # or
219
+ ZRO_API_KEY=your-api-key node scripts/update-models.js
220
+ ```
221
+
222
+ This will:
223
+ 1. Fetch models from `https://zro.moonmath.ai/api/cli/models`
224
+ 2. Regenerate `models.json` as pure metadata from the live catalog
225
+ 3. Apply overrides from `patch.json` only when building the README
226
+ 4. Remove custom models now available upstream from `custom-models.json`
227
+ 5. Reconcile delisted models through the 14-day `deprecated-models.json` grace layer
228
+ 6. Update `models.json` and the README model table
229
+
230
+ ## License
231
+
232
+ MIT
@@ -0,0 +1 @@
1
+ []
@@ -0,0 +1 @@
1
+ {}