@router-for-me/pi-cliproxyapi-provider 1.4.1 → 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
@@ -49,6 +49,8 @@ or:
49
49
  /login cliproxyapi
50
50
  ```
51
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
+
52
54
  ### Menu path
53
55
 
54
56
  ```text
@@ -2,7 +2,8 @@
2
2
  * CLIProxyAPI dynamic model provider for pi.
3
3
  *
4
4
  * Supports login-style setup via `/login` and a dedicated command:
5
- * 1. Provider always appears under "Sign in with an account" as CLIProxyAPI
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
6
7
  * (pi only supports multi-field prompts on the account/OAuth path).
7
8
  * 2. Preferred shortcuts: `/login CLIProxyAPI`, `/login cliproxyapi`,
8
9
  * or the dedicated `/cliproxyapi` command.
@@ -140,6 +141,13 @@ async function configureAndRegister(options: {
140
141
  streamSimple: CliproxyCodexStreamSimple;
141
142
  setupCommands: SetupCommandsController;
142
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;
143
151
  }): Promise<{ modelCount: number; modelsUrl: string }> {
144
152
  const {
145
153
  pi,
@@ -152,6 +160,7 @@ async function configureAndRegister(options: {
152
160
  streamSimple,
153
161
  setupCommands,
154
162
  fastMode,
163
+ registerConfiguredApiKey = false,
155
164
  } = options;
156
165
 
157
166
  const loaded = await loadMappedModels(baseUrlInput, apiKey);
@@ -171,7 +180,7 @@ async function configureAndRegister(options: {
171
180
  providerId,
172
181
  providerName,
173
182
  baseUrlInput,
174
- apiKey,
183
+ apiKey: registerConfiguredApiKey ? apiKey : undefined,
175
184
  models: loaded.models,
176
185
  defaultBaseUrl: baseUrlInput || defaultBaseUrl,
177
186
  agentDir,
@@ -313,14 +322,19 @@ function registerProvider(
313
322
  fastMode,
314
323
  });
315
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
+
316
329
  pi.registerProvider(providerId, {
317
330
  name: providerName,
318
331
  baseUrl: endpoints.inferenceBaseUrl,
319
332
  api: CLIPROXYAPI_CODEX_API,
320
333
  streamSimple,
321
- // 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.
322
337
  oauth,
323
- // apiKey is optional when oauth is present; include it when known for direct use.
324
338
  ...(apiKey ? { apiKey } : {}),
325
339
  ...(models && models.length > 0 ? { models } : {}),
326
340
  });
@@ -409,6 +423,9 @@ function createSetupCommandsController(options: {
409
423
  streamSimple,
410
424
  setupCommands,
411
425
  fastMode,
426
+ // Dedicated command does not write auth.json; keep ambient apiKey
427
+ // so requests work in the current session.
428
+ registerConfiguredApiKey: true,
412
429
  });
413
430
 
414
431
  logInfo(`command setup ok: registered ${result.modelCount} models from ${result.modelsUrl}`);
@@ -597,11 +614,15 @@ export default async function (pi: ExtensionAPI): Promise<void> {
597
614
  try {
598
615
  const loaded = await loadMappedModels(connection.baseUrlInput, connection.apiKey);
599
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);
600
621
  registerProvider(pi, {
601
622
  providerId: identity.providerId,
602
623
  providerName: identity.providerName,
603
624
  baseUrlInput: connection.baseUrlInput,
604
- apiKey: connection.apiKey,
625
+ apiKey: hasStoredLogin ? undefined : connection.apiKey,
605
626
  models: loaded.models,
606
627
  defaultBaseUrl,
607
628
  agentDir,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@router-for-me/pi-cliproxyapi-provider",
3
- "version": "1.4.1",
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": [