lark-remote 0.4.5 → 0.5.1
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/CHANGELOG.md +34 -0
- package/dist/bridge/approval-coordinator.d.ts +1 -1
- package/dist/bridge/approval-coordinator.js +3 -3
- package/dist/bridge/inbound-media.js +10 -7
- package/dist/bridge/index.d.ts +55 -17
- package/dist/bridge/index.js +145 -74
- package/dist/bridge/queue-manager.d.ts +71 -20
- package/dist/bridge/queue-manager.js +139 -57
- package/dist/card/approval-render.d.ts +1 -1
- package/dist/card/approval-render.js +6 -6
- package/dist/card/bash-card-session.d.ts +3 -3
- package/dist/card/bash-card-session.js +3 -3
- package/dist/card/bash-renderer.js +1 -1
- package/dist/card/card-session.d.ts +4 -4
- package/dist/card/card-session.js +6 -6
- package/dist/card/run-card-session.js +2 -2
- package/dist/card/run-renderer.d.ts +1 -1
- package/dist/card/run-renderer.js +14 -14
- package/dist/card/run-state.d.ts +2 -2
- package/dist/card/run-state.js +3 -3
- package/dist/card/tool-render.d.ts +1 -1
- package/dist/card/tool-render.js +6 -6
- package/dist/cli.js +2 -1
- package/dist/clone.d.ts +5 -3
- package/dist/clone.js +8 -4
- package/dist/common/truncate.d.ts +1 -1
- package/dist/common/truncate.js +2 -2
- package/dist/common/ttl-cache.d.ts +2 -2
- package/dist/common/ttl-cache.js +2 -2
- package/dist/config/codex-config.d.ts +9 -9
- package/dist/config/codex-config.js +18 -18
- package/dist/config/dir.js +5 -2
- package/dist/config/index.d.ts +3 -3
- package/dist/config/index.js +6 -6
- package/dist/config/opencode-config.js +3 -3
- package/dist/connector/index.d.ts +5 -5
- package/dist/connector/index.js +24 -11
- package/dist/inbound/event.d.ts +1 -1
- package/dist/inbound/event.js +1 -1
- package/dist/inbound/placeholder.d.ts +2 -2
- package/dist/inbound/placeholder.js +2 -2
- package/dist/index.js +23 -12
- package/dist/instance-lock.js +4 -3
- package/dist/logger/index.d.ts +1 -1
- package/dist/logger/index.js +4 -4
- package/dist/persistence/atomic-write.d.ts +1 -1
- package/dist/persistence/atomic-write.js +6 -2
- package/dist/platform/agent-stopper.d.ts +1 -1
- package/dist/platform/identity.d.ts +7 -1
- package/dist/platform/identity.js +2 -2
- package/dist/platform/path.d.ts +6 -0
- package/dist/platform/path.js +14 -8
- package/dist/platform/select.d.ts +1 -1
- package/dist/platform/select.js +1 -1
- package/dist/platform/shell.d.ts +2 -3
- package/dist/platform/spawn.d.ts +2 -2
- package/dist/platform/spawn.js +2 -2
- package/dist/platform/terminator-posix.js +1 -1
- package/dist/platform/terminator-win32.js +2 -2
- package/dist/platform/terminator.d.ts +3 -3
- package/dist/platform/terminator.js +2 -2
- package/dist/platform/types.d.ts +1 -1
- package/dist/restart.d.ts +1 -1
- package/dist/restart.js +5 -3
- package/dist/router/config/codex.d.ts +1 -1
- package/dist/router/config/codex.js +2 -2
- package/dist/router/config/opencode.js +1 -1
- package/dist/router/index.d.ts +65 -16
- package/dist/router/index.js +141 -47
- package/dist/router/order-exec-dispatch.js +2 -2
- package/dist/runner/bash/runner.d.ts +2 -2
- package/dist/runner/bash/runner.js +6 -6
- package/dist/runner/claude/runner.js +1 -1
- package/dist/runner/claude/session.d.ts +2 -2
- package/dist/runner/claude/session.js +14 -14
- package/dist/runner/codex/app-server/runner.d.ts +28 -0
- package/dist/runner/codex/app-server/runner.js +57 -4
- package/dist/runner/codex/app-server/translator.d.ts +2 -2
- package/dist/runner/codex/app-server/translator.js +5 -5
- package/dist/runner/common/acp/acp-approval.d.ts +2 -2
- package/dist/runner/common/acp/acp-approval.js +3 -3
- package/dist/runner/common/acp/base-acp-runner.js +1 -1
- package/dist/runner/common/acp/base-translator.d.ts +3 -3
- package/dist/runner/common/acp/base-translator.js +4 -4
- package/dist/runner/common/acp/protocol-types.js +1 -1
- package/dist/runner/common/connection-based-runner.d.ts +1 -1
- package/dist/runner/common/connection-based-runner.js +2 -2
- package/dist/runner/common/jsonl-stream.d.ts +2 -2
- package/dist/runner/common/jsonl-stream.js +12 -12
- package/dist/runner/common/jsonrpc/client.d.ts +1 -1
- package/dist/runner/common/jsonrpc/client.js +1 -1
- package/dist/runner/common/jsonrpc/connection-manager.d.ts +1 -1
- package/dist/runner/common/jsonrpc/connection-manager.js +1 -1
- package/dist/runner/common/jsonrpc/transport.d.ts +1 -1
- package/dist/runner/common/jsonrpc/transport.js +2 -2
- package/dist/runner/common/spawning-runner.d.ts +21 -8
- package/dist/runner/common/spawning-runner.js +41 -15
- package/dist/runner/dsh/runner.js +2 -2
- package/dist/runner/kimi/acp/runner.d.ts +3 -3
- package/dist/runner/kimi/acp/runner.js +9 -9
- package/dist/runner/kimi/acp/translator.d.ts +2 -2
- package/dist/runner/kimi/acp/translator.js +4 -4
- package/dist/runner/opencode/acp/runner.d.ts +2 -2
- package/dist/runner/opencode/acp/runner.js +3 -3
- package/dist/runner/opencode/acp/translator.js +1 -1
- package/dist/runner/pi/rpc/runner.js +2 -2
- package/dist/runner/pi/rpc/translator.d.ts +1 -1
- package/dist/runner/pi/rpc/translator.js +4 -4
- package/dist/runner/types.d.ts +11 -2
- package/dist/runner/types.js +12 -1
- package/dist/session/claude/session-index.d.ts +12 -0
- package/dist/session/claude/session-index.js +20 -5
- package/dist/session/claude/sessions.js +10 -10
- package/dist/session/codex/rollout-reader.d.ts +4 -4
- package/dist/session/codex/rollout-reader.js +12 -12
- package/dist/session/common/two-pass.js +2 -2
- package/dist/session/common/usage-accumulator.d.ts +2 -2
- package/dist/session/common/usage-accumulator.js +2 -2
- package/dist/session/dsh/sessions.js +2 -2
- package/dist/session/kimi/sessions.d.ts +2 -2
- package/dist/session/kimi/sessions.js +11 -11
- package/dist/session/opencode/sessions.d.ts +3 -3
- package/dist/session/opencode/sessions.js +12 -10
- package/dist/session/pi/sessions.js +13 -12
- package/dist/session/session-store.d.ts +1 -1
- package/dist/session/session-store.js +1 -1
- package/package.json +1 -1
|
@@ -61,7 +61,7 @@ export class JsonRpcClient {
|
|
|
61
61
|
* Replace the per-run hooks (used by the runner to bridge
|
|
62
62
|
* notifications/server requests into the active turn's translator).
|
|
63
63
|
* Connection-layer hooks (slot cleanup / onConnectionLost) are preserved:
|
|
64
|
-
*
|
|
64
|
+
* an overwrite here previously silenced onClose slot cleanup,
|
|
65
65
|
* leaving dead slots behind after the server process was killed.
|
|
66
66
|
*/
|
|
67
67
|
setHooks(hooks) {
|
|
@@ -94,7 +94,7 @@ export declare class ConnectionManager<TClient extends ConnectionClient = JsonRp
|
|
|
94
94
|
/** Callback when a connection is lost — cleared from slot map. */
|
|
95
95
|
onConnectionLost?: (cwd: string) => void;
|
|
96
96
|
/**
|
|
97
|
-
*
|
|
97
|
+
* 协议停止通道工厂:连接建立后按 pid 登记到 AgentStopperRegistry,
|
|
98
98
|
* 供 Terminator 在**优雅**停止时回调(win32 上没有可拦截的 SIGTERM,只能靠
|
|
99
99
|
* 协议通道让 agent 自己收摊)。返回 undefined = 该协议无通道。
|
|
100
100
|
*
|
|
@@ -34,7 +34,7 @@ export class ConnectionManager {
|
|
|
34
34
|
/** Callback when a connection is lost — cleared from slot map. */
|
|
35
35
|
onConnectionLost;
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
37
|
+
* 协议停止通道工厂:连接建立后按 pid 登记到 AgentStopperRegistry,
|
|
38
38
|
* 供 Terminator 在**优雅**停止时回调(win32 上没有可拦截的 SIGTERM,只能靠
|
|
39
39
|
* 协议通道让 agent 自己收摊)。返回 undefined = 该协议无通道。
|
|
40
40
|
*
|
|
@@ -42,7 +42,7 @@ export declare class JsonlRpcTransport {
|
|
|
42
42
|
/** 终止器注入(测试用);默认按平台建实现 */
|
|
43
43
|
terminator?: Terminator;
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
45
|
+
* 协议停止通道工厂:spawn 成功后按 pid 建通道并登记到
|
|
46
46
|
* AgentStopperRegistry,进程退出/关闭时注销。返回 undefined = 无通道。
|
|
47
47
|
*/
|
|
48
48
|
stopper?: (pid: number) => AgentStopper | undefined;
|
|
@@ -70,7 +70,7 @@ export class JsonlRpcTransport {
|
|
|
70
70
|
// agent 是用户自己的可信二进制,provider 认证依赖 API key /
|
|
71
71
|
// 自定义 provider 的 env_key,代理环境依赖 HTTP(S)_PROXY、TMPDIR 等;
|
|
72
72
|
// 任何白名单收窄都会打断认证或网络。调用方 this.env 覆盖 process.env 同名键。
|
|
73
|
-
// env 覆盖必须大小写不敏感合并(win32 PATH/Path
|
|
73
|
+
// env 覆盖必须大小写不敏感合并(win32 PATH/Path 双键防护)
|
|
74
74
|
const childEnv = mergeProcessEnv(process.env, this.env);
|
|
75
75
|
const proc = spawnProcess(this.binary, this.args, {
|
|
76
76
|
cwd: this.cwd,
|
|
@@ -195,7 +195,7 @@ export class JsonlRpcTransport {
|
|
|
195
195
|
}
|
|
196
196
|
try {
|
|
197
197
|
// 入队后顺序 flush;write() 返回 false(高水位)时暂停直到 drain,
|
|
198
|
-
// 避免大消息/突发消息在 Node
|
|
198
|
+
// 避免大消息/突发消息在 Node 内部无限缓冲。
|
|
199
199
|
this.writeQueue.push(Buffer.from(JSON.stringify(msg) + '\n', 'utf8'));
|
|
200
200
|
this.flush();
|
|
201
201
|
}
|
|
@@ -4,7 +4,7 @@ import { type Terminator } from '../../platform/terminator.js';
|
|
|
4
4
|
import { SpawnHeartbeat } from './spawn-heartbeat.js';
|
|
5
5
|
import type { SpawnOptions } from '../types.js';
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* 进程级退出监听单例分发(修复,2026-08-02)。
|
|
8
8
|
*
|
|
9
9
|
* 背景:各 agent runner 的 registerExitHandlers 曾是同构复制,每个实例
|
|
10
10
|
* process.on('exit'|'SIGINT'|'SIGTERM') 注册 3 个永不移除的闭包(捕获整个
|
|
@@ -20,13 +20,26 @@ import type { SpawnOptions } from '../types.js';
|
|
|
20
20
|
/**
|
|
21
21
|
* Exit-cleanup contract: anything that spawns a child process group and wants
|
|
22
22
|
* process-level cleanup (agent runners via SpawningRunner, and BashProcessRunner
|
|
23
|
-
* for `!` commands
|
|
23
|
+
* for `!` commands) registers with the singleton dispatcher.
|
|
24
24
|
*/
|
|
25
25
|
interface ExitCleanupHandler {
|
|
26
26
|
cleanupOnExit(): void;
|
|
27
27
|
}
|
|
28
28
|
/** Register a process-exit cleanup handler (installs listeners at most once). */
|
|
29
29
|
export declare function registerExitCleanup(handler: ExitCleanupHandler): void;
|
|
30
|
+
/**
|
|
31
|
+
* pid 文件名的 workspace 后缀:`-<消毒 cwd>-<cwd hash>`。
|
|
32
|
+
*
|
|
33
|
+
* 消毒段(非字母数字 → `_`)只是可读性;不同 cwd 可能消毒出同一段
|
|
34
|
+
* (`/w/a+b` 与 `/w/a_b`),而 killOrphan 的身份校验只比对二进制名——
|
|
35
|
+
* 不掺 hash 时两个 workspace 会共用同一个 pid 文件,启动时的孤儿回收
|
|
36
|
+
* 可能误杀对方 workspace 存活的同名 agent。hash 段按**原始 cwd** 计算,
|
|
37
|
+
* 与消毒无关,消除碰撞。消毒段截到 96 字符,深路径下给 MAX_PATH 留余量。
|
|
38
|
+
*
|
|
39
|
+
* 导出给测试/anchor 复用:任何「手工构造 runner 会写出的 pid 文件路径」的
|
|
40
|
+
* 代码都必须走这里,自己拼一份就是自造半迁移。
|
|
41
|
+
*/
|
|
42
|
+
export declare function pidFileSuffix(cwd: string): string;
|
|
30
43
|
/** Remove a handler so it can be GC'd (agent slots / finished bash runs). */
|
|
31
44
|
export declare function unregisterExitCleanup(handler: ExitCleanupHandler): void;
|
|
32
45
|
/**
|
|
@@ -119,12 +132,12 @@ export declare abstract class SpawningRunner {
|
|
|
119
132
|
protected getStdio(): ('ignore' | 'pipe')[];
|
|
120
133
|
/**
|
|
121
134
|
* Create an async iterator over the child's stdout. Default: createJSONLStream
|
|
122
|
-
*
|
|
135
|
+
* withbackpressure enabled (pauseThreshold=100).
|
|
123
136
|
*/
|
|
124
137
|
protected createStreamReader(stdout: Readable): AsyncGenerator<unknown>;
|
|
125
138
|
/**
|
|
126
139
|
* Await the spawn 'error' event when proc.pid === undefined. Races a
|
|
127
|
-
* finite timeout
|
|
140
|
+
* finite timeout against the 'error' event: Node guarantees
|
|
128
141
|
* 'error' for ENOENT/EACCES, but some binaries fail silently without ever
|
|
129
142
|
* emitting it. Without the race, the spawn lead-in hangs forever → the
|
|
130
143
|
* cwd serial queue never settles → permanent deadlock, and /stop
|
|
@@ -143,7 +156,7 @@ export declare abstract class SpawningRunner {
|
|
|
143
156
|
*/
|
|
144
157
|
protected spawnChild(opts: SpawnOptions): Promise<ChildProcess>;
|
|
145
158
|
/**
|
|
146
|
-
*
|
|
159
|
+
* 登记本进程的协议停止通道:win32 上没有可拦截的跨进程
|
|
147
160
|
* SIGTERM,「优雅停止」只能经 agent 自有通道请求对方自行退出。stdio 型 agent
|
|
148
161
|
* CLI 的通道就是关 stdin(cc-connect 已验证 claude:关 stdin → 干净退出并跑
|
|
149
162
|
* Stop hooks)。
|
|
@@ -166,12 +179,12 @@ export declare abstract class SpawningRunner {
|
|
|
166
179
|
immediate?: boolean;
|
|
167
180
|
}): Promise<void>;
|
|
168
181
|
/**
|
|
169
|
-
*
|
|
182
|
+
* 杀掉上一次崩溃留下的孤儿 agent 进程。**身份校验是动手的前置条件**:
|
|
170
183
|
* pid 文件里的 pid 可能已被系统回收给无关进程,`kill(pid, 0)` 存活探测分不出来。
|
|
171
184
|
*
|
|
172
185
|
* 判定单源 = `platform/identity`(posix `ps -o command=` / win32 CIM),三态:
|
|
173
186
|
* - match → 杀整个进程组(detached:true 下 agent 是组长,与 Terminator
|
|
174
|
-
* posix 路径的 kill(-pid)
|
|
187
|
+
* posix 路径的 kill(-pid) 同语义,子进程不孤儿化);
|
|
175
188
|
* - mismatch → pid 已被无关进程占用:绝不杀,文件是陈旧垃圾,清除自愈;
|
|
176
189
|
* - unknown → 查不到身份(ps 不可用/超时/CIM 被拒):同样不杀,清文件。
|
|
177
190
|
* 统一原则:只有身份匹配才杀,验证失败一律不杀(fail-closed)。
|
|
@@ -198,7 +211,7 @@ export declare abstract class SpawningRunner {
|
|
|
198
211
|
unregisterExitHandlers(): void;
|
|
199
212
|
/**
|
|
200
213
|
* Current number of runners registered with the process-level exit
|
|
201
|
-
* dispatcher. Diagnostics / test-support introspection (
|
|
214
|
+
* dispatcher. Diagnostics / test-support introspection (asserts
|
|
202
215
|
* the count returns to baseline after bridge eviction).
|
|
203
216
|
*/
|
|
204
217
|
static getRegisteredExitHandlerCount(): number;
|
|
@@ -11,7 +11,7 @@ import { SpawnHeartbeat } from './spawn-heartbeat.js';
|
|
|
11
11
|
import { createJSONLStream } from './jsonl-stream.js';
|
|
12
12
|
import { DEFAULT_STOP_GRACE_MS } from '../../config/index.js';
|
|
13
13
|
/**
|
|
14
|
-
* Magic-number constants (Clean Code
|
|
14
|
+
* Magic-number constants (Clean Code G25 Replace Magic Numbers with
|
|
15
15
|
* Named Constants). Centralized here so the truncation budgets are visible
|
|
16
16
|
* and adjustable in one place rather than scattered as raw literals.
|
|
17
17
|
*/
|
|
@@ -22,7 +22,7 @@ class SpawnChildError extends Error {
|
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
24
|
* Timeout (ms) for awaiting the spawn 'error' event when proc.pid === undefined
|
|
25
|
-
*
|
|
25
|
+
* Node guarantees 'error' for ENOENT/EACCES, but some binaries
|
|
26
26
|
* fail silently; the race keeps a silent failure from hanging the spawn lead-in
|
|
27
27
|
* forever. Matches the 5s race kimi's override used before it was hoisted to
|
|
28
28
|
* the base.
|
|
@@ -54,6 +54,33 @@ export function registerExitCleanup(handler) {
|
|
|
54
54
|
installExitListenersOnce();
|
|
55
55
|
registeredRunners.add(handler);
|
|
56
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* FNV-1a 32 位哈希(hex,平台无关确定性):pid 文件后缀的消歧段。
|
|
59
|
+
*/
|
|
60
|
+
function fnv1aHex(text) {
|
|
61
|
+
let hash = 0x811c9dc5;
|
|
62
|
+
for (let i = 0; i < text.length; i++) {
|
|
63
|
+
hash ^= text.charCodeAt(i);
|
|
64
|
+
hash = Math.imul(hash, 0x01000193);
|
|
65
|
+
}
|
|
66
|
+
return (hash >>> 0).toString(16).padStart(8, '0');
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* pid 文件名的 workspace 后缀:`-<消毒 cwd>-<cwd hash>`。
|
|
70
|
+
*
|
|
71
|
+
* 消毒段(非字母数字 → `_`)只是可读性;不同 cwd 可能消毒出同一段
|
|
72
|
+
* (`/w/a+b` 与 `/w/a_b`),而 killOrphan 的身份校验只比对二进制名——
|
|
73
|
+
* 不掺 hash 时两个 workspace 会共用同一个 pid 文件,启动时的孤儿回收
|
|
74
|
+
* 可能误杀对方 workspace 存活的同名 agent。hash 段按**原始 cwd** 计算,
|
|
75
|
+
* 与消毒无关,消除碰撞。消毒段截到 96 字符,深路径下给 MAX_PATH 留余量。
|
|
76
|
+
*
|
|
77
|
+
* 导出给测试/anchor 复用:任何「手工构造 runner 会写出的 pid 文件路径」的
|
|
78
|
+
* 代码都必须走这里,自己拼一份就是自造半迁移。
|
|
79
|
+
*/
|
|
80
|
+
export function pidFileSuffix(cwd) {
|
|
81
|
+
const sanitized = cwd.replace(/[^a-zA-Z0-9]/g, '_').slice(0, 96);
|
|
82
|
+
return `-${sanitized}-${fnv1aHex(cwd)}`;
|
|
83
|
+
}
|
|
57
84
|
/** Remove a handler so it can be GC'd (agent slots / finished bash runs). */
|
|
58
85
|
export function unregisterExitCleanup(handler) {
|
|
59
86
|
registeredRunners.delete(handler);
|
|
@@ -120,9 +147,8 @@ export class SpawningRunner {
|
|
|
120
147
|
this.logTag = opts.logTag ?? 'spawning-runner';
|
|
121
148
|
this.agent = opts.agent;
|
|
122
149
|
const pidDir = opts.pidDir ?? path.join(os.homedir(), '.lark-remote');
|
|
123
|
-
const workspaceSuffix = `-${opts.cwd.replace(/[^a-zA-Z0-9]/g, '_')}`;
|
|
124
150
|
const pidFilePrefix = opts.pidFilePrefix ?? 'spawning';
|
|
125
|
-
this.pidFilePath = path.join(pidDir, `${pidFilePrefix}${
|
|
151
|
+
this.pidFilePath = path.join(pidDir, `${pidFilePrefix}${pidFileSuffix(opts.cwd)}.pid`);
|
|
126
152
|
this.terminator =
|
|
127
153
|
opts.terminator ?? createTerminator({ graceMs: this.stopGraceMs, agent: opts.agent });
|
|
128
154
|
this.spawnHeartbeat = new SpawnHeartbeat(opts.spawnHeartbeatMs ?? 30_000, this.logTag);
|
|
@@ -142,7 +168,7 @@ export class SpawningRunner {
|
|
|
142
168
|
}
|
|
143
169
|
/**
|
|
144
170
|
* Create an async iterator over the child's stdout. Default: createJSONLStream
|
|
145
|
-
*
|
|
171
|
+
* withbackpressure enabled (pauseThreshold=100).
|
|
146
172
|
*/
|
|
147
173
|
createStreamReader(stdout) {
|
|
148
174
|
return createJSONLStream(stdout, {
|
|
@@ -155,7 +181,7 @@ export class SpawningRunner {
|
|
|
155
181
|
}
|
|
156
182
|
/**
|
|
157
183
|
* Await the spawn 'error' event when proc.pid === undefined. Races a
|
|
158
|
-
* finite timeout
|
|
184
|
+
* finite timeout against the 'error' event: Node guarantees
|
|
159
185
|
* 'error' for ENOENT/EACCES, but some binaries fail silently without ever
|
|
160
186
|
* emitting it. Without the race, the spawn lead-in hangs forever → the
|
|
161
187
|
* cwd serial queue never settles → permanent deadlock, and /stop
|
|
@@ -203,7 +229,7 @@ export class SpawningRunner {
|
|
|
203
229
|
}
|
|
204
230
|
this.currentProcess = null;
|
|
205
231
|
this.spawnHeartbeat.clear();
|
|
206
|
-
//
|
|
232
|
+
// surface the real spawn error cause instead of a fixed "binary
|
|
207
233
|
// not found" message. ENOENT (binary missing) keeps the friendly hint,
|
|
208
234
|
// but EMFILE/EACCES/ENOMEM/bad-cwd failures must name the actual reason
|
|
209
235
|
// so the user is not misdiagnosed into reinstalling the binary.
|
|
@@ -219,7 +245,7 @@ export class SpawningRunner {
|
|
|
219
245
|
proc.stdout?.once('data', () => {
|
|
220
246
|
this.spawnHeartbeat.notifyStdout();
|
|
221
247
|
});
|
|
222
|
-
//
|
|
248
|
+
// 协议停止通道登记:子进程起来后立刻登记,win32 上
|
|
223
249
|
// Terminator 停这个 pid 时才能取到通道;进程退出/被停后注销。
|
|
224
250
|
this.registerStopper(proc);
|
|
225
251
|
this.spawnStderr = '';
|
|
@@ -235,7 +261,7 @@ export class SpawningRunner {
|
|
|
235
261
|
this.commandNotFoundSeen = true;
|
|
236
262
|
getLogger().error(`[${this.logTag}] command not found suspected (win32 shim): ${text}`);
|
|
237
263
|
}
|
|
238
|
-
//
|
|
264
|
+
// most agent CLIs emit progress/warnings/deprecation notices on
|
|
239
265
|
// stderr, not real errors. Logging each chunk at error level drowns out
|
|
240
266
|
// genuine errors. Downgrade to warn — the accumulated stderr is already
|
|
241
267
|
// surfaced at error level in the non-zero-exit result path.
|
|
@@ -245,7 +271,7 @@ export class SpawningRunner {
|
|
|
245
271
|
return proc;
|
|
246
272
|
}
|
|
247
273
|
/**
|
|
248
|
-
*
|
|
274
|
+
* 登记本进程的协议停止通道:win32 上没有可拦截的跨进程
|
|
249
275
|
* SIGTERM,「优雅停止」只能经 agent 自有通道请求对方自行退出。stdio 型 agent
|
|
250
276
|
* CLI 的通道就是关 stdin(cc-connect 已验证 claude:关 stdin → 干净退出并跑
|
|
251
277
|
* Stop hooks)。
|
|
@@ -302,12 +328,12 @@ export class SpawningRunner {
|
|
|
302
328
|
getLogger().debug(`[${this.logTag}] cleaned pid file ${this.pidFilePath}`);
|
|
303
329
|
}
|
|
304
330
|
/**
|
|
305
|
-
*
|
|
331
|
+
* 杀掉上一次崩溃留下的孤儿 agent 进程。**身份校验是动手的前置条件**:
|
|
306
332
|
* pid 文件里的 pid 可能已被系统回收给无关进程,`kill(pid, 0)` 存活探测分不出来。
|
|
307
333
|
*
|
|
308
334
|
* 判定单源 = `platform/identity`(posix `ps -o command=` / win32 CIM),三态:
|
|
309
335
|
* - match → 杀整个进程组(detached:true 下 agent 是组长,与 Terminator
|
|
310
|
-
* posix 路径的 kill(-pid)
|
|
336
|
+
* posix 路径的 kill(-pid) 同语义,子进程不孤儿化);
|
|
311
337
|
* - mismatch → pid 已被无关进程占用:绝不杀,文件是陈旧垃圾,清除自愈;
|
|
312
338
|
* - unknown → 查不到身份(ps 不可用/超时/CIM 被拒):同样不杀,清文件。
|
|
313
339
|
* 统一原则:只有身份匹配才杀,验证失败一律不杀(fail-closed)。
|
|
@@ -343,7 +369,7 @@ export class SpawningRunner {
|
|
|
343
369
|
return;
|
|
344
370
|
}
|
|
345
371
|
// 身份匹配:杀整个进程组(detached:true 下 agent 是组长),与
|
|
346
|
-
// Terminator 的 kill(-pid)
|
|
372
|
+
// Terminator 的 kill(-pid) 语义对齐,子进程不会孤儿化。
|
|
347
373
|
getLogger().info(`[${this.logTag}] killing orphan process group ${-pid}`);
|
|
348
374
|
try {
|
|
349
375
|
process.kill(-pid, 'SIGTERM');
|
|
@@ -377,7 +403,7 @@ export class SpawningRunner {
|
|
|
377
403
|
}
|
|
378
404
|
/**
|
|
379
405
|
* Current number of runners registered with the process-level exit
|
|
380
|
-
* dispatcher. Diagnostics / test-support introspection (
|
|
406
|
+
* dispatcher. Diagnostics / test-support introspection (asserts
|
|
381
407
|
* the count returns to baseline after bridge eviction).
|
|
382
408
|
*/
|
|
383
409
|
static getRegisteredExitHandlerCount() {
|
|
@@ -392,7 +418,7 @@ export class SpawningRunner {
|
|
|
392
418
|
cleanupOnExit() {
|
|
393
419
|
if (this.currentProcess && this.currentProcess.exitCode === null) {
|
|
394
420
|
try {
|
|
395
|
-
//
|
|
421
|
+
// 只杀组长会让组内子进程(工具调用起的后台进程)reparent 成孤儿。
|
|
396
422
|
// Terminator.cleanupOnExit 在两种平台上都是「fire-and-forget 强杀整个
|
|
397
423
|
// 进程组/进程树」(posix kill(-pgid, SIGKILL) / win32 taskkill /T /F),
|
|
398
424
|
// 退出路径上无法等待,也不需要优雅段。
|
|
@@ -67,7 +67,7 @@ export class DshRunner {
|
|
|
67
67
|
let sessionId = opts.sessionId;
|
|
68
68
|
let terminalEmitted = false;
|
|
69
69
|
try {
|
|
70
|
-
//
|
|
70
|
+
// session.create 必须包进同一 try/finally,否则创建失败(服务端不可达/报错)
|
|
71
71
|
// 会在进入旧 try 之前抛异常,finally 不执行 → running 恒 true、activeAbort 残留。
|
|
72
72
|
if (!sessionId) {
|
|
73
73
|
const created = await this.client.createSession({
|
|
@@ -188,7 +188,7 @@ export class DshRunner {
|
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
catch (err) {
|
|
191
|
-
//
|
|
191
|
+
// createSession 等启动期失败也产出 error result(而非抛异常),
|
|
192
192
|
// 由本 catch 统一转 error result;state 清理在 finally。
|
|
193
193
|
if (!abort.signal.aborted) {
|
|
194
194
|
yield {
|
|
@@ -83,7 +83,7 @@ export declare class KimiAcpRunner extends BaseAcpRunner<KimiAcpTranslator> {
|
|
|
83
83
|
*/
|
|
84
84
|
private readonly terminator;
|
|
85
85
|
/**
|
|
86
|
-
* shell seam:terminal/create
|
|
86
|
+
* shell seam:terminal/create 的可执行解析走这里。kimi 的
|
|
87
87
|
* ACP 服务端固定要 `bash -c`,win32 上没有 Git Bash 时必须在 seam 里变成
|
|
88
88
|
* 明确错误,而不是一个语焉不详的 spawn ENOENT。
|
|
89
89
|
*/
|
|
@@ -105,7 +105,7 @@ export declare class KimiAcpRunner extends BaseAcpRunner<KimiAcpTranslator> {
|
|
|
105
105
|
* before producing the result. There is NO total timeout — silence beyond
|
|
106
106
|
* compactIdleTimeoutMs yields 'unknown' (never a fake success). Keeps the
|
|
107
107
|
* connection alive while the background compaction finishes — otherwise
|
|
108
|
-
* dispose/exit kills it and the record never lands (
|
|
108
|
+
* dispose/exit kills it and the record never lands (打回复现 /
|
|
109
109
|
* 2026-08-31 事故).
|
|
110
110
|
*/
|
|
111
111
|
protected compactBaseline(sessionId: string, opts: SpawnOptions): number;
|
|
@@ -113,7 +113,7 @@ export declare class KimiAcpRunner extends BaseAcpRunner<KimiAcpTranslator> {
|
|
|
113
113
|
protected buildApprovalOutcome(action: string, pending: AcpPendingApproval, response: unknown): unknown;
|
|
114
114
|
getStatusInfo(): AgentStatusInfo;
|
|
115
115
|
/**
|
|
116
|
-
* Hot-apply a permission-mode change to the live ACP session
|
|
116
|
+
* Hot-apply a permission-mode change to the live ACP session.
|
|
117
117
|
*
|
|
118
118
|
* The local cache is always updated so `getStatusInfo()` (and therefore
|
|
119
119
|
* `/s`) reflects the new mode immediately. When a session is connected,
|
|
@@ -163,7 +163,7 @@ export class KimiAcpRunner extends BaseAcpRunner {
|
|
|
163
163
|
*/
|
|
164
164
|
terminator = createTerminator({ graceMs: 2_000, agent: 'kimi' });
|
|
165
165
|
/**
|
|
166
|
-
* shell seam:terminal/create
|
|
166
|
+
* shell seam:terminal/create 的可执行解析走这里。kimi 的
|
|
167
167
|
* ACP 服务端固定要 `bash -c`,win32 上没有 Git Bash 时必须在 seam 里变成
|
|
168
168
|
* 明确错误,而不是一个语焉不详的 spawn ENOENT。
|
|
169
169
|
*/
|
|
@@ -224,7 +224,7 @@ export class KimiAcpRunner extends BaseAcpRunner {
|
|
|
224
224
|
return new KimiAcpTranslator();
|
|
225
225
|
}
|
|
226
226
|
async applyTurnSettings(client, sessionId) {
|
|
227
|
-
//
|
|
227
|
+
// 下发配置的模型(provider/model)。session/new|resume 只带 cwd/mcpServers,
|
|
228
228
|
// 不带 model;不主动下发则实际跑 kimi 服务端默认模型。
|
|
229
229
|
// 仿 opencode 用 session/set_config_option。失败仅告警不阻断。
|
|
230
230
|
if (this.model) {
|
|
@@ -239,7 +239,7 @@ export class KimiAcpRunner extends BaseAcpRunner {
|
|
|
239
239
|
getLogger().warn(`[${this.logTag}] set_config_option model failed (non-fatal): ${err.message}`);
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
|
-
//
|
|
242
|
+
// 下发配置的思考强度。configId 与取值不是猜的——kimi 真机(0.43.1)
|
|
243
243
|
// `session/new` 就通告 `{id:'thinking', category:'thought_level',
|
|
244
244
|
// options:[low|high|max]}`,set 成功后响应里 `currentValue` 变成新值;
|
|
245
245
|
// 未知 configId / 非法取值回 -32602(不静默接受),所以失败告警即可判定。
|
|
@@ -283,7 +283,7 @@ export class KimiAcpRunner extends BaseAcpRunner {
|
|
|
283
283
|
* before producing the result. There is NO total timeout — silence beyond
|
|
284
284
|
* compactIdleTimeoutMs yields 'unknown' (never a fake success). Keeps the
|
|
285
285
|
* connection alive while the background compaction finishes — otherwise
|
|
286
|
-
* dispose/exit kills it and the record never lands (
|
|
286
|
+
* dispose/exit kills it and the record never lands (打回复现 /
|
|
287
287
|
* 2026-08-31 事故).
|
|
288
288
|
*/
|
|
289
289
|
compactBaseline(sessionId, opts) {
|
|
@@ -300,7 +300,7 @@ export class KimiAcpRunner extends BaseAcpRunner {
|
|
|
300
300
|
const baselineTerminalCount = this.compactBaselineRecords.filter(isCompactionTerminalLike).length;
|
|
301
301
|
let promptRejected = false;
|
|
302
302
|
// prompt 结算只供两样东西:成功 result 的翻译素材(stopReason/usage)与 §5.4
|
|
303
|
-
//
|
|
303
|
+
// 探针。终态判定不再挂在它后面。
|
|
304
304
|
const promptSettled = promptPromise.then((result) => {
|
|
305
305
|
this.promptSettled = true;
|
|
306
306
|
if (compactionReader) {
|
|
@@ -326,7 +326,7 @@ export class KimiAcpRunner extends BaseAcpRunner {
|
|
|
326
326
|
});
|
|
327
327
|
return;
|
|
328
328
|
}
|
|
329
|
-
//
|
|
329
|
+
// 语义等待在 prompt 触发的那一刻武装。引擎静默超过 compactIdleTimeoutMs
|
|
330
330
|
// 就给出 compact 语义终态,不等 session/prompt 结算——否则挂住的 prompt 会把
|
|
331
331
|
// 用户拖到通用 turnIdleTimeout(默认 30min),拿到的还是一个语义泛化的 turn
|
|
332
332
|
// 超时,而不是「压缩状态未知 / 可重试」。
|
|
@@ -372,7 +372,7 @@ export class KimiAcpRunner extends BaseAcpRunner {
|
|
|
372
372
|
};
|
|
373
373
|
}
|
|
374
374
|
/**
|
|
375
|
-
* Hot-apply a permission-mode change to the live ACP session
|
|
375
|
+
* Hot-apply a permission-mode change to the live ACP session.
|
|
376
376
|
*
|
|
377
377
|
* The local cache is always updated so `getStatusInfo()` (and therefore
|
|
378
378
|
* `/s`) reflects the new mode immediately. When a session is connected,
|
|
@@ -553,14 +553,14 @@ export class KimiAcpRunner extends BaseAcpRunner {
|
|
|
553
553
|
: undefined;
|
|
554
554
|
const cwd = params.cwd ?? this.activeCwd ?? undefined;
|
|
555
555
|
const outputLimit = params.outputByteLimit ?? TERMINAL_DEFAULT_OUTPUT_LIMIT;
|
|
556
|
-
// 走 shell seam
|
|
556
|
+
// 走 shell seam:argv 逐 token 保留,只把「可执行文件在哪」
|
|
557
557
|
// 收口——win32 上 Git Bash 缺失时在这里抛 ShellUnavailableError,由
|
|
558
558
|
// handleTerminalRequest 转成明确的 Terminal request failed 回执,而不是一个
|
|
559
559
|
// 语焉不详的 spawn ENOENT。
|
|
560
560
|
const proc = this.shell.spawnArgv(params.command, params.args ?? [], {
|
|
561
561
|
cwd,
|
|
562
562
|
options: {
|
|
563
|
-
// env 覆盖大小写不敏感合并(win32 PATH/Path
|
|
563
|
+
// env 覆盖大小写不敏感合并(win32 PATH/Path 双键防护)
|
|
564
564
|
env: env ? mergeProcessEnv(process.env, env) : undefined,
|
|
565
565
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
566
566
|
// Terminator 用负 PID 杀进程组(kill(-pgid));子进程必须是组长
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
* accumulates text/thinking deltas and emits turn_diff snapshots (NOT
|
|
9
9
|
* assistant deltas — see handleAgentMessageChunk), plus question elicitation.
|
|
10
10
|
*
|
|
11
|
-
* Wire envelope (
|
|
11
|
+
* Wire envelope (source: kimi-code packages/acp-server/src/events-map.ts,
|
|
12
12
|
* verified live 2026-08-15/16 against kimi 0.36.0):
|
|
13
13
|
* session/update params = {sessionId, update: {sessionUpdate: '<kind>', ...}}
|
|
14
14
|
* — the discriminator is `update.sessionUpdate`, NOT a nested `event.type`.
|
|
15
15
|
*
|
|
16
|
-
* Event mapping
|
|
16
|
+
* Event mapping:
|
|
17
17
|
* agent_message_chunk → turn_diff text snapshot (content.text accumulation)
|
|
18
18
|
* agent_thought_chunk → turn_diff reasoning snapshot (content.text accumulation)
|
|
19
19
|
* tool_call / tool_call_update / usage_update / plan / control-plane noise →
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
* accumulates text/thinking deltas and emits turn_diff snapshots (NOT
|
|
9
9
|
* assistant deltas — see handleAgentMessageChunk), plus question elicitation.
|
|
10
10
|
*
|
|
11
|
-
* Wire envelope (
|
|
11
|
+
* Wire envelope (source: kimi-code packages/acp-server/src/events-map.ts,
|
|
12
12
|
* verified live 2026-08-15/16 against kimi 0.36.0):
|
|
13
13
|
* session/update params = {sessionId, update: {sessionUpdate: '<kind>', ...}}
|
|
14
14
|
* — the discriminator is `update.sessionUpdate`, NOT a nested `event.type`.
|
|
15
15
|
*
|
|
16
|
-
* Event mapping
|
|
16
|
+
* Event mapping:
|
|
17
17
|
* agent_message_chunk → turn_diff text snapshot (content.text accumulation)
|
|
18
18
|
* agent_thought_chunk → turn_diff reasoning snapshot (content.text accumulation)
|
|
19
19
|
* tool_call / tool_call_update / usage_update / plan / control-plane noise →
|
|
@@ -53,7 +53,7 @@ export class KimiAcpTranslator extends BaseAcpTranslator {
|
|
|
53
53
|
// Use a stable key for the current text stream. Kimi ACP doesn't
|
|
54
54
|
// provide an itemId in agent_message_chunk; we use 'text' as the
|
|
55
55
|
// single logical text accumulator (one text stream per turn).
|
|
56
|
-
//
|
|
56
|
+
// wire chunk text lives at content.text and is a DELTA
|
|
57
57
|
// (kimi-code events-map.ts assistantDeltaToSessionUpdate:
|
|
58
58
|
// content.text = event.delta), so we accumulate here into a full-text
|
|
59
59
|
// snapshot and emit it as turn_diff. The card reducer's turn_diff path
|
|
@@ -145,7 +145,7 @@ export class KimiAcpTranslator extends BaseAcpTranslator {
|
|
|
145
145
|
: summary
|
|
146
146
|
? truncateWithEllipsis(summary, 200)
|
|
147
147
|
: undefined,
|
|
148
|
-
//
|
|
148
|
+
// 从服务端 options kind 派生——带 approve_always(或 allow_always)
|
|
149
149
|
// 才提供「本会话总是允许」(acceptForSession);否则与旧行为一致。
|
|
150
150
|
availableDecisions: deriveAcpAvailableDecisions(params.options ?? []),
|
|
151
151
|
};
|
|
@@ -51,7 +51,7 @@ export interface OpencodeAcpRunnerOptions {
|
|
|
51
51
|
errorMonitorPollIntervalMs?: number;
|
|
52
52
|
}
|
|
53
53
|
export declare class OpencodeAcpRunner extends BaseAcpRunner<OpencodeAcpTranslator> {
|
|
54
|
-
/** Configured session mode applied via session/set_mode
|
|
54
|
+
/** Configured session mode applied via session/set_mode. */
|
|
55
55
|
private configuredMode;
|
|
56
56
|
/** Current session mode id, parsed from session/new|resume configOptions. */
|
|
57
57
|
private currentModeId?;
|
|
@@ -86,7 +86,7 @@ export declare class OpencodeAcpRunner extends BaseAcpRunner<OpencodeAcpTranslat
|
|
|
86
86
|
protected buildApprovalOutcome(action: string, pending: AcpPendingApproval, _response: unknown): unknown;
|
|
87
87
|
getStatusInfo(): AgentStatusInfo;
|
|
88
88
|
/**
|
|
89
|
-
* Hot-apply a mode change to the live ACP session
|
|
89
|
+
* Hot-apply a mode change to the live ACP session.
|
|
90
90
|
*
|
|
91
91
|
* opencode's session/set_mode sends no notification — the client refreshes
|
|
92
92
|
* the local mode view itself. The local mode is always updated so
|
|
@@ -30,7 +30,7 @@ import { OpencodeLogErrorMonitor, resolveOpencodeLogPath } from './error-monitor
|
|
|
30
30
|
// Runner
|
|
31
31
|
// =============================================================================
|
|
32
32
|
export class OpencodeAcpRunner extends BaseAcpRunner {
|
|
33
|
-
/** Configured session mode applied via session/set_mode
|
|
33
|
+
/** Configured session mode applied via session/set_mode. */
|
|
34
34
|
configuredMode;
|
|
35
35
|
/** Current session mode id, parsed from session/new|resume configOptions. */
|
|
36
36
|
currentModeId;
|
|
@@ -103,7 +103,7 @@ export class OpencodeAcpRunner extends BaseAcpRunner {
|
|
|
103
103
|
return new OpencodeAcpTranslator();
|
|
104
104
|
}
|
|
105
105
|
async applyTurnSettings(client, sessionId) {
|
|
106
|
-
//
|
|
106
|
+
// apply the configured mode (build/plan). If the session already
|
|
107
107
|
// runs it (from session/new|resume configOptions), skip the wire call;
|
|
108
108
|
// otherwise send session/set_mode and refresh the local view (opencode
|
|
109
109
|
// sends no notification for set_mode).
|
|
@@ -160,7 +160,7 @@ export class OpencodeAcpRunner extends BaseAcpRunner {
|
|
|
160
160
|
};
|
|
161
161
|
}
|
|
162
162
|
/**
|
|
163
|
-
* Hot-apply a mode change to the live ACP session
|
|
163
|
+
* Hot-apply a mode change to the live ACP session.
|
|
164
164
|
*
|
|
165
165
|
* opencode's session/set_mode sends no notification — the client refreshes
|
|
166
166
|
* the local mode view itself. The local mode is always updated so
|
|
@@ -176,7 +176,7 @@ export class OpencodeAcpTranslator extends BaseAcpTranslator {
|
|
|
176
176
|
kind: 'command',
|
|
177
177
|
command: params.toolCall.title ?? undefined,
|
|
178
178
|
reason: rawInput ? truncateWithEllipsis(stringify(rawInput), 200) : undefined,
|
|
179
|
-
//
|
|
179
|
+
// 从服务端 options kind 派生——带 allow_always(或 approve_always)
|
|
180
180
|
// 才提供「本会话总是允许」(acceptForSession)。
|
|
181
181
|
availableDecisions: deriveAcpAvailableDecisions(params.options ?? []),
|
|
182
182
|
};
|
|
@@ -53,7 +53,7 @@ export class PiRpcRunner extends ConnectionBasedRunner {
|
|
|
53
53
|
idleTtlMs: opts.idleTtlMs,
|
|
54
54
|
logTag: 'pi-rpc-connection-manager',
|
|
55
55
|
});
|
|
56
|
-
//
|
|
56
|
+
// 协议停止通道:pi 的 cancel 是 `{type:'abort'}` 通知,已由
|
|
57
57
|
// cancelCurrentTurn 实现;登记后 win32 优雅停止才有通道可用(否则一路树杀)。
|
|
58
58
|
this.manager.stopper = ({ client }) => this.buildCooperativeStop(client);
|
|
59
59
|
}
|
|
@@ -139,7 +139,7 @@ export class PiRpcRunner extends ConnectionBasedRunner {
|
|
|
139
139
|
this.promptSettled = false;
|
|
140
140
|
const response = await client.request({ type: 'prompt', message });
|
|
141
141
|
if (!response.success) {
|
|
142
|
-
//
|
|
142
|
+
// pi 返回 success:false(无效模型/provider 错误/忙)时立即失败,
|
|
143
143
|
// 不能当成成功 ACK 继续等 agent_settled(否则最长 turn idle timeout)。
|
|
144
144
|
throw new Error(`pi prompt failed: ${response.error ?? 'unknown error'}`);
|
|
145
145
|
}
|
|
@@ -32,7 +32,7 @@ export declare class PiRpcTranslator {
|
|
|
32
32
|
private accReasoning;
|
|
33
33
|
private lastTotalTokens;
|
|
34
34
|
private hasUsage;
|
|
35
|
-
/** toolcall_start bookkeeping:占位不发事件,end 时补发完整 tool_use
|
|
35
|
+
/** toolcall_start bookkeeping:占位不发事件,end 时补发完整 tool_use。 */
|
|
36
36
|
private pendingToolCall;
|
|
37
37
|
/** Provider failure (stopReason="error") on the final assistant message. */
|
|
38
38
|
private lastAssistantStopReason;
|
|
@@ -23,7 +23,7 @@ export class PiRpcTranslator {
|
|
|
23
23
|
accReasoning = 0;
|
|
24
24
|
lastTotalTokens;
|
|
25
25
|
hasUsage = false;
|
|
26
|
-
/** toolcall_start bookkeeping:占位不发事件,end 时补发完整 tool_use
|
|
26
|
+
/** toolcall_start bookkeeping:占位不发事件,end 时补发完整 tool_use。 */
|
|
27
27
|
pendingToolCall = false;
|
|
28
28
|
/** Provider failure (stopReason="error") on the final assistant message. */
|
|
29
29
|
lastAssistantStopReason;
|
|
@@ -98,7 +98,7 @@ export class PiRpcTranslator {
|
|
|
98
98
|
return [];
|
|
99
99
|
}
|
|
100
100
|
case 'compaction_start': {
|
|
101
|
-
// 信息保真
|
|
101
|
+
// 信息保真 压缩过程用户可见(info 通知),不再静默。
|
|
102
102
|
const c = evt;
|
|
103
103
|
return [
|
|
104
104
|
{
|
|
@@ -125,7 +125,7 @@ export class PiRpcTranslator {
|
|
|
125
125
|
}
|
|
126
126
|
default:
|
|
127
127
|
// turn_start/turn_end, agent_start/agent_end, tool_execution_*, and
|
|
128
|
-
// unknown types are ignored. (compaction_start/end
|
|
128
|
+
// unknown types are ignored. (compaction_start/end 映射为
|
|
129
129
|
// notice 事件,不再静默。)
|
|
130
130
|
return [];
|
|
131
131
|
}
|
|
@@ -269,7 +269,7 @@ export class PiRpcTranslator {
|
|
|
269
269
|
}
|
|
270
270
|
break;
|
|
271
271
|
case 'toolcall_start':
|
|
272
|
-
// 信息保真
|
|
272
|
+
// 信息保真 不再 push 空壳 tool_use(空 id/name 会被渲染成
|
|
273
273
|
// 无意义工具块)。只保留 bookkeeping,toolcall_end 补发完整事件。
|
|
274
274
|
this.pendingToolCall = true;
|
|
275
275
|
break;
|
package/dist/runner/types.d.ts
CHANGED
|
@@ -395,14 +395,23 @@ export interface Runner {
|
|
|
395
395
|
killOrphan(): void;
|
|
396
396
|
registerExitHandlers(): void;
|
|
397
397
|
/**
|
|
398
|
-
* Remove the runner from the process-level exit dispatcher
|
|
398
|
+
* Remove the runner from the process-level exit dispatcher. Called by
|
|
399
399
|
* the bridge when the (cwd, kind) cache slot is evicted so the instance is
|
|
400
400
|
* not retained by the singleton dispatcher. Optional so test stubs that only
|
|
401
401
|
* satisfy `registerExitHandlers` remain structurally valid.
|
|
402
402
|
*/
|
|
403
403
|
unregisterExitHandlers?(): void;
|
|
404
404
|
}
|
|
405
|
-
|
|
405
|
+
/**
|
|
406
|
+
* Agent 名单单源(运行时数组 + 类型同源,二者不可能漂移)。
|
|
407
|
+
*
|
|
408
|
+
* 历史上这份名单被手抄成多份(router 的 VALID_AGENTS、bridge 的 resume.compact
|
|
409
|
+
* 校验、各 agent 的 config builder…),漂移过:dsh 加入后 bridge 的
|
|
410
|
+
* resume.compact 仍只有 5 个,带 dsh 的 resume 卡片会静默退回 defaultAgent。
|
|
411
|
+
* 新增 agent 只改这里。
|
|
412
|
+
*/
|
|
413
|
+
export declare const AGENT_KINDS: readonly ["claude", "codex", "opencode", "pi", "kimi", "dsh"];
|
|
414
|
+
export type AgentKind = (typeof AGENT_KINDS)[number];
|
|
406
415
|
/** Unified session descriptor returned by every AgentSessionReader. */
|
|
407
416
|
export interface AgentSession {
|
|
408
417
|
sessionId: string;
|