@ynhcj/xiaoyi 2.4.2 → 2.4.3
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/dist/channel.js +44 -36
- package/package.json +1 -1
package/dist/channel.js
CHANGED
|
@@ -330,44 +330,52 @@ exports.xiaoyiPlugin = {
|
|
|
330
330
|
// Start 60-second timeout timer
|
|
331
331
|
const timeoutConfig = runtime.getTimeoutConfig();
|
|
332
332
|
console.log(`[TIMEOUT] Starting ${timeoutConfig.duration}ms timeout protection for session ${sessionId}`);
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
333
|
+
// Define recursive timeout handler
|
|
334
|
+
const createTimeoutHandler = () => {
|
|
335
|
+
return async () => {
|
|
336
|
+
const elapsed = Date.now() - startTime;
|
|
337
|
+
console.log("\n" + "=".repeat(60));
|
|
338
|
+
console.log(`[TIMEOUT] Timeout triggered for session ${sessionId}`);
|
|
339
|
+
console.log(` Elapsed: ${elapsed}ms`);
|
|
340
|
+
console.log(` Task ID: ${taskId}`);
|
|
341
|
+
console.log("=".repeat(60) + "\n");
|
|
342
|
+
const conn = runtime.getConnection();
|
|
343
|
+
if (conn) {
|
|
344
|
+
const timeoutResponse = {
|
|
345
|
+
sessionId: sessionId,
|
|
346
|
+
messageId: `timeout_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
|
|
347
|
+
timestamp: Date.now(),
|
|
348
|
+
agentId: resolvedAccount.config.agentId,
|
|
349
|
+
sender: {
|
|
350
|
+
id: resolvedAccount.config.agentId,
|
|
351
|
+
name: "OpenClaw Agent",
|
|
352
|
+
type: "agent",
|
|
353
|
+
},
|
|
354
|
+
content: {
|
|
355
|
+
type: "text",
|
|
356
|
+
text: timeoutConfig.message,
|
|
357
|
+
},
|
|
358
|
+
status: "success",
|
|
359
|
+
};
|
|
360
|
+
try {
|
|
361
|
+
// Send timeout message with isFinal=false (not final), append=false (replace)
|
|
362
|
+
await conn.sendResponse(timeoutResponse, taskId, sessionId, false, false);
|
|
363
|
+
console.log(`[TIMEOUT] Timeout message sent successfully to session ${sessionId}\n`);
|
|
364
|
+
// Restart the timeout timer - allow repeated timeout messages
|
|
365
|
+
console.log(`[TIMEOUT] Restarting timeout timer for session ${sessionId}...\n`);
|
|
366
|
+
runtime.setTimeoutForSession(sessionId, createTimeoutHandler());
|
|
367
|
+
}
|
|
368
|
+
catch (error) {
|
|
369
|
+
console.error(`[TIMEOUT] Failed to send timeout message:`, error);
|
|
370
|
+
}
|
|
362
371
|
}
|
|
363
|
-
|
|
364
|
-
console.error(`[TIMEOUT]
|
|
372
|
+
else {
|
|
373
|
+
console.error(`[TIMEOUT] Connection not available, cannot send timeout message\n`);
|
|
365
374
|
}
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
});
|
|
375
|
+
};
|
|
376
|
+
};
|
|
377
|
+
// Start initial timeout
|
|
378
|
+
runtime.setTimeoutForSession(sessionId, createTimeoutHandler());
|
|
371
379
|
// ==================== END TIMEOUT PROTECTION ====================
|
|
372
380
|
await pluginRuntime.channel.reply.dispatchReplyWithBufferedBlockDispatcher({
|
|
373
381
|
ctx: msgContext,
|