Skip to content

fix(models): include extension-registered providers in settings and auth routes - #833

Open
elrond298 wants to merge 1 commit into
agegr:mainfrom
elrond298:fix/settings-extension-providers
Open

fix(models): include extension-registered providers in settings and auth routes#833
elrond298 wants to merge 1 commit into
agegr:mainfrom
elrond298:fix/settings-extension-providers

Conversation

@elrond298

@elrond298 elrond298 commented Sep 13, 2026

Copy link
Copy Markdown

Problem

Providers registered by an extension package (any extension that calls
pi.registerProvider / createProvider while loading resources) never appear in the
Models config panel, so their credentials cannot be managed from Pi Web — even though
the composer's model selector offers them and they work in a session.

With such an extension installed and its key stored in auth.json:

  • /api/models → lists the provider's models ✅
  • /api/auth/providersapiKeyProviders has no entry for that provider ❌

Root cause

Extension providers reach a model runtime in createAgentSessionServices(): it runs the
resource loader, then replays pendingProviderRegistrations onto its ModelRuntime
(dist/core/agent-session-services.js).

/api/models builds its runtime that way — hence the model is offered in the composer.
The four auth routes instead called a bare ModelRuntime.create(), which only knows
built-in providers plus models.json. getProviders() never contained the extension
provider (so the panel could not list it) and getProvider(id) returned undefined for
its login / logout / save-key paths.

Fix

New lib/model-runtime.ts exports createModelRuntimeWithExtensions(), which builds the
runtime through createAgentSessionServices({ cwd: agentDir, agentDir }). All four auth
routes now use it:

  • app/api/auth/providers/route.ts — panel listing
  • app/api/auth/api-key/[provider]/route.ts — save key
  • app/api/auth/login/[provider]/route.ts — OAuth / device-code login
  • app/api/auth/logout/[provider]/route.ts — OAuth logout

Deliberate choices:

Verification

Dev server started from this branch (pi-web 0.9.1) with a provider extension installed
(14 models registered, key already in auth.json):

GET /api/auth/providers
-  before: apiKeyProviders ... "newapi", "oc-sdk-go"        (extension provider absent)
+  after:  apiKeyProviders ..., "<ext-provider>", "newapi", "oc-sdk-go"
+
+  {"id":"<ext-provider>","displayName":"<Ext Provider>","configured":true,
+   "source":"stored","modelCount":14,"supportsOAuth":false}
  • /api/models unchanged — same list, extension models still present
  • POST /api/auth/api-key/<unknown> still fails cleanly (... does not support API key login) rather than crashing
  • npm run lint clean; no type errors in the changed files
  • cost: 3.3 s on the first request (Turbopack compile + extension load), 0.4 s steady state

Scope

@elrond298
elrond298 force-pushed the fix/settings-extension-providers branch from b96528e to 90d115f Compare September 13, 2026 09:18
…uth routes

Providers registered by an extension (via registerProvider, typically with
the createProvider helper) were missing from the provider listing and auth
routes: such a provider was selectable in the composer — /api/models loads
extensions — but absent from the Models panel, and its stored API key could
not be managed.

A bare ModelRuntime.create() only sees built-in providers plus models.json;
extension registrations are applied by createAgentSessionServices(). Add
createModelRuntimeWithExtensions() and use it in the provider listing and
auth routes. The agent dir acts as cwd so project-local extensions stay out;
global package extensions always load. Uncached: auth status and
login/logout need fresh credentials.
@elrond298
elrond298 force-pushed the fix/settings-extension-providers branch from 90d115f to 4e8bbe8 Compare September 13, 2026 09:20
@elrond298
elrond298 marked this pull request as ready for review September 13, 2026 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant