@openagents-org/agent-launcher 0.2.218 → 0.2.220

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.
Files changed (36) hide show
  1. package/node_modules/ws/LICENSE +20 -0
  2. package/node_modules/ws/README.md +548 -0
  3. package/node_modules/ws/browser.js +8 -0
  4. package/node_modules/ws/index.js +22 -0
  5. package/node_modules/ws/lib/buffer-util.js +131 -0
  6. package/node_modules/ws/lib/constants.js +19 -0
  7. package/node_modules/ws/lib/event-target.js +292 -0
  8. package/node_modules/ws/lib/extension.js +203 -0
  9. package/node_modules/ws/lib/limiter.js +55 -0
  10. package/node_modules/ws/lib/permessage-deflate.js +528 -0
  11. package/node_modules/ws/lib/receiver.js +706 -0
  12. package/node_modules/ws/lib/sender.js +602 -0
  13. package/node_modules/ws/lib/stream.js +161 -0
  14. package/node_modules/ws/lib/subprotocol.js +62 -0
  15. package/node_modules/ws/lib/validation.js +152 -0
  16. package/node_modules/ws/lib/websocket-server.js +554 -0
  17. package/node_modules/ws/lib/websocket.js +1393 -0
  18. package/node_modules/ws/package.json +70 -0
  19. package/node_modules/ws/wrapper.mjs +21 -0
  20. package/package.json +5 -2
  21. package/registry.json +12 -2
  22. package/src/adapters/claude.js +13 -9
  23. package/src/adapters/codearts.js +1 -0
  24. package/src/adapters/codex.js +49 -9
  25. package/src/adapters/deepseek-runtime.js +6 -2
  26. package/src/adapters/kimi-stream.js +78 -5
  27. package/src/adapters/kimi.js +114 -24
  28. package/src/adapters/mimo-code.js +1 -0
  29. package/src/adapters/openclaw.js +24 -19
  30. package/src/adapters/opencode.js +55 -2
  31. package/src/adapters/utils.js +11 -0
  32. package/src/daemon.js +4 -2
  33. package/src/installer.js +206 -36
  34. package/src/native-build.js +132 -0
  35. package/src/probe.js +88 -7
  36. package/src/utils.js +123 -12
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "ws",
3
+ "version": "8.20.0",
4
+ "description": "Simple to use, blazing fast and thoroughly tested websocket client and server for Node.js",
5
+ "keywords": [
6
+ "HyBi",
7
+ "Push",
8
+ "RFC-6455",
9
+ "WebSocket",
10
+ "WebSockets",
11
+ "real-time"
12
+ ],
13
+ "homepage": "https://github.com/websockets/ws",
14
+ "bugs": "https://github.com/websockets/ws/issues",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/websockets/ws.git"
18
+ },
19
+ "author": "Einar Otto Stangvik <einaros@gmail.com> (http://2x.io)",
20
+ "license": "MIT",
21
+ "main": "index.js",
22
+ "exports": {
23
+ ".": {
24
+ "browser": "./browser.js",
25
+ "import": "./wrapper.mjs",
26
+ "require": "./index.js"
27
+ },
28
+ "./package.json": "./package.json"
29
+ },
30
+ "browser": "browser.js",
31
+ "engines": {
32
+ "node": ">=10.0.0"
33
+ },
34
+ "files": [
35
+ "browser.js",
36
+ "index.js",
37
+ "lib/*.js",
38
+ "wrapper.mjs"
39
+ ],
40
+ "scripts": {
41
+ "test": "nyc --reporter=lcov --reporter=text mocha --throw-deprecation test/*.test.js",
42
+ "integration": "mocha --throw-deprecation test/*.integration.js",
43
+ "lint": "eslint . && prettier --check --ignore-path .gitignore \"**/*.{json,md,yaml,yml}\""
44
+ },
45
+ "peerDependencies": {
46
+ "bufferutil": "^4.0.1",
47
+ "utf-8-validate": ">=5.0.2"
48
+ },
49
+ "peerDependenciesMeta": {
50
+ "bufferutil": {
51
+ "optional": true
52
+ },
53
+ "utf-8-validate": {
54
+ "optional": true
55
+ }
56
+ },
57
+ "devDependencies": {
58
+ "@eslint/js": "^10.0.1",
59
+ "benchmark": "^2.1.4",
60
+ "bufferutil": "^4.0.1",
61
+ "eslint": "^10.0.1",
62
+ "eslint-config-prettier": "^10.0.1",
63
+ "eslint-plugin-prettier": "^5.0.0",
64
+ "globals": "^17.0.0",
65
+ "mocha": "^8.4.0",
66
+ "nyc": "^15.0.0",
67
+ "prettier": "^3.0.0",
68
+ "utf-8-validate": "^6.0.0"
69
+ }
70
+ }
@@ -0,0 +1,21 @@
1
+ import createWebSocketStream from './lib/stream.js';
2
+ import extension from './lib/extension.js';
3
+ import PerMessageDeflate from './lib/permessage-deflate.js';
4
+ import Receiver from './lib/receiver.js';
5
+ import Sender from './lib/sender.js';
6
+ import subprotocol from './lib/subprotocol.js';
7
+ import WebSocket from './lib/websocket.js';
8
+ import WebSocketServer from './lib/websocket-server.js';
9
+
10
+ export {
11
+ createWebSocketStream,
12
+ extension,
13
+ PerMessageDeflate,
14
+ Receiver,
15
+ Sender,
16
+ subprotocol,
17
+ WebSocket,
18
+ WebSocketServer
19
+ };
20
+
21
+ export default WebSocket;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openagents-org/agent-launcher",
3
- "version": "0.2.218",
3
+ "version": "0.2.220",
4
4
  "description": "OpenAgents Launcher — install, configure, and run AI coding agents from your terminal",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -42,5 +42,8 @@
