pi-cliproxyapi 0.4.2 → 0.4.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/README.md
CHANGED
|
@@ -14,19 +14,69 @@
|
|
|
14
14
|
|
|
15
15
|
Pi extension for corporate management of model providers via a single [CliProxyAPI](https://github.com/router-for-me/CLIProxyAPI) endpoint.
|
|
16
16
|
|
|
17
|
-
One `(endpoint, apiKey)` pair — every provider and model inherits it
|
|
17
|
+
One `(endpoint, apiKey)` pair — every provider and model inherits it
|
|
18
|
+
automatically, including live quota.
|
|
18
19
|
|
|
19
|
-
|
|
20
|
+
## Quota in the status line
|
|
21
|
+
|
|
22
|
+
The footer shows how much of each provider window is left for the model you are
|
|
23
|
+
currently using, so a limit is visible before it bites rather than after:
|
|
24
|
+
|
|
25
|
+
```text
|
|
26
|
+
claude-sonnet-5 5h ⣶ 69 7d ⣷ 81
|
|
27
|
+
claude-fable-5 5h ⣶ 69 7d ⣷ 81 Fable ⣾ 91
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Windows are read live, not guessed. Anthropic caps some models against a slice
|
|
31
|
+
of the weekly pool — Fable may draw down half of it, and draws faster than other
|
|
32
|
+
models — so that per-model window is shown **alongside** the weekly figure
|
|
33
|
+
rather than folded into it. Switching models switches the window on display.
|
|
34
|
+
Other models' windows never drag down the general figure.
|
|
35
|
+
|
|
36
|
+
Green ≥ 70%, yellow 30–69%, red < 30%. The **Usage** tab breaks the same data
|
|
37
|
+
down per account, with reset times.
|
|
38
|
+
|
|
39
|
+
## How the numbers get here
|
|
40
|
+
|
|
41
|
+
Quota and the model catalogue come from the
|
|
42
|
+
**[pi-bridge](https://github.com/abix5/pi-cliproxyapi-bridge)** plugin running
|
|
43
|
+
inside CliProxyAPI, authenticated with the same `apiKey` used for model calls
|
|
44
|
+
— no second credential, no extra container:
|
|
45
|
+
|
|
46
|
+
```text
|
|
47
|
+
Pi + extension ──▶ CliProxyAPI
|
|
48
|
+
/v1/models, /v1/chat/… model calls
|
|
49
|
+
/v0/resource/plugins/pi-bridge/
|
|
50
|
+
well-known → model catalogue
|
|
51
|
+
usage → per-account quota
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The plugin caches quota server-side, so every Pi instance shares one upstream
|
|
55
|
+
poll and provider rate limits stay comfortable. It also knows where each
|
|
56
|
+
provider keeps its numbers — a description that lives in configuration, so a
|
|
57
|
+
provider reshuffling its API is answered by an edit rather than a release.
|
|
58
|
+
|
|
59
|
+
Without the plugin the extension still works: it falls back to raw `/v1/models`
|
|
60
|
+
with local heuristics, and the quota display is simply absent.
|
|
61
|
+
|
|
62
|
+
| | With pi-bridge | Without |
|
|
63
|
+
| --- | --- | --- |
|
|
64
|
+
| Quota in status line + Usage tab | Live per-account windows | Unavailable |
|
|
65
|
+
| Model discovery | Enriched from [models.dev](https://models.dev) — real context windows, costs, reasoning flags | Defaults: `contextWindow=128k`, `maxTokens=16k`, `cost=0` |
|
|
66
|
+
| Classification | Server-side | Local heuristics by `owned_by` |
|
|
67
|
+
|
|
68
|
+
See the [plugin's README](https://github.com/abix5/pi-cliproxyapi-bridge) for
|
|
69
|
+
installing it into CliProxyAPI.
|
|
20
70
|
|
|
21
71
|
## Features
|
|
22
72
|
|
|
73
|
+
- **Live quota** — status-line windows for the model in use, per-account bars in the **Usage** tab, no LLM call
|
|
23
74
|
- **Unified hub** — one `/cliproxy` overlay with **Models / Usage / Diagnostics** tabs (number hotkeys `1` `2` `3`) plus global actions: `r` refresh, `e` setup, `s` save
|
|
24
75
|
- **Built-in provider routing** — whitelist which Anthropic / OpenAI / etc. models are available through the proxy
|
|
25
76
|
- **Custom provider groups** — create named groups (e.g. `corp-glm`, `corp-gemini`) for proxy-only models with automatic metadata from [models.dev](https://models.dev)
|
|
26
77
|
- **Exclusive model pool** — a model assigned to one group automatically disappears from others, grouped by `owned_by` with type-to-filter (`/`)
|
|
27
78
|
- **Live save state** — the header shows `● unsaved` while you edit and `✓ settings saved` after `s`, no console noise
|
|
28
|
-
- **
|
|
29
|
-
- **Setup wizard** — `/cliproxy-setup` configures endpoint, API key, provider prefix, and usage key interactively
|
|
79
|
+
- **Setup wizard** — `/cliproxy-setup` configures endpoint, API key, and provider prefix interactively
|
|
30
80
|
|
|
31
81
|
## Commands
|
|
32
82
|
|
|
@@ -35,7 +85,7 @@ Two commands; everything else lives inside the hub as tabs and actions.
|
|
|
35
85
|
| Command | Description |
|
|
36
86
|
| --- | --- |
|
|
37
87
|
| `/cliproxy` | Hub overlay — **Models** / **Usage** / **Diagnostics** tabs plus global actions |
|
|
38
|
-
| `/cliproxy-setup` | Configure endpoint, API key, provider prefix
|
|
88
|
+
| `/cliproxy-setup` | Configure endpoint, API key, provider prefix |
|
|
39
89
|
|
|
40
90
|
### The `/cliproxy` hub
|
|
41
91
|
|
|
@@ -53,25 +103,11 @@ Extra Models keys: `d` removes a custom group (with confirmation).
|
|
|
53
103
|
|
|
54
104
|
**Diagnostics tab** — connectivity, key resolution, and discovery shape.
|
|
55
105
|
|
|
56
|
-
## Screenshots
|
|
57
|
-
|
|
58
|
-
**Models — custom group, pool grouped by owner (`/` filters the pool)**
|
|
59
|
-
|
|
60
|
-

|
|
61
|
-
|
|
62
|
-
**Usage — per-account quota windows**
|
|
63
|
-
|
|
64
|
-

|
|
65
|
-
|
|
66
|
-
**Diagnostics — connectivity, keys, discovery shape**
|
|
67
|
-
|
|
68
|
-

|
|
69
|
-
|
|
70
106
|
## Prerequisites
|
|
71
107
|
|
|
72
108
|
You need a running [CliProxyAPI](https://github.com/router-for-me/CLIProxyAPI) instance — this is the corporate LLM proxy that aggregates multiple providers behind a single OpenAI-compatible endpoint.
|
|
73
109
|
|
|
74
|
-
For full functionality
|
|
110
|
+
For full functionality — quota windows and enriched model metadata — also install the **[pi-bridge](https://github.com/abix5/pi-cliproxyapi-bridge)** plugin into that instance. See [How the numbers get here](#how-the-numbers-get-here) above.
|
|
75
111
|
|
|
76
112
|
## Install
|
|
77
113
|
|
|
@@ -134,34 +170,6 @@ cache.
|
|
|
134
170
|
|
|
135
171
|
Values support `!command` (shell exec), `$ENV_VAR`, or literal strings. The `/cliproxy-setup` wizard also accepts bare `~/path` values and saves them as `!cat` commands; when editing the file by hand, write the `!cat ~/path` form explicitly.
|
|
136
172
|
|
|
137
|
-
## Discovery
|
|
138
|
-
|
|
139
|
-
The extension reads the model catalogue and provider quota from the
|
|
140
|
-
**[pi-bridge](https://github.com/abix5/pi-cliproxyapi-bridge)** plugin running
|
|
141
|
-
inside CliProxyAPI, authenticating with the same `apiKey` it uses for model
|
|
142
|
-
calls. No second credential and no extra container are involved.
|
|
143
|
-
|
|
144
|
-
```
|
|
145
|
-
┌──────────────┐ ┌────────────────────────────────────────┐
|
|
146
|
-
│ Pi + plugin │────▶│ CliProxyAPI │
|
|
147
|
-
│ │ │ /v1/models, /v1/chat/... │
|
|
148
|
-
│ │ │ /v0/resource/plugins/pi-bridge/… │
|
|
149
|
-
│ │ │ well-known → model catalogue │
|
|
150
|
-
│ │ │ usage → per-account quota │
|
|
151
|
-
└──────────────┘ └────────────────────────────────────────┘
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
Without the plugin the extension still works: it falls back to raw `/v1/models`
|
|
155
|
-
with local heuristics.
|
|
156
|
-
|
|
157
|
-
| | With pi-bridge | Without |
|
|
158
|
-
| --- | --- | --- |
|
|
159
|
-
| Model discovery | Enriched from [models.dev](https://models.dev) — real context windows, costs, reasoning flags | Defaults: `contextWindow=128k`, `maxTokens=16k`, `cost=0` |
|
|
160
|
-
| Usage tab | Per-account quota bars | Unavailable |
|
|
161
|
-
| Classification | Server-side | Local heuristics by `owned_by` |
|
|
162
|
-
|
|
163
|
-
See the plugin's README for installing it into CliProxyAPI.
|
|
164
|
-
|
|
165
173
|
## Setup
|
|
166
174
|
|
|
167
175
|
Run `/cliproxy-setup` in Pi and enter:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-cliproxyapi",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Pi extension for corporate management of model providers via a single CliProxyAPI endpoint",
|
|
6
6
|
"license": "MIT",
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
"files": [
|
|
12
12
|
"index.ts",
|
|
13
13
|
"src",
|
|
14
|
-
"docs",
|
|
15
14
|
"README.md"
|
|
16
15
|
],
|
|
17
16
|
"pi": {
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
# ISSUE: taskflow child agents have zero usable models (pi-cliproxyapi not loaded in `piChild`)
|
|
2
|
-
|
|
3
|
-
- **Status:** open (workaround applied at user-settings level; proper fix needed in this package)
|
|
4
|
-
- **Package:** `pi-cliproxyapi` (this repo, v0.3.5)
|
|
5
|
-
- **Interacts with:** `pi-taskflow` (`taskflow.piChild` spawn config), `@earendil-works/pi-coding-agent` runtime
|
|
6
|
-
- **Severity:** high — blocks ALL taskflow subagents/subflows from running on any model
|
|
7
|
-
- **Found:** 2026-07 while trying to run `designer` / `architect` subagents on `openai/gpt-5.6-sol`
|
|
8
|
-
|
|
9
|
-
## Symptom
|
|
10
|
-
|
|
11
|
-
Every `taskflow action=run` (single agent or flow) fails immediately. The parent
|
|
12
|
-
session works fine; only the spawned child process is broken. Representative output:
|
|
13
|
-
|
|
14
|
-
```
|
|
15
|
-
Taskflow 'task' failed (0/1 done, 1 failed).
|
|
16
|
-
Warning: No models match pattern "anthropic/claude-opus-4-8"
|
|
17
|
-
Warning: No models match pattern "proxy/glm-5.2"
|
|
18
|
-
Warning: No models match pattern "openai/gpt-5.6-sol"
|
|
19
|
-
... (every entry of settings.enabledModels)
|
|
20
|
-
No API key found for openai. Use /login to log into a provider via OAuth or API key.
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
i.e. in the child, **no model pattern resolves at all**, and the fallback to a
|
|
24
|
-
direct provider (`openai`) fails because there is no API key (`~/.pi/agent/auth.json`
|
|
25
|
-
is empty — auth is normally provided by this proxy extension, not by stored keys).
|
|
26
|
-
|
|
27
|
-
## Root cause
|
|
28
|
-
|
|
29
|
-
The parent pi session gets its whole model catalog + auth from **this extension**
|
|
30
|
-
(`pi-cliproxyapi`): it registers the proxied model list and routes calls through the
|
|
31
|
-
local CLIProxyAPI. `settings.packages` loads it for the parent.
|
|
32
|
-
|
|
33
|
-
But `pi-taskflow` spawns children with an **allowlisted** extension set:
|
|
34
|
-
|
|
35
|
-
```jsonc
|
|
36
|
-
// settings.json
|
|
37
|
-
"taskflow": {
|
|
38
|
-
"piChild": {
|
|
39
|
-
"resourceProfile": "allowlist",
|
|
40
|
-
"extensions": [
|
|
41
|
-
".../taskflow-extensions/child-path-guard.ts",
|
|
42
|
-
".../node_modules/pi-mcp-adapter/index.ts"
|
|
43
|
-
]
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
`pi-cliproxyapi` is **absent** from `piChild.extensions`, so the child never
|
|
49
|
-
registers the proxied model catalog and starts with an empty model registry →
|
|
50
|
-
every configured model (proxy/* and openai/*) is "not found", and the direct-provider
|
|
51
|
-
fallback has no key. Net effect: subagents cannot run on any model.
|
|
52
|
-
|
|
53
|
-
## Workaround (applied at user settings level, reversible)
|
|
54
|
-
|
|
55
|
-
Prepend this extension to the taskflow child allowlist so the child also loads the
|
|
56
|
-
proxy and registers models. The child reads `settings.json` fresh on spawn, so no
|
|
57
|
-
parent restart is needed.
|
|
58
|
-
|
|
59
|
-
```jsonc
|
|
60
|
-
"taskflow": {
|
|
61
|
-
"piChild": {
|
|
62
|
-
"extensions": [
|
|
63
|
-
".../node_modules/pi-cliproxyapi/index.ts", // <-- added (first, so models
|
|
64
|
-
".../taskflow-extensions/child-path-guard.ts", // register before agents resolve)
|
|
65
|
-
".../node_modules/pi-mcp-adapter/index.ts"
|
|
66
|
-
]
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
After this, child agents resolve e.g. `openai/gpt-5.6-sol` and run. Backup kept at
|
|
72
|
-
`~/.pi/agent/settings.json.bak-notif`.
|
|
73
|
-
|
|
74
|
-
### Secondary note (expected, not this bug)
|
|
75
|
-
|
|
76
|
-
`child-path-guard.ts` restricts child **writes** to the working directory. Run
|
|
77
|
-
taskflow with `cwd` set to the repo root and use **relative** output paths; absolute
|
|
78
|
-
paths like `/tmp/...` are rejected ("Taskflow запрещает дочернему агенту запись вне
|
|
79
|
-
рабочего каталога").
|
|
80
|
-
|
|
81
|
-
## Proper fix (options for this package)
|
|
82
|
-
|
|
83
|
-
The extension should be usable inside a taskflow child out of the box, cheaply.
|
|
84
|
-
|
|
85
|
-
1. **Docs-only (minimum):** document in README that `taskflow.piChild.extensions`
|
|
86
|
-
must include `pi-cliproxyapi` for subagents to have models. Low effort, leaves
|
|
87
|
-
every user to discover this the hard way.
|
|
88
|
-
2. **Slim child entrypoint (recommended):** export a lightweight "child mode" that
|
|
89
|
-
only registers the model catalog + provider routing from the on-disk discovery
|
|
90
|
-
cache (`~/.pi/agent/discovery-cache.json`) and skips parent-only concerns
|
|
91
|
-
(interactive `/commands`, status/quota segments, live `fetchDiscovery`/`fetchUsage`).
|
|
92
|
-
Cheap enough to load on every child spawn; avoids network under the child's
|
|
93
|
-
`allowlist` resourceProfile (which may block discovery fetches → must rely on cache).
|
|
94
|
-
3. **Auto-detect child context:** when the extension detects it is running in a
|
|
95
|
-
taskflow child (env/flag from pi-taskflow), self-limit to the slim registration
|
|
96
|
-
path from (2) automatically, so no `piChild.extensions` edit is required.
|
|
97
|
-
|
|
98
|
-
Preference: (3) if pi-taskflow exposes a detectable child signal, else (2) plus a
|
|
99
|
-
short README note. Coordinate the child-detection signal with `pi-taskflow`.
|
|
100
|
-
|
|
101
|
-
## Acceptance criteria
|
|
102
|
-
|
|
103
|
-
- [ ] `taskflow action=run` with an agent pinned to a proxied model succeeds on a
|
|
104
|
-
clean setup (no manual `piChild.extensions` edit), OR README documents the
|
|
105
|
-
required allowlist entry.
|
|
106
|
-
- [ ] Child model registration does not perform blocking network fetches under
|
|
107
|
-
`resourceProfile: allowlist` (uses discovery cache).
|
|
108
|
-
- [ ] Child startup overhead from this extension is negligible per spawn.
|
|
109
|
-
- [ ] Revert the user-level workaround once shipped.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|