@mcowger/opencode-plexus 1.4.7 → 1.4.9

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 +34 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -360,8 +360,33 @@ function createLogger(client) {
360
360
 
361
361
  // src/mapper.ts
362
362
  var REASONING_PARAMS2 = new Set(["reasoning", "include_reasoning", "reasoning_effort"]);
363
+ var OPEN_CODE_NONE = "none";
363
364
  var DEFAULT_CONTEXT = 250000;
364
365
  var PER_TOKEN_TO_PER_MILLION = 1e6;
366
+ function normalizeReasoningEffort(value) {
367
+ return value === null || value === "off" ? OPEN_CODE_NONE : value;
368
+ }
369
+ function reasoningVariantSettings(preferredApi, effort) {
370
+ switch (preferredApi) {
371
+ case "anthropic-messages":
372
+ return { effort };
373
+ case "google-generative-ai":
374
+ return { thinkingConfig: { includeThoughts: true, thinkingLevel: effort } };
375
+ default:
376
+ return { reasoningEffort: effort };
377
+ }
378
+ }
379
+ function buildReasoningVariants(model, preferredApi, hasReasoning) {
380
+ if (!hasReasoning)
381
+ return;
382
+ const effortOption = model.reasoning_options?.find((option) => option.type === "effort");
383
+ if (!effortOption)
384
+ return;
385
+ return Object.fromEntries(effortOption.values.map((value) => {
386
+ const effort = normalizeReasoningEffort(value);
387
+ return [effort, reasoningVariantSettings(preferredApi, effort)];
388
+ }));
389
+ }
365
390
  function resolveModelProvider(model, baseURL) {
366
391
  const preferredApi = mapPreferredApi(model.preferred_api);
367
392
  const api = adjustBaseUrl(baseURL, preferredApi, "versioned");
@@ -470,6 +495,8 @@ function buildModels(models, baseURL, suppress) {
470
495
  const provider = resolveModelProvider(m, baseURL);
471
496
  const created = releaseDate(m.created);
472
497
  const interleaved = interleavedReasoning(m, preferredApi);
498
+ const hasReasoning = params.some((p) => REASONING_PARAMS2.has(p));
499
+ const variants = buildReasoningVariants(m, preferredApi, hasReasoning);
473
500
  const entry = {
474
501
  id: m.id,
475
502
  name: m.name ?? m.id,
@@ -490,12 +517,13 @@ function buildModels(models, baseURL, suppress) {
490
517
  }
491
518
  } : {},
492
519
  ...params.includes("tools") ? { tool_call: true } : {},
493
- ...params.some((p) => REASONING_PARAMS2.has(p)) ? { reasoning: true } : {},
520
+ ...hasReasoning ? { reasoning: true } : {},
494
521
  ...params.includes("temperature") ? { temperature: true } : {},
495
522
  ...hasNonTextInput ? { attachment: true } : {},
496
523
  ...pricingTiers ? { pricingTiers } : {},
497
524
  ...created ? { release_date: created } : {},
498
- ...interleaved ? { interleaved } : {}
525
+ ...interleaved ? { interleaved } : {},
526
+ ...variants ? { variants } : {}
499
527
  };
500
528
  result[m.id] = entry;
501
529
  }
@@ -565,7 +593,8 @@ function toRuntimeModels(models, provider) {
565
593
  status: "active",
566
594
  options: {},
567
595
  headers: {},
568
- release_date: model.release_date ?? ""
596
+ release_date: model.release_date ?? "",
597
+ ...model.variants ? { variants: model.variants } : {}
569
598
  };
570
599
  }
571
600
  return result;
@@ -692,8 +721,8 @@ var PlexusProviderPlugin = async (ctx) => {
692
721
  const key = authKey ?? apiKey;
693
722
  if (!baseURL) {
694
723
  log.info("Provider hook skipped live refresh; baseURL missing");
695
- const cached2 = await readCachedModels(client, suppress);
696
- return cached2 ? toRuntimeModels(cached2.models, provider) : {};
724
+ const cached = await readCachedModels(client, suppress);
725
+ return cached ? toRuntimeModels(cached.models, provider) : {};
697
726
  }
698
727
  const refreshPromise = refreshModels(client, baseURL, log, key, false, suppress);
699
728
  const race = await raceWithTimeout(refreshPromise, CONFIG_HOOK_REFRESH_BUDGET_MS);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcowger/opencode-plexus",
3
- "version": "1.4.7",
3
+ "version": "1.4.9",
4
4
  "description": "OpenCode plugin: Plexus provider with dynamic model discovery",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",