@2tle/pi-provider-manager 0.1.0 → 0.1.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
@@ -1,14 +1,31 @@
1
1
  # Pi Provider Manager
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/%402tle%2Fpi-provider-manager)](https://www.npmjs.com/package/@2tle/pi-provider-manager)
4
+
3
5
  An extension for registering and managing OpenAI-compatible API providers in Pi Agent.
4
6
 
5
7
  When working with local LLM servers, private gateways, proxies, or hosted APIs, managing each provider through `models.json` and restarting Pi can be cumbersome. This extension keeps managed providers and their model catalogs in one place.
6
8
 
9
+ ## Installation
10
+
11
+ Install the package from [npm](https://www.npmjs.com/package/@2tle/pi-provider-manager) and register it with Pi:
12
+
13
+ ```bash
14
+ pi install npm:@2tle/pi-provider-manager
15
+ ```
16
+
17
+ To try it without adding it to your settings:
18
+
19
+ ```bash
20
+ pi -e npm:@2tle/pi-provider-manager
21
+ ```
22
+
7
23
  ## Features
8
24
 
9
25
  - Add OpenAI-compatible providers from the Pi TUI
10
26
  - List managed providers without exposing API keys
11
27
  - Edit a provider's display name, Base URL, or API key
28
+ - Override missing or incorrect model context/output limits per provider
12
29
  - Refresh one provider's model catalog or every managed catalog
13
30
  - Delete a managed provider and its stored API key
14
31
  - Keep provider metadata and credentials in separate files
@@ -41,13 +58,52 @@ Displays each provider's ID, display name, Base URL, API key status, and the num
41
58
  ### Edit a provider
42
59
 
43
60
  ```text
44
- /provider edit <provider_name>
61
+ /provider edit [provider_name]
45
62
  ```
46
63
 
64
+ With no provider name, an interactive provider picker is shown. The provider editor now includes display name, Base URL, API key, per-model limits, and a guarded action to reset all model overrides.
65
+
47
66
  Use a provider ID (recommended) or a unique display name. Select the fields to change, then choose **Save changes**. The extension refreshes the provider's model catalog after saving.
48
67
 
49
68
  In TUI mode, API key input is masked with `*` characters. In RPC mode, the connected client is responsible for secret masking.
50
69
 
70
+ ### Override a model's limits
71
+
72
+ ```text
73
+ /provider model [provider_name] [model_id]
74
+ ```
75
+
76
+ Both arguments are optional. You can select the provider and model interactively, or pass them directly. The model picker displays the effective context/output limits and marks models with saved overrides. Existing override-only model IDs remain selectable even when a refresh no longer returns them.
77
+
78
+ Choose a model discovered from the provider's catalog (or enter its exact model ID), then set its **context window** and/or **maximum output tokens**. Values accept readable suffixes such as `128k`, `1m`, and `2b`, as well as raw token counts. These values override the API catalog metadata after every refresh. You can clear either field independently, or choose **Remove all overrides for this model** followed by **Save changes** to return to the API-provided value or extension fallback.
79
+
80
+ This is useful for compatible gateways that omit model metadata. For example, to correct the OpenCodex Go DeepSeek V4.1 catalog row:
81
+
82
+ ```text
83
+ /provider model opencodex
84
+ # select: opencode-go/deepseek-v4.1-flash
85
+ # set its context window to the gateway's documented value
86
+ # Save changes
87
+ ```
88
+
89
+ Overrides are persisted in the provider configuration, keyed by the exact model ID:
90
+
91
+ ```json
92
+ {
93
+ "providers": [{
94
+ "id": "opencodex",
95
+ "name": "opencodex",
96
+ "baseUrl": "http://127.0.0.1:10100/v1",
97
+ "modelOverrides": {
98
+ "opencode-go/deepseek-v4.1-flash": {
99
+ "contextWindow": 1048576,
100
+ "maxTokens": 16384
101
+ }
102
+ }
103
+ }]
104
+ }
105
+ ```
106
+
51
107
  ### Refresh model catalogs
52
108
 
53
109
  ```text
@@ -86,6 +142,24 @@ The extension targets OpenAI Chat Completions-compatible services that provide a
86
142
 
87
143
  Provider implementations differ in support for developer roles, reasoning options, token fields, and streaming usage. This extension currently uses Pi's standard `openai-completions` transport.
88
144
 
145
+ ### Thinking / reasoning
146
+
147
+ During each catalog refresh, the extension recognizes OpenAI-compatible reasoning metadata from either top-level fields or `capabilities`:
148
+
149
+ - `supports_reasoning`, `supports_reasoning_effort`, or `capabilities.supports_reasoning`
150
+ - `reasoning_efforts` or `capabilities.reasoning_effort` (an array of strings or `{ "value": "..." }` objects)
151
+
152
+ Reasoning-capable models are registered with Pi's `reasoning_effort` compatibility enabled. Supported effort values are exposed as Pi thinking levels; unavailable levels are hidden. An upstream `ultra` effort is mapped to Pi's highest available level, `max`.
153
+
154
+ For example, after `/provider reload opencodex`, select a discovered reasoning model with a thinking suffix:
155
+
156
+ ```text
157
+ /provider reload opencodex
158
+ # Then select: opencodex/gpt-5.6-sol:max
159
+ ```
160
+
161
+ An endpoint must actually accept the OpenAI Chat Completions `reasoning_effort` request field. Providers that use a different thinking protocol (for example, Qwen's `enable_thinking`) are outside this extension's OpenAI-compatible transport scope.
162
+
89
163
  ## Stored configuration
90
164
 
91
165
  Provider metadata and API keys are stored separately:
@@ -102,7 +176,8 @@ The first file contains provider IDs, display names, and Base URLs. The second c
102
176
  - Provider IDs are stable identifiers. `/provider edit` changes the display name, Base URL, and API key, but does not rename the provider ID.
103
177
  - Cancelling the edit menu discards all unsaved changes.
104
178
  - Saving an edit persists the new settings first, then refreshes that provider's model catalog. A failed catalog refresh does not discard an otherwise valid saved edit.
105
- - `/provider list` reports the model count currently loaded in Pi. It can be `0` before a successful refresh.
179
+ - `/provider list` reports the model count currently loaded in Pi and the number of saved model overrides. It can be `0` before a successful refresh.
180
+ - Model overrides take precedence over model-list metadata for `contextWindow` and `maxTokens`; unset fields continue to use the API value or the extension fallback.
106
181
  - The extension starts by refreshing every managed provider with a 30-second timeout per refresh operation.
107
182
 
108
183
  ## Development