@yu_robotics/remote-cli-router 1.6.219 → 1.6.220
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 +4 -3
- package/dist/feishu/FeishuLongConnHandler.d.ts +3 -1
- package/dist/feishu/FeishuLongConnHandler.d.ts.map +1 -1
- package/dist/feishu/FeishuLongConnHandler.js +49 -47
- package/dist/feishu/FeishuLongConnHandler.js.map +1 -1
- package/dist/server.d.ts +1 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +122 -94
- package/dist/server.js.map +1 -1
- package/dist/utils/DeliveryDiagnostics.d.ts +46 -0
- package/dist/utils/DeliveryDiagnostics.d.ts.map +1 -0
- package/dist/utils/DeliveryDiagnostics.js +322 -0
- package/dist/utils/DeliveryDiagnostics.js.map +1 -0
- package/package.json +1 -1
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
|
|
158
|
-
|
|
159
|
-
|
|
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;
|
|
@@ -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;
|
|
@@ -220,7 +222,7 @@ export declare class FeishuLongConnHandler {
|
|
|
220
222
|
* Send streaming message with card update support
|
|
221
223
|
* Returns message_id for updating
|
|
222
224
|
*/
|
|
223
|
-
sendStreamingStart(openId: string, initialText?: string, threadName?: string, cwd?: string): Promise<string | null>;
|
|
225
|
+
sendStreamingStart(openId: string, initialText?: string, threadName?: string, cwd?: string, diagnosticTaskId?: string): Promise<string | null>;
|
|
224
226
|
/**
|
|
225
227
|
* Serialize async operations per messageId to prevent race conditions.
|
|
226
228
|
* Concurrent calls for the same messageId will queue and execute in order.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeishuLongConnHandler.d.ts","sourceRoot":"","sources":["../../src/feishu/FeishuLongConnHandler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FeishuLongConnHandler.d.ts","sourceRoot":"","sources":["../../src/feishu/FeishuLongConnHandler.ts"],"names":[],"mappings":"AAGA,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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AG,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,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.FeishuLongConnHandler = void 0;
|
|
37
|
+
const DeliveryDiagnostics_1 = require("../utils/DeliveryDiagnostics");
|
|
37
38
|
const lark = __importStar(require("@larksuiteoapi/node-sdk"));
|
|
38
39
|
const uuid_1 = require("uuid");
|
|
39
40
|
const BindingManager_1 = require("../binding/BindingManager");
|
|
@@ -51,6 +52,8 @@ const CardTables_1 = require("../utils/CardTables");
|
|
|
51
52
|
* Uses Feishu SDK's WSClient for WebSocket long connection
|
|
52
53
|
*/
|
|
53
54
|
class FeishuLongConnHandler {
|
|
55
|
+
cardDiagnostics = new DeliveryDiagnostics_1.CardDeliveryDiagnostics();
|
|
56
|
+
bindDiagnosticTask(cardId, taskId) { this.cardDiagnostics.bind(cardId, taskId); }
|
|
54
57
|
workerContexts;
|
|
55
58
|
settingsCards;
|
|
56
59
|
client;
|
|
@@ -99,6 +102,7 @@ class FeishuLongConnHandler {
|
|
|
99
102
|
appSecret: config.appSecret,
|
|
100
103
|
appType: lark.AppType.SelfBuild,
|
|
101
104
|
domain: lark.Domain.Feishu,
|
|
105
|
+
logger: (0, DeliveryDiagnostics_1.safeSdkLogger)(),
|
|
102
106
|
});
|
|
103
107
|
}
|
|
104
108
|
/**
|
|
@@ -458,7 +462,7 @@ class FeishuLongConnHandler {
|
|
|
458
462
|
// Generate message ID first
|
|
459
463
|
const commandMessageId = (0, uuid_1.v4)();
|
|
460
464
|
// Register streaming session BEFORE sending command
|
|
461
|
-
const feishuMessageId = await this.sendStreamingStart(openId, `🤔 Executing ${command}...`, threadName);
|
|
465
|
+
const feishuMessageId = await this.sendStreamingStart(openId, `🤔 Executing ${command}...`, threadName, undefined, commandMessageId);
|
|
462
466
|
const currentBinding = await this.bindingManager.getUserBinding(openId);
|
|
463
467
|
if (!currentBinding?.devices.some((device) => device.deviceId === activeDevice.deviceId)) {
|
|
464
468
|
throw new Error('Device ownership changed before the command could be sent.');
|
|
@@ -827,7 +831,7 @@ Examples:
|
|
|
827
831
|
console.log(`[FeishuHandler] Creating streaming card for command ${commandMessageId}${threadId ? ` (threadId=${threadId})` : ''}${pendingNewThread ? ' (pendingNewThread)' : ''}`);
|
|
828
832
|
// Register streaming session BEFORE sending command to avoid race condition
|
|
829
833
|
// where stream chunks arrive before registration
|
|
830
|
-
const feishuMessageId = await this.sendStreamingStart(openId, attachments ? '🖼️ Processing image...' : '🤔 Processing...', threadName);
|
|
834
|
+
const feishuMessageId = await this.sendStreamingStart(openId, attachments ? '🖼️ Processing image...' : '🤔 Processing...', threadName, undefined, commandMessageId);
|
|
831
835
|
const currentBinding = await this.bindingManager.getUserBinding(openId);
|
|
832
836
|
if (!currentBinding?.devices.some((device) => device.deviceId === activeDevice.deviceId)) {
|
|
833
837
|
throw new Error('Device ownership changed before the command could be sent.');
|
|
@@ -960,7 +964,7 @@ Examples:
|
|
|
960
964
|
});
|
|
961
965
|
}
|
|
962
966
|
catch (error) {
|
|
963
|
-
|
|
967
|
+
(0, DeliveryDiagnostics_1.deliveryEvent)('text_reply_failed', (0, DeliveryDiagnostics_1.safeCardError)(error));
|
|
964
968
|
}
|
|
965
969
|
}
|
|
966
970
|
/**
|
|
@@ -979,7 +983,7 @@ Examples:
|
|
|
979
983
|
return true;
|
|
980
984
|
}
|
|
981
985
|
catch (error) {
|
|
982
|
-
|
|
986
|
+
(0, DeliveryDiagnostics_1.deliveryEvent)('text_message_failed', (0, DeliveryDiagnostics_1.safeCardError)(error));
|
|
983
987
|
return false;
|
|
984
988
|
}
|
|
985
989
|
}
|
|
@@ -987,26 +991,27 @@ Examples:
|
|
|
987
991
|
* Send streaming message with card update support
|
|
988
992
|
* Returns message_id for updating
|
|
989
993
|
*/
|
|
990
|
-
async sendStreamingStart(openId, initialText = '🤔 Thinking...', threadName, cwd) {
|
|
991
|
-
|
|
994
|
+
async sendStreamingStart(openId, initialText = '🤔 Thinking...', threadName, cwd, diagnosticTaskId) {
|
|
995
|
+
let attempted = false;
|
|
992
996
|
try {
|
|
993
997
|
const elements = this.createResponseHeaderElements(threadName || 'Resolving thread...', cwd);
|
|
994
998
|
elements.push({ tag: 'markdown', content: initialText });
|
|
995
|
-
const
|
|
999
|
+
const content = JSON.stringify({ schema: '2.0', body: { elements } });
|
|
1000
|
+
attempted = true;
|
|
1001
|
+
const result = await this.cardDiagnostics.deliver({ operation: 'create', taskId: diagnosticTaskId }, content, () => this.client.im.message.create({
|
|
996
1002
|
params: { receive_id_type: 'open_id' },
|
|
997
1003
|
data: {
|
|
998
1004
|
receive_id: openId,
|
|
999
1005
|
msg_type: 'interactive',
|
|
1000
|
-
content
|
|
1001
|
-
schema: '2.0',
|
|
1002
|
-
body: { elements },
|
|
1003
|
-
}),
|
|
1006
|
+
content,
|
|
1004
1007
|
},
|
|
1005
|
-
});
|
|
1008
|
+
}));
|
|
1006
1009
|
return result?.data?.message_id || null;
|
|
1007
1010
|
}
|
|
1008
1011
|
catch (error) {
|
|
1009
|
-
|
|
1012
|
+
// Actual request failures are already aggregated at the send boundary.
|
|
1013
|
+
if (!attempted)
|
|
1014
|
+
(0, DeliveryDiagnostics_1.deliveryEvent)('card_preparation_failed', (0, DeliveryDiagnostics_1.safeCardError)(error));
|
|
1010
1015
|
return null;
|
|
1011
1016
|
}
|
|
1012
1017
|
}
|
|
@@ -1261,7 +1266,7 @@ Examples:
|
|
|
1261
1266
|
};
|
|
1262
1267
|
const jsonSize = JSON.stringify(cardData).length;
|
|
1263
1268
|
const sizeLimit = this.CARD_DATA_SIZE_LIMIT - this.CARD_SIZE_BUFFER;
|
|
1264
|
-
console.log(`[FeishuHandler] Card
|
|
1269
|
+
console.log(`[FeishuHandler] Card preflight size: ${jsonSize} UTF-16 units, limit: ${sizeLimit} units`);
|
|
1265
1270
|
// Use buffer for safety (2.9MB instead of 3MB)
|
|
1266
1271
|
if (jsonSize > sizeLimit) {
|
|
1267
1272
|
console.log(`[FeishuHandler] Data size (${jsonSize}) exceeds limit (${sizeLimit})`);
|
|
@@ -1277,9 +1282,11 @@ Examples:
|
|
|
1277
1282
|
* @param elements Array of Feishu Card 2.0 elements
|
|
1278
1283
|
* @returns The new message ID, or null on error
|
|
1279
1284
|
*/
|
|
1280
|
-
async createContinuationCard(openId, elements, onTextFallback, allowFallback = true, header, rootId) {
|
|
1285
|
+
async createContinuationCard(openId, elements, onTextFallback, allowFallback = true, header, rootId, diagnosticIndex) {
|
|
1286
|
+
let attempted = false;
|
|
1281
1287
|
try {
|
|
1282
1288
|
const content = JSON.stringify({ schema: '2.0', ...(header ? { header } : {}), body: { elements: (0, CardTables_1.limitCardTables)(elements) } });
|
|
1289
|
+
attempted = true;
|
|
1283
1290
|
const result = await this.sendCardRequest(content, async (body) => {
|
|
1284
1291
|
const response = await this.client.im.message.create({
|
|
1285
1292
|
params: { receive_id_type: 'open_id' },
|
|
@@ -1292,18 +1299,21 @@ Examples:
|
|
|
1292
1299
|
if (!response.code && response.data?.message_id)
|
|
1293
1300
|
this.workerContexts?.remember(response.data.message_id, rootId ?? response.data.message_id, body);
|
|
1294
1301
|
return response;
|
|
1295
|
-
}, onTextFallback, allowFallback);
|
|
1302
|
+
}, onTextFallback, allowFallback, { operation: 'create', rootId, index: diagnosticIndex });
|
|
1296
1303
|
return result.data?.message_id || null;
|
|
1297
1304
|
}
|
|
1298
1305
|
catch (error) {
|
|
1299
|
-
|
|
1306
|
+
// Actual request failures are already aggregated at the send boundary.
|
|
1307
|
+
if (!attempted)
|
|
1308
|
+
(0, DeliveryDiagnostics_1.deliveryEvent)('card_preparation_failed', (0, DeliveryDiagnostics_1.safeCardError)(error));
|
|
1300
1309
|
return null;
|
|
1301
1310
|
}
|
|
1302
1311
|
}
|
|
1303
1312
|
/** Retry a confirmed table-limit or Markdown parse rejection once with readable text. */
|
|
1304
|
-
async sendCardRequest(content, send, onTextFallback, allowFallback = true) {
|
|
1313
|
+
async sendCardRequest(content, send, onTextFallback, allowFallback = true, context = { operation: 'update' }) {
|
|
1305
1314
|
const checkedSend = async (body) => {
|
|
1306
|
-
const
|
|
1315
|
+
const decorated = this.workerContexts?.decorate(body) ?? body;
|
|
1316
|
+
const result = await this.cardDiagnostics.deliver(context, decorated, () => send(decorated));
|
|
1307
1317
|
if (result?.code)
|
|
1308
1318
|
throw result;
|
|
1309
1319
|
return result;
|
|
@@ -1419,9 +1429,7 @@ Examples:
|
|
|
1419
1429
|
return this._updateStreamingMessage(messageId, [...headerElements, ...elements], openId, headerElements);
|
|
1420
1430
|
});
|
|
1421
1431
|
}
|
|
1422
|
-
async _updateStreamingMessage(messageId, elements, openId, continuationHeaderElements = [], trailingElements = [], keepCompletionWithBody = false) {
|
|
1423
|
-
let updatingMessageId = messageId;
|
|
1424
|
-
let updatingCardIndex = 0;
|
|
1432
|
+
async _updateStreamingMessage(messageId, elements, openId, continuationHeaderElements = [], trailingElements = [], keepCompletionWithBody = false, diagnosticOperation = 'update') {
|
|
1425
1433
|
try {
|
|
1426
1434
|
// Get or initialize message chain
|
|
1427
1435
|
let chain = this.messageChains.get(messageId);
|
|
@@ -1451,8 +1459,6 @@ Examples:
|
|
|
1451
1459
|
const nextToolIds = chunks.map(chunk => new Set(chunk.filter(isTool).map(element => element.element_id)));
|
|
1452
1460
|
const clearDeliveredPage = async (index, elements) => {
|
|
1453
1461
|
const cardId = chain[index];
|
|
1454
|
-
updatingMessageId = cardId;
|
|
1455
|
-
updatingCardIndex = index;
|
|
1456
1462
|
const fallback = fallbackCards.has(index);
|
|
1457
1463
|
const content = JSON.stringify({ schema: '2.0', body: { elements: fallback ? (0, CardTables_1.plainTextCard)(elements) : elements } });
|
|
1458
1464
|
await this.sendCardRequest(content, async (body) => {
|
|
@@ -1460,7 +1466,7 @@ Examples:
|
|
|
1460
1466
|
if (!result?.code)
|
|
1461
1467
|
this.workerContexts?.remember(cardId, messageId, body);
|
|
1462
1468
|
return result;
|
|
1463
|
-
}, () => fallbackCards.add(index), !fallback);
|
|
1469
|
+
}, () => fallbackCards.add(index), !fallback, { operation: 'tail-clear', cardId, rootId: messageId, index });
|
|
1464
1470
|
hashes[index] = '';
|
|
1465
1471
|
};
|
|
1466
1472
|
// Remove previous owners before publishing moved tools, including still-active
|
|
@@ -1508,16 +1514,16 @@ Examples:
|
|
|
1508
1514
|
nextHashes[index] = (0, crypto_1.createHash)('sha256').update(payloads[index]).digest('hex');
|
|
1509
1515
|
};
|
|
1510
1516
|
const patchCard = async (index) => {
|
|
1511
|
-
if (hashes[index] === nextHashes[index])
|
|
1517
|
+
if (hashes[index] === nextHashes[index]) {
|
|
1518
|
+
this.cardDiagnostics.skip({ operation: diagnosticOperation, cardId: chain[index], rootId: messageId, index });
|
|
1512
1519
|
return;
|
|
1513
|
-
|
|
1514
|
-
updatingCardIndex = index;
|
|
1520
|
+
}
|
|
1515
1521
|
await this.sendCardRequest(payloads[index], async (content) => {
|
|
1516
1522
|
const result = await this.client.im.message.patch({ path: { message_id: chain[index] }, data: { content } });
|
|
1517
1523
|
if (!result?.code)
|
|
1518
1524
|
this.workerContexts?.remember(chain[index], messageId, content);
|
|
1519
1525
|
return result;
|
|
1520
|
-
}, () => usePlainText(index), !fallbackCards.has(index));
|
|
1526
|
+
}, () => usePlainText(index), !fallbackCards.has(index), { operation: diagnosticOperation, cardId: chain[index], rootId: messageId, index });
|
|
1521
1527
|
// Failed requests must remain eligible for retry.
|
|
1522
1528
|
hashes[index] = nextHashes[index];
|
|
1523
1529
|
rememberPage(index);
|
|
@@ -1539,7 +1545,7 @@ Examples:
|
|
|
1539
1545
|
console.log(`[FeishuHandler] Creating ${neededContinuationCards - existingContinuationCards.length} new continuation card(s)`);
|
|
1540
1546
|
for (let i = existingContinuationCards.length; i < neededContinuationCards; i++) {
|
|
1541
1547
|
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);
|
|
1548
|
+
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
1549
|
if (newMessageId) {
|
|
1544
1550
|
chain.push(newMessageId);
|
|
1545
1551
|
hashes[chunkIndex] = nextHashes[chunkIndex];
|
|
@@ -1556,13 +1562,8 @@ Examples:
|
|
|
1556
1562
|
return true;
|
|
1557
1563
|
}
|
|
1558
1564
|
catch (error) {
|
|
1559
|
-
|
|
1560
|
-
|
|
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
|
-
});
|
|
1565
|
+
// Attempt errors are recorded and rate-limited at the exact send boundary.
|
|
1566
|
+
// Do not print the SDK error again here (it can contain the entire card).
|
|
1566
1567
|
return false;
|
|
1567
1568
|
}
|
|
1568
1569
|
}
|
|
@@ -1628,7 +1629,7 @@ Examples:
|
|
|
1628
1629
|
// Repack changed previews and clear obsolete tool copies without retracting messages.
|
|
1629
1630
|
const trailingElements = !queueConfirmation ? [...footerElements, ...threadSwitchElements] : threadSwitchElements;
|
|
1630
1631
|
const keepCompletionWithBody = !bare && !queueConfirmation;
|
|
1631
|
-
const updated = await this._updateStreamingMessage(messageId, finalElements, openId, headerElements, trailingElements, keepCompletionWithBody);
|
|
1632
|
+
const updated = await this._updateStreamingMessage(messageId, finalElements, openId, headerElements, trailingElements, keepCompletionWithBody, 'finalize');
|
|
1632
1633
|
if (!updated) {
|
|
1633
1634
|
return false;
|
|
1634
1635
|
}
|
|
@@ -1664,7 +1665,7 @@ Examples:
|
|
|
1664
1665
|
return true;
|
|
1665
1666
|
}
|
|
1666
1667
|
catch (error) {
|
|
1667
|
-
|
|
1668
|
+
(0, DeliveryDiagnostics_1.deliveryEvent)('card_finalize_failed', (0, DeliveryDiagnostics_1.safeCardError)(error));
|
|
1668
1669
|
return false;
|
|
1669
1670
|
}
|
|
1670
1671
|
}
|
|
@@ -1828,7 +1829,7 @@ Examples:
|
|
|
1828
1829
|
if (!result?.code)
|
|
1829
1830
|
this.workerContexts?.remember(cardMessageId, rootId, content);
|
|
1830
1831
|
return result;
|
|
1831
|
-
});
|
|
1832
|
+
}, undefined, true, { operation: 'controls', cardId: cardMessageId, rootId });
|
|
1832
1833
|
this.threadSwitchCardState.set(cardMessageId, { ...state, activeThreadId: newActiveThreadId });
|
|
1833
1834
|
});
|
|
1834
1835
|
}
|
|
@@ -1842,7 +1843,7 @@ Examples:
|
|
|
1842
1843
|
if (!result?.code)
|
|
1843
1844
|
this.workerContexts?.remember(cardId, rootId, body);
|
|
1844
1845
|
return result;
|
|
1845
|
-
});
|
|
1846
|
+
}, undefined, true, { operation: 'controls', cardId, rootId });
|
|
1846
1847
|
// A concurrent reset can change controls without changing the streaming source elements.
|
|
1847
1848
|
this.cardContentHashes.delete(rootId);
|
|
1848
1849
|
});
|
|
@@ -1936,11 +1937,11 @@ Examples:
|
|
|
1936
1937
|
if (selectedName && typeof selectedName === 'object') {
|
|
1937
1938
|
return { toast: { type: 'info', content: selectedName.notice } };
|
|
1938
1939
|
}
|
|
1939
|
-
this.refreshThreadSwitchButtons(openMessageId, parsed.threadId).catch((err) =>
|
|
1940
|
+
this.refreshThreadSwitchButtons(openMessageId, parsed.threadId).catch((err) => (0, DeliveryDiagnostics_1.deliveryEvent)('card_controls_failed', (0, DeliveryDiagnostics_1.safeCardError)(err)));
|
|
1940
1941
|
return { toast: { type: 'success', content: `Switched to: ${selectedName ?? parsed.threadName ?? parsed.threadId}` } };
|
|
1941
1942
|
}
|
|
1942
1943
|
catch (error) {
|
|
1943
|
-
|
|
1944
|
+
(0, DeliveryDiagnostics_1.deliveryEvent)('card_switch_failed', (0, DeliveryDiagnostics_1.safeCardError)(error));
|
|
1944
1945
|
return { toast: { type: 'error', content: error instanceof Error ? error.message : 'Thread selection failed.' } };
|
|
1945
1946
|
}
|
|
1946
1947
|
}
|
|
@@ -1953,7 +1954,7 @@ Examples:
|
|
|
1953
1954
|
return { toast: { type: 'info', content: 'Creating new thread...' } };
|
|
1954
1955
|
}
|
|
1955
1956
|
catch (error) {
|
|
1956
|
-
|
|
1957
|
+
(0, DeliveryDiagnostics_1.deliveryEvent)('card_new_thread_failed', (0, DeliveryDiagnostics_1.safeCardError)(error));
|
|
1957
1958
|
return { toast: { type: 'error', content: error instanceof Error ? error.message : 'Could not create a thread.' } };
|
|
1958
1959
|
}
|
|
1959
1960
|
}
|
|
@@ -1966,7 +1967,7 @@ Examples:
|
|
|
1966
1967
|
return { toast: { type: 'success', content: parsed.action === 'queue_confirm' ? 'Queue confirmation sent' : 'Queue request cancelled' } };
|
|
1967
1968
|
}
|
|
1968
1969
|
catch (error) {
|
|
1969
|
-
|
|
1970
|
+
(0, DeliveryDiagnostics_1.deliveryEvent)('card_queue_action_failed', (0, DeliveryDiagnostics_1.safeCardError)(error));
|
|
1970
1971
|
return { toast: { type: 'error', content: 'Queue action failed' } };
|
|
1971
1972
|
}
|
|
1972
1973
|
}
|
|
@@ -2001,7 +2002,7 @@ Examples:
|
|
|
2001
2002
|
executionMessageId = (0, uuid_1.v4)();
|
|
2002
2003
|
const feishuMessageId = this.connectionHub.supportsQueueStarted(activeDevice.deviceId)
|
|
2003
2004
|
? null
|
|
2004
|
-
: await this.sendStreamingStart(openId, '🤔 Queued message confirmed. Waiting for the current task to finish...');
|
|
2005
|
+
: await this.sendStreamingStart(openId, '🤔 Queued message confirmed. Waiting for the current task to finish...', undefined, undefined, executionMessageId);
|
|
2005
2006
|
try {
|
|
2006
2007
|
await this.onStartStreaming?.(executionMessageId, openId, feishuMessageId, activeDevice.deviceId, threadId, false, cardMessageId, undefined, selectionFence);
|
|
2007
2008
|
}
|
|
@@ -2087,7 +2088,7 @@ Examples:
|
|
|
2087
2088
|
});
|
|
2088
2089
|
}
|
|
2089
2090
|
catch (error) {
|
|
2090
|
-
|
|
2091
|
+
(0, DeliveryDiagnostics_1.deliveryEvent)('card_queue_update_failed', (0, DeliveryDiagnostics_1.safeCardError)(error));
|
|
2091
2092
|
}
|
|
2092
2093
|
}
|
|
2093
2094
|
/**
|
|
@@ -2138,6 +2139,7 @@ Examples:
|
|
|
2138
2139
|
* Stop the Feishu connection
|
|
2139
2140
|
*/
|
|
2140
2141
|
async stop() {
|
|
2142
|
+
this.cardDiagnostics.close();
|
|
2141
2143
|
try {
|
|
2142
2144
|
console.log('Stopping Feishu WebSocket connection...');
|
|
2143
2145
|
// Close WebSocket connection — must call close() to stop internal ping
|