@yu_robotics/remote-cli-router 1.6.219 → 1.6.221

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/README.md CHANGED
@@ -154,9 +154,10 @@ this fallback requires only a Router upgrade.
154
154
 
155
155
  Router 1.6.92 requires successful recovery-notice delivery before acknowledging
156
156
  reuse of a surviving card. A failed update can retry within the same recovery
157
- round without duplicating the notice. Update-failure logs identify the root
158
- reply, affected card ID and number, and Feishu error and trace codes without
159
- logging the card body. Older recovery-capable CLIs remain compatible.
157
+ round without duplicating the notice. Update-failure logs correlate affected cards using pseudonymous identifiers
158
+ and report Feishu error and trace codes without logging the card body. Older recovery-capable CLIs remain compatible.
159
+
160
+ Version 1.6.220 adds bounded card-delivery and task-recovery diagnostics. Update both CLI and Router to correlate result acknowledgement waits, recovery attempts, and socket closure events. Router diagnostics include serialized UTF-8 sizes and component-change metadata without card contents or request credentials. A recovery card does not by itself prove a socket disconnected. Inspect service logs (or `docker logs` for the Router), and redact logs before sharing them.
160
161
 
161
162
  Router 1.6.90 checks tool parameters before using specialized card formatting.
162
163
  Missing or incompatible fields fall back to a bounded parameter summary;
@@ -790,3 +791,7 @@ When supported by the connected CLI, Codex and Claude Code permission requests a
790
791
  When the Router reports that an approval card could not be delivered, CLI 1.6.88 and newer show the requested action in a code block above the text reply instructions. This also applies to delegated worker approval requests, which never offer persistent grants.
791
792
 
