@yu_robotics/remote-cli-router 1.6.134 → 1.6.139
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 +53 -0
- package/dist/feishu/FeishuLongConnHandler.d.ts +3 -0
- package/dist/feishu/FeishuLongConnHandler.d.ts.map +1 -1
- package/dist/feishu/FeishuLongConnHandler.js +69 -31
- package/dist/feishu/FeishuLongConnHandler.js.map +1 -1
- package/dist/feishu/WorkerContextCards.d.ts +36 -0
- package/dist/feishu/WorkerContextCards.d.ts.map +1 -0
- package/dist/feishu/WorkerContextCards.js +199 -0
- package/dist/feishu/WorkerContextCards.js.map +1 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +38 -2
- package/dist/server.js.map +1 -1
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/ToolFormatter.d.ts +1 -0
- package/dist/utils/ToolFormatter.d.ts.map +1 -1
- package/dist/utils/ToolFormatter.js +7 -1
- package/dist/utils/ToolFormatter.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WorkerContextCards = void 0;
|
|
4
|
+
exports.workerContextControl = workerContextControl;
|
|
5
|
+
const crypto_1 = require("crypto");
|
|
6
|
+
const TTL = 24 * 60 * 60_000;
|
|
7
|
+
const MAX_ACTIONS = 500;
|
|
8
|
+
const MAX_CARD_BYTES = 8 * 1024 * 1024;
|
|
9
|
+
const PREFIX = 'wc_';
|
|
10
|
+
function workerContextControl(id) {
|
|
11
|
+
return { tag: 'column_set', element_id: `${PREFIX}${(0, crypto_1.createHash)('sha256').update(id).digest('hex').slice(0, 16)}`, flex_mode: 'none', columns: [
|
|
12
|
+
{ tag: 'column', width: 'weighted', weight: 1, elements: [
|
|
13
|
+
{ tag: 'button', text: { tag: 'plain_text', content: 'Clear context' }, type: 'default',
|
|
14
|
+
behaviors: [{ type: 'callback', value: { action: 'worker_context_clear', id } }] },
|
|
15
|
+
] },
|
|
16
|
+
] };
|
|
17
|
+
}
|
|
18
|
+
/** Ephemeral controls, bound to actual delivered cards; native reset epochs persist on the CLI. */
|
|
19
|
+
class WorkerContextCards {
|
|
20
|
+
transport;
|
|
21
|
+
actions = new Map();
|
|
22
|
+
cards = new Map();
|
|
23
|
+
cardBytes = 0;
|
|
24
|
+
constructor(transport) {
|
|
25
|
+
this.transport = transport;
|
|
26
|
+
}
|
|
27
|
+
register(target) {
|
|
28
|
+
this.prune();
|
|
29
|
+
if (!this.transport.available(target.deviceId))
|
|
30
|
+
return;
|
|
31
|
+
if (this.actions.size >= MAX_ACTIONS) {
|
|
32
|
+
const oldest = [...this.actions].find(([, action]) => action.status !== 'pending');
|
|
33
|
+
if (!oldest)
|
|
34
|
+
return;
|
|
35
|
+
clearTimeout(oldest[1].timer);
|
|
36
|
+
this.actions.delete(oldest[0]);
|
|
37
|
+
}
|
|
38
|
+
const id = (0, crypto_1.randomUUID)();
|
|
39
|
+
this.actions.set(id, { ...target, status: 'idle', createdAt: Date.now() });
|
|
40
|
+
return id;
|
|
41
|
+
}
|
|
42
|
+
visit(value, callback) {
|
|
43
|
+
if (!value || typeof value !== 'object')
|
|
44
|
+
return;
|
|
45
|
+
if (typeof value.element_id === 'string' && value.element_id.startsWith(PREFIX)) {
|
|
46
|
+
const action = value.columns?.[0]?.elements?.[0]?.behaviors?.[0]?.value;
|
|
47
|
+
if (action?.action === 'worker_context_clear' && typeof action.id === 'string')
|
|
48
|
+
callback(value, action.id);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
for (const child of Object.values(value)) {
|
|
52
|
+
if (Array.isArray(child))
|
|
53
|
+
for (const node of child)
|
|
54
|
+
this.visit(node, callback);
|
|
55
|
+
else if (child && typeof child === 'object')
|
|
56
|
+
this.visit(child, callback);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
decorate(content) {
|
|
60
|
+
if (!content.includes(PREFIX))
|
|
61
|
+
return content;
|
|
62
|
+
const card = JSON.parse(content);
|
|
63
|
+
this.visit(card, (node, id) => {
|
|
64
|
+
const action = this.actions.get(id);
|
|
65
|
+
const replacement = workerContextControl(id);
|
|
66
|
+
const elements = replacement.columns[0].elements;
|
|
67
|
+
const button = elements[0];
|
|
68
|
+
const status = action?.status;
|
|
69
|
+
button.text.content = !action ? 'Context control expired' : status === 'pending' ? 'Clearing context...'
|
|
70
|
+
: status === 'cleared' ? 'Context cleared' : status === 'failed' ? 'Retry clear context' : 'Clear context';
|
|
71
|
+
button.disabled = !action || status === 'pending' || status === 'cleared';
|
|
72
|
+
if (action?.error)
|
|
73
|
+
elements.push({ tag: 'markdown', text_size: 'notation', content: action.error });
|
|
74
|
+
Object.assign(node, replacement);
|
|
75
|
+
});
|
|
76
|
+
return JSON.stringify(card);
|
|
77
|
+
}
|
|
78
|
+
remember(cardId, rootId, content) {
|
|
79
|
+
this.prune();
|
|
80
|
+
this.forgetCard(cardId);
|
|
81
|
+
if (!content.includes(PREFIX))
|
|
82
|
+
return;
|
|
83
|
+
const ids = new Set();
|
|
84
|
+
this.visit(JSON.parse(content), (_node, id) => { if (this.actions.has(id))
|
|
85
|
+
ids.add(id); });
|
|
86
|
+
const bytes = Buffer.byteLength(content);
|
|
87
|
+
if (!ids.size || bytes > MAX_CARD_BYTES)
|
|
88
|
+
return;
|
|
89
|
+
this.cards.set(cardId, { rootId, content, ids, bytes, createdAt: Date.now() });
|
|
90
|
+
this.cardBytes += bytes;
|
|
91
|
+
while (this.cardBytes > MAX_CARD_BYTES || this.cards.size > MAX_ACTIONS)
|
|
92
|
+
this.forgetCard(this.cards.keys().next().value);
|
|
93
|
+
}
|
|
94
|
+
rootFor(cardId) { return this.cards.get(cardId)?.rootId; }
|
|
95
|
+
contentFor(cardId) {
|
|
96
|
+
this.prune();
|
|
97
|
+
const card = this.cards.get(cardId);
|
|
98
|
+
return card ? this.decorate(card.content) : undefined;
|
|
99
|
+
}
|
|
100
|
+
async click(openId, id, cardId) {
|
|
101
|
+
this.prune();
|
|
102
|
+
const action = this.actions.get(id);
|
|
103
|
+
if (!action || !this.cards.get(cardId)?.ids.has(id))
|
|
104
|
+
throw new Error('This Worker control has expired. Use a newer Worker card.');
|
|
105
|
+
if (action.openId !== openId || !(await this.transport.ownsDevice(openId, action.deviceId)))
|
|
106
|
+
throw new Error('This Worker belongs to another user.');
|
|
107
|
+
if (action.status === 'cleared') {
|
|
108
|
+
void this.refresh(id);
|
|
109
|
+
return 'Context already cleared. The next delegation starts fresh.';
|
|
110
|
+
}
|
|
111
|
+
if (action.status === 'pending')
|
|
112
|
+
return 'Clearing context. Waiting for the CLI.';
|
|
113
|
+
if (!this.transport.available(action.deviceId))
|
|
114
|
+
throw new Error('The original CLI is offline or does not support context clearing. Reconnect it first.');
|
|
115
|
+
const requestId = (0, crypto_1.randomUUID)();
|
|
116
|
+
action.status = 'pending';
|
|
117
|
+
action.error = undefined;
|
|
118
|
+
action.requestId = requestId;
|
|
119
|
+
action.timer = setTimeout(() => {
|
|
120
|
+
if (action.requestId !== requestId || action.status !== 'pending')
|
|
121
|
+
return;
|
|
122
|
+
action.status = 'failed';
|
|
123
|
+
action.error = 'CLI confirmation timed out. Retry when the device is connected.';
|
|
124
|
+
void this.refresh(id);
|
|
125
|
+
}, 15_000);
|
|
126
|
+
action.timer.unref?.();
|
|
127
|
+
// Do not hold a Feishu callback open while patching cards.
|
|
128
|
+
void this.refresh(id);
|
|
129
|
+
try {
|
|
130
|
+
if (!await this.transport.send(action.deviceId, { type: 'worker_context_reset', messageId: requestId,
|
|
131
|
+
threadId: action.threadId, laneId: action.laneId, generation: action.generation, timestamp: Date.now() })) {
|
|
132
|
+
throw new Error('offline');
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
if (action.status === 'pending') {
|
|
137
|
+
clearTimeout(action.timer);
|
|
138
|
+
action.status = 'failed';
|
|
139
|
+
action.error = 'Could not contact the original CLI. Reconnect it and retry.';
|
|
140
|
+
void this.refresh(id);
|
|
141
|
+
}
|
|
142
|
+
throw new Error('Could not contact the original CLI. Reconnect it and retry.');
|
|
143
|
+
}
|
|
144
|
+
return 'Clearing Worker context. Files and results will be kept.';
|
|
145
|
+
}
|
|
146
|
+
async resolve(deviceId, message) {
|
|
147
|
+
if (typeof message?.messageId !== 'string' || typeof message.success !== 'boolean')
|
|
148
|
+
return;
|
|
149
|
+
for (const [id, action] of this.actions) {
|
|
150
|
+
if (action.deviceId !== deviceId || action.requestId !== message.messageId || action.status === 'cleared')
|
|
151
|
+
continue;
|
|
152
|
+
clearTimeout(action.timer);
|
|
153
|
+
action.status = message.success ? 'cleared' : 'failed';
|
|
154
|
+
// Only display known protocol errors; arbitrary peer text must not become card Markdown.
|
|
155
|
+
const errors = [
|
|
156
|
+
'This Worker card has expired. Use the latest Worker card.',
|
|
157
|
+
'The Worker context has changed. Use the latest Worker card.',
|
|
158
|
+
'The Worker is active or its shutdown is unconfirmed. Wait before clearing context.',
|
|
159
|
+
];
|
|
160
|
+
action.error = message.success ? undefined : errors.includes(message.error) ? message.error
|
|
161
|
+
: 'Could not clear Worker context. Check the local CLI and retry.';
|
|
162
|
+
await this.refresh(id);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
async refresh(id) {
|
|
166
|
+
await Promise.all([...this.cards].filter(([, card]) => card.ids.has(id)).map(async ([cardId, card]) => {
|
|
167
|
+
try {
|
|
168
|
+
await this.transport.refresh(cardId, card.rootId);
|
|
169
|
+
}
|
|
170
|
+
catch { /* Retry decoration on the next card update or click. */ }
|
|
171
|
+
}));
|
|
172
|
+
}
|
|
173
|
+
forgetCard(id) {
|
|
174
|
+
const card = this.cards.get(id);
|
|
175
|
+
if (card)
|
|
176
|
+
this.cardBytes -= card.bytes;
|
|
177
|
+
this.cards.delete(id);
|
|
178
|
+
}
|
|
179
|
+
prune() {
|
|
180
|
+
const cutoff = Date.now() - TTL;
|
|
181
|
+
for (const [id, action] of this.actions)
|
|
182
|
+
if (action.createdAt < cutoff) {
|
|
183
|
+
clearTimeout(action.timer);
|
|
184
|
+
this.actions.delete(id);
|
|
185
|
+
}
|
|
186
|
+
for (const [id, card] of this.cards)
|
|
187
|
+
if (card.createdAt < cutoff)
|
|
188
|
+
this.forgetCard(id);
|
|
189
|
+
}
|
|
190
|
+
destroy() {
|
|
191
|
+
for (const action of this.actions.values())
|
|
192
|
+
clearTimeout(action.timer);
|
|
193
|
+
this.actions.clear();
|
|
194
|
+
this.cards.clear();
|
|
195
|
+
this.cardBytes = 0;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
exports.WorkerContextCards = WorkerContextCards;
|
|
199
|
+
//# sourceMappingURL=WorkerContextCards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WorkerContextCards.js","sourceRoot":"","sources":["../../src/feishu/WorkerContextCards.ts"],"names":[],"mappings":";;;AA8BA,oDAOC;AArCD,mCAAgD;AAyBhD,MAAM,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC;AAC7B,MAAM,WAAW,GAAG,GAAG,CAAC;AACxB,MAAM,cAAc,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AACvC,MAAM,MAAM,GAAG,KAAK,CAAC;AAErB,SAAgB,oBAAoB,CAAC,EAAU;IAC7C,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,UAAU,EAAE,GAAG,MAAM,GAAG,IAAA,mBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE;YAC5I,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,EAAE,QA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|
private bindingManager;
|
|
16
16
|
private approvalCards;
|
|
17
|
+
private readonly workerContextCards;
|
|
18
|
+
private readonly workerContextConnections;
|
|
17
19
|
private readonly maintenanceCards;
|
|
18
20
|
private readonly maintenanceConnections;
|
|
19
21
|
private cleanupInterval;
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAmDhD;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,GAAG,CAAM;IACjB,OAAO,CAAC,UAAU,CAA2B;IAC7C,OAAO,CAAC,GAAG,CAAgC;IAC3C,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,KAAK,CAAY;IACzB,OAAO,CAAC,qBAAqB,CAAwB;IACrD,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAqB;IACxD,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAoC;IAC7E,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAmB;IACpD,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAwE;IAC/G,OAAO,CAAC,eAAe,CAA+B;IAEtD,OAAO,CAAC,iBAAiB,CAA4C;IACrE,OAAO,CAAC,cAAc,CAAgE;IACtF,OAAO,CAAC,sBAAsB,CAAoC;IAClE,OAAO,CAAC,oBAAoB,CAA6B;IACzD,OAAO,CAAC,QAAQ,CAAC,4BAA4B,CAAkB;IAC/D,OAAO,CAAC,QAAQ,CAAC,gCAAgC,CAAa;I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AkB;IA+EhC;;;;;;;;OAQG;YACW,sBAAsB;IAuBpC;;OAEG;YACW,wBAAwB;IAiFtC;;;OAGG;IACH,OAAO,CAAC,6BAA6B;IAqCrC;;;OAGG;IACH,OAAO,CAAC,iCAAiC;IA6BzC;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAmE3B;;OAEG;IACH,QAAQ;;;;CAGT"}
|
package/dist/server.js
CHANGED
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.RouterServer = void 0;
|
|
7
7
|
const ApprovalCards_1 = require("./feishu/ApprovalCards");
|
|
8
|
+
const WorkerContextCards_1 = require("./feishu/WorkerContextCards");
|
|
8
9
|
const MaintenanceCards_1 = require("./maintenance/MaintenanceCards");
|
|
9
10
|
const NoticeReceipts_1 = require("./maintenance/NoticeReceipts");
|
|
10
11
|
const DeviceAuth_1 = require("./files/DeviceAuth");
|
|
@@ -43,6 +44,8 @@ class RouterServer {
|
|
|
43
44
|
connectionHub;
|
|
44
45
|
bindingManager;
|
|
45
46
|
approvalCards;
|
|
47
|
+
workerContextCards;
|
|
48
|
+
workerContextConnections = new Map();
|
|
46
49
|
maintenanceCards;
|
|
47
50
|
maintenanceConnections = new Map();
|
|
48
51
|
cleanupInterval = null;
|
|
@@ -125,6 +128,13 @@ class RouterServer {
|
|
|
125
128
|
},
|
|
126
129
|
});
|
|
127
130
|
this.feishuLongConnHandler.onApprovalAction = (openId, requestId, cardId, decision) => this.approvalCards.click(openId, requestId, cardId, decision);
|
|
131
|
+
this.workerContextCards = new WorkerContextCards_1.WorkerContextCards({
|
|
132
|
+
ownsDevice: async (openId, deviceId) => (await this.bindingManager.getDeviceBinding(deviceId))?.openId === openId,
|
|
133
|
+
available: deviceId => this.workerContextConnections.get(deviceId)?.() === true,
|
|
134
|
+
send: (deviceId, message) => this.connectionHub.sendToDevice(deviceId, message),
|
|
135
|
+
refresh: (cardId, rootId) => this.feishuLongConnHandler.refreshWorkerContextCard(cardId, rootId),
|
|
136
|
+
});
|
|
137
|
+
this.feishuLongConnHandler.workerContexts = this.workerContextCards;
|
|
128
138
|
this.maintenanceCards = new MaintenanceCards_1.MaintenanceCards(new NoticeReceipts_1.NoticeReceipts(path_1.default.join(path_1.default.dirname(config.getConfigPath() || path_1.default.join(os_1.default.homedir(), '.remote-cli-router', 'config.json')), 'notice-receipts.json')), {
|
|
129
139
|
owner: async (deviceId) => (await this.bindingManager.getDeviceBinding(deviceId))?.openId,
|
|
130
140
|
send: (deviceId, message) => this.connectionHub.sendToDevice(deviceId, message),
|
|
@@ -336,6 +346,7 @@ class RouterServer {
|
|
|
336
346
|
let approvalCardsEnabled = false;
|
|
337
347
|
let delegationProgressEnabled = false;
|
|
338
348
|
let delegationProgressTextEnabled = false;
|
|
349
|
+
let workerContextResetEnabled = false;
|
|
339
350
|
let streamingContextEnabled = false;
|
|
340
351
|
let updateNoticeEnabled = false;
|
|
341
352
|
let subscriptionInspectionEnabled = false;
|
|
@@ -383,6 +394,11 @@ class RouterServer {
|
|
|
383
394
|
await this.maintenanceCards.receiveReminder(message, deviceId, current);
|
|
384
395
|
return;
|
|
385
396
|
}
|
|
397
|
+
if (message.type === 'worker_context_reset_result') {
|
|
398
|
+
if (workerContextResetEnabled && deviceId)
|
|
399
|
+
await this.workerContextCards.resolve(deviceId, message);
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
386
402
|
if (message.type === 'approval_request' || message.type === 'approval_resolved') {
|
|
387
403
|
if (!approvalCardsEnabled || !deviceId)
|
|
388
404
|
return;
|
|
@@ -518,6 +534,11 @@ class RouterServer {
|
|
|
518
534
|
delegationProgressEnabled = message.data.capabilities?.delegationProgress === true;
|
|
519
535
|
delegationProgressTextEnabled = delegationProgressEnabled
|
|
520
536
|
&& message.data.capabilities?.delegationProgressText === true;
|
|
537
|
+
workerContextResetEnabled = delegationProgressEnabled && message.data.capabilities?.workerContextReset === true;
|
|
538
|
+
if (workerContextResetEnabled)
|
|
539
|
+
this.workerContextConnections.set(deviceId, () => ws.readyState === ws_1.WebSocket.OPEN && this.connectionHub.isCurrentConnection(requestedId, ws));
|
|
540
|
+
else
|
|
541
|
+
this.workerContextConnections.delete(deviceId);
|
|
521
542
|
// Send confirmation with version info for client-side version check
|
|
522
543
|
ws.send(JSON.stringify({
|
|
523
544
|
type: types_1.MessageType.BINDING_CONFIRM,
|
|
@@ -535,6 +556,7 @@ class RouterServer {
|
|
|
535
556
|
...(approvalCardsEnabled ? { approvalCards: true } : {}),
|
|
536
557
|
...(delegationProgressEnabled ? { delegationProgress: true } : {}),
|
|
537
558
|
...(delegationProgressTextEnabled ? { delegationProgressText: true } : {}),
|
|
559
|
+
...(workerContextResetEnabled ? { workerContextReset: true } : {}),
|
|
538
560
|
...(streamingContextEnabled ? { streamingContext: true } : {}),
|
|
539
561
|
} } : {}),
|
|
540
562
|
}
|
|
@@ -666,7 +688,7 @@ class RouterServer {
|
|
|
666
688
|
break;
|
|
667
689
|
case 'delegation_progress':
|
|
668
690
|
if (delegationProgressEnabled && message.delegationProgress) {
|
|
669
|
-
await this.handleDelegationProgress(message.messageId, message.openId, message.delegationProgress, delegationProgressTextEnabled);
|
|
691
|
+
await this.handleDelegationProgress(message.messageId, message.openId, message.delegationProgress, delegationProgressTextEnabled, workerContextResetEnabled ? deviceId ?? undefined : undefined);
|
|
670
692
|
}
|
|
671
693
|
break;
|
|
672
694
|
case 'redacted_thinking':
|
|
@@ -734,6 +756,7 @@ class RouterServer {
|
|
|
734
756
|
this.approvalCards.disconnect(deviceId);
|
|
735
757
|
this.maintenanceCards.disconnect(deviceId);
|
|
736
758
|
this.maintenanceConnections.delete(deviceId);
|
|
759
|
+
this.workerContextConnections.delete(deviceId);
|
|
737
760
|
this.cleanupStreamingSessionsForDevice(deviceId);
|
|
738
761
|
console.log('Device disconnected:', deviceId);
|
|
739
762
|
}
|
|
@@ -976,6 +999,11 @@ class RouterServer {
|
|
|
976
999
|
const startedAt = typeof raw.startedAt === 'number' && Number.isFinite(raw.startedAt) && raw.startedAt >= 0
|
|
977
1000
|
? raw.startedAt : undefined;
|
|
978
1001
|
const executionMetadata = (0, ExecutionMetadata_1.parseExecutionMetadata)(raw.executionMetadata);
|
|
1002
|
+
const reference = raw.workerContext;
|
|
1003
|
+
const workerContext = reference && typeof reference.laneId === 'string'
|
|
1004
|
+
&& /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(reference.laneId)
|
|
1005
|
+
&& Number.isSafeInteger(reference.generation) && reference.generation >= 0
|
|
1006
|
+
? { laneId: reference.laneId, generation: reference.generation } : undefined;
|
|
979
1007
|
return {
|
|
980
1008
|
taskId,
|
|
981
1009
|
backend,
|
|
@@ -988,6 +1016,7 @@ class RouterServer {
|
|
|
988
1016
|
error: this.boundedDelegationProgressText(raw.error, 4000),
|
|
989
1017
|
startedAt,
|
|
990
1018
|
...(executionMetadata?.backend === backend ? { executionMetadata } : {}),
|
|
1019
|
+
...(workerContext ? { workerContext } : {}),
|
|
991
1020
|
};
|
|
992
1021
|
}
|
|
993
1022
|
appendDelegationProgressEvent(state, label, isError = false, toolId) {
|
|
@@ -1058,7 +1087,7 @@ class RouterServer {
|
|
|
1058
1087
|
state.currentToolStartedAt = activeId ? state.toolStartedAt.get(activeId) : undefined;
|
|
1059
1088
|
}
|
|
1060
1089
|
/** Update one bounded, nested worker panel rather than flattening child tool cards. */
|
|
1061
|
-
async handleDelegationProgress(messageId, openId, value, allowText = false) {
|
|
1090
|
+
async handleDelegationProgress(messageId, openId, value, allowText = false, contextDeviceId) {
|
|
1062
1091
|
const progress = this.normalizeDelegationProgress(value, allowText);
|
|
1063
1092
|
if (!progress) {
|
|
1064
1093
|
console.log(`[RouterServer] Ignoring malformed delegation progress for ${messageId}`);
|
|
@@ -1102,6 +1131,11 @@ class RouterServer {
|
|
|
1102
1131
|
}
|
|
1103
1132
|
if (!state.objective && progress.objective)
|
|
1104
1133
|
state.objective = progress.objective;
|
|
1134
|
+
if (DELEGATION_PROGRESS_TERMINAL_PHASES.has(progress.phase) && progress.workerContext && contextDeviceId
|
|
1135
|
+
&& streamData.deviceId === contextDeviceId && streamData.openId === openId && streamData.threadId) {
|
|
1136
|
+
state.contextActionId = this.workerContextCards.register({ openId, deviceId: contextDeviceId,
|
|
1137
|
+
threadId: streamData.threadId, ...progress.workerContext });
|
|
1138
|
+
}
|
|
1105
1139
|
if (progress.executionMetadata)
|
|
1106
1140
|
state.executionMetadata = progress.executionMetadata;
|
|
1107
1141
|
if (progress.phase === 'waiting_input')
|
|
@@ -1633,6 +1667,8 @@ class RouterServer {
|
|
|
1633
1667
|
async stop() {
|
|
1634
1668
|
console.log('Stopping router server...');
|
|
1635
1669
|
this.approvalCards.destroy();
|
|
1670
|
+
this.workerContextCards.destroy();
|
|
1671
|
+
this.workerContextConnections.clear();
|
|
1636
1672
|
this.maintenanceCards.destroy();
|
|
1637
1673
|
this.maintenanceConnections.clear();
|
|
1638
1674
|
await this.fileTransfers.destroy();
|