@router-for-me/pi-cliproxyapi-provider 1.4.0 → 1.4.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 CHANGED
@@ -4,7 +4,7 @@ Pi provider extension that discovers models from [CLIProxyAPI](https://github.co
4
4
 
5
5
  ## What it does
6
6
 
7
- 1. Registers a provider that always appears in `/login` (subscription path) and via `/cliproxyapi` / `/cpa`.
7
+ 1. Registers a provider that always appears in `/login` (account sign-in path) and via `/cliproxyapi`.
8
8
  2. Interactive setup collects `baseUrl` + `apiKey`.
9
9
  3. Fetches `{root}/v1/models?client_version=pi`.
10
10
  4. Maps the CLIProxyAPI catalog into pi models, including Fast service-tier capability.
@@ -27,26 +27,15 @@ pi -e /absolute/path/to/pi-cliproxyapi-provider
27
27
 
28
28
  ## Login-style setup (recommended)
29
29
 
30
- This plugin needs both **baseUrl** and **apiKey**. pi's built-in `/login` only supports multi-field prompts on the OAuth/subscription path, so CLIProxyAPI appears under **Use a subscription** (not API key).
30
+ This plugin needs both **baseUrl** and **apiKey**. pi's built-in `/login` only supports multi-field prompts on the account/OAuth path, so CLIProxyAPI appears under **Sign in with an account** (not API key).
31
31
 
32
- ### Preferred: dedicated command (when not yet authenticated)
32
+ ### Preferred: dedicated command
33
33
 
34
34
  ```text
35
35
  /cliproxyapi
36
36
  ```
37
37
 
38
- or short alias:
39
-
40
- ```text
41
- /cpa
42
- ```
43
-
44
- These slash commands appear only when setup is needed. After a successful login they are **hidden** from the `/` menu. They reappear when:
45
-
46
- - you run `/logout` and remove CLIProxyAPI credentials
47
- - a models request returns **HTTP 401**
48
-
49
- To reconfigure while still authenticated, use `/login CLIProxyAPI`.
38
+ This slash command remains available so the connection can be reconfigured at any time. If the provider currently has credentials saved by `/login`, use `/login CLIProxyAPI` to replace them, or run `/logout` before using a dedicated command. This avoids reporting a successful reconfiguration while pi is still prioritizing the stored login credential.
50
39
 
51
40
  ### Or use /login shortcuts (skip the menu)
52
41
 
@@ -60,6 +49,8 @@ or:
60
49
  /login cliproxyapi
61
50
  ```
62
51
 
52
+ These shortcuts jump straight into CLIProxyAPI's multi-field baseUrl + API key prompts. The provider is registered as OAuth-only, so pi does not ask you to choose between API key and account first.
53
+
63
54
  ### Menu path
64
55
 
65
56
  ```text
@@ -68,7 +59,7 @@ or:
68
59
 
69
60
  Then choose:
70
61
 
71
- 1. **Use a subscription**
62
+ 1. **Sign in with an account**
72
63
  (required for multi-field baseUrl + API key prompts)
73
64
  2. **CLIProxyAPI**
74
65
  3. Enter:
@@ -83,10 +74,10 @@ Final login validation calls `{root}/v1/models?client_version=pi`:
83
74
  On success (any of the paths above):
84
75
 
85
76
  - models are registered immediately in the current session (0 models is allowed)
86
- - credentials are stored in `~/.pi/agent/auth.json`
87
- - `baseUrl` / `apiKey` are also written to `~/.pi/agent/cliproxyapi.json`
77
+ - `baseUrl` / `apiKey` are written to `~/.pi/agent/cliproxyapi.json`
78
+ - when using `/login`, pi also stores the returned credential in `~/.pi/agent/auth.json`
88
79
 
89
- Re-run `/cliproxyapi`, `/cpa`, or `/login CLIProxyAPI` anytime to reconfigure.
80
+ Re-run `/cliproxyapi` or `/login CLIProxyAPI` anytime to reconfigure. Dedicated commands require any existing `/login` credential to be removed first. The built-in `/logout` command only removes credentials saved in `auth.json`; it does not erase `cliproxyapi.json`. Remove or update that file if you also need to clear the provider configuration.
90
81
 
91
82
  ## Non-interactive configuration
92
83
 
@@ -197,13 +188,14 @@ Disable just this helper via `pi config` if you only want the CLIProxyAPI provid
197
188
 
198
189
  ## Failure behavior
199
190
 
200
- - Before setup / without credentials: provider still appears in `/login`; `/cliproxyapi` and `/cpa` are shown; no models are listed yet.
201
- - After successful login: `/cliproxyapi` and `/cpa` are hidden; reconfigure via `/login CLIProxyAPI` if needed.
202
- - After `/logout` for CLIProxyAPI: setup commands reappear for reconfiguration.
203
- - If a models request returns **HTTP 401**: setup commands reappear for reconfiguration.
204
- - If CPA is unreachable during startup (non-401): a warning is logged; setup commands stay available via `/cliproxyapi` or `/login`.
191
+ - Before setup / without credentials: provider still appears in `/login`; `/cliproxyapi` is shown; no models are listed yet.
192
+ - After successful login or setup: `/cliproxyapi` remains available for reconfiguration.
193
+ - If an `auth.json` credential exists, the dedicated command asks you to use `/login CLIProxyAPI` or run `/logout` first so the old credential cannot override the new key.
194
+ - The built-in `/logout` command removes only the matching `auth.json` credential; environment variables and `cliproxyapi.json` are unchanged.
195
+ - If a models request returns **HTTP 401**, the setup command remains available for reconfiguration.
196
+ - If CPA is unreachable during startup (non-401), a warning is logged; the setup command remains available via `/cliproxyapi` or `/login`.
205
197
  - Login/setup final step validates credentials by requesting models:
206
- - HTTP 200 (including empty catalog) → credentials are persisted; setup commands hidden
198
+ - HTTP 200 (including empty catalog) → credentials are persisted; the setup command remains available
207
199
  - non-200 / network / invalid baseUrl → nothing is persisted; re-enter baseUrl + API key
208
200
  - If CPA returns HTTP 200 with zero usable models: login still succeeds; re-run setup later after models become available.
209
201
  - If the selected model does not provide a non-empty `service_tiers` array: the request is left unchanged; `/fast` still updates the global preference and warns when enabling it.
@@ -131,6 +131,9 @@ function patchCodexSource(source: string, providerIds: string[]): string {
131
131
  // Keep assistant message api metadata aligned with the registered custom api id.
132
132
  src = src.replaceAll(`api: "openai-codex-responses"`, `api: ${JSON.stringify(CLIPROXYAPI_CODEX_API)}`);
133
133
 
134
+ // The generated module lives outside the original source map directory.
135
+ src = src.replace(/^\/\/# sourceMappingURL=.*$/gm, "");
136
+
134
137
  return src;
135
138
  }
136
139
 
@@ -1,17 +1,17 @@
1
1
  /**
2
2
  * CLIProxyAPI dynamic model provider for pi.
3
3
  *
4
- * Supports login-style setup via `/login` and dedicated commands:
5
- * 1. Provider always appears under "Use a subscription" as CLIProxyAPI
6
- * (pi only supports multi-field prompts on the oauth/subscription path).
4
+ * Supports login-style setup via `/login` and a dedicated command:
5
+ * 1. Provider is registered as OAuth-only so `/login CLIProxyAPI` / `/login cliproxyapi`
6
+ * skip the API-key vs account selector and go straight to multi-field prompts
7
+ * (pi only supports multi-field prompts on the account/OAuth path).
7
8
  * 2. Preferred shortcuts: `/login CLIProxyAPI`, `/login cliproxyapi`,
8
- * or dedicated commands `/cliproxyapi` / `/cpa` (shown only when not authenticated).
9
+ * or the dedicated `/cliproxyapi` command.
9
10
  * 3. Setup prompts for baseUrl + apiKey.
10
11
  * 4. Final login step validates credentials via /v1/models?client_version=pi
11
12
  * (HTTP 200 = success even if the catalog is empty; otherwise re-prompt).
12
- * 5. On success, models/credentials are saved and `/cliproxyapi` `/cpa` are hidden.
13
- * 6. Setup commands reappear after `/logout` or when a models request returns HTTP 401.
14
- * 7. `/fast` globally controls catalog-driven priority service tier injection.
13
+ * 5. On success, models/credentials are saved and registered immediately.
14
+ * 6. `/fast` globally controls catalog-driven priority service tier injection.
15
15
  *
16
16
  * Uses a patched openai-codex-responses implementation that does not require
17
17
  * extracting chatgpt_account_id from the API key (plain CPA keys work).
@@ -48,11 +48,9 @@ import {
48
48
  saveConfigFile,
49
49
  } from "./lib.ts";
50
50
 
51
- /** Controls visibility of /cliproxyapi and /cpa in the slash-command menu. */
51
+ /** Registers /cliproxyapi in the slash-command menu. */
52
52
  interface SetupCommandsController {
53
53
  show(): void;
54
- hide(): void;
55
- isVisible(): boolean;
56
54
  }
57
55
 
58
56
  class ConfigPersistenceError extends Error {
@@ -143,6 +141,13 @@ async function configureAndRegister(options: {
143
141
  streamSimple: CliproxyCodexStreamSimple;
144
142
  setupCommands: SetupCommandsController;
145
143
  fastMode: FastModeController;
144
+ /**
145
+ * When true, register a configured API key for ambient request auth.
146
+ * Only used by `/cliproxyapi` (no auth.json write). `/login` must leave this
147
+ * false so the provider stays OAuth-only and `/login <provider>` skips the
148
+ * API-key vs account selector.
149
+ */
150
+ registerConfiguredApiKey?: boolean;
146
151
  }): Promise<{ modelCount: number; modelsUrl: string }> {
147
152
  const {
148
153
  pi,
@@ -155,6 +160,7 @@ async function configureAndRegister(options: {
155
160
  streamSimple,
156
161
  setupCommands,
157
162
  fastMode,
163
+ registerConfiguredApiKey = false,
158
164
  } = options;
159
165
 
160
166
  const loaded = await loadMappedModels(baseUrlInput, apiKey);
@@ -174,7 +180,7 @@ async function configureAndRegister(options: {
174
180
  providerId,
175
181
  providerName,
176
182
  baseUrlInput,
177
- apiKey,
183
+ apiKey: registerConfiguredApiKey ? apiKey : undefined,
178
184
  models: loaded.models,
179
185
  defaultBaseUrl: baseUrlInput || defaultBaseUrl,
180
186
  agentDir,
@@ -184,9 +190,6 @@ async function configureAndRegister(options: {
184
190
  });
185
191
  fastMode.setSupportedModelIds(loaded.fastModelIds);
186
192
 
187
- // Login succeeded — hide dedicated setup commands from the slash menu.
188
- setupCommands.hide();
189
-
190
193
  return { modelCount: loaded.models.length, modelsUrl: loaded.modelsUrl };
191
194
  }
192
195
 
@@ -239,7 +242,7 @@ function createOAuthHandlers(options: {
239
242
  callbacks.onProgress?.(message);
240
243
  throw error;
241
244
  }
242
- // Auth failures should keep setup commands available for reconfiguration.
245
+ // Auth failures should keep the setup command available for reconfiguration.
243
246
  if (isUnauthorizedModelsError(error)) {
244
247
  setupCommands.show();
245
248
  }
@@ -319,53 +322,25 @@ function registerProvider(
319
322
  fastMode,
320
323
  });
321
324
 
325
+ // Replace any previous registration so an earlier ambient apiKey does not linger
326
+ // via registerProvider merge semantics and reintroduce the auth-type selector.
327
+ pi.unregisterProvider(providerId);
328
+
322
329
  pi.registerProvider(providerId, {
323
330
  name: providerName,
324
331
  baseUrl: endpoints.inferenceBaseUrl,
325
332
  api: CLIPROXYAPI_CODEX_API,
326
333
  streamSimple,
327
- // Keep oauth always registered so /login lists this provider even before models exist.
334
+ // OAuth-only keeps `/login <provider>` on the multi-field account path.
335
+ // Pass apiKey only for ambient request auth when no /login credential exists
336
+ // (config file / env / `/cliproxyapi`). Never pass both for /login flows.
328
337
  oauth,
329
- // apiKey is optional when oauth is present; include it when known for direct use.
330
338
  ...(apiKey ? { apiKey } : {}),
331
339
  ...(models && models.length > 0 ? { models } : {}),
332
340
  });
333
341
  }
334
342
 
335
- const SETUP_COMMAND_NAMES = ["cliproxyapi", "cpa"] as const;
336
-
337
- /** Avoid double-wrapping the same AuthStorage instance across session reloads. */
338
- const logoutWatchedStorages = new WeakSet<object>();
339
-
340
- /**
341
- * pi has no logout extension event. Wrap authStorage.logout so we can re-show
342
- * setup commands when this provider is removed via /logout.
343
- */
344
- function watchProviderLogout(
345
- authStorage: { logout(provider: string): void },
346
- providerId: string,
347
- onLogout: () => void,
348
- ): void {
349
- if (logoutWatchedStorages.has(authStorage as object)) {
350
- return;
351
- }
352
- logoutWatchedStorages.add(authStorage as object);
353
-
354
- const originalLogout = authStorage.logout.bind(authStorage);
355
- authStorage.logout = (provider: string): void => {
356
- originalLogout(provider);
357
- if (provider === providerId) {
358
- onLogout();
359
- }
360
- };
361
- }
362
-
363
- /**
364
- * Show/hide /cliproxyapi and /cpa.
365
- *
366
- * pi has registerCommand but no unregisterCommand, so hide() removes entries from the
367
- * extension's internal commands Map captured during the first registration.
368
- */
343
+ /** Register the always-available /cliproxyapi setup command. */
369
344
  function createSetupCommandsController(options: {
370
345
  pi: ExtensionAPI;
371
346
  agentDir: string;
@@ -377,22 +352,14 @@ function createSetupCommandsController(options: {
377
352
  }): SetupCommandsController {
378
353
  const { pi, agentDir, providerId, providerName, defaultBaseUrl, streamSimple, fastMode } = options;
379
354
 
380
- // Self-referential controller so handlers can hide/show after validation.
355
+ // Self-referential controller so validation failures can ensure commands are registered.
381
356
  const setupCommands: SetupCommandsController = {
382
357
  show() {
383
358
  /* replaced below */
384
359
  },
385
- hide() {
386
- /* replaced below */
387
- },
388
- isVisible() {
389
- return false;
390
- },
391
360
  };
392
361
 
393
362
  let visible = false;
394
- // Captured extension.commands Map (pi has no public unregisterCommand API).
395
- let commandMap: Map<string, unknown> | null = null;
396
363
 
397
364
  const handler = async (_args: string, ctx: ExtensionCommandContext): Promise<void> => {
398
365
  if (!ctx.hasUI) {
@@ -403,6 +370,14 @@ function createSetupCommandsController(options: {
403
370
  return;
404
371
  }
405
372
 
373
+ if (loadAuthConnection(agentDir, providerId)?.apiKey) {
374
+ ctx.ui.notify(
375
+ `CLIProxyAPI credentials are already stored by /login. Use /login ${providerName} to replace them, or run /logout before /cliproxyapi.`,
376
+ "error",
377
+ );
378
+ return;
379
+ }
380
+
406
381
  const promptDefaultBaseUrl = resolveDefaultBaseUrl(agentDir, providerId) || defaultBaseUrl;
407
382
 
408
383
  const baseUrlRaw = await ctx.ui.input(`CLIProxyAPI base URL [${promptDefaultBaseUrl}]:`, promptDefaultBaseUrl);
@@ -448,12 +423,9 @@ function createSetupCommandsController(options: {
448
423
  streamSimple,
449
424
  setupCommands,
450
425
  fastMode,
451
- });
452
-
453
- // Persist only after successful validation; keep AuthStorage in-memory too.
454
- ctx.modelRegistry.authStorage.set(providerId, {
455
- type: "oauth",
456
- ...buildOAuthCredentials(currentBaseUrl, currentApiKey),
426
+ // Dedicated command does not write auth.json; keep ambient apiKey
427
+ // so requests work in the current session.
428
+ registerConfiguredApiKey: true,
457
429
  });
458
430
 
459
431
  logInfo(`command setup ok: registered ${result.modelCount} models from ${result.modelsUrl}`);
@@ -506,78 +478,22 @@ function createSetupCommandsController(options: {
506
478
  }
507
479
  };
508
480
 
509
- const commandSpecs: Array<{ name: (typeof SETUP_COMMAND_NAMES)[number]; description: string }> = [
510
- {
511
- name: "cliproxyapi",
481
+ const registerCommand = (): void => {
482
+ pi.registerCommand("cliproxyapi", {
512
483
  description: "Configure CLIProxyAPI (baseUrl + API key) and load models. Prefer this or /login CLIProxyAPI.",
513
- },
514
- {
515
- name: "cpa",
516
- description: "Alias for /cliproxyapi — configure CLIProxyAPI and load models.",
517
- },
518
- ];
519
-
520
- const registerAll = (): void => {
521
- for (const spec of commandSpecs) {
522
- pi.registerCommand(spec.name, {
523
- description: spec.description,
524
- handler,
525
- });
526
- }
484
+ handler,
485
+ });
527
486
  };
528
487
 
529
488
  setupCommands.show = (): void => {
530
489
  if (visible) {
531
490
  return;
532
491
  }
533
-
534
- if (!commandMap) {
535
- // Capture the extension.commands Map during first registration.
536
- const originalSet = Map.prototype.set;
537
- Map.prototype.set = function setWithCapture(this: Map<unknown, unknown>, key: unknown, value: unknown) {
538
- if (
539
- key === "cliproxyapi" &&
540
- value &&
541
- typeof value === "object" &&
542
- "handler" in (value as Record<string, unknown>)
543
- ) {
544
- commandMap = this as Map<string, unknown>;
545
- }
546
- return originalSet.call(this, key, value);
547
- } as typeof Map.prototype.set;
548
- try {
549
- registerAll();
550
- } finally {
551
- Map.prototype.set = originalSet;
552
- }
553
- if (!commandMap) {
554
- logWarn("could not capture command map; /cliproxyapi and /cpa cannot be hidden after login");
555
- }
556
- } else {
557
- registerAll();
558
- }
559
-
492
+ registerCommand();
560
493
  visible = true;
561
- logInfo("setup commands shown: /cliproxyapi, /cpa");
494
+ logInfo("setup command registered: /cliproxyapi");
562
495
  };
563
496
 
564
- setupCommands.hide = (): void => {
565
- if (!visible) {
566
- return;
567
- }
568
- if (!commandMap) {
569
- logWarn("setup commands remain visible (no command map capture for unregister)");
570
- return;
571
- }
572
- for (const name of SETUP_COMMAND_NAMES) {
573
- commandMap.delete(name);
574
- }
575
- visible = false;
576
- logInfo("setup commands hidden (CLIProxyAPI already authenticated)");
577
- };
578
-
579
- setupCommands.isVisible = (): boolean => visible;
580
-
581
497
  return setupCommands;
582
498
  }
583
499
 
@@ -670,14 +586,7 @@ export default async function (pi: ExtensionAPI): Promise<void> {
670
586
  fastMode,
671
587
  });
672
588
 
673
- // Re-show setup commands when the user /logout this provider.
674
- // Installed on session_start because AuthStorage is only available via ctx then.
675
- pi.on("session_start", (_event, ctx) => {
676
- watchProviderLogout(ctx.modelRegistry.authStorage, identity.providerId, () => {
677
- setupCommands.show();
678
- logInfo(`logout detected for ${identity.providerId}: setup commands restored: /cliproxyapi, /cpa`);
679
- });
680
- });
589
+ setupCommands.show();
681
590
 
682
591
  // Always register oauth so the provider is visible in /login immediately after install.
683
592
  registerProvider(pi, {
@@ -695,8 +604,8 @@ export default async function (pi: ExtensionAPI): Promise<void> {
695
604
  if (!connection) {
696
605
  setupCommands.show();
697
606
  logInfo(
698
- `not configured yet. Prefer /cliproxyapi (or /cpa), or /login ${identity.providerName}. ` +
699
- `Menu path: /login → Use a subscription → ${identity.providerName}. ` +
607
+ `not configured yet. Prefer /cliproxyapi or /login ${identity.providerName}. ` +
608
+ `Menu path: /login → Sign in with an account → ${identity.providerName}. ` +
700
609
  `Or set ${CONFIG_FILE_NAME} / CLIPROXYAPI_API_KEY.`,
701
610
  );
702
611
  return;
@@ -705,11 +614,15 @@ export default async function (pi: ExtensionAPI): Promise<void> {
705
614
  try {
706
615
  const loaded = await loadMappedModels(connection.baseUrlInput, connection.apiKey);
707
616
  fastMode.setSupportedModelIds(loaded.fastModelIds);
617
+ // Prefer OAuth-only registration when /login already stored credentials so
618
+ // `/login <provider>` jumps straight into the multi-field flow. Fall back to
619
+ // ambient apiKey only for config-file / env setups without auth.json.
620
+ const hasStoredLogin = Boolean(loadAuthConnection(agentDir, identity.providerId)?.apiKey);
708
621
  registerProvider(pi, {
709
622
  providerId: identity.providerId,
710
623
  providerName: identity.providerName,
711
624
  baseUrlInput: connection.baseUrlInput,
712
- apiKey: connection.apiKey,
625
+ apiKey: hasStoredLogin ? undefined : connection.apiKey,
713
626
  models: loaded.models,
714
627
  defaultBaseUrl,
715
628
  agentDir,
@@ -717,14 +630,12 @@ export default async function (pi: ExtensionAPI): Promise<void> {
717
630
  setupCommands,
718
631
  fastMode,
719
632
  });
720
- // Already authenticated — keep /cliproxyapi and /cpa hidden.
721
- setupCommands.hide();
722
633
  } catch (error) {
723
634
  const message = error instanceof Error ? error.message : String(error);
724
635
  if (isUnauthorizedModelsError(error)) {
725
- // 401 → credentials rejected; re-show setup commands for reconfiguration.
636
+ // 401 → credentials rejected; keep the setup command available for reconfiguration.
726
637
  setupCommands.show();
727
- logWarn(`models request unauthorized (${message}). Setup commands restored: /cliproxyapi, /cpa.`);
638
+ logWarn(`models request unauthorized (${message}). Setup command remains available: /cliproxyapi.`);
728
639
  } else {
729
640
  // Other failures (network, etc.): still offer setup so the user can fix baseUrl/key.
730
641
  setupCommands.show();
package/extensions/lib.ts CHANGED
@@ -4,6 +4,7 @@
4
4
 
5
5
  import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
6
6
  import { dirname, join } from "node:path";
7
+ import { readStoredCredential } from "@earendil-works/pi-coding-agent";
7
8
 
8
9
  // Local shape matching pi ThinkingLevelMap; avoid hard runtime peer imports here.
9
10
  export type ThinkingLevelMap = Partial<
@@ -199,31 +200,17 @@ export function saveConfigFile(agentDir: string, config: CliproxyConfigFile): vo
199
200
  }
200
201
 
201
202
  export function loadAuthConnection(agentDir: string, providerId: string): { baseUrl?: string; apiKey?: string } | null {
202
- const authPath = join(agentDir, AUTH_FILE_NAME);
203
- try {
204
- const raw = readFileSync(authPath, "utf8");
205
- const data = JSON.parse(raw) as Record<string, any>;
206
- const entry = data?.[providerId];
207
- if (!entry || typeof entry !== "object") {
208
- return null;
209
- }
210
-
211
- if (entry.type === "oauth" && typeof entry.access === "string" && entry.access.trim()) {
212
- const meta = decodeRefreshMeta(typeof entry.refresh === "string" ? entry.refresh : undefined);
213
- return {
214
- apiKey: entry.access.trim(),
215
- baseUrl: meta?.baseUrl,
216
- };
217
- }
203
+ const entry = readStoredCredential(providerId, join(agentDir, AUTH_FILE_NAME));
204
+ if (entry?.type === "oauth" && typeof entry.access === "string" && entry.access.trim()) {
205
+ const meta = decodeRefreshMeta(typeof entry.refresh === "string" ? entry.refresh : undefined);
206
+ return {
207
+ apiKey: entry.access.trim(),
208
+ baseUrl: meta?.baseUrl,
209
+ };
210
+ }
218
211
 
219
- if (entry.type === "api_key" && typeof entry.key === "string" && entry.key.trim()) {
220
- return { apiKey: entry.key.trim() };
221
- }
222
- } catch (error) {
223
- const err = error as NodeJS.ErrnoException;
224
- if (err.code !== "ENOENT") {
225
- throw error;
226
- }
212
+ if (entry?.type === "api_key" && typeof entry.key === "string" && entry.key.trim()) {
213
+ return { apiKey: entry.key.trim() };
227
214
  }
228
215
  return null;
229
216
  }
@@ -400,7 +387,7 @@ export function toPiModel(model: CodexClientModel): PiProviderModel | null {
400
387
  };
401
388
  }
402
389
 
403
- /** HTTP error from /v1/models (used to detect 401 and re-show setup commands). */
390
+ /** HTTP error from /v1/models (used to detect 401 and keep the setup command available). */
404
391
  export class ModelsHttpError extends Error {
405
392
  readonly status: number;
406
393
  readonly statusText: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@router-for-me/pi-cliproxyapi-provider",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "description": "Pi provider extension that auto-registers CLIProxyAPI models, plus TUI elapsed/TPS status",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -39,12 +39,12 @@
39
39
  },
40
40
  "peerDependencies": {
41
41
  "@earendil-works/pi-ai": "*",
42
- "@earendil-works/pi-coding-agent": ">=0.80.6 <0.81.0"
42
+ "@earendil-works/pi-coding-agent": ">=0.80.9 <0.81.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@biomejs/biome": "2.5.3",
46
- "@earendil-works/pi-ai": "^0.80.6",
47
- "@earendil-works/pi-coding-agent": "0.80.6",
46
+ "@earendil-works/pi-ai": "0.80.9",
47
+ "@earendil-works/pi-coding-agent": "0.80.9",
48
48
  "@types/node": "^22.15.21",
49
49
  "typescript": "6.0.3",
50
50
  "vitest": "4.1.9"