42
42
  "dependencies": {
43
43
  "blessed": "^0.1.81",
44
44
  "ws": "^8.18.0"
45
- }
45
+ },
46
+ "bundleDependencies": [
47
+ "ws"
48
+ ]
46
49
  }
package/registry.json CHANGED
@@ -833,7 +833,13 @@
833
833
  "saved_env_key": "COPILOT_GITHUB_TOKEN",
834
834
  "login_command": "copilot",
835
835
  "unverifiable": true,
836
- "not_ready_message": "Sign-in not confirmed. A token env var (COPILOT_GITHUB_TOKEN/GH_TOKEN/GITHUB_TOKEN) is one option; you may already be signed in via `copilot` /login or `gh auth`. Auth is confirmed when you run a task."
836
+ "creds_file": "~/.copilot/config.json",
837
+ "creds_no_parse": true,
838
+ "creds_classifier": "copilot_logged_in_users",
839
+ "creds_key": "loggedInUsers",
840
+ "not_ready_message": "Sign-in not confirmed. A token env var (COPILOT_GITHUB_TOKEN/GH_TOKEN/GITHUB_TOKEN) is one option; you may already be signed in via `copilot` /login or `gh auth`. Auth is confirmed when you run a task.",
841
+ "unknown_message": "Sign-in not confirmed. A token env var (COPILOT_GITHUB_TOKEN/GH_TOKEN/GITHUB_TOKEN) is one option; you may already be signed in via `copilot` /login or `gh auth`. Auth is confirmed when you run a task.",
842
+ "unreadable_message": "Sign-in not confirmed. A token env var (COPILOT_GITHUB_TOKEN/GH_TOKEN/GITHUB_TOKEN) is one option; you may already be signed in via `copilot` /login or `gh auth`. Auth is confirmed when you run a task."
837
843
  },