792
793
  Restricted Claude Code threads use the same approval card flow, titled Permission request, for outside writes, protected files, read-only-mode edits, and commands outside their native sandbox. Ordinary workspace and explicitly authorized directory edits in workspace-write mode do not create approval cards, unless a native ask rule requires one. If card creation fails, Claude accepts text replies without starting a new model turn; completed or expired requests cannot be approved later. The CLI enforces file boundaries before native allow rules; native deny and ask rules still apply. Sandboxed command networking is enabled by default, subject to native domain denials and administrator-managed restrictions; `/sandbox network off` disables it without changing the approval card flow. Missing sandbox dependencies stop execution on the CLI; the Router cannot override that startup failure. See [Claude sandbox configuration](../../README.md#optional-claude-code-sandbox).
794
+
795
+ ## Retrieve Output Files
796
+
797
+ CLI and Router 1.6.221 add explicit local Markdown link retrieval using immutable 20 MiB snapshots with a fixed 24-hour expiry. A stable file entry opens a separate transfer task card, followed by a native Feishu file message. Progress, safe retries, offline waiting, original-device ownership, restart receipts, and unknown-send handling are independent of the assistant reply and model task. Approved device enrollment and HTTPS are required; Router `files.enabled` also gates retrieval. CLI `outputFiles.allowedRoots` adds specific export roots, and `outputFiles.maxBytes` can lower the limit. Existing 16 MiB delegated exports and incoming attachments retain their contracts. See [Retrieve Output Files](../../README.md#retrieve-output-files) for permissions, limits, proxy configuration, and failure behavior.
@@ -21,6 +21,8 @@ export interface FeishuLongConnHandlerConfig {
21
21
  * Uses Feishu SDK's WSClient for WebSocket long connection
22
22
  */
23
23
  export declare class FeishuLongConnHandler {
24
+ private readonly cardDiagnostics;
25
+ bindDiagnosticTask(cardId: string, taskId: string): void;
24
26
  workerContexts?: WorkerContextCards;
25
27
  settingsCards?: SettingsCards;
26
28
  private client;
@@ -95,6 +97,7 @@ export declare class FeishuLongConnHandler {
95
97
  onApprovalAction?: (openId: string, requestId: string, cardId: string, decision: string) => Promise<string>;
96
98
  onMaintenanceAction?: (openId: string, id: string, cardId: string, action: string, offset?: number) => Promise<string>;
97
99
  onTipsCommand?: (openId: string, content: string) => Promise<void>;
100
+ onOutputFileAction?: (openId: string, cardId: string, payload: unknown) => Promise<string>;
98
101
  onTipsAction?: (openId: string, cardId: string, payload: unknown) => Promise<string>;
99
102
  onUserActivity?: (openId: string) => Promise<void>;
100
103
  onQueueAction?: (openId: string, action: 'confirm' | 'cancel', queueId: string, threadId: string, cardMessageId?: string) => Promise<'sent' | 'already_processed'>;
@@ -220,7 +223,7 @@ export declare class FeishuLongConnHandler {
220
223
  * Send streaming message with card update support
221
224
  * Returns message_id for updating
222
225
  */
223
- sendStreamingStart(openId: string, initialText?: string, threadName?: string, cwd?: string): Promise<string | null>;
226
+ sendStreamingStart(openId: string, initialText?: string, threadName?: string, cwd?: string, diagnosticTaskId?: string): Promise<string | null>;
224
227
  /**
225
228
  * Serialize async operations per messageId to prevent race conditions.
226
229
  * Concurrent calls for the same messageId will queue and execute in order.
@@ -293,6 +296,15 @@ export declare class FeishuLongConnHandler {
293
296
  /** A single passive send: never fall back, execute examples, or register task routes. */
294
297
  sendTipCard(openId: string, elements: any[], header: Record<string, unknown>, deliveryKey: string): Promise<string | null>;
295
298
  updateTipCard(cardId: string, elements: any[], header: Record<string, unknown>): Promise<void>;
299
+ private readonly outputLogger;
300
+ /** A per-operation deadline also aborts SDK token requests and the actual HTTP transport. */
301
+ private outputRequest;
302
+ /** Strict receipts: missing codes/IDs are unknown, never invented success. */
303
+ createOutputCard(openId: string, content: string, uuid: string): Promise<string>;
304
+ patchOutputCard(cardId: string, content: string): Promise<void>;
305
+ uploadOutputFile(filename: string, name: string): Promise<string>;
306
+ sendOutputFile(openId: string, content: string, uuid: string): Promise<string>;
307
+ private outputMessageReceipt;
296
308
  private recordUserActivity;
297
309
  updateApprovalCard(cardId: string, elements: any[], header?: Record<string, unknown>): Promise<void>;
298
310
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"FeishuLongConnHandler.d.ts","sourceRoot":"","sources":["../../src/feishu/FeishuLongConnHandler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAA4B,aAAa,EAAc,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACtG,OAAO,KAAK,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAIxE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAKjD,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc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AAG,OAAO,CAAC,IAAI,CAAC;IAc7E;;;OAGG;IACG,gBAAgB,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC;QAAE,KAAK,CAAC,EAAE,GAAG,CAAA;KAAE,GAAG,IAAI,CAAC;IAmIlE;;;OAGG;IACG,yBAAyB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,gBAAgB,UAAQ,EAAE,cAAc,CAAC,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAQpK,qFAAqF;IAC/E,6BAA6B,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,mBAAmB,CAAC;IA+DnL,yEAAyE;IACnE,oBAAoB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAahE,OAAO,CAAC,8BAA8B;YASxB,2BAA2B;IAsBzC;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA4C5B;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAgC3B;;OAEG;IACH,iBAAiB,IAAI,cAAc;CAGpC"}
@@ -34,6 +34,8 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.FeishuLongConnHandler = void 0;
37
+ const OutputTransfers_1 = require("../output/OutputTransfers");
38
+ const DeliveryDiagnostics_1 = require("../utils/DeliveryDiagnostics");
37
39
  const lark = __importStar(require("@larksuiteoapi/node-sdk"));
38
40
  const uuid_1 = require("uuid");
39
41
  const BindingManager_1 = require("../binding/BindingManager");
@@ -51,6 +53,8 @@ const CardTables_1 = require("../utils/CardTables");
51
53
  * Uses Feishu SDK's WSClient for WebSocket long connection
52
54
  */
53
55
  class FeishuLongConnHandler {
56
+ cardDiagnostics = new DeliveryDiagnostics_1.CardDeliveryDiagnostics();
57
+ bindDiagnosticTask(cardId, taskId) { this.cardDiagnostics.bind(cardId, taskId); }
54
58
  workerContexts;
55
59
  settingsCards;
56
60
  client;
@@ -99,6 +103,7 @@ class FeishuLongConnHandler {
99
103
  appSecret: config.appSecret,
100
104
  appType: lark.AppType.SelfBuild,
101
105
  domain: lark.Domain.Feishu,
106
+ logger: (0, DeliveryDiagnostics_1.safeSdkLogger)(),
102
107
  });
103
108
  }
104
109
  /**
@@ -151,6 +156,7 @@ class FeishuLongConnHandler {
151
156
  onApprovalAction;
152
157
  onMaintenanceAction;
153
158
  onTipsCommand;
159
+ onOutputFileAction;
154
160
  onTipsAction;
155
161
  onUserActivity;
156
162
  onQueueAction;
@@ -458,7 +464,7 @@ class FeishuLongConnHandler {
458
464
  // Generate message ID first
459
465
  const commandMessageId = (0, uuid_1.v4)();
460
466
  // Register streaming session BEFORE sending command
461
- const feishuMessageId = await this.sendStreamingStart(openId, `🤔 Executing ${command}...`, threadName);
467
+ const feishuMessageId = await this.sendStreamingStart(openId, `🤔 Executing ${command}...`, threadName, undefined, commandMessageId);
462
468
  const currentBinding = await this.bindingManager.getUserBinding(openId);
463
469
  if (!currentBinding?.devices.some((device) => device.deviceId === activeDevice.deviceId)) {
464
470
  throw new Error('Device ownership changed before the command could be sent.');
@@ -827,7 +833,7 @@ Examples:
827
833
  console.log(`[FeishuHandler] Creating streaming card for command ${commandMessageId}${threadId ? ` (threadId=${threadId})` : ''}${pendingNewThread ? ' (pendingNewThread)' : ''}`);
828
834
  // Register streaming session BEFORE sending command to avoid race condition
829
835
  // where stream chunks arrive before registration
830
- const feishuMessageId = await this.sendStreamingStart(openId, attachments ? '🖼️ Processing image...' : '🤔 Processing...', threadName);
836
+ const feishuMessageId = await this.sendStreamingStart(openId, attachments ? '🖼️ Processing image...' : '🤔 Processing...', threadName, undefined, commandMessageId);
831
837
  const currentBinding = await this.bindingManager.getUserBinding(openId);
832
838
  if (!currentBinding?.devices.some((device) => device.deviceId === activeDevice.deviceId)) {
833
839
  throw new Error('Device ownership changed before the command could be sent.');
@@ -960,7 +966,7 @@ Examples:
960
966
  });
961
967
  }
962
968
  catch (error) {
963
- console.error('Failed to reply to message:', error?.message || error);
969
+ (0, DeliveryDiagnostics_1.deliveryEvent)('text_reply_failed', (0, DeliveryDiagnostics_1.safeCardError)(error));
964
970
  }
965
971
  }
966
972
  /**
@@ -979,7 +985,7 @@ Examples:
979
985
  return true;
980
986
  }
981
987
  catch (error) {
982
- console.error('Failed to send message:', error?.message || error);
988
+ (0, DeliveryDiagnostics_1.deliveryEvent)('text_message_failed', (0, DeliveryDiagnostics_1.safeCardError)(error));
983
989
  return false;
984
990
  }
985
991
  }
@@ -987,26 +993,27 @@ Examples:
987
993
  * Send streaming message with card update support
988
994
  * Returns message_id for updating
989
995
  */
990
- async sendStreamingStart(openId, initialText = '🤔 Thinking...', threadName, cwd) {
991
- console.log(`[FeishuHandler] Creating interactive card v2 for ${openId}`);
996
+ async sendStreamingStart(openId, initialText = '🤔 Thinking...', threadName, cwd, diagnosticTaskId) {
997
+ let attempted = false;
992
998
  try {
993
999
  const elements = this.createResponseHeaderElements(threadName || 'Resolving thread...', cwd);
994
1000
  elements.push({ tag: 'markdown', content: initialText });
995
- const result = await this.client.im.message.create({
1001
+ const content = JSON.stringify({ schema: '2.0', body: { elements } });
1002
+ attempted = true;
1003
+ const result = await this.cardDiagnostics.deliver({ operation: 'create', taskId: diagnosticTaskId }, content, () => this.client.im.message.create({
996
1004
  params: { receive_id_type: 'open_id' },
997
1005
  data: {
998
1006
  receive_id: openId,
999
1007
  msg_type: 'interactive',
1000
- content: JSON.stringify({
1001
- schema: '2.0',
1002
- body: { elements },
1003
- }),
1008
+ content,
1004
1009
  },
1005
- });
1010
+ }));
1006
1011
  return result?.data?.message_id || null;
1007
1012
  }
1008
1013
  catch (error) {
1009
- console.error('Failed to send streaming start:', error?.message || error);
1014
+ // Actual request failures are already aggregated at the send boundary.
1015
+ if (!attempted)
1016
+ (0, DeliveryDiagnostics_1.deliveryEvent)('card_preparation_failed', (0, DeliveryDiagnostics_1.safeCardError)(error));
1010
1017
  return null;
1011
1018
  }
1012
1019
  }
@@ -1261,7 +1268,7 @@ Examples:
1261
1268
  };
1262
1269
  const jsonSize = JSON.stringify(cardData).length;
1263
1270
  const sizeLimit = this.CARD_DATA_SIZE_LIMIT - this.CARD_SIZE_BUFFER;
1264
- console.log(`[FeishuHandler] Card data size: ${jsonSize} bytes, limit: ${sizeLimit} bytes`);
1271
+ console.log(`[FeishuHandler] Card preflight size: ${jsonSize} UTF-16 units, limit: ${sizeLimit} units`);
1265
1272
  // Use buffer for safety (2.9MB instead of 3MB)
1266
1273
  if (jsonSize > sizeLimit) {
1267
1274
  console.log(`[FeishuHandler] Data size (${jsonSize}) exceeds limit (${sizeLimit})`);
@@ -1277,9 +1284,11 @@ Examples:
1277
1284
  * @param elements Array of Feishu Card 2.0 elements
1278
1285
  * @returns The new message ID, or null on error
1279
1286
  */
1280
- async createContinuationCard(openId, elements, onTextFallback, allowFallback = true, header, rootId) {
1287
+ async createContinuationCard(openId, elements, onTextFallback, allowFallback = true, header, rootId, diagnosticIndex) {
1288
+ let attempted = false;
1281
1289
  try {
1282
1290
  const content = JSON.stringify({ schema: '2.0', ...(header ? { header } : {}), body: { elements: (0, CardTables_1.limitCardTables)(elements) } });
1291
+ attempted = true;
1283
1292
  const result = await this.sendCardRequest(content, async (body) => {
1284
1293
  const response = await this.client.im.message.create({
1285
1294
  params: { receive_id_type: 'open_id' },
@@ -1292,18 +1301,21 @@ Examples:
1292
1301
  if (!response.code && response.data?.message_id)
1293
1302
  this.workerContexts?.remember(response.data.message_id, rootId ?? response.data.message_id, body);
1294
1303
  return response;
1295
- }, onTextFallback, allowFallback);
1304
+ }, onTextFallback, allowFallback, { operation: 'create', rootId, index: diagnosticIndex });
1296
1305
  return result.data?.message_id || null;
1297
1306
  }
1298
1307
  catch (error) {
1299
- console.error('Failed to create continuation card:', error?.message || error);
1308
+ // Actual request failures are already aggregated at the send boundary.
1309
+ if (!attempted)
1310
+ (0, DeliveryDiagnostics_1.deliveryEvent)('card_preparation_failed', (0, DeliveryDiagnostics_1.safeCardError)(error));
1300
1311
  return null;
1301
1312
  }
1302
1313
  }
1303
1314
  /** Retry a confirmed table-limit or Markdown parse rejection once with readable text. */
1304
- async sendCardRequest(content, send, onTextFallback, allowFallback = true) {
1315
+ async sendCardRequest(content, send, onTextFallback, allowFallback = true, context = { operation: 'update' }) {
1305
1316
  const checkedSend = async (body) => {
1306
- const result = await send(this.workerContexts?.decorate(body) ?? body);
1317
+ const decorated = this.workerContexts?.decorate(body) ?? body;
1318
+ const result = await this.cardDiagnostics.deliver(context, decorated, () => send(decorated));
1307
1319
  if (result?.code)
1308
1320
  throw result;
1309
1321
  return result;
@@ -1348,6 +1360,82 @@ Examples:
1348
1360
  throw new Error('Could not update tip card.');
1349
1361
  });
1350
1362
  }
1363
+ outputLogger = (0, DeliveryDiagnostics_1.safeSdkLogger)();
1364
+ /** A per-operation deadline also aborts SDK token requests and the actual HTTP transport. */
1365
+ async outputRequest(timeout, run) {
1366
+ const controller = new AbortController();
1367
+ const timer = setTimeout(() => controller.abort(), timeout);
1368
+ timer.unref();
1369
+ const httpInstance = Object.create(lark.defaultHttpInstance);
1370
+ httpInstance.request = (options) => lark.defaultHttpInstance.request({ ...options, timeout,
1371
+ signal: controller.signal, maxRedirects: 0, maxContentLength: 64 * 1024, maxBodyLength: 20 * 1024 * 1024 + 64 * 1024 });
1372
+ for (const method of ['get', 'delete', 'head', 'options']) {
1373
+ httpInstance[method] = (url, options = {}) => httpInstance.request({ ...options, method, url });
1374
+ }
1375
+ for (const method of ['post', 'put', 'patch']) {
1376
+ httpInstance[method] = (url, data, options = {}) => httpInstance.request({ ...options, method, url, data });
1377
+ }
1378
+ try {
1379
+ const client = new lark.Client({ appId: this.appId, appSecret: this.appSecret, appType: lark.AppType.SelfBuild,
1380
+ domain: lark.Domain.Feishu, httpInstance, logger: this.outputLogger });
1381
+ return await run(client);
1382
+ }
1383
+ catch (cause) {
1384
+ const safe = (0, DeliveryDiagnostics_1.safeCardError)(cause);
1385
+ throw Object.assign(new Error('Output service request outcome unknown.'), { code: safe.category,
1386
+ response: { status: safe.httpStatus, data: { code: safe.apiCode,
1387
+ msg: safe.subCode === undefined ? undefined : `ErrCode: ${safe.subCode}`, error: { log_id: safe.traceId } } } });
1388
+ }
1389
+ finally {
1390
+ clearTimeout(timer);
1391
+ controller.abort();
1392
+ }
1393
+ }
1394
+ /** Strict receipts: missing codes/IDs are unknown, never invented success. */
1395
+ async createOutputCard(openId, content, uuid) {
1396
+ const result = await this.cardDiagnostics.deliver({ operation: 'create' }, content, () => this.outputRequest(6000, client => client.im.message.create({
1397
+ params: { receive_id_type: 'open_id' }, data: { receive_id: openId, msg_type: 'interactive', uuid, content },
1398
+ })));
1399
+ return this.outputMessageReceipt(result);
1400
+ }
1401
+ async patchOutputCard(cardId, content) {
1402
+ await this.withMessageLock(cardId, async () => {
1403
+ const result = await this.cardDiagnostics.deliver({ operation: 'update', rootId: cardId }, content, () => this.outputRequest(6000, client => client.im.message.patch({ path: { message_id: cardId }, data: { content } })));
1404
+ if (result?.code !== 0) {
1405
+ if (typeof result?.code === 'number' && result.code !== 0)
1406
+ throw new OutputTransfers_1.OutputApiRejection();
1407
+ throw new Error('Output card update outcome unknown.');
1408
+ }
1409
+ });
1410
+ }
1411
+ async uploadOutputFile(filename, name) {
1412
+ const stream = fs.createReadStream(filename);
1413
+ stream.on('error', () => { });
1414
+ try {
1415
+ const result = await this.outputRequest(110_000, client => client.im.file.create({ data: { file_type: 'stream', file_name: name, file: stream } }));
1416
+ // This SDK returns the upload data directly, unlike message.create.
1417
+ if (typeof result?.file_key === 'string' && result.file_key)
1418
+ return result.file_key;
1419
+ throw new Error('File upload outcome unknown.');
1420
+ }
1421
+ finally {
1422
+ stream.destroy();
1423
+ if (!stream.closed)
1424
+ await new Promise(resolve => stream.once('close', resolve));
1425
+ }
1426
+ }
1427
+ async sendOutputFile(openId, content, uuid) {
1428
+ const result = await this.outputRequest(10_000, client => client.im.message.create({ params: { receive_id_type: 'open_id' },
1429
+ data: { receive_id: openId, msg_type: 'file', uuid, content } }));
1430
+ return this.outputMessageReceipt(result);
1431
+ }
1432
+ outputMessageReceipt(result) {
1433
+ if (result?.code === 0 && typeof result.data?.message_id === 'string' && result.data.message_id && result.data.message_id.length <= 512)
1434
+ return result.data.message_id;
1435
+ if (typeof result?.code === 'number' && result.code !== 0)
1436
+ throw new OutputTransfers_1.OutputApiRejection();
1437
+ throw new Error('Output message outcome unknown.');
1438
+ }
1351
1439
  recordUserActivity(openId) {
1352
1440
  // Activity persistence must never delay task admission or expose private identifiers in logs.
1353
1441
  try {
@@ -1419,9 +1507,7 @@ Examples:
1419
1507
  return this._updateStreamingMessage(messageId, [...headerElements, ...elements], openId, headerElements);
1420
1508
  });
1421
1509
  }
1422
- async _updateStreamingMessage(messageId, elements, openId, continuationHeaderElements = [], trailingElements = [], keepCompletionWithBody = false) {
1423
- let updatingMessageId = messageId;
1424
- let updatingCardIndex = 0;
1510
+ async _updateStreamingMessage(messageId, elements, openId, continuationHeaderElements = [], trailingElements = [], keepCompletionWithBody = false, diagnosticOperation = 'update') {
1425
1511
  try {
1426
1512
  // Get or initialize message chain
1427
1513
  let chain = this.messageChains.get(messageId);
@@ -1451,8 +1537,6 @@ Examples:
1451
1537
  const nextToolIds = chunks.map(chunk => new Set(chunk.filter(isTool).map(element => element.element_id)));
1452
1538
  const clearDeliveredPage = async (index, elements) => {
1453
1539
  const cardId = chain[index];
1454
- updatingMessageId = cardId;
1455
- updatingCardIndex = index;
1456
1540
  const fallback = fallbackCards.has(index);
1457
1541
  const content = JSON.stringify({ schema: '2.0', body: { elements: fallback ? (0, CardTables_1.plainTextCard)(elements) : elements } });
1458
1542
  await this.sendCardRequest(content, async (body) => {
@@ -1460,7 +1544,7 @@ Examples:
1460
1544
  if (!result?.code)
1461
1545
  this.workerContexts?.remember(cardId, messageId, body);
1462
1546
  return result;
1463
- }, () => fallbackCards.add(index), !fallback);
1547
+ }, () => fallbackCards.add(index), !fallback, { operation: 'tail-clear', cardId, rootId: messageId, index });
1464
1548
  hashes[index] = '';
1465
1549
  };
1466
1550
  // Remove previous owners before publishing moved tools, including still-active
@@ -1508,16 +1592,16 @@ Examples:
1508
1592
  nextHashes[index] = (0, crypto_1.createHash)('sha256').update(payloads[index]).digest('hex');
1509
1593
  };
1510
1594
  const patchCard = async (index) => {
1511
- if (hashes[index] === nextHashes[index])
1595
+ if (hashes[index] === nextHashes[index]) {
1596
+ this.cardDiagnostics.skip({ operation: diagnosticOperation, cardId: chain[index], rootId: messageId, index });
1512
1597
  return;
1513
- updatingMessageId = chain[index];
1514
- updatingCardIndex = index;
1598
+ }
1515
1599
  await this.sendCardRequest(payloads[index], async (content) => {
1516
1600
  const result = await this.client.im.message.patch({ path: { message_id: chain[index] }, data: { content } });
1517
1601
  if (!result?.code)
1518
1602
  this.workerContexts?.remember(chain[index], messageId, content);
1519
1603
  return result;
1520
- }, () => usePlainText(index), !fallbackCards.has(index));
1604
+ }, () => usePlainText(index), !fallbackCards.has(index), { operation: diagnosticOperation, cardId: chain[index], rootId: messageId, index });
1521
1605
  // Failed requests must remain eligible for retry.
1522
1606
  hashes[index] = nextHashes[index];
1523
1607
  rememberPage(index);
@@ -1539,7 +1623,7 @@ Examples:
1539
1623
  console.log(`[FeishuHandler] Creating ${neededContinuationCards - existingContinuationCards.length} new continuation card(s)`);
1540
1624
  for (let i = existingContinuationCards.length; i < neededContinuationCards; i++) {
1541
1625
  const chunkIndex = i + 1;
1542
- const newMessageId = await this.createContinuationCard(openId, fallbackCards.has(chunkIndex) ? (0, CardTables_1.plainTextCard)(chunks[chunkIndex]) : chunks[chunkIndex], () => usePlainText(chunkIndex), !fallbackCards.has(chunkIndex), undefined, messageId);
1626
+ const newMessageId = await this.createContinuationCard(openId, fallbackCards.has(chunkIndex) ? (0, CardTables_1.plainTextCard)(chunks[chunkIndex]) : chunks[chunkIndex], () => usePlainText(chunkIndex), !fallbackCards.has(chunkIndex), undefined, messageId, chunkIndex);
1543
1627
  if (newMessageId) {
1544
1628
  chain.push(newMessageId);
1545
1629
  hashes[chunkIndex] = nextHashes[chunkIndex];
@@ -1556,13 +1640,8 @@ Examples:
1556
1640
  return true;
1557
1641
  }
1558
1642
  catch (error) {
1559
- const detail = error?.response?.data ?? error;
1560
- console.error('Failed to update streaming message:', {
1561
- rootMessageId: messageId, messageId: updatingMessageId, cardNumber: updatingCardIndex + 1,
1562
- code: detail?.code,
1563
- subCode: typeof detail?.msg === 'string' ? /ErrCode:\s*(\d+)/.exec(detail.msg)?.[1] : undefined,
1564
- logId: detail?.log_id, message: error?.message || 'Card update failed',
1565
- });
1643
+ // Attempt errors are recorded and rate-limited at the exact send boundary.
1644
+ // Do not print the SDK error again here (it can contain the entire card).
1566
1645
  return false;
1567
1646
  }
1568
1647
  }
@@ -1628,7 +1707,7 @@ Examples:
1628
1707
  // Repack changed previews and clear obsolete tool copies without retracting messages.
1629
1708
  const trailingElements = !queueConfirmation ? [...footerElements, ...threadSwitchElements] : threadSwitchElements;
1630
1709
  const keepCompletionWithBody = !bare && !queueConfirmation;
1631
- const updated = await this._updateStreamingMessage(messageId, finalElements, openId, headerElements, trailingElements, keepCompletionWithBody);
1710
+ const updated = await this._updateStreamingMessage(messageId, finalElements, openId, headerElements, trailingElements, keepCompletionWithBody, 'finalize');
1632
1711
  if (!updated) {
1633
1712
  return false;
1634
1713
  }
@@ -1664,7 +1743,7 @@ Examples:
1664
1743
  return true;
1665
1744
  }
1666
1745
  catch (error) {
1667
- console.error('Failed to finalize streaming message:', error?.message || error);
1746
+ (0, DeliveryDiagnostics_1.deliveryEvent)('card_finalize_failed', (0, DeliveryDiagnostics_1.safeCardError)(error));
1668
1747
  return false;
1669
1748
  }
1670
1749
  }
@@ -1828,7 +1907,7 @@ Examples:
1828
1907
  if (!result?.code)
1829
1908
  this.workerContexts?.remember(cardMessageId, rootId, content);
1830
1909
  return result;
1831
- });
1910
+ }, undefined, true, { operation: 'controls', cardId: cardMessageId, rootId });
1832
1911
  this.threadSwitchCardState.set(cardMessageId, { ...state, activeThreadId: newActiveThreadId });
