@ynhcj/xiaoyi-channel 0.0.204-next → 0.0.205-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/index.js CHANGED
@@ -231,16 +231,27 @@ function registerFullHooks(api) {
231
231
  // message between splice and delete, it would be lost when delete removes
232
232
  // the (now-repopulated) entry. With delete-first, bot.ts always creates a
233
233
  // fresh entry for new messages.
234
+ let hookFireCount = 0;
234
235
  api.on("agent_turn_prepare", async (_event, ctx) => {
235
- const sessionKey = ctx.sessionKey;
236
- if (!sessionKey)
236
+ hookFireCount++;
237
+ // Use ctx.sessionId (A2A session UUID) as the queue lookup key.
238
+ // bot.ts writes with parsed.sessionId — both refer to the same A2A UUID.
239
+ const sessionId = ctx.sessionId;
240
+ if (!sessionId)
237
241
  return;
238
242
  const queue = getSteerQueue();
239
- const pending = queue.get(sessionKey);
243
+ const pending = queue.get(sessionId);
244
+ // Diagnostic: log every N-th hook fire and whenever queue has entries
245
+ const queueKeys = Array.from(queue.keys());
246
+ if (hookFireCount <= 3 || queueKeys.length > 0 || (pending && pending.length > 0)) {
247
+ console.log(`[STEER-HOOK-DIAG] fireCount=${hookFireCount} sessionId=${sessionId} ` +
248
+ `sessionKey=${ctx.sessionKey} queueKeys=${JSON.stringify(queueKeys)} pendingLen=${pending?.length ?? 0}`);
249
+ }
240
250
  if (!pending || pending.length === 0)
241
251
  return;
242
- queue.delete(sessionKey); // delete first to prevent race
252
+ queue.delete(sessionId); // delete first to prevent race
243
253
  const text = pending.splice(0).join("\n\n");
254
+ console.log(`[STEER-HOOK] Injecting steer: sessionId=${sessionId} textLen=${text.length}`);
244
255
  return { appendContext: `\n用户追加诉求:${text}` };
245
256
  });
246
257
  }
package/dist/src/bot.js CHANGED
@@ -357,10 +357,16 @@ export async function handleXYMessage(params) {
357
357
  // the model on the next turn without blocking.
358
358
  if (isUpdate) {
359
359
  const steerQueue = getSteerQueue();
360
- const pending = steerQueue.get(route.sessionKey) ?? [];
360
+ // Use parsed.sessionId (A2A session UUID) as the queue key instead of
361
+ // route.sessionKey. The agent_turn_prepare hook looks up by ctx.sessionId
362
+ // which is the same A2A session UUID stored in the OpenClaw session entry.
363
+ // Using sessionId avoids format mismatches between the channel's route-based
364
+ // sessionKey and the agent runner's sessionKey.
365
+ const queueKey = parsed.sessionId;
366
+ const pending = steerQueue.get(queueKey) ?? [];
361
367
  pending.push(textForAgent);
362
- steerQueue.set(route.sessionKey, pending);
363
- log.log(`[BOT] Steer bypass: queued for agent_turn_prepare hook, sessionKey=${route.sessionKey}, queueDepth=${pending.length}, skipReg=${skipReg}`);
368
+ steerQueue.set(queueKey, pending);
369
+ log.log(`[BOT] Steer bypass: queued for agent_turn_prepare hook, queueKey=${queueKey}, sessionKey=${route.sessionKey}, queueDepth=${pending.length}, skipReg=${skipReg}`);
364
370
  // Only decrement refCount when registerTaskId was called (non-skipReg).
365
371
  // skipReg callers (CSPL/self-evolution) don't increment refCount.
366
372
  if (!skipReg) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ynhcj/xiaoyi-channel",
3
- "version": "0.0.204-next",
3
+ "version": "0.0.205-next",
4
4
  "description": "OpenClaw Xiaoyi Channel plugin - Xiaoyi A2A protocol integration",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",