@telsoncc/opencode-commandcode 1.2.26 → 1.2.27

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/CHANGELOG.md CHANGED
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.2.27] - 2026-10-23
11
+
10
12
  ## [1.2.26] - 2026-10-21
11
13
 
12
14
  ## [1.2.25] - 2026-10-20
package/manifest.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "generatedAt": "2026-10-21T03:25:57.316Z",
4
- "pluginVersion": "1.2.26",
4
+ "pluginVersion": "1.2.27",
5
5
  "commandCodeVersion": "1.86.3",
6
6
  "commandCodeTarball": "https://registry.npmjs.org/command-code/-/command-code-1.86.3.tgz",
7
7
  "modelCount": 96,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telsoncc/opencode-commandcode",
3
- "version": "1.2.26",
3
+ "version": "1.2.27",
4
4
  "description": "Command Code API provider for opencode — use Claude, GPT, Gemini, DeepSeek, Qwen, Kimi, GLM, MiniMax, and Step models via Command Code",
5
5
  "keywords": [
6
6
  "ai",
package/src/catalog.ts CHANGED
@@ -19,6 +19,40 @@ export interface ModelEntry {
19
19
  modalities?: { input: string[]; output: string[] };
20
20
  /** Runtime estimate from models.dev — replaced on the next catalog sync. */
21
21
  estimated?: boolean;
22
+ /**
23
+ * Wire endpoints the gateway serves this model on, as advertised by the
24
+ * vendor `/models` payload (`supported_endpoints`). Absent on catalogs
25
+ * extracted before the field existed; `modelTransport` falls back to the
26
+ * model family in that case.
27
+ */
28
+ supportedEndpoints?: string[];
29
+ }
30
+
31
+ /** OpenAI-shaped wire (`/chat/completions`) vs Anthropic Messages (`/messages`). */
32
+ export type ModelTransport = "chat" | "messages";
33
+
34
+ /**
35
+ * Which wire shape a model is served on. A model that is Messages-only cannot
36
+ * be called through `/chat/completions` — the gateway rejects it with
37
+ * `must be called via /provider/v1/messages` — so the transport has to be
38
+ * resolved per model, not per provider.
39
+ *
40
+ * Falls back to the model family when the catalog carries no
41
+ * `supported_endpoints`: the `claude-*` family is the only Messages-only group
42
+ * the gateway serves, so the heuristic is exact for catalogs that predate the
43
+ * field. Family matching runs on the config key, so a vendor-prefixed id like
44
+ * `anthropic/claude-sonnet-5` resolves the same as a bare one.
45
+ */
46
+ export function modelTransport(
47
+ entry: Pick<ModelEntry, "id" | "supportedEndpoints">,
48
+ ): ModelTransport {
49
+ const endpoints = entry.supportedEndpoints;
50
+ if (endpoints && endpoints.length > 0) {
51
+ return endpoints.includes("/messages") && !endpoints.includes("/chat/completions")
52
+ ? "messages"
53
+ : "chat";
54
+ }
55
+ return toConfigKey(entry.id).startsWith("claude-") ? "messages" : "chat";
22
56
  }
23
57
 
24
58
  export interface CostEntry {
@@ -794,8 +828,26 @@ function isNonEmptyString(value: unknown): value is string {
794
828
  return typeof value === "string" && value.length > 0;
795
829
  }
796
830
 
831
+ /**
832
+ * One row of the vendor availability payload. `supported_endpoints` is
833
+ * optional upstream data: it is kept only when it is an array of non-empty
834
+ * strings, so a schema nudge there can never fail a whole catalog sync.
835
+ */
836
+ export interface AvailabilityModel {
837
+ id: string;
838
+ supportedEndpoints?: string[];
839
+ }
840
+
841
+ function parseSupportedEndpoints(value: unknown): string[] | undefined {
842
+ if (!Array.isArray(value)) return undefined;
843
+ const endpoints = value.filter(
844
+ (item): item is string => typeof item === "string" && item.length > 0,
845
+ );
846
+ return endpoints.length > 0 ? endpoints : undefined;
847
+ }
848
+
797
849
  /** Validate the OpenAI-style `{ object: "list", data: [{ id }] }` availability payload. */
798
- export function parseAvailabilityIds(payload: unknown): string[] {
850
+ export function parseAvailability(payload: unknown): AvailabilityModel[] {
799
851
  if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
800
852
  throw new Error("availability response must be an object");
801
853
  }
@@ -805,21 +857,49 @@ export function parseAvailabilityIds(payload: unknown): string[] {
805
857
  if (!Array.isArray(data) || data.length === 0) {
806
858
  throw new Error("availability response data must be a non-empty array");
807
859
  }
808
- const ids: string[] = [];
860
+ const models: AvailabilityModel[] = [];
809
861
  const seen = new Set<string>();
810
862
  for (const item of data) {
811
863
  if (!item || typeof item !== "object" || Array.isArray(item)) {
812
864
  throw new Error("availability response items must be objects with a non-empty string id");
813
865
  }
814
- const id = (item as Record<string, unknown>)["id"];
866
+ const row = item as Record<string, unknown>;
867
+ const id = row["id"];
815
868
  if (!isNonEmptyString(id)) {
816
869
  throw new Error("availability response items must be objects with a non-empty string id");
817
870
  }
818
871
  if (seen.has(id)) throw new Error(`duplicate availability id: ${id}`);
819
872
  seen.add(id);
820
- ids.push(id);
873
+ const supportedEndpoints = parseSupportedEndpoints(row["supported_endpoints"]);
874
+ models.push(supportedEndpoints ? { id, supportedEndpoints } : { id });
875
+ }
876
+ return models;
877
+ }
878
+
879
+ /** Validate the OpenAI-style `{ object: "list", data: [{ id }] }` availability payload. */
880
+ export function parseAvailabilityIds(payload: unknown): string[] {
881
+ return parseAvailability(payload).map((model) => model.id);
882
+ }
883
+
884
+ /**
885
+ * Copy `supported_endpoints` from the availability payload onto matching
886
+ * entries. Entries the payload omits, or lists without usable endpoints, are
887
+ * left untouched — a partial payload never strips transport data already on
888
+ * the catalog. Returns how many entries were updated.
889
+ */
890
+ export function applyAvailabilityEndpoints<T extends { id: string; supportedEndpoints?: string[] }>(
891
+ entries: T[],
892
+ availability: readonly AvailabilityModel[],
893
+ ): number {
894
+ const byId = new Map(availability.map((model) => [model.id, model.supportedEndpoints]));
895
+ let updated = 0;
896
+ for (const entry of entries) {
897
+ const endpoints = byId.get(entry.id);
898
+ if (!endpoints) continue;
899
+ entry.supportedEndpoints = endpoints;
900
+ updated++;
821
901
  }
822
- return ids;
902
+ return updated;
823
903
  }
824
904
 
825
905
  /** Retain only candidates whose exact ID is callable; collect sorted excluded IDs. */
package/src/opencode2.ts CHANGED
@@ -5,6 +5,7 @@ import { fileURLToPath } from "url";
5
5
  import {
6
6
  MODELS_API_URL,
7
7
  filterCatalogByAvailability,
8
+ modelTransport,
8
9
  parseAvailabilityIds,
9
10
  toConfigKey,
10
11
  loadCatalogFromLocalCommandCode,
@@ -33,6 +34,12 @@ export const COMMANDCODE_INTEGRATION_ID = "commandcode";
33
34
  export const COMMANDCODE_PROVIDER_NAME = "Command Code";
34
35
  export const COMMANDCODE_BASE_URL = "https://api.commandcode.ai/provider/v1";
35
36
  export const COMMANDCODE_PACKAGE = "@opencode/ai/providers/openai-compatible";
37
+ /**
38
+ * Anthropic Messages runtime. Models the gateway serves only on `/messages`
39
+ * cannot go through the OpenAI-compatible runtime, so they carry this package
40
+ * on the model entry and it overrides the provider-wide default.
41
+ */
42
+ export const COMMANDCODE_ANTHROPIC_PACKAGE = "@opencode/ai/providers/anthropic-compatible";
36
43
  export const COMMANDCODE_ENV_NAMES = ["COMMANDCODE_API_KEY"];
37
44
 
38
45
  const MODULE_DIR = dirname(fileURLToPath(import.meta.url));
@@ -57,6 +64,12 @@ export type V2ModelInfo = {
57
64
  /** Wire id sent to the provider. Lets one upstream model back one entry. */
58
65
  modelID: string;
59
66
  providerID: string;
67
+ /**
68
+ * Provider runtime for this model. Overrides the provider-wide `package`
69
+ * — Anthropic Messages models are rejected by the OpenAI-compatible
70
+ * runtime, so they carry `@opencode/ai/providers/anthropic-compatible`.
71
+ */
72
+ package?: string;
60
73
  name: string;
61
74
  capabilities: { tools: boolean; input: string[]; output: string[] };
62
75
  limit: { context: number; output: number };
@@ -136,6 +149,16 @@ function loadPluginFileConfig(): PluginFileConfig {
136
149
  }
137
150
  }
138
151
 
152
+ /**
153
+ * Provider runtime for one model: Anthropic Messages models need the
154
+ * anthropic-compatible runtime, everything else the OpenAI-compatible one.
155
+ * The provider-wide `package` stays the OpenAI default and is only a fallback
156
+ * for entries that carry no `package` of their own.
157
+ */
158
+ export function modelPackage(entry: ModelEntry): string {
159
+ return modelTransport(entry) === "messages" ? COMMANDCODE_ANTHROPIC_PACKAGE : COMMANDCODE_PACKAGE;
160
+ }
161
+
139
162
  export function modelEntryToV2(entry: ModelEntry): V2ModelInfo {
140
163
  const rawInput = entry.modalities?.input?.filter(
141
164
  (m): m is string => typeof m === "string" && m.length > 0,
@@ -149,6 +172,7 @@ export function modelEntryToV2(entry: ModelEntry): V2ModelInfo {
149
172
  id: toConfigKey(entry.id),
150
173
  modelID: entry.id,
151
174
  providerID: COMMANDCODE_PROVIDER_ID,
175
+ package: modelPackage(entry),
152
176
  name: entry.name,
153
177
  capabilities: { tools: entry.tool_call, input, output: ["text"] },
154
178
  limit: { context: entry.limit.context, output: entry.limit.output },