838
844
  "env_config": [
839
845
  {
@@ -1388,10 +1394,14 @@
1388
1394
  "GEMINI_API_KEY"
1389
1395
  ],
1390
1396
  "credential_target": "gemini:antigravity",
1397
+ "keychain_item": {
1398
+ "service": "gemini",
1399
+ "account": "antigravity"
1400
+ },
1391
1401
  "unverifiable": true,
1392
1402
  "saved_env_key": "GEMINI_API_KEY",
1393
1403
  "login_command": "agy",
1394
- "not_ready_message": "Sign-in not confirmed. Run `agy` in a terminal to sign in with Google, or set GEMINI_API_KEY. On Windows the sign-in is detected once it lands in Credential Manager; elsewhere agy keeps it out of reach, so it is confirmed when you run a task.",
1404
+ "not_ready_message": "Sign-in not confirmed. Run `agy` in a terminal to sign in with Google, or set GEMINI_API_KEY. The sign-in is detected once it lands in the macOS Keychain or Windows Credential Manager; on Linux it is confirmed when you run a task.",
1395
1405
  "auth_detected_labels": {
1396
1406
  "cli_login": "Google account sign-in detected",
1397
1407
  "api_key": "API key detected"
@@ -1603,15 +1603,19 @@ class ClaudeAdapter extends BaseAdapter {
1603
1603
 
1604
1604
  /**
1605
1605
  * @anthropic-ai/claude-code ships a placeholder where its native binary goes
1606
- * and swaps the real one in from a postinstall script. With that script
1607
- * skipped (`ignore-scripts=true` in an npmrc, pnpm, bun) the placeholder is
1608
- * what runs: shell text on macOS/Linux, and on Windows a `claude.exe` the OS
1609
- * will not start (spawn EFTYPE).
1606
+ * and swaps the real one in from a postinstall script, copied out of a
1607
+ * per-platform optional dependency. Skip that script (`ignore-scripts=true` in
1608
+ * an npmrc, pnpm, bun) or lose that dependency (npm drops one whose download
1609
+ * fails, or under omit=optional) and the placeholder is what runs: shell text
1610
+ * on macOS/Linux, and on Windows a `claude.exe` the OS will not start (spawn
1611
+ * EFTYPE). Which of the two happened is the installer's to find out; a
1612
+ * reinstall from the launcher handles both (installer.finishNpmInstall).
1610
1613
  */
1611
- ClaudeAdapter.INSTALL_INCOMPLETE = 'Claude Code is installed, but its setup never finished: the '
1612
- + '@anthropic-ai/claude-code package\'s postinstall script did not run (npm `ignore-scripts`, or a '
1613
- + 'pnpm/bun install), so the `claude` command is only a placeholder. Reinstall Claude Code from the '
1614
- + 'launcher — or, for a copy you installed yourself, run '
1615
- + '`npm install -g @anthropic-ai/claude-code --ignore-scripts=false` — then retry.';
1614
+ ClaudeAdapter.INSTALL_INCOMPLETE = 'Claude Code is installed, but its setup never finished, so the '
1615
+ + '`claude` command is only a placeholder: either the @anthropic-ai/claude-code package\'s postinstall '
1616
+ + 'script did not run (npm `ignore-scripts`, or a pnpm/bun install), or npm left out the per-platform '
1617
+ + 'package that holds the native binary (its download failed, or optional dependencies are turned off). '
1618
+ + 'Reinstall Claude Code from the launcher — or, for a copy you installed yourself, run '
1619
+ + '`npm install -g @anthropic-ai/claude-code --ignore-scripts=false --include=optional` — then retry.';
1616
1620
 
1617
1621
  module.exports = ClaudeAdapter;
@@ -79,6 +79,7 @@ const FAILURE_MESSAGES = {
79
79
  incomplete_run: 'CodeArts Agent stopped mid-task right after a tool call and never produced a final reply — its progress notes are shown above. Send "continue" to pick up where it left off.',
80
80
  process_crashed: 'CodeArts Agent exited unexpectedly. Open diagnostics or retry.',
81
81
  cwd_unavailable: "CodeArts Agent's working directory is not accessible. Check the agent's configured path (or agent home) permissions.",
82
+ config_invalid: 'CodeArts Agent would not start because one of its config files is invalid — the file and what is wrong with it are below. Correct or remove that entry, then retry.',
82
83
  unknown_error: 'CodeArts Agent failed for an undetermined reason. Open diagnostics or retry.',
83
84
  };
84
85
 
@@ -63,6 +63,12 @@ const CODEX_LOG_RECORD = /^\d{4}-\d{2}-\d{2}T[\d:.]+Z?\s+(TRACE|DEBUG|INFO|WARN|
63
63
  // Things codex says beside a run rather than about it, such as a config key
64
64
  // it skipped. Quoted only when nothing else was said.
65
65
  const CODEX_SIDE_NOTE = /^warning:/i;
66
+ // ERROR records codex logs beside a run, not about it: a skill file it could
67
+ // not parse (it skips that skill and answers anyway, verified with codex-cli
68
+ // 0.167), and its own ChatGPT connector (rmcp) losing a side connection. In
69
+ // the field they came first in stderr and were quoted as the reason a run
70
+ // failed. Quoted only when nothing else was logged.
71
+ const CODEX_SIDE_ERROR = /\brmcp::|failed to load skill\b/;
66
72
  // Codex's wording when the model service could not be reached or the stream
67
73
  // dropped. Seen in the field from devices that cannot reach OpenAI, and
68
74
  // reproduced against codex-cli 0.160 behind a dead proxy: the run then fails
@@ -71,6 +77,13 @@ const CODEX_SIDE_NOTE = /^warning:/i;
71
77
  const CODEX_CONNECTION_FAILURE = /error sending request|Connection failed|failed to connect to websocket: IO error|tls handshake|dns error|failed to lookup address|stream disconnected before completion|workspace routing discovery (?:failed|timed out)|request timed out/i;
72
78
  // codex retrying a failed connection by itself: "Reconnecting... 2/5 (why)".
73
79
  const CODEX_RECONNECTING = /^Reconnecting\.\.\.\s*\d+\/\d+\s*(?:\((.*)\))?\s*$/i;
80
+ // An endpoint refusing a field of the request. Codex sends the same fields
81
+ // (client_metadata among them) on every turn and has no setting to drop one,
82
+ // so on a custom Responses provider this fails every run.
83
+ const PARAM_REFUSED = /unsupported .{0,40}parameter|unsupported_parameter|unknown parameter|unrecognized request argument|unrecognized (key|field)|additional properties|extra (inputs|fields) are not permitted/i;
84
+ // OpenAI's own "Unsupported parameter: 'reasoning.effort' is not supported with
85
+ // this model" is about the model chosen, which the user can change.
86
+ const MODEL_CAPABILITY_REFUSAL = /with this model|reasoning[._]/i;
74
87
  // The service answered and said no: a key, a plan, a quota, or a model it
75
88
  // will not serve. Network advice would send the user the wrong way. The
76
89
  // terms of _serviceRefused, less "error sending request" (that one is a
@@ -777,7 +790,7 @@ class CodexAdapter extends BaseAdapter {
777
790
  * reply, instead of a generic "No response generated".
778
791
  */
779
792
  async _sendRunFailure(msgChannel, result, { partial = false } = {}) {
780
- const detail = CodexAdapter._failureDetail(result);
793
+ const detail = CodexAdapter._failureDetail(result, { customProvider: this._customProvider });
781
794
  if (partial) {
782
795
  const body = detail
783
796
  ? `It stopped before finishing this task.\n\n> ${detail}`
@@ -825,13 +838,19 @@ class CodexAdapter extends BaseAdapter {
825
838
  * The cap applies to the quoted reason, before the advice is added, so a
826
839
  * long stderr cannot push the advice out of the message.
827
840
  */
828
- static _failureDetail({ errorMessage, stderr, exitCode, signal } = {}) {
841
+ static _failureDetail({ errorMessage, stderr, exitCode, signal } = {}, { customProvider = null } = {}) {
842
+ // A clean exit with no turn.failed and no error event is codex saying the
843
+ // turn finished; it just wrote no reply. Whatever stderr holds then is not
844
+ // why (a skill it skipped, its ChatGPT connector), and quoting it read as
845
+ // "failed to complete this run > failed to load skill …" for a run that
846
+ // had not failed.
847
+ const finished = exitCode === 0 && !signal;
829
848
  const raw = String(errorMessage || '').trim()
830
- || CodexAdapter._stderrReason(stderr)
849
+ || (finished ? '' : CodexAdapter._stderrReason(stderr))
831
850
  || (signal ? `codex was terminated by ${signal}` : '')
832
851
  || (exitCode ? `codex exited with code ${exitCode}` : '');
833
852
  const reason = CodexAdapter._redact(CodexAdapter._unwrap(raw)).slice(0, FAILURE_DETAIL_CAP).trim();
834
- return reason ? CodexAdapter._explain(reason, stderr) : '';
853
+ return reason ? CodexAdapter._explain(reason, stderr, { customProvider }) : '';
835
854
  }
836
855
 
837
856
  /**
@@ -854,7 +873,8 @@ class CodexAdapter extends BaseAdapter {
854
873
  * (or "Reading additional input from stdin...") on every run. A plain tail
855
874
  * of the last lines was mostly that noise. So, in order: lines the CLI
856
875
  * printed for a person; failing those, its ERROR records with timestamp and
857
- * module stripped; failing those, its warnings. The banner and known-harmless
876
+ * module stripped; failing those, its warnings and the ERROR records it logs
877
+ * beside a run (CODEX_SIDE_ERROR). The banner and known-harmless
858
878
  * lines are never a reason: a clean exit with only the banner reads as "no
859
879
  * reply", not as "> Reading prompt from stdin...".
860
880
  *
@@ -871,7 +891,8 @@ class CodexAdapter extends BaseAdapter {
871
891
  const record = CODEX_LOG_RECORD.exec(line);
872
892
  if (record) {
873
893
  const [, level, message] = record;
874
- const bucket = level === 'ERROR' ? errors : level === 'WARN' ? notes : null;
894
+ const side = level === 'WARN' || (level === 'ERROR' && CODEX_SIDE_ERROR.test(line));
895
+ const bucket = side ? notes : level === 'ERROR' ? errors : null;
875
896
  if (bucket && message && !bucket.includes(message)) bucket.push(message);
876
897
  } else if (!BENIGN_CLI_OUTPUT.test(line)) {
877
898
  (CODEX_SIDE_NOTE.test(line) ? notes : said).push(line);
@@ -896,8 +917,14 @@ class CodexAdapter extends BaseAdapter {
896
917
  for (const key of ['detail', 'message', 'error']) {
897
918
  const v = parsed && parsed[key];
898
919
  if (typeof v === 'string' && v.trim()) return v.trim();
899
- // OpenAI also nests as { error: { message } }.
900
- if (v && typeof v.message === 'string' && v.message.trim()) return v.message.trim();
920
+ // OpenAI also nests as { error: { message } }. Its `param` names the
921
+ // field a 400 is about — "Unsupported Responses request parameter."
922
+ // alone did not say which.
923
+ if (v && typeof v.message === 'string' && v.message.trim()) {
924
+ const message = v.message.trim();
925
+ const param = typeof v.param === 'string' ? v.param.trim() : '';
926
+ return param && !message.includes(param) ? `${message} (parameter: ${param})` : message;
927
+ }
901
928
  }
902
929
  } catch {}
903
930
  return text;
@@ -912,7 +939,20 @@ class CodexAdapter extends BaseAdapter {
912
939
  * match is on the backend's own wording, so an unrelated failure is passed
913
940
  * through untouched.
914
941
  */
915
- static _explain(detail, stderr = '') {
942
+ static _explain(detail, stderr = '', { customProvider = null } = {}) {
943
+ // A custom Responses endpoint refusing a field Codex always sends. Nothing
944
+ // the user retries changes that; which endpoint to use, or the chat-only
945
+ // mode, does.
946
+ if (customProvider && PARAM_REFUSED.test(detail) && !MODEL_CAPABILITY_REFUSAL.test(detail)) {
947
+ let host = '';
948
+ try { host = new URL(customProvider.baseUrl).host; } catch {}
949
+ const m = /\(parameter: ([^)]+)\)/.exec(detail) || /parameter:?\s*'([\w.[\]]+)'/i.exec(detail);
950
+ return `${detail}\n\nThe endpoint this agent is set to${host ? ` (${host})` : ''} takes Responses API requests ` +
951
+ `but refuses ${m ? `the "${m[1]}" field` : 'a field'} that the Codex CLI sends with every one of them, ` +
952
+ 'and Codex has no setting to leave it out — so every run here will fail the same way. Point the agent ' +
953
+ 'at an endpoint that supports the full Responses API, or edit the agent and set Agent capabilities to ' +
954
+ '"Chat only · Chat Completions API" (it then answers without running tools on this device).';
955
+ }
916
956
  // Ahead of the network check: a model that needs a newer Codex can
917
957
  // arrive with connection warnings in stderr, and the upgrade is the fix.
918
958
  if (/requires a newer version|upgrade to the latest (app|version)/i.test(detail)) {
@@ -83,8 +83,12 @@ const DSH_BUILTIN_MODELS = ['deepseek-flash', 'deepseek-v4-pro'];
83
83
  /** The pi-ai route an OpenAI-compatible gateway is served through. */
84
84
  const GATEWAY_PROVIDER = 'openai-gateway';
85
85
 
86
- /** The model a gateway route runs when none is configured. */
87
- const DEFAULT_GATEWAY_MODEL = 'deepseek-v4-flash';
86
+ /**
87
+ * The model a gateway route runs when none is configured: the one the
88
+ * OpenAgents gateway serves. It has since narrowed to this single id and
89
+ * refuses `deepseek-v4-flash` with "This gateway only allows: …".
90
+ */
91
+ const DEFAULT_GATEWAY_MODEL = 'deepseek-v4.1-flash';
88
92
 
89
93
  /** Where DeepSeek's own model list is read (its OpenAI-style root). */
90
94
  const DEEPSEEK_MODELS_BASE = 'https://api.deepseek.com/v1';
@@ -297,6 +297,71 @@ function encodeKimiWorkDirKey(workDir) {
297
297
  return `wd_${slug}_${hash}`;
298
298
  }
299
299
 
300
+ // ---------------------------------------------------------------------------
301
+ // What a session journal says is still running
302
+ // ---------------------------------------------------------------------------
303
+
304
+ /**
305
+ * Follows a session journal (`agents/main/wire.jsonl`) as it grows and keeps
306
+ * the tool calls and background tasks it shows as started but not finished.
307
+ *
308
+ * Print mode says nothing while a tool runs — not even the tool call, which
309
+ * only comes out with its result — but the journal records each step as it
310
+ * happens (verified v2.5.2):
311
+ * {type:"context.append_loop_event", event:{type:"step.begin"}} a model step starts
312
+ * {type:"context.append_loop_event", event:{type:"tool.call", toolCallId}} a tool starts
313
+ * {type:"context.append_loop_event", event:{type:"tool.result", toolCallId}} it ends
314
+ * {type:"task.started", info:{taskId}} / {type:"task.terminated", info:{taskId}}
315
+ * a background task (Bash run_in_background), which the run waits on
316
+ * Every record carries `time`, ms since the epoch. Kimi bounds both itself: a
317
+ * foreground command at 300s, a task at its timeoutMs.
318
+ *
319
+ * A record from before `since` (the run's start) opens nothing: it belongs to
320
+ * an earlier run, maybe one that was stopped mid-tool. A step begins only
321
+ * after the previous step's tools have returned, so `step.begin` closes any
322
+ * call still open — as does `turn.ended`; a task outlives both. Lines it does
323
+ * not know are skipped. A journal whose shape changed reads as "nothing
324
+ * running", or — if starts are still recognized and ends are not — as a
325
+ * tool running until the next step: never as a reason to stop a run earlier.
326
+ */
327
+ class KimiWireTracker {
328
+ constructor({ since = 0 } = {}) {
329
+ this._since = since;
330
+ this._partial = '';
331
+ this.toolCalls = new Set();
332
+ this.tasks = new Set();
333
+ }
334
+
335
+ /** Feed the next chunk of the file. */
336
+ push(chunk) {
337
+ const lines = (this._partial + chunk).split('\n');
338
+ this._partial = lines.pop();
339
+ for (const line of lines) {
340
+ let e;
341
+ try { e = JSON.parse(line); } catch { continue; }
342
+ if (!e || typeof e !== 'object') continue;
343
+ const current = !(typeof e.time === 'number' && e.time < this._since);
344
+ const ev = e.event && typeof e.event === 'object' ? e.event : null;
345
+ if (e.type === 'context.append_loop_event' && ev && ev.type === 'step.begin') {
346
+ this.toolCalls.clear();
347
+ } else if (e.type === 'context.append_loop_event' && ev && typeof ev.toolCallId === 'string') {
348
+ if (ev.type === 'tool.call' && current) this.toolCalls.add(ev.toolCallId);
349
+ else if (ev.type === 'tool.result') this.toolCalls.delete(ev.toolCallId);
350
+ } else if ((e.type === 'task.started' || e.type === 'task.terminated') && e.info && typeof e.info.taskId === 'string') {
351
+ if (e.type === 'task.started') { if (current) this.tasks.add(e.info.taskId); }
352
+ else this.tasks.delete(e.info.taskId);
353
+ } else if (e.type === 'turn.ended') {
354
+ this.toolCalls.clear();
355
+ }
356
+ }
357
+ }
358
+
359
+ /** Whether a tool call or a background task is still running. */
360
+ get busy() {
361
+ return this.toolCalls.size > 0 || this.tasks.size > 0;
362
+ }
363
+ }
364
+
300
365
  // ---------------------------------------------------------------------------
301
366
  // Error classification
302
367
  // ---------------------------------------------------------------------------
@@ -319,24 +384,31 @@ function extractStderrError(stderrText) {
319
384
 
320
385
  /**
321
386
  * Classify a failed run into a user-facing message.
322
- * @param {{code: number|null, signal: string|null, stderrText: string, retryMessage: string, timedOutMs?: number}} info
387
+ * @param {{code: number|null, signal: string|null, stderrText: string, retryMessage: string, timedOutMs?: number, timedOutInTool?: boolean}} info
323
388
  * `timedOutMs` is set when the adapter's idle watchdog stopped the run after
324
- * that long without any sign of progress.
389
+ * that long without any sign of progress; `timedOutInTool` when a tool call
390
+ * or background task was still running then (see KimiWireTracker).
325
391
  * @returns {{kind: string, userMessage: string}}
326
392
  */
327
393
  function classifyKimiError(info) {
328
- const { code, signal, stderrText, retryMessage, timedOutMs } = info || {};
394
+ const { code, signal, stderrText, retryMessage, timedOutMs, timedOutInTool } = info || {};
329
395
  const detail = extractStderrError(stderrText) || redactSecrets(retryMessage || '');
330
396
 
331
397
  // The watchdog's own stop wins: the signal it leaves behind (SIGINT on
332
398
  // Windows) explains nothing, and stderr by then holds whatever tools printed.
399
+ // "No progress" read as a hang; in print mode Kimi says nothing while the
400
+ // model works on a step, so the message says what was actually seen.
333
401
  if (timedOutMs) {
334
402
  const minutes = Math.max(1, Math.round(timedOutMs / 60000));
335
403
  return {
336
404
  kind: 'timeout',
337
405
  userMessage:
338
- `Kimi showed no progress for about ${minutes} min and was stopped. ` +
339
- 'Send the request again, or break a long task into smaller steps.' +
406
+ (timedOutInTool
407
+ ? `A command or task Kimi started was still running after about ${minutes} min with no output, so Kimi was stopped. ` +
408
+ 'Send the request again, or ask Kimi to split the long command into smaller parts.'
409
+ : `Kimi printed nothing for about ${minutes} min and was stopped. Kimi prints nothing while the model ` +
410
+ 'works on a step, so a very long step looks the same as a stuck one. ' +
411
+ 'Send the request again, or break a long task into smaller steps.') +
340
412
  (detail ? `\n\nDetails: ${detail}` : ''),
341
413
  };
342
414
  }
@@ -457,6 +529,7 @@ module.exports = {
457
529
  buildKimiArgs,
458
530
  buildKimiEnv,
459
531
  encodeKimiWorkDirKey,
532
+ KimiWireTracker,
460
533
  extractStderrError,
461
534
  classifyKimiError,
462
535
  DEFAULT_KIMI_MODEL,