@ynhcj/xiaoyi-channel 0.0.129-next → 0.0.130-next
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/src/monitor.js +4 -29
- package/package.json +1 -1
package/dist/src/monitor.js
CHANGED
|
@@ -29,27 +29,6 @@ function createSessionQueue() {
|
|
|
29
29
|
return next;
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
/**
|
|
33
|
-
* Per-session serial queue for steer messages only.
|
|
34
|
-
* Steer messages must run concurrently with the main query (which may block for
|
|
35
|
-
* minutes inside the Pi agent loop), but must be serialized among themselves to
|
|
36
|
-
* prevent concurrent dispatchReplyFromConfig calls that can drop mid-stream
|
|
37
|
-
* steer messages under race conditions.
|
|
38
|
-
*/
|
|
39
|
-
function createSteerQueue() {
|
|
40
|
-
const queues = new Map();
|
|
41
|
-
return (sessionId, task) => {
|
|
42
|
-
const prev = queues.get(sessionId) ?? Promise.resolve();
|
|
43
|
-
const next = prev.then(task, task);
|
|
44
|
-
queues.set(sessionId, next);
|
|
45
|
-
void next.finally(() => {
|
|
46
|
-
if (queues.get(sessionId) === next) {
|
|
47
|
-
queues.delete(sessionId);
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
return next;
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
32
|
/**
|
|
54
33
|
* Monitor XY channel WebSocket connections.
|
|
55
34
|
* Keeps the connection alive until abortSignal is triggered.
|
|
@@ -86,9 +65,6 @@ export async function monitorXYProvider(opts = {}) {
|
|
|
86
65
|
const activeMessages = new Set();
|
|
87
66
|
// Create session queue for ordered message processing
|
|
88
67
|
const enqueue = createSessionQueue();
|
|
89
|
-
// Steer-only serial queue: keeps steer messages concurrent with the main
|
|
90
|
-
// query but serialized among themselves to avoid race conditions.
|
|
91
|
-
const enqueueSteer = createSteerQueue();
|
|
92
68
|
// Global gate that serializes dispatch initialization across sessions.
|
|
93
69
|
// When a new session starts dispatching, it acquires this gate and holds it
|
|
94
70
|
// until agent setup (agentTools + wrapStreamFn) is complete, then releases it.
|
|
@@ -142,12 +118,11 @@ export async function monitorXYProvider(opts = {}) {
|
|
|
142
118
|
const steerMode = cfg.messages?.queue?.mode === "steer";
|
|
143
119
|
const hasActiveRun = hasActiveTask(parsed.sessionId);
|
|
144
120
|
if (steerMode && hasActiveRun) {
|
|
145
|
-
// Steer
|
|
146
|
-
|
|
147
|
-
logger.log(`[MONITOR-HANDLER] 🔄 STEER MODE: Enqueuing steer for messageKey=${messageKey}`);
|
|
121
|
+
// Steer模式且有活跃任务:不入队列,直接并发执行
|
|
122
|
+
logger.log(`[MONITOR-HANDLER] 🔄 STEER MODE: Executing concurrently for messageKey=${messageKey}`);
|
|
148
123
|
logger.log(`[MONITOR-HANDLER] - sessionId: ${parsed.sessionId}`);
|
|
149
|
-
void
|
|
150
|
-
logger.error(`XY gateway: steer
|
|
124
|
+
void task().catch((err) => {
|
|
125
|
+
logger.error(`XY gateway: concurrent steer task failed for ${messageKey}: ${String(err)}`);
|
|
151
126
|
activeMessages.delete(messageKey);
|
|
152
127
|
});
|
|
153
128
|
}
|