原始内容
@alexeiled/pi-provider-compat
A compatibility bridge for Pi custom providers that use streamSimple.
Problem
Pi 0.80 moved the old global pi-ai dispatcher to @earendil-works/pi-ai/compat.
Custom providers registered with pi.registerProvider() are provider-scoped, but some
extensions still call the global compat dispatcher directly.
That mismatch produces errors such as:
No API provider registered for api: router-local-api
No API provider registered for api: openai-codex-personal-responses
It can affect model routers, provider aliases, watchdogs, background commands, and any
extension that calls stream() or streamSimple() from @earendil-works/pi-ai/compat.
What it does
This extension discovers every registered provider with both:
apistreamSimple
It registers a provider-aware dispatcher for that API in the compat registry when no
compat provider is already registered. Calls route by model.provider. Existing compat
providers are left untouched, preserving their ownership and reload cleanup. The bridge
refreshes on session/model lifecycle events and removes only its own registrations.
There are no provider-specific names or allowlists.
Install
pi install npm:@alexeiled/pi-provider-compat
Reload Pi:
/reload
Then retry the command that failed.
Requirements
- Pi
>=0.80.8 - A custom provider registered with
pi.registerProvider(..., { api, streamSimple })
Pi packages its core libraries. This package declares them as peers and does not bundle Pi.
Scope
This is a compatibility workaround for extensions that use the legacy global dispatcher.
It does not replace a provider implementation, register credentials, or change model routing.
It does not override an API that already has a compat provider, and it does not help an API
that has no registered provider-scoped streamSimple implementation.
The durable upstream fix is for Pi to bridge registerProvider() registrations into the
compat registry itself, or for callers to use Pi's provider-scoped runtime.
Development
npm install
npm run test:all
The tests cover custom routing, preservation and cleanup of an existing compat provider, refresh after provider changes, type checking, and the npm package manifest.
License
MIT