@yu_robotics/remote-cli-router 1.6.169 → 1.6.170
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 +0 -2
- package/dist/feishu/FeishuLongConnHandler.d.ts +1 -10
- package/dist/feishu/FeishuLongConnHandler.d.ts.map +1 -1
- package/dist/feishu/FeishuLongConnHandler.js +29 -172
- package/dist/feishu/FeishuLongConnHandler.js.map +1 -1
- package/dist/server.d.ts +0 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +0 -7
- package/dist/server.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,8 +6,6 @@ Backend executable discovery is local-client behavior. CLI 1.6.119 supplements L
|
|
|
6
6
|
|
|
7
7
|
## Public Activity
|
|
8
8
|
|
|
9
|
-
From Router 1.6.169, reply-card thread lists start collapsed. Use **Show threads** to expand the list in the same card, or **Switch to this thread** to select the thread that produced the reply. Opening or hiding the list does not change the input target; a successful switch hides the list and confirms the new target without changing the reply's source label. No separate thread-management card is sent. The recursive element budget is 180 instead of 150, with room reserved for the expanded controls; table and size thresholds are unchanged. This presentation update requires the newer Router, not a new CLI protocol capability.
|
|
10
|
-
|
|
11
9
|
From Router 1.6.158, completion pagination keeps the final body item (or complete worker group) with the completion note, optional model metadata and thread controls when they fit together. This avoids preventable footer-only continuations, including replies without model metadata. Indivisible oversized groups still split according to node, size and table limits; thread-button refreshes preserve the final body. This does not change streaming completion timing or the wire protocol.
|
|
12
10
|
|
|
13
11
|
From CLI 1.6.153, Codex shell calls no longer lose their label when native command actions are absent or unknown. Native reads, searches, and directory listings remain preferred. Other calls use fixed operation labels such as `Run npm command` or `Run Git command` for simple allowlisted programs, and `Run shell command` for compound or unrecognized commands. These are deterministic operation labels, not model-authored purpose summaries: installed Codex 0.160.0 command items have no per-call description field. Arguments, full paths, output, and execution-wide reasoning are never copied into these fallback labels. Late native action metadata can enrich a pending row before its first result; repeated results retain one row. Existing description fields, heading limits, and card-node counts are unchanged; upgrade the CLI, with no new Router capability required.
|
|
@@ -84,8 +84,6 @@ export declare class FeishuLongConnHandler {
|
|
|
84
84
|
* RouterServer sets this directly after construction.
|
|
85
85
|
*/
|
|
86
86
|
onCardNewThread?: (openId: string) => Promise<void>;
|
|
87
|
-
/** Latest device-reported inventory; missing inventory fails closed for new controls. */
|
|
88
|
-
onCardThreadExists?: (deviceId: string, threadId: string) => boolean;
|
|
89
87
|
/** Callback invoked when a user confirms or cancels a queued command. */
|
|
90
88
|
onApprovalAction?: (openId: string, requestId: string, cardId: string, decision: string) => Promise<string>;
|
|
91
89
|
onMaintenanceAction?: (openId: string, id: string, cardId: string, action: string, offset?: number) => Promise<string>;
|
|
@@ -229,7 +227,7 @@ export declare class FeishuLongConnHandler {
|
|
|
229
227
|
* Split Card 2.0 elements into chunks based on Feishu limits
|
|
230
228
|
*
|
|
231
229
|
* Card packing budgets:
|
|
232
|
-
* 1. Element count: Max 200 tagged nodes per card (we use
|
|
230
|
+
* 1. Element count: Max 200 tagged nodes per card (we use 150 for safety)
|
|
233
231
|
* 2. Data size: Max 3,000,000 characters in the data field (JSON.stringify result)
|
|
234
232
|
* 3. Tables: A conservative budget including tables embedded in Markdown
|
|
235
233
|
*
|
|
@@ -250,7 +248,6 @@ export declare class FeishuLongConnHandler {
|
|
|
250
248
|
* According to Feishu docs, all nodes with 'tag' property count towards the 200 limit
|
|
251
249
|
*
|
|
252
250
|
* @param obj The object or array to count tags in
|
|
253
|
-
* @param reserveWorkerErrors Reserve a future error row for each Worker context control
|
|
254
251
|
* @returns Total count of nodes with 'tag' property
|
|
255
252
|
*/
|
|
256
253
|
private countTaggedNodes;
|
|
@@ -322,12 +319,6 @@ export declare class FeishuLongConnHandler {
|
|
|
322
319
|
* split across rows so desktop clients do not compress every button into one line.
|
|
323
320
|
*/
|
|
324
321
|
private createThreadSwitchElements;
|
|
325
|
-
/** The source action never accepts a target from the callback payload. */
|
|
326
|
-
private createThreadSelectorElements;
|
|
327
|
-
/** Caller owns the root message lock. Commit UI state only after a successful patch. */
|
|
328
|
-
private patchThreadSelector;
|
|
329
|
-
private assertThreadSelectorBudget;
|
|
330
|
-
private handleThreadSelector;
|
|
331
322
|
private threadButtonLabel;
|
|
332
323
|
private createResponseHeaderElements;
|
|
333
324
|
/**
|
|
@@ -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,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGrD;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,SAAS,CAAC;CAClB;
|
|
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,C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AC;IAahE,OAAO,CAAC,8BAA8B;YASxB,2BAA2B;IAsBzC;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA4C5B;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IA+B3B;;OAEG;IACH,iBAAiB,IAAI,cAAc;CAGpC"}
|
|
@@ -62,8 +62,9 @@ class FeishuLongConnHandler {
|
|
|
62
62
|
// Feishu message size limit (4000 chars per message) - DEPRECATED for Card 2.0
|
|
63
63
|
FEISHU_MESSAGE_LIMIT = 4000;
|
|
64
64
|
// Feishu Card 2.0 limits (from official docs)
|
|
65
|
-
//
|
|
66
|
-
|
|
65
|
+
// Note: Using conservative limits - official says 200, we use 150 with proper recursive counting
|
|
66
|
+
// The 150 limit leaves a 50-node safety buffer while still being practical
|
|
67
|
+
CARD_ELEMENT_LIMIT = 150; // Conservative: 150 tagged nodes per card (official: 200)
|
|
67
68
|
CARD_DATA_SIZE_LIMIT = 3000000; // Max 3MB (3,000,000 chars) for data field
|
|
68
69
|
CARD_SIZE_BUFFER = 100000; // Safety buffer: use 2.9MB instead of 3MB
|
|
69
70
|
THREAD_BUTTONS_PER_ROW = 3;
|
|
@@ -139,8 +140,6 @@ class FeishuLongConnHandler {
|
|
|
139
140
|
* RouterServer sets this directly after construction.
|
|
140
141
|
*/
|
|
141
142
|
onCardNewThread;
|
|
142
|
-
/** Latest device-reported inventory; missing inventory fails closed for new controls. */
|
|
143
|
-
onCardThreadExists;
|
|
144
143
|
/** Callback invoked when a user confirms or cancels a queued command. */
|
|
145
144
|
onApprovalAction;
|
|
146
145
|
onMaintenanceAction;
|
|
@@ -990,7 +989,7 @@ Examples:
|
|
|
990
989
|
* Split Card 2.0 elements into chunks based on Feishu limits
|
|
991
990
|
*
|
|
992
991
|
* Card packing budgets:
|
|
993
|
-
* 1. Element count: Max 200 tagged nodes per card (we use
|
|
992
|
+
* 1. Element count: Max 200 tagged nodes per card (we use 150 for safety)
|
|
994
993
|
* 2. Data size: Max 3,000,000 characters in the data field (JSON.stringify result)
|
|
995
994
|
* 3. Tables: A conservative budget including tables embedded in Markdown
|
|
996
995
|
*
|
|
@@ -1025,10 +1024,10 @@ Examples:
|
|
|
1025
1024
|
const headerTables = (0, CardTables_1.countCardTables)(continuationHeaderElements);
|
|
1026
1025
|
// Reserve space for continuation indicators and the repeated card header.
|
|
1027
1026
|
const continuationHeaderSize = JSON.stringify(continuationHeaderElements).length;
|
|
1028
|
-
const continuationHeaderTaggedNodes = continuationHeaderElements.reduce((total, element) => total + this.countTaggedNodes(element
|
|
1027
|
+
const continuationHeaderTaggedNodes = continuationHeaderElements.reduce((total, element) => total + this.countTaggedNodes(element), 0);
|
|
1029
1028
|
// Reserve the bounded tail while packing so it never displaces content onto an activity-only page.
|
|
1030
1029
|
const continuationIndicatorSize = 200 + continuationHeaderSize + (activityTail ? JSON.stringify(activityTail).length : 0);
|
|
1031
|
-
const continuationIndicatorCount = 2 + continuationHeaderTaggedNodes + (activityTail ? this.countTaggedNodes(activityTail
|
|
1030
|
+
const continuationIndicatorCount = 2 + continuationHeaderTaggedNodes + (activityTail ? this.countTaggedNodes(activityTail) : 0);
|
|
1032
1031
|
// Keep the completion block with the final body item when they fit on a
|
|
1033
1032
|
// continuation card. Include the whole worker group, never just its details.
|
|
1034
1033
|
const trailingStart = keepCompletionWithBody && trailingElements.length ? elements.indexOf(trailingElements[0]) : -1;
|
|
@@ -1040,13 +1039,13 @@ Examples:
|
|
|
1040
1039
|
const finalGroup = finalBodyStart >= continuationHeaderElements.length
|
|
1041
1040
|
? elements.slice(finalBodyStart) : [];
|
|
1042
1041
|
const keepFinalBody = finalGroup.length > trailingElements.length
|
|
1043
|
-
&& finalGroup.reduce((sum, item) => sum + this.countTaggedNodes(item
|
|
1042
|
+
&& finalGroup.reduce((sum, item) => sum + this.countTaggedNodes(item), 0) + continuationIndicatorCount <= this.CARD_ELEMENT_LIMIT
|
|
1044
1043
|
&& finalGroup.reduce((sum, item) => sum + JSON.stringify(item).length, 0) + continuationIndicatorSize <= this.CARD_DATA_SIZE_LIMIT - this.CARD_SIZE_BUFFER
|
|
1045
1044
|
&& (0, CardTables_1.countCardTables)(finalGroup) + headerTables <= CardTables_1.CARD_TABLE_LIMIT;
|
|
1046
1045
|
for (let i = 0; i < elements.length; i++) {
|
|
1047
1046
|
const element = elements[i];
|
|
1048
1047
|
const elementSize = JSON.stringify(element).length;
|
|
1049
|
-
const elementTaggedNodes = this.countTaggedNodes(element
|
|
1048
|
+
const elementTaggedNodes = this.countTaggedNodes(element);
|
|
1050
1049
|
const elementTables = (0, CardTables_1.countCardTables)(element);
|
|
1051
1050
|
// Keep worker identity, visible content and diagnostics together when packing cards.
|
|
1052
1051
|
const workerPrefix = /^dw_\d+_header$/.test(element.element_id ?? '')
|
|
@@ -1058,7 +1057,7 @@ Examples:
|
|
|
1058
1057
|
const group = keepFinalBody && i === finalBodyStart ? finalGroup
|
|
1059
1058
|
: isWorkerGroup ? workerGroup : element === trailingElements[0] ? trailingElements : [element];
|
|
1060
1059
|
const groupSize = group.reduce((sum, item) => sum + JSON.stringify(item).length, 0);
|
|
1061
|
-
const groupTaggedNodes = group.reduce((sum, item) => sum + this.countTaggedNodes(item
|
|
1060
|
+
const groupTaggedNodes = group.reduce((sum, item) => sum + this.countTaggedNodes(item), 0);
|
|
1062
1061
|
const groupTables = (0, CardTables_1.countCardTables)(group);
|
|
1063
1062
|
// Check if adding this element would exceed limits
|
|
1064
1063
|
// Reserve space for continuation indicators
|
|
@@ -1115,10 +1114,9 @@ Examples:
|
|
|
1115
1114
|
* According to Feishu docs, all nodes with 'tag' property count towards the 200 limit
|
|
1116
1115
|
*
|
|
1117
1116
|
* @param obj The object or array to count tags in
|
|
1118
|
-
* @param reserveWorkerErrors Reserve a future error row for each Worker context control
|
|
1119
1117
|
* @returns Total count of nodes with 'tag' property
|
|
1120
1118
|
*/
|
|
1121
|
-
countTaggedNodes(obj
|
|
1119
|
+
countTaggedNodes(obj) {
|
|
1122
1120
|
if (!obj || typeof obj !== 'object') {
|
|
1123
1121
|
return 0;
|
|
1124
1122
|
}
|
|
@@ -1127,13 +1125,6 @@ Examples:
|
|
|
1127
1125
|
if (obj.tag) {
|
|
1128
1126
|
count = 1;
|
|
1129
1127
|
}
|
|
1130
|
-
// WorkerContextCards.decorate can add one error row after pagination, including
|
|
1131
|
-
// on a later reset failure. Already-decorated rows must not be counted twice.
|
|
1132
|
-
const controlElements = obj.columns?.[0]?.elements;
|
|
1133
|
-
if (reserveWorkerErrors && typeof obj.element_id === 'string' && obj.element_id.startsWith('wc_')
|
|
1134
|
-
&& controlElements?.[0]?.behaviors?.[0]?.value?.action === 'worker_context_clear'
|
|
1135
|
-
&& !controlElements.some((element) => element.tag === 'markdown'))
|
|
1136
|
-
count += 1;
|
|
1137
1128
|
// Recursively count in all properties
|
|
1138
1129
|
for (const key in obj) {
|
|
1139
1130
|
if (obj.hasOwnProperty(key)) {
|
|
@@ -1141,12 +1132,12 @@ Examples:
|
|
|
1141
1132
|
if (Array.isArray(value)) {
|
|
1142
1133
|
// Recursively count in array elements
|
|
1143
1134
|
for (const item of value) {
|
|
1144
|
-
count += this.countTaggedNodes(item
|
|
1135
|
+
count += this.countTaggedNodes(item);
|
|
1145
1136
|
}
|
|
1146
1137
|
}
|
|
1147
1138
|
else if (typeof value === 'object' && value !== null) {
|
|
1148
1139
|
// Recursively count in nested objects
|
|
1149
|
-
count += this.countTaggedNodes(value
|
|
1140
|
+
count += this.countTaggedNodes(value);
|
|
1150
1141
|
}
|
|
1151
1142
|
}
|
|
1152
1143
|
}
|
|
@@ -1164,7 +1155,7 @@ Examples:
|
|
|
1164
1155
|
return false;
|
|
1165
1156
|
}
|
|
1166
1157
|
// Check element count limit - MUST count ALL nodes with 'tag' property recursively
|
|
1167
|
-
const totalTaggedNodes = elements.reduce((sum, element) => sum + this.countTaggedNodes(element
|
|
1158
|
+
const totalTaggedNodes = elements.reduce((sum, element) => sum + this.countTaggedNodes(element), 0);
|
|
1168
1159
|
console.log(`[FeishuHandler] Element count check: top-level=${elements.length}, total tagged nodes=${totalTaggedNodes}, limit=${this.CARD_ELEMENT_LIMIT}`);
|
|
1169
1160
|
if (totalTaggedNodes > this.CARD_ELEMENT_LIMIT) {
|
|
1170
1161
|
console.log(`[FeishuHandler] Total tagged nodes (${totalTaggedNodes}) exceeds limit (${this.CARD_ELEMENT_LIMIT})`);
|
|
@@ -1311,7 +1302,7 @@ Examples:
|
|
|
1311
1302
|
return this._updateStreamingMessage(messageId, [...headerElements, ...elements], openId, headerElements);
|
|
1312
1303
|
});
|
|
1313
1304
|
}
|
|
1314
|
-
async _updateStreamingMessage(messageId, elements, openId, continuationHeaderElements = [], trailingElements = [], keepCompletionWithBody = false
|
|
1305
|
+
async _updateStreamingMessage(messageId, elements, openId, continuationHeaderElements = [], trailingElements = [], keepCompletionWithBody = false) {
|
|
1315
1306
|
let updatingMessageId = messageId;
|
|
1316
1307
|
let updatingCardIndex = 0;
|
|
1317
1308
|
try {
|
|
@@ -1324,10 +1315,7 @@ Examples:
|
|
|
1324
1315
|
// Split elements into chunks based on Feishu Card 2.0 limits
|
|
1325
1316
|
const shell = this.activityShells.get(messageId);
|
|
1326
1317
|
const activityTail = shell && shell.finishedAt === undefined ? (0, ActivityProgress_1.createActivityElement)(shell.activity) : undefined;
|
|
1327
|
-
const
|
|
1328
|
-
// Pack the expanded controls, but initially deliver the compact footer on the same page.
|
|
1329
|
-
const chunks = selectorRender ? packed.map(chunk => chunk.flatMap(element => element === selectorRender.expanded[0] ? selectorRender.collapsed
|
|
1330
|
-
: selectorRender.expanded.includes(element) ? [] : [element])) : packed;
|
|
1318
|
+
const chunks = this.splitElementsIntoChunks(elements, continuationHeaderElements, trailingElements, activityTail, keepCompletionWithBody);
|
|
1331
1319
|
const tailIndex = activityTail ? chunks.length - 1 : -1;
|
|
1332
1320
|
console.log(`[FeishuHandler] Need ${chunks.length} card(s), currently have ${chain.length} card(s)`);
|
|
1333
1321
|
let hashes = this.cardContentHashes.get(messageId);
|
|
@@ -1500,8 +1488,6 @@ Examples:
|
|
|
1500
1488
|
}
|
|
1501
1489
|
// Append thread switch buttons when at least one thread exists
|
|
1502
1490
|
let threadSwitchElements = [];
|
|
1503
|
-
let selector;
|
|
1504
|
-
let selectorRender;
|
|
1505
1491
|
// The reply's owner and the destination of new messages are independent.
|
|
1506
1492
|
const activeThreadId = (openId ? this.onResolveActiveThread?.(openId)?.threadId : undefined)
|
|
1507
1493
|
?? threads?.find(thread => thread.name === 'default')?.id;
|
|
@@ -1512,18 +1498,14 @@ Examples:
|
|
|
1512
1498
|
? [replyThreadName, replyWorkspace].filter(Boolean).join(' · ')
|
|
1513
1499
|
: undefined;
|
|
1514
1500
|
if (!bare && threads && threads.length >= 1) {
|
|
1515
|
-
|
|
1516
|
-
rootId: messageId, replyThreadId, expanded: false };
|
|
1517
|
-
const state = { threads, activeThreadId, replyLabel, selector };
|
|
1518
|
-
threadSwitchElements = this.createThreadSelectorElements(state, true);
|
|
1519
|
-
selectorRender = { expanded: threadSwitchElements, collapsed: this.createThreadSelectorElements(state, false) };
|
|
1501
|
+
threadSwitchElements = this.createThreadSwitchElements(threads, activeThreadId, replyLabel);
|
|
1520
1502
|
finalElements.push(...threadSwitchElements);
|
|
1521
1503
|
}
|
|
1522
1504
|
// Reuse streaming update logic: only create cards, never delete.
|
|
1523
1505
|
// Repack changed previews and clear obsolete tool copies without retracting messages.
|
|
1524
1506
|
const trailingElements = !queueConfirmation ? [...footerElements, ...threadSwitchElements] : threadSwitchElements;
|
|
1525
1507
|
const keepCompletionWithBody = !bare && !queueConfirmation;
|
|
1526
|
-
const updated = await this._updateStreamingMessage(messageId, finalElements, openId, headerElements, trailingElements, keepCompletionWithBody
|
|
1508
|
+
const updated = await this._updateStreamingMessage(messageId, finalElements, openId, headerElements, trailingElements, keepCompletionWithBody);
|
|
1527
1509
|
if (!updated) {
|
|
1528
1510
|
return false;
|
|
1529
1511
|
}
|
|
@@ -1547,7 +1529,6 @@ Examples:
|
|
|
1547
1529
|
threads,
|
|
1548
1530
|
activeThreadId,
|
|
1549
1531
|
replyLabel,
|
|
1550
|
-
selector,
|
|
1551
1532
|
createdAt: Date.now(),
|
|
1552
1533
|
});
|
|
1553
1534
|
}
|
|
@@ -1614,90 +1595,6 @@ Examples:
|
|
|
1614
1595
|
};
|
|
1615
1596
|
return [{ tag: 'hr' }, caption, ...rows];
|
|
1616
1597
|
}
|
|
1617
|
-
/** The source action never accepts a target from the callback payload. */
|
|
1618
|
-
createThreadSelectorElements(state, expanded) {
|
|
1619
|
-
const selector = state.selector;
|
|
1620
|
-
const button = (text, op, disabled = false) => ({ tag: 'column', width: 'auto', elements: [{
|
|
1621
|
-
tag: 'button', text: { tag: 'plain_text', content: text }, type: 'default', disabled,
|
|
1622
|
-
behaviors: [{ type: 'callback', value: { action: 'thread_selector', id: selector.id, op } }],
|
|
1623
|
-
}] });
|
|
1624
|
-
const controls = { tag: 'column_set', flex_mode: 'stretch', columns: [
|
|
1625
|
-
button('Switch to this thread', 'source', !selector.replyThreadId || !selector.owner || !selector.deviceId),
|
|
1626
|
-
button(expanded ? 'Hide threads' : 'Show threads', expanded ? 'hide' : 'show'),
|
|
1627
|
-
] };
|
|
1628
|
-
const full = this.createThreadSwitchElements(state.threads, state.activeThreadId, state.replyLabel);
|
|
1629
|
-
if (!expanded)
|
|
1630
|
-
return [...full.slice(0, 2), controls];
|
|
1631
|
-
for (const row of full.slice(2))
|
|
1632
|
-
for (const column of row.columns) {
|
|
1633
|
-
const action = column.elements[0].behaviors[0].value;
|
|
1634
|
-
column.elements[0].behaviors[0].value = action.action === 'new_thread'
|
|
1635
|
-
? { action: 'thread_selector', id: selector.id, op: 'new' }
|
|
1636
|
-
: { action: 'thread_selector', id: selector.id, op: 'select', offset: state.threads.findIndex(thread => thread.id === action.threadId) };
|
|
1637
|
-
}
|
|
1638
|
-
return [...full.slice(0, 2), controls, ...full.slice(2)];
|
|
1639
|
-
}
|
|
1640
|
-
/** Caller owns the root message lock. Commit UI state only after a successful patch. */
|
|
1641
|
-
async patchThreadSelector(cardId, state, expanded, activeThreadId = state.activeThreadId) {
|
|
1642
|
-
const next = { ...state, activeThreadId, selector: { ...state.selector, expanded } };
|
|
1643
|
-
const elements = [...state.baseElements, ...this.createThreadSelectorElements(next, expanded)];
|
|
1644
|
-
if (this.checkIfElementsNeedSplitting(elements))
|
|
1645
|
-
throw new Error('Thread controls exceed this card budget.');
|
|
1646
|
-
await this.sendCardRequest(JSON.stringify({ schema: '2.0', body: { elements } }), async (content) => {
|
|
1647
|
-
this.assertThreadSelectorBudget(content);
|
|
1648
|
-
const result = await this.client.im.message.patch({ path: { message_id: cardId }, data: { content } });
|
|
1649
|
-
if (!result?.code)
|
|
1650
|
-
this.workerContexts?.remember(cardId, next.selector.rootId, content);
|
|
1651
|
-
return result;
|
|
1652
|
-
});
|
|
1653
|
-
this.threadSwitchCardState.set(cardId, next);
|
|
1654
|
-
}
|
|
1655
|
-
assertThreadSelectorBudget(content) {
|
|
1656
|
-
if (this.countTaggedNodes(JSON.parse(content)) > this.CARD_ELEMENT_LIMIT) {
|
|
1657
|
-
throw new Error('Thread controls exceed this card budget after decoration.');
|
|
1658
|
-
}
|
|
1659
|
-
}
|
|
1660
|
-
async handleThreadSelector(openId, cardId, action) {
|
|
1661
|
-
const error = (content) => ({ toast: { type: 'error', content } });
|
|
1662
|
-
if (typeof cardId !== 'string')
|
|
1663
|
-
return error('This thread selector is unavailable.');
|
|
1664
|
-
const rootId = this.threadSwitchCardState.get(cardId)?.selector?.rootId ?? cardId;
|
|
1665
|
-
return this.withMessageLock(rootId, async () => {
|
|
1666
|
-
const state = this.threadSwitchCardState.get(cardId);
|
|
1667
|
-
const selector = state?.selector;
|
|
1668
|
-
if (!state || !selector || selector.id !== action.id || selector.owner !== openId
|
|
1669
|
-
|| Date.now() - state.createdAt >= this.THREAD_SWITCH_STATE_TTL_MS)
|
|
1670
|
-
return error('This thread selector has expired or belongs to another card.');
|
|
1671
|
-
let switched;
|
|
1672
|
-
try {
|
|
1673
|
-
const device = await this.bindingManager.getActiveDevice(openId);
|
|
1674
|
-
if (!selector.deviceId || device?.deviceId !== selector.deviceId)
|
|
1675
|
-
return error('Select the original device before using this card.');
|
|
1676
|
-
if (action.op === 'show' || action.op === 'hide') {
|
|
1677
|
-
await this.patchThreadSelector(cardId, state, action.op === 'show', this.onResolveActiveThread?.(openId)?.threadId);
|
|
1678
|
-
return { toast: { type: 'info', content: action.op === 'show' ? 'Threads shown. Input target unchanged.' : 'Threads hidden. Input target unchanged.' } };
|
|
1679
|
-
}
|
|
1680
|
-
if (action.op === 'new') {
|
|
1681
|
-
if (!selector.expanded || state.threads.length >= types_1.MAX_THREADS || !this.onCardNewThread)
|
|
1682
|
-
return error('New thread is unavailable.');
|
|
1683
|
-
await this.onCardNewThread(openId);
|
|
1684
|
-
return { toast: { type: 'info', content: 'Creating new thread...' } };
|
|
1685
|
-
}
|
|
1686
|
-
const target = action.op === 'source' ? state.threads.find(thread => thread.id === selector.replyThreadId)
|
|
1687
|
-
: action.op === 'select' && selector.expanded && Number.isInteger(action.offset) && action.offset >= 0
|
|
1688
|
-
? state.threads[action.offset] : undefined;
|
|
1689
|
-
if (!target || !this.onCardThreadExists?.(selector.deviceId, target.id) || !this.onCardSwitchThread)
|
|
1690
|
-
return error('This thread is no longer available.');
|
|
1691
|
-
await this.onCardSwitchThread(openId, target.id, target.name);
|
|
1692
|
-
switched = target.name;
|
|
1693
|
-
await this.patchThreadSelector(cardId, state, false, target.id);
|
|
1694
|
-
return { toast: { type: 'success', content: `Input target: ${target.name}` } };
|
|
1695
|
-
}
|
|
1696
|
-
catch {
|
|
1697
|
-
return error(switched ? `Input target changed to ${switched}, but the card could not refresh. Try Hide threads again.` : 'Thread action failed. Please try again.');
|
|
1698
|
-
}
|
|
1699
|
-
});
|
|
1700
|
-
}
|
|
1701
1598
|
threadButtonLabel(thread, active) {
|
|
1702
1599
|
const details = [
|
|
1703
1600
|
thread.workspaceName,
|
|
@@ -1793,17 +1690,13 @@ Examples:
|
|
|
1793
1690
|
* Re-patches the card with updated button states (new active thread highlighted).
|
|
1794
1691
|
*/
|
|
1795
1692
|
async refreshThreadSwitchButtons(cardMessageId, newActiveThreadId) {
|
|
1796
|
-
const rootId = this.
|
|
1693
|
+
const rootId = this.workerContexts?.rootFor(cardMessageId) ?? cardMessageId;
|
|
1797
1694
|
await this.withMessageLock(rootId, async () => {
|
|
1798
1695
|
const state = this.threadSwitchCardState.get(cardMessageId);
|
|
1799
1696
|
if (!state) {
|
|
1800
1697
|
console.warn(`[FeishuHandler] No thread switch state found for card ${cardMessageId}`);
|
|
1801
1698
|
return;
|
|
1802
1699
|
}
|
|
1803
|
-
if (state.selector) {
|
|
1804
|
-
await this.patchThreadSelector(cardMessageId, state, false, newActiveThreadId);
|
|
1805
|
-
return;
|
|
1806
|
-
}
|
|
1807
1700
|
const updatedElements = [
|
|
1808
1701
|
...state.baseElements,
|
|
1809
1702
|
...this.createThreadSwitchElements(state.threads, newActiveThreadId, state.replyLabel),
|
|
@@ -1823,8 +1716,6 @@ Examples:
|
|
|
1823
1716
|
if (!content)
|
|
1824
1717
|
return;
|
|
1825
1718
|
await this.sendCardRequest(content, async (body) => {
|
|
1826
|
-
if (this.threadSwitchCardState.get(cardId)?.selector)
|
|
1827
|
-
this.assertThreadSelectorBudget(body);
|
|
1828
1719
|
const result = await this.client.im.message.patch({ path: { message_id: cardId }, data: { content: body } });
|
|
1829
1720
|
if (!result?.code)
|
|
1830
1721
|
this.workerContexts?.remember(cardId, rootId, body);
|
|
@@ -1850,15 +1741,6 @@ Examples:
|
|
|
1850
1741
|
catch {
|
|
1851
1742
|
return;
|
|
1852
1743
|
}
|
|
1853
|
-
if (!parsed || typeof parsed !== 'object' || typeof parsed.action !== 'string')
|
|
1854
|
-
return;
|
|
1855
|
-
if (parsed.action === 'thread_selector')
|
|
1856
|
-
return this.handleThreadSelector(openId, data?.context?.open_message_id, parsed);
|
|
1857
|
-
// New cards must not fall through to the legacy unbound callback contract.
|
|
1858
|
-
if ((parsed.action === 'switch_thread' || parsed.action === 'new_thread')
|
|
1859
|
-
&& this.threadSwitchCardState.get(data?.context?.open_message_id)?.selector) {
|
|
1860
|
-
return { toast: { type: 'error', content: 'Use this card’s thread controls.' } };
|
|
1861
|
-
}
|
|
1862
1744
|
if (parsed.action === 'settings') {
|
|
1863
1745
|
const cardId = data?.context?.open_message_id;
|
|
1864
1746
|
if (typeof parsed.id !== 'string' || typeof cardId !== 'string' || !this.settingsCards) {
|
|
@@ -1908,25 +1790,6 @@ Examples:
|
|
|
1908
1790
|
return { toast: { type: 'error', content: error instanceof Error ? error.message : 'Approval failed.' } };
|
|
1909
1791
|
}
|
|
1910
1792
|
}
|
|
1911
|
-
// Legacy cards remain usable while their original state is present. A new Router
|
|
1912
|
-
// must not let expired/unknown cards bypass the bound selector via legacy actions.
|
|
1913
|
-
if ((parsed.action === 'switch_thread' || parsed.action === 'new_thread') && this.onCardThreadExists) {
|
|
1914
|
-
const cardId = data?.context?.open_message_id;
|
|
1915
|
-
const state = this.threadSwitchCardState.get(cardId);
|
|
1916
|
-
const route = typeof cardId === 'string' ? this.onResolveThread?.(cardId) : undefined;
|
|
1917
|
-
let device;
|
|
1918
|
-
try {
|
|
1919
|
-
device = await this.bindingManager.getActiveDevice(openId);
|
|
1920
|
-
}
|
|
1921
|
-
catch {
|
|
1922
|
-
return { toast: { type: 'error', content: 'Thread action failed. Please try again.' } };
|
|
1923
|
-
}
|
|
1924
|
-
if (!state || Date.now() - state.createdAt >= this.THREAD_SWITCH_STATE_TTL_MS || !route
|
|
1925
|
-
|| device?.deviceId !== route.deviceId || (parsed.action === 'switch_thread'
|
|
1926
|
-
&& (!state.threads.some(thread => thread.id === parsed.threadId) || !this.onCardThreadExists(route.deviceId, parsed.threadId)))) {
|
|
1927
|
-
return { toast: { type: 'error', content: 'This thread card is no longer available.' } };
|
|
1928
|
-
}
|
|
1929
|
-
}
|
|
1930
1793
|
if (parsed.action === 'switch_thread' && parsed.threadId) {
|
|
1931
1794
|
const openMessageId = data?.context?.open_message_id;
|
|
1932
1795
|
try {
|
|
@@ -2031,17 +1894,15 @@ Examples:
|
|
|
2031
1894
|
/** Leave a historical queue receipt after output moves to a new card. */
|
|
2032
1895
|
async markQueueCardStarted(cardMessageId) {
|
|
2033
1896
|
await this.queueCardDecisions.get(cardMessageId);
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
this.threadSwitchCardState.delete(cardMessageId);
|
|
2044
|
-
});
|
|
1897
|
+
await this.withMessageLock(cardMessageId, () => this.client.im.message.patch({
|
|
1898
|
+
path: { message_id: cardMessageId },
|
|
1899
|
+
data: {
|
|
1900
|
+
content: JSON.stringify({
|
|
1901
|
+
schema: '2.0',
|
|
1902
|
+
body: { elements: [{ tag: 'markdown', content: '▶️ **Queued task started**\n\nFollow progress in the new execution card at the bottom of the chat.' }] },
|
|
1903
|
+
}),
|
|
1904
|
+
},
|
|
1905
|
+
}));
|
|
2045
1906
|
}
|
|
2046
1907
|
removeExpiredQueueActionStates() {
|
|
2047
1908
|
const expiry = Date.now() - this.QUEUE_ACTION_STATE_TTL_MS;
|
|
@@ -2056,9 +1917,8 @@ Examples:
|
|
|
2056
1917
|
? '✅ **Added to queue**\n\nThis message has been accepted into the thread queue. Use /queue to check its status. If the queue is paused, use /queue continue to resume.'
|
|
2057
1918
|
: '❌ **Queue request cancelled**\n\nThis message was not added to the thread queue.';
|
|
2058
1919
|
try {
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
const result = await this.client.im.message.patch({
|
|
1920
|
+
await this.withMessageLock(cardMessageId, async () => {
|
|
1921
|
+
await this.client.im.message.patch({
|
|
2062
1922
|
path: { message_id: cardMessageId },
|
|
2063
1923
|
data: {
|
|
2064
1924
|
content: JSON.stringify({
|
|
@@ -2067,9 +1927,6 @@ Examples:
|
|
|
2067
1927
|
}),
|
|
2068
1928
|
},
|
|
2069
1929
|
});
|
|
2070
|
-
if (result?.code)
|
|
2071
|
-
throw result;
|
|
2072
|
-
this.threadSwitchCardState.delete(cardMessageId);
|
|
2073
1930
|
});
|
|
2074
1931
|
}
|
|
2075
1932
|
catch (error) {
|