@4yi/cli 0.1.10 → 0.1.11
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/package.json +1 -1
- package/src/connect.mjs +10 -0
- package/src/opencode.mjs +14 -4
package/package.json
CHANGED
package/src/connect.mjs
CHANGED
|
@@ -311,6 +311,16 @@ function buildCodexCatalog(models, template) {
|
|
|
311
311
|
description: `${planModel.display_name || planModel.id} via 4YI Gateway with OpenAI Responses tool support.`,
|
|
312
312
|
supported_in_api: true,
|
|
313
313
|
use_responses_lite: false,
|
|
314
|
+
// The template is whatever `codex debug models --bundled` returns on this
|
|
315
|
+
// machine, and that is not a stable schema: 0.147 carries this field,
|
|
316
|
+
// 0.150 omits it, and connect installs the latest codex -- so it upgrades
|
|
317
|
+
// its own template source into the version that drops it. Codex.app
|
|
318
|
+
// requires it and will not start without one, so it is set here rather
|
|
319
|
+
// than inherited. The endpoint is authoritative when it answers; `true`
|
|
320
|
+
// is the fallback because every model this catalog can describe is served
|
|
321
|
+
// through the Responses ingress, which requires `parallel_tool_calls` on
|
|
322
|
+
// each request.
|
|
323
|
+
supports_parallel_tool_calls: planModel.supports_parallel_tool_calls ?? true,
|
|
314
324
|
tool_mode: undefined,
|
|
315
325
|
})).map((model) => {
|
|
316
326
|
delete model.tool_mode;
|
package/src/opencode.mjs
CHANGED
|
@@ -10,6 +10,7 @@ const DEFAULT_CONTEXT_LIMIT = 200000;
|
|
|
10
10
|
const DEFAULT_OUTPUT_LIMIT = 8192;
|
|
11
11
|
|
|
12
12
|
function isClaudeModel(model) {
|
|
13
|
+
if (model?.family === "claude") return true;
|
|
13
14
|
const id = model?.id || "";
|
|
14
15
|
const name = model?.display_name || "";
|
|
15
16
|
return /claude/i.test(id) || /claude/i.test(name);
|
|
@@ -23,14 +24,23 @@ function modelOutputLimit(model) {
|
|
|
23
24
|
return model.output_limit || model.max_output_tokens || model.max_tokens || DEFAULT_OUTPUT_LIMIT;
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
function modelPickerName(model) {
|
|
28
|
+
const displayName = model.display_name || model.id;
|
|
29
|
+
if (model.family === "claude") {
|
|
30
|
+
return `Claude · ${displayName.replace(/^(?:anthropic[ ._-]*)?claude[ ._-]*/i, "")}`;
|
|
31
|
+
}
|
|
32
|
+
if (model.family === "codex") return `Codex · ${displayName}`;
|
|
33
|
+
return displayName;
|
|
34
|
+
}
|
|
35
|
+
|
|
26
36
|
export function buildOpenCodeConfig({ modelConfig, preferredModel = null, tokenEnv = "FOURYI_CLI_TOKEN", orgEnv = "FOURYI_ORG_ID" }) {
|
|
27
|
-
// Register
|
|
28
|
-
// (`Tab` / `/models`) can move between
|
|
37
|
+
// Register every server-approved coding model so OpenCode's native switcher
|
|
38
|
+
// (`Tab` / `/models`) can move between Claude and Codex. Claude stays the default.
|
|
29
39
|
const list = modelConfig.models || [];
|
|
30
40
|
const models = {};
|
|
31
41
|
for (const model of list) {
|
|
32
42
|
const entry = {
|
|
33
|
-
name: model
|
|
43
|
+
name: modelPickerName(model),
|
|
34
44
|
limit: {
|
|
35
45
|
context: modelContextLimit(model),
|
|
36
46
|
output: modelOutputLimit(model),
|
|
@@ -111,7 +121,7 @@ export function ensureOpenCodeRuntime({ home = os.homedir(), stdout = console.lo
|
|
|
111
121
|
|
|
112
122
|
export async function runCode({ session, home = os.homedir(), argv = [], stdout = console.log, preferredModel = null } = {}) {
|
|
113
123
|
if (!session?.token) throw new Error("Not signed in. Run `4yi login`.");
|
|
114
|
-
const modelConfig = await requestJson(session.baseUrl, "/api/cli/models", { token: session.token });
|
|
124
|
+
const modelConfig = await requestJson(session.baseUrl, "/api/cli/models?runtime=opencode", { token: session.token });
|
|
115
125
|
const list = modelConfig.models || [];
|
|
116
126
|
if (list.length === 0) throw new Error("No chat models available for this organization.");
|
|
117
127
|
|