pi-cliproxyapi-native 0.2.0 → 0.2.1
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 +4 -4
- package/package.json +1 -1
- package/src/claude-quota.ts +4 -4
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.3.0 and CLIProxyAPI 8.0.
|
|
30
|
+
The extension targets Pi 1.3.0 and CLIProxyAPI 8.0.32, 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.1
|
|
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.1`. 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
|
|
package/package.json
CHANGED
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",
|