pi-cliproxyapi-autoconnect 1.2.2 → 1.2.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 +10 -0
- package/index.ts +43 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -141,10 +141,13 @@ An Anthropic-compatible endpoint does not always expose a model list. If `/v1/mo
|
|
|
141
141
|
```text
|
|
142
142
|
/cliproxy Show the current config, model count and last error
|
|
143
143
|
/cliproxy refresh Refresh the model list immediately
|
|
144
|
+
/cliproxy clear Delete the saved config and its backup
|
|
144
145
|
```
|
|
145
146
|
|
|
146
147
|
The model catalog is cached for **5 minutes** by default: opening `/model` does not hit the upstream every time. `/cliproxy refresh` forces a refresh.
|
|
147
148
|
|
|
149
|
+
Running `/logout` only removes the credential from pi's `auth.json`; the saved `cliproxy.json` is intentionally kept so a later `/login` can reuse it. While signed out, `/cliproxy` reports that CLIProxy is not signed in instead of showing the old endpoint as active. Use `/cliproxy clear` if you want to remove the saved domain, endpoint and model cache as well.
|
|
150
|
+
|
|
148
151
|
To reconfigure (new domain or key), run `/login` → `CLIProxy` again. If you switched to a completely different domain and the old models are still visible, run `/reload` so the plugin rebuilds the provider from the new config.
|
|
149
152
|
|
|
150
153
|
### Relationship to pi update commands
|
|
@@ -196,6 +199,7 @@ Notes:
|
|
|
196
199
|
- Since 1.1.0, complete model metadata (`reasoning` / `input` / `cost` / `contextWindow` / `maxTokens`) is written directly to `cliproxy.json`, not just model IDs.
|
|
197
200
|
- The previous version is saved as `cliproxy.json.bak` before each write, for manual recovery.
|
|
198
201
|
- The plugin never writes the key to `cliproxy.json` and never prints it to logs.
|
|
202
|
+
- `/logout` removes the credential from `auth.json` but keeps `cliproxy.json`, so the saved endpoint and model cache can be reused after signing in again. While signed out, `/cliproxy` reports that CLIProxy is not signed in; run `/cliproxy clear` to delete the saved config.
|
|
199
203
|
- The key prompt is **not masked** in pi's current TUI (pi renders `secret` and normal text prompts the same way). Be aware of your surroundings.
|
|
200
204
|
- Removing the plugin does not remove credentials from `auth.json`. To clean up, run `/logout` in pi and select CLIProxy, or edit `auth.json` manually.
|
|
201
205
|
|
|
@@ -289,6 +293,12 @@ Run `/reload`, or restart pi after editing the plugin. The model list refreshes
|
|
|
289
293
|
|
|
290
294
|
## Changelog
|
|
291
295
|
|
|
296
|
+
### 1.2.3
|
|
297
|
+
|
|
298
|
+
- `/cliproxy` now checks whether CLIProxy is actually signed in. After `/logout` it reports “not signed in” instead of displaying the previous endpoint and model count as if they were active.
|
|
299
|
+
- Added `/cliproxy clear` to delete `cliproxy.json` and its backup when the saved config should not be reused.
|
|
300
|
+
- `/cliproxy refresh` refuses to run while signed out.
|
|
301
|
+
|
|
292
302
|
### 1.2.2
|
|
293
303
|
|
|
294
304
|
- Rewrote this README in English for the npm package page and the pi package gallery.
|
package/index.ts
CHANGED
|
@@ -638,7 +638,7 @@ async function fetchOpenAIModels(baseUrl: string, apiKey: string, signal: AbortS
|
|
|
638
638
|
headers: {
|
|
639
639
|
Accept: "application/json",
|
|
640
640
|
Authorization: `Bearer ${apiKey}`,
|
|
641
|
-
"User-Agent": "pi-cliproxyapi-autoconnect/1.2.
|
|
641
|
+
"User-Agent": "pi-cliproxyapi-autoconnect/1.2.3",
|
|
642
642
|
},
|
|
643
643
|
signal: requestSignal,
|
|
644
644
|
});
|
|
@@ -662,7 +662,7 @@ async function fetchGeminiModels(baseUrl: string, apiKey: string, signal: AbortS
|
|
|
662
662
|
const { signal: requestSignal, cleanup } = abortSignalWithTimeout(signal, REQUEST_TIMEOUT_MS);
|
|
663
663
|
try {
|
|
664
664
|
const response = await fetch(url, {
|
|
665
|
-
headers: { Accept: "application/json", "User-Agent": "pi-cliproxyapi-autoconnect/1.2.
|
|
665
|
+
headers: { Accept: "application/json", "User-Agent": "pi-cliproxyapi-autoconnect/1.2.3" },
|
|
666
666
|
signal: requestSignal,
|
|
667
667
|
});
|
|
668
668
|
if (!response.ok) {
|
|
@@ -703,7 +703,7 @@ async function fetchAnthropicModels(baseUrl: string, apiKey: string, signal: Abo
|
|
|
703
703
|
// Anthropic's x-api-key header; sending both is harmless upstream.
|
|
704
704
|
Authorization: `Bearer ${apiKey}`,
|
|
705
705
|
"anthropic-version": "2023-06-01",
|
|
706
|
-
"User-Agent": "pi-cliproxyapi-autoconnect/1.2.
|
|
706
|
+
"User-Agent": "pi-cliproxyapi-autoconnect/1.2.3",
|
|
707
707
|
},
|
|
708
708
|
signal: requestSignal,
|
|
709
709
|
});
|
|
@@ -1254,10 +1254,49 @@ export default function (pi: ExtensionAPI): void {
|
|
|
1254
1254
|
pi.registerProvider(buildProvider(readConfig()));
|
|
1255
1255
|
|
|
1256
1256
|
pi.registerCommand("cliproxy", {
|
|
1257
|
-
description: "Show CLIProxy config,
|
|
1257
|
+
description: "Show CLIProxy config, refresh models, or clear the saved config",
|
|
1258
1258
|
handler: async (args, ctx) => {
|
|
1259
1259
|
const subcommand = args.trim().toLowerCase();
|
|
1260
1260
|
const config = readConfig();
|
|
1261
|
+
const signedIn = ctx.modelRegistry.getProviderAuthStatus(PROVIDER_ID).configured;
|
|
1262
|
+
|
|
1263
|
+
if (subcommand === "clear" || subcommand === "reset") {
|
|
1264
|
+
const backupPath = `${configPath()}.bak`;
|
|
1265
|
+
if (!config && !existsSync(backupPath)) {
|
|
1266
|
+
ctx.ui.notify("No saved CLIProxy config to clear.", "info");
|
|
1267
|
+
return;
|
|
1268
|
+
}
|
|
1269
|
+
const confirmed = await ctx.ui.confirm(
|
|
1270
|
+
"Delete saved CLIProxy config?",
|
|
1271
|
+
`This removes ${configPath()} and its backup. You will need to sign in again.`,
|
|
1272
|
+
);
|
|
1273
|
+
if (!confirmed) return;
|
|
1274
|
+
try {
|
|
1275
|
+
for (const path of [configPath(), backupPath]) {
|
|
1276
|
+
if (existsSync(path)) unlinkSync(path);
|
|
1277
|
+
}
|
|
1278
|
+
} catch (error) {
|
|
1279
|
+
ctx.ui.notify(
|
|
1280
|
+
`Failed to clear CLIProxy config: ${error instanceof Error ? error.message : String(error)}`,
|
|
1281
|
+
"error",
|
|
1282
|
+
);
|
|
1283
|
+
return;
|
|
1284
|
+
}
|
|
1285
|
+
lastRefreshError = undefined;
|
|
1286
|
+
ctx.ui.notify("CLIProxy config cleared. Run /login to configure it again.", "info");
|
|
1287
|
+
return;
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
if (!signedIn) {
|
|
1291
|
+
const saved = config
|
|
1292
|
+
? `\nA saved config remains at ${configPath()} and will be reused after you sign in.\nRemove it with /cliproxy clear.`
|
|
1293
|
+
: "";
|
|
1294
|
+
ctx.ui.notify(
|
|
1295
|
+
`CLIProxy is not signed in.\nRun /login -> "Sign in with an API key" -> CLIProxy.${saved}`,
|
|
1296
|
+
"warning",
|
|
1297
|
+
);
|
|
1298
|
+
return;
|
|
1299
|
+
}
|
|
1261
1300
|
|
|
1262
1301
|
if (subcommand === "refresh") {
|
|
1263
1302
|
if (!config) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-cliproxyapi-autoconnect",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "CLIProxyAPI auto-connect provider for pi: sign in with a bound domain and API key, automatically discover OpenAI/Gemini/Anthropic-compatible endpoints, and register models in /model.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|