lark-remote 0.5.19 → 0.5.21
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 +29 -0
- package/dist/bridge/approval-actions.d.ts +1 -1
- package/dist/bridge/approval-actions.js +1 -1
- package/dist/bridge/bash-run.d.ts +71 -0
- package/dist/bridge/bash-run.js +217 -0
- package/dist/bridge/compact.d.ts +155 -0
- package/dist/bridge/compact.js +450 -0
- package/dist/bridge/final-usage.js +4 -4
- package/dist/bridge/inbound-media.js +72 -46
- package/dist/bridge/index.d.ts +106 -153
- package/dist/bridge/index.js +400 -1000
- package/dist/bridge/job-watch.d.ts +68 -0
- package/dist/bridge/job-watch.js +146 -0
- package/dist/bridge/queue-manager.d.ts +3 -3
- package/dist/bridge/queue-manager.js +10 -29
- package/dist/card/approval-render.d.ts +2 -2
- package/dist/card/approval-render.js +141 -130
- package/dist/card/card-budget.js +123 -98
- package/dist/card/card-helpers.d.ts +3 -3
- package/dist/card/card-helpers.js +6 -6
- package/dist/card/final-answer-file.js +1 -1
- package/dist/card/run-renderer.d.ts +3 -3
- package/dist/card/run-renderer.js +114 -159
- package/dist/card/run-state.d.ts +1 -15
- package/dist/card/run-state.js +358 -292
- package/dist/card/tool-render.d.ts +1 -1
- package/dist/card/tool-render.js +21 -17
- package/dist/card/usage-format.d.ts +22 -7
- package/dist/card/usage-format.js +119 -100
- package/dist/cli.js +15 -3
- package/dist/clone.js +2 -2
- package/dist/common/text-width.js +36 -24
- package/dist/common/tool-summary.js +132 -90
- package/dist/config/codex-config.js +130 -106
- package/dist/config/index.d.ts +16 -2
- package/dist/config/index.js +23 -8
- package/dist/connector/index.js +6 -6
- package/dist/error-classification.js +3 -2
- package/dist/inbound/placeholder.d.ts +1 -1
- package/dist/inbound/placeholder.js +1 -1
- package/dist/index.js +387 -281
- package/dist/logger/index.js +6 -6
- package/dist/message-handlers.d.ts +0 -5
- package/dist/message-handlers.js +254 -237
- package/dist/model-catalog.d.ts +2 -2
- package/dist/model-catalog.js +3 -8
- package/dist/platform/identity.js +1 -1
- package/dist/platform/path.d.ts +1 -1
- package/dist/platform/path.js +1 -1
- package/dist/platform/sleep-blocker.js +1 -1
- package/dist/platform/terminator-win32.js +2 -1
- package/dist/router/commands/ls.d.ts +3 -0
- package/dist/router/commands/ls.js +256 -175
- package/dist/router/commands/order.js +184 -159
- package/dist/router/commands/resume.js +190 -152
- package/dist/router/commands/ws.js +219 -174
- package/dist/router/config/dsh.d.ts +4 -8
- package/dist/router/config/dsh.js +3 -10
- package/dist/router/config/kimi.js +1 -1
- package/dist/router/config/types.d.ts +1 -1
- package/dist/router/config-diff.js +1 -1
- package/dist/router/index.d.ts +56 -11
- package/dist/router/index.js +401 -391
- package/dist/runner/bash/runner.js +2 -4
- package/dist/runner/claude/session.d.ts +1 -1
- package/dist/runner/claude/session.js +6 -4
- package/dist/runner/codex/app-server/runner.d.ts +9 -2
- package/dist/runner/codex/app-server/runner.js +30 -25
- package/dist/runner/codex/app-server/translator.d.ts +2 -5
- package/dist/runner/codex/app-server/translator.js +291 -238
- package/dist/runner/common/acp/acp-approval.d.ts +1 -1
- package/dist/runner/common/acp/acp-approval.js +1 -1
- package/dist/runner/common/acp/base-acp-runner.d.ts +5 -2
- package/dist/runner/common/acp/base-acp-runner.js +26 -65
- package/dist/runner/common/acp/base-translator.d.ts +12 -2
- package/dist/runner/common/acp/base-translator.js +50 -26
- package/dist/runner/common/acp/protocol-types.d.ts +1 -1
- package/dist/runner/common/acp/protocol-types.js +2 -2
- package/dist/runner/common/connection-based-runner.d.ts +32 -1
- package/dist/runner/common/connection-based-runner.js +32 -2
- package/dist/runner/common/jsonl-stream.js +154 -187
- package/dist/runner/common/jsonrpc/client.d.ts +29 -0
- package/dist/runner/common/jsonrpc/client.js +43 -12
- package/dist/runner/common/jsonrpc/connection-manager.d.ts +2 -2
- package/dist/runner/common/jsonrpc/connection-manager.js +4 -4
- package/dist/runner/common/spawning-runner.d.ts +6 -1
- package/dist/runner/common/spawning-runner.js +9 -4
- package/dist/runner/common/turn-started.d.ts +8 -0
- package/dist/runner/common/turn-started.js +11 -0
- package/dist/runner/dsh/approval.js +84 -51
- package/dist/runner/dsh/catalog-probe.d.ts +17 -0
- package/dist/runner/dsh/catalog-probe.js +10 -0
- package/dist/runner/dsh/client.d.ts +7 -11
- package/dist/runner/dsh/client.js +356 -289
- package/dist/runner/dsh/exit-cancel.d.ts +2 -2
- package/dist/runner/dsh/exit-cancel.js +2 -2
- package/dist/runner/dsh/inflight.d.ts +1 -1
- package/dist/runner/dsh/inflight.js +1 -1
- package/dist/runner/dsh/mux-stream.js +28 -8
- package/dist/runner/dsh/runner.d.ts +44 -4
- package/dist/runner/dsh/runner.js +296 -199
- package/dist/runner/dsh/translator.d.ts +1 -31
- package/dist/runner/dsh/translator.js +180 -178
- package/dist/runner/index.d.ts +1 -1
- package/dist/runner/kimi/acp/runner.d.ts +1 -2
- package/dist/runner/kimi/acp/runner.js +82 -46
- package/dist/runner/kimi/acp/translator.d.ts +1 -1
- package/dist/runner/kimi/acp/translator.js +3 -4
- package/dist/runner/opencode/acp/error-monitor.js +5 -5
- package/dist/runner/opencode/acp/runner.d.ts +2 -2
- package/dist/runner/opencode/acp/runner.js +4 -4
- package/dist/runner/pi/rpc/client.js +4 -13
- package/dist/runner/pi/rpc/protocol-types.d.ts +1 -1
- package/dist/runner/pi/rpc/protocol-types.js +1 -1
- package/dist/runner/pi/rpc/runner.d.ts +3 -0
- package/dist/runner/pi/rpc/runner.js +27 -42
- package/dist/runner/pi/rpc/translator.js +61 -60
- package/dist/runner/types.d.ts +2 -2
- package/dist/runner/types.js +1 -1
- package/dist/session/claude/sessions.d.ts +45 -0
- package/dist/session/claude/sessions.js +160 -122
- package/dist/session/codex/rollout-reader.js +181 -182
- package/dist/session/common/throw-session-list-error.d.ts +10 -0
- package/dist/session/common/throw-session-list-error.js +16 -0
- package/dist/session/dsh/sessions.js +291 -235
- package/dist/session/kimi/sessions.d.ts +40 -8
- package/dist/session/kimi/sessions.js +373 -301
- package/dist/session/opencode/sessions.d.ts +142 -1
- package/dist/session/opencode/sessions.js +378 -321
- package/dist/session/pi/sessions.js +4 -5
- package/dist/session/session-store.d.ts +9 -1
- package/dist/session/session-store.js +99 -99
- package/dist/update/version-check.js +2 -1
- package/dist/workspace/index.d.ts +1 -1
- package/dist/workspace/index.js +1 -1
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import { getLogger } from '../../logger/index.js';
|
|
|
2
2
|
import { createShellBackend, ShellUnavailableError, } from '../../platform/shell.js';
|
|
3
3
|
import { createTerminator } from '../../platform/terminator.js';
|
|
4
4
|
import { useDetachedProcessGroup } from '../../platform/spawn.js';
|
|
5
|
-
import { registerExitCleanup, unregisterExitCleanup } from '../common/spawning-runner.js';
|
|
5
|
+
import { isChildProcessRunning, registerExitCleanup, unregisterExitCleanup, } from '../common/spawning-runner.js';
|
|
6
6
|
/**
|
|
7
7
|
* Lightweight bash executor for `!` commands.
|
|
8
8
|
* Spawns `bash -c "<command>"` and yields stdout/stderr/exit as events.
|
|
@@ -38,9 +38,7 @@ export class BashProcessRunner {
|
|
|
38
38
|
this.shell = opts?.shell ?? createShellBackend();
|
|
39
39
|
}
|
|
40
40
|
get isRunning() {
|
|
41
|
-
return (this.currentProcess
|
|
42
|
-
this.currentProcess.exitCode === null &&
|
|
43
|
-
this.currentProcess.signalCode === null);
|
|
41
|
+
return isChildProcessRunning(this.currentProcess);
|
|
44
42
|
}
|
|
45
43
|
async *run(command, opts) {
|
|
46
44
|
if (this.isRunning) {
|
|
@@ -140,7 +140,7 @@ export declare class ClaudeSession extends SpawningRunner {
|
|
|
140
140
|
* 消费事件队列直到本 turn 的 result 事件(非 compact/compaction)。
|
|
141
141
|
* 消费者提前关闭生成器(bridge 循环体抛错)→ 杀进程防孤儿(语义)。
|
|
142
142
|
*
|
|
143
|
-
* result = turn
|
|
143
|
+
* result = turn 终态(长驻模式下 result 之后
|
|
144
144
|
* 不再有 stdout 事件,后台任务完成是静默的;旧 -p 流程「等进程退出再收尾」
|
|
145
145
|
* 的 post-result drain 在长驻模式下无对应物)。
|
|
146
146
|
*/
|
|
@@ -127,7 +127,7 @@ export class ClaudeSession extends SpawningRunner {
|
|
|
127
127
|
// 或 --resume 目标会话)。比较进程当前 session(init 报告值)而非 spawn
|
|
128
128
|
// 请求值:bridge 会把 init 的 session_id 写回 SessionStore,第二条消息
|
|
129
129
|
// 带着它来;若拿 spawn 请求值('')比较,每条消息都会误判切换、杀进程
|
|
130
|
-
//
|
|
130
|
+
// 重启,长驻设计失效。
|
|
131
131
|
if (this.isRunning && this.sessionId !== (opts.sessionId ?? '')) {
|
|
132
132
|
getLogger().info(`[${this.logTag}] session mismatch: process=${this.sessionId || '(fresh)'} ` +
|
|
133
133
|
`requested=${opts.sessionId ?? '(fresh)'}, recycling process`);
|
|
@@ -151,7 +151,7 @@ export class ClaudeSession extends SpawningRunner {
|
|
|
151
151
|
// review:stop()/进程死亡与写 stdin 竞态(EPIPE/ENOTCONN)。用户
|
|
152
152
|
// stop 已置 stoppedByUser(或进程已死/流已结束)时,写入失败不抛给
|
|
153
153
|
// 调用方,交由 consumeTurn 按 interrupted/error 产出终态——否则
|
|
154
|
-
// stop 在途的 run 会以裸 EPIPE 崩溃(
|
|
154
|
+
// stop 在途的 run 会以裸 EPIPE 崩溃(flaky)。
|
|
155
155
|
if (this.stoppedByUser || !this.isRunning || this.streamEnded) {
|
|
156
156
|
getLogger().warn(`[${this.logTag}] user message write failed, process stopping: ${err instanceof Error ? err.message : String(err)}`);
|
|
157
157
|
}
|
|
@@ -383,7 +383,7 @@ export class ClaudeSession extends SpawningRunner {
|
|
|
383
383
|
* 消费事件队列直到本 turn 的 result 事件(非 compact/compaction)。
|
|
384
384
|
* 消费者提前关闭生成器(bridge 循环体抛错)→ 杀进程防孤儿(语义)。
|
|
385
385
|
*
|
|
386
|
-
* result = turn
|
|
386
|
+
* result = turn 终态(长驻模式下 result 之后
|
|
387
387
|
* 不再有 stdout 事件,后台任务完成是静默的;旧 -p 流程「等进程退出再收尾」
|
|
388
388
|
* 的 post-result drain 在长驻模式下无对应物)。
|
|
389
389
|
*/
|
|
@@ -716,7 +716,9 @@ export class ClaudeSession extends SpawningRunner {
|
|
|
716
716
|
void this.writeControlResponse(requestId, {
|
|
717
717
|
behavior: 'deny',
|
|
718
718
|
message: '无法解析 AskUserQuestion 选项',
|
|
719
|
-
}).catch(() => {
|
|
719
|
+
}).catch((err) => {
|
|
720
|
+
getLogger().warn(`[${this.logTag}] AskUserQuestion deny write failed requestId=${requestId}: ${err.message}`);
|
|
721
|
+
});
|
|
720
722
|
// 解析失败 deny 后同样释放条目(不经过 respondPermission)。
|
|
721
723
|
this.pendingToolInputs.delete(requestId);
|
|
722
724
|
return [];
|
|
@@ -62,7 +62,14 @@ export declare class CodexAppServerRunner extends ConnectionBasedRunner<JsonRpcC
|
|
|
62
62
|
protected cancelCurrentTurn(): Promise<void>;
|
|
63
63
|
protected clearTurnState(): void;
|
|
64
64
|
protected releaseConnection(cwd: string): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Wire the acquired client's hooks into the turn dispatcher (anchor-guarded).
|
|
67
|
+
* 代际锚点与 ACP/pi 同口径:连接按 workspace 缓存复用,旧 turn 迟到的通知 /
|
|
68
|
+
* server request / onClose 不得进入新轮(此前 codex 缺这层守卫,属补齐漂移)。
|
|
69
|
+
*/
|
|
70
|
+
private installTurnHooks;
|
|
65
71
|
protected notifyIdle(cwd: string): void;
|
|
72
|
+
protected notifyConnectionActivity(cwd: string): void;
|
|
66
73
|
protected disposeConnections(): Promise<void>;
|
|
67
74
|
/**
|
|
68
75
|
* Run a compact operation on the current thread.
|
|
@@ -100,8 +107,8 @@ export declare class CodexAppServerRunner extends ConnectionBasedRunner<JsonRpcC
|
|
|
100
107
|
*
|
|
101
108
|
* App-server 把已知线程的通知全部复用同一条 stdio 连接:agent 用
|
|
102
109
|
* multi-agent v2 派生子 agent 后,子线程的 `turn/started`、`item/*`、
|
|
103
|
-
* `turn/completed`、`thread/tokenUsage/updated`
|
|
104
|
-
*
|
|
110
|
+
* `turn/completed`、`thread/tokenUsage/updated` 会与本轮通知交错到达。
|
|
111
|
+
* 一个 turn 只属于一个线程,因此外来线程的通知一律
|
|
105
112
|
* 丢弃——否则子线程的 `turn/started` 会覆盖本轮 threadId,会话写回把子
|
|
106
113
|
* 线程 id 当成顶层会话指针存盘(冷连接 `thread/resume` 直接报
|
|
107
114
|
* "cannot resume an unloaded multi-agent v2 sub-agent"),且子线程的
|
|
@@ -58,8 +58,8 @@ function buildRequestUserInputResponse(action, questions, response) {
|
|
|
58
58
|
return;
|
|
59
59
|
const values = Array.isArray(value) ? value : [value];
|
|
60
60
|
const cleaned = values.filter((v) => typeof v === 'string' && v.length > 0);
|
|
61
|
-
// Codex user_note:补充说明编码为 "user_note: <text>" 条目(
|
|
62
|
-
//
|
|
61
|
+
// Codex user_note:补充说明编码为 "user_note: <text>" 条目(deepseek-v4-flash
|
|
62
|
+
// 明确理解并遵守该格式)。
|
|
63
63
|
const note = notes?.[q.question]?.trim();
|
|
64
64
|
if (note)
|
|
65
65
|
cleaned.push(`user_note: ${note}`);
|
|
@@ -184,9 +184,27 @@ export class CodexAppServerRunner extends ConnectionBasedRunner {
|
|
|
184
184
|
async releaseConnection(cwd) {
|
|
185
185
|
await this.connectionManager.release(cwd);
|
|
186
186
|
}
|
|
187
|
+
/**
|
|
188
|
+
* Wire the acquired client's hooks into the turn dispatcher (anchor-guarded).
|
|
189
|
+
* 代际锚点与 ACP/pi 同口径:连接按 workspace 缓存复用,旧 turn 迟到的通知 /
|
|
190
|
+
* server request / onClose 不得进入新轮(此前 codex 缺这层守卫,属补齐漂移)。
|
|
191
|
+
*/
|
|
192
|
+
installTurnHooks(anchor) {
|
|
193
|
+
anchor.client.setHooks({
|
|
194
|
+
onNotification: this.forCurrentTurn(anchor, 'notification', (method, params) => this.handleNotification(method, params)),
|
|
195
|
+
onServerRequest: this.forCurrentTurn(anchor, 'server request', (id, method, params) => this.handleServerRequest(id, method, params)),
|
|
196
|
+
onClose: this.forCurrentTurn(anchor, 'connection close', () => {
|
|
197
|
+
getLogger().warn(`[${this.logTag}] client connection closed`);
|
|
198
|
+
this.failTurn('Codex app-server connection closed');
|
|
199
|
+
}),
|
|
200
|
+
});
|
|
201
|
+
}
|
|
187
202
|
notifyIdle(cwd) {
|
|
188
203
|
this.connectionManager.notifyIdle(cwd);
|
|
189
204
|
}
|
|
205
|
+
notifyConnectionActivity(cwd) {
|
|
206
|
+
this.connectionManager.notifyActivity(cwd);
|
|
207
|
+
}
|
|
190
208
|
async disposeConnections() {
|
|
191
209
|
await this.connectionManager.disposeAll();
|
|
192
210
|
}
|
|
@@ -195,14 +213,9 @@ export class CodexAppServerRunner extends ConnectionBasedRunner {
|
|
|
195
213
|
*/
|
|
196
214
|
async *runCompact(_message, opts) {
|
|
197
215
|
yield* this.executeTurn(opts, async () => {
|
|
198
|
-
const
|
|
199
|
-
this.
|
|
200
|
-
|
|
201
|
-
client.setHooks({
|
|
202
|
-
onNotification: (method, params) => this.handleNotification(method, params),
|
|
203
|
-
onServerRequest: (id, method, params) => this.handleServerRequest(id, method, params),
|
|
204
|
-
onClose: () => this.failTurn('Codex app-server connection closed'),
|
|
205
|
-
});
|
|
216
|
+
const anchor = await this.acquireForTurn(opts.cwd, () => this.connectionManager.acquire(opts.cwd));
|
|
217
|
+
this.installTurnHooks(anchor);
|
|
218
|
+
const { client } = anchor;
|
|
206
219
|
if (!opts.sessionId) {
|
|
207
220
|
throw new Error('compact requires a sessionId');
|
|
208
221
|
}
|
|
@@ -244,8 +257,8 @@ export class CodexAppServerRunner extends ConnectionBasedRunner {
|
|
|
244
257
|
else if (pending.kind === 'permissions') {
|
|
245
258
|
// 权限审批的响应没有 decision 字段(真实协议只回 granted profile +
|
|
246
259
|
// scope):decline/cancel 必须返回空授权(拒绝全部),否则会把用户已
|
|
247
|
-
//
|
|
248
|
-
//
|
|
260
|
+
// 勾选的条目当作授予返回(勾选后点「拒绝」实际授予了所选权限)。
|
|
261
|
+
// accept/acceptForSession 才带用户勾选的条目。
|
|
249
262
|
const denied = action === 'decline' || action === 'cancel';
|
|
250
263
|
client.respond(requestId, {
|
|
251
264
|
permissions: denied
|
|
@@ -344,17 +357,9 @@ export class CodexAppServerRunner extends ConnectionBasedRunner {
|
|
|
344
357
|
* thread/resume(按 sessionId 恢复既有线程)→ turn/start。
|
|
345
358
|
*/
|
|
346
359
|
async setupTurn(message, opts) {
|
|
347
|
-
const
|
|
348
|
-
this.
|
|
349
|
-
|
|
350
|
-
client.setHooks({
|
|
351
|
-
onNotification: (method, params) => this.handleNotification(method, params),
|
|
352
|
-
onServerRequest: (id, method, params) => this.handleServerRequest(id, method, params),
|
|
353
|
-
onClose: () => {
|
|
354
|
-
getLogger().warn(`[${this.logTag}] client connection closed`);
|
|
355
|
-
this.failTurn('Codex app-server connection closed');
|
|
356
|
-
},
|
|
357
|
-
});
|
|
360
|
+
const anchor = await this.acquireForTurn(opts.cwd, () => this.connectionManager.acquire(opts.cwd));
|
|
361
|
+
this.installTurnHooks(anchor);
|
|
362
|
+
const { client } = anchor;
|
|
358
363
|
const threadParams = this.buildThreadParams(opts.cwd);
|
|
359
364
|
let threadId;
|
|
360
365
|
if (opts.sessionId) {
|
|
@@ -387,8 +392,8 @@ export class CodexAppServerRunner extends ConnectionBasedRunner {
|
|
|
387
392
|
*
|
|
388
393
|
* App-server 把已知线程的通知全部复用同一条 stdio 连接:agent 用
|
|
389
394
|
* multi-agent v2 派生子 agent 后,子线程的 `turn/started`、`item/*`、
|
|
390
|
-
* `turn/completed`、`thread/tokenUsage/updated`
|
|
391
|
-
*
|
|
395
|
+
* `turn/completed`、`thread/tokenUsage/updated` 会与本轮通知交错到达。
|
|
396
|
+
* 一个 turn 只属于一个线程,因此外来线程的通知一律
|
|
392
397
|
* 丢弃——否则子线程的 `turn/started` 会覆盖本轮 threadId,会话写回把子
|
|
393
398
|
* 线程 id 当成顶层会话指针存盘(冷连接 `thread/resume` 直接报
|
|
394
399
|
* "cannot resume an unloaded multi-agent v2 sub-agent"),且子线程的
|
|
@@ -14,7 +14,6 @@ export type TranslatorEvent = AgentEvent | TurnStartedEvent | TurnDiffEvent | Ap
|
|
|
14
14
|
export declare class CodexAppServerTranslator {
|
|
15
15
|
private turnId;
|
|
16
16
|
private threadId;
|
|
17
|
-
private turnStatus;
|
|
18
17
|
/** Full agentMessage text per item id (item-scoped snapshot). */
|
|
19
18
|
private textByItem;
|
|
20
19
|
/** agentMessage item ids whose protocol phase is `final_answer`. */
|
|
@@ -69,10 +68,6 @@ export declare class CodexAppServerTranslator {
|
|
|
69
68
|
inputTokens: number;
|
|
70
69
|
outputTokens: number;
|
|
71
70
|
};
|
|
72
|
-
/**
|
|
73
|
-
* Get the current turn status.
|
|
74
|
-
*/
|
|
75
|
-
getTurnStatus(): string;
|
|
76
71
|
/**
|
|
77
72
|
* Set the operation kind (exec vs compact).
|
|
78
73
|
*/
|
|
@@ -124,4 +119,6 @@ export declare class CodexAppServerTranslator {
|
|
|
124
119
|
private reasoningSnapshotFor;
|
|
125
120
|
/** Receive-time stamp, aligned with the exec JSONL parse path. */
|
|
126
121
|
private now;
|
|
122
|
+
/** 把实例状态打包成模块级 handler 可用的显式快照(.bind 保留 this 绑定)。 */
|
|
123
|
+
private translatorState;
|
|
127
124
|
}
|