@ynhcj/xiaoyi-channel 0.0.205-next → 0.0.206-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.
Files changed (2) hide show
  1. package/dist/index.js +11 -19
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -13,6 +13,7 @@ import { normalizeToolRetrieverConfig } from "./src/skill-retriever/config.js";
13
13
  import { registerCLIHook } from "./src/tools/hmos-cli.js";
14
14
  import { writeSkillUsage } from "./src/utils/skills-logger.js";
15
15
  import { getSteerQueue } from "./src/steer-queue.js";
16
+ import { logger } from "./src/utils/logger.js";
16
17
  /**
17
18
  * Parse a file path string to detect if it refers to a SKILL.md file within
18
19
  * a skills directory. Returns the skill name (parent directory) if so.
@@ -223,35 +224,26 @@ function registerFullHooks(api) {
223
224
  // and injects them as appendContext on the next agent turn.
224
225
  // This bypasses dispatchReplyFromConfig's admitReplyTurn blocking.
225
226
  //
226
- // appendContext places the steer after the current prompt context (which
227
- // includes the original user query + tool results), so the model sees:
228
- // [original context]\n\n用户追加诉求:<steer text>
227
+ // Uses before_prompt_build (NOT agent_turn_prepare) because the global
228
+ // hook runner's hasHooks/runAgentTurnPrepare check can fail to detect
229
+ // hooks registered via api.on(). before_prompt_build is proven to work
230
+ // (already used by skill-retriever in the same registerFullHooks call).
229
231
  //
230
- // Key is deleted BEFORE splice to avoid a race: if bot.ts pushes a new
231
- // message between splice and delete, it would be lost when delete removes
232
- // the (now-repopulated) entry. With delete-first, bot.ts always creates a
233
- // fresh entry for new messages.
234
- let hookFireCount = 0;
235
- api.on("agent_turn_prepare", async (_event, ctx) => {
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.
232
+ // appendContext places the steer after the current prompt context, so the
233
+ // model sees: [original context]\n\n用户追加诉求:<steer text>
234
+ //
235
+ // Key is deleted BEFORE splice to avoid a race.
236
+ api.on("before_prompt_build", async (_event, ctx) => {
239
237
  const sessionId = ctx.sessionId;
240
238
  if (!sessionId)
241
239
  return;
242
240
  const queue = getSteerQueue();
243
241
  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
- }
250
242
  if (!pending || pending.length === 0)
251
243
  return;
252
244
  queue.delete(sessionId); // delete first to prevent race
253
245
  const text = pending.splice(0).join("\n\n");
254
- console.log(`[STEER-HOOK] Injecting steer: sessionId=${sessionId} textLen=${text.length}`);
246
+ logger.log(`[STEER-HOOK] Injecting steer: sessionId=${sessionId} textLen=${text.length}`);
255
247
  return { appendContext: `\n用户追加诉求:${text}` };
256
248
  });
257
249
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ynhcj/xiaoyi-channel",
3
- "version": "0.0.205-next",
3
+ "version": "0.0.206-next",
4
4
  "description": "OpenClaw Xiaoyi Channel plugin - Xiaoyi A2A protocol integration",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",