@ynhcj/xiaoyi 2.4.3 → 2.4.4
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 +5 -21
- package/dist/websocket.d.ts +5 -0
- package/dist/websocket.js +58 -0
- package/package.json +6 -1
package/dist/channel.js
CHANGED
|
@@ -341,36 +341,20 @@ exports.xiaoyiPlugin = {
|
|
|
341
341
|
console.log("=".repeat(60) + "\n");
|
|
342
342
|
const conn = runtime.getConnection();
|
|
343
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
344
|
try {
|
|
361
|
-
// Send
|
|
362
|
-
await conn.
|
|
363
|
-
console.log(`[TIMEOUT]
|
|
345
|
+
// Send status update instead of artifact-update to keep conversation active
|
|
346
|
+
await conn.sendStatusUpdate(taskId, sessionId, timeoutConfig.message);
|
|
347
|
+
console.log(`[TIMEOUT] Status update sent successfully to session ${sessionId}\n`);
|
|
364
348
|
// Restart the timeout timer - allow repeated timeout messages
|
|
365
349
|
console.log(`[TIMEOUT] Restarting timeout timer for session ${sessionId}...\n`);
|
|
366
350
|
runtime.setTimeoutForSession(sessionId, createTimeoutHandler());
|
|
367
351
|
}
|
|
368
352
|
catch (error) {
|
|
369
|
-
console.error(`[TIMEOUT] Failed to send
|
|
353
|
+
console.error(`[TIMEOUT] Failed to send status update:`, error);
|
|
370
354
|
}
|
|
371
355
|
}
|
|
372
356
|
else {
|
|
373
|
-
console.error(`[TIMEOUT] Connection not available, cannot send
|
|
357
|
+
console.error(`[TIMEOUT] Connection not available, cannot send status update\n`);
|
|
374
358
|
}
|
|
375
359
|
};
|
|
376
360
|
};
|
package/dist/websocket.d.ts
CHANGED
|
@@ -70,6 +70,11 @@ export declare class XiaoYiWebSocketManager extends EventEmitter {
|
|
|
70
70
|
* Send clear context response to specific server
|
|
71
71
|
*/
|
|
72
72
|
sendClearContextResponse(requestId: string, sessionId: string, success?: boolean, targetServer?: ServerId): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Send status update (for intermediate status messages, e.g., timeout warnings)
|
|
75
|
+
* This uses "status-update" event type which keeps the conversation active
|
|
76
|
+
*/
|
|
77
|
+
sendStatusUpdate(taskId: string, sessionId: string, message: string, targetServer?: ServerId): Promise<void>;
|
|
73
78
|
/**
|
|
74
79
|
* Send tasks cancel response to specific server
|
|
75
80
|
*/
|
package/dist/websocket.js
CHANGED
|
@@ -456,6 +456,64 @@ class XiaoYiWebSocketManager extends events_1.EventEmitter {
|
|
|
456
456
|
throw error;
|
|
457
457
|
}
|
|
458
458
|
}
|
|
459
|
+
/**
|
|
460
|
+
* Send status update (for intermediate status messages, e.g., timeout warnings)
|
|
461
|
+
* This uses "status-update" event type which keeps the conversation active
|
|
462
|
+
*/
|
|
463
|
+
async sendStatusUpdate(taskId, sessionId, message, targetServer) {
|
|
464
|
+
const serverId = targetServer || this.sessionServerMap.get(sessionId);
|
|
465
|
+
if (!serverId) {
|
|
466
|
+
console.error(`[STATUS] Unknown server for session ${sessionId}`);
|
|
467
|
+
throw new Error(`Cannot send status update: unknown session ${sessionId}`);
|
|
468
|
+
}
|
|
469
|
+
const ws = serverId === 'server1' ? this.ws1 : this.ws2;
|
|
470
|
+
if (!ws || ws.readyState !== ws_1.default.OPEN) {
|
|
471
|
+
console.error(`[STATUS] ${serverId} not connected`);
|
|
472
|
+
throw new Error(`${serverId} is not available`);
|
|
473
|
+
}
|
|
474
|
+
// Create unique ID for this status update
|
|
475
|
+
const messageId = `status_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
476
|
+
const jsonRpcResponse = {
|
|
477
|
+
jsonrpc: "2.0",
|
|
478
|
+
id: messageId,
|
|
479
|
+
result: {
|
|
480
|
+
taskId: taskId,
|
|
481
|
+
kind: "status-update",
|
|
482
|
+
final: false, // IMPORTANT: Not final, keeps conversation active
|
|
483
|
+
status: {
|
|
484
|
+
message: {
|
|
485
|
+
role: "agent",
|
|
486
|
+
parts: [
|
|
487
|
+
{
|
|
488
|
+
kind: "text",
|
|
489
|
+
text: message,
|
|
490
|
+
},
|
|
491
|
+
],
|
|
492
|
+
},
|
|
493
|
+
state: "working", // Indicates task is still being processed
|
|
494
|
+
},
|
|
495
|
+
},
|
|
496
|
+
};
|
|
497
|
+
const outboundMessage = {
|
|
498
|
+
msgType: "agent_response",
|
|
499
|
+
agentId: this.config.agentId,
|
|
500
|
+
sessionId: sessionId,
|
|
501
|
+
taskId: taskId,
|
|
502
|
+
msgDetail: JSON.stringify(jsonRpcResponse),
|
|
503
|
+
};
|
|
504
|
+
console.log(`[STATUS] Sending status update to ${serverId}:`);
|
|
505
|
+
console.log(` sessionId: ${sessionId}`);
|
|
506
|
+
console.log(` taskId: ${taskId}`);
|
|
507
|
+
console.log(` message: ${message}`);
|
|
508
|
+
console.log(` final: false, state: working\n`);
|
|
509
|
+
try {
|
|
510
|
+
ws.send(JSON.stringify(outboundMessage));
|
|
511
|
+
}
|
|
512
|
+
catch (error) {
|
|
513
|
+
console.error(`[STATUS] Failed to send to ${serverId}:`, error);
|
|
514
|
+
throw error;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
459
517
|
/**
|
|
460
518
|
* Send tasks cancel response to specific server
|
|
461
519
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ynhcj/xiaoyi",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.4",
|
|
4
4
|
"description": "XiaoYi channel plugin for OpenClaw",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -29,6 +29,11 @@
|
|
|
29
29
|
"blurb": "小艺 A2A 协议支持,通过 WebSocket 连接。",
|
|
30
30
|
"order": 80,
|
|
31
31
|
"aliases": ["xy"]
|
|
32
|
+
},
|
|
33
|
+
"install": {
|
|
34
|
+
"npmSpec": "@ynhcj/xiaoyi",
|
|
35
|
+
"localPath": ".",
|
|
36
|
+
"defaultChoice": "npm"
|
|
32
37
|
}
|
|
33
38
|
},
|
|
34
39
|
"peerDependencies": {
|