@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/src/installer.js CHANGED
@@ -3,7 +3,7 @@
3
3
  const fs = require('fs');
4
4
  const os = require('os');
5
5
  const path = require('path');
6
- const { execSync, exec, execFile, spawnSync } = require('child_process');
6
+ const { execSync, execFileSync, exec, execFile, spawnSync } = require('child_process');
7
7
  const {
8
8
  whichBinary,
9
9
  getEnhancedEnv,
@@ -19,7 +19,8 @@ const {
19
19
  const { isWslBinary, bridgedCommandString, wslHomeUnc } = require('./wsl');
20
20
  const { canBlock } = require('./probe-mode');
21
21
  const { EnvManager } = require('./env');
22
- const { nodeDistUrls, installRegistry } = require('./mirrors');
22
+ const { nodeDistUrls, installRegistry, userConfiguredRegistry } = require('./mirrors');
23
+ const { resolveInstallableVersion, fetchPackument, unpinnedPackage } = require('./node-engines');
23
24
  const { readinessReason, REASON } = require('./adapters/health-status');
24
25
  const { resolveCursorNodeEntry } = require('./adapters/cursor-node-entry');
25
26
  const { checkInstallPrereqs, missingPrereqError } = require('./install-preflight');
@@ -919,7 +920,7 @@ class Installer {
919
920
  // ~/.gemini/oauth_creds.json) or a service-account file path, WITHOUT
920
921
  // parsing or logging the token. Additive: agents that don't declare
921
922
  // creds_no_parse / creds_path_env get identical behavior to before.
922
- const credsFile = this._evaluateCredsFile(checkReady, agentType);
923
+ const credsFile = this._evaluateCredsFile(checkReady, agentType, savedEnv);
923
924
  const credsPathReady = this._checkCredsPathEnv(checkReady, savedEnv, agentType);
924
925
 
925
926
  let cliReady = false;
@@ -981,7 +982,7 @@ class Installer {
981
982
  // agent never needs.
982
983
  const credsReady = checkReady.creds_json_has_entries
983
984
  ? false
984
- : this._checkCredsReady(checkReady, agentType);
985
+ : this._checkCredsReady(checkReady, agentType, savedEnv);
985
986
  if (credsReady || credsFile.ready || credsPathReady) {
986
987
  return {
987
988
  ready: true,
@@ -1072,10 +1073,10 @@ class Installer {
1072
1073
  return checkReady.creds_file || null;
1073
1074
  }
1074
1075
 
1075
- _checkCredsReady(checkReady, agentType) {
1076
+ _checkCredsReady(checkReady, agentType, savedEnv = null) {
1076
1077
  if (this._credsFile(checkReady)) {
1077
1078
  try {
1078
- const credsPath = this._expandHome(this._credsFile(checkReady), agentType);
1079
+ const credsPath = this._credsFilePath(checkReady, agentType, savedEnv);
1079
1080
  if (fs.existsSync(credsPath)) {
1080
1081
  const stat = fs.statSync(credsPath);
1081
1082
  if (stat.isDirectory()) return fs.readdirSync(credsPath).length > 0;
@@ -1105,6 +1106,38 @@ class Installer {
1105
1106
  return false;
1106
1107
  }
1107
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
+
1108
1141
  /**
1109
1142
  * Expand a leading "~" to the home directory the AGENT writes its sign-in to.
1110
1143
  *
@@ -1155,9 +1188,9 @@ class Installer {
1155
1188
  * against the running user's home (the daemon/launcher user), not the
1156
1189
  * renderer/browser user.
1157
1190
  */
1158
- _credsFileState(checkReady, agentType) {
1191
+ _credsFileState(checkReady, agentType, savedEnv = null) {
1159
1192
  if (!this._credsFile(checkReady)) return 'absent';
1160
- const p = this._expandHome(this._credsFile(checkReady), agentType);
1193
+ const p = this._credsFilePath(checkReady, agentType, savedEnv);
1161
1194
  let exists = false;
1162
1195
  try { exists = fs.existsSync(p); } catch { return 'unreadable'; }
1163
1196
  if (!exists) return 'absent';
@@ -1204,11 +1237,11 @@ class Installer {
1204
1237
  * Returns { ready, unreadable }, plus `unknown: true` when the entry's
1205
1238
  * creds_classifier cannot tell from the file.
1206
1239
  */
1207
- _evaluateCredsFile(checkReady, agentType) {
1240
+ _evaluateCredsFile(checkReady, agentType, savedEnv = null) {
1208
1241
  if (!this._credsFile(checkReady) || !checkReady.creds_no_parse) {
1209
1242
  return { ready: false, unreadable: false };
1210
1243
  }
1211
- const state = this._credsFileState(checkReady, agentType);
1244
+ const state = this._credsFileState(checkReady, agentType, savedEnv);
1212
1245
  return {
1213
1246
  ready: state === 'present',
1214
1247
  unreadable: state === 'unreadable',
@@ -1447,7 +1480,7 @@ class Installer {
1447
1480
 
1448
1481
  let bootstrapEnv = this._buildShellEnv();
1449
1482
  let installEnv;
1450
- if (agentType === 'hermes' && process.platform === 'win32') {
1483
+ if (['hermes', 'qoder', 'qoder-cn'].includes(agentType) && process.platform === 'win32') {
1451
1484
  const prepared = this._prepareWindowsPowerShellInstall(cmd, bootstrapEnv);
1452
1485
  cmd = prepared.command;
1453
1486
  bootstrapEnv = prepared.env;
@@ -1546,11 +1579,11 @@ class Installer {
1546
1579
  let env = this._buildShellEnv();
1547
1580
  const isWin = process.platform === 'win32';
1548
1581
 
1549
- // Hermes's registry command names the inbox Windows PowerShell host for
1550
- // compatibility, but some Windows environments expose only PowerShell 7.
1551
- // Resolve the host that actually exists and keep module paths from the
1552
- // launcher's own PowerShell runtime out of both installer processes.
1553
- if (agentType === 'hermes' && isWin) {
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) {
1554
1587
  const prepared = this._prepareWindowsPowerShellInstall(rawCmd, env);
1555
1588
  rawCmd = prepared.command;
1556
1589
  env = prepared.env;
@@ -1589,6 +1622,12 @@ class Installer {
1589
1622
  // on next install). --registry is added only when we'd be helping — see
1590
1623
  // installRegistry(); a user's own registry choice is never overridden.
1591
1624
  const registry = installRegistry();
1625
+ const direct = this._resolveNodeNpmCli();
1626
+ // `latest` may need a Node newer than the one that will run it.
1627
+ if (direct) {
1628
+ const held = await this._holdBackForNode(pkgArgs, direct.node, registry, onData);
1629
+ pkgArgs.splice(0, pkgArgs.length, ...held);
1630
+ }
1592
1631
  // The verbose log stays: it is the install's progress, and the output the
1593
1632
  // stall watchdog below waits on.
1594
1633
  const npmArgs = [
@@ -1598,7 +1637,6 @@ class Installer {
1598
1637
  ];
1599
1638
  displayCmd = `npm ${npmArgs.join(' ')}`;
1600
1639
 
1601
- const direct = this._resolveNodeNpmCli();
1602
1640
  if (direct) {
1603
1641
  spawnFile = direct.node;
1604
1642
  spawnArgs = [direct.npmCli, ...npmArgs];
@@ -2521,7 +2559,7 @@ class Installer {
2521
2559
  throw new Error('Windows PowerShell or PowerShell 7 is required for this installer.');
2522
2560
  }
2523
2561
  return {
2524
- command: this._retargetPowerShellCommand(command, host),
2562
+ command: this._retargetPowerShellCommand(this._wrapForWindowsShell(command), host),
2525
2563
  env: this._powerShellChildEnv(env),
2526
2564
  host,
2527
2565
  };
@@ -2671,6 +2709,46 @@ class Installer {
2671
2709
  return false;
2672
2710
  }
2673
2711
 
2712
+ /**
2713
+ * Swap an unpinned package (`pkg`, `pkg@latest`) for the newest release
2714
+ * whose `engines.node` accepts the Node that will run it. openclaw raises
2715
+ * its floor without notice (2026.10.6 wanted Node 24.22.1 while the runtime
2716
+ * was 24.21.0) and its preinstall exits 1 below it, so a workspace's remote
2717
+ * "create agent" — which installs here, not through the launcher's own
2718
+ * holdback — failed on every such machine. Anything uncertain (no Node
2719
+ * version, registry unreachable, unreadable range) leaves the args alone.
2720
+ *
2721
+ * @param {string[]} pkgArgs
2722
+ * @param {string} nodeBin the node npm runs under
2723
+ * @param {string|null} registry the `--registry` this install will use
2724
+ * @param {function(string)} [onData]
2725
+ * @returns {Promise<string[]>}
2726
+ */
2727
+ async _holdBackForNode(pkgArgs, nodeBin, registry, onData) {
2728
+ const pkgs = pkgArgs.filter((a) => !a.startsWith('-'));
2729
+ if (pkgs.length !== 1) return pkgArgs;
2730
+ const pkg = unpinnedPackage(pkgs[0]);
2731
+ if (!pkg) return pkgArgs;
2732
+ let nodeVersion;
2733
+ try {
2734
+ nodeVersion = execFileSync(nodeBin, ['-v'], { encoding: 'utf-8', timeout: 5000, windowsHide: true }).trim();
2735
+ } catch { return pkgArgs; }
2736
+ let info;
2737
+ try {
2738
+ info = await fetchPackument(registry || userConfiguredRegistry() || 'https://registry.npmjs.org', pkg);
2739
+ } catch { return pkgArgs; }
2740
+ const latest = info && info['dist-tags'] && info['dist-tags'].latest;
2741
+ const target = resolveInstallableVersion(info, nodeVersion);
2742
+ if (!latest || !target || target === latest) return pkgArgs;
2743
+ const range = info.versions && info.versions[latest] && info.versions[latest].engines
2744
+ && info.versions[latest].engines.node;
2745
+ if (onData) {
2746
+ onData(`${pkg}@${latest} requires Node ${range}, but agents here run on Node ${nodeVersion} — `
2747
+ + `installing ${target}, the newest release that supports it.\n\n`);
2748
+ }
2749
+ return pkgArgs.map((a) => (a === pkgs[0] ? `${pkg}@${target}` : a));
2750
+ }
2751
+
2674
2752
  /**
2675
2753
  * The Node.js the portable runtime gets — the same pin as the launcher's
2676
2754
  * bootstrap/node-version.ts, which owns upgrading an existing runtime; this
@@ -2682,7 +2760,7 @@ class Installer {
2682
2760
  const [major, minor] = String(release).split('.').map(Number);
2683
2761
  if (major < 22 || (major === 22 && minor < 6)) return 'v22.22.3';
2684
2762
  }
2685
- return 'v24.21.0';
2763
+ return 'v24.22.1';
2686
2764
  }
2687
2765
 
2688
2766
  /**
@@ -2977,12 +3055,12 @@ class Installer {
2977
3055
  * `Invoke-RestMethod`, etc. The launcher's install shell is cmd.exe, which
2978
3056
  * doesn't recognize these aliases — without wrapping, e.g. Cursor's
2979
3057
  * `irm '…' | iex` exits 255. Skips commands already prefixed with
2980
- * `powershell`/`powershell.exe` so we don't double-wrap.
3058
+ * `powershell`/`pwsh` so we don't double-wrap.
2981
3059
  */
2982
3060
  _wrapForWindowsShell(cmd) {
2983
3061
  if (!cmd || process.platform !== 'win32') return cmd;
2984
3062
  const trimmed = cmd.trimStart();
2985
- if (/^("[^"]*\\)?powershell(\.exe)?["']?\s/i.test(trimmed)) return cmd;
3063
+ if (/^("[^"]*\\)?(powershell|pwsh)(\.exe)?["']?\s/i.test(trimmed)) return cmd;
2986
3064
  const psTokens = /\b(irm|iwr|iex|Invoke-RestMethod|Invoke-WebRequest|Invoke-Expression|Expand-Archive|Get-[A-Z]\w*|Set-[A-Z]\w*)\b/;
2987
3065
  if (!psTokens.test(cmd)) return cmd;
2988
3066
  const escaped = cmd.replace(/"/g, '\\"');
@@ -0,0 +1,173 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Which release of an npm agent can run on the Node that will run it.
5
+ *
6
+ * Every npm agent is installed and run on one Node — the portable runtime in
7
+ * ~/.openagents/nodejs. npm only warns when a package's `engines.node` rules
8
+ * that Node out, so `npm install <pkg>` happily fetches a `latest` the runtime
9
+ * cannot start, and some packages then refuse on their own: openclaw's
10
+ * preinstall exits 1 below its floor (2026.9.3 → Node 24.16, 2026.10.6 →
11
+ * 24.22.1). The launcher's Install button already held such packages back to
12
+ * the newest release that runs; a workspace's remote "create agent" goes
13
+ * through the daemon and this installer instead, and failed outright.
14
+ *
15
+ * Mirrors the launcher's main/agents/node-engines.ts + npm-registry.ts. The
16
+ * grammar read is what packages write in `engines.node`: comparators
17
+ * (>= > <= < =), bare and partial versions (22, 22.1, 22.x, *), caret, tilde,
18
+ * hyphen ranges and `||`. Anything else answers null ("can't tell"), which
19
+ * counts as compatible: a wrong "no" would hold an agent back for nothing.
20
+ */
21
+
22
+ const https = require('https');
23
+ const http = require('http');
24
+
25
+ const PARTIAL = /^v?(\d+|[xX*])(?:\.(\d+|[xX*]))?(?:\.(\d+|[xX*]))?$/;
26
+
27
+ function parsePartial(s) {
28
+ const m = PARTIAL.exec(s);
29
+ if (!m) return null;
30
+ const parts = [m[1], m[2], m[3]].map((p) => (p === undefined || /^[xX*]$/.test(p) ? null : Number(p)));
31
+ const wild = parts.indexOf(null);
32
+ return wild === -1 ? parts : parts.map((p, i) => (i < wild ? p : null));
33
+ }
34
+
35
+ function compare(a, b) {
36
+ for (let i = 0; i < 3; i++) if (a[i] !== b[i]) return a[i] < b[i] ? -1 : 1;
37
+ return 0;
38
+ }
39
+
40
+ /** One comparator as the [lo, hi) interval it allows, or null when unreadable. */
41
+ function toInterval(comparator) {
42
+ const m = /^(>=|<=|>|<|=|\^|~)?(.*)$/.exec(comparator);
43
+ const parts = m && parsePartial(m[2]);
44
+ if (!m || !parts) return null;
45
+ const op = m[1] || '=';
46
+ const [major, minor, patch] = parts;
47
+ if (major === null) return op === '<' || op === '>' ? null : {};
48
+ const lo = [major, minor ?? 0, patch ?? 0];
49
+ const next = minor === null ? [major + 1, 0, 0]
50
+ : patch === null ? [major, minor + 1, 0]
51
+ : [major, minor, patch + 1];
52
+ switch (op) {
53
+ case '>=': return { lo };
54
+ case '>': return { lo: next };
55
+ case '<': return { hi: lo };
56
+ case '<=': return { hi: next };
57
+ case '~': return { lo, hi: minor === null ? [major + 1, 0, 0] : [major, minor + 1, 0] };
58
+ case '^': return {
59
+ lo,
60
+ hi: major > 0 || minor === null ? [major + 1, 0, 0]
61
+ : minor > 0 || patch === null ? [0, minor + 1, 0]
62
+ : [0, 0, patch + 1],
63
+ };
64
+ default: return { lo, hi: next };
65
+ }
66
+ }
67
+
68
+ function parseSet(set) {
69
+ const s = set.trim();
70
+ const hyphen = /^(\S+)\s+-\s+(\S+)$/.exec(s);
71
+ const comparators = hyphen
72
+ ? [`>=${hyphen[1]}`, `<=${hyphen[2]}`]
73
+ : s.replace(/(>=|<=|>|<|=|\^|~)\s+/g, '$1').split(/\s+/).filter(Boolean);
74
+ const out = [];
75
+ for (const c of comparators) {
76
+ const interval = toInterval(c);
77
+ if (!interval) return null;
78
+ out.push(interval);
79
+ }
80
+ return out;
81
+ }
82
+
83
+ /** true / false when the range can be read, null when it can't. */
84
+ function nodeSatisfies(version, range) {
85
+ const v = parsePartial(String(version || '').trim());
86
+ if (!v || v.includes(null)) return null;
87
+ let unreadable = false;
88
+ for (const set of String(range).split('||')) {
89
+ const intervals = parseSet(set);
90
+ if (!intervals) { unreadable = true; continue; }
91
+ if (intervals.every(({ lo, hi }) => (!lo || compare(v, lo) >= 0) && (!hi || compare(v, hi) < 0))) return true;
92
+ }
93
+ return unreadable ? null : false;
94
+ }
95
+
96
+ function compareVersionsDesc(a, b) {
97
+ const pa = a.split('.').map((n) => parseInt(n, 10) || 0);
98
+ const pb = b.split('.').map((n) => parseInt(n, 10) || 0);
99
+ for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
100
+ const x = pa[i] || 0;
101
+ const y = pb[i] || 0;
102
+ if (x !== y) return y - x;
103
+ }
104
+ return 0;
105
+ }
106
+
107
+ function nodeEngineRange(info, version) {
108
+ const range = info && info.versions && info.versions[version] && info.versions[version].engines
109
+ && info.versions[version].engines.node;
110
+ return typeof range === 'string' && range.trim() ? range : null;
111
+ }
112
+
113
+ /**
114
+ * The version to install on `nodeVersion`: `latest` when it accepts that Node,
115
+ * else the newest earlier stable release that does. `latest` comes back
116
+ * unchanged when the Node is unknown or nothing accepts it — npm or the
117
+ * package then says why in its own words.
118
+ */
119
+ function resolveInstallableVersion(info, nodeVersion) {
120
+ const versions = Object.keys((info && info.versions) || {});
121
+ const latest = (info && info['dist-tags'] && info['dist-tags'].latest)
122
+ || versions.filter((v) => /^\d/.test(v) && !v.includes('-')).sort(compareVersionsDesc)[0]
123
+ || null;
124
+ if (!latest || !nodeVersion) return latest;
125
+ const runs = (v) => {
126
+ const range = nodeEngineRange(info, v);
127
+ return !range || nodeSatisfies(nodeVersion, range) !== false;
128
+ };
129
+ if (runs(latest)) return latest;
130
+ const older = versions
131
+ .filter((v) => /^\d/.test(v) && !v.includes('-'))
132
+ .sort(compareVersionsDesc)
133
+ .find((v) => compareVersionsDesc(v, latest) > 0 && runs(v));
134
+ return older || latest;
135
+ }
136
+
137
+ /** npm's abbreviated packument: dist-tags plus each version's engines. */
138
+ function fetchPackument(registry, pkg, { timeoutMs = 10000 } = {}) {
139
+ const url = `${String(registry).replace(/\/+$/, '')}/${encodeURIComponent(pkg).replace('%40', '@')}`;
140
+ const get = (target, hops) => new Promise((resolve, reject) => {
141
+ const mod = target.startsWith('https:') ? https : http;
142
+ const req = mod.get(target, { headers: { Accept: 'application/vnd.npm.install-v1+json' } }, (res) => {
143
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location && hops < 3) {
144
+ res.resume();
145
+ get(new URL(res.headers.location, target).toString(), hops + 1).then(resolve, reject);
146
+ return;
147
+ }
148
+ if (res.statusCode !== 200) { res.resume(); reject(new Error(`HTTP ${res.statusCode}`)); return; }
149
+ let data = '';
150
+ res.setEncoding('utf-8');
151
+ res.on('data', (c) => { data += c; });
152
+ res.on('end', () => { try { resolve(JSON.parse(data)); } catch (e) { reject(e); } });
153
+ });
154
+ req.on('error', reject);
155
+ req.setTimeout(timeoutMs, () => req.destroy(new Error('npm registry timeout')));
156
+ });
157
+ return get(url, 0);
158
+ }
159
+
160
+ /** `openclaw`, `openclaw@latest`, `@scope/pkg@latest` → the package name; null for a pinned spec. */
161
+ function unpinnedPackage(arg) {
162
+ const m = /^(@[^/@\s]+\/[^@\s]+|[^@\s][^@\s]*)(?:@(.*))?$/.exec(String(arg || ''));
163
+ if (!m) return null;
164
+ const spec = m[2];
165
+ return spec === undefined || spec === '' || spec === 'latest' ? m[1] : null;
166
+ }
167
+
168
+ module.exports = {
169
+ nodeSatisfies,
170
+ resolveInstallableVersion,
171
+ fetchPackument,
172
+ unpinnedPackage,
173
+ };
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'));
package/src/probe.js CHANGED
@@ -538,6 +538,20 @@ async function probeAgentType(connector, type, opts = {}) {
538
538
  reply: tail(reply, REPLY_CAP),
539
539
  });
540
540
  }
541
+ // The model answered and the CLI then failed to exit — Claude Code held
542
+ // open by a hook or an MCP server reads "Timed out after 120s: Hi! What
543
+ // can I help you with?". Sign-in, endpoint and model all just worked, and
544
+ // chat runs the CLI as a long-lived process where exiting never matters.
545
+ // Only for output that reads as an answer, never as a retry or an error.
546
+ const looksLikeAnswer = reply && !classifyOutputText(output.toLowerCase())
547
+ && !/\b(error|errors|failed|failure|retrying|exception)\b/i.test(reply);
548
+ if (res.timedOut && !res.spawnError && looksLikeAnswer) {
549
+ return done({
550
+ ok: true, method: 'cli', code: CODE.OK,
551
+ message: `Responded (the CLI did not exit within ${Math.round(timeoutMs / 1000)}s)`,
552
+ reply: tail(reply, REPLY_CAP),
553
+ });
554
+ }
541
555
  let code = res.code === 0 && !res.timedOut && !res.spawnError
542
556
  ? CODE.EMPTY_RESPONSE
543
557
  : classifyFailure(output, res);
@@ -573,7 +587,50 @@ async function probeAgentType(connector, type, opts = {}) {
573
587
 
574
588
  // ── Live tier 2: direct LLM API call for API-key agents (e.g. OpenClaw) ──
575
589
  if (canCallDirect || (entry.install && entry.install.api_only && reachable)) {
576
- const res = await callLLM(agentEnv, model, baseUrl, protocol);
590
+ let apiEnv = agentEnv;
591
+ let apiModel = model;
592
+ let apiBaseUrl = baseUrl;
593
+ if (type === 'mimo-code' && agentEnv.LLM_API_KEY) {
594
+ // The runtime owns MiMo's defaults and provider/model normalization.
595
+ // Generic API defaults would send a MiMo key/model to OpenAI instead.
596
+ const { resolveMimoRoute, parseMimoModelList, pickMimoModel } = require('./adapters/mimo-code-runtime');
597
+ let route = resolveMimoRoute(agentEnv);
598
+ if (!route.model && route.providerId === 'xiaomi' && health.binary) {
599
+ const listEnv = { ...env };
600
+ delete listEnv.LLM_API_KEY;
601
+ delete listEnv.XIAOMI_API_KEY;
602
+ const shell = shouldUseShellForBinary(health.binary);
603
+ const command = shell ? '"' + health.binary + '"' : health.binary;
604
+ const listed = await runCommand(command, ['models', 'xiaomi'], {
605
+ env: {
606
+ ...listEnv,
607
+ MIMOCODE_AUTH_CONTENT: '{}',
608
+ MIMOCODE_CONFIG_CONTENT: JSON.stringify({ enabled_providers: ['xiaomi'], disabled_providers: [] }),
609
+ MIMOCODE_DISABLE_AUTOUPDATE: '1',
610
+ },
611
+ timeoutMs,
612
+ shell,
613
+ });
614
+ if (!listed.timedOut && !listed.spawnError && listed.code === 0) {
615
+ route = resolveMimoRoute(agentEnv, null, {
616
+ fallbackModel: pickMimoModel(parseMimoModelList(listed.stdout)),
617
+ });
618
+ }
619
+ }
620
+ if (!route.model) {
621
+ return done({
622
+ ok: false, method: 'none', code: CODE.BAD_MODEL,
623
+ message: 'No model is configured and no default model could be resolved. Select a model and test again.',
624
+ guidance: buildGuidance(CODE.BAD_MODEL, entry, agentEnv),
625
+ });
626
+ }
627
+ // Match the runtime's credential choice, even if unrelated provider
628
+ // variables were saved alongside this agent's LLM_* configuration.
629
+ apiEnv = { LLM_API_KEY: route.apiKey, LLM_BASE_URL: route.baseURL, LLM_MODEL: route.model };
630
+ apiModel = route.model;
631
+ apiBaseUrl = route.baseURL;
632
+ }
633
+ const res = await callLLM(apiEnv, apiModel, apiBaseUrl, protocol);
577
634
  if (res && res.success) {
578
635
  return done({
579
636
  ok: true, method: 'llm_api', code: CODE.OK,
@@ -627,11 +627,12 @@ class WorkspaceClient {
627
627
  * Skill Hub UI can render installing / installed / failed states. Best
628
628
  * effort — returns the updated payload or throws (caller decides).
629
629
  */
630
- async reportSkillStatus(workspaceId, agentName, token, { skillId, state, path: installPath, error, partial } = {}) {
630
+ async reportSkillStatus(workspaceId, agentName, token, { skillId, state, path: installPath, error, partial, versionId } = {}) {
631
631
  const body = { skill_id: skillId, state };
632
632
  if (installPath) body.path = installPath;
633
633
  if (error) body.error = String(error).slice(0, 2000);
634
634
  if (partial) body.partial = true;
635
+ if (versionId) body.version_id = versionId;
635
636
  const data = await this._post(
636
637
  `/v1/workspaces/${workspaceId}/members/${encodeURIComponent(agentName)}/skills/status`,
637
638
  body,
@@ -815,6 +816,16 @@ class WorkspaceClient {
815
816
  return this._getRaw(`/v1/files/${fileId}?${params}`, this._wsHeaders(token), 60000);
816
817
  }
817
818
 
819
+ /** Download an immutable public registry version. */
820
+ async readRegistryVersion(versionId, token) {
821
+ if (!versionId) throw new Error('registry version id is required');
822
+ return this._getRaw(
823
+ `/v1/registry/versions/${encodeURIComponent(versionId)}/download`,
824
+ this._wsHeaders(token),
825
+ 60000,
826
+ );
827
+ }
828
+
818
829
  /**
819
830
  * Delete a file via DELETE /v1/files/{fileId}.
820
831
  */
@@ -934,10 +945,11 @@ class WorkspaceClient {
934
945
  return data.data || data;
935
946
  }
936
947
 
937
- async getTodos(workspaceId, channelName, token, { agent, all } = {}) {
948
+ async getTodos(workspaceId, channelName, token, { agent, all, source } = {}) {
938
949
  const params = new URLSearchParams({ network: workspaceId });
939
950
  if (channelName) params.set('channel', channelName);
940
951
  if (agent) params.set('agent', agent);
952
+ if (source) params.set('source', source);
941
953
  if (all) params.set('all', 'true');
942
954
  const data = await this._get(`/v1/todos?${params}`, this._wsHeaders(token));
943
955
  return data.data || data;