@ynhcj/xiaoyi-channel 0.0.220-next → 0.0.221-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
|
@@ -5,7 +5,7 @@ import { xyPlugin } from "./src/channel.js";
|
|
|
5
5
|
import registerSentinelHook from "./src/cspl/sentinel_hook.js";
|
|
6
6
|
import registerSkillScopeHook from "./src/cspl/skill_scope_hook.js";
|
|
7
7
|
import { setXYRuntime } from "./src/runtime.js";
|
|
8
|
-
import { markCronToolCall, clearCronToolCall, getCurrentSessionContext, setCronToolRunInfo, clearCronToolRunInfo } from "./src/tools/session-manager.js";
|
|
8
|
+
import { markCronToolCall, clearCronToolCall, getCurrentSessionContext, setCronToolRunInfo, clearCronToolRunInfo, isCronActive } from "./src/tools/session-manager.js";
|
|
9
9
|
import { configManager } from "./src/utils/config-manager.js";
|
|
10
10
|
import { setJobPushId } from "./src/utils/cron-push-map.js";
|
|
11
11
|
import { getAllPushIds } from "./src/utils/pushid-manager.js";
|
|
@@ -63,7 +63,9 @@ function registerSkillsDiagnosticHook(api) {
|
|
|
63
63
|
*/
|
|
64
64
|
function registerCronDetectionHook(api) {
|
|
65
65
|
api.on("before_tool_call", async (event, ctx) => {
|
|
66
|
-
|
|
66
|
+
// sessionKey 前缀依赖 openclaw 版本行为,不一定可靠;
|
|
67
|
+
// isCronActive() 由 provider.ts 根据消息内容 [cron:...] 设置,更可靠。
|
|
68
|
+
if ((ctx.sessionKey?.startsWith("cron:") || isCronActive()) && event.toolCallId) {
|
|
67
69
|
markCronToolCall(event.toolCallId);
|
|
68
70
|
// 存储 runId,供 call_device_tool 在 ALS 缺失时构造合成 SessionContext
|
|
69
71
|
if (event.runId) {
|
package/dist/src/bot.js
CHANGED
|
@@ -322,11 +322,10 @@ export async function handleXYMessage(params) {
|
|
|
322
322
|
});
|
|
323
323
|
if (queued) {
|
|
324
324
|
log.log(`[BOT-STEER] Direct steer succeeded — message injected into active run`);
|
|
325
|
-
// Steer message taskId
|
|
326
|
-
//
|
|
327
|
-
//
|
|
328
|
-
//
|
|
329
|
-
decrementTaskIdRef(parsed.sessionId, parsed.taskId);
|
|
325
|
+
// Steer message taskId stays in the binding so getActiveTaskId()
|
|
326
|
+
// resolves to the latest taskId for onPartialReply replies.
|
|
327
|
+
// Cleanup happens via the original dispatcher's onIdleComplete →
|
|
328
|
+
// decrementTaskIdRef(sessionId) which removes the entire binding.
|
|
330
329
|
return;
|
|
331
330
|
}
|
|
332
331
|
log.log(`[BOT-STEER] Direct steer failed (queued=false), falling through to dispatchReplyFromConfig`);
|
package/dist/src/provider.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// models.providers.xiaoyiprovider.models = [...]
|
|
10
10
|
import { createHash } from "crypto";
|
|
11
11
|
import { logger } from "./utils/logger.js";
|
|
12
|
-
import { getCurrentSessionContext, setCurrentCronJobId } from "./tools/session-manager.js";
|
|
12
|
+
import { getCurrentSessionContext, setCurrentCronJobId, markCronDetected } from "./tools/session-manager.js";
|
|
13
13
|
import { selfEvolutionManager } from "./utils/self-evolution-manager.js";
|
|
14
14
|
import { setCompactionConfig, setCompactionSessionSnapshot } from "./compaction-provider.js";
|
|
15
15
|
// ── Retry config ──────────────────────────────────────────────
|
|
@@ -560,6 +560,9 @@ export const xiaoyiProvider = {
|
|
|
560
560
|
// 4. UID-based fallback: sha256(uid).hex[:32]_timestamp
|
|
561
561
|
const isCron = isCronTriggered(context.messages);
|
|
562
562
|
if (isCron) {
|
|
563
|
+
// 通知 before_tool_call hook:当前请求是 cron 触发。
|
|
564
|
+
// 不依赖 openclaw 的 sessionKey 前缀(部分版本可能不设置)。
|
|
565
|
+
markCronDetected();
|
|
563
566
|
// fire 期 jobId 桥:把首条消息 `[cron:<jobId> ...]` 解析出的真实 jobId
|
|
564
567
|
// 绑定到本次 cron run 的合成 sessionId。sendCommand 凭同一 sessionId
|
|
565
568
|
// 反查 jobId → cron-push-map → 正确设备的 pushId(多设备路由)。
|
|
@@ -20,6 +20,10 @@ export interface SessionContext {
|
|
|
20
20
|
* Tools should use the push channel instead of WebSocket sendCommand. */
|
|
21
21
|
isCron?: boolean;
|
|
22
22
|
}
|
|
23
|
+
/** Mark that the current request is cron-triggered (called by provider). */
|
|
24
|
+
export declare function markCronDetected(): void;
|
|
25
|
+
/** Check whether a cron request was recently detected. */
|
|
26
|
+
export declare function isCronActive(ttlMs?: number): boolean;
|
|
23
27
|
/** Mark a toolCallId as originating from a cron trigger. */
|
|
24
28
|
export declare function markCronToolCall(toolCallId: string): void;
|
|
25
29
|
/** Check whether a toolCallId is from a cron trigger. */
|
|
@@ -14,6 +14,20 @@ import { AsyncLocalStorage } from "async_hooks";
|
|
|
14
14
|
import { logger } from "../utils/logger.js";
|
|
15
15
|
import { getCurrentTaskId, getCurrentMessageId } from "../task-manager.js";
|
|
16
16
|
const _g = globalThis;
|
|
17
|
+
// ── Cron request detection ──────────────────────────────────────────
|
|
18
|
+
// The provider detects cron from [cron:...] in message text and sets
|
|
19
|
+
// this timestamp. The before_tool_call hook checks it as a fallback
|
|
20
|
+
// when openclaw's sessionKey does not have the "cron:" prefix.
|
|
21
|
+
// Timestamp-based so it self-expires and requires no explicit cleanup.
|
|
22
|
+
let __xyCronDetectedTs = 0;
|
|
23
|
+
/** Mark that the current request is cron-triggered (called by provider). */
|
|
24
|
+
export function markCronDetected() {
|
|
25
|
+
__xyCronDetectedTs = Date.now();
|
|
26
|
+
}
|
|
27
|
+
/** Check whether a cron request was recently detected. */
|
|
28
|
+
export function isCronActive(ttlMs = 120_000) {
|
|
29
|
+
return Date.now() - __xyCronDetectedTs < ttlMs;
|
|
30
|
+
}
|
|
17
31
|
// ── Cron tool-call tracking ─────────────────────────────────────────
|
|
18
32
|
// Global Map keyed by toolCallId to track whether a specific tool call
|
|
19
33
|
// originated from a cron/scheduled task. Populated by the
|