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
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* - isSessionActive: use `updated` timestamp with 1 hour stale window.
|
|
16
16
|
* - Simple memory cache with TTL.
|
|
17
17
|
*/
|
|
18
|
-
import type { AgentSession, AgentSessionReader, SessionContent } from '../../session-contract.js';
|
|
18
|
+
import type { AgentSession, AgentSessionReader, AgentSessionUsage, SessionContent } from '../../session-contract.js';
|
|
19
19
|
interface OpencodeSessionReaderOptions {
|
|
20
20
|
/** Path to the opencode binary. Defaults to `opencode`. */
|
|
21
21
|
binary?: string;
|
|
@@ -28,6 +28,134 @@ interface OpencodeSessionReaderOptions {
|
|
|
28
28
|
*/
|
|
29
29
|
captureExport?: (sessionId: string) => string;
|
|
30
30
|
}
|
|
31
|
+
/** v1 export 单条消息(外部 JSON 契约,导出供扫描累积器单测构造)。 */
|
|
32
|
+
export interface OpencodeExportMessage {
|
|
33
|
+
info: {
|
|
34
|
+
role: 'user' | 'assistant';
|
|
35
|
+
time?: {
|
|
36
|
+
created: number;
|
|
37
|
+
};
|
|
38
|
+
id: string;
|
|
39
|
+
sessionID: string;
|
|
40
|
+
};
|
|
41
|
+
parts: Array<{
|
|
42
|
+
type: string;
|
|
43
|
+
text?: string;
|
|
44
|
+
tool?: string;
|
|
45
|
+
callID?: string;
|
|
46
|
+
state?: {
|
|
47
|
+
status: string;
|
|
48
|
+
input?: Record<string, unknown>;
|
|
49
|
+
output?: string;
|
|
50
|
+
error?: string;
|
|
51
|
+
};
|
|
52
|
+
reason?: string;
|
|
53
|
+
tokens?: {
|
|
54
|
+
total: number;
|
|
55
|
+
input: number;
|
|
56
|
+
output: number;
|
|
57
|
+
reasoning: number;
|
|
58
|
+
cache?: {
|
|
59
|
+
read: number;
|
|
60
|
+
write: number;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
}>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* v2 `session export` messages are flattened: `{type, text, content}` rather
|
|
67
|
+
* than v1's `{info, parts}` envelope. Keep the v2 types local to this reader —
|
|
68
|
+
* they are an external JSON contract, not an internal model.
|
|
69
|
+
*/
|
|
70
|
+
/** v2 export 单条消息(外部 JSON 契约,导出供扫描累积器单测构造)。 */
|
|
71
|
+
export interface OpencodeV2Message {
|
|
72
|
+
id?: string;
|
|
73
|
+
type: string;
|
|
74
|
+
time?: {
|
|
75
|
+
created?: number;
|
|
76
|
+
completed?: number;
|
|
77
|
+
};
|
|
78
|
+
text?: string;
|
|
79
|
+
content?: Array<OpencodeV2ContentPart>;
|
|
80
|
+
tokens?: {
|
|
81
|
+
input: number;
|
|
82
|
+
output: number;
|
|
83
|
+
reasoning: number;
|
|
84
|
+
cache?: {
|
|
85
|
+
read: number;
|
|
86
|
+
write: number;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
error?: {
|
|
90
|
+
type?: string;
|
|
91
|
+
message?: string;
|
|
92
|
+
};
|
|
93
|
+
command?: string;
|
|
94
|
+
output?: string;
|
|
95
|
+
callID?: string;
|
|
96
|
+
summary?: string;
|
|
97
|
+
}
|
|
98
|
+
interface OpencodeV2ContentPart {
|
|
99
|
+
type: string;
|
|
100
|
+
text?: string;
|
|
101
|
+
id?: string;
|
|
102
|
+
name?: string;
|
|
103
|
+
state?: {
|
|
104
|
+
status?: string;
|
|
105
|
+
input?: unknown;
|
|
106
|
+
content?: Array<{
|
|
107
|
+
type?: string;
|
|
108
|
+
text?: string;
|
|
109
|
+
content?: {
|
|
110
|
+
type?: string;
|
|
111
|
+
text?: string;
|
|
112
|
+
};
|
|
113
|
+
}>;
|
|
114
|
+
error?: {
|
|
115
|
+
type?: string;
|
|
116
|
+
message?: string;
|
|
117
|
+
} | string;
|
|
118
|
+
result?: unknown;
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/** flow 累计的五个字段(v1 step-finish tokens 与 v2 message tokens 同形)。 */
|
|
122
|
+
interface OpencodeUsageFlow {
|
|
123
|
+
input: number;
|
|
124
|
+
output: number;
|
|
125
|
+
cacheRead: number;
|
|
126
|
+
cacheCreation: number;
|
|
127
|
+
total: number;
|
|
128
|
+
}
|
|
129
|
+
/** v1 扫描累积器结果(纯数据)。 */
|
|
130
|
+
export interface OpencodeV1Scan {
|
|
131
|
+
/** 末条 user 消息下标(catch-up tail 起点);整份 export 无 user 消息 = -1。 */
|
|
132
|
+
lastUserIndex: number;
|
|
133
|
+
/** tail 内首条 user 文本(displayTitle 首选)。 */
|
|
134
|
+
tailDisplayTitle: string | undefined;
|
|
135
|
+
/** tail 内最后一次非零 step-finish 采样(contextLength 水位来源)。 */
|
|
136
|
+
latest: AgentSessionUsage | undefined;
|
|
137
|
+
/** tail 内非零 step-finish 求和(本 run flow)。 */
|
|
138
|
+
turn: OpencodeUsageFlow;
|
|
139
|
+
/** 全会话 step-finish 求和(cumulative;零 total 的退化 step 字段照加)。 */
|
|
140
|
+
cum: OpencodeUsageFlow;
|
|
141
|
+
}
|
|
142
|
+
export declare function scanV1Messages(messages: OpencodeExportMessage[]): OpencodeV1Scan;
|
|
143
|
+
/** v2 usage 扫描累积器结果(纯数据)。 */
|
|
144
|
+
export interface OpencodeV2UsageScan {
|
|
145
|
+
/** 末条采样(contextLength 水位来源)。 */
|
|
146
|
+
latest: AgentSessionUsage | undefined;
|
|
147
|
+
/** 末个 turn(末个 turn 起点之后)的采样求和(本 run flow)。 */
|
|
148
|
+
turn: OpencodeUsageFlow;
|
|
149
|
+
/** 全会话采样求和(cumulative)。 */
|
|
150
|
+
cum: OpencodeUsageFlow;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* v2 扫描累积器(纯函数):usageSample 已滤掉零 total 的退化消息;turn 边界
|
|
154
|
+
* 由 lastTurnStartIndex 判定(idle / user / synthetic / system,见其注释)。
|
|
155
|
+
*
|
|
156
|
+
* 产生:OpencodeV2UsageScan。依赖:入参 messages。不改任何外部状态。
|
|
157
|
+
*/
|
|
158
|
+
export declare function scanV2Usage(messages: OpencodeV2Message[]): OpencodeV2UsageScan;
|
|
31
159
|
export declare class OpencodeSessionReader implements AgentSessionReader {
|
|
32
160
|
private readonly binary;
|
|
33
161
|
private readonly cacheTtlMs;
|
|
@@ -56,14 +184,27 @@ export declare class OpencodeSessionReader implements AgentSessionReader {
|
|
|
56
184
|
getNewestSession(cwd: string): AgentSession | null;
|
|
57
185
|
/**
|
|
58
186
|
* Read session content: extract catch-up tail (last user message + everything after).
|
|
187
|
+
*
|
|
188
|
+
* 编排:定位会话文件(captureExport + parse)→ directory 精确匹配(与
|
|
189
|
+
* cwd-scoped list 同口径)→ 按 export 版本分发到 v1/v2 装配。
|
|
59
190
|
*/
|
|
60
191
|
readSessionContent(sessionId: string, cwd: string, opts?: {
|
|
61
192
|
maxEvents?: number;
|
|
62
193
|
}): SessionContent;
|
|
194
|
+
/**
|
|
195
|
+
* v1 export(`{info, parts}` 信封 + step-finish 用量 part)的 catch-up tail
|
|
196
|
+
* 装配:扫描累积器(scanV1Messages)出 tail 位置与本 run/累计 usage,事件
|
|
197
|
+
* 装配(assembleV1TailEvents)出展示流,这里只做组装。
|
|
198
|
+
*/
|
|
199
|
+
private readV1SessionContent;
|
|
63
200
|
/**
|
|
64
201
|
* v2 export: messages are flat (`type` + `text`/`content`) and assistant
|
|
65
202
|
* usage lives on the message instead of a `step-finish` part. Keep this
|
|
66
203
|
* mapping isolated from the v1 parser so v1 behaviour stays unchanged.
|
|
204
|
+
*
|
|
205
|
+
* turnStart 可能落在末条采样之后(新 turn 尚无采样)→ turn 全 0;latest
|
|
206
|
+
* 仍是上一轮末条采样,contextLength 保留水位。turnStart 小于最后一个采样
|
|
207
|
+
* 下标时,flow 覆盖末条值,只有 contextLength 保留末条(finalizeTurnUsage)。
|
|
67
208
|
*/
|
|
68
209
|
private readV2SessionContent;
|
|
69
210
|
/**
|