@brainervirus/opencode-commandcode 0.7.80 → 0.8.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/CHANGELOG.md +4 -0
- package/_version.txt +1 -1
- package/index.ts +4 -0
- package/manifest.json +7 -7
- package/models.json +31 -0
- package/package.json +11 -7
- package/plugin.ts +139 -80
- package/src/entry.ts +3 -0
- package/src/paths.ts +43 -0
- package/src/v2models.ts +66 -0
package/CHANGELOG.md
CHANGED
package/_version.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.
|
|
1
|
+
1.66.0
|
package/index.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { resolveApiKey } from "./src/auth.js";
|
|
2
2
|
import { CommandCodeLanguageModel } from "./src/model.js";
|
|
3
3
|
|
|
4
|
+
// Re-export the plugin definition so a directory plugin entry (<dir>/index.ts)
|
|
5
|
+
// loads the dual V1+V2 plugin. No cycle: plugin.ts only imports from src/.
|
|
6
|
+
export { default, server } from "./plugin.js";
|
|
7
|
+
|
|
4
8
|
export interface CommandCodeProviderOptions {
|
|
5
9
|
name?: string;
|
|
6
10
|
apiKey?: string;
|
package/manifest.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"generatedAt": "2026-09-
|
|
4
|
-
"pluginVersion": "0.
|
|
5
|
-
"commandCodeVersion": "1.
|
|
6
|
-
"commandCodeTarball": "https://registry.npmjs.org/command-code/-/command-code-1.
|
|
7
|
-
"modelCount":
|
|
8
|
-
"reasoningModelCount":
|
|
3
|
+
"generatedAt": "2026-09-26T06:01:17.803Z",
|
|
4
|
+
"pluginVersion": "0.8.0",
|
|
5
|
+
"commandCodeVersion": "1.66.0",
|
|
6
|
+
"commandCodeTarball": "https://registry.npmjs.org/command-code/-/command-code-1.66.0.tgz",
|
|
7
|
+
"modelCount": 82,
|
|
8
|
+
"reasoningModelCount": 69,
|
|
9
9
|
"extraction": {
|
|
10
10
|
"modelCatalog": "ok",
|
|
11
11
|
"costCatalog": "cli",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"costSources": {
|
|
15
15
|
"cli": 27,
|
|
16
|
-
"officialDocs":
|
|
16
|
+
"officialDocs": 55,
|
|
17
17
|
"thirdParty": 0,
|
|
18
18
|
"free": 0,
|
|
19
19
|
"fallback": 0,
|
package/models.json
CHANGED
|
@@ -2007,6 +2007,37 @@
|
|
|
2007
2007
|
]
|
|
2008
2008
|
}
|
|
2009
2009
|
},
|
|
2010
|
+
{
|
|
2011
|
+
"id": "stealth/pixel-canary",
|
|
2012
|
+
"name": "Pixel Canary",
|
|
2013
|
+
"tier": "open-source",
|
|
2014
|
+
"reasoning": true,
|
|
2015
|
+
"reasoningEfforts": [
|
|
2016
|
+
"low",
|
|
2017
|
+
"medium",
|
|
2018
|
+
"xhigh"
|
|
2019
|
+
],
|
|
2020
|
+
"tool_call": true,
|
|
2021
|
+
"cost": {
|
|
2022
|
+
"input": 0,
|
|
2023
|
+
"output": 0,
|
|
2024
|
+
"cache_read": 0
|
|
2025
|
+
},
|
|
2026
|
+
"limit": {
|
|
2027
|
+
"context": 262144,
|
|
2028
|
+
"output": 131072
|
|
2029
|
+
},
|
|
2030
|
+
"attachment": true,
|
|
2031
|
+
"modalities": {
|
|
2032
|
+
"input": [
|
|
2033
|
+
"text",
|
|
2034
|
+
"image"
|
|
2035
|
+
],
|
|
2036
|
+
"output": [
|
|
2037
|
+
"text"
|
|
2038
|
+
]
|
|
2039
|
+
}
|
|
2040
|
+
},
|
|
2010
2041
|
{
|
|
2011
2042
|
"id": "Qwen/Qwen3.6-Max-Preview",
|
|
2012
2043
|
"name": "Qwen 3.6 Max Preview",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brainervirus/opencode-commandcode",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
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",
|
|
@@ -29,30 +29,34 @@
|
|
|
29
29
|
"url": "git+https://github.com/BrainerVirus/opencode-commandcode.git"
|
|
30
30
|
},
|
|
31
31
|
"files": [
|
|
32
|
-
"
|
|
33
|
-
"plugin.ts",
|
|
32
|
+
"dist/",
|
|
34
33
|
"models.json",
|
|
35
34
|
"manifest.json",
|
|
36
35
|
"_version.txt",
|
|
37
36
|
"README.md",
|
|
38
37
|
"CHANGELOG.md",
|
|
38
|
+
"index.ts",
|
|
39
|
+
"plugin.ts",
|
|
39
40
|
"src/"
|
|
40
41
|
],
|
|
41
42
|
"type": "module",
|
|
42
|
-
"main": "
|
|
43
|
-
"types": "index.ts",
|
|
43
|
+
"main": "./dist/plugin.js",
|
|
44
|
+
"types": "./dist/index.d.ts",
|
|
44
45
|
"exports": {
|
|
45
46
|
".": {
|
|
46
|
-
"
|
|
47
|
+
"types": "./dist/index.d.ts",
|
|
48
|
+
"import": "./dist/plugin.js"
|
|
47
49
|
},
|
|
48
50
|
"./server": {
|
|
49
|
-
"
|
|
51
|
+
"types": "./dist/plugin.d.ts",
|
|
52
|
+
"import": "./dist/plugin.js"
|
|
50
53
|
}
|
|
51
54
|
},
|
|
52
55
|
"publishConfig": {
|
|
53
56
|
"access": "public"
|
|
54
57
|
},
|
|
55
58
|
"scripts": {
|
|
59
|
+
"build": "bun scripts/build-plugin.ts && bunx tsc -p tsconfig.json --emitDeclarationOnly",
|
|
56
60
|
"lint": "oxlint --deny-warnings src scripts plugin.ts index.ts tests",
|
|
57
61
|
"lint:fix": "oxlint --fix src scripts plugin.ts index.ts tests",
|
|
58
62
|
"format": "oxfmt src scripts plugin.ts index.ts tests package.json tsconfig.json release.config.cjs",
|
package/plugin.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { readFileSync, existsSync } from "fs";
|
|
2
2
|
import { homedir } from "os";
|
|
3
|
-
import { join
|
|
4
|
-
import { fileURLToPath } from "url";
|
|
3
|
+
import { join } from "path";
|
|
5
4
|
import {
|
|
6
5
|
generateOpencodeModels,
|
|
7
6
|
loadCatalogFromLocalCommandCode,
|
|
@@ -14,11 +13,10 @@ import {
|
|
|
14
13
|
pluginStateDir,
|
|
15
14
|
} from "./src/startup.js";
|
|
16
15
|
import type { CatalogManifest } from "./src/manifest.js";
|
|
16
|
+
import { generateV2Models } from "./src/v2models.js";
|
|
17
|
+
import { catalogPaths } from "./src/paths.js";
|
|
17
18
|
|
|
18
|
-
const
|
|
19
|
-
const MODELS_PATH = join(__dirname, "models.json");
|
|
20
|
-
const VERSION_PATH = join(__dirname, "_version.txt");
|
|
21
|
-
const MANIFEST_PATH = join(__dirname, "manifest.json");
|
|
19
|
+
const { models: MODELS_PATH, manifest: MANIFEST_PATH, version: VERSION_PATH } = catalogPaths();
|
|
22
20
|
|
|
23
21
|
interface PluginFileConfig {
|
|
24
22
|
disableModelSync?: boolean;
|
|
@@ -72,7 +70,94 @@ function readBundledVersion(): string | null {
|
|
|
72
70
|
}
|
|
73
71
|
}
|
|
74
72
|
|
|
75
|
-
|
|
73
|
+
type CatalogLoad = {
|
|
74
|
+
models: ModelEntry[];
|
|
75
|
+
catalogSource: "bundled" | "cache" | "opt-in-local";
|
|
76
|
+
commandCodeVersion: string | null;
|
|
77
|
+
degraded: boolean;
|
|
78
|
+
degradedReason: string | null;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
function loadCatalogEntries(): CatalogLoad {
|
|
82
|
+
const pluginCfg = loadPluginConfig();
|
|
83
|
+
const override =
|
|
84
|
+
pluginCfg.commandCodePackagePath?.trim() || process.env.COMMANDCODE_PACKAGE_PATH?.trim() || "";
|
|
85
|
+
|
|
86
|
+
let models: ModelEntry[] = [];
|
|
87
|
+
let catalogSource: CatalogLoad["catalogSource"] = "bundled";
|
|
88
|
+
let commandCodeVersion: string | null = null;
|
|
89
|
+
let degraded = false;
|
|
90
|
+
let degradedReason: string | null = null;
|
|
91
|
+
|
|
92
|
+
if (override) {
|
|
93
|
+
const localCatalog = loadCatalogFromLocalCommandCode({ packagePath: override });
|
|
94
|
+
if (localCatalog && localCatalog.models.length > 0) {
|
|
95
|
+
models = localCatalog.models;
|
|
96
|
+
catalogSource = "opt-in-local";
|
|
97
|
+
commandCodeVersion = localCatalog.version;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (models.length === 0) {
|
|
102
|
+
const bundled = loadBundledModels();
|
|
103
|
+
if (bundled) {
|
|
104
|
+
models = bundled;
|
|
105
|
+
catalogSource = "bundled";
|
|
106
|
+
commandCodeVersion = readBundledVersion();
|
|
107
|
+
const manifest = readBundledManifest();
|
|
108
|
+
if (manifest?.status === "degraded" || manifest?.status === "broken") {
|
|
109
|
+
degraded = true;
|
|
110
|
+
degradedReason =
|
|
111
|
+
manifest.status === "broken"
|
|
112
|
+
? "bundled catalog marked broken"
|
|
113
|
+
: "bundled catalog has models with no listed price";
|
|
114
|
+
}
|
|
115
|
+
} else {
|
|
116
|
+
const cached = readCatalogCache();
|
|
117
|
+
if (cached) {
|
|
118
|
+
models = cached;
|
|
119
|
+
catalogSource = "cache";
|
|
120
|
+
degraded = true;
|
|
121
|
+
degradedReason = "bundled models.json unreadable; using last-good cache";
|
|
122
|
+
} else {
|
|
123
|
+
degraded = true;
|
|
124
|
+
degradedReason = "no bundled catalog and no cache";
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return { models, catalogSource, commandCodeVersion, degraded, degradedReason };
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function persistCatalogSideEffects(load: CatalogLoad, debug: boolean): void {
|
|
133
|
+
if (load.models.length > 0) {
|
|
134
|
+
try {
|
|
135
|
+
writeCatalogCache(pluginStateDir(), load.models);
|
|
136
|
+
} catch {
|
|
137
|
+
// ignore cache write
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const summary = {
|
|
142
|
+
catalogSource: load.catalogSource,
|
|
143
|
+
commandCodeVersion: load.commandCodeVersion,
|
|
144
|
+
modelCount: load.models.length,
|
|
145
|
+
reasoningModelCount: load.models.filter((m) => m.reasoning).length,
|
|
146
|
+
degraded: load.degraded,
|
|
147
|
+
degradedReason: load.degradedReason,
|
|
148
|
+
};
|
|
149
|
+
try {
|
|
150
|
+
writeStartupSummary(pluginStateDir(), summary);
|
|
151
|
+
} catch {
|
|
152
|
+
// ignore
|
|
153
|
+
}
|
|
154
|
+
if (debug) {
|
|
155
|
+
console.warn("[commandcode]", JSON.stringify(summary));
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** V1 entrypoint (OpenCode 1.18.29+ also accepts it via `server`). */
|
|
160
|
+
export async function server() {
|
|
76
161
|
return {
|
|
77
162
|
config: async (config: Record<string, unknown>) => {
|
|
78
163
|
if (!(config as Record<string, unknown>).provider) {
|
|
@@ -85,10 +170,6 @@ export default async function commandcodePlugin() {
|
|
|
85
170
|
|
|
86
171
|
const pluginCfg = loadPluginConfig();
|
|
87
172
|
const debug = pluginCfg.debugStartupLogs === true;
|
|
88
|
-
const override =
|
|
89
|
-
pluginCfg.commandCodePackagePath?.trim() ||
|
|
90
|
-
process.env.COMMANDCODE_PACKAGE_PATH?.trim() ||
|
|
91
|
-
"";
|
|
92
173
|
|
|
93
174
|
if (!cc.npm) cc.npm = "commandcode-go-opencode-provider";
|
|
94
175
|
if (!cc.name) cc.name = "Command Code";
|
|
@@ -96,75 +177,9 @@ export default async function commandcodePlugin() {
|
|
|
96
177
|
|
|
97
178
|
if (cc.models) return;
|
|
98
179
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
let degraded = false;
|
|
103
|
-
let degradedReason: string | null = null;
|
|
104
|
-
|
|
105
|
-
if (override) {
|
|
106
|
-
const localCatalog = loadCatalogFromLocalCommandCode({ packagePath: override });
|
|
107
|
-
if (localCatalog && localCatalog.models.length > 0) {
|
|
108
|
-
models = localCatalog.models;
|
|
109
|
-
catalogSource = "opt-in-local";
|
|
110
|
-
commandCodeVersion = localCatalog.version;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (models.length === 0) {
|
|
115
|
-
const bundled = loadBundledModels();
|
|
116
|
-
if (bundled) {
|
|
117
|
-
models = bundled;
|
|
118
|
-
catalogSource = "bundled";
|
|
119
|
-
commandCodeVersion = readBundledVersion();
|
|
120
|
-
const manifest = readBundledManifest();
|
|
121
|
-
if (manifest?.status === "degraded" || manifest?.status === "broken") {
|
|
122
|
-
degraded = true;
|
|
123
|
-
degradedReason =
|
|
124
|
-
manifest.status === "broken"
|
|
125
|
-
? "bundled catalog marked broken"
|
|
126
|
-
: "bundled catalog has models with no listed price";
|
|
127
|
-
}
|
|
128
|
-
} else {
|
|
129
|
-
const cached = readCatalogCache();
|
|
130
|
-
if (cached) {
|
|
131
|
-
models = cached;
|
|
132
|
-
catalogSource = "cache";
|
|
133
|
-
degraded = true;
|
|
134
|
-
degradedReason = "bundled models.json unreadable; using last-good cache";
|
|
135
|
-
} else {
|
|
136
|
-
degraded = true;
|
|
137
|
-
degradedReason = "no bundled catalog and no cache";
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if (models.length > 0) {
|
|
143
|
-
try {
|
|
144
|
-
writeCatalogCache(pluginStateDir(), models);
|
|
145
|
-
} catch {
|
|
146
|
-
// ignore cache write
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
cc.models = generateOpencodeModels(models);
|
|
151
|
-
|
|
152
|
-
const summary = {
|
|
153
|
-
catalogSource,
|
|
154
|
-
commandCodeVersion,
|
|
155
|
-
modelCount: models.length,
|
|
156
|
-
reasoningModelCount: models.filter((m) => m.reasoning).length,
|
|
157
|
-
degraded,
|
|
158
|
-
degradedReason,
|
|
159
|
-
};
|
|
160
|
-
try {
|
|
161
|
-
writeStartupSummary(pluginStateDir(), summary);
|
|
162
|
-
} catch {
|
|
163
|
-
// ignore
|
|
164
|
-
}
|
|
165
|
-
if (debug) {
|
|
166
|
-
console.warn("[commandcode]", JSON.stringify(summary));
|
|
167
|
-
}
|
|
180
|
+
const load = loadCatalogEntries();
|
|
181
|
+
persistCatalogSideEffects(load, debug);
|
|
182
|
+
cc.models = generateOpencodeModels(load.models);
|
|
168
183
|
},
|
|
169
184
|
|
|
170
185
|
auth: {
|
|
@@ -195,3 +210,47 @@ export default async function commandcodePlugin() {
|
|
|
195
210
|
},
|
|
196
211
|
};
|
|
197
212
|
}
|
|
213
|
+
|
|
214
|
+
/** V2 setup: provider inventory + models through transforms. Auth stays V1-only for now. */
|
|
215
|
+
async function setup(ctx: any): Promise<void> {
|
|
216
|
+
const pluginCfg = loadPluginConfig();
|
|
217
|
+
const debug = pluginCfg.debugStartupLogs === true;
|
|
218
|
+
const load = loadCatalogEntries();
|
|
219
|
+
persistCatalogSideEffects(load, debug);
|
|
220
|
+
const v2models = generateV2Models(load.models);
|
|
221
|
+
|
|
222
|
+
await ctx.provider.transform((editor: any) => {
|
|
223
|
+
const existing = editor.get("commandcode");
|
|
224
|
+
if (!existing) {
|
|
225
|
+
editor.add({
|
|
226
|
+
info: {
|
|
227
|
+
id: "commandcode",
|
|
228
|
+
name: "Command Code",
|
|
229
|
+
activation: "enabled",
|
|
230
|
+
package: "aisdk:@ai-sdk/openai-compatible",
|
|
231
|
+
settings: {
|
|
232
|
+
baseURL: "https://api.commandcode.ai/provider/v1",
|
|
233
|
+
apiKey: "{env:COMMANDCODE_API_KEY}",
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
models: v2models,
|
|
237
|
+
});
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
editor.update("commandcode", (provider: any) => {
|
|
241
|
+
provider.name = provider.name ?? "Command Code";
|
|
242
|
+
provider.settings = provider.settings ?? {};
|
|
243
|
+
if (typeof provider.settings === "object") {
|
|
244
|
+
if (!provider.settings.baseURL)
|
|
245
|
+
provider.settings.baseURL = "https://api.commandcode.ai/provider/v1";
|
|
246
|
+
if (!provider.settings.apiKey) provider.settings.apiKey = "{env:COMMANDCODE_API_KEY}";
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
editor.models.set("commandcode", v2models);
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const definition = { id: "commandcode", setup };
|
|
254
|
+
|
|
255
|
+
// Dual entry: V2 reads default.id/setup, V1 (>=1.18.29) calls default.server().
|
|
256
|
+
export default { ...definition, server };
|
package/src/entry.ts
ADDED
package/src/paths.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { existsSync, realpathSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
|
|
5
|
+
/** Directory of this module, canonicalized so symlinked checkouts, tmpdir
|
|
6
|
+
* aliasing (`/var` vs `/private/var`), and Windows 8.3 short names cannot
|
|
7
|
+
* split the reported locations from the caller's spelling. */
|
|
8
|
+
const moduleDir = (): string => {
|
|
9
|
+
try {
|
|
10
|
+
return realpathSync(path.dirname(fileURLToPath(import.meta.url)));
|
|
11
|
+
} catch {
|
|
12
|
+
return path.dirname(fileURLToPath(import.meta.url));
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Resolve the provider package root from any layout, workit-style: source
|
|
18
|
+
* modules live in `src/`, the plugin entry at the package root (`plugin.ts`),
|
|
19
|
+
* and a future bundle in `dist/`. The nearest ancestor with a `package.json`
|
|
20
|
+
* wins, so moving a source file or bundling the entry can never silently
|
|
21
|
+
* point catalog reads at the wrong directory.
|
|
22
|
+
*/
|
|
23
|
+
export const packageRoot = (): string => {
|
|
24
|
+
const dir = moduleDir();
|
|
25
|
+
for (const candidate of [
|
|
26
|
+
path.resolve(dir, ".."),
|
|
27
|
+
path.resolve(dir, "..", ".."),
|
|
28
|
+
path.resolve(dir, "..", "..", ".."),
|
|
29
|
+
]) {
|
|
30
|
+
if (existsSync(path.join(candidate, "package.json"))) return candidate;
|
|
31
|
+
}
|
|
32
|
+
return path.resolve(dir, "..");
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/** Catalog artifact locations under the resolved package root. */
|
|
36
|
+
export const catalogPaths = (): { models: string; manifest: string; version: string } => {
|
|
37
|
+
const root = packageRoot();
|
|
38
|
+
return {
|
|
39
|
+
models: path.join(root, "models.json"),
|
|
40
|
+
manifest: path.join(root, "manifest.json"),
|
|
41
|
+
version: path.join(root, "_version.txt"),
|
|
42
|
+
};
|
|
43
|
+
};
|
package/src/v2models.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { toConfigKey, type ModelEntry } from "./catalog.js";
|
|
2
|
+
|
|
3
|
+
/** Minimal V2 model shape (structural subset of Model.Info). */
|
|
4
|
+
export interface V2Model {
|
|
5
|
+
id: string;
|
|
6
|
+
modelID: string;
|
|
7
|
+
providerID: string;
|
|
8
|
+
name: string;
|
|
9
|
+
capabilities: { tools: boolean; input: string[]; output: string[] };
|
|
10
|
+
cost: Array<{ input: number; output: number; cache: { read: number; write: number } }>;
|
|
11
|
+
limit: { context: number; output: number };
|
|
12
|
+
variants: Array<{ id: string; settings: Record<string, unknown> }>;
|
|
13
|
+
status: "active";
|
|
14
|
+
enabled: boolean;
|
|
15
|
+
time: { released: number };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function v2Input(entry: ModelEntry): string[] {
|
|
19
|
+
if (entry.modalities?.input && entry.modalities.input.length > 0)
|
|
20
|
+
return [...entry.modalities.input];
|
|
21
|
+
if (entry.attachment === true) return ["text", "image"];
|
|
22
|
+
return ["text"];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function v2Output(entry: ModelEntry): string[] {
|
|
26
|
+
if (entry.modalities?.output && entry.modalities.output.length > 0)
|
|
27
|
+
return [...entry.modalities.output];
|
|
28
|
+
return ["text"];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function toV2Model(entry: ModelEntry): V2Model {
|
|
32
|
+
const id = toConfigKey(entry.id);
|
|
33
|
+
return {
|
|
34
|
+
id,
|
|
35
|
+
modelID: id,
|
|
36
|
+
providerID: "commandcode",
|
|
37
|
+
name: entry.name,
|
|
38
|
+
capabilities: {
|
|
39
|
+
tools: entry.tool_call,
|
|
40
|
+
input: v2Input(entry),
|
|
41
|
+
output: v2Output(entry),
|
|
42
|
+
},
|
|
43
|
+
cost: [
|
|
44
|
+
{
|
|
45
|
+
input: entry.cost.input,
|
|
46
|
+
output: entry.cost.output,
|
|
47
|
+
cache: {
|
|
48
|
+
read: entry.cost.cache_read ?? 0,
|
|
49
|
+
write: entry.cost.cache_write ?? 0,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
limit: { context: entry.limit.context, output: entry.limit.output },
|
|
54
|
+
variants: (entry.reasoningEfforts ?? []).map((effort) => ({
|
|
55
|
+
id: effort,
|
|
56
|
+
settings: { reasoningEffort: effort },
|
|
57
|
+
})),
|
|
58
|
+
status: "active",
|
|
59
|
+
enabled: true,
|
|
60
|
+
time: { released: 0 },
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function generateV2Models(entries: ModelEntry[]): V2Model[] {
|
|
65
|
+
return entries.map(toV2Model);
|
|
66
|
+
}
|