@openagents-org/agent-launcher 0.2.209 → 0.2.211
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/icons/mimo-code.svg +1 -0
- package/icons/qoder-cn.svg +1 -0
- package/icons/qoder.svg +1 -0
- package/icons/qwen-code.svg +1 -0
- package/package.json +1 -1
- package/registry.json +374 -2
- package/src/adapters/base.js +31 -7
- package/src/adapters/claude.js +44 -10
- package/src/adapters/codex.js +48 -2
- package/src/adapters/cursor.js +5 -3
- package/src/adapters/deepseek.js +21 -3
- package/src/adapters/index.js +13 -1
- package/src/adapters/kimi-stream.js +6 -5
- package/src/adapters/mimo-code-runtime.js +266 -0
- package/src/adapters/mimo-code.js +581 -0
- package/src/adapters/opencode.js +21 -16
- package/src/adapters/pi.js +91 -8
- package/src/adapters/qoder-cn.js +24 -0
- package/src/adapters/qoder-runtime.js +611 -0
- package/src/adapters/qoder.js +946 -0
- package/src/adapters/qwen-code-stream.js +735 -0
- package/src/adapters/qwen-code.js +1125 -0
- package/src/adapters/utils.js +8 -2
- package/src/adapters/workspace-prompt.js +7 -1
- package/src/agent-login.js +93 -0
- package/src/cli-models.js +45 -2
- package/src/cli.js +94 -0
- package/src/daemon.js +80 -4
- package/src/env.js +3 -0
- package/src/installer.js +99 -21
- package/src/node-engines.js +173 -0
- package/src/paths.js +21 -0
- package/src/probe.js +58 -1
- package/src/workspace-client.js +14 -2
package/src/adapters/utils.js
CHANGED
|
@@ -240,9 +240,15 @@ function decodeConsoleOutput(buf, isWindows = process.platform === 'win32') {
|
|
|
240
240
|
* they hid the real one. Claude Code warns about its claude.ai connectors
|
|
241
241
|
* whenever a key is set, and about a model it does not know (any relay model:
|
|
242
242
|
* glm, kimi, …) — "…so it assumes a context window of 200000 tokens … Until
|
|
243
|
-
* then auto-compact keeps this session within 200k tokens".
|
|
243
|
+
* then auto-compact keeps this session within 200k tokens". Codex does the
|
|
244
|
+
* same for a model missing from its catalog: "warning: Model metadata for
|
|
245
|
+
* `gpt-5.5` not found. Defaulting to fallback metadata…", and logs every
|
|
246
|
+
* run's housekeeping as timestamped WARN/INFO records plus "Reading prompt
|
|
247
|
+
* from stdin...", which filled the smoke test's timeout message. Node's own
|
|
248
|
+
* process warnings ("(node:1234) Warning: …", "(Use `node --trace-warnings
|
|
249
|
+
* ...`") come ahead of the real error from npm-shipped CLIs like CodeBuddy.
|
|
244
250
|
*/
|
|
245
|
-
const BENIGN_CLI_OUTPUT = /claude\.ai connectors are disabled|doesn't recognize the model|assumes a context window|auto-compact keeps this session|CLAUDE_CODE_DISABLE_UNKNOWN_MODEL_WINDOW_ENFORCEMENT
|
|
251
|
+
const BENIGN_CLI_OUTPUT = /claude\.ai connectors are disabled|doesn't recognize the model|assumes a context window|auto-compact keeps this session|CLAUDE_CODE_DISABLE_UNKNOWN_MODEL_WINDOW_ENFORCEMENT|Model metadata for .* not found|Defaulting to fallback metadata|^\s*Reading (prompt|additional input) from stdin|^\s*\d{4}-\d{2}-\d{2}T[\d:.]+Z?\s+(TRACE|DEBUG|INFO|WARN)\s|^\s*\(node:\d+\) (\[\w+\] )?\w*Warning:|^\s*\(Use `node --trace-(warnings|deprecation) \.\.\.`/i;
|
|
246
252
|
|
|
247
253
|
/** CLI output with the known-harmless lines taken out. */
|
|
248
254
|
function stripCliNoise(text) {
|
|
@@ -524,6 +524,12 @@ function buildApiSkillsPrompt({ endpoint, workspaceId, token, agentName, channel
|
|
|
524
524
|
'Create or update your to-do list to track progress. The entire list ' +
|
|
525
525
|
'is replaced each time (send the full list with current statuses).\n\n' +
|
|
526
526
|
'**Status values:** `pending`, `in_progress`, `completed`\n\n' +
|
|
527
|
+
'Use `in_progress` only for work you can actively execute now. Before ending a turn, ' +
|
|
528
|
+
'move tasks waiting for human input, approval, login, or dependencies back to `pending`. ' +
|
|
529
|
+
'Set the actual assignee when another person or agent owns the next action. ' +
|
|
530
|
+
'Only your own `in_progress` tasks may automatically continue after a reply; ' +
|
|
531
|
+
'pending tasks stay visible but do not wake you. When the required input arrives, ' +
|
|
532
|
+
'mark the relevant task `in_progress` and resume it.\n\n' +
|
|
527
533
|
'**Update your to-do list:**\n' +
|
|
528
534
|
`\`${curl} -s -X PUT -H "${h}" -H "Content-Type: application/json" ` +
|
|
529
535
|
`${baseUrl}/v1/todos -d '{"todos":[` +
|
|
@@ -532,7 +538,7 @@ function buildApiSkillsPrompt({ endpoint, workspaceId, token, agentName, channel
|
|
|
532
538
|
`],"network":"${workspaceId}","channel":"${channelName}",` +
|
|
533
539
|
`"source":"openagents:${agentName}"}'\`\n\n` +
|
|
534
540
|
'**Get your to-do list:**\n' +
|
|
535
|
-
`\`${curl} -s -H "${h}" "${baseUrl}/v1/todos?network=${workspaceId}&channel=${channelName}"\`\n\n` +
|
|
541
|
+
`\`${curl} -s -H "${h}" "${baseUrl}/v1/todos?network=${workspaceId}&channel=${channelName}&source=openagents%3A${encodeURIComponent(agentName)}"\`\n\n` +
|
|
536
542
|
'**IMPORTANT:** When you receive a task with multiple steps or a list of things to do, ' +
|
|
537
543
|
'ALWAYS create a to-do list first before starting work. This lets the user see your ' +
|
|
538
544
|
'progress in real time. Update statuses as you work through each item.\n' +
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* `agn login <agent>` — sign an agent's own CLI in to its account on this device.
|
|
5
|
+
*
|
|
6
|
+
* The account belongs to the CLI, not to OpenAgents (`codex login` writes
|
|
7
|
+
* ~/.codex/auth.json and the adapter only runs codex), so this runs the CLI's
|
|
8
|
+
* own login command from the registry. What it adds over typing that command:
|
|
9
|
+
*
|
|
10
|
+
* - The CLI is found where OpenAgents installed it. An agent added from the
|
|
11
|
+
* workspace lands in ~/.openagents/runtimes/<type>/, which the install
|
|
12
|
+
* scripts never put on the user's PATH, so a bare `codex login` on that
|
|
13
|
+
* machine is "command not found".
|
|
14
|
+
* - A machine with no local browser gets the login that works without one.
|
|
15
|
+
* - The daemon re-detects afterwards, so the workspace stops saying the agent
|
|
16
|
+
* has no credentials without waiting for its 2-minute refresh.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Arguments a CLI's login needs when the browser is not on this machine.
|
|
21
|
+
* `codex login` waits for its browser on 127.0.0.1:1455, which a browser on
|
|
22
|
+
* another computer can never reach; `--device-auth` prints a URL and a one-time
|
|
23
|
+
* code that work from any browser. Claude (paste the code back) and Cursor (the
|
|
24
|
+
* CLI polls its own server) need nothing extra.
|
|
25
|
+
*/
|
|
26
|
+
const HEADLESS_LOGIN_ARGS = {
|
|
27
|
+
codex: ['--device-auth'],
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Sign-ins the registry does not declare as `login_command`. Declaring one
|
|
32
|
+
* there also changes how the add form and the daemon treat the type's keys
|
|
33
|
+
* and models, so `agn login` knows these on its own.
|
|
34
|
+
*/
|
|
35
|
+
const EXTRA_LOGIN_COMMANDS = {
|
|
36
|
+
// In `opencode auth login` (1.19.5) OpenAI offers a ChatGPT Plus/Pro sign-in
|
|
37
|
+
// and GitHub Copilot a GitHub one; every other provider only takes a key.
|
|
38
|
+
opencode: 'opencode auth login',
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/** The login command for a registry entry: its own, else one named above. */
|
|
42
|
+
function loginCommandOf(entry) {
|
|
43
|
+
if (!entry) return null;
|
|
44
|
+
const declared = entry.check_ready && entry.check_ready.login_command;
|
|
45
|
+
const command = (declared && String(declared).trim()) || EXTRA_LOGIN_COMMANDS[entry.name] || '';
|
|
46
|
+
return command || null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Whether a browser opened by the CLI would not be in front of the user: an
|
|
51
|
+
* SSH session anywhere, or Linux with no display server.
|
|
52
|
+
*/
|
|
53
|
+
function isHeadless(env = process.env, platform = process.platform) {
|
|
54
|
+
if (env.SSH_CONNECTION || env.SSH_TTY) return true;
|
|
55
|
+
return platform === 'linux' && !env.DISPLAY && !env.WAYLAND_DISPLAY;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** `"claude auth login"` → `["auth", "login"]`: the binary is resolved separately. */
|
|
59
|
+
function loginArgs(loginCommand) {
|
|
60
|
+
return String(loginCommand || '').trim().split(/\s+/).filter(Boolean).slice(1);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The login to run for a registry entry, or null when its CLI has no sign-in
|
|
65
|
+
* of its own (those agents only take an API key).
|
|
66
|
+
*/
|
|
67
|
+
function loginPlan(entry, { env = process.env, platform = process.platform } = {}) {
|
|
68
|
+
const command = loginCommandOf(entry);
|
|
69
|
+
if (!command) return null;
|
|
70
|
+
const args = loginArgs(command);
|
|
71
|
+
const headless = isHeadless(env, platform);
|
|
72
|
+
const extra = headless ? (HEADLESS_LOGIN_ARGS[entry.name] || []) : [];
|
|
73
|
+
return {
|
|
74
|
+
command,
|
|
75
|
+
args: [...args, ...extra.filter((a) => !args.includes(a))],
|
|
76
|
+
headless,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** The command a workspace shows for signing an agent type in on a device. */
|
|
81
|
+
function agnLoginCommand(type) {
|
|
82
|
+
return `agn login ${type}`;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
module.exports = {
|
|
86
|
+
HEADLESS_LOGIN_ARGS,
|
|
87
|
+
EXTRA_LOGIN_COMMANDS,
|
|
88
|
+
isHeadless,
|
|
89
|
+
loginArgs,
|
|
90
|
+
loginCommandOf,
|
|
91
|
+
loginPlan,
|
|
92
|
+
agnLoginCommand,
|
|
93
|
+
};
|
package/src/cli-models.js
CHANGED
|
@@ -106,6 +106,24 @@ function parseClaudeModels(text) {
|
|
|
106
106
|
return [...seen.values()].slice(0, MAX_MODELS);
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
+
/**
|
|
110
|
+
* `qodercli --list-models`: a "MODEL" header, then one model per line — the
|
|
111
|
+
* display name for Qoder's own tiers (which `-m` accepts as is) and
|
|
112
|
+
* "Name (key)" for a bring-your-own-key model, which `-m` takes by its key.
|
|
113
|
+
*/
|
|
114
|
+
function parseQoderModels(text) {
|
|
115
|
+
const seen = new Map();
|
|
116
|
+
for (const raw of String(text || '').split(/\r?\n/)) {
|
|
117
|
+
const line = raw.trim();
|
|
118
|
+
if (!line || line === 'MODEL') continue;
|
|
119
|
+
const custom = line.match(/^(.*\S)\s+\(([^()]+)\)$/);
|
|
120
|
+
const id = cleanId(custom ? custom[2] : line);
|
|
121
|
+
if (!id || seen.has(id)) continue;
|
|
122
|
+
seen.set(id, { id, label: cleanLabel(custom ? custom[1] : line, id) });
|
|
123
|
+
}
|
|
124
|
+
return [...seen.values()].slice(0, MAX_MODELS);
|
|
125
|
+
}
|
|
126
|
+
|
|
109
127
|
/**
|
|
110
128
|
* How each CLI is asked. Claude Code has no command for it; its SDK control
|
|
111
129
|
* protocol does, and a run that is sent the request and then end-of-input
|
|
@@ -123,6 +141,23 @@ const LISTERS = {
|
|
|
123
141
|
parse: parseClaudeModels,
|
|
124
142
|
timeoutMs: 45_000,
|
|
125
143
|
},
|
|
144
|
+
// Qoder's personal access token signs in to the same account a browser
|
|
145
|
+
// sign-in would, so a token in the env is no reason not to ask (`withKey`).
|
|
146
|
+
// NO_RC keeps a first-ever start from editing the user's shell rc files.
|
|
147
|
+
qoder: {
|
|
148
|
+
args: ['--list-models'],
|
|
149
|
+
parse: parseQoderModels,
|
|
150
|
+
timeoutMs: 45_000,
|
|
151
|
+
withKey: true,
|
|
152
|
+
env: { QODER_NO_RC: '1' },
|
|
153
|
+
},
|
|
154
|
+
'qoder-cn': {
|
|
155
|
+
args: ['--list-models'],
|
|
156
|
+
parse: parseQoderModels,
|
|
157
|
+
timeoutMs: 45_000,
|
|
158
|
+
withKey: true,
|
|
159
|
+
env: { QODERCN_NO_RC: '1' },
|
|
160
|
+
},
|
|
126
161
|
};
|
|
127
162
|
|
|
128
163
|
/** Whether this agent type's CLI can be asked for its account's models. */
|
|
@@ -130,6 +165,14 @@ function supportsCliModels(agentType) {
|
|
|
130
165
|
return Object.prototype.hasOwnProperty.call(LISTERS, agentType);
|
|
131
166
|
}
|
|
132
167
|
|
|
168
|
+
/**
|
|
169
|
+
* Whether the CLI's list still applies with a key configured: true where the
|
|
170
|
+
* key is a token for the same account, not another endpoint's credential.
|
|
171
|
+
*/
|
|
172
|
+
function cliModelsWithKey(agentType) {
|
|
173
|
+
return supportsCliModels(agentType) && LISTERS[agentType].withKey === true;
|
|
174
|
+
}
|
|
175
|
+
|
|
133
176
|
/**
|
|
134
177
|
* Stop a CLI that ran too long. On Windows the npm shim runs under cmd.exe
|
|
135
178
|
* (shell: true), and killing that leaves the node process it started alive,
|
|
@@ -226,7 +269,7 @@ async function listCliModels(connector, type, opts = {}) {
|
|
|
226
269
|
const resolved = connector.resolveAgentEnv(type, saved) || {};
|
|
227
270
|
agentEnv = { ...saved, ...resolved };
|
|
228
271
|
} catch {}
|
|
229
|
-
const env = stripForCliLogin(type, { ...getEnhancedEnv(), ...agentEnv }, connector.registry, opts.agentEnv);
|
|
272
|
+
const env = stripForCliLogin(type, { ...getEnhancedEnv(), ...agentEnv, ...(lister.env || {}) }, connector.registry, opts.agentEnv);
|
|
230
273
|
|
|
231
274
|
const res = await runCli(binary, lister.args, {
|
|
232
275
|
env,
|
|
@@ -241,4 +284,4 @@ async function listCliModels(connector, type, opts = {}) {
|
|
|
241
284
|
return fail(res.error || 'The CLI listed no models.');
|
|
242
285
|
}
|
|
243
286
|
|
|
244
|
-
module.exports = { listCliModels, supportsCliModels, parseCodexModels, parseClaudeModels };
|
|
287
|
+
module.exports = { listCliModels, supportsCliModels, cliModelsWithKey, parseCodexModels, parseClaudeModels, parseQoderModels };
|
package/src/cli.js
CHANGED
|
@@ -1070,6 +1070,98 @@ async function cmdProbe(connector, flags, positional) {
|
|
|
1070
1070
|
}
|
|
1071
1071
|
}
|
|
1072
1072
|
|
|
1073
|
+
/**
|
|
1074
|
+
* `agn login <type|agent>` — run the agent CLI's own sign-in on this device.
|
|
1075
|
+
* See agent-login.js for why this is more than the bare login command.
|
|
1076
|
+
*/
|
|
1077
|
+
async function cmdLogin(connector, flags, positional) {
|
|
1078
|
+
const target = (positional[0] || '').trim();
|
|
1079
|
+
if (!target) {
|
|
1080
|
+
print('Usage: agn login <type|agent>');
|
|
1081
|
+
print("Signs the agent's own CLI in to its account on this device, e.g. agn login codex");
|
|
1082
|
+
process.exitCode = 1;
|
|
1083
|
+
return;
|
|
1084
|
+
}
|
|
1085
|
+
// A type first: the first agent of a type is often named after it.
|
|
1086
|
+
let type = target;
|
|
1087
|
+
let entry = connector.registry.getEntry(target);
|
|
1088
|
+
if (!entry) {
|
|
1089
|
+
const agent = connector.config.getAgent(target);
|
|
1090
|
+
if (agent) {
|
|
1091
|
+
type = agent.type || 'openclaw';
|
|
1092
|
+
entry = connector.registry.getEntry(type);
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
if (!entry) {
|
|
1096
|
+
print(`Unknown agent type or agent '${target}'. See: agn search`);
|
|
1097
|
+
process.exitCode = 1;
|
|
1098
|
+
return;
|
|
1099
|
+
}
|
|
1100
|
+
const label = entry.label || type;
|
|
1101
|
+
const { loginPlan } = require('./agent-login');
|
|
1102
|
+
const plan = loginPlan(entry);
|
|
1103
|
+
if (!plan) {
|
|
1104
|
+
print(`${label} has no sign-in of its own. Give it an API key instead, in the workspace or with: agn env ${type} --set <KEY>=<value>`);
|
|
1105
|
+
process.exitCode = 1;
|
|
1106
|
+
return;
|
|
1107
|
+
}
|
|
1108
|
+
const bin = connector.installer.which(type);
|
|
1109
|
+
if (!bin) {
|
|
1110
|
+
print(`${label} is not installed on this device. Install it first: agn install ${type}`);
|
|
1111
|
+
process.exitCode = 1;
|
|
1112
|
+
return;
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
// wsl.spawn: a CLI installed inside a WSL distro signs in over there.
|
|
1116
|
+
const { spawn } = require('./wsl');
|
|
1117
|
+
const { getEnhancedEnv } = require('./paths');
|
|
1118
|
+
const { shouldUseShellForBinary } = require('./adapters/health-status');
|
|
1119
|
+
const shell = shouldUseShellForBinary(bin);
|
|
1120
|
+
print(`Signing in ${label}: ${[plan.command.split(/\s+/)[0], ...plan.args].join(' ')}`);
|
|
1121
|
+
if (plan.headless && plan.args.includes('--device-auth')) {
|
|
1122
|
+
print('No browser on this machine: open the link below on any device and enter the code.');
|
|
1123
|
+
}
|
|
1124
|
+
if (!process.stdin.isTTY) {
|
|
1125
|
+
print('Warning: this is not an interactive terminal. The sign-in may need one to take input; if it stalls, run this command in a terminal.');
|
|
1126
|
+
}
|
|
1127
|
+
print('');
|
|
1128
|
+
// The CLI owns the terminal until it is done. Ctrl+C reaches it too, and it
|
|
1129
|
+
// decides what that means; this process waits to report the result.
|
|
1130
|
+
const ignoreInterrupt = () => {};
|
|
1131
|
+
process.on('SIGINT', ignoreInterrupt);
|
|
1132
|
+
const code = await new Promise((resolve) => {
|
|
1133
|
+
let child;
|
|
1134
|
+
try {
|
|
1135
|
+
child = spawn(shell ? `"${bin}"` : bin, plan.args, {
|
|
1136
|
+
stdio: 'inherit',
|
|
1137
|
+
env: getEnhancedEnv(),
|
|
1138
|
+
shell,
|
|
1139
|
+
});
|
|
1140
|
+
} catch (e) {
|
|
1141
|
+
print(`Could not start ${bin}: ${e.message}`);
|
|
1142
|
+
resolve(1);
|
|
1143
|
+
return;
|
|
1144
|
+
}
|
|
1145
|
+
child.on('error', (e) => { print(`Could not start ${bin}: ${e.message}`); resolve(1); });
|
|
1146
|
+
child.on('exit', (c) => resolve(c == null ? 1 : c));
|
|
1147
|
+
});
|
|
1148
|
+
process.removeListener('SIGINT', ignoreInterrupt);
|
|
1149
|
+
|
|
1150
|
+
// The CLI's word is not enough (some exit 0 on a cancelled login): ask the
|
|
1151
|
+
// same readiness check the daemon uses, with keys not counting.
|
|
1152
|
+
let ready = false;
|
|
1153
|
+
try { ready = !!connector.installer.healthCheck(type, { cliLogin: true }).ready; } catch {}
|
|
1154
|
+
// Have a running daemon re-detect and report, so the workspace updates now.
|
|
1155
|
+
try { connector.sendDaemonCommand('detect'); } catch {}
|
|
1156
|
+
print('');
|
|
1157
|
+
if (ready) {
|
|
1158
|
+
print(`✓ ${label} is signed in on this device. The workspace will show it as ready shortly.`);
|
|
1159
|
+
} else {
|
|
1160
|
+
print(`✗ ${label} is still not signed in${code ? ` (the login exited with code ${code})` : ''}.`);
|
|
1161
|
+
process.exitCode = 1;
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1073
1165
|
async function cmdModels(connector, flags, positional) {
|
|
1074
1166
|
const target = positional[0];
|
|
1075
1167
|
if (!target) { print('Usage: agn models <type|agent> [--json] [--sign-in]'); return; }
|
|
@@ -1168,6 +1260,7 @@ Commands:
|
|
|
1168
1260
|
stop <name> Stop a single agent
|
|
1169
1261
|
install <type> Install an agent runtime
|
|
1170
1262
|
uninstall <type> Uninstall an agent runtime
|
|
1263
|
+
login <type|agent> Sign the agent's own CLI in to its account (e.g. agn login codex)
|
|
1171
1264
|
search [query] Browse agent catalog
|
|
1172
1265
|
runtimes List installed runtimes
|
|
1173
1266
|
device connect <code> Pair this device (formerly "node") to a workspace with a pairing code
|
|
@@ -1275,6 +1368,7 @@ async function main() {
|
|
|
1275
1368
|
'test-llm': () => cmdTestLLM(connector, flags, positional),
|
|
1276
1369
|
probe: () => cmdProbe(connector, flags, positional),
|
|
1277
1370
|
models: () => cmdModels(connector, flags, positional),
|
|
1371
|
+
login: () => cmdLogin(connector, flags, positional),
|
|
1278
1372
|
update: () => cmdUpdate(connector),
|
|
1279
1373
|
'mcp-server': () => {
|
|
1280
1374
|
const { runMcpServer } = require('./mcp-server');
|
package/src/daemon.js
CHANGED
|
@@ -11,7 +11,8 @@ const { spawn } = require('./wsl');
|
|
|
11
11
|
const os = require('os');
|
|
12
12
|
const { WorkspaceClient } = require('./workspace-client');
|
|
13
13
|
const { listEndpointModels } = require('./model-list');
|
|
14
|
-
const { supportsCliModels } = require('./cli-models');
|
|
14
|
+
const { supportsCliModels, cliModelsWithKey } = require('./cli-models');
|
|
15
|
+
const { agnLoginCommand, loginCommandOf } = require('./agent-login');
|
|
15
16
|
const {
|
|
16
17
|
AUTH_MODE_KEY, CLI_LOGIN, MODEL_MODE_KEY, MODEL_DEFAULT, credentialKeys, isCliLogin, modelKeys, stripForCliLogin, typeEnvFor,
|
|
17
18
|
} = require('./env');
|
|
@@ -170,6 +171,7 @@ class Daemon {
|
|
|
170
171
|
this._cliModelsStartupTimer = null;
|
|
171
172
|
this._cliModelsInterval = null;
|
|
172
173
|
this._reloadInFlight = null; // serialize concurrent _reload() calls
|
|
174
|
+
this._runtimeRepairs = new Map(); // agent type → in-flight reinstall of its supported version
|
|
173
175
|
}
|
|
174
176
|
|
|
175
177
|
// ── Agent smoke tests (probes) ─────────────────────────────────────────
|
|
@@ -293,6 +295,8 @@ class Daemon {
|
|
|
293
295
|
*/
|
|
294
296
|
_onCliSignIn(a) {
|
|
295
297
|
if (!supportsCliModels(a.type)) return false;
|
|
298
|
+
// A Qoder token IS the account: the CLI lists the same models either way.
|
|
299
|
+
if (cliModelsWithKey(a.type)) return true;
|
|
296
300
|
const endpoint = this._agentEndpoint(a);
|
|
297
301
|
return !endpoint.baseUrl && !endpoint.apiKey;
|
|
298
302
|
}
|
|
@@ -446,12 +450,21 @@ class Daemon {
|
|
|
446
450
|
* its sign-in's models carries that list, for the add form's model picker.
|
|
447
451
|
* Null until the CLI has answered, and from devices too old to ask, where
|
|
448
452
|
* the form keeps the catalog's list.
|
|
453
|
+
*
|
|
454
|
+
* A type with a sign-in of its own also carries `loginCommand`, the command
|
|
455
|
+
* to run on this device (`agn login codex`). Its presence is how the
|
|
456
|
+
* workspace knows this device has `agn login`; for an older device it shows
|
|
457
|
+
* the CLI's own login command instead.
|
|
449
458
|
*/
|
|
450
459
|
_heartbeatRuntimes() {
|
|
451
460
|
return (this._runtimes || []).map((rt) => {
|
|
452
|
-
if (!rt
|
|
461
|
+
if (!rt) return rt;
|
|
462
|
+
// Whatever `agn login` can sign in, which is wider than _hasCliSignIn:
|
|
463
|
+
// OpenCode signs in without the registry marking it a sign-in agent.
|
|
464
|
+
const out = this._agnLoginFor(rt.type) ? { ...rt, loginCommand: agnLoginCommand(rt.type) } : rt;
|
|
465
|
+
if (!out.installed || !supportsCliModels(rt.type)) return out;
|
|
453
466
|
const listed = this._cliModels[this._cliModelsKey(this._signInAgent(rt.type))];
|
|
454
|
-
return { ...
|
|
467
|
+
return { ...out, cliModels: (listed && listed.models) || null };
|
|
455
468
|
});
|
|
456
469
|
}
|
|
457
470
|
|
|
@@ -718,6 +731,24 @@ class Daemon {
|
|
|
718
731
|
return !SHARED_NATIVE_CONFIG.has(type);
|
|
719
732
|
}
|
|
720
733
|
|
|
734
|
+
/**
|
|
735
|
+
* Whether `agn login <type>` has a sign-in to run for this type. Remembered
|
|
736
|
+
* per type: the heartbeat asks for every runtime every 10s, and each
|
|
737
|
+
* getEntry() re-reads and parses the bundled registry (~25ms for all types).
|
|
738
|
+
*/
|
|
739
|
+
_agnLoginFor(type) {
|
|
740
|
+
if (!this._agnLoginTypes) this._agnLoginTypes = new Map();
|
|
741
|
+
if (this._agnLoginTypes.has(type)) return this._agnLoginTypes.get(type);
|
|
742
|
+
let has = false;
|
|
743
|
+
try {
|
|
744
|
+
has = !!loginCommandOf(this.registry.getEntry(type));
|
|
745
|
+
} catch {
|
|
746
|
+
return false; // not remembered: a registry that failed to load can recover
|
|
747
|
+
}
|
|
748
|
+
this._agnLoginTypes.set(type, has);
|
|
749
|
+
return has;
|
|
750
|
+
}
|
|
751
|
+
|
|
721
752
|
/** Whether this type's CLI has a sign-in of its own (`codex login`, …). */
|
|
722
753
|
_hasCliSignIn(type) {
|
|
723
754
|
try {
|
|
@@ -1886,6 +1917,47 @@ async _runNodeCommand(n, cmd) {
|
|
|
1886
1917
|
this._writeStatus();
|
|
1887
1918
|
}
|
|
1888
1919
|
|
|
1920
|
+
/**
|
|
1921
|
+
* Put a runtime the adapter can run in place of one it refused, then ask the
|
|
1922
|
+
* adapter again. Used for a pinned agent found on the wrong version (DeepSeek
|
|
1923
|
+
* Harness, whose adapter accepts exactly one preview): the registry's install
|
|
1924
|
+
* command already names the supported version and installs it into the
|
|
1925
|
+
* managed prefix, which the adapter prefers. Doing it here instead of
|
|
1926
|
+
* reporting the mismatch is what keeps a stale install — an old global copy,
|
|
1927
|
+
* or one the launcher placed before the pin moved — from surfacing as an
|
|
1928
|
+
* error the user has to fix by hand.
|
|
1929
|
+
*
|
|
1930
|
+
* One install per agent type at a time, shared by every agent of that type
|
|
1931
|
+
* starting together. Returns the new preflight result, or null when the
|
|
1932
|
+
* install failed and the original reason should stand.
|
|
1933
|
+
*/
|
|
1934
|
+
async _repairRuntime(name, agentType, adapter, info, pf) {
|
|
1935
|
+
this._log(`${name} preflight: ${pf.message} — installing the supported version`, 'warn');
|
|
1936
|
+
info.state = 'starting';
|
|
1937
|
+
info.lastError = null;
|
|
1938
|
+
info.errorReason = null;
|
|
1939
|
+
this._writeStatus();
|
|
1940
|
+
|
|
1941
|
+
let job = this._runtimeRepairs.get(agentType);
|
|
1942
|
+
if (!job) {
|
|
1943
|
+
const { Installer } = require('./installer');
|
|
1944
|
+
const installer = new Installer(this.registry, this.config.configDir);
|
|
1945
|
+
job = installer.installStreaming(agentType, () => {})
|
|
1946
|
+
.then(() => true, (e) => {
|
|
1947
|
+
this._log(`${agentType} reinstall failed: ${redactDiagnostic(String(e && e.message || e)).slice(0, 500)}`, 'error');
|
|
1948
|
+
return false;
|
|
1949
|
+
})
|
|
1950
|
+
.finally(() => this._runtimeRepairs.delete(agentType));
|
|
1951
|
+
this._runtimeRepairs.set(agentType, job);
|
|
1952
|
+
}
|
|
1953
|
+
if (!(await job)) return null;
|
|
1954
|
+
|
|
1955
|
+
if (typeof adapter.forgetRuntime === 'function') adapter.forgetRuntime();
|
|
1956
|
+
const next = adapter.preflight();
|
|
1957
|
+
if (next && next.ok !== false) this._log(`${name}: supported ${agentType} runtime installed`);
|
|
1958
|
+
return next;
|
|
1959
|
+
}
|
|
1960
|
+
|
|
1889
1961
|
async _adapterLoop(name, agentCfg, info, network) {
|
|
1890
1962
|
const { createAdapter } = require('./adapters');
|
|
1891
1963
|
const { skillsToDisabledModules } = require('./skill-catalog');
|
|
@@ -1937,8 +2009,12 @@ async _runNodeCommand(n, cmd) {
|
|
|
1937
2009
|
// no point spinning a join/poll loop that can never run the CLI. Adapters
|
|
1938
2010
|
// that don't override preflight() always pass.
|
|
1939
2011
|
try {
|
|
1940
|
-
|
|
2012
|
+
let pf =
|
|
1941
2013
|
typeof adapter.preflight === 'function' ? adapter.preflight() : null;
|
|
2014
|
+
if (pf && pf.ok === false && pf.repairable) {
|
|
2015
|
+
pf = (await this._repairRuntime(name, agentType, adapter, info, pf)) || pf;
|
|
2016
|
+
if (this._shuttingDown || this._stoppedAgents.has(name)) return;
|
|
2017
|
+
}
|
|
1942
2018
|
if (pf && pf.ok === false) {
|
|
1943
2019
|
info.state = 'error';
|
|
1944
2020
|
info.errorReason = pf.reason || 'runtime_missing';
|
package/src/env.js
CHANGED
|
@@ -169,6 +169,9 @@ function usesDefaultModel(agentEnv) {
|
|
|
169
169
|
*/
|
|
170
170
|
const NATIVE_CREDENTIALS = {
|
|
171
171
|
codex: ['CODEX_API_KEY'],
|
|
172
|
+
// MiMo Code reads a key for its built-in provider from XIAOMI_API_KEY; a
|
|
173
|
+
// signed-in agent must run on the sign-in, not on that.
|
|
174
|
+
'mimo-code': ['XIAOMI_API_KEY'],
|
|
172
175
|
gemini: ['GOOGLE_GEMINI_BASE_URL'],
|
|
173
176
|
antigravity: ['GOOGLE_GEMINI_BASE_URL'],
|
|
174
177
|
};
|