1833
1912
  });
1834
1913
  }
@@ -1842,7 +1921,7 @@ Examples:
1842
1921
  if (!result?.code)
1843
1922
  this.workerContexts?.remember(cardId, rootId, body);
1844
1923
  return result;
1845
- });
1924
+ }, undefined, true, { operation: 'controls', cardId, rootId });
1846
1925
  // A concurrent reset can change controls without changing the streaming source elements.
1847
1926
  this.cardContentHashes.delete(rootId);
1848
1927
  });
@@ -1866,6 +1945,17 @@ Examples:
1866
1945
  if (!parsed || typeof parsed !== 'object')
1867
1946
  return;
1868
1947
  this.recordUserActivity(openId);
1948
+ if (parsed.action === 'output_file') {
1949
+ const cardId = data?.context?.open_message_id;
1950
+ if (typeof cardId !== 'string' || !this.onOutputFileAction)
1951
+ return { toast: { type: 'error', content: 'Output files unavailable.' } };
1952
+ try {
1953
+ return { toast: { type: 'info', content: await this.onOutputFileAction(openId, cardId, parsed) } };
1954
+ }
1955
+ catch {
1956
+ return { toast: { type: 'error', content: 'File retrieval could not be admitted.' } };
1957
+ }
1958
+ }
1869
1959
  if (parsed.action === 'tips') {
1870
1960
  const cardId = data?.context?.open_message_id;
1871
1961
  if (typeof cardId !== 'string' || !this.onTipsAction) {
@@ -1936,11 +2026,11 @@ Examples:
1936
2026
  if (selectedName && typeof selectedName === 'object') {
1937
2027
  return { toast: { type: 'info', content: selectedName.notice } };
1938
2028
  }
1939
- this.refreshThreadSwitchButtons(openMessageId, parsed.threadId).catch((err) => console.error('[FeishuLongConnHandler] Failed to refresh thread switch buttons:', err));
2029
+ this.refreshThreadSwitchButtons(openMessageId, parsed.threadId).catch((err) => (0, DeliveryDiagnostics_1.deliveryEvent)('card_controls_failed', (0, DeliveryDiagnostics_1.safeCardError)(err)));
1940
2030
  return { toast: { type: 'success', content: `Switched to: ${selectedName ?? parsed.threadName ?? parsed.threadId}` } };
1941
2031
  }
1942
2032
  catch (error) {
1943
- console.error('[FeishuLongConnHandler] Card action switch_thread failed:', error);
2033
+ (0, DeliveryDiagnostics_1.deliveryEvent)('card_switch_failed', (0, DeliveryDiagnostics_1.safeCardError)(error));
1944
2034
  return { toast: { type: 'error', content: error instanceof Error ? error.message : 'Thread selection failed.' } };
1945
2035
  }
1946
2036
  }
@@ -1953,7 +2043,7 @@ Examples:
1953
2043
  return { toast: { type: 'info', content: 'Creating new thread...' } };
1954
2044
  }
1955
2045
  catch (error) {
1956
- console.error('[FeishuLongConnHandler] Card action new_thread failed:', error);
2046
+ (0, DeliveryDiagnostics_1.deliveryEvent)('card_new_thread_failed', (0, DeliveryDiagnostics_1.safeCardError)(error));
1957
2047
  return { toast: { type: 'error', content: error instanceof Error ? error.message : 'Could not create a thread.' } };
1958
2048
  }
1959
2049
  }
@@ -1966,7 +2056,7 @@ Examples:
1966
2056
  return { toast: { type: 'success', content: parsed.action === 'queue_confirm' ? 'Queue confirmation sent' : 'Queue request cancelled' } };
1967
2057
  }
1968
2058
  catch (error) {
1969
- console.error('[FeishuLongConnHandler] Queue action failed:', error);
2059
+ (0, DeliveryDiagnostics_1.deliveryEvent)('card_queue_action_failed', (0, DeliveryDiagnostics_1.safeCardError)(error));
1970
2060
  return { toast: { type: 'error', content: 'Queue action failed' } };
1971
2061
  }
1972
2062
  }
@@ -2001,7 +2091,7 @@ Examples:
2001
2091
  executionMessageId = (0, uuid_1.v4)();
2002
2092
  const feishuMessageId = this.connectionHub.supportsQueueStarted(activeDevice.deviceId)
2003
2093
  ? null
2004
- : await this.sendStreamingStart(openId, '🤔 Queued message confirmed. Waiting for the current task to finish...');
2094
+ : await this.sendStreamingStart(openId, '🤔 Queued message confirmed. Waiting for the current task to finish...', undefined, undefined, executionMessageId);
2005
2095
  try {
2006
2096
  await this.onStartStreaming?.(executionMessageId, openId, feishuMessageId, activeDevice.deviceId, threadId, false, cardMessageId, undefined, selectionFence);
2007
2097
  }
@@ -2087,7 +2177,7 @@ Examples:
2087
2177
  });
2088
2178
  }
2089
2179
  catch (error) {
2090
- console.error('[FeishuLongConnHandler] Failed to update queue confirmation card:', error?.message || error);
2180
+ (0, DeliveryDiagnostics_1.deliveryEvent)('card_queue_update_failed', (0, DeliveryDiagnostics_1.safeCardError)(error));
2091
2181
  }
2092
2182
  }
2093
2183
  /**
@@ -2138,6 +2228,7 @@ Examples:
2138
2228
  * Stop the Feishu connection
2139
2229
  */
2140
2230
  async stop() {
2231
+ this.cardDiagnostics.close();
2141
2232
  try {
2142
2233
  console.log('Stopping Feishu WebSocket connection...');
2143
2234
  // Close WebSocket connection — must call close() to stop internal ping