@mcowger/opencode-plexus 1.4.12 → 1.7.1
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 +63 -153
- package/dist/index.js +377 -407
- package/package.json +6 -6
- package/server.js +1 -0
package/README.md
CHANGED
|
@@ -7,13 +7,14 @@ Exposes models from a self-hosted [Plexus](https://github.com/mcowger/plexus) AI
|
|
|
7
7
|
| Package | Agent | npm |
|
|
8
8
|
|---|---|---|
|
|
9
9
|
| `plexus-pi` | [pi](https://github.com/earendil-works/pi) | `@mcowger/pi-plexus` |
|
|
10
|
-
| `plexus-opencode` | [OpenCode](https://opencode.ai) | `@mcowger/opencode-plexus` |
|
|
11
10
|
| `plexus-oh-my-pi` | [Oh My Pi](https://github.com/can1357/oh-my-pi) | `@mcowger/oh-my-pi-plexus` |
|
|
11
|
+
| `plexus-opencode-v2` | [OpenCode](https://github.com/anomalyco/opencode) V2 | `@mcowger/opencode-plexus` |
|
|
12
12
|
|
|
13
13
|
## Prerequisites
|
|
14
14
|
|
|
15
15
|
- A running Plexus instance
|
|
16
|
-
- pi 0.
|
|
16
|
+
- pi 0.85.1 or later (for `plexus-pi`)
|
|
17
|
+
- OpenCode V2 (for `plexus-opencode-v2`)
|
|
17
18
|
|
|
18
19
|
## Installation
|
|
19
20
|
|
|
@@ -54,38 +55,6 @@ Then register the path in `~/.pi/agent/settings.json`:
|
|
|
54
55
|
|
|
55
56
|
---
|
|
56
57
|
|
|
57
|
-
### OpenCode
|
|
58
|
-
|
|
59
|
-
#### Option 1 — npm (recommended)
|
|
60
|
-
|
|
61
|
-
```sh
|
|
62
|
-
npm install -g @mcowger/opencode-plexus
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
Then add the plugin to your `opencode.json`:
|
|
66
|
-
|
|
67
|
-
```json
|
|
68
|
-
{
|
|
69
|
-
"plugins": ["@mcowger/opencode-plexus"]
|
|
70
|
-
}
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
#### Option 2 — path reference
|
|
74
|
-
|
|
75
|
-
```sh
|
|
76
|
-
git clone https://github.com/mcowger/plexus-agent-plugins ~/code/plexus-agent-plugins
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
Then reference the built artifact in `opencode.json`:
|
|
80
|
-
|
|
81
|
-
```json
|
|
82
|
-
{
|
|
83
|
-
"plugins": ["~/code/plexus-agent-plugins/packages/plexus-opencode/dist/index.js"]
|
|
84
|
-
}
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
---
|
|
88
|
-
|
|
89
58
|
### Oh My Pi
|
|
90
59
|
|
|
91
60
|
Oh My Pi is a fork of pi and is **not** wire-compatible with `plexus-pi` in every respect (different runtime packages, extension manifest field, and built-in model registry — see [AGENTS.md](AGENTS.md)), so it has its own adapter package.
|
|
@@ -119,6 +88,28 @@ Then register the path in `~/.omp/agent/settings.json`:
|
|
|
119
88
|
}
|
|
120
89
|
```
|
|
121
90
|
|
|
91
|
+
### OpenCode (V2)
|
|
92
|
+
|
|
93
|
+
Add the plugin to `~/.config/opencode/opencode.jsonc`, either from npm or from a local clone (local plugins must point at the package directory, not a file):
|
|
94
|
+
|
|
95
|
+
```jsonc
|
|
96
|
+
{
|
|
97
|
+
"plugins": ["@mcowger/opencode-plexus"]
|
|
98
|
+
// or: ["file:///home/you/code/plexus-agent-plugins/packages/plexus-opencode-v2"]
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
If you use `experimental.policies` to restrict providers, policies are last-match-wins — put the `plexus` allow **after** any `"*"` deny:
|
|
103
|
+
|
|
104
|
+
```jsonc
|
|
105
|
+
"policies": [
|
|
106
|
+
{ "action": "provider.use", "resource": "*", "effect": "deny" },
|
|
107
|
+
{ "action": "provider.use", "resource": "plexus", "effect": "allow" }
|
|
108
|
+
]
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Restart the service (`opencode service stop && opencode service start`) after changing plugins.
|
|
112
|
+
|
|
122
113
|
---
|
|
123
114
|
|
|
124
115
|
## First-time setup
|
|
@@ -142,13 +133,14 @@ To force a model refresh:
|
|
|
142
133
|
/plexus refresh
|
|
143
134
|
```
|
|
144
135
|
|
|
145
|
-
|
|
136
|
+
Inspect the effective URL, authentication availability, and catalog source without exposing a credential:
|
|
146
137
|
|
|
147
138
|
```
|
|
148
|
-
/plexus
|
|
149
|
-
/plexus set-default-model claude-sonnet-4-5
|
|
139
|
+
/plexus status
|
|
150
140
|
```
|
|
151
141
|
|
|
142
|
+
Select a Plexus model in `/model`. Save its startup default with the host's normal model-picker action; Plexus does not maintain a separate default-model setting.
|
|
143
|
+
|
|
152
144
|
Use `/login plexus` for setup and `/logout plexus` to remove stored credentials.
|
|
153
145
|
|
|
154
146
|
### Oh My Pi
|
|
@@ -159,108 +151,44 @@ Run inside Oh My Pi using the native login flow:
|
|
|
159
151
|
/login plexus
|
|
160
152
|
```
|
|
161
153
|
|
|
162
|
-
Same prompts and `/plexus refresh` / `/plexus
|
|
154
|
+
Same prompts and `/plexus refresh` / `/plexus status` commands as pi (see above). Save the selected startup model through OMP's normal `/model` or `/models` flow.
|
|
163
155
|
|
|
164
|
-
### OpenCode
|
|
156
|
+
### OpenCode (V2)
|
|
165
157
|
|
|
166
|
-
Run
|
|
158
|
+
Run `/connect` and pick **Plexus**. You will be prompted for the Plexus base URL and API key; models load immediately — no restart needed. Disconnecting, reconnecting, or rotating the key also reloads the model list.
|
|
167
159
|
|
|
168
|
-
|
|
169
|
-
/connect
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
Select **Plexus** and enter your base URL and API key. OpenCode has no live model-discovery hook for custom providers, so the model list is seeded from the on-disk cache at startup. Run `/plexus-refresh` to force a live fetch from Plexus and rewrite the cache, then restart OpenCode to pick up the refreshed list:
|
|
160
|
+
To force a model refresh:
|
|
173
161
|
|
|
174
162
|
```
|
|
175
163
|
/plexus-refresh
|
|
176
164
|
```
|
|
177
165
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
```text
|
|
181
|
-
https://plexus.example.com
|
|
182
|
-
https://plexus.example.com/v1
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
The plugins normalize either form to the Plexus root URL for storage and derive `/v1` paths when calling the API.
|
|
186
|
-
|
|
187
|
-
OpenCode stores the API key in its native auth store and stores the Plexus base URL as auth metadata on that connection. Existing `provider.plexus.options.plexusBaseURL` config is still honored as a fallback.
|
|
188
|
-
|
|
189
|
-
`provider.plexus.options.baseURL` is also accepted as input-only compatibility config. Some external clients read OpenCode config files directly and only recognize `options.baseURL`. The plugin normalizes that value for Plexus discovery and then removes it from OpenCode's in-memory provider options, so individual models keep their own `/v1` or `/v1beta` endpoints instead of being overridden by a provider-wide URL.
|
|
190
|
-
|
|
191
|
-
For an OpenChamber-compatible OpenCode config, omit `options.apiKey` and authenticate through `/connect`:
|
|
192
|
-
|
|
193
|
-
```json
|
|
194
|
-
{
|
|
195
|
-
"provider": {
|
|
196
|
-
"plexus": {
|
|
197
|
-
"options": {
|
|
198
|
-
"baseURL": "https://plexus.example.com/v1"
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
Then run `/connect`, select **Plexus**, and authenticate against the same Plexus server. A raw unresolved `options.apiKey` value in this file can override the resolved runtime credential used by OpenChamber, including OpenCode `{env:NAME}` templates that OpenChamber does not expand when extra characters follow the template.
|
|
206
|
-
|
|
207
|
-
The plugin publishes models with `/v1` endpoints before `/v1beta` models. This ordering helps OpenChamber versions that derive a provider-wide endpoint from the first runtime model; it does not change model endpoints or OpenCode routing. Gemini models still use `/v1beta` through `@ai-sdk/google`.
|
|
208
|
-
|
|
209
|
-
The OpenCode plugin respects each model's `preferred_api` value and routes models through the matching SDK/API shape:
|
|
210
|
-
|
|
211
|
-
- `chat_completions` / `openai-completions` → OpenAI-compatible chat completions
|
|
212
|
-
- `responses` / `openai-responses` → OpenAI Responses API
|
|
213
|
-
- `messages` / `anthropic-messages` → Anthropic Messages API
|
|
214
|
-
- `gemini` / `google-generative-ai` → Google Gemini API
|
|
215
|
-
|
|
216
|
-
You can also pre-configure via environment variables:
|
|
217
|
-
|
|
218
|
-
```sh
|
|
219
|
-
export PLEXUS_API_URL=https://plexus.example.com
|
|
220
|
-
export PLEXUS_API_KEY=your-api-key
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
`PLEXUS_BASE_URL` is also accepted for compatibility; `PLEXUS_API_URL` wins when both are set.
|
|
224
|
-
|
|
225
|
-
---
|
|
166
|
+
`PLEXUS_API_URL` / `PLEXUS_BASE_URL` / `PLEXUS_API_KEY` env vars and plugin options (`plexusBaseURL`, `suppressModels`) are also honored. Until a URL is configured, the provider shows a single `plexus-unconfigured` placeholder. Plugin logs are written to `~/.local/share/opencode/plugins/plexus/plugin.log` (the OpenCode service discards plugin stdout).
|
|
226
167
|
|
|
227
168
|
## Configuration files
|
|
228
169
|
|
|
229
|
-
###
|
|
230
|
-
|
|
231
|
-
```
|
|
232
|
-
~/.pi/agent/extensions/plexus/
|
|
233
|
-
config.json # base URL and model preference metadata
|
|
234
|
-
plexus-models-cache.json # last-fetched model list (startup cache)
|
|
235
|
-
plexus-models-response.json # raw API response (diagnostics)
|
|
236
|
-
plexus.log # extension activity log
|
|
237
|
-
```
|
|
170
|
+
### Connection state
|
|
238
171
|
|
|
239
|
-
|
|
172
|
+
Each adapter stores only non-secret Plexus settings in its own `config.json`:
|
|
240
173
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
```
|
|
244
|
-
~/.omp/agent/extensions/plexus/
|
|
245
|
-
config.json # base URL and model preference metadata
|
|
246
|
-
plexus-models-cache.json # last-fetched model list (startup cache)
|
|
247
|
-
plexus-models-response.json # raw API response (diagnostics)
|
|
248
|
-
plexus.log # extension activity log
|
|
174
|
+
```text
|
|
175
|
+
<agent-dir>/extensions/plexus/config.json # base URL and optional model suppression
|
|
249
176
|
```
|
|
250
177
|
|
|
251
|
-
|
|
178
|
+
Credentials stay in the host credential store (`auth.json` for Pi, `agent.db` for OMP). Model catalogs stay in the host model registry/store. The extension no longer writes a second model cache, ETag file, raw API response, or default-model preference.
|
|
252
179
|
|
|
253
|
-
|
|
180
|
+
At runtime, configuration resolves as follows:
|
|
254
181
|
|
|
255
|
-
```
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
182
|
+
```text
|
|
183
|
+
base URL: PLEXUS_API_URL → PLEXUS_BASE_URL → saved Plexus base URL
|
|
184
|
+
API key: host credential store → PLEXUS_API_KEY process fallback
|
|
185
|
+
catalog: host model store → live Plexus refresh
|
|
186
|
+
startup model: host model-picker preference
|
|
259
187
|
```
|
|
260
188
|
|
|
261
|
-
|
|
189
|
+
`PLEXUS_API_URL` and `PLEXUS_BASE_URL` are process-only URL overrides; `PLEXUS_API_KEY` is a process-only credential fallback. None are persisted. `/plexus status` reports the effective URL source, whether auth is available, and catalog state without exposing credentials.
|
|
262
190
|
|
|
263
|
-
|
|
191
|
+
Plexus accepts a root URL or a `/v1` API URL. The adapter normalizes that only for the Plexus discovery request. Each model then receives its own API-specific base URL: OpenAI stays on `/v1`, Anthropic uses the root, and Google uses `/v1beta`.
|
|
264
192
|
|
|
265
193
|
---
|
|
266
194
|
|
|
@@ -290,19 +218,6 @@ All plugin packages support suppressing models by name or pattern so undesired m
|
|
|
290
218
|
}
|
|
291
219
|
```
|
|
292
220
|
|
|
293
|
-
- **OpenCode config**: Add `suppressModels` (or `suppress`) under `provider.plexus.options` in `opencode.json`:
|
|
294
|
-
```json
|
|
295
|
-
{
|
|
296
|
-
"provider": {
|
|
297
|
-
"plexus": {
|
|
298
|
-
"options": {
|
|
299
|
-
"suppressModels": ["gpt-3.5*", "claude-2*"]
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
```
|
|
305
|
-
|
|
306
221
|
---
|
|
307
222
|
|
|
308
223
|
## Package layout
|
|
@@ -319,29 +234,25 @@ packages/
|
|
|
319
234
|
src/
|
|
320
235
|
extension.ts # entry point: commands, session refresh, auth flow
|
|
321
236
|
mapper.ts # PlexusModelDescriptor → pi ProviderModelConfig
|
|
322
|
-
config.ts # base URL /
|
|
323
|
-
cache.ts # model
|
|
237
|
+
config.ts # base URL / suppression config I/O
|
|
238
|
+
cache.ts # Pi native model-store restore
|
|
324
239
|
log.ts # append-only log
|
|
325
240
|
package.json # declares pi.extensions entry point
|
|
326
241
|
plexus-oh-my-pi/ # Oh My Pi host adapter (fork of pi; own runtime packages + catalog)
|
|
327
242
|
src/
|
|
328
243
|
extension.ts # entry point: commands, session refresh, auth flow
|
|
329
244
|
mapper.ts # PlexusModelDescriptor → Oh My Pi ProviderModelConfig
|
|
330
|
-
config.ts # base URL /
|
|
331
|
-
cache.ts # model cache I/O
|
|
245
|
+
config.ts # base URL / suppression config I/O
|
|
332
246
|
log.ts # append-only log
|
|
333
247
|
package.json # declares omp.extensions entry point
|
|
334
|
-
plexus-opencode/
|
|
248
|
+
plexus-opencode-v2/ # OpenCode V2 provider plugin
|
|
335
249
|
src/
|
|
336
|
-
plugin.ts #
|
|
337
|
-
mapper.ts #
|
|
250
|
+
plugin.ts # entry point: provider/integration transforms, /plexus-refresh, credential watcher
|
|
251
|
+
mapper.ts # PlexusModelDescriptor → OpenCode Model.Info
|
|
252
|
+
config-store.ts # base URL / API key / suppression resolution
|
|
338
253
|
cache.ts # model cache I/O
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
constants.ts # provider ID, env var names, timeouts
|
|
342
|
-
url.ts # URL helpers (trimURL, apiBase, modelsUrl)
|
|
343
|
-
index.ts # barrel export
|
|
344
|
-
package.json # npm package manifest
|
|
254
|
+
log.ts # console + file log
|
|
255
|
+
server.js # root entrypoint required by OpenCode for directory plugins
|
|
345
256
|
```
|
|
346
257
|
|
|
347
258
|
`plexus-models` has zero imports from any agent framework. Each host adapter imports it via a relative path.
|
|
@@ -355,9 +266,8 @@ The `/v1/models` endpoint returns an OpenRouter-style list. These fields drive h
|
|
|
355
266
|
| `preferred_api` | String or array. First recognized value selects the host API dialect. |
|
|
356
267
|
| `supported_parameters` | `reasoning`, `include_reasoning`, or `reasoning_effort` enables reasoning support. |
|
|
357
268
|
| `architecture.input_modalities` | Enables text/image/audio/video/pdf support where the host supports it. |
|
|
358
|
-
| `architecture.output_modalities` | Non-text-only output models are filtered from OpenCode chat providers. |
|
|
359
269
|
| `pricing` | Converted into host per-million-token cost metadata. Plexus returns per-token prices. |
|
|
360
|
-
| `pricing.tiers` | Alternate rates above `input_tokens_above`; mapped to native pi
|
|
270
|
+
| `pricing.tiers` | Alternate rates above `input_tokens_above`; mapped to native pi context pricing tiers. |
|
|
361
271
|
| `top_provider` | Supplies context and output token limits when present. |
|
|
362
272
|
| `pi_provider` / `pi_model` | Lets the pi adapter reuse built-in pi compat, headers, and thinking-level metadata. |
|
|
363
273
|
| `pi_options` | pi compat overrides. These win over heuristic and built-in metadata. |
|
|
@@ -367,11 +277,7 @@ Models with a falsy `id` are skipped. Missing metadata falls back to safe defaul
|
|
|
367
277
|
## Adapter behavior
|
|
368
278
|
|
|
369
279
|
- **pi** refreshes on session start and through `/plexus refresh`, without changing the model selected for the session. It accepts either root URLs or URLs ending in `/v1` and normalizes them before calling Plexus.
|
|
370
|
-
-
|
|
371
|
-
- OpenCode models retain their upstream model ID, SDK dialect, release date, and reasoning metadata so OpenCode can generate its native GPT, Claude, Gemini, and OpenAI-compatible variants and apply its current request transforms. DeepSeek models also preserve `reasoning_content` across tool-call turns.
|
|
372
|
-
- OpenCode uses a 250K-token context window when Plexus supplies no context metadata; its output fallback remains 20% of that window.
|
|
373
|
-
- OpenCode moves `/v1beta` models after `/v1` models in published model order. Model endpoints and per-model SDK selection are unchanged.
|
|
374
|
-
- Both adapters convert Plexus's per-token base and tier rates to the per-million-token units expected by their host.
|
|
280
|
+
- The active adapters convert Plexus's per-token base and tier rates to the per-million-token units expected by their host.
|
|
375
281
|
|
|
376
282
|
## Development
|
|
377
283
|
|
|
@@ -381,6 +287,10 @@ After cloning, install dependencies to set up the pre-commit hook:
|
|
|
381
287
|
bun install
|
|
382
288
|
```
|
|
383
289
|
|
|
384
|
-
The pre-commit hook (via lefthook) rebuilds
|
|
290
|
+
The pre-commit hook (via lefthook) rebuilds the active dist artifacts automatically whenever source files change. After committing, reload/restart your agent.
|
|
291
|
+
|
|
292
|
+
## Archived adapters
|
|
293
|
+
|
|
294
|
+
`packages/deprecated/plexus-opencode` (the OpenCode V1 adapter) is preserved for reference but is archived. It is private and excluded from builds, tests, hooks, version sync, and publishing. It is superseded by `plexus-opencode-v2`.
|
|
385
295
|
|
|
386
296
|
To add support for a new host agent, see [AGENTS.md](AGENTS.md).
|