@openagents-org/agent-launcher 0.2.210 → 0.2.212
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 +378 -6
- package/src/adapters/base.js +25 -4
- package/src/adapters/deepseek-runtime.js +31 -5
- package/src/adapters/deepseek-workspace-api.js +150 -0
- package/src/adapters/deepseek.js +51 -6
- 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/workspace-prompt.js +41 -4
- package/src/agent-login.js +93 -0
- package/src/cli-models.js +45 -2
- package/src/cli.js +117 -11
- 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
|
@@ -1041,7 +1041,7 @@ function buildOpenWorkerSystemPrompt({ agentName, workspaceId, channelName, endp
|
|
|
1041
1041
|
* constant sentence on the command line. Two consequences shape this function:
|
|
1042
1042
|
*
|
|
1043
1043
|
* - The workspace token must NEVER appear. `tokenExpr` is a SHELL EXPRESSION
|
|
1044
|
-
* (`$
|
|
1044
|
+
* (`$OPENAGENTS_WORKSPACE_AUTH`, or `$env:OPENAGENTS_WORKSPACE_AUTH` on
|
|
1045
1045
|
* Windows) that the agent expands at run time from the child environment.
|
|
1046
1046
|
* Passing the real token here would put it on disk for no benefit — and the
|
|
1047
1047
|
* guard below makes that a loud failure rather than a silent leak.
|
|
@@ -1050,17 +1050,52 @@ function buildOpenWorkerSystemPrompt({ agentName, workspaceId, channelName, endp
|
|
|
1050
1050
|
* is therefore part of the task itself rather than something the agent can
|
|
1051
1051
|
* be expected to remember.
|
|
1052
1052
|
*/
|
|
1053
|
+
/** Quote a path as a PowerShell single-quoted literal. */
|
|
1054
|
+
function psQuote(value) {
|
|
1055
|
+
return `'${String(value).replace(/'/g, "''")}'`;
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
/**
|
|
1059
|
+
* How a DeepSeek Harness run on Windows reaches the workspace API.
|
|
1060
|
+
*
|
|
1061
|
+
* dsh's Windows sandbox gives shell commands a token with no Schannel
|
|
1062
|
+
* credentials, so the `curl` recipes above fail every HTTPS request
|
|
1063
|
+
* (SEC_E_NO_CREDENTIALS) and so does Invoke-WebRequest. Node's TLS works, so the
|
|
1064
|
+
* calls go through deepseek-workspace-api.js on the adapter's own Node binary.
|
|
1065
|
+
* The recipes above stay as the reference for routes and JSON bodies.
|
|
1066
|
+
*/
|
|
1067
|
+
function buildDeepSeekWindowsApiSection({ node, helper, channelName }) {
|
|
1068
|
+
const run = `& ${psQuote(node)} ${psQuote(helper)}`;
|
|
1069
|
+
return [
|
|
1070
|
+
'## Calling the workspace API on this machine (Windows)',
|
|
1071
|
+
'This sandbox cannot open HTTPS connections with `curl.exe` or `Invoke-WebRequest` '
|
|
1072
|
+
+ '(they fail with SEC_E_NO_CREDENTIALS), so do NOT use the `curl` commands above as '
|
|
1073
|
+
+ 'written. Use them only as the reference for routes and JSON bodies, and make every '
|
|
1074
|
+
+ 'workspace call with this PowerShell helper instead. It adds the auth header itself '
|
|
1075
|
+
+ 'and prints the JSON response.',
|
|
1076
|
+
'',
|
|
1077
|
+
`- GET: \`${run} GET '/v1/files?network=...'\``,
|
|
1078
|
+
`- POST/PUT/PATCH: write the JSON body to a file with your file tool, then \`${run} POST /v1/events --body-file body.json\``,
|
|
1079
|
+
`- DELETE: \`${run} DELETE '/v1/files/FILE_ID?network=...'\``,
|
|
1080
|
+
`- Upload a file to this thread: \`${run} upload report.md --channel ${psQuote(channelName)}\``,
|
|
1081
|
+
`- Download a file: \`${run} download FILE_ID out.bin\``,
|
|
1082
|
+
'',
|
|
1083
|
+
'Never paste the workspace token into a command or a file: the helper reads it from the environment.',
|
|
1084
|
+
'',
|
|
1085
|
+
].join('\n');
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1053
1088
|
function buildDeepSeekTaskFile({
|
|
1054
1089
|
agentName, workspaceId, channelName, endpoint, tokenExpr,
|
|
1055
1090
|
mode = 'execute', disabledModules, browserEnabled = false,
|
|
1056
|
-
recap = '', request = '', attachments = '',
|
|
1091
|
+
recap = '', request = '', attachments = '', windowsApi = null,
|
|
1057
1092
|
}) {
|
|
1058
1093
|
// A token expression is a shell reference, never a credential. Anything that
|
|
1059
1094
|
// does not start with `$` is almost certainly a real token passed by mistake.
|
|
1060
1095
|
if (!tokenExpr || !/^\$/.test(String(tokenExpr))) {
|
|
1061
1096
|
throw new Error(
|
|
1062
1097
|
'buildDeepSeekTaskFile: tokenExpr must be a shell expression such as '
|
|
1063
|
-
+ '$
|
|
1098
|
+
+ '$OPENAGENTS_WORKSPACE_AUTH — never the workspace token itself.',
|
|
1064
1099
|
);
|
|
1065
1100
|
}
|
|
1066
1101
|
|
|
@@ -1072,7 +1107,9 @@ function buildDeepSeekTaskFile({
|
|
|
1072
1107
|
endpoint, workspaceId, token: tokenExpr, agentName, channelName, disabledModules, mode,
|
|
1073
1108
|
});
|
|
1074
1109
|
|
|
1075
|
-
const parts = [identity, directive, '\n', collab, '\n', modePrompt, '\n', api, '\n'
|
|
1110
|
+
const parts = [identity, directive, '\n', collab, '\n', modePrompt, '\n', api, '\n'];
|
|
1111
|
+
if (windowsApi) parts.push(buildDeepSeekWindowsApiSection({ ...windowsApi, channelName }), '\n');
|
|
1112
|
+
parts.push(buildGuardrails());
|
|
1076
1113
|
|
|
1077
1114
|
if (recap) {
|
|
1078
1115
|
parts.push(
|
|
@@ -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
|
@@ -12,22 +12,30 @@ const { AUTH_MODE_KEY, CLI_LOGIN, isCliLogin } = require('./env');
|
|
|
12
12
|
// Arg parsing
|
|
13
13
|
// ---------------------------------------------------------------------------
|
|
14
14
|
|
|
15
|
+
// Flags that may be given more than once (`agn env x --set A=1 --set B=2`).
|
|
16
|
+
// They always parse to an array; every other flag keeps its last value.
|
|
17
|
+
const REPEATABLE_FLAGS = new Set(['set']);
|
|
18
|
+
|
|
15
19
|
function parseArgs(argv) {
|
|
16
20
|
const args = argv.slice(2);
|
|
17
21
|
const flags = {};
|
|
18
22
|
const allPositional = [];
|
|
23
|
+
const setFlag = (name, value) => {
|
|
24
|
+
if (REPEATABLE_FLAGS.has(name)) (flags[name] = flags[name] || []).push(value);
|
|
25
|
+
else flags[name] = value;
|
|
26
|
+
};
|
|
19
27
|
|
|
20
28
|
for (let i = 0; i < args.length; i++) {
|
|
21
29
|
const a = args[i];
|
|
22
30
|
if (a.startsWith('--')) {
|
|
23
31
|
const eq = a.indexOf('=');
|
|
24
32
|
if (eq > 0) {
|
|
25
|
-
|
|
33
|
+
setFlag(a.slice(2, eq), a.slice(eq + 1));
|
|
26
34
|
} else if (i + 1 < args.length && !args[i + 1].startsWith('--')) {
|
|
27
|
-
|
|
35
|
+
setFlag(a.slice(2), args[i + 1]);
|
|
28
36
|
i++;
|
|
29
37
|
} else {
|
|
30
|
-
|
|
38
|
+
setFlag(a.slice(2), true);
|
|
31
39
|
}
|
|
32
40
|
} else {
|
|
33
41
|
allPositional.push(a);
|
|
@@ -820,15 +828,19 @@ async function cmdEnv(connector, flags, positional) {
|
|
|
820
828
|
const type = positional[0];
|
|
821
829
|
if (!type) { print('Usage: agn env <type> [--set KEY=VALUE]'); return; }
|
|
822
830
|
|
|
823
|
-
const
|
|
824
|
-
if (
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
const
|
|
828
|
-
const
|
|
829
|
-
|
|
831
|
+
const setVals = flags.set || [];
|
|
832
|
+
if (setVals.length) {
|
|
833
|
+
// Validate every pair before saving any, so a typo in the last one does
|
|
834
|
+
// not leave the first ones half-applied.
|
|
835
|
+
const updates = {};
|
|
836
|
+
for (const setVal of setVals) {
|
|
837
|
+
const eq = typeof setVal === 'string' ? setVal.indexOf('=') : -1;
|
|
838
|
+
if (eq < 1) { print('Usage: --set KEY=VALUE'); return; }
|
|
839
|
+
updates[setVal.slice(0, eq)] = setVal.slice(eq + 1);
|
|
840
|
+
}
|
|
841
|
+
connector.saveAgentEnv(type, updates);
|
|
830
842
|
try { connector.sendDaemonCommand('reload'); } catch {}
|
|
831
|
-
print(`Saved ${
|
|
843
|
+
print(`Saved ${Object.keys(updates).join(', ')} for ${type}`);
|
|
832
844
|
return;
|
|
833
845
|
}
|
|
834
846
|
|
|
@@ -1070,6 +1082,98 @@ async function cmdProbe(connector, flags, positional) {
|
|
|
1070
1082
|
}
|
|
1071
1083
|
}
|
|
1072
1084
|
|
|
1085
|
+
/**
|
|
1086
|
+
* `agn login <type|agent>` — run the agent CLI's own sign-in on this device.
|
|
1087
|
+
* See agent-login.js for why this is more than the bare login command.
|
|
1088
|
+
*/
|
|
1089
|
+
async function cmdLogin(connector, flags, positional) {
|
|
1090
|
+
const target = (positional[0] || '').trim();
|
|
1091
|
+
if (!target) {
|
|
1092
|
+
print('Usage: agn login <type|agent>');
|
|
1093
|
+
print("Signs the agent's own CLI in to its account on this device, e.g. agn login codex");
|
|
1094
|
+
process.exitCode = 1;
|
|
1095
|
+
return;
|
|
1096
|
+
}
|
|
1097
|
+
// A type first: the first agent of a type is often named after it.
|
|
1098
|
+
let type = target;
|
|
1099
|
+
let entry = connector.registry.getEntry(target);
|
|
1100
|
+
if (!entry) {
|
|
1101
|
+
const agent = connector.config.getAgent(target);
|
|
1102
|
+
if (agent) {
|
|
1103
|
+
type = agent.type || 'openclaw';
|
|
1104
|
+
entry = connector.registry.getEntry(type);
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
if (!entry) {
|
|
1108
|
+
print(`Unknown agent type or agent '${target}'. See: agn search`);
|
|
1109
|
+
process.exitCode = 1;
|
|
1110
|
+
return;
|
|
1111
|
+
}
|
|
1112
|
+
const label = entry.label || type;
|
|
1113
|
+
const { loginPlan } = require('./agent-login');
|
|
1114
|
+
const plan = loginPlan(entry);
|
|
1115
|
+
if (!plan) {
|
|
1116
|
+
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>`);
|
|
1117
|
+
process.exitCode = 1;
|
|
1118
|
+
return;
|
|
1119
|
+
}
|
|
1120
|
+
const bin = connector.installer.which(type);
|
|
1121
|
+
if (!bin) {
|
|
1122
|
+
print(`${label} is not installed on this device. Install it first: agn install ${type}`);
|
|
1123
|
+
process.exitCode = 1;
|
|
1124
|
+
return;
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
// wsl.spawn: a CLI installed inside a WSL distro signs in over there.
|
|
1128
|
+
const { spawn } = require('./wsl');
|
|
1129
|
+
const { getEnhancedEnv } = require('./paths');
|
|
1130
|
+
const { shouldUseShellForBinary } = require('./adapters/health-status');
|
|
1131
|
+
const shell = shouldUseShellForBinary(bin);
|
|
1132
|
+
print(`Signing in ${label}: ${[plan.command.split(/\s+/)[0], ...plan.args].join(' ')}`);
|
|
1133
|
+
if (plan.headless && plan.args.includes('--device-auth')) {
|
|
1134
|
+
print('No browser on this machine: open the link below on any device and enter the code.');
|
|
1135
|
+
}
|
|
1136
|
+
if (!process.stdin.isTTY) {
|
|
1137
|
+
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.');
|
|
1138
|
+
}
|
|
1139
|
+
print('');
|
|
1140
|
+
// The CLI owns the terminal until it is done. Ctrl+C reaches it too, and it
|
|
1141
|
+
// decides what that means; this process waits to report the result.
|
|
1142
|
+
const ignoreInterrupt = () => {};
|
|
1143
|
+
process.on('SIGINT', ignoreInterrupt);
|
|
1144
|
+
const code = await new Promise((resolve) => {
|
|
1145
|
+
let child;
|
|
1146
|
+
try {
|
|
1147
|
+
child = spawn(shell ? `"${bin}"` : bin, plan.args, {
|
|
1148
|
+
stdio: 'inherit',
|
|
1149
|
+
env: getEnhancedEnv(),
|
|
1150
|
+
shell,
|
|
1151
|
+
});
|
|
1152
|
+
} catch (e) {
|
|
1153
|
+
print(`Could not start ${bin}: ${e.message}`);
|
|
1154
|
+
resolve(1);
|
|
1155
|
+
return;
|
|
1156
|
+
}
|
|
1157
|
+
child.on('error', (e) => { print(`Could not start ${bin}: ${e.message}`); resolve(1); });
|
|
1158
|
+
child.on('exit', (c) => resolve(c == null ? 1 : c));
|
|
1159
|
+
});
|
|
1160
|
+
process.removeListener('SIGINT', ignoreInterrupt);
|
|
1161
|
+
|
|
1162
|
+
// The CLI's word is not enough (some exit 0 on a cancelled login): ask the
|
|
1163
|
+
// same readiness check the daemon uses, with keys not counting.
|
|
1164
|
+
let ready = false;
|
|
1165
|
+
try { ready = !!connector.installer.healthCheck(type, { cliLogin: true }).ready; } catch {}
|
|
1166
|
+
// Have a running daemon re-detect and report, so the workspace updates now.
|
|
1167
|
+
try { connector.sendDaemonCommand('detect'); } catch {}
|
|
1168
|
+
print('');
|
|
1169
|
+
if (ready) {
|
|
1170
|
+
print(`✓ ${label} is signed in on this device. The workspace will show it as ready shortly.`);
|
|
1171
|
+
} else {
|
|
1172
|
+
print(`✗ ${label} is still not signed in${code ? ` (the login exited with code ${code})` : ''}.`);
|
|
1173
|
+
process.exitCode = 1;
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1073
1177
|
async function cmdModels(connector, flags, positional) {
|
|
1074
1178
|
const target = positional[0];
|
|
1075
1179
|
if (!target) { print('Usage: agn models <type|agent> [--json] [--sign-in]'); return; }
|
|
@@ -1168,6 +1272,7 @@ Commands:
|
|
|
1168
1272
|
stop <name> Stop a single agent
|
|
1169
1273
|
install <type> Install an agent runtime
|
|
1170
1274
|
uninstall <type> Uninstall an agent runtime
|
|
1275
|
+
login <type|agent> Sign the agent's own CLI in to its account (e.g. agn login codex)
|
|
1171
1276
|
search [query] Browse agent catalog
|
|
1172
1277
|
runtimes List installed runtimes
|
|
1173
1278
|
device connect <code> Pair this device (formerly "node") to a workspace with a pairing code
|
|
@@ -1275,6 +1380,7 @@ async function main() {
|
|
|
1275
1380
|
'test-llm': () => cmdTestLLM(connector, flags, positional),
|
|
1276
1381
|
probe: () => cmdProbe(connector, flags, positional),
|
|
1277
1382
|
models: () => cmdModels(connector, flags, positional),
|
|
1383
|
+
login: () => cmdLogin(connector, flags, positional),
|
|
1278
1384
|
update: () => cmdUpdate(connector),
|
|
1279
1385
|
'mcp-server': () => {
|
|
1280
1386
|
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
|
};
|