@openagents-org/agent-launcher 0.2.215 → 0.2.217
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/kiro.svg +11 -0
- package/package.json +1 -1
- package/registry.json +103 -3
- package/src/adapters/acp-client.js +217 -0
- package/src/adapters/claude.js +64 -8
- package/src/adapters/codex.js +126 -33
- package/src/adapters/hermes.js +164 -87
- package/src/adapters/index.js +4 -1
- package/src/adapters/kiro-runtime.js +318 -0
- package/src/adapters/kiro.js +813 -0
- package/src/adapters/opencode.js +37 -1
- package/src/daemon.js +7 -8
- package/src/index.js +7 -13
- package/src/install-preflight.js +20 -1
- package/src/paths.js +6 -0
- package/src/utils.js +12 -0
package/icons/kiro.svg
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<svg width="1200" height="1200" viewBox="0 0 1200 1200" fill="none" xmlns="http://www.w3.org/2000/svg" role="img"><title>Kiro</title>
|
|
2
|
+
<rect width="1200" height="1200" rx="260" fill="#9046FF"/>
|
|
3
|
+
<mask id="mask0_1106_4856" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="272" y="202" width="655" height="796">
|
|
4
|
+
<path d="M926.578 202.793H272.637V997.857H926.578V202.793Z" fill="white"/>
|
|
5
|
+
</mask>
|
|
6
|
+
<g mask="url(#mask0_1106_4856)">
|
|
7
|
+
<path d="M398.554 818.914C316.315 1001.03 491.477 1046.74 620.672 940.156C658.687 1059.66 801.052 970.473 852.234 877.795C964.787 673.567 919.318 465.357 907.64 422.374C827.637 129.443 427.623 128.946 358.8 423.865C342.651 475.544 342.402 534.18 333.458 595.051C328.986 625.86 325.507 645.488 313.83 677.785C306.873 696.424 297.68 712.819 282.773 740.645C259.915 783.881 269.604 867.113 387.87 823.883L399.051 818.914H398.554Z" fill="white"/>
|
|
8
|
+
<path d="M636.123 549.353C603.328 549.353 598.359 510.097 598.359 486.742C598.359 465.623 602.086 448.977 609.293 438.293C615.504 428.852 624.697 424.131 636.123 424.131C647.555 424.131 657.492 428.852 664.447 438.541C672.398 449.474 676.623 466.12 676.623 486.742C676.623 525.998 661.471 549.353 636.375 549.353H636.123Z" fill="black"/>
|
|
9
|
+
<path d="M771.24 549.353C738.445 549.353 733.477 510.097 733.477 486.742C733.477 465.623 737.203 448.977 744.41 438.293C750.621 428.852 759.814 424.131 771.24 424.131C782.672 424.131 792.609 428.852 799.564 438.541C807.516 449.474 811.74 466.12 811.74 486.742C811.74 525.998 796.588 549.353 771.492 549.353H771.24Z" fill="black"/>
|
|
10
|
+
</g>
|
|
11
|
+
</svg>
|
package/package.json
CHANGED
package/registry.json
CHANGED
|
@@ -26,6 +26,11 @@
|
|
|
26
26
|
"nodejs",
|
|
27
27
|
"git"
|
|
28
28
|
],
|
|
29
|
+
"requires_on": {
|
|
30
|
+
"git": [
|
|
31
|
+
"windows"
|
|
32
|
+
]
|
|
33
|
+
},
|
|
29
34
|
"macos": "npm install -g @anthropic-ai/claude-code",
|
|
30
35
|
"linux": "npm install -g @anthropic-ai/claude-code",
|
|
31
36
|
"windows": "npm install -g @anthropic-ai/claude-code"
|
|
@@ -2151,8 +2156,8 @@
|
|
|
2151
2156
|
},
|
|
2152
2157
|
{
|
|
2153
2158
|
"name": "codebuddy",
|
|
2154
|
-
"label": "
|
|
2155
|
-
"description": "Tencent's CodeBuddy Code CLI —
|
|
2159
|
+
"label": "WorkBuddy (CodeBuddy)",
|
|
2160
|
+
"description": "Tencent WorkBuddy's agent engine (the CodeBuddy Code CLI), driven headlessly — same account and credits as the WorkBuddy desktop app; its built-in office plugins are not included",
|
|
2156
2161
|
"homepage": "https://www.codebuddy.ai",
|
|
2157
2162
|
"tags": [
|
|
2158
2163
|
"workbuddy",
|
|
@@ -2165,7 +2170,7 @@
|
|
|
2165
2170
|
"order": 999,
|
|
2166
2171
|
"catalog": true,
|
|
2167
2172
|
"vendor": "Tencent",
|
|
2168
|
-
"tagline": "The
|
|
2173
|
+
"tagline": "The engine behind Tencent's WorkBuddy desktop app — same account and credits, driven headlessly. Installed with npm.",
|
|
2169
2174
|
"logo": {
|
|
2170
2175
|
"key": "codebuddy"
|
|
2171
2176
|
},
|
|
@@ -2731,5 +2736,100 @@
|
|
|
2731
2736
|
},
|
|
2732
2737
|
"vendor": "Alibaba Qwen",
|
|
2733
2738
|
"tagline": "Qwen's terminal coding agent, on your Model Studio or Coding Plan key."
|
|
2739
|
+
},
|
|
2740
|
+
{
|
|
2741
|
+
"name": "kiro",
|
|
2742
|
+
"label": "Kiro",
|
|
2743
|
+
"description": "Kiro's terminal coding agent (kiro-cli), driven over the Agent Client Protocol",
|
|
2744
|
+
"homepage": "https://kiro.dev/cli/",
|
|
2745
|
+
"tags": [
|
|
2746
|
+
"coding",
|
|
2747
|
+
"cli",
|
|
2748
|
+
"acp",
|
|
2749
|
+
"headless"
|
|
2750
|
+
],
|
|
2751
|
+
"featured": false,
|
|
2752
|
+
"order": 999,
|
|
2753
|
+
"builtin": true,
|
|
2754
|
+
"logo": {
|
|
2755
|
+
"key": "kiro"
|
|
2756
|
+
},
|
|
2757
|
+
"support": {
|
|
2758
|
+
"install": true,
|
|
2759
|
+
"workspace": true,
|
|
2760
|
+
"collaboration": true
|
|
2761
|
+
},
|
|
2762
|
+
"install": {
|
|
2763
|
+
"binary": "kiro-cli",
|
|
2764
|
+
"verify": "kiro-cli --version",
|
|
2765
|
+
"verify_win": "kiro-cli --version",
|
|
2766
|
+
"macos": "curl -fsSL https://cli.kiro.dev/install | bash",
|
|
2767
|
+
"linux": "curl -fsSL https://cli.kiro.dev/install | bash",
|
|
2768
|
+
"windows": "irm https://cli.kiro.dev/install.ps1 | iex"
|
|
2769
|
+
},
|
|
2770
|
+
"uninstall": null,
|
|
2771
|
+
"adapter": {
|
|
2772
|
+
"module": "openagents.adapters.kiro",
|
|
2773
|
+
"class": "KiroAdapter"
|
|
2774
|
+
},
|
|
2775
|
+
"launch": null,
|
|
2776
|
+
"check_ready": {
|
|
2777
|
+
"min_version": "2.37.0",
|
|
2778
|
+
"env_vars": [
|
|
2779
|
+
"KIRO_API_KEY"
|
|
2780
|
+
],
|
|
2781
|
+
"status_args": [
|
|
2782
|
+
"whoami"
|
|
2783
|
+
],
|
|
2784
|
+
"logged_in_pattern": "Logged in with",
|
|
2785
|
+
"logged_out_pattern": "Not logged in",
|
|
2786
|
+
"login_command": "kiro-cli login",
|
|
2787
|
+
"not_ready_message": "Not signed in. Run: kiro-cli login (or set KIRO_API_KEY for headless machines)"
|
|
2788
|
+
},
|
|
2789
|
+
"env_config": [
|
|
2790
|
+
{
|
|
2791
|
+
"name": "KIRO_AGENT",
|
|
2792
|
+
"description": "Kiro agent profile to run (a .kiro/agents/<name>.json in the working directory or ~/.kiro/agents). The profile carries this agent's own prompt, tools and MCP servers. Leave empty for Kiro's default agent.",
|
|
2793
|
+
"required": false,
|
|
2794
|
+
"placeholder": "my-agent"
|
|
2795
|
+
},
|
|
2796
|
+
{
|
|
2797
|
+
"name": "KIRO_MODEL",
|
|
2798
|
+
"description": "Model id, e.g. claude-sonnet-4.6 (see `kiro-cli chat --list-models`). Leave empty for Kiro's default (auto).",
|
|
2799
|
+
"required": false,
|
|
2800
|
+
"placeholder": "auto"
|
|
2801
|
+
},
|
|
2802
|
+
{
|
|
2803
|
+
"name": "KIRO_API_KEY",
|
|
2804
|
+
"description": "Optional. Kiro API key for machines where `kiro-cli login` is not possible; a signed-in CLI needs none.",
|
|
2805
|
+
"required": false,
|
|
2806
|
+
"password": true
|
|
2807
|
+
}
|
|
2808
|
+
],
|
|
2809
|
+
"models": [
|
|
2810
|
+
{
|
|
2811
|
+
"id": "auto",
|
|
2812
|
+
"label": "Auto",
|
|
2813
|
+
"category": "chat"
|
|
2814
|
+
},
|
|
2815
|
+
{
|
|
2816
|
+
"id": "claude-sonnet-4.6",
|
|
2817
|
+
"label": "Claude Sonnet 4.6",
|
|
2818
|
+
"category": "chat"
|
|
2819
|
+
},
|
|
2820
|
+
{
|
|
2821
|
+
"id": "claude-opus-4.6",
|
|
2822
|
+
"label": "Claude Opus 4.6",
|
|
2823
|
+
"category": "chat"
|
|
2824
|
+
},
|
|
2825
|
+
{
|
|
2826
|
+
"id": "claude-haiku-4.5",
|
|
2827
|
+
"label": "Claude Haiku 4.5",
|
|
2828
|
+
"category": "chat"
|
|
2829
|
+
}
|
|
2830
|
+
],
|
|
2831
|
+
"workspace_model": true,
|
|
2832
|
+
"vendor": "Amazon",
|
|
2833
|
+
"tagline": "Kiro's agent in your workspace, with its own agent profile, tools and MCP servers."
|
|
2734
2834
|
}
|
|
2735
2835
|
]
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A minimal Agent Client Protocol (ACP) client: JSON-RPC 2.0, one message per
|
|
5
|
+
* line, over a child process's stdio. Nothing in here is specific to one CLI —
|
|
6
|
+
* Kiro (`kiro-cli acp`) is the first adapter on it, and any other CLI that
|
|
7
|
+
* serves ACP on stdio can reuse it unchanged.
|
|
8
|
+
*
|
|
9
|
+
* Responsibilities:
|
|
10
|
+
* - frame stdout into lines and parse each as JSON (non-JSON lines are
|
|
11
|
+
* reported through onUnparsed and otherwise ignored — a CLI may log);
|
|
12
|
+
* - match responses to requests by id, with an optional per-request timeout;
|
|
13
|
+
* - hand agent → client REQUESTS (session/request_permission, fs/…) to
|
|
14
|
+
* onRequest and send back its result, or a JSON-RPC error if it throws or
|
|
15
|
+
* is missing (method not found, so the agent never waits forever);
|
|
16
|
+
* - hand NOTIFICATIONS (session/update, vendor extensions) to onNotification;
|
|
17
|
+
* - fail every pending request once the process is gone.
|
|
18
|
+
*
|
|
19
|
+
* Spec: https://agentclientprotocol.com
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
const JSONRPC = '2.0';
|
|
23
|
+
const METHOD_NOT_FOUND = -32601;
|
|
24
|
+
const INTERNAL_ERROR = -32603;
|
|
25
|
+
|
|
26
|
+
/** A JSON-RPC error answer from the agent. Keeps code and data for callers. */
|
|
27
|
+
class AcpRpcError extends Error {
|
|
28
|
+
constructor(method, error) {
|
|
29
|
+
const data = error && error.data !== undefined
|
|
30
|
+
? (typeof error.data === 'string' ? error.data : JSON.stringify(error.data))
|
|
31
|
+
: '';
|
|
32
|
+
super(`${method} failed: ${(error && error.message) || 'error'}${data ? ` (${data})` : ''}`);
|
|
33
|
+
this.name = 'AcpRpcError';
|
|
34
|
+
this.method = method;
|
|
35
|
+
this.code = error && error.code;
|
|
36
|
+
this.data = error && error.data;
|
|
37
|
+
this.rpcError = error || null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** The agent process went away (or was closed) with requests still open. */
|
|
42
|
+
class AcpClosedError extends Error {
|
|
43
|
+
constructor(method, reason) {
|
|
44
|
+
super(`${method} interrupted: ${reason || 'the agent process exited'}`);
|
|
45
|
+
this.name = 'AcpClosedError';
|
|
46
|
+
this.method = method;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
class AcpTimeoutError extends Error {
|
|
51
|
+
constructor(method, ms) {
|
|
52
|
+
super(`${method} timed out after ${Math.round(ms / 1000)}s`);
|
|
53
|
+
this.name = 'AcpTimeoutError';
|
|
54
|
+
this.method = method;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
class AcpClient {
|
|
59
|
+
/**
|
|
60
|
+
* @param {import('child_process').ChildProcess} proc - spawned with piped stdio
|
|
61
|
+
* @param {object} [handlers]
|
|
62
|
+
* @param {(method: string, params: object) => void} [handlers.onNotification]
|
|
63
|
+
* @param {(method: string, params: object) => (object|Promise<object>)} [handlers.onRequest]
|
|
64
|
+
* @param {(line: string) => void} [handlers.onUnparsed]
|
|
65
|
+
* @param {() => void} [handlers.onActivity] - any frame arrived (watchdogs)
|
|
66
|
+
*/
|
|
67
|
+
constructor(proc, { onNotification, onRequest, onUnparsed, onActivity } = {}) {
|
|
68
|
+
this.proc = proc;
|
|
69
|
+
this._onNotification = onNotification || (() => {});
|
|
70
|
+
this._onRequest = onRequest || null;
|
|
71
|
+
this._onUnparsed = onUnparsed || (() => {});
|
|
72
|
+
this._onActivity = onActivity || (() => {});
|
|
73
|
+
this._nextId = 1;
|
|
74
|
+
this._pending = new Map(); // id → { method, resolve, reject, timer }
|
|
75
|
+
this._buf = '';
|
|
76
|
+
this._closed = false;
|
|
77
|
+
this._closeReason = null;
|
|
78
|
+
|
|
79
|
+
// A killed child's pipes can emit EPIPE/ECONNRESET a tick later; with no
|
|
80
|
+
// 'error' listener that is an uncaughtException that takes the daemon down.
|
|
81
|
+
if (proc.stdout) {
|
|
82
|
+
proc.stdout.on('error', () => {});
|
|
83
|
+
proc.stdout.setEncoding('utf8');
|
|
84
|
+
proc.stdout.on('data', (chunk) => this._feed(chunk));
|
|
85
|
+
}
|
|
86
|
+
if (proc.stdin) proc.stdin.on('error', () => {});
|
|
87
|
+
proc.on('exit', (code, signal) => {
|
|
88
|
+
this._fail(signal ? `the agent process was killed (${signal})` : `the agent process exited (code ${code})`);
|
|
89
|
+
});
|
|
90
|
+
proc.on('error', (e) => this._fail(e && e.message ? e.message : 'the agent process failed'));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
get closed() {
|
|
94
|
+
return this._closed;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Send a request; resolves with `result`, rejects with AcpRpcError/AcpClosedError/AcpTimeoutError. */
|
|
98
|
+
request(method, params, { timeoutMs = 0 } = {}) {
|
|
99
|
+
if (this._closed) return Promise.reject(new AcpClosedError(method, this._closeReason));
|
|
100
|
+
const id = this._nextId++;
|
|
101
|
+
return new Promise((resolve, reject) => {
|
|
102
|
+
const entry = { method, resolve, reject, timer: null };
|
|
103
|
+
if (timeoutMs > 0) {
|
|
104
|
+
entry.timer = setTimeout(() => {
|
|
105
|
+
this._pending.delete(id);
|
|
106
|
+
reject(new AcpTimeoutError(method, timeoutMs));
|
|
107
|
+
}, timeoutMs);
|
|
108
|
+
}
|
|
109
|
+
this._pending.set(id, entry);
|
|
110
|
+
if (!this._write({ jsonrpc: JSONRPC, id, method, params })) {
|
|
111
|
+
this._pending.delete(id);
|
|
112
|
+
if (entry.timer) clearTimeout(entry.timer);
|
|
113
|
+
reject(new AcpClosedError(method, 'could not write to the agent process'));
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** Fire-and-forget notification (e.g. session/cancel). Returns false if it could not be written. */
|
|
119
|
+
notify(method, params) {
|
|
120
|
+
if (this._closed) return false;
|
|
121
|
+
return this._write({ jsonrpc: JSONRPC, method, params });
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Stop accepting traffic and fail anything still pending. */
|
|
125
|
+
close(reason = 'closed by the client') {
|
|
126
|
+
this._fail(reason);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// ------------------------------------------------------------------
|
|
130
|
+
|
|
131
|
+
_write(msg) {
|
|
132
|
+
try {
|
|
133
|
+
if (!this.proc.stdin || this.proc.stdin.destroyed || !this.proc.stdin.writable) return false;
|
|
134
|
+
this.proc.stdin.write(`${JSON.stringify(msg)}\n`);
|
|
135
|
+
return true;
|
|
136
|
+
} catch {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
_feed(chunk) {
|
|
142
|
+
this._buf += chunk;
|
|
143
|
+
let nl;
|
|
144
|
+
while ((nl = this._buf.indexOf('\n')) !== -1) {
|
|
145
|
+
const line = this._buf.slice(0, nl).replace(/\r$/, '');
|
|
146
|
+
this._buf = this._buf.slice(nl + 1);
|
|
147
|
+
if (line.trim()) this._handleLine(line);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
_handleLine(line) {
|
|
152
|
+
let msg;
|
|
153
|
+
try {
|
|
154
|
+
msg = JSON.parse(line);
|
|
155
|
+
} catch {
|
|
156
|
+
this._onUnparsed(line);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
if (!msg || typeof msg !== 'object') return;
|
|
160
|
+
this._onActivity();
|
|
161
|
+
|
|
162
|
+
const hasId = msg.id !== undefined && msg.id !== null;
|
|
163
|
+
if (hasId && typeof msg.method === 'string') {
|
|
164
|
+
this._answerRequest(msg);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
if (hasId) {
|
|
168
|
+
const entry = this._pending.get(msg.id);
|
|
169
|
+
if (!entry) return;
|
|
170
|
+
this._pending.delete(msg.id);
|
|
171
|
+
if (entry.timer) clearTimeout(entry.timer);
|
|
172
|
+
if (msg.error) entry.reject(new AcpRpcError(entry.method, msg.error));
|
|
173
|
+
else entry.resolve(msg.result === undefined ? null : msg.result);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
if (typeof msg.method === 'string') {
|
|
177
|
+
try { this._onNotification(msg.method, msg.params || {}); } catch {}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
async _answerRequest(msg) {
|
|
182
|
+
if (!this._onRequest) {
|
|
183
|
+
this._write({ jsonrpc: JSONRPC, id: msg.id, error: { code: METHOD_NOT_FOUND, message: `Method not supported: ${msg.method}` } });
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
try {
|
|
187
|
+
const result = await this._onRequest(msg.method, msg.params || {});
|
|
188
|
+
if (result === undefined) {
|
|
189
|
+
this._write({ jsonrpc: JSONRPC, id: msg.id, error: { code: METHOD_NOT_FOUND, message: `Method not supported: ${msg.method}` } });
|
|
190
|
+
} else {
|
|
191
|
+
this._write({ jsonrpc: JSONRPC, id: msg.id, result });
|
|
192
|
+
}
|
|
193
|
+
} catch (e) {
|
|
194
|
+
this._write({ jsonrpc: JSONRPC, id: msg.id, error: { code: INTERNAL_ERROR, message: (e && e.message) || 'client error' } });
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
_fail(reason) {
|
|
199
|
+
if (this._closed) return;
|
|
200
|
+
this._closed = true;
|
|
201
|
+
this._closeReason = reason;
|
|
202
|
+
for (const [id, entry] of this._pending) {
|
|
203
|
+
this._pending.delete(id);
|
|
204
|
+
if (entry.timer) clearTimeout(entry.timer);
|
|
205
|
+
entry.reject(new AcpClosedError(entry.method, reason));
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
module.exports = {
|
|
211
|
+
AcpClient,
|
|
212
|
+
AcpRpcError,
|
|
213
|
+
AcpClosedError,
|
|
214
|
+
AcpTimeoutError,
|
|
215
|
+
METHOD_NOT_FOUND,
|
|
216
|
+
INTERNAL_ERROR,
|
|
217
|
+
};
|
package/src/adapters/claude.js
CHANGED
|
@@ -746,6 +746,11 @@ class ClaudeAdapter extends BaseAdapter {
|
|
|
746
746
|
* silent for too long while a message is in flight. Pauses during
|
|
747
747
|
* tool execution (awaitingToolResult) since long-running commands
|
|
748
748
|
* like builds or sleep produce no stdout legitimately.
|
|
749
|
+
*
|
|
750
|
+
* It only stops the process. What the channel is told depends on what
|
|
751
|
+
* happens next, so the caller says it (see _silenceNotice): it used to post
|
|
752
|
+
* "became unresponsive and was restarted" itself, and the caller then also
|
|
753
|
+
* posted "No response generated (exit code unknown)".
|
|
749
754
|
*/
|
|
750
755
|
_startWatchdog(pp) {
|
|
751
756
|
this._stopWatchdog(pp);
|
|
@@ -771,23 +776,51 @@ class ClaudeAdapter extends BaseAdapter {
|
|
|
771
776
|
this._log(`Watchdog: process unresponsive for ${consecutiveTimeouts * 15}s on ${pp.msgChannel} — killing`);
|
|
772
777
|
if (tail) this._log(`stderr: ${tail}`);
|
|
773
778
|
this._stopWatchdog(pp);
|
|
774
|
-
try {
|
|
775
|
-
await this.sendError(
|
|
776
|
-
pp.msgChannel,
|
|
777
|
-
'Agent process became unresponsive and was restarted.' +
|
|
778
|
-
(tail ? `\n\n\`\`\`\n${tail}\n\`\`\`` : ''),
|
|
779
|
-
);
|
|
780
|
-
} catch {}
|
|
781
779
|
if (pp.messageResolve) {
|
|
782
780
|
const resolve = pp.messageResolve;
|
|
783
781
|
pp.messageResolve = null;
|
|
784
|
-
resolve({ exited: true, error: new Error('watchdog timeout') });
|
|
782
|
+
resolve({ exited: true, watchdog: true, stderrTail: tail, error: new Error('watchdog timeout') });
|
|
785
783
|
}
|
|
786
784
|
this._killPersistentProc(pp.msgChannel);
|
|
787
785
|
}
|
|
788
786
|
}, this._WATCHDOG_INTERVAL_MS);
|
|
789
787
|
}
|
|
790
788
|
|
|
789
|
+
/** How long the watchdog waits, in whole minutes, for the channel. */
|
|
790
|
+
_watchdogMinutes() {
|
|
791
|
+
return Math.max(1, Math.round((this._WATCHDOG_INTERVAL_MS * this._WATCHDOG_MAX_TIMEOUTS) / 60_000));
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
/**
|
|
795
|
+
* What the channel reads when the watchdog stopped a turn for good.
|
|
796
|
+
*
|
|
797
|
+
* Tool runs pause the watchdog, so silence this long is Claude waiting on
|
|
798
|
+
* the model. That is almost always the API or the relay not answering, and
|
|
799
|
+
* the user can check that; "the agent process became unresponsive" sent
|
|
800
|
+
* them looking at the agent instead.
|
|
801
|
+
*/
|
|
802
|
+
_silenceNotice(stderrTail) {
|
|
803
|
+
return `Claude produced no output for ${this._watchdogMinutes()} minutes, so this turn was stopped. ` +
|
|
804
|
+
'This usually means the model API (or the relay this agent uses) is not responding. ' +
|
|
805
|
+
'Check it, then send the message again.' +
|
|
806
|
+
(stderrTail ? `\n\n\`\`\`\n${stderrTail}\n\`\`\`` : '');
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
/**
|
|
810
|
+
* A status line for Claude Code's own `api_retry` event, or '' when it
|
|
811
|
+
* carries nothing to show. Without it the channel saw nothing at all while
|
|
812
|
+
* the CLI retried a failing request for minutes.
|
|
813
|
+
*/
|
|
814
|
+
_apiRetryStatus(event) {
|
|
815
|
+
const attempt = Number(event && event.attempt);
|
|
816
|
+
if (!attempt) return '';
|
|
817
|
+
const max = Number(event.max_retries);
|
|
818
|
+
const why = event.error_status
|
|
819
|
+
? `HTTP ${event.error_status}`
|
|
820
|
+
: this._redact(String(event.error || '')).slice(0, 60).trim();
|
|
821
|
+
return `Claude's API request failed${why ? ` (${why})` : ''}, retrying (${max ? `${attempt}/${max}` : attempt})…`;
|
|
822
|
+
}
|
|
823
|
+
|
|
791
824
|
_stopWatchdog(pp) {
|
|
792
825
|
if (pp.watchdogTimer) { clearInterval(pp.watchdogTimer); pp.watchdogTimer = null; }
|
|
793
826
|
}
|
|
@@ -975,6 +1008,11 @@ class ClaudeAdapter extends BaseAdapter {
|
|
|
975
1008
|
pp.backgroundTasks = Array.isArray(event.tasks) ? event.tasks.length : 0;
|
|
976
1009
|
return;
|
|
977
1010
|
}
|
|
1011
|
+
if (subtype === 'api_retry') {
|
|
1012
|
+
const status = this._apiRetryStatus(event);
|
|
1013
|
+
if (status) { try { await this.sendStatus(pp.msgChannel, status); } catch {} }
|
|
1014
|
+
return;
|
|
1015
|
+
}
|
|
978
1016
|
if (subtype.includes('compact') || String(message).toLowerCase().includes('compact')) {
|
|
979
1017
|
await this.sendStatus(pp.msgChannel, String(message) || 'Compacting conversation...');
|
|
980
1018
|
}
|
|
@@ -1401,6 +1439,17 @@ class ClaudeAdapter extends BaseAdapter {
|
|
|
1401
1439
|
} else {
|
|
1402
1440
|
// Process died mid-message — fall through to spawn a fresh one
|
|
1403
1441
|
this._log(`Persistent process died, falling back to fresh spawn for ${msgChannel}`);
|
|
1442
|
+
if (result.watchdog) {
|
|
1443
|
+
// A long-lived process can wedge on its own, so one restart is
|
|
1444
|
+
// worth it. If the fresh one goes silent too, the spawn path below
|
|
1445
|
+
// stops and says why.
|
|
1446
|
+
try {
|
|
1447
|
+
await this.sendStatus(
|
|
1448
|
+
msgChannel,
|
|
1449
|
+
`Claude produced no output for ${this._watchdogMinutes()} minutes. Restarting it and sending your message again.`,
|
|
1450
|
+
);
|
|
1451
|
+
} catch {}
|
|
1452
|
+
}
|
|
1404
1453
|
}
|
|
1405
1454
|
}
|
|
1406
1455
|
}
|
|
@@ -1487,6 +1536,13 @@ class ClaudeAdapter extends BaseAdapter {
|
|
|
1487
1536
|
|
|
1488
1537
|
if (result.exited) {
|
|
1489
1538
|
this._log(`Process exited during first message (attempt ${attempt + 1})`);
|
|
1539
|
+
if (result.watchdog) {
|
|
1540
|
+
// Silence is not a session that failed to resume. Retrying without
|
|
1541
|
+
// it threw the session away, posted "could not be resumed", and
|
|
1542
|
+
// waited out the same silence again.
|
|
1543
|
+
try { await this.sendError(msgChannel, this._silenceNotice(result.stderrTail)); } catch {}
|
|
1544
|
+
break;
|
|
1545
|
+
}
|
|
1490
1546
|
if (attempt === 0 && this._channelSessions[msgChannel]) {
|
|
1491
1547
|
this._log(`Stale session detected, retrying without resume`);
|
|
1492
1548
|
delete this._channelSessions[msgChannel];
|