lark-remote 0.3.0 → 0.4.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.
Files changed (60) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.en.md +6 -6
  3. package/README.md +8 -7
  4. package/dist/binder.d.ts +1 -1
  5. package/dist/binder.js +1 -1
  6. package/dist/bridge/final-usage.js +2 -2
  7. package/dist/bridge/inbound-media.d.ts +13 -20
  8. package/dist/bridge/inbound-media.js +107 -91
  9. package/dist/bridge/index.d.ts +6 -6
  10. package/dist/bridge/index.js +81 -87
  11. package/dist/cli.js +5 -1
  12. package/dist/clone.d.ts +1 -1
  13. package/dist/common/fs.js +1 -1
  14. package/dist/config/dir.d.ts +9 -0
  15. package/dist/config/dir.js +69 -0
  16. package/dist/config/index.d.ts +22 -3
  17. package/dist/config/index.js +26 -4
  18. package/dist/connector/index.d.ts +28 -1
  19. package/dist/connector/index.js +155 -31
  20. package/dist/error-classification.d.ts +7 -0
  21. package/dist/error-classification.js +37 -1
  22. package/dist/inbound/event.d.ts +41 -0
  23. package/dist/inbound/event.js +11 -0
  24. package/dist/inbound/placeholder.d.ts +26 -0
  25. package/dist/inbound/placeholder.js +149 -0
  26. package/dist/inbound/prompt.d.ts +20 -0
  27. package/dist/inbound/prompt.js +47 -0
  28. package/dist/inbound/receipt.d.ts +28 -0
  29. package/dist/inbound/receipt.js +62 -0
  30. package/dist/inbound/turn-assembler.d.ts +63 -0
  31. package/dist/inbound/turn-assembler.js +233 -0
  32. package/dist/inbound/turn.d.ts +48 -0
  33. package/dist/inbound/turn.js +10 -0
  34. package/dist/index.js +108 -73
  35. package/dist/platform/command.js +1 -1
  36. package/dist/platform/sleep-blocker.d.ts +17 -0
  37. package/dist/platform/sleep-blocker.js +73 -0
  38. package/dist/platform/terminator-win32.js +1 -1
  39. package/dist/restart.d.ts +4 -4
  40. package/dist/restart.js +5 -5
  41. package/dist/router/config/kimi.js +4 -3
  42. package/dist/router/config/opencode.d.ts +1 -1
  43. package/dist/router/config/opencode.js +11 -0
  44. package/dist/router/index.d.ts +17 -0
  45. package/dist/router/index.js +53 -15
  46. package/dist/runner/common/acp/base-acp-runner.js +7 -2
  47. package/dist/runner/common/acp/base-translator.d.ts +19 -0
  48. package/dist/runner/common/acp/base-translator.js +82 -0
  49. package/dist/runner/common/acp/protocol-types.d.ts +16 -2
  50. package/dist/runner/common/acp/protocol-types.js +3 -0
  51. package/dist/runner/common/connection-based-runner.js +6 -2
  52. package/dist/runner/kimi/acp/runner.d.ts +1 -1
  53. package/dist/runner/kimi/acp/runner.js +1 -1
  54. package/dist/runner/kimi/acp/translator.js +60 -4
  55. package/dist/runner/opencode/acp/runner.d.ts +1 -1
  56. package/dist/session/session-store.d.ts +1 -1
  57. package/dist/session/session-store.js +1 -1
  58. package/dist/workspace/index.d.ts +1 -1
  59. package/dist/workspace/index.js +1 -1
  60. package/package.json +1 -1
@@ -120,13 +120,31 @@ export class KimiAcpTranslator extends BaseAcpTranslator {
120
120
  getLogger().info(`[kimi-acp-translator] permission request without toolCall, auto-responding cancelled (requestId=${requestId})`);
121
121
  return [];
122
122
  }
123
+ // 命令恢复(2026-09-13 对 kimi 0.42.0 实测):审批门在 tool.call.started
124
+ // 之前触发,request_permission 的 toolCall 只有 title("Bash")+ content
125
+ // 里一句截断摘要("Requesting approval to Running: <cmd>…"),无 rawInput;
126
+ // 完整命令只从审批前的 tool_call/tool_call_update 流式 args 累积文本拿到
127
+ // (基类按 toolCallId 追踪)。解析顺序:流式 args JSON 的 command 字段 →
128
+ // title;流式缺失时退回 content 摘要放进 reason(旧版 kimi 不推 delta)。
129
+ const tracked = typeof toolCall.toolCallId === 'string'
130
+ ? this.getTrackedToolCallArgs(toolCall.toolCallId)
131
+ : undefined;
132
+ const argsCommand = tracked ? extractCommandFromArgsText(tracked) : undefined;
133
+ const rawInput = typeof toolCall.rawInput === 'string' && toolCall.rawInput.length > 0
134
+ ? toolCall.rawInput
135
+ : undefined;
136
+ const summary = extractPermissionSummaryText(toolCall.content);
123
137
  const view = {
124
138
  requestId,
125
139
  kind: 'command',
126
- command: params.toolCall?.title ?? undefined,
127
- reason: params.toolCall?.rawInput
128
- ? truncateWithEllipsis(params.toolCall.rawInput, 200)
129
- : undefined,
140
+ command: argsCommand ?? toolCall.title ?? undefined,
141
+ reason: argsCommand
142
+ ? undefined
143
+ : rawInput
144
+ ? truncateWithEllipsis(rawInput, 200)
145
+ : summary
146
+ ? truncateWithEllipsis(summary, 200)
147
+ : undefined,
130
148
  // §P4: 从服务端 options kind 派生——带 approve_always(或 allow_always)
131
149
  // 才提供「本会话总是允许」(acceptForSession);否则与旧行为一致。
132
150
  availableDecisions: deriveAcpAvailableDecisions(params.options ?? []),
@@ -244,4 +262,42 @@ function extractQuestionText(toolCall) {
244
262
  }
245
263
  return toolCall?.title?.trim() || '请选择';
246
264
  }
265
+ /**
266
+ * 从流式累积的 args 文本恢复命令:完整 JSON 且含 string command 字段时取该
267
+ * 字段;否则(非 Bash 工具 / 防御性半截 JSON)返回原文。
268
+ */
269
+ function extractCommandFromArgsText(argsText) {
270
+ try {
271
+ const parsed = JSON.parse(argsText);
272
+ if (parsed && typeof parsed === 'object') {
273
+ const command = parsed.command;
274
+ if (typeof command === 'string' && command.length > 0)
275
+ return command;
276
+ }
277
+ }
278
+ catch {
279
+ // 半截 JSON(审批正常在 args 流式完成后才到,此处纯防御)——用原文。
280
+ }
281
+ return argsText;
282
+ }
283
+ /**
284
+ * request_permission toolCall.content 里的摘要文本(kimi 0.42:
285
+ * "Requesting approval to Running: <cmd>…",约 64 字符截断)。无文本返回
286
+ * undefined。
287
+ */
288
+ function extractPermissionSummaryText(content) {
289
+ if (!Array.isArray(content))
290
+ return undefined;
291
+ let text = '';
292
+ let found = false;
293
+ for (const block of content) {
294
+ const t = block?.content
295
+ ?.text;
296
+ if (typeof t === 'string' && t.length > 0) {
297
+ text += t;
298
+ found = true;
299
+ }
300
+ }
301
+ return found ? text : undefined;
302
+ }
247
303
  //# sourceMappingURL=translator.js.map
@@ -40,7 +40,7 @@ export interface OpencodeAcpRunnerOptions {
40
40
  requestTimeoutMs?: number;
41
41
  /** Idle TTL for connection manager. */
42
42
  idleTtlMs?: number;
43
- /** How long to wait for turn output before failing. Defaults to 10 min. */
43
+ /** How long to wait for turn output before failing. Defaults to 30 min. */
44
44
  turnIdleTimeoutMs?: number;
45
45
  model?: string;
46
46
  /** Configured session mode: 'build' (default) or 'plan' (opencode agent names). */
@@ -14,7 +14,7 @@ interface SessionEntry {
14
14
  /**
15
15
  * Per-user session store. Persists cwd + per-agent sessions to disk so that
16
16
  * the last workspace AND the last-used sessionId per agent are restored after
17
- * a bridge restart.
17
+ * a lark-remote restart.
18
18
  *
19
19
  * Persistence strategy:
20
20
  * - Persists `cwd`, `sessions` (per-agent sessionId), `previousSessions`
@@ -4,7 +4,7 @@ import { atomicWriteJson } from '../persistence/atomic-write.js';
4
4
  /**
5
5
  * Per-user session store. Persists cwd + per-agent sessions to disk so that
6
6
  * the last workspace AND the last-used sessionId per agent are restored after
7
- * a bridge restart.
7
+ * a lark-remote restart.
8
8
  *
9
9
  * Persistence strategy:
10
10
  * - Persists `cwd`, `sessions` (per-agent sessionId), `previousSessions`
@@ -9,7 +9,7 @@ export interface WorkspaceEntry {
9
9
  *
10
10
  * Atomic write (§9.10): writes a temp file then `fs.rename` so a crash
11
11
  * mid-write cannot leave a truncated JSON file. On load, a corrupt file
12
- * is treated as empty (with a warning) so the bridge can still start.
12
+ * is treated as empty (with a warning) so the lark-remote can still start.
13
13
  *
14
14
  * lastUsedAt 语义(2026-08-19 语义对齐):保存(save)与使用(use/touch)
15
15
  * 都会把时间戳更新为当前时间。save 内部调用 touch,保证「最近使用」排序
@@ -8,7 +8,7 @@ import { getLogger } from '../logger/index.js';
8
8
  *
9
9
  * Atomic write (§9.10): writes a temp file then `fs.rename` so a crash
10
10
  * mid-write cannot leave a truncated JSON file. On load, a corrupt file
11
- * is treated as empty (with a warning) so the bridge can still start.
11
+ * is treated as empty (with a warning) so the lark-remote can still start.
12
12
  *
13
13
  * lastUsedAt 语义(2026-08-19 语义对齐):保存(save)与使用(use/touch)
14
14
  * 都会把时间戳更新为当前时间。save 内部调用 touch,保证「最近使用」排序
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lark-remote",
3
- "version": "0.3.0",
3
+ "version": "0.4.1",
4
4
  "description": "Feishu (Lark) private-chat bridge to local coding agents — Claude Code / Codex / opencode / pi / kimi, with live-streaming CardKit 2.0 cards",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",