lark-remote 0.5.6 → 0.5.7
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 +30 -6
- package/README.en.md +2 -2
- package/README.md +2 -2
- package/dist/bridge/index.d.ts +48 -1
- package/dist/bridge/index.js +86 -14
- package/dist/card/card-budget.d.ts +37 -0
- package/dist/card/card-budget.js +128 -5
- package/dist/card/run-renderer.d.ts +24 -0
- package/dist/card/run-renderer.js +256 -60
- package/dist/card/run-state.d.ts +26 -0
- package/dist/card/run-state.js +45 -0
- package/dist/card/time.d.ts +14 -0
- package/dist/card/time.js +30 -0
- package/dist/card/tool-render.d.ts +15 -2
- package/dist/card/tool-render.js +40 -66
- package/dist/common/text-width.d.ts +24 -0
- package/dist/common/text-width.js +93 -0
- package/dist/common/tool-summary.d.ts +11 -0
- package/dist/common/tool-summary.js +153 -0
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.js +1 -1
- package/dist/connector/index.js +1 -1
- package/dist/index.js +61 -6
- package/dist/platform/command.js +1 -1
- package/dist/platform/shell.d.ts +2 -2
- package/dist/platform/spawn.d.ts +1 -1
- package/dist/platform/spawn.js +2 -2
- package/dist/platform/types.d.ts +1 -1
- package/dist/router/card-helpers.d.ts +18 -16
- package/dist/router/card-helpers.js +65 -4
- package/dist/router/index.d.ts +9 -0
- package/dist/router/index.js +57 -7
- package/dist/runner/claude/session.d.ts +1 -1
- package/dist/runner/claude/session.js +3 -3
- package/dist/runner/common/jsonrpc/transport.d.ts +1 -1
- package/dist/runner/common/jsonrpc/transport.js +3 -3
- package/dist/runner/common/spawning-runner.d.ts +1 -1
- package/dist/runner/common/spawning-runner.js +2 -2
- package/dist/runner/dsh/auth.js +2 -1
- package/dist/runner/dsh/client.d.ts +100 -3
- package/dist/runner/dsh/client.js +289 -4
- package/dist/runner/dsh/exit-cancel.d.ts +32 -0
- package/dist/runner/dsh/exit-cancel.js +72 -0
- package/dist/runner/dsh/inflight.d.ts +62 -0
- package/dist/runner/dsh/inflight.js +140 -0
- package/dist/runner/dsh/runner.d.ts +90 -4
- package/dist/runner/dsh/runner.js +436 -18
- package/dist/runner/dsh/translator.d.ts +1 -1
- package/dist/runner/dsh/translator.js +103 -1
- package/dist/runner/dsh/types.d.ts +60 -0
- package/dist/runner/types.d.ts +76 -2
- package/dist/session/claude/sessions.js +2 -2
- package/dist/session/dsh/sessions.js +100 -15
- package/dist/update/install.js +1 -1
- package/package.json +1 -1
|
@@ -6,8 +6,10 @@
|
|
|
6
6
|
* alignment → synthetic system/init (DSH has no init event) → session/prompt
|
|
7
7
|
* (mode:'queue') → consume `session/follow` + `$events` until turn/end.
|
|
8
8
|
*
|
|
9
|
-
* stop() → session/cancel + abort the mux subscription. killOrphan
|
|
10
|
-
*
|
|
9
|
+
* stop() → session/cancel + abort the mux subscription. killOrphan is a no-op
|
|
10
|
+
* (no local process); registerExitHandlers cancels the in-flight turn
|
|
11
|
+
* synchronously on process exit, because the turn lives in the shared host and
|
|
12
|
+
* would otherwise keep running with no subscriber. DSH approvals are
|
|
11
13
|
* two-channel: durable `approval/asked` / `approval/decided` drive the Feishu
|
|
12
14
|
* card, while the answerable `$events` waterfall supplies eventId/clientId.
|
|
13
15
|
* `ask_user_question` prompts arrive only as a `user-questions/request`
|
|
@@ -15,7 +17,7 @@
|
|
|
15
17
|
* approval on the same card. If `$events` is unavailable, the runner falls
|
|
16
18
|
* back to the Web UI prompt.
|
|
17
19
|
*/
|
|
18
|
-
import type { AgentEvent, AgentSessionReader, AgentStatusInfo, SpawnOptions } from '../types.js';
|
|
20
|
+
import type { AgentEvent, AgentSessionReader, AgentStatusInfo, SpawnOptions, StopOutcome } from '../types.js';
|
|
19
21
|
import type { AgentRunner } from '../types.js';
|
|
20
22
|
import { DshClient, type WebSocketFactory } from './client.js';
|
|
21
23
|
import type { DshDaemon } from './daemon.js';
|
|
@@ -48,6 +50,18 @@ export interface DshRunnerOptions {
|
|
|
48
50
|
webSocketImpl?: WebSocketFactory;
|
|
49
51
|
/** Unary request timeout in ms (default 60s); 0 disables. */
|
|
50
52
|
requestTimeoutMs?: number;
|
|
53
|
+
/**
|
|
54
|
+
* 退出路径上取消在途 turn 的传输实现(测试注入)。
|
|
55
|
+
* 默认走同步 curl(`cancelSessionSync`):`process.on('exit')` 里不能 await。
|
|
56
|
+
*/
|
|
57
|
+
cancelOnExit?: (info: {
|
|
58
|
+
baseUrl: string;
|
|
59
|
+
sessionId: string;
|
|
60
|
+
}) => void;
|
|
61
|
+
/**
|
|
62
|
+
* 在途 prompt 的持久化记录文件(启动对账用)。省略 = 不记录(测试、临时实例)。
|
|
63
|
+
*/
|
|
64
|
+
inflightPath?: string;
|
|
51
65
|
}
|
|
52
66
|
export declare class DshRunner implements AgentRunner {
|
|
53
67
|
readonly kind: "dsh";
|
|
@@ -71,6 +85,19 @@ export declare class DshRunner implements AgentRunner {
|
|
|
71
85
|
private activeAbort;
|
|
72
86
|
private activeSessionId;
|
|
73
87
|
private running;
|
|
88
|
+
/** This run's prompt identity (`source.rpcId`); null outside a submitted prompt. */
|
|
89
|
+
private activePromptRequestId;
|
|
90
|
+
/** Whether the current prompt request was accepted by the host. */
|
|
91
|
+
private promptAdmitted;
|
|
92
|
+
/**
|
|
93
|
+
* Releases the next run's prompt only after this stop's withdraw/cancel has
|
|
94
|
+
* been applied. Aborting the local mux lets the queue advance immediately;
|
|
95
|
+
* without the gate the successor's prompt can reach the host before the
|
|
96
|
+
* cancel, and a session-scoped cancel would then hit the *new* turn.
|
|
97
|
+
*/
|
|
98
|
+
private pendingStopGate;
|
|
99
|
+
private pendingStopSessionId;
|
|
100
|
+
private readonly inflight;
|
|
74
101
|
private readonly daemon;
|
|
75
102
|
/**
|
|
76
103
|
* 已对齐模型的 session 集合:同一 session 二次 run 不再重发 selectModel
|
|
@@ -94,6 +121,8 @@ export declare class DshRunner implements AgentRunner {
|
|
|
94
121
|
private readonly toolCalls;
|
|
95
122
|
/** False after `$events` is unavailable; approval/asked then falls back to text. */
|
|
96
123
|
private approvalChannelAvailable;
|
|
124
|
+
/** 退出路径的取消实现(默认同步 curl,见 `cancelSessionSync`)。 */
|
|
125
|
+
private readonly cancelOnExit;
|
|
97
126
|
constructor(opts: DshRunnerOptions);
|
|
98
127
|
get isRunning(): boolean;
|
|
99
128
|
getStatusInfo(): AgentStatusInfo;
|
|
@@ -112,6 +141,16 @@ export declare class DshRunner implements AgentRunner {
|
|
|
112
141
|
* stream keeps either transport from starving the other.
|
|
113
142
|
*/
|
|
114
143
|
private runTurn;
|
|
144
|
+
/**
|
|
145
|
+
* 收尾时仍在跑的后台任务。
|
|
146
|
+
*
|
|
147
|
+
* 只保留非终态(running/stopping):已完成的任务由 agent 自己的 output 呈
|
|
148
|
+
* 现,卡片列出来只会误导"还没跑完"。`job/list` 拿不到时返回空数组——没有
|
|
149
|
+
* 任务列表不等于有任务在跑。
|
|
150
|
+
*/
|
|
151
|
+
private collectBackgroundJobs;
|
|
152
|
+
/** Kill one background job of this runner's session (card button path). */
|
|
153
|
+
killJob(sessionId: string, jobId: string): Promise<boolean>;
|
|
115
154
|
/** Apply the configured permission preset once per session, before prompt. */
|
|
116
155
|
private alignPermissionPreset;
|
|
117
156
|
/** Hot-update the configured preset; the next run aligns it. */
|
|
@@ -160,10 +199,57 @@ export declare class DshRunner implements AgentRunner {
|
|
|
160
199
|
private awaitOrAbort;
|
|
161
200
|
/** Send session/cancel with a short bound; never throws (cleanup path). */
|
|
162
201
|
private cancelSessionQuietly;
|
|
202
|
+
/**
|
|
203
|
+
* Stop this run's work in the shared host.
|
|
204
|
+
*
|
|
205
|
+
* Two distinct things can be running, and DSH needs a different call for each:
|
|
206
|
+
*
|
|
207
|
+
* 1. A prompt that was accepted but not claimed yet still sits in the host
|
|
208
|
+
* inbox. `session/cancel` would NOT drop it (`keepInbox`), so the turn would
|
|
209
|
+
* start later with no subscriber — an orphan. Withdraw it by `rpcId` via
|
|
210
|
+
* `session/updateQueue` instead, and leave the (foreign) active turn alone.
|
|
211
|
+
* 2. An already-claimed turn (or a compact) can only be stopped with
|
|
212
|
+
* `session/cancel`. Since that request is session-scoped and only an
|
|
213
|
+
* acknowledgement, verify the session went idle before reporting success.
|
|
214
|
+
*
|
|
215
|
+
* The gate is held until the host-side action has landed. For a cancel that
|
|
216
|
+
* includes the verification (and possible retry), because a retry cancel is
|
|
217
|
+
* session-scoped and would otherwise hit the successor's new turn.
|
|
218
|
+
*/
|
|
163
219
|
stop(_opts?: {
|
|
164
220
|
immediate?: boolean;
|
|
165
|
-
}): Promise<
|
|
221
|
+
}): Promise<StopOutcome>;
|
|
222
|
+
/** Wait for a concurrent stop to reach the host before submitting a new prompt. */
|
|
223
|
+
private awaitStopGate;
|
|
224
|
+
private performStop;
|
|
225
|
+
/**
|
|
226
|
+
* Locate this run's unclaimed prompt.
|
|
227
|
+
*
|
|
228
|
+
* An already-admitted prompt is visible immediately. A request still in
|
|
229
|
+
* flight can be admitted after stop aborted it, so poll the inbox briefly —
|
|
230
|
+
* that is the only client-side protection against a late orphan turn.
|
|
231
|
+
*/
|
|
232
|
+
private findPendingPromptWithin;
|
|
233
|
+
private removePendingPrompt;
|
|
234
|
+
/** One cancel attempt, then one retry (the request is idempotent when idle). */
|
|
235
|
+
private cancelWithRetry;
|
|
236
|
+
private cancelOnce;
|
|
237
|
+
/** Poll the host until the session reports idle, or the budget runs out. */
|
|
238
|
+
private waitForClosed;
|
|
239
|
+
/** Sleep, but never past the stop deadline. Returns false when out of budget. */
|
|
240
|
+
private sleepWithin;
|
|
241
|
+
private stopProbeTimeout;
|
|
166
242
|
killOrphan(): void;
|
|
243
|
+
/**
|
|
244
|
+
* 退出前取消在途 turn。
|
|
245
|
+
*
|
|
246
|
+
* turn 跑在常驻共享的 `dsh web` host 里,不在本进程的子进程树上;所以
|
|
247
|
+
* "杀自己的子进程"这套退出清理对它无效,桥接一退出,turn 继续无人接收地跑
|
|
248
|
+
* (2026-10-19 实测:一个孤儿 turn 在桥接死后又跑了 2h21m / 345 个 step)。
|
|
249
|
+
* 这里复用进程级退出分发器,用同步 curl 发一次 `session/cancel`。
|
|
250
|
+
*/
|
|
167
251
|
registerExitHandlers(): void;
|
|
168
252
|
unregisterExitHandlers(): void;
|
|
253
|
+
/** Exit dispatcher hook: cancel the in-flight turn, bounded and never throwing. */
|
|
254
|
+
cleanupOnExit(): void;
|
|
169
255
|
}
|