@ynhcj/xiaoyi-channel 0.0.211-next β 0.0.212-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/bot.js +14 -0
- package/dist/src/provider.js +21 -0
- package/dist/src/steer-queue.js +2 -2
- package/package.json +1 -1
package/dist/src/bot.js
CHANGED
|
@@ -15,6 +15,7 @@ import { selfEvolutionManager } from "./utils/self-evolution-manager.js";
|
|
|
15
15
|
import { saveRuntimeInfo } from "./utils/runtime-manager.js";
|
|
16
16
|
import { toolCallNudgeManager } from "./utils/tool-call-nudge-manager.js";
|
|
17
17
|
import { setCsplSteerContext } from "./cspl/steer-context.js";
|
|
18
|
+
import { getSteerQueue } from "./steer-queue.js";
|
|
18
19
|
import { registerTaskId, decrementTaskIdRef, hasActiveTask, } from "./task-manager.js";
|
|
19
20
|
import { logger } from "./utils/logger.js";
|
|
20
21
|
/**
|
|
@@ -299,6 +300,19 @@ export async function handleXYMessage(params) {
|
|
|
299
300
|
textForAgent = `${textForAgent}${fileHint}`;
|
|
300
301
|
log.log(`[BOT] Steer: appended file paths to text`);
|
|
301
302
|
}
|
|
303
|
+
// π Provider-level steer injection: push steer text to the shared queue.
|
|
304
|
+
// provider.ts checks this queue on every model call (including tool-loop
|
|
305
|
+
// model calls in agent.continue()) and drains pending steer messages
|
|
306
|
+
// directly into context.messages before sending to the model.
|
|
307
|
+
// Key: parsed.sessionId (A2A conversationId) matches getCurrentSessionContext().sessionId.
|
|
308
|
+
if (isUpdate) {
|
|
309
|
+
const steerQueue = getSteerQueue();
|
|
310
|
+
const queueKey = parsed.sessionId;
|
|
311
|
+
const pending = steerQueue.get(queueKey) ?? [];
|
|
312
|
+
pending.push(textForAgent);
|
|
313
|
+
steerQueue.set(queueKey, pending);
|
|
314
|
+
log.log(`[BOT-STEER] Queued for provider injection, sessionId=${queueKey}, queueDepth=${pending.length}`);
|
|
315
|
+
}
|
|
302
316
|
// Resolve envelope format options (following feishu pattern)
|
|
303
317
|
const envelopeOptions = core.channel.reply.resolveEnvelopeFormatOptions(cfg);
|
|
304
318
|
// Build message body with speaker prefix (following feishu pattern)
|
package/dist/src/provider.js
CHANGED
|
@@ -11,6 +11,7 @@ import { createHash } from "crypto";
|
|
|
11
11
|
import { logger } from "./utils/logger.js";
|
|
12
12
|
import { getCurrentSessionContext, setCurrentCronJobId } from "./tools/session-manager.js";
|
|
13
13
|
import { selfEvolutionManager } from "./utils/self-evolution-manager.js";
|
|
14
|
+
import { getSteerQueue } from "./steer-queue.js";
|
|
14
15
|
// ββ Retry config ββββββββββββββββββββββββββββββββββββββββββββββ
|
|
15
16
|
const RETRY_DELAYS_MS = [10_000, 20_000, 40_000, 60_000, 60_000];
|
|
16
17
|
const MAX_RETRY_ATTEMPTS = 5;
|
|
@@ -592,6 +593,26 @@ export const xiaoyiProvider = {
|
|
|
592
593
|
}
|
|
593
594
|
// deviceType: prefer text-extracted value, ALS as fallback.
|
|
594
595
|
const sessionCtx = getCurrentSessionContext();
|
|
596
|
+
// π Provider-level steer injection: drain pending steer messages from the
|
|
597
|
+
// shared queue and inject them as user messages before each model call.
|
|
598
|
+
// This runs on EVERY model call including tool-loop model calls, so steer
|
|
599
|
+
// messages injected mid-turn take effect immediately (unlike the hook-based
|
|
600
|
+
// approach which only fires at turn boundaries).
|
|
601
|
+
if (sessionCtx?.sessionId && context.messages) {
|
|
602
|
+
const steerQueue = getSteerQueue();
|
|
603
|
+
const pending = steerQueue.get(sessionCtx.sessionId);
|
|
604
|
+
if (pending && pending.length > 0) {
|
|
605
|
+
steerQueue.delete(sessionCtx.sessionId); // drain before injection
|
|
606
|
+
const steerText = pending.splice(0).join("\n\n");
|
|
607
|
+
const steerMessage = {
|
|
608
|
+
role: "user",
|
|
609
|
+
content: [{ type: "text", text: `η¨ζ·θΏ½ε θ―ζ±οΌ${steerText}` }],
|
|
610
|
+
timestamp: Date.now(),
|
|
611
|
+
};
|
|
612
|
+
context.messages.push(steerMessage);
|
|
613
|
+
logger.log(`[PROVIDER-STEER] Injected steer into context.messages, sessionId=${sessionCtx.sessionId}, textLen=${steerText.length}, msgCount=${context.messages.length}`);
|
|
614
|
+
}
|
|
615
|
+
}
|
|
595
616
|
const deviceType = extractedDeviceType
|
|
596
617
|
?? sessionCtx?.deviceType;
|
|
597
618
|
// app_ver and sdk_api_version from session context (ALS)
|
package/dist/src/steer-queue.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// Shared steer injection queue β bot.ts writes,
|
|
2
|
-
// Uses globalThis to survive module deduplication
|
|
1
|
+
// Shared steer injection queue β bot.ts writes, provider.ts reads.
|
|
2
|
+
// Uses globalThis to survive module deduplication.
|
|
3
3
|
const _g = globalThis;
|
|
4
4
|
if (!_g.__xySteerInjectionQueue) {
|
|
5
5
|
_g.__xySteerInjectionQueue = new Map();
|