@ynhcj/xiaoyi-channel 0.0.114-next → 0.0.115-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.
|
@@ -99,7 +99,6 @@ async function downloadRemoteFile(url) {
|
|
|
99
99
|
*/
|
|
100
100
|
export function createSendFileToUserTool(ctx) {
|
|
101
101
|
const { config, sessionId, taskId, messageId } = ctx;
|
|
102
|
-
logger.log(`[SEND-FILE-TO-USER] 🏭 CREATE: sessionId=${sessionId} taskId=${taskId}`);
|
|
103
102
|
return {
|
|
104
103
|
name: "send_file_to_user",
|
|
105
104
|
label: "Send File to User",
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// Session manager for XY tool context
|
|
2
2
|
// Stores active session contexts that tools can access
|
|
3
3
|
import { AsyncLocalStorage } from "async_hooks";
|
|
4
|
-
import { logger } from "../utils/logger.js";
|
|
5
4
|
import { configManager } from "../utils/config-manager.js";
|
|
6
5
|
import { toolCallNudgeManager } from "../utils/tool-call-nudge-manager.js";
|
|
7
6
|
import { getCurrentTaskId, getCurrentMessageId } from "../task-manager.js";
|
|
@@ -103,7 +102,6 @@ export function getLatestSessionContext() {
|
|
|
103
102
|
* This ensures thread-safe context isolation for concurrent requests.
|
|
104
103
|
*/
|
|
105
104
|
export function runWithSessionContext(context, callback) {
|
|
106
|
-
logger.log(`[SESSION-MGR] 🔵 ALS SET: sessionId=${context.sessionId} taskId=${context.taskId}`);
|
|
107
105
|
return asyncLocalStorage.run(context, callback);
|
|
108
106
|
}
|
|
109
107
|
/**
|
|
@@ -122,9 +120,6 @@ export function getCurrentSessionContext(sessionKey) {
|
|
|
122
120
|
if (alsContext) {
|
|
123
121
|
return enrichWithLatestTaskInfo(alsContext);
|
|
124
122
|
}
|
|
125
|
-
// ALS not available — logging to understand when/why
|
|
126
|
-
const stack = new Error().stack?.split("\n").slice(2, 5).map(s => s.trim()).join(" | ");
|
|
127
|
-
logger.log(`[SESSION-MGR] ⚠️ ALS miss, falling back to Map (size=${activeSessions.size}), callers: ${stack}`);
|
|
128
123
|
// 2. Fallback: look up from global activeSessions Map
|
|
129
124
|
if (activeSessions.size === 0) {
|
|
130
125
|
return null;
|
|
@@ -137,7 +132,6 @@ export function getCurrentSessionContext(sessionKey) {
|
|
|
137
132
|
return enrichWithLatestTaskInfo(context);
|
|
138
133
|
}
|
|
139
134
|
// sessionKey provided but not found — don't fall back to heuristics
|
|
140
|
-
logger.log(`[SESSION-MGR] sessionKey "${sessionKey}" not found in activeSessions (size=${activeSessions.size})`);
|
|
141
135
|
return null;
|
|
142
136
|
}
|
|
143
137
|
// 2b. Single active session — return it directly (but check TTL)
|
|
@@ -146,7 +140,6 @@ export function getCurrentSessionContext(sessionKey) {
|
|
|
146
140
|
if (entry) {
|
|
147
141
|
// Check if session is stale
|
|
148
142
|
if (Date.now() - entry.createdAt > SESSION_TTL_MS) {
|
|
149
|
-
logger.log(`[SESSION-MGR] single session expired, createdAt=${entry.createdAt}, cleaning up`);
|
|
150
143
|
activeSessions.clear();
|
|
151
144
|
return null;
|
|
152
145
|
}
|
|
@@ -165,7 +158,6 @@ export function getCurrentSessionContext(sessionKey) {
|
|
|
165
158
|
if (lastKey) {
|
|
166
159
|
const lastEntry = activeSessions.get(lastKey);
|
|
167
160
|
if (lastEntry) {
|
|
168
|
-
logger.log(`[SESSION-MGR] 🎯 using lastRegistered session: ${lastKey}`);
|
|
169
161
|
const { refCount, createdAt, ...context } = lastEntry;
|
|
170
162
|
return enrichWithLatestTaskInfo(context);
|
|
171
163
|
}
|
|
@@ -193,7 +185,6 @@ export function cleanupAllSessions() {
|
|
|
193
185
|
toolCallNudgeManager.clearSession(key);
|
|
194
186
|
}
|
|
195
187
|
activeSessions.clear();
|
|
196
|
-
logger.log("[SESSION-MGR] all sessions cleaned up");
|
|
197
188
|
}
|
|
198
189
|
/**
|
|
199
190
|
* Clean up sessions that have exceeded TTL.
|
|
@@ -210,9 +201,6 @@ export function cleanupStaleSessions() {
|
|
|
210
201
|
cleaned++;
|
|
211
202
|
}
|
|
212
203
|
}
|
|
213
|
-
if (cleaned > 0) {
|
|
214
|
-
logger.log(`[SESSION-MGR] cleaned ${cleaned} stale session(s)`);
|
|
215
|
-
}
|
|
216
204
|
return cleaned;
|
|
217
205
|
}
|
|
218
206
|
/**
|
package/dist/src/utils/logger.js
CHANGED
|
@@ -50,8 +50,8 @@ cleanupTimer.unref?.();
|
|
|
50
50
|
let currentDate = getTodayDateStr();
|
|
51
51
|
const dest = pino.destination({ dest: getLogFilePath(currentDate), sync: false, mkdir: true });
|
|
52
52
|
const pinoLogger = pino({
|
|
53
|
-
name: "xiaoyi-channel",
|
|
54
53
|
level: "debug",
|
|
54
|
+
base: undefined,
|
|
55
55
|
timestamp: pino.stdTimeFunctions.isoTime,
|
|
56
56
|
formatters: {
|
|
57
57
|
level(label) {
|