@ynhcj/xiaoyi-channel 0.0.170-beta → 0.0.170-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 +141 -1
- package/dist/src/bot.js +55 -28
- package/dist/src/channel.js +54 -64
- package/dist/src/client.d.ts +5 -0
- package/dist/src/client.js +10 -0
- package/dist/src/cron-command.d.ts +2 -0
- package/dist/src/cron-command.js +14 -8
- package/dist/src/cron-query-handler.js +45 -8
- package/dist/src/cspl/call_api.js +2 -2
- package/dist/src/cspl/sentinel_hook.js +2 -2
- package/dist/src/cspl/upload_file.js +2 -2
- package/dist/src/file-upload.d.ts +5 -0
- package/dist/src/file-upload.js +102 -0
- package/dist/src/formatter.d.ts +29 -0
- package/dist/src/formatter.js +106 -19
- package/dist/src/monitor.js +2 -9
- package/dist/src/parser.d.ts +1 -1
- package/dist/src/parser.js +9 -15
- package/dist/src/provider.js +67 -62
- package/dist/src/reply-dispatcher.js +57 -60
- package/dist/src/task-manager.d.ts +5 -6
- package/dist/src/task-manager.js +5 -9
- package/dist/src/tools/agent-as-skill-tool.d.ts +45 -2
- package/dist/src/tools/agent-as-skill-tool.js +149 -151
- package/dist/src/tools/calendar-tool.d.ts +24 -2
- package/dist/src/tools/calendar-tool.js +115 -117
- package/dist/src/tools/call-device-tool.d.ts +20 -6
- package/dist/src/tools/call-device-tool.js +116 -138
- package/dist/src/tools/call-phone-tool.d.ts +21 -2
- package/dist/src/tools/call-phone-tool.js +112 -114
- package/dist/src/tools/check-plugin-privilege-tool.d.ts +16 -2
- package/dist/src/tools/check-plugin-privilege-tool.js +141 -143
- package/dist/src/tools/create-alarm-tool.d.ts +39 -2
- package/dist/src/tools/create-alarm-tool.js +229 -231
- package/dist/src/tools/create-all-tools.js +2 -0
- package/dist/src/tools/delete-alarm-tool.d.ts +15 -2
- package/dist/src/tools/delete-alarm-tool.js +134 -136
- package/dist/src/tools/device-tool-map.d.ts +1 -1
- package/dist/src/tools/device-tool-map.js +8 -1
- package/dist/src/tools/discover-cross-devices-tool.d.ts +16 -2
- package/dist/src/tools/discover-cross-devices-tool.js +121 -124
- package/dist/src/tools/display-a2ui-card-tool.d.ts +27 -2
- package/dist/src/tools/display-a2ui-card-tool.js +65 -68
- package/dist/src/tools/get-alarm-tool-schema.d.ts +1 -2
- package/dist/src/tools/get-alarm-tool-schema.js +10 -16
- package/dist/src/tools/get-calendar-tool-schema.d.ts +1 -2
- package/dist/src/tools/get-calendar-tool-schema.js +8 -12
- package/dist/src/tools/get-collection-tool-schema.d.ts +1 -2
- package/dist/src/tools/get-collection-tool-schema.js +9 -11
- package/dist/src/tools/get-contact-tool-schema.d.ts +1 -2
- package/dist/src/tools/get-contact-tool-schema.js +10 -16
- package/dist/src/tools/get-device-file-tool-schema.d.ts +1 -2
- package/dist/src/tools/get-device-file-tool-schema.js +9 -13
- package/dist/src/tools/get-email-tool-schema.d.ts +1 -2
- package/dist/src/tools/get-email-tool-schema.js +8 -11
- package/dist/src/tools/get-note-tool-schema.d.ts +1 -2
- package/dist/src/tools/get-note-tool-schema.js +9 -14
- package/dist/src/tools/get-photo-tool-schema.d.ts +1 -2
- package/dist/src/tools/get-photo-tool-schema.js +9 -12
- package/dist/src/tools/image-reading-tool.d.ts +28 -2
- package/dist/src/tools/image-reading-tool.js +76 -76
- package/dist/src/tools/location-tool.d.ts +11 -2
- package/dist/src/tools/location-tool.js +93 -92
- package/dist/src/tools/login-token-tool.d.ts +20 -2
- package/dist/src/tools/login-token-tool.js +122 -125
- package/dist/src/tools/modify-alarm-tool.d.ts +47 -2
- package/dist/src/tools/modify-alarm-tool.js +252 -237
- package/dist/src/tools/modify-note-tool.d.ts +20 -2
- package/dist/src/tools/modify-note-tool.js +107 -109
- package/dist/src/tools/note-tool.d.ts +20 -2
- package/dist/src/tools/note-tool.js +106 -108
- package/dist/src/tools/query-app-message-tool.d.ts +28 -2
- package/dist/src/tools/query-app-message-tool.js +111 -113
- package/dist/src/tools/query-memory-data-tool.d.ts +28 -2
- package/dist/src/tools/query-memory-data-tool.js +112 -114
- package/dist/src/tools/query-todo-task-tool.d.ts +24 -2
- package/dist/src/tools/query-todo-task-tool.js +106 -108
- package/dist/src/tools/save-file-to-phone-tool.d.ts +24 -2
- package/dist/src/tools/save-file-to-phone-tool.js +130 -132
- package/dist/src/tools/save-media-to-gallery-tool.d.ts +24 -2
- package/dist/src/tools/save-media-to-gallery-tool.js +137 -139
- package/dist/src/tools/save-self-evolution-skill-tool.d.ts +54 -2
- package/dist/src/tools/save-self-evolution-skill-tool.js +194 -194
- package/dist/src/tools/search-alarm-tool.d.ts +34 -2
- package/dist/src/tools/search-alarm-tool.js +174 -176
- package/dist/src/tools/search-calendar-tool.d.ts +24 -2
- package/dist/src/tools/search-calendar-tool.js +148 -150
- package/dist/src/tools/search-contact-tool.d.ts +16 -2
- package/dist/src/tools/search-contact-tool.js +101 -103
- package/dist/src/tools/search-email-tool.d.ts +21 -2
- package/dist/src/tools/search-email-tool.js +110 -112
- package/dist/src/tools/search-file-tool.d.ts +16 -2
- package/dist/src/tools/search-file-tool.js +104 -106
- package/dist/src/tools/search-message-tool.d.ts +16 -2
- package/dist/src/tools/search-message-tool.js +103 -105
- package/dist/src/tools/search-note-tool.d.ts +16 -2
- package/dist/src/tools/search-note-tool.js +98 -100
- package/dist/src/tools/search-photo-gallery-tool.d.ts +21 -2
- package/dist/src/tools/search-photo-gallery-tool.js +35 -37
- package/dist/src/tools/send-cross-device-task-tool.d.ts +35 -2
- package/dist/src/tools/send-cross-device-task-tool.js +214 -150
- package/dist/src/tools/send-email-tool.d.ts +24 -2
- package/dist/src/tools/send-email-tool.js +108 -110
- package/dist/src/tools/send-file-to-user-tool.d.ts +20 -2
- package/dist/src/tools/send-file-to-user-tool.js +172 -178
- package/dist/src/tools/send-html-card-tool.d.ts +25 -0
- package/dist/src/tools/send-html-card-tool.js +111 -0
- package/dist/src/tools/send-message-tool.d.ts +20 -2
- package/dist/src/tools/send-message-tool.js +122 -124
- package/dist/src/tools/session-manager.d.ts +16 -53
- package/dist/src/tools/session-manager.js +95 -239
- package/dist/src/tools/upload-file-tool.d.ts +20 -2
- package/dist/src/tools/upload-file-tool.js +80 -82
- package/dist/src/tools/upload-photo-tool.d.ts +20 -2
- package/dist/src/tools/upload-photo-tool.js +68 -70
- package/dist/src/tools/xiaoyi-add-collection-tool.d.ts +32 -2
- package/dist/src/tools/xiaoyi-add-collection-tool.js +146 -148
- package/dist/src/tools/xiaoyi-collection-tool.d.ts +20 -2
- package/dist/src/tools/xiaoyi-collection-tool.js +114 -116
- package/dist/src/tools/xiaoyi-delete-collection-tool.d.ts +15 -2
- package/dist/src/tools/xiaoyi-delete-collection-tool.js +127 -129
- package/dist/src/tools/xiaoyi-gui-tool.d.ts +16 -2
- package/dist/src/tools/xiaoyi-gui-tool.js +92 -95
- package/dist/src/types.d.ts +6 -6
- package/dist/src/utils/config-manager.d.ts +3 -2
- package/dist/src/utils/config-manager.js +22 -2
- package/dist/src/utils/cron-push-map.d.ts +26 -0
- package/dist/src/utils/cron-push-map.js +131 -0
- package/dist/src/utils/logger.js +3 -14
- package/dist/src/websocket.d.ts +1 -1
- package/dist/src/websocket.js +11 -13
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ import { callApi } from './call_api.js';
|
|
|
6
6
|
import { processText, extractResultText, validateAndTruncateText, parseSecurityResult, handleExecToolInput, handleMessageToolInput, handleOtherToolInput } from './utils.js';
|
|
7
7
|
import { ALLOWED_TOOLS, MAX_TEXT_LENGTH, MAX_TOTAL_LENGTH, MIN_TEXT_LENGTH, STEER_ABORT_MESSAGE, TOOL_OUTPUT_ACTION } from './constants.js';
|
|
8
8
|
import { logger } from '../utils/logger.js';
|
|
9
|
-
import {
|
|
9
|
+
import { getCurrentSessionContext } from '../tools/session-manager.js';
|
|
10
10
|
import { tryInjectSteer } from './steer-context.js';
|
|
11
11
|
// 主入口模块
|
|
12
12
|
export default function register(api) {
|
|
@@ -78,7 +78,7 @@ export default function register(api) {
|
|
|
78
78
|
logger.log(`[SENTINEL HOOK] TOOL_OUTPUT response: status=${result.status}.`);
|
|
79
79
|
if (result.status === 'REJECT') {
|
|
80
80
|
logger.warn('[SENTINEL HOOK] REJECT detected, attempting steer injection');
|
|
81
|
-
const sessionCtx =
|
|
81
|
+
const sessionCtx = getCurrentSessionContext();
|
|
82
82
|
if (sessionCtx?.sessionId && sessionCtx?.taskId) {
|
|
83
83
|
await tryInjectSteer({
|
|
84
84
|
sessionId: sessionCtx.sessionId,
|
|
@@ -6,7 +6,7 @@ import path from 'path';
|
|
|
6
6
|
import https from 'https';
|
|
7
7
|
import { URL } from 'url';
|
|
8
8
|
import { getConfig } from './config.js';
|
|
9
|
-
import {
|
|
9
|
+
import { DEFAULT_HTTPS_PORT, MAX_TIMES, CONNECT_TIMEOUT, READ_TIMEOUT, EXPIRE_TIME, OSMS_PREPARE_URL, OSMS_COMPLETE_URL, TEMPORARY_MATERIAL_PACKAGE, FILE_OWNER_UID, FILE_OWNER_TEAM_ID } from './constants.js';
|
|
10
10
|
function buildOsmsHeaders(config, traceId) {
|
|
11
11
|
return {
|
|
12
12
|
'content-type': 'application/json',
|
|
@@ -22,7 +22,7 @@ function httpRequest(url, method, headers, body, timeout) {
|
|
|
22
22
|
const urlObj = new URL(url);
|
|
23
23
|
const options = {
|
|
24
24
|
hostname: urlObj.hostname,
|
|
25
|
-
port: urlObj.port ||
|
|
25
|
+
port: urlObj.port || DEFAULT_HTTPS_PORT,
|
|
26
26
|
path: urlObj.pathname + urlObj.search,
|
|
27
27
|
method: method,
|
|
28
28
|
headers: headers,
|
|
@@ -17,6 +17,11 @@ export declare class XYFileUploadService {
|
|
|
17
17
|
* Uses completeAndQuery endpoint to get the file URL directly.
|
|
18
18
|
*/
|
|
19
19
|
uploadFileAndGetUrl(filePath: string, objectType?: string): Promise<string>;
|
|
20
|
+
/**
|
|
21
|
+
* Upload a file and return a preview-able URL (needPreview=true).
|
|
22
|
+
* Same as uploadFileAndGetUrl but adds needPreview flag to get a directly viewable URL.
|
|
23
|
+
*/
|
|
24
|
+
uploadFileAndGetPreviewUrl(filePath: string, objectType?: string): Promise<string>;
|
|
20
25
|
/**
|
|
21
26
|
* Upload multiple files and return their file IDs.
|
|
22
27
|
*/
|
package/dist/src/file-upload.js
CHANGED
|
@@ -235,6 +235,108 @@ export class XYFileUploadService {
|
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
|
+
/**
|
|
239
|
+
* Upload a file and return a preview-able URL (needPreview=true).
|
|
240
|
+
* Same as uploadFileAndGetUrl but adds needPreview flag to get a directly viewable URL.
|
|
241
|
+
*/
|
|
242
|
+
async uploadFileAndGetPreviewUrl(filePath, objectType = "TEMPORARY_MATERIAL_DOC") {
|
|
243
|
+
let localFilePath = filePath;
|
|
244
|
+
let isTempFile = false;
|
|
245
|
+
try {
|
|
246
|
+
// Handle remote URLs by downloading first
|
|
247
|
+
if (isRemoteUrl(filePath)) {
|
|
248
|
+
localFilePath = await downloadToTempFile(filePath);
|
|
249
|
+
isTempFile = true;
|
|
250
|
+
}
|
|
251
|
+
// Read file
|
|
252
|
+
const fileBuffer = await fs.readFile(localFilePath);
|
|
253
|
+
const fileName = path.basename(localFilePath);
|
|
254
|
+
const fileSha256 = calculateSHA256(fileBuffer);
|
|
255
|
+
const fileSize = fileBuffer.length;
|
|
256
|
+
// Phase 1: Prepare
|
|
257
|
+
logger.log(`[XY File Upload] Phase 1 (preview): Prepare upload for ${fileName}`);
|
|
258
|
+
const prepareResp = await fetch(`${this.baseUrl}/osms/v1/file/manager/prepare`, {
|
|
259
|
+
method: "POST",
|
|
260
|
+
headers: {
|
|
261
|
+
"Content-Type": "application/json",
|
|
262
|
+
"x-uid": this.uid,
|
|
263
|
+
"x-api-key": this.apiKey,
|
|
264
|
+
"x-request-from": "openclaw",
|
|
265
|
+
},
|
|
266
|
+
body: JSON.stringify({
|
|
267
|
+
objectType,
|
|
268
|
+
fileName,
|
|
269
|
+
fileSha256,
|
|
270
|
+
fileSize,
|
|
271
|
+
fileOwnerInfo: {
|
|
272
|
+
uid: this.uid,
|
|
273
|
+
teamId: this.uid,
|
|
274
|
+
},
|
|
275
|
+
useEdge: false,
|
|
276
|
+
}),
|
|
277
|
+
});
|
|
278
|
+
if (!prepareResp.ok) {
|
|
279
|
+
throw new Error(`Prepare failed: HTTP ${prepareResp.status}`);
|
|
280
|
+
}
|
|
281
|
+
const prepareData = await prepareResp.json();
|
|
282
|
+
if (prepareData.code !== "0") {
|
|
283
|
+
throw new Error(`Prepare failed: ${prepareData.desc}`);
|
|
284
|
+
}
|
|
285
|
+
const { objectId, draftId, uploadInfos } = prepareData;
|
|
286
|
+
logger.log(`[XY File Upload] Prepare (preview) complete: objectId=${objectId}, draftId=${draftId}`);
|
|
287
|
+
// Phase 2: Upload
|
|
288
|
+
logger.log(`[XY File Upload] Phase 2 (preview): Upload file data`);
|
|
289
|
+
const uploadInfo = uploadInfos[0];
|
|
290
|
+
const uploadResp = await fetch(uploadInfo.url, {
|
|
291
|
+
method: uploadInfo.method,
|
|
292
|
+
headers: uploadInfo.headers,
|
|
293
|
+
body: fileBuffer,
|
|
294
|
+
});
|
|
295
|
+
if (!uploadResp.ok) {
|
|
296
|
+
throw new Error(`Upload failed: HTTP ${uploadResp.status}`);
|
|
297
|
+
}
|
|
298
|
+
logger.log(`[XY File Upload] Upload (preview) complete`);
|
|
299
|
+
// Phase 3: CompleteAndQuery with needPreview=true
|
|
300
|
+
logger.log(`[XY File Upload] Phase 3 (preview): CompleteAndQuery with needPreview=true`);
|
|
301
|
+
const completeResp = await fetch(`${this.baseUrl}/osms/v1/file/manager/completeAndQuery`, {
|
|
302
|
+
method: "POST",
|
|
303
|
+
headers: {
|
|
304
|
+
"Content-Type": "application/json",
|
|
305
|
+
"x-uid": this.uid,
|
|
306
|
+
"x-api-key": this.apiKey,
|
|
307
|
+
"x-request-from": "openclaw",
|
|
308
|
+
},
|
|
309
|
+
body: JSON.stringify({
|
|
310
|
+
objectId,
|
|
311
|
+
draftId,
|
|
312
|
+
needPreview: true,
|
|
313
|
+
expireTime: 259200,
|
|
314
|
+
}),
|
|
315
|
+
});
|
|
316
|
+
if (!completeResp.ok) {
|
|
317
|
+
throw new Error(`CompleteAndQuery (preview) failed: HTTP ${completeResp.status}`);
|
|
318
|
+
}
|
|
319
|
+
const completeData = await completeResp.json();
|
|
320
|
+
const fileUrl = completeData?.fileDetailInfo?.url || "";
|
|
321
|
+
if (!fileUrl) {
|
|
322
|
+
throw new Error("No file URL returned from completeAndQuery (preview)");
|
|
323
|
+
}
|
|
324
|
+
logger.log(`[XY File Upload] File upload with preview URL successful`);
|
|
325
|
+
return fileUrl;
|
|
326
|
+
}
|
|
327
|
+
catch (error) {
|
|
328
|
+
logger.error(`[XY File Upload] File upload with preview URL failed for ${filePath}:`, error);
|
|
329
|
+
throw error;
|
|
330
|
+
}
|
|
331
|
+
finally {
|
|
332
|
+
if (isTempFile) {
|
|
333
|
+
try {
|
|
334
|
+
await fs.unlink(localFilePath);
|
|
335
|
+
}
|
|
336
|
+
catch { }
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
238
340
|
/**
|
|
239
341
|
* Upload multiple files and return their file IDs.
|
|
240
342
|
*/
|
package/dist/src/formatter.d.ts
CHANGED
|
@@ -82,6 +82,35 @@ export interface SendCommandParams {
|
|
|
82
82
|
* listening in the calling tool works unchanged.
|
|
83
83
|
*/
|
|
84
84
|
export declare function sendCommand(params: SendCommandParams): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Parameters for sending a card (e.g., HTML H5 card).
|
|
87
|
+
*/
|
|
88
|
+
export interface SendCardParams {
|
|
89
|
+
config: XYChannelConfig;
|
|
90
|
+
sessionId: string;
|
|
91
|
+
taskId: string;
|
|
92
|
+
messageId: string;
|
|
93
|
+
/** toolCallId from the tool's execute() — used for cron detection via hook-set Map. */
|
|
94
|
+
toolCallId?: string;
|
|
95
|
+
/** When true, the artifact-update is sent with final=true. Default: false. */
|
|
96
|
+
final?: boolean;
|
|
97
|
+
/** Array of card data objects to send. */
|
|
98
|
+
cardsInfo: CardDataObject[];
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Card data object for sending display cards.
|
|
102
|
+
*/
|
|
103
|
+
export interface CardDataObject {
|
|
104
|
+
cardName: string;
|
|
105
|
+
cardData: Record<string, any>;
|
|
106
|
+
displayType: string;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Send a card (e.g., HTML H5 card) as an artifact update (final=false).
|
|
110
|
+
*
|
|
111
|
+
* Cron-aware: same routing logic as sendCommand.
|
|
112
|
+
*/
|
|
113
|
+
export declare function sendCard(params: SendCardParams): Promise<void>;
|
|
85
114
|
/**
|
|
86
115
|
* Parameters for sending a clearContext response.
|
|
87
116
|
*/
|
package/dist/src/formatter.js
CHANGED
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
import { v4 as uuidv4 } from "uuid";
|
|
3
3
|
import { getXYWebSocketManager } from "./client.js";
|
|
4
4
|
import { logger } from "./utils/logger.js";
|
|
5
|
-
import { getCurrentTaskId, getCurrentMessageId } from "./task-manager.js";
|
|
6
5
|
import { redactSensitiveText, containsSensitiveInfo } from "./sensitive-redactor.js";
|
|
7
6
|
import { rewriteOutboundApprovalText } from "./approval-bridge.js";
|
|
8
|
-
import { isCronToolCall } from "./tools/session-manager.js";
|
|
7
|
+
import { isCronToolCall, getCurrentCronJobId } from "./tools/session-manager.js";
|
|
8
|
+
import { configManager } from "./utils/config-manager.js";
|
|
9
|
+
import { getPushIdByJobId } from "./utils/cron-push-map.js";
|
|
10
|
+
import { getAllPushIds } from "./utils/pushid-manager.js";
|
|
9
11
|
// ─────────────────────────────────────────────────────────────
|
|
10
12
|
// 敏感信息脱敏辅助函数
|
|
11
13
|
// ─────────────────────────────────────────────────────────────
|
|
@@ -155,11 +157,7 @@ export async function sendReasoningTextUpdate(params) {
|
|
|
155
157
|
*/
|
|
156
158
|
export async function sendStatusUpdate(params) {
|
|
157
159
|
const { config, sessionId, taskId, messageId, text, state } = params;
|
|
158
|
-
|
|
159
|
-
// fall back to closure-captured values
|
|
160
|
-
const currentTaskId = getCurrentTaskId(sessionId) ?? taskId;
|
|
161
|
-
const currentMessageId = getCurrentMessageId(sessionId) ?? messageId;
|
|
162
|
-
const log = logger.withContext(sessionId, currentTaskId);
|
|
160
|
+
const log = logger.withContext(sessionId, taskId);
|
|
163
161
|
// 审批桥接和脱敏
|
|
164
162
|
const bridgedText = rewriteOutboundApprovalText(sessionId, text);
|
|
165
163
|
const redactedText = redactSensitiveText(bridgedText);
|
|
@@ -174,7 +172,7 @@ export async function sendStatusUpdate(params) {
|
|
|
174
172
|
],
|
|
175
173
|
});
|
|
176
174
|
const statusUpdate = {
|
|
177
|
-
taskId
|
|
175
|
+
taskId,
|
|
178
176
|
kind: "status-update",
|
|
179
177
|
final: false, // Status updates should not end the stream
|
|
180
178
|
status: {
|
|
@@ -185,7 +183,7 @@ export async function sendStatusUpdate(params) {
|
|
|
185
183
|
// Build JSON-RPC response
|
|
186
184
|
const jsonRpcResponse = {
|
|
187
185
|
jsonrpc: "2.0",
|
|
188
|
-
id:
|
|
186
|
+
id: messageId,
|
|
189
187
|
result: statusUpdate,
|
|
190
188
|
};
|
|
191
189
|
// Send via WebSocket
|
|
@@ -194,13 +192,52 @@ export async function sendStatusUpdate(params) {
|
|
|
194
192
|
msgType: "agent_response",
|
|
195
193
|
agentId: config.agentId,
|
|
196
194
|
sessionId,
|
|
197
|
-
taskId
|
|
195
|
+
taskId,
|
|
198
196
|
msgDetail: JSON.stringify(jsonRpcResponse),
|
|
199
197
|
};
|
|
200
198
|
// Log complete response body
|
|
201
199
|
log.log(`[A2A_STATUS] Sending status-update, text="${redactedText}"`);
|
|
202
200
|
await wsManager.sendMessage(sessionId, outboundMessage);
|
|
203
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* 解析 cron fire 时应使用的 pushId(多设备路由)。
|
|
204
|
+
*
|
|
205
|
+
* 查询链(逐级回退):
|
|
206
|
+
* 1. 合成 sessionId → jobId → cron-push-map.json → 创建时记录的设备 pushId
|
|
207
|
+
* 2. configManager 同进程的 sessionId→pushId(进程未重启时兜底)
|
|
208
|
+
* 3. getAllPushIds()[0](单设备兼容旧行为)
|
|
209
|
+
* 返回 undefined 表示走兜底(由 sendCommandViaPush 内部处理)。
|
|
210
|
+
*/
|
|
211
|
+
async function resolveCronPushId(sessionId, config) {
|
|
212
|
+
// 1. jobId → 持久化映射
|
|
213
|
+
const jobId = getCurrentCronJobId(sessionId);
|
|
214
|
+
if (jobId) {
|
|
215
|
+
const hit = await getPushIdByJobId(jobId);
|
|
216
|
+
if (hit?.pushId) {
|
|
217
|
+
logger.log(`[CRON-PUSH] Resolved pushId via map, jobId=${jobId}`);
|
|
218
|
+
return hit.pushId;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
// 2. 同进程 configManager 兜底
|
|
222
|
+
const sessionPushId = configManager.getPushId(sessionId);
|
|
223
|
+
if (sessionPushId) {
|
|
224
|
+
logger.log(`[CRON-PUSH] Resolved pushId via configManager (fallback)`);
|
|
225
|
+
return sessionPushId;
|
|
226
|
+
}
|
|
227
|
+
// 3. config.pushId / getAllPushIds()[0] 交给 sendCommandViaPush 内部处理
|
|
228
|
+
void config;
|
|
229
|
+
try {
|
|
230
|
+
const all = await getAllPushIds();
|
|
231
|
+
if (all.length > 0) {
|
|
232
|
+
logger.log(`[CRON-PUSH] Resolved pushId via getAllPushIds[0] (legacy fallback)`);
|
|
233
|
+
return all[0];
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
catch (error) {
|
|
237
|
+
logger.error(`[CRON-PUSH] getAllPushIds failed:`, error);
|
|
238
|
+
}
|
|
239
|
+
return undefined;
|
|
240
|
+
}
|
|
204
241
|
/**
|
|
205
242
|
* Send a command as an artifact update (final=false).
|
|
206
243
|
*
|
|
@@ -222,18 +259,17 @@ export async function sendCommand(params) {
|
|
|
222
259
|
// (b) toolCallId marked by before_tool_call hook from openclaw's sessionKey.
|
|
223
260
|
if (sessionId.startsWith("cron-") || isCronToolCall(toolCallId)) {
|
|
224
261
|
const { sendCommandViaPush } = await import("./cron-command.js");
|
|
225
|
-
|
|
262
|
+
// 解析正确设备的 pushId:合成 sessionId → jobId → cron-push-map。
|
|
263
|
+
// provider.ts 在 isCron 分支已把 jobId 绑定到该 sessionId。
|
|
264
|
+
const pushId = await resolveCronPushId(sessionId, config);
|
|
265
|
+
return sendCommandViaPush({ config, command: commands[0], pushId });
|
|
226
266
|
}
|
|
227
267
|
// ── Normal mode: WebSocket ─────────────────────────────────────
|
|
228
|
-
|
|
229
|
-
// fall back to closure-captured values
|
|
230
|
-
const currentTaskId = getCurrentTaskId(sessionId) ?? taskId;
|
|
231
|
-
const currentMessageId = getCurrentMessageId(sessionId) ?? messageId;
|
|
232
|
-
const log = logger.withContext(sessionId, currentTaskId);
|
|
268
|
+
const log = logger.withContext(sessionId, taskId);
|
|
233
269
|
// Build artifact update with command as data
|
|
234
270
|
// Wrap command in commands array as per protocol requirement
|
|
235
271
|
const artifact = {
|
|
236
|
-
taskId
|
|
272
|
+
taskId,
|
|
237
273
|
kind: "artifact-update",
|
|
238
274
|
append: false,
|
|
239
275
|
lastChunk: true,
|
|
@@ -255,7 +291,7 @@ export async function sendCommand(params) {
|
|
|
255
291
|
// Build JSON-RPC response
|
|
256
292
|
const jsonRpcResponse = {
|
|
257
293
|
jsonrpc: "2.0",
|
|
258
|
-
id:
|
|
294
|
+
id: messageId,
|
|
259
295
|
result: artifact,
|
|
260
296
|
};
|
|
261
297
|
// Send via WebSocket
|
|
@@ -264,7 +300,7 @@ export async function sendCommand(params) {
|
|
|
264
300
|
msgType: "agent_response",
|
|
265
301
|
agentId: config.agentId,
|
|
266
302
|
sessionId,
|
|
267
|
-
taskId
|
|
303
|
+
taskId,
|
|
268
304
|
msgDetail: JSON.stringify(jsonRpcResponse),
|
|
269
305
|
};
|
|
270
306
|
// Log complete response body
|
|
@@ -272,6 +308,57 @@ export async function sendCommand(params) {
|
|
|
272
308
|
await wsManager.sendMessage(sessionId, outboundMessage);
|
|
273
309
|
log.log(`[A2A_COMMAND] Command sent successfully`);
|
|
274
310
|
}
|
|
311
|
+
/**
|
|
312
|
+
* Send a card (e.g., HTML H5 card) as an artifact update (final=false).
|
|
313
|
+
*
|
|
314
|
+
* Cron-aware: same routing logic as sendCommand.
|
|
315
|
+
*/
|
|
316
|
+
export async function sendCard(params) {
|
|
317
|
+
const { config, sessionId, taskId, messageId, toolCallId } = params;
|
|
318
|
+
// ── Cron mode: route through push channel ──────────────────────
|
|
319
|
+
if (sessionId.startsWith("cron-") || isCronToolCall(toolCallId)) {
|
|
320
|
+
throw new Error("sendCard does not support cron mode");
|
|
321
|
+
}
|
|
322
|
+
// ── Normal mode: WebSocket ─────────────────────────────────────
|
|
323
|
+
const log = logger.withContext(sessionId, taskId);
|
|
324
|
+
// Build artifact update with cardsInfo as data
|
|
325
|
+
const artifact = {
|
|
326
|
+
taskId,
|
|
327
|
+
kind: "artifact-update",
|
|
328
|
+
append: false,
|
|
329
|
+
lastChunk: true,
|
|
330
|
+
final: params.final ?? false,
|
|
331
|
+
artifact: {
|
|
332
|
+
artifactId: uuidv4(),
|
|
333
|
+
parts: [
|
|
334
|
+
{
|
|
335
|
+
kind: "data",
|
|
336
|
+
data: {
|
|
337
|
+
cardsInfo: params.cardsInfo,
|
|
338
|
+
},
|
|
339
|
+
},
|
|
340
|
+
],
|
|
341
|
+
},
|
|
342
|
+
};
|
|
343
|
+
// Build JSON-RPC response
|
|
344
|
+
const jsonRpcResponse = {
|
|
345
|
+
jsonrpc: "2.0",
|
|
346
|
+
id: messageId,
|
|
347
|
+
result: artifact,
|
|
348
|
+
};
|
|
349
|
+
// Send via WebSocket
|
|
350
|
+
const wsManager = getXYWebSocketManager(config);
|
|
351
|
+
const outboundMessage = {
|
|
352
|
+
msgType: "agent_response",
|
|
353
|
+
agentId: config.agentId,
|
|
354
|
+
sessionId,
|
|
355
|
+
taskId,
|
|
356
|
+
msgDetail: JSON.stringify(jsonRpcResponse),
|
|
357
|
+
};
|
|
358
|
+
log.log(`[A2A_CARD] Sending card`);
|
|
359
|
+
await wsManager.sendMessage(sessionId, outboundMessage);
|
|
360
|
+
log.log(`[A2A_CARD] Card sent successfully`);
|
|
361
|
+
}
|
|
275
362
|
/**
|
|
276
363
|
* Send a clearContext response.
|
|
277
364
|
*/
|
package/dist/src/monitor.js
CHANGED
|
@@ -9,7 +9,6 @@ import { handleSelfEvolutionEvent, handleSelfEvolutionStateGetEvent } from "./se
|
|
|
9
9
|
import { handleLoginTokenEvent } from "./login-token-handler.js";
|
|
10
10
|
import { handleCronQueryEvent } from "./cron-query-handler.js";
|
|
11
11
|
import { cleanupStaleTempFiles } from "./reply-dispatcher.js";
|
|
12
|
-
import { cleanupStaleSessions, getActiveSessionCount, cleanupAllSessions } from "./tools/session-manager.js";
|
|
13
12
|
import { logger } from "./utils/logger.js";
|
|
14
13
|
/**
|
|
15
14
|
* Per-session serial queue that ensures messages from the same session are processed
|
|
@@ -231,8 +230,7 @@ export async function monitorXYProvider(opts = {}) {
|
|
|
231
230
|
wsManager.disconnect();
|
|
232
231
|
// ✅ Remove manager from cache to prevent reusing dirty state
|
|
233
232
|
removeXYWebSocketManager(account);
|
|
234
|
-
//
|
|
235
|
-
cleanupAllSessions();
|
|
233
|
+
// Session context is ALS-scoped now — nothing global to clean up.
|
|
236
234
|
loggedServers.clear();
|
|
237
235
|
activeMessages.clear();
|
|
238
236
|
logger.log(`[MONITOR-HANDLER] Cleanup complete, cleared active messages and sessions`);
|
|
@@ -300,12 +298,7 @@ export async function monitorXYProvider(opts = {}) {
|
|
|
300
298
|
if (cleaned > 0) {
|
|
301
299
|
logger.log(`[HEALTH CHECK] Auto-cleaned ${cleaned} manager(s) with orphan connections`);
|
|
302
300
|
}
|
|
303
|
-
//
|
|
304
|
-
const cleanedSessions = cleanupStaleSessions();
|
|
305
|
-
const remainingSessions = getActiveSessionCount();
|
|
306
|
-
if (cleanedSessions > 0 || remainingSessions > 0) {
|
|
307
|
-
logger.log(`[HEALTH CHECK] Sessions: cleaned=${cleanedSessions}, active=${remainingSessions}`);
|
|
308
|
-
}
|
|
301
|
+
// Session context is ALS-scoped — no global session cleanup needed.
|
|
309
302
|
// Cleanup stale temp files (older than 24 hours)
|
|
310
303
|
void cleanupStaleTempFiles();
|
|
311
304
|
}, 6 * 60 * 60 * 1000); // 6 hours
|
package/dist/src/parser.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ export declare function extractPushId(parts: A2AMessagePart[]): string | null;
|
|
|
52
52
|
export declare function extractDeviceType(parts: A2AMessagePart[]): string | null;
|
|
53
53
|
/**
|
|
54
54
|
* Extract modelName from message parts.
|
|
55
|
-
* Looks for modelName in data parts under variables.
|
|
55
|
+
* Looks for modelName in data parts under variables.clientVariables.modelName
|
|
56
56
|
* (same level as systemVariables).
|
|
57
57
|
*/
|
|
58
58
|
export declare function extractModelName(parts: A2AMessagePart[]): string | null;
|
package/dist/src/parser.js
CHANGED
|
@@ -56,22 +56,16 @@ export function extractRunCrossTaskContext(parts) {
|
|
|
56
56
|
return null;
|
|
57
57
|
}
|
|
58
58
|
const candidate = item;
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
? candidate.fileRemoteUrls.filter((url) => typeof url === "string" && url.length > 0)
|
|
64
|
-
: [];
|
|
65
|
-
const fileNames = Array.isArray(candidate.fileNames)
|
|
66
|
-
? candidate.fileNames.filter((name) => typeof name === "string" && name.length > 0)
|
|
67
|
-
: [];
|
|
68
|
-
if (fileLocalUrls.length === 0 && fileRemoteUrls.length === 0) {
|
|
59
|
+
const fileName = typeof candidate.fileName === "string" ? candidate.fileName.trim() : "";
|
|
60
|
+
const fileId = typeof candidate.fileId === "string" ? candidate.fileId.trim() : "";
|
|
61
|
+
const mimeType = typeof candidate.mimeType === "string" ? candidate.mimeType.trim() : "";
|
|
62
|
+
if (!fileName || !fileId) {
|
|
69
63
|
return null;
|
|
70
64
|
}
|
|
71
65
|
return {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
...(
|
|
66
|
+
fileName,
|
|
67
|
+
fileId,
|
|
68
|
+
...(mimeType ? { mimeType } : {}),
|
|
75
69
|
};
|
|
76
70
|
})
|
|
77
71
|
.filter((item) => item !== null);
|
|
@@ -145,13 +139,13 @@ export function extractDeviceType(parts) {
|
|
|
145
139
|
}
|
|
146
140
|
/**
|
|
147
141
|
* Extract modelName from message parts.
|
|
148
|
-
* Looks for modelName in data parts under variables.
|
|
142
|
+
* Looks for modelName in data parts under variables.clientVariables.modelName
|
|
149
143
|
* (same level as systemVariables).
|
|
150
144
|
*/
|
|
151
145
|
export function extractModelName(parts) {
|
|
152
146
|
for (const part of parts) {
|
|
153
147
|
if (part.kind === "data" && part.data) {
|
|
154
|
-
const modelName = part.data.variables?.
|
|
148
|
+
const modelName = part.data.variables?.clientVariables?.modelName;
|
|
155
149
|
if (modelName && typeof modelName === "string" && modelName.trim() !== "" && modelName.toLowerCase() !== "none") {
|
|
156
150
|
return modelName;
|
|
157
151
|
}
|
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 } from "./tools/session-manager.js";
|
|
12
|
+
import { getCurrentSessionContext, setCurrentCronJobId } from "./tools/session-manager.js";
|
|
13
13
|
import { selfEvolutionManager } from "./utils/self-evolution-manager.js";
|
|
14
14
|
import { notifyModelStreaming } from "./bot.js";
|
|
15
15
|
// ── Retry config ──────────────────────────────────────────────
|
|
@@ -393,30 +393,43 @@ function trimUserMetadata(text) {
|
|
|
393
393
|
text = text.replace(/\n*Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n*/, "\n");
|
|
394
394
|
return text.replace(/\n{3,}/g, "\n\n");
|
|
395
395
|
}
|
|
396
|
-
/**
|
|
397
|
-
* Extract A2A taskId and deviceType from Conversation info JSON.
|
|
398
|
-
* bot.ts stores them as MessageSid = "xiaoyi_taskId_deviceType".
|
|
399
|
-
* The "xiaoyi_" prefix ensures extraction only happens for messages
|
|
400
|
-
* routed through xiaoyi-channel, not other channels sharing the provider.
|
|
401
|
-
*/
|
|
402
|
-
function extractA2AFromConversationInfo(text) {
|
|
403
|
-
const match = text.match(/Conversation info \(untrusted metadata\):\n```json\n([\s\S]*?)\n```/);
|
|
404
|
-
if (!match)
|
|
405
|
-
return null;
|
|
406
|
-
const msgIdMatch = match[1].match(/"message_id"\s*:\s*"([^"]+)"/);
|
|
407
|
-
if (!msgIdMatch)
|
|
408
|
-
return null;
|
|
409
|
-
const parts = msgIdMatch[1].split("_");
|
|
410
|
-
if (parts.length < 3 || parts[0] !== "xiaoyi")
|
|
411
|
-
return null;
|
|
412
|
-
return { taskId: parts[1], deviceType: parts[2] };
|
|
413
|
-
}
|
|
414
396
|
export const xiaoyiProvider = {
|
|
415
397
|
id: "xiaoyiprovider",
|
|
416
398
|
label: "Xiaoyi Provider",
|
|
417
399
|
docsPath: "/providers/models",
|
|
418
400
|
auth: [],
|
|
419
401
|
isCacheTtlEligible: () => true,
|
|
402
|
+
/**
|
|
403
|
+
* Dynamic model resolution for A2A-specified model names.
|
|
404
|
+
* A2A messages carry a dynamic modelName that isn't in any static catalog.
|
|
405
|
+
* This hook lets OpenClaw's resolveModelAsync accept any model ID under
|
|
406
|
+
* xiaoyiprovider as long as the provider has a configured baseUrl.
|
|
407
|
+
*/
|
|
408
|
+
resolveDynamicModel: (ctx) => {
|
|
409
|
+
// providerConfig from models.providers.xiaoyiprovider is preferred;
|
|
410
|
+
// fall back to zai baseUrl when config-driven provider setup is unavailable.
|
|
411
|
+
let baseUrl = ctx.providerConfig?.baseUrl;
|
|
412
|
+
if (!baseUrl || typeof baseUrl !== "string") {
|
|
413
|
+
baseUrl = ctx.config?.models?.providers?.zai?.baseUrl;
|
|
414
|
+
}
|
|
415
|
+
if (!baseUrl || typeof baseUrl !== "string")
|
|
416
|
+
return null;
|
|
417
|
+
return {
|
|
418
|
+
id: ctx.modelId,
|
|
419
|
+
name: ctx.modelId,
|
|
420
|
+
api: ctx.providerConfig?.api ?? "openai-completions",
|
|
421
|
+
provider: "xiaoyiprovider",
|
|
422
|
+
baseUrl,
|
|
423
|
+
reasoning: false,
|
|
424
|
+
input: ["text"],
|
|
425
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
426
|
+
contextWindow: 256_000,
|
|
427
|
+
maxTokens: 8192,
|
|
428
|
+
...(ctx.providerConfig?.headers && typeof ctx.providerConfig.headers === "object"
|
|
429
|
+
? { headers: ctx.providerConfig.headers }
|
|
430
|
+
: {}),
|
|
431
|
+
};
|
|
432
|
+
},
|
|
420
433
|
/**
|
|
421
434
|
* Store uid-based fallback prefix for lazy timestamp generation in wrapStreamFn.
|
|
422
435
|
* Session-level headers (traceId / sessionId / interactionId) are resolved
|
|
@@ -448,38 +461,21 @@ export const xiaoyiProvider = {
|
|
|
448
461
|
return underlying;
|
|
449
462
|
return async (model, context, options) => {
|
|
450
463
|
const dynamicHeaders = {};
|
|
451
|
-
// ── Extract A2A taskId/deviceType from Conversation info ──
|
|
452
|
-
// bot.ts stores taskId_deviceType as MessageSid, which the framework
|
|
453
|
-
// renders as message_id in the Conversation info JSON block.
|
|
454
|
-
let extractedTaskId = null;
|
|
455
|
-
let extractedDeviceType = null;
|
|
456
|
-
if (context.messages) {
|
|
457
|
-
for (let i = context.messages.length - 1; i >= 0; i--) {
|
|
458
|
-
const msg = context.messages[i];
|
|
459
|
-
if (msg.role !== "user")
|
|
460
|
-
continue;
|
|
461
|
-
const text = typeof msg.content === "string"
|
|
462
|
-
? msg.content
|
|
463
|
-
: Array.isArray(msg.content)
|
|
464
|
-
? msg.content.find((b) => b.type === "text")?.text ?? ""
|
|
465
|
-
: "";
|
|
466
|
-
if (!text)
|
|
467
|
-
continue;
|
|
468
|
-
const extracted = extractA2AFromConversationInfo(text);
|
|
469
|
-
if (extracted) {
|
|
470
|
-
extractedTaskId = extracted.taskId;
|
|
471
|
-
extractedDeviceType = extracted.deviceType;
|
|
472
|
-
break;
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
464
|
// ── Build dynamic headers ────────────────────────────
|
|
477
465
|
// Priority:
|
|
478
466
|
// 1. Cron-triggered: uid → cronUuid, with cron-specific headers
|
|
479
|
-
// 2. Xiaoyi A2A:
|
|
467
|
+
// 2. Xiaoyi A2A: rawTaskId from AsyncLocalStorage, split on "&"
|
|
480
468
|
// 3. UID-based fallback: sha256(uid).hex[:32]_timestamp
|
|
481
469
|
const isCron = isCronTriggered(context.messages);
|
|
482
470
|
if (isCron) {
|
|
471
|
+
// fire 期 jobId 桥:把首条消息 `[cron:<jobId> ...]` 解析出的真实 jobId
|
|
472
|
+
// 绑定到本次 cron run 的合成 sessionId。sendCommand 凭同一 sessionId
|
|
473
|
+
// 反查 jobId → cron-push-map → 正确设备的 pushId(多设备路由)。
|
|
474
|
+
const cronJobId = extractCronUuid(context.messages);
|
|
475
|
+
const cronCtx = getCurrentSessionContext();
|
|
476
|
+
if (cronJobId && cronCtx?.sessionId) {
|
|
477
|
+
setCurrentCronJobId(cronCtx.sessionId, cronJobId);
|
|
478
|
+
}
|
|
483
479
|
const fallbackPrefix = ctx.extraParams?.[FALLBACK_PREFIX_KEY];
|
|
484
480
|
if (typeof fallbackPrefix === "string") {
|
|
485
481
|
const fallbackValue = `${fallbackPrefix}_${Date.now()}`;
|
|
@@ -499,21 +495,32 @@ export const xiaoyiProvider = {
|
|
|
499
495
|
dynamicHeaders["x-cron-title"] = encodeURIComponent(cronTitle);
|
|
500
496
|
if (context.messages?.length === 1)
|
|
501
497
|
dynamicHeaders["x-cron-flag"] = "begin";
|
|
502
|
-
|
|
503
|
-
else if (extractedTaskId) {
|
|
504
|
-
const sessionId = extractedTaskId.split("&")[0];
|
|
505
|
-
const interactionId = extractedTaskId.split("&")[1] ?? "";
|
|
506
|
-
dynamicHeaders[HEADER_TRACE_ID] = extractedTaskId;
|
|
507
|
-
dynamicHeaders[HEADER_SESSION_ID] = sessionId;
|
|
508
|
-
dynamicHeaders[HEADER_INTERACTION_ID] = interactionId;
|
|
498
|
+
logger.log(`[ALS-PROOF] provider headers source=cron`);
|
|
509
499
|
}
|
|
510
500
|
else {
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
501
|
+
// ALS path: rawTaskId comes from the per-turn AsyncLocalStorage scope
|
|
502
|
+
// set by bot.ts runWithSessionContext. Real upstream params.id is
|
|
503
|
+
// `realSession&realInteraction`; tester UUIDs degenerate to the whole
|
|
504
|
+
// id as sessionId with empty interactionId.
|
|
505
|
+
const als = getCurrentSessionContext();
|
|
506
|
+
const rawTaskId = als?.taskId;
|
|
507
|
+
if (rawTaskId) {
|
|
508
|
+
const sessionId = rawTaskId.split("&")[0];
|
|
509
|
+
const interactionId = rawTaskId.split("&")[1] ?? "";
|
|
510
|
+
dynamicHeaders[HEADER_TRACE_ID] = rawTaskId;
|
|
511
|
+
dynamicHeaders[HEADER_SESSION_ID] = sessionId;
|
|
512
|
+
dynamicHeaders[HEADER_INTERACTION_ID] = interactionId;
|
|
513
|
+
logger.log(`[ALS-PROOF] provider headers source=ALS traceId=${rawTaskId} sessionId=${sessionId} interactionId=${interactionId}`);
|
|
514
|
+
}
|
|
515
|
+
else {
|
|
516
|
+
const fallbackPrefix = ctx.extraParams?.[FALLBACK_PREFIX_KEY];
|
|
517
|
+
if (typeof fallbackPrefix === "string") {
|
|
518
|
+
const fallbackValue = `${fallbackPrefix}_${Date.now()}`;
|
|
519
|
+
dynamicHeaders[HEADER_TRACE_ID] = fallbackValue;
|
|
520
|
+
dynamicHeaders[HEADER_SESSION_ID] = fallbackValue;
|
|
521
|
+
dynamicHeaders[HEADER_INTERACTION_ID] = fallbackValue;
|
|
522
|
+
}
|
|
523
|
+
logger.log(`[ALS-PROOF] provider headers source=uid-fallback (ALS miss)`);
|
|
517
524
|
}
|
|
518
525
|
}
|
|
519
526
|
// 记录输入
|
|
@@ -526,10 +533,8 @@ export const xiaoyiProvider = {
|
|
|
526
533
|
if (context.systemPrompt) {
|
|
527
534
|
logger.log(`[xiaoyiprovider] system prompt length: ${context.systemPrompt.length}`);
|
|
528
535
|
}
|
|
529
|
-
// deviceType:
|
|
530
|
-
|
|
531
|
-
const deviceType = extractedDeviceType
|
|
532
|
-
?? getCurrentSessionContext()?.deviceType;
|
|
536
|
+
// deviceType: read from ALS (no more text-extraction).
|
|
537
|
+
const deviceType = getCurrentSessionContext()?.deviceType;
|
|
533
538
|
// 在发送给模型前,优化 systemPrompt 结构
|
|
534
539
|
if (context.systemPrompt) {
|
|
535
540
|
let sp = context.systemPrompt;
|