pi-cliproxyapi-native 0.2.0 → 0.2.2
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 +8 -6
- package/package.json +4 -4
- package/src/claude-quota.ts +4 -4
- package/src/compaction.ts +1 -1
package/README.md
CHANGED
|
@@ -27,15 +27,15 @@ Chat uses Pi's native API adapters and model metadata, with availability from yo
|
|
|
27
27
|
|
|
28
28
|
## Install
|
|
29
29
|
|
|
30
|
-
The extension targets Pi 1.
|
|
30
|
+
The extension targets Pi 1.4.0 and CLIProxyAPI 8.0.38, with Node.js 22.19 or newer. Run CLIProxyAPI with your upstream accounts configured before connecting Pi. The extension uses Pi's host-provided packages, adds no runtime dependencies, and needs no compilation.
|
|
31
31
|
|
|
32
32
|
If you installed `pi-cliproxy-native`, remove it before installing the renamed package. Both register the same `cliproxyapi` provider.
|
|
33
33
|
|
|
34
34
|
```sh
|
|
35
|
-
pi install npm:pi-cliproxyapi-native@0.2.
|
|
35
|
+
pi install npm:pi-cliproxyapi-native@0.2.2
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
For Git installation, use `pi install git:github.com/hawkff/pi-cliproxyapi-native@v0.2.
|
|
38
|
+
For Git installation, use `pi install git:github.com/hawkff/pi-cliproxyapi-native@v0.2.2`. For a local checkout, use `pi install /path/to/pi-cliproxyapi-native`.
|
|
39
39
|
|
|
40
40
|
The default proxy address is `http://localhost:8317`. For another address, set the [connection](#connection) before logging in. Restart Pi, then run:
|
|
41
41
|
|
|
@@ -218,7 +218,7 @@ Without a management key, Claude retains its SDK retry settings and response-bas
|
|
|
218
218
|
|
|
219
219
|
Invalid management credentials, rejected account access, invalid usage data, or an exhausted allowance with an expired reset stop the quota wait with an explanation. These failures do not trigger Pi's quick retries. Extension-managed waits share one fixed seven-day deadline per provider call; a new cooldown cannot extend it. The extension checks the deadline after waking and before accepting available quota, including after machine sleep. It does not replay a request that has started streaming.
|
|
220
220
|
|
|
221
|
-
Management requests stay on the configured proxy and reject redirects. Account access tokens stay in CLIProxyAPI. The extension reads account metadata and proxies usage GETs; it does not reset quotas, change credentials, or clear proxy cooldowns. Management keys grant broader access than chat keys, so keep them private. Live lookup supports up to 100 active Claude subscription accounts.
|
|
221
|
+
Live quota lookup requires CLIProxyAPI's `/v8/management` API and does not fall back to legacy `/v0/management` routes. Management requests stay on the configured proxy and reject redirects. Account access tokens stay in CLIProxyAPI. The extension reads account metadata and proxies usage GETs; it does not reset quotas, change credentials, or clear proxy cooldowns. Management keys grant broader access than chat keys, so keep them private. Live lookup supports up to 100 active Claude subscription accounts.
|
|
222
222
|
|
|
223
223
|
Explicit `api/` routes skip live Claude subscription lookup, even with a management key. `oauth/` routes keep the lookup for matching OAuth accounts. Retries keep the selected route's full model ID.
|
|
224
224
|
|
|
@@ -226,9 +226,11 @@ Other chat routes retain the response-based fallback: `Retry-After` on HTTP 429
|
|
|
226
226
|
|
|
227
227
|
### Compaction
|
|
228
228
|
|
|
229
|
-
For automatic compaction and `/compact`, the extension limits medium or higher thinking to low without changing your chat thinking level. It uses Pi's default thinking budgets for these requests.
|
|
229
|
+
For automatic compaction and `/compact`, the extension limits medium or higher thinking to low without changing your chat thinking level. It uses Pi's default thinking budgets for these requests. Without an explicit output cap, summaries use the model's output limit. Pi's native adapters reduce the output allowance when needed to fit the remaining context space.
|
|
230
230
|
|
|
231
|
-
|
|
231
|
+
If a caller supplies a smaller cap and the summary hits it, the extension retries once with more output room, up to the model's output limit. An empty or thinking-only response gets one retry, including at the model's output limit.
|
|
232
|
+
|
|
233
|
+
Pi still selects which messages to summarize and retains recent history, previous summaries, custom instructions, and file tracking. Only the final response reaches the compactor, with usage from all attempts. Compaction fails rather than saving an incomplete summary. Cancellation, tool calls, and provider failures do not trigger these output retries; Pi keeps its configured transient-error retries and the extension keeps its quota handling.
|
|
232
234
|
|
|
233
235
|
Authentication failures, exhausted quotas, and inputs that exceed the model's context window still need correction. Run `/compact` after resolving the cause. The extension does not truncate history to force a summary or switch models. CLIProxyAPI's Responses compaction endpoint is separate from Pi's text-summary workflow.
|
|
234
236
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-cliproxyapi-native",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "CLIProxyAPI chat discovery and image/video generation with Pi's native adapters",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@biomejs/biome": "^2.5.13",
|
|
42
|
-
"@earendil-works/pi-ai": "^1.
|
|
43
|
-
"@earendil-works/pi-coding-agent": "^1.
|
|
44
|
-
"@earendil-works/pi-tui": "^1.
|
|
42
|
+
"@earendil-works/pi-ai": "^1.4.0",
|
|
43
|
+
"@earendil-works/pi-coding-agent": "^1.4.0",
|
|
44
|
+
"@earendil-works/pi-tui": "^1.4.0",
|
|
45
45
|
"@types/node": "^24.13.4",
|
|
46
46
|
"typescript": "5.9.3"
|
|
47
47
|
},
|
package/src/claude-quota.ts
CHANGED
|
@@ -15,7 +15,7 @@ async function managementRequest(
|
|
|
15
15
|
) {
|
|
16
16
|
let response: Response;
|
|
17
17
|
try {
|
|
18
|
-
response = await fetch(`${config.baseUrl}/
|
|
18
|
+
response = await fetch(`${config.baseUrl}/v8/management/${path}`, {
|
|
19
19
|
method: body ? "POST" : "GET",
|
|
20
20
|
headers: { Authorization: `Bearer ${key}`, ...(body ? { "Content-Type": "application/json" } : {}) },
|
|
21
21
|
body: body ? JSON.stringify(body) : undefined,
|
|
@@ -135,7 +135,7 @@ export async function fetchClaudeQuota(
|
|
|
135
135
|
);
|
|
136
136
|
}
|
|
137
137
|
const bounded = AbortSignal.any([...(signal ? [signal] : []), AbortSignal.timeout(15000)]);
|
|
138
|
-
const listing = await managementRequest(config, key, "
|
|
138
|
+
const listing = await managementRequest(config, key, "credentials", bounded);
|
|
139
139
|
if (!isRecord(listing) || !Array.isArray(listing.files) || listing.files.length > 10000) {
|
|
140
140
|
throw new Error("The management API returned an invalid account list.");
|
|
141
141
|
}
|
|
@@ -168,13 +168,13 @@ export async function fetchClaudeQuota(
|
|
|
168
168
|
const models = await managementRequest(
|
|
169
169
|
config,
|
|
170
170
|
key,
|
|
171
|
-
`
|
|
171
|
+
`credentials/models?name=${encodeURIComponent(account.name)}`,
|
|
172
172
|
bounded,
|
|
173
173
|
);
|
|
174
174
|
if (!isRecord(models) || !Array.isArray(models.models))
|
|
175
175
|
throw new Error("The management API returned an invalid account catalog.");
|
|
176
176
|
if (!models.models.some((model: unknown) => isRecord(model) && model.id === modelId)) return undefined;
|
|
177
|
-
const response = await managementRequest(config, key, "api-call", bounded, {
|
|
177
|
+
const response = await managementRequest(config, key, "requests/api-call", bounded, {
|
|
178
178
|
auth_index: account.auth_index,
|
|
179
179
|
method: "GET",
|
|
180
180
|
url: "https://api.anthropic.com/api/oauth/usage",
|
package/src/compaction.ts
CHANGED
|
@@ -10,7 +10,7 @@ export function withCompactionRecovery(
|
|
|
10
10
|
return lazyStream(model, async () => ({
|
|
11
11
|
async *[Symbol.asyncIterator]() {
|
|
12
12
|
const limit = model.maxTokens > 0 ? model.maxTokens : 32768;
|
|
13
|
-
let maxTokens = Math.max(1, Math.min(options.maxTokens ??
|
|
13
|
+
let maxTokens = Math.max(1, Math.min(options.maxTokens ?? limit, limit));
|
|
14
14
|
const reasoning =
|
|
15
15
|
options.reasoning && !["minimal", "low"].includes(options.reasoning) ? "low" : options.reasoning;
|
|
16
16
|
const run = () =>
|