@mcowger/pi-plexus 1.0.4 → 1.1.0

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
@@ -227,8 +227,10 @@ Models with a falsy `id` are skipped. Missing metadata falls back to safe defaul
227
227
 
228
228
  ## Adapter behavior
229
229
 
230
- - **pi** refreshes on startup, extension reload, and through `/plexus refresh`. It accepts either root URLs or URLs ending in `/v1` and normalizes them before calling Plexus.
230
+ - **pi** refreshes on session start and through `/plexus refresh`. It accepts either root URLs or URLs ending in `/v1` and normalizes them before calling Plexus.
231
231
  - **OpenCode** seeds the provider from cache or a placeholder model during config loading, then performs live discovery through the `provider.models` hook. If Plexus is slow or unavailable, OpenCode uses the cache and lets the refresh continue in the background.
232
+ - 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.
233
+ - OpenCode uses a 250K-token context window when Plexus supplies no context metadata; its output fallback remains 20% of that window.
232
234
  - Both adapters convert Plexus's per-token base and tier rates to the per-million-token units expected by their host.
233
235
 
234
236
  ## Development
package/dist/extension.js CHANGED
@@ -1,7 +1,6 @@
1
1
  // @bun
2
2
  // ../plexus-models/src/convert.ts
3
3
  var REASONING_PARAMS = new Set(["reasoning", "include_reasoning", "reasoning_effort"]);
4
- var NON_CHAT_ID_PATTERN = /embedding|embed|tts|whisper|image-[0-9]|image\b.*gen|diffusion|dall-e|stable-diff|sdxl|dream/i;
5
4
  var API_DIALECT_MAP = {
6
5
  chat_completions: "openai-completions",
7
6
  "openai-completions": "openai-completions",
@@ -45,15 +44,6 @@ function mapInputModalities(model) {
45
44
  }
46
45
  return result.length > 0 ? result : ["text"];
47
46
  }
48
- function isChatModel(model) {
49
- const inputModalities = model.architecture?.input_modalities;
50
- if (inputModalities !== undefined && !inputModalities.includes("text"))
51
- return false;
52
- const outputModalities = model.architecture?.output_modalities;
53
- if (outputModalities !== undefined)
54
- return outputModalities.includes("text");
55
- return !NON_CHAT_ID_PATTERN.test(model.id);
56
- }
57
47
  function inferReasoning(model) {
58
48
  const params = model.supported_parameters;
59
49
  if (!params)
@@ -126,7 +116,7 @@ function convertToDescriptor(raw, baseUrl) {
126
116
  function convertDescriptors(models, baseUrl) {
127
117
  const result = [];
128
118
  for (const m of models) {
129
- if (!m.id || !isChatModel(m))
119
+ if (!m.id)
130
120
  continue;
131
121
  result.push(convertToDescriptor(m, baseUrl));
132
122
  }
@@ -409,12 +399,12 @@ async function writeLogLine(message, data) {
409
399
  }
410
400
 
411
401
  // src/mapper.ts
412
- import { getModel } from "@earendil-works/pi-ai/compat";
402
+ import { getBuiltinModel } from "@earendil-works/pi-ai/providers/all";
413
403
  function descriptorToPiModel(descriptor) {
414
404
  let builtinModel;
415
405
  if (descriptor.piProvider && descriptor.piModel) {
416
406
  try {
417
- builtinModel = getModel(descriptor.piProvider, descriptor.piModel);
407
+ builtinModel = getBuiltinModel(descriptor.piProvider, descriptor.piModel);
418
408
  } catch {
419
409
  builtinModel = undefined;
420
410
  }
@@ -465,19 +455,11 @@ function descriptorToPiModel(descriptor) {
465
455
  var PROVIDER_NAME = "plexus";
466
456
  var PROVIDER_API_KEY_TEMPLATE = "${PLEXUS_API_KEY}";
467
457
  var PLEXUS_CREDENTIAL_EXPIRES_AT = 253402300799000;
468
- function getPlexusModelBaseUrl(baseUrl, api) {
469
- const normalized = baseUrl.trim().replace(/\/+$/, "");
470
- const apiBase = normalized.endsWith("/v1") ? normalized : `${normalized}/v1`;
471
- return adjustBaseUrl(apiBase, api);
472
- }
473
- function shouldRefreshModels(reason) {
474
- return reason === "startup" || reason === "reload";
475
- }
476
458
  var currentModels = [];
477
459
  function plexusExtension(pi) {
478
460
  const cached = readCachedModelsSync();
479
461
  const startupBaseUrl = getBaseUrl() ?? "http://localhost/v1";
480
- const startupModels = cached?.models.filter(isChatModel).map(descriptorToPiModel) ?? [];
462
+ const startupModels = cached?.models.map(descriptorToPiModel) ?? [];
481
463
  log("startup", {
482
464
  cachedModelCount: startupModels.length,
483
465
  startupBaseUrl
@@ -491,11 +473,7 @@ function plexusExtension(pi) {
491
473
  oauth: createPlexusLoginProvider(pi)
492
474
  });
493
475
  currentModels = startupModels;
494
- pi.on("session_start", async (event, ctx) => {
495
- if (!shouldRefreshModels(event.reason)) {
496
- log("session_start: skipping refresh", { reason: event.reason });
497
- return;
498
- }
476
+ pi.on("session_start", async (_event, ctx) => {
499
477
  const apiKey = await ctx.modelRegistry.authStorage.getApiKey(PROVIDER_NAME) ?? getEnvApiKey();
500
478
  const baseUrl = getBaseUrl();
501
479
  log("session_start", { hasApiKey: !!apiKey, baseUrl });
@@ -554,7 +532,8 @@ function createPlexusLoginProvider(pi) {
554
532
  const baseUrl = credentials.plexusBaseUrl;
555
533
  if (!baseUrl)
556
534
  return models;
557
- return models.map((model) => model.provider === PROVIDER_NAME ? { ...model, baseUrl: getPlexusModelBaseUrl(baseUrl, model.api) } : model);
535
+ const apiBase = baseUrl.trim().replace(/\/+$/, "").endsWith("/v1") ? baseUrl.trim().replace(/\/+$/, "") : `${baseUrl.trim().replace(/\/+$/, "")}/v1`;
536
+ return models.map((model) => model.provider === PROVIDER_NAME ? { ...model, baseUrl: apiBase } : model);
558
537
  }
559
538
  };
560
539
  }
@@ -615,7 +594,5 @@ async function trySetDefaultModel(pi, models) {
615
594
  log("trySetDefaultModel", { defaultModelId, ok });
616
595
  }
617
596
  export {
618
- shouldRefreshModels,
619
- getPlexusModelBaseUrl,
620
597
  plexusExtension as default
621
598
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcowger/pi-plexus",
3
- "version": "1.0.4",
3
+ "version": "1.1.0",
4
4
  "description": "Plexus AI proxy plugin for the pi coding agent",
5
5
  "type": "module",
6
6
  "files": [