lark-remote 0.4.3 → 0.4.5

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 (106) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/binder.d.ts +11 -10
  3. package/dist/binder.js +17 -16
  4. package/dist/bridge/inbound-media.d.ts +1 -27
  5. package/dist/bridge/inbound-media.js +13 -14
  6. package/dist/bridge/index.d.ts +49 -49
  7. package/dist/bridge/index.js +99 -92
  8. package/dist/bridge/queue-manager.d.ts +33 -26
  9. package/dist/bridge/queue-manager.js +117 -117
  10. package/dist/card/bash-renderer.js +4 -4
  11. package/dist/card/card-shared.d.ts +1 -1
  12. package/dist/card/card-shared.js +2 -2
  13. package/dist/card/run-renderer.js +8 -8
  14. package/dist/card/run-state.js +81 -31
  15. package/dist/card/tool-render.js +6 -2
  16. package/dist/cli.js +5 -6
  17. package/dist/clone.d.ts +1 -6
  18. package/dist/clone.js +4 -4
  19. package/dist/common/clamp.d.ts +2 -0
  20. package/dist/common/clamp.js +5 -0
  21. package/dist/common/fs.d.ts +4 -3
  22. package/dist/common/fs.js +5 -4
  23. package/dist/config/dir.d.ts +4 -5
  24. package/dist/config/dir.js +7 -8
  25. package/dist/config/wizard.js +2 -2
  26. package/dist/connector/index.d.ts +0 -2
  27. package/dist/connector/index.js +5 -5
  28. package/dist/inbound/receipt.d.ts +1 -3
  29. package/dist/inbound/receipt.js +2 -2
  30. package/dist/inbound/turn-assembler.d.ts +1 -3
  31. package/dist/inbound/turn-assembler.js +2 -2
  32. package/dist/index.js +30 -22
  33. package/dist/instance-lock.js +4 -4
  34. package/dist/persistence/atomic-write.js +3 -3
  35. package/dist/platform/agent-stopper.d.ts +1 -1
  36. package/dist/platform/terminator-posix.js +5 -5
  37. package/dist/platform/terminator-win32.js +1 -1
  38. package/dist/router/card-helpers.d.ts +1 -3
  39. package/dist/router/card-helpers.js +2 -2
  40. package/dist/router/config/codex.js +1 -1
  41. package/dist/router/config/common/model-patch.d.ts +1 -2
  42. package/dist/router/config/common/model-patch.js +1 -2
  43. package/dist/router/config/opencode.js +1 -1
  44. package/dist/router/config/pi.js +1 -1
  45. package/dist/router/index.d.ts +22 -22
  46. package/dist/router/index.js +71 -52
  47. package/dist/router/order-exec-dispatch.d.ts +3 -10
  48. package/dist/router/order-exec-dispatch.js +3 -3
  49. package/dist/router/{utils.d.ts → usage-format.d.ts} +2 -4
  50. package/dist/router/{utils.js → usage-format.js} +3 -8
  51. package/dist/runner/claude/runner.d.ts +1 -1
  52. package/dist/runner/claude/runner.js +1 -2
  53. package/dist/runner/claude/session.d.ts +2 -4
  54. package/dist/runner/claude/session.js +7 -9
  55. package/dist/runner/common/acp/{protocol-helpers.d.ts → acp-approval.d.ts} +2 -8
  56. package/dist/runner/common/acp/{protocol-helpers.js → acp-approval.js} +4 -3
  57. package/dist/runner/common/acp/base-acp-runner.d.ts +1 -1
  58. package/dist/runner/common/acp/base-acp-runner.js +1 -1
  59. package/dist/runner/common/acp/base-translator.d.ts +43 -0
  60. package/dist/runner/common/acp/base-translator.js +83 -18
  61. package/dist/runner/common/connection-based-runner.d.ts +4 -4
  62. package/dist/runner/common/connection-based-runner.js +3 -3
  63. package/dist/runner/common/jsonrpc/connection-manager.d.ts +12 -12
  64. package/dist/runner/common/jsonrpc/connection-manager.js +36 -36
  65. package/dist/runner/common/{usage.d.ts → result-usage.d.ts} +1 -1
  66. package/dist/runner/common/{usage.js → result-usage.js} +2 -2
  67. package/dist/runner/common/spawning-runner.d.ts +2 -2
  68. package/dist/runner/common/spawning-runner.js +8 -8
  69. package/dist/runner/common/{runner-utils.d.ts → synthetic-events.d.ts} +4 -4
  70. package/dist/runner/common/{runner-utils.js → synthetic-events.js} +5 -5
  71. package/dist/runner/dsh/client.d.ts +1 -1
  72. package/dist/runner/dsh/client.js +1 -1
  73. package/dist/runner/dsh/runner.js +1 -1
  74. package/dist/runner/kimi/acp/runner.d.ts +1 -1
  75. package/dist/runner/kimi/acp/runner.js +1 -1
  76. package/dist/runner/kimi/acp/translator.js +1 -1
  77. package/dist/runner/opencode/acp/runner.d.ts +2 -2
  78. package/dist/runner/opencode/acp/runner.js +1 -1
  79. package/dist/runner/opencode/acp/translator.d.ts +22 -1
  80. package/dist/runner/opencode/acp/translator.js +61 -1
  81. package/dist/runner/pi/rpc/runner.d.ts +1 -1
  82. package/dist/runner/pi/rpc/translator.d.ts +0 -1
  83. package/dist/runner/pi/rpc/translator.js +0 -2
  84. package/dist/runner/registry.d.ts +3 -3
  85. package/dist/runner/registry.js +3 -3
  86. package/dist/session/claude/session-index.d.ts +1 -1
  87. package/dist/session/claude/session-index.js +1 -1
  88. package/dist/session/claude/session-reader.d.ts +1 -1
  89. package/dist/session/claude/session-reader.js +1 -1
  90. package/dist/session/codex/rollout-reader.js +2 -2
  91. package/dist/session/dsh/sessions.d.ts +1 -1
  92. package/dist/session/dsh/sessions.js +1 -1
  93. package/dist/session/kimi/sessions.d.ts +0 -4
  94. package/dist/session/kimi/sessions.js +2 -8
  95. package/dist/session/opencode/sessions.js +3 -3
  96. package/dist/session/registry.d.ts +1 -1
  97. package/dist/session/registry.js +1 -1
  98. package/dist/session/session-store.d.ts +2 -3
  99. package/dist/session/session-store.js +2 -4
  100. package/dist/update/index.d.ts +1 -1
  101. package/dist/update/index.js +1 -1
  102. package/dist/update/version-check.d.ts +5 -3
  103. package/dist/update/version-check.js +10 -8
  104. package/dist/workspace/index.d.ts +4 -4
  105. package/dist/workspace/index.js +5 -5
  106. package/package.json +1 -1
@@ -7,6 +7,13 @@ import type { AgentKind } from '../runner/types.js';
7
7
  export interface AgentBinding {
8
8
  agent: AgentKind;
9
9
  sessionId?: string;
10
+ /**
11
+ * 会话代际快照(与 sessionId 同刻捕获)。随 binding 带到执行时刻:若执行前
12
+ * session 指针被移动(/new、/cd、/resume、/config 切换),该 run 的 init /
13
+ * turn_started 写回判 stale 跳过,避免「先发消息 → 后点新会话」时旧 sessionId
14
+ * 被写回复活(2026-10-07 事故)。缺省时回退到执行起点捕获,保持旧行为。
15
+ */
16
+ sessionEpoch?: number;
10
17
  }
11
18
  /** A queued task with its metadata for queue display cards. */
12
19
  export interface QueuedTask {
@@ -26,7 +33,7 @@ export interface QueuedTask {
26
33
  * to `messageId` for hand-typed messages, where the two coincide.
27
34
  */
28
35
  feishuReplyTo?: string;
29
- workspace: string;
36
+ cwd: string;
30
37
  timestamp: number;
31
38
  messagePreview: string;
32
39
  /**
@@ -67,7 +74,7 @@ export interface EnqueueOptions {
67
74
  binding?: AgentBinding;
68
75
  };
69
76
  }
70
- /** Queue info for a workspace */
77
+ /** Queue info for a cwd */
71
78
  interface QueueInfo {
72
79
  position: number;
73
80
  tasksAhead: number;
@@ -89,7 +96,7 @@ export declare class QueueManager {
89
96
  * `updateQueuedTaskMessage`. The ordered array remains the source of truth
90
97
  * (position display depends on order); the index must be kept in sync on
91
98
  * every mutation (push / splice / shift) via the `indexAdd`/`indexRemove`
92
- * helpers. Same messageId is never enqueued twice in one workspace
99
+ * helpers. Same messageId is never enqueued twice in one cwd
93
100
  * (Feishu dedup + internal-key dedup), so no overwrite concern.
94
101
  */
95
102
  private taskIndex;
@@ -103,7 +110,7 @@ export declare class QueueManager {
103
110
  */
104
111
  /** queue card 的 send promise 表(public:bridge 集成测试注入/断言用)。 */
105
112
  queueCardMessages: Map<string, Promise<string | undefined>>;
106
- /** Track number of executing tasks per workspace (for queue card display). */
113
+ /** Track number of executing tasks per cwd (for queue card display). */
107
114
  private pendingOrExecutingCount;
108
115
  /**
109
116
  * Monotonic counter minting a unique slot id per enqueued task. A slot
@@ -146,13 +153,13 @@ export declare class QueueManager {
146
153
  * before begin); `removeFromQueue` therefore needs no cleanup here.
147
154
  */
148
155
  private beganMessageIds;
149
- /** Callback to check if workspace has an active run */
156
+ /** Callback to check if cwd has an active run */
150
157
  private isWorkspaceRunning;
151
158
  /** Callback to send card updates */
152
159
  private sendCard;
153
160
  /** Callback to update existing card */
154
161
  private updateCard;
155
- constructor(isWorkspaceRunning: (workspace: string) => boolean, sendCard: (chatId: string, card: object, opts?: {
162
+ constructor(isWorkspaceRunning: (cwd: string) => boolean, sendCard: (chatId: string, card: object, opts?: {
156
163
  replyTo?: string;
157
164
  }) => Promise<string>, updateCard: (messageId: string, card: object) => Promise<void>);
158
165
  /** P3-5: register a queued task in the per-workspace `messageId → task` index. */
@@ -163,31 +170,31 @@ export declare class QueueManager {
163
170
  private indexGet;
164
171
  /**
165
172
  * Enqueue a task into the workspace-level serial queue.
166
- * Each workspace has its own serial queue for parallel execution across workspaces.
173
+ * Each cwd has its own serial queue for parallel execution across workspaces.
167
174
  */
168
- enqueue(workspace: string, task: () => Promise<void>, opts?: EnqueueOptions): void;
175
+ enqueue(cwd: string, task: () => Promise<void>, opts?: EnqueueOptions): void;
169
176
  /**
170
177
  * Execute a task immediately without going through the queue.
171
178
  * Used for / commands that should respond immediately.
172
179
  */
173
- enqueueImmediate(workspace: string, task: () => Promise<void>): void;
180
+ enqueueImmediate(cwd: string, task: () => Promise<void>): void;
174
181
  /**
175
182
  * One-shot: replace the execution closure of an existing queued task in
176
183
  * place, preserving its queue position (tasks queued behind it still run
177
184
  * after it). Consumed when the task's slot begins; removed if cancelled.
178
185
  */
179
- setTaskReplacement(workspace: string, messageId: string, task: () => Promise<void>): void;
186
+ setTaskReplacement(cwd: string, messageId: string, task: () => Promise<void>): void;
180
187
  /** Send a queue status card showing current queue position and actions. */
181
188
  private sendQueueStatusCard;
182
- /** Get queue info for a workspace. */
183
- getQueueInfo(workspace: string): QueueInfo;
189
+ /** Get queue info for a cwd. */
190
+ getQueueInfo(cwd: string): QueueInfo;
184
191
  /** Build queue status card elements. */
185
192
  private buildQueueStatusCardElements;
186
193
  /**
187
194
  * Build the 撤销/立即执行 action button pair for a queue card.
188
195
  *
189
196
  * Both buttons route to `queue.cancel` / `queue.immediate` callbacks with
190
- * the same workspace/messageId; only the `disabled` flag varies by card
197
+ * the same cwd/messageId; only the `disabled` flag varies by card
191
198
  * state — pending cards enable both, executing/cancelled cards disable
192
199
  * both. Centralizing the pair here eliminates the 3-way duplication
193
200
  * between `buildQueueStatusCardElements`, `updateQueueCardToExecuting`,
@@ -205,13 +212,13 @@ export declare class QueueManager {
205
212
  * the card must keep its "❌ 已撤销" state instead of being flipped back to
206
213
  * executing. The mapping is deleted in finally in both cases.
207
214
  */
208
- updateQueueCardToExecuting(workspace: string, messageId: string, messagePreview: string, started?: boolean): Promise<void>;
215
+ updateQueueCardToExecuting(cwd: string, messageId: string, messagePreview: string, started?: boolean): Promise<void>;
209
216
  /** Remove a task from the queue by messageId. Returns true if found and removed. */
210
- removeFromQueue(workspace: string, messageId: string): boolean;
217
+ removeFromQueue(cwd: string, messageId: string): boolean;
211
218
  /** Update queue card to "cancelled" status when user clicks 撤销. */
212
- updateQueueCardToCancelled(workspace: string, messageId: string): Promise<void>;
219
+ updateQueueCardToCancelled(cwd: string, messageId: string): Promise<void>;
213
220
  /** Get task metadata from queue. */
214
- getQueuedTask(workspace: string, messageId: string): QueuedTask | undefined;
221
+ getQueuedTask(cwd: string, messageId: string): QueuedTask | undefined;
215
222
  /**
216
223
  * Whether a task with the given messageId has begun executing (cancellation
217
224
  * check passed, task removed from the queue). Sticky: true even after the
@@ -219,10 +226,10 @@ export declare class QueueManager {
219
226
  * completed)" from "never began / cancelled".
220
227
  */
221
228
  hasBegan(messageId: string): boolean;
222
- /** Get all queued tasks for a workspace. Returns a copy to prevent aliasing bugs. */
223
- getQueuedTasks(workspace: string): QueuedTask[];
229
+ /** Get all queued tasks for a cwd. Returns a copy to prevent aliasing bugs. */
230
+ getQueuedTasks(cwd: string): QueuedTask[];
224
231
  /** Update the messagePreview for a queued task. Returns true if found and updated. */
225
- updateQueuedTaskMessage(workspace: string, messageId: string, newMessage: string): boolean;
232
+ updateQueuedTaskMessage(cwd: string, messageId: string, newMessage: string): boolean;
226
233
  /**
227
234
  * Build the orange queue card reflecting the edited message content. Returns
228
235
  * the card object (sent as the cardAction callback response `card.data`,
@@ -235,9 +242,9 @@ export declare class QueueManager {
235
242
  * concurrent PATCH updateCard result. Returning { card } in the callback
236
243
  * response updates the card synchronously with no API race.
237
244
  */
238
- buildQueueCardForEdit(workspace: string, messageId: string, newMessagePreview: string): object | null;
245
+ buildQueueCardForEdit(cwd: string, messageId: string, newMessagePreview: string): object | null;
239
246
  /**
240
- * Decrement `pendingOrExecutingCount` for a workspace, honoring per-slot
247
+ * Decrement `pendingOrExecutingCount` for a cwd, honoring per-slot
241
248
  * interrupt bookkeeping.
242
249
  *
243
250
  * Called from the queue chain's `.then()`/`.catch()` settle with the slot
@@ -253,7 +260,7 @@ export declare class QueueManager {
253
260
  */
254
261
  private decrementExecutingCount;
255
262
  /**
256
- * Reset the executing task count for a workspace.
263
+ * Reset the executing task count for a cwd.
257
264
  *
258
265
  * This should be called when a running task is interrupted externally
259
266
  * (e.g., via /stop command or "立即执行" button) so that the queue
@@ -278,10 +285,10 @@ export declare class QueueManager {
278
285
  * running successor and mark ITS slot interrupted, hiding it from the
279
286
  * queue card (A22).
280
287
  */
281
- resetExecutingCount(workspace: string, expectedSlot: number): void;
288
+ resetExecutingCount(cwd: string, expectedSlot: number): void;
282
289
  /**
283
- * The slot id of the task currently executing in this workspace (if any).
290
+ * The slot id of the task currently executing in this cwd (if any).
284
291
  */
285
- getExecutingSlot(workspace: string): number | undefined;
292
+ getExecutingSlot(cwd: string): number | undefined;
286
293
  }
287
294
  export {};