@mcowger/opencode-plexus 1.1.0 → 1.1.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.
Files changed (2) hide show
  1. package/dist/index.js +17 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -16,6 +16,7 @@ var PLACEHOLDER_MODEL_ID = "plexus-unconfigured";
16
16
 
17
17
  // ../plexus-models/src/convert.ts
18
18
  var REASONING_PARAMS = new Set(["reasoning", "include_reasoning", "reasoning_effort"]);
19
+ var NON_CHAT_PATTERN = /(?:^|[\W_])(?:embed(?:ding|dings)?|transcri(?:be[ds]?|ptions?)|whisper|speech[\W_]*to[\W_]*text|stt|text[\W_]*to[\W_]*speech|tts|image[\W_]*(?:gen(?:eration)?|\d+)|diffusion|dall[\W_]*e|stable[\W_]*diffusion|sdxl|dream)(?:$|[\W_])/i;
19
20
  var API_DIALECT_MAP = {
20
21
  chat_completions: "openai-completions",
21
22
  "openai-completions": "openai-completions",
@@ -48,6 +49,21 @@ function adjustBaseUrl(baseUrl, preferredApi) {
48
49
  return stripped;
49
50
  }
50
51
  }
52
+ function isChatModel(model) {
53
+ if (!model.id)
54
+ return false;
55
+ const outputModalities = model.architecture?.output_modalities;
56
+ if (outputModalities !== undefined && !outputModalities.includes("text"))
57
+ return false;
58
+ const modality = model.architecture?.modality;
59
+ if (modality?.includes("->")) {
60
+ const output = modality.split("->").at(-1) ?? "";
61
+ if (!output.toLowerCase().includes("text"))
62
+ return false;
63
+ }
64
+ const apiHints = Array.isArray(model.preferred_api) ? model.preferred_api.join(" ") : model.preferred_api ?? "";
65
+ return !NON_CHAT_PATTERN.test(`${model.id} ${model.name ?? ""} ${apiHints}`);
66
+ }
51
67
  var DEFAULT_MODELS_FETCH_TIMEOUT_MS = 1e4;
52
68
  async function fetchPlexusModels(apiKey, modelsUrl, timeoutMs = DEFAULT_MODELS_FETCH_TIMEOUT_MS) {
53
69
  const controller = new AbortController;
@@ -296,7 +312,6 @@ function buildInputModalities(model) {
296
312
  const mapped = raw.map(mapModality).filter((m) => m !== null);
297
313
  return mapped.length > 0 ? [...new Set(mapped)] : ["text"];
298
314
  }
299
- var NON_CHAT_ID_PATTERN = /embedding|embed|tts|whisper|image-[0-9]|image\b.*gen|diffusion|dall-e|stable-diff|sdxl|dream/i;
300
315
  function buildOutputModalities(model) {
301
316
  const raw = model.architecture?.output_modalities;
302
317
  if (raw !== undefined) {
@@ -305,14 +320,12 @@ function buildOutputModalities(model) {
305
320
  const mapped = raw.map(mapModality).filter((m) => m !== null);
306
321
  return mapped.length > 0 ? [...new Set(mapped)] : ["text"];
307
322
  }
308
- if (NON_CHAT_ID_PATTERN.test(model.id))
309
- return null;
310
323
  return ["text"];
311
324
  }
312
325
  function buildModels(models, baseURL) {
313
326
  const result = {};
314
327
  for (const m of models) {
315
- if (!m.id)
328
+ if (!isChatModel(m))
316
329
  continue;
317
330
  const outputModalities = buildOutputModalities(m);
318
331
  if (outputModalities === null)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcowger/opencode-plexus",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "OpenCode plugin: Plexus provider with dynamic model discovery",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",