@openagents-org/agent-launcher 0.2.210 → 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 +25 -4
- 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/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 +49 -17
- package/src/paths.js +21 -0
- package/src/probe.js +44 -1
- package/src/workspace-client.js +12 -1
|
@@ -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
|
};
|
package/src/installer.js
CHANGED
|
@@ -920,7 +920,7 @@ class Installer {
|
|
|
920
920
|
// ~/.gemini/oauth_creds.json) or a service-account file path, WITHOUT
|
|
921
921
|
// parsing or logging the token. Additive: agents that don't declare
|
|
922
922
|
// creds_no_parse / creds_path_env get identical behavior to before.
|
|
923
|
-
const credsFile = this._evaluateCredsFile(checkReady, agentType);
|
|
923
|
+
const credsFile = this._evaluateCredsFile(checkReady, agentType, savedEnv);
|
|
924
924
|
const credsPathReady = this._checkCredsPathEnv(checkReady, savedEnv, agentType);
|
|
925
925
|
|
|
926
926
|
let cliReady = false;
|
|
@@ -982,7 +982,7 @@ class Installer {
|
|
|
982
982
|
// agent never needs.
|
|
983
983
|
const credsReady = checkReady.creds_json_has_entries
|
|
984
984
|
? false
|
|
985
|
-
: this._checkCredsReady(checkReady, agentType);
|
|
985
|
+
: this._checkCredsReady(checkReady, agentType, savedEnv);
|
|
986
986
|
if (credsReady || credsFile.ready || credsPathReady) {
|
|
987
987
|
return {
|
|
988
988
|
ready: true,
|
|
@@ -1073,10 +1073,10 @@ class Installer {
|
|
|
1073
1073
|
return checkReady.creds_file || null;
|
|
1074
1074
|
}
|
|
1075
1075
|
|
|
1076
|
-
_checkCredsReady(checkReady, agentType) {
|
|
1076
|
+
_checkCredsReady(checkReady, agentType, savedEnv = null) {
|
|
1077
1077
|
if (this._credsFile(checkReady)) {
|
|
1078
1078
|
try {
|
|
1079
|
-
const credsPath = this.
|
|
1079
|
+
const credsPath = this._credsFilePath(checkReady, agentType, savedEnv);
|
|
1080
1080
|
if (fs.existsSync(credsPath)) {
|
|
1081
1081
|
const stat = fs.statSync(credsPath);
|
|
1082
1082
|
if (stat.isDirectory()) return fs.readdirSync(credsPath).length > 0;
|
|
@@ -1106,6 +1106,38 @@ class Installer {
|
|
|
1106
1106
|
return false;
|
|
1107
1107
|
}
|
|
1108
1108
|
|
|
1109
|
+
/**
|
|
1110
|
+
* Where `creds_file` is for this machine. A CLI that keeps its sign-in in
|
|
1111
|
+
* the XDG data directory (MiMo Code's auth.json) follows XDG_DATA_HOME when
|
|
1112
|
+
* it is set, so `creds_xdg_data_file` names the file under it and
|
|
1113
|
+
* `creds_file` stays the default — which is also all an older core reads.
|
|
1114
|
+
* `creds_home_env` + `creds_home_env_file` name a CLI home variable that
|
|
1115
|
+
* overrides both. The agent's own setting (`savedEnv`, what the CLI is
|
|
1116
|
+
* spawned with) comes before the daemon's. Not for a WSL install: the variable here is this
|
|
1117
|
+
* side's, not the distro's.
|
|
1118
|
+
*/
|
|
1119
|
+
_credsFilePath(checkReady, agentType, savedEnv = null) {
|
|
1120
|
+
const fromEnv = (name) => String((savedEnv && savedEnv[name]) || process.env[name] || '').trim();
|
|
1121
|
+
let wsl = null;
|
|
1122
|
+
const isWsl = () => {
|
|
1123
|
+
if (wsl === null) {
|
|
1124
|
+
wsl = false;
|
|
1125
|
+
try { wsl = !!agentType && isWslBinary(this._whichBinary(agentType)); } catch { /* best-effort */ }
|
|
1126
|
+
}
|
|
1127
|
+
return wsl;
|
|
1128
|
+
};
|
|
1129
|
+
// A CLI home named by its own variable comes first (MiMo Code reads
|
|
1130
|
+
// $MIMOCODE_HOME/data/auth.json when MIMOCODE_HOME is set).
|
|
1131
|
+
const homeVar = checkReady.creds_home_env;
|
|
1132
|
+
const homeRel = checkReady.creds_home_env_file;
|
|
1133
|
+
const cliHome = homeVar && homeRel ? fromEnv(homeVar) : '';
|
|
1134
|
+
if (cliHome && path.isAbsolute(cliHome) && !isWsl()) return path.join(cliHome, homeRel);
|
|
1135
|
+
const rel = checkReady.creds_xdg_data_file;
|
|
1136
|
+
const dataHome = fromEnv('XDG_DATA_HOME');
|
|
1137
|
+
if (rel && dataHome && path.isAbsolute(dataHome) && !isWsl()) return path.join(dataHome, rel);
|
|
1138
|
+
return this._expandHome(this._credsFile(checkReady), agentType);
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1109
1141
|
/**
|
|
1110
1142
|
* Expand a leading "~" to the home directory the AGENT writes its sign-in to.
|
|
1111
1143
|
*
|
|
@@ -1156,9 +1188,9 @@ class Installer {
|
|
|
1156
1188
|
* against the running user's home (the daemon/launcher user), not the
|
|
1157
1189
|
* renderer/browser user.
|
|
1158
1190
|
*/
|
|
1159
|
-
_credsFileState(checkReady, agentType) {
|
|
1191
|
+
_credsFileState(checkReady, agentType, savedEnv = null) {
|
|
1160
1192
|
if (!this._credsFile(checkReady)) return 'absent';
|
|
1161
|
-
const p = this.
|
|
1193
|
+
const p = this._credsFilePath(checkReady, agentType, savedEnv);
|
|
1162
1194
|
let exists = false;
|
|
1163
1195
|
try { exists = fs.existsSync(p); } catch { return 'unreadable'; }
|
|
1164
1196
|
if (!exists) return 'absent';
|
|
@@ -1205,11 +1237,11 @@ class Installer {
|
|
|
1205
1237
|
* Returns { ready, unreadable }, plus `unknown: true` when the entry's
|
|
1206
1238
|
* creds_classifier cannot tell from the file.
|
|
1207
1239
|
*/
|
|
1208
|
-
_evaluateCredsFile(checkReady, agentType) {
|
|
1240
|
+
_evaluateCredsFile(checkReady, agentType, savedEnv = null) {
|
|
1209
1241
|
if (!this._credsFile(checkReady) || !checkReady.creds_no_parse) {
|
|
1210
1242
|
return { ready: false, unreadable: false };
|
|
1211
1243
|
}
|
|
1212
|
-
const state = this._credsFileState(checkReady, agentType);
|
|
1244
|
+
const state = this._credsFileState(checkReady, agentType, savedEnv);
|
|
1213
1245
|
return {
|
|
1214
1246
|
ready: state === 'present',
|
|
1215
1247
|
unreadable: state === 'unreadable',
|
|
@@ -1448,7 +1480,7 @@ class Installer {
|
|
|
1448
1480
|
|
|
1449
1481
|
let bootstrapEnv = this._buildShellEnv();
|
|
1450
1482
|
let installEnv;
|
|
1451
|
-
if (
|
|
1483
|
+
if (['hermes', 'qoder', 'qoder-cn'].includes(agentType) && process.platform === 'win32') {
|
|
1452
1484
|
const prepared = this._prepareWindowsPowerShellInstall(cmd, bootstrapEnv);
|
|
1453
1485
|
cmd = prepared.command;
|
|
1454
1486
|
bootstrapEnv = prepared.env;
|
|
@@ -1547,11 +1579,11 @@ class Installer {
|
|
|
1547
1579
|
let env = this._buildShellEnv();
|
|
1548
1580
|
const isWin = process.platform === 'win32';
|
|
1549
1581
|
|
|
1550
|
-
//
|
|
1551
|
-
//
|
|
1552
|
-
//
|
|
1553
|
-
//
|
|
1554
|
-
if (
|
|
1582
|
+
// Resolve a compatible host and keep inherited PowerShell 7 modules out
|
|
1583
|
+
// of Windows PowerShell. Qoder otherwise cannot load Get-FileHash when
|
|
1584
|
+
// verifying its download, just as Hermes's uv bootstrap could not load
|
|
1585
|
+
// Get-ExecutionPolicy.
|
|
1586
|
+
if (['hermes', 'qoder', 'qoder-cn'].includes(agentType) && isWin) {
|
|
1555
1587
|
const prepared = this._prepareWindowsPowerShellInstall(rawCmd, env);
|
|
1556
1588
|
rawCmd = prepared.command;
|
|
1557
1589
|
env = prepared.env;
|
|
@@ -2527,7 +2559,7 @@ class Installer {
|
|
|
2527
2559
|
throw new Error('Windows PowerShell or PowerShell 7 is required for this installer.');
|
|
2528
2560
|
}
|
|
2529
2561
|
return {
|
|
2530
|
-
command: this._retargetPowerShellCommand(command, host),
|
|
2562
|
+
command: this._retargetPowerShellCommand(this._wrapForWindowsShell(command), host),
|
|
2531
2563
|
env: this._powerShellChildEnv(env),
|
|
2532
2564
|
host,
|
|
2533
2565
|
};
|
|
@@ -3023,12 +3055,12 @@ class Installer {
|
|
|
3023
3055
|
* `Invoke-RestMethod`, etc. The launcher's install shell is cmd.exe, which
|
|
3024
3056
|
* doesn't recognize these aliases — without wrapping, e.g. Cursor's
|
|
3025
3057
|
* `irm '…' | iex` exits 255. Skips commands already prefixed with
|
|
3026
|
-
* `powershell`/`
|
|
3058
|
+
* `powershell`/`pwsh` so we don't double-wrap.
|
|
3027
3059
|
*/
|
|
3028
3060
|
_wrapForWindowsShell(cmd) {
|
|
3029
3061
|
if (!cmd || process.platform !== 'win32') return cmd;
|
|
3030
3062
|
const trimmed = cmd.trimStart();
|
|
3031
|
-
if (/^("[^"]*\\)?powershell(\.exe)?["']?\s/i.test(trimmed)) return cmd;
|
|
3063
|
+
if (/^("[^"]*\\)?(powershell|pwsh)(\.exe)?["']?\s/i.test(trimmed)) return cmd;
|
|
3032
3064
|
const psTokens = /\b(irm|iwr|iex|Invoke-RestMethod|Invoke-WebRequest|Invoke-Expression|Expand-Archive|Get-[A-Z]\w*|Set-[A-Z]\w*)\b/;
|
|
3033
3065
|
if (!psTokens.test(cmd)) return cmd;
|
|
3034
3066
|
const escaped = cmd.replace(/"/g, '\\"');
|
package/src/paths.js
CHANGED
|
@@ -525,6 +525,11 @@ function _addAgentInstallerPaths(dirs) {
|
|
|
525
525
|
// keeps off PATH.
|
|
526
526
|
_push(dirs, path.join(HOME, '.codeartsdoer', 'installers'));
|
|
527
527
|
|
|
528
|
+
// mimo — Xiaomi's install.sh / install.ps1 drop the binary into
|
|
529
|
+
// ~/.mimocode/bin (mimo.exe on Windows) and reach PATH through a shell rc
|
|
530
|
+
// edit or the user `Path` value, neither of which a GUI launch sees.
|
|
531
|
+
_push(dirs, path.join(HOME, '.mimocode', 'bin'));
|
|
532
|
+
|
|
528
533
|
// claude — `claude install` (the native, non-npm build) relocates the CLI to
|
|
529
534
|
// ~/.claude/local and reaches it through a shell alias, which a GUI process
|
|
530
535
|
// inherits no more than it inherits an rc-file PATH edit.
|
|
@@ -534,6 +539,14 @@ function _addAgentInstallerPaths(dirs) {
|
|
|
534
539
|
// _addWindowsPaths; this is the half nothing covered.
|
|
535
540
|
_push(dirs, path.join(HOME, '.hermes', 'bin'));
|
|
536
541
|
|
|
542
|
+
// qoder / qoder-cn — the official install scripts keep the binary in
|
|
543
|
+
// ~/.qoder/bin/qodercli (~/.qoder-cn/bin/qoderclicn). On Windows that dir
|
|
544
|
+
// holds qodercli.exe and reaches PATH only through the user `Path` registry
|
|
545
|
+
// value; on Unix it holds the versioned builds and the CLI is linked from
|
|
546
|
+
// ~/.local/bin, which is searched already.
|
|
547
|
+
_push(dirs, path.join(HOME, '.qoder', 'bin', 'qodercli'));
|
|
548
|
+
_push(dirs, path.join(HOME, '.qoder-cn', 'bin', 'qoderclicn'));
|
|
549
|
+
|
|
537
550
|
// Installers that let the user choose the install dir. Each of these CLIs
|
|
538
551
|
// reads an env var for its target, and a user who set one has their ONLY copy
|
|
539
552
|
// there — every hardcoded default above then finds nothing. Added rather than
|
|
@@ -544,6 +557,11 @@ function _addAgentInstallerPaths(dirs) {
|
|
|
544
557
|
if (process.env.GOOSE_BIN_DIR) _push(dirs, process.env.GOOSE_BIN_DIR);
|
|
545
558
|
if (process.env.HERMES_INSTALL_DIR) _push(dirs, process.env.HERMES_INSTALL_DIR);
|
|
546
559
|
if (process.env.HERMES_HOME) _push(dirs, path.join(process.env.HERMES_HOME, 'bin'));
|
|
560
|
+
// mimo — install.ps1 installs into MIMOCODE_INSTALL_DIR when it is set.
|
|
561
|
+
if (process.env.MIMOCODE_INSTALL_DIR) _push(dirs, process.env.MIMOCODE_INSTALL_DIR);
|
|
562
|
+
// qwen — install-qwen-standalone.sh / .ps1 read these for a custom target.
|
|
563
|
+
if (process.env.QWEN_INSTALL_BIN_DIR) _push(dirs, process.env.QWEN_INSTALL_BIN_DIR);
|
|
564
|
+
if (process.env.QWEN_INSTALL_ROOT) _push(dirs, path.join(process.env.QWEN_INSTALL_ROOT, 'bin'));
|
|
547
565
|
|
|
548
566
|
// uv — `uv tool install X` builds a venv at <uv tool dir>/X and only COPIES
|
|
549
567
|
// the executable into uv's bin dir, which reaches PATH through a shell rc
|
|
@@ -587,6 +605,9 @@ function _addAgentInstallerPaths(dirs) {
|
|
|
587
605
|
_push(dirs, path.join(lad, 'Programs', 'cursor-agent'));
|
|
588
606
|
// codebuddy's native Windows install.
|
|
589
607
|
_push(dirs, path.join(lad, 'CodeBuddy', 'bin'));
|
|
608
|
+
// qwen — install-qwen-standalone.ps1 puts its qwen.cmd wrapper here and
|
|
609
|
+
// edits the user Path; on Unix the same installer uses ~/.local/bin.
|
|
610
|
+
_push(dirs, path.join(lad, 'qwen-code', 'bin'));
|
|
590
611
|
// winget's shim dir — how GitHub Copilot CLI arrives on Windows for anyone
|
|
591
612
|
// who didn't take the npm route. The copilot adapter knew it; nothing else did.
|
|
592
613
|
_push(dirs, path.join(lad, 'Microsoft', 'WinGet', 'Links'));
|