@ynhcj/xiaoyi-channel 0.0.165-next → 0.0.166-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
|
@@ -6,6 +6,7 @@ import { setXYRuntime } from "./src/runtime.js";
|
|
|
6
6
|
import { markCronToolCall, clearCronToolCall, getSessionContext } from "./src/tools/session-manager.js";
|
|
7
7
|
import { configManager } from "./src/utils/config-manager.js";
|
|
8
8
|
import { setJobPushId } from "./src/utils/cron-push-map.js";
|
|
9
|
+
import { getAllPushIds } from "./src/utils/pushid-manager.js";
|
|
9
10
|
import { registerSelfEvolutionToolResultNudge } from "./src/self-evolution-tool-result-nudge.js";
|
|
10
11
|
import { createBeforePromptBuildHandler } from "./src/skill-retriever/hooks.js";
|
|
11
12
|
import { normalizeToolRetrieverConfig } from "./src/skill-retriever/config.js";
|
|
@@ -59,9 +60,9 @@ async function captureCronAddMapping(event, ctx) {
|
|
|
59
60
|
console.log(`[CRONMAP] skip: no sessionId (sessionKey=${ctx.sessionKey}, ctxFound=${!!sessionCtx})`);
|
|
60
61
|
return;
|
|
61
62
|
}
|
|
62
|
-
const pushId =
|
|
63
|
+
const pushId = await resolvePushId(sessionId);
|
|
63
64
|
if (!pushId) {
|
|
64
|
-
console.log(`[CRONMAP] skip:
|
|
65
|
+
console.log(`[CRONMAP] skip: no pushId available for sessionId=${sessionId} (no session match, no global, no file)`);
|
|
65
66
|
return;
|
|
66
67
|
}
|
|
67
68
|
console.log(`[CRONMAP] writing map: jobId=${jobId}, sessionId=${sessionId}, pushId=${pushId.substring(0, 16)}...`);
|
|
@@ -73,6 +74,27 @@ async function captureCronAddMapping(event, ctx) {
|
|
|
73
74
|
});
|
|
74
75
|
console.log(`[CRONMAP] map written OK`);
|
|
75
76
|
}
|
|
77
|
+
/** 回退链取 pushId:当前会话 → 全局兜底 → 本地文件首个(保底)。 */
|
|
78
|
+
async function resolvePushId(sessionId) {
|
|
79
|
+
// 1. 同会话
|
|
80
|
+
const session = configManager.getPushId(sessionId);
|
|
81
|
+
if (session)
|
|
82
|
+
return session;
|
|
83
|
+
// 2. 全局(任何会话注册过的)
|
|
84
|
+
const global = configManager.getPushId();
|
|
85
|
+
if (global)
|
|
86
|
+
return global;
|
|
87
|
+
// 3. 文件兜底
|
|
88
|
+
try {
|
|
89
|
+
const all = await getAllPushIds();
|
|
90
|
+
if (all.length > 0)
|
|
91
|
+
return all[0];
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
// ignore
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
76
98
|
/** 判断 exec 命令是否为 cron add(匹配 "openclaw cron add" 或裸 "cron add",排除 list/remove 等)。 */
|
|
77
99
|
function isExecCronAddCommand(command) {
|
|
78
100
|
if (typeof command !== "string")
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
* Specifically handles pushId which can be updated per-session.
|
|
4
4
|
*/
|
|
5
5
|
declare class ConfigManager {
|
|
6
|
-
private sessionPushIds;
|
|
7
|
-
private globalPushId;
|
|
6
|
+
private get sessionPushIds();
|
|
7
|
+
private get globalPushId();
|
|
8
|
+
private set globalPushId(value);
|
|
8
9
|
/**
|
|
9
10
|
* Update push ID for a specific session.
|
|
10
11
|
*/
|
|
@@ -1,12 +1,32 @@
|
|
|
1
1
|
// Dynamic configuration manager for runtime updates
|
|
2
|
+
//
|
|
3
|
+
// NOTE: xy_channel is loaded from multiple module resolution paths
|
|
4
|
+
// (plugin entry vs tool registration), which duplicates class instances.
|
|
5
|
+
// sessionPushIds and globalPushId must live on globalThis so all copies
|
|
6
|
+
// share the same Map — same reason activeSessions is on globalThis in
|
|
7
|
+
// session-manager.ts.
|
|
2
8
|
import { logger } from "./logger.js";
|
|
9
|
+
const _g = globalThis;
|
|
10
|
+
if (!_g.__xyConfigSessionPushIds) {
|
|
11
|
+
_g.__xyConfigSessionPushIds = new Map();
|
|
12
|
+
}
|
|
13
|
+
if (!_g.__xyConfigGlobalPushId) {
|
|
14
|
+
_g.__xyConfigGlobalPushId = null;
|
|
15
|
+
}
|
|
3
16
|
/**
|
|
4
17
|
* Manages dynamic configuration updates that can change at runtime.
|
|
5
18
|
* Specifically handles pushId which can be updated per-session.
|
|
6
19
|
*/
|
|
7
20
|
class ConfigManager {
|
|
8
|
-
sessionPushIds
|
|
9
|
-
|
|
21
|
+
get sessionPushIds() {
|
|
22
|
+
return _g.__xyConfigSessionPushIds;
|
|
23
|
+
}
|
|
24
|
+
get globalPushId() {
|
|
25
|
+
return _g.__xyConfigGlobalPushId;
|
|
26
|
+
}
|
|
27
|
+
set globalPushId(value) {
|
|
28
|
+
_g.__xyConfigGlobalPushId = value;
|
|
29
|
+
}
|
|
10
30
|
/**
|
|
11
31
|
* Update push ID for a specific session.
|
|
12
32
|
*/
|