@ynhcj/xiaoyi-channel 0.0.194-beta → 0.0.196-beta
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { updateSessionStoreEntry, updateSessionStore, resolveStorePath } from "openclaw/plugin-sdk/session-store-runtime";
|
|
2
2
|
import { getXYRuntime } from "./runtime.js";
|
|
3
3
|
import { createXYReplyDispatcher } from "./reply-dispatcher.js";
|
|
4
|
-
import { parseA2AMessage, extractTextFromParts, extractFileParts, extractPushId, extractDeviceType, extractModelName, extractTriggerData, extractRunCrossTaskContext } from "./parser.js";
|
|
4
|
+
import { parseA2AMessage, extractTextFromParts, extractFileParts, extractPushId, extractDeviceType, extractAppVer, extractDisplayVersion, extractModelName, extractTriggerData, extractRunCrossTaskContext } from "./parser.js";
|
|
5
5
|
import { downloadFilesFromParts } from "./file-download.js";
|
|
6
6
|
import { resolveXYConfig } from "./config.js";
|
|
7
7
|
import { sendStatusUpdate, sendClearContextResponse, sendTasksCancelResponse, sendA2AResponse } from "./formatter.js";
|
|
@@ -139,6 +139,15 @@ export async function handleXYMessage(params) {
|
|
|
139
139
|
if (deviceType) {
|
|
140
140
|
log.log(`[BOT] Extracted deviceType: ${deviceType}`);
|
|
141
141
|
}
|
|
142
|
+
// Extract app_ver and display_version if present
|
|
143
|
+
const appVer = extractAppVer(parsed.parts);
|
|
144
|
+
if (appVer) {
|
|
145
|
+
log.log(`[BOT] Extracted app_ver: ${appVer}`);
|
|
146
|
+
}
|
|
147
|
+
const displayVersion = extractDisplayVersion(parsed.parts);
|
|
148
|
+
if (displayVersion) {
|
|
149
|
+
log.log(`[BOT] Extracted display_version: ${displayVersion}`);
|
|
150
|
+
}
|
|
142
151
|
// Extract modelName if present (used by provider.ts to override model.id)
|
|
143
152
|
const modelName = extractModelName(parsed.parts);
|
|
144
153
|
if (modelName) {
|
|
@@ -170,6 +179,8 @@ export async function handleXYMessage(params) {
|
|
|
170
179
|
messageId: parsed.messageId,
|
|
171
180
|
agentId: route.accountId,
|
|
172
181
|
deviceType,
|
|
182
|
+
appVer: appVer ?? undefined,
|
|
183
|
+
displayVersion: displayVersion ?? undefined,
|
|
173
184
|
modelName,
|
|
174
185
|
runCrossTaskContext: runCrossTaskContext ?? undefined,
|
|
175
186
|
});
|
|
@@ -246,9 +246,9 @@ function handleMemoryHistory() {
|
|
|
246
246
|
const timestamp = line.slice(0, firstPipe);
|
|
247
247
|
const fileName = line.slice(firstPipe + 1, secondPipe);
|
|
248
248
|
const detail = line.slice(secondPipe + 1);
|
|
249
|
-
// timestamp format: 2026-06-22T15:18:00
|
|
249
|
+
// timestamp format: 2026-06-22T15:18:00 → extract hh:mm
|
|
250
250
|
const datePart = timestamp.slice(0, 10);
|
|
251
|
-
const timePart = timestamp.slice(11,
|
|
251
|
+
const timePart = timestamp.slice(11, 16);
|
|
252
252
|
const entryDate = new Date(`${datePart}T00:00:00`);
|
|
253
253
|
// Retain log lines within the 30-day window.
|
|
254
254
|
if (!isNaN(entryDate.getTime()) && entryDate >= retentionSince) {
|
package/dist/src/parser.d.ts
CHANGED
|
@@ -44,6 +44,18 @@ export declare function isTasksCancelMessage(method: string): boolean;
|
|
|
44
44
|
* Looks for push_id in data parts under variables.systemVariables.push_id
|
|
45
45
|
*/
|
|
46
46
|
export declare function extractPushId(parts: A2AMessagePart[]): string | null;
|
|
47
|
+
/**
|
|
48
|
+
* Extract app_ver from message parts.
|
|
49
|
+
* Looks for app_ver in data parts under variables.systemVariables.app_ver
|
|
50
|
+
* (same level as push_id).
|
|
51
|
+
*/
|
|
52
|
+
export declare function extractAppVer(parts: A2AMessagePart[]): string | null;
|
|
53
|
+
/**
|
|
54
|
+
* Extract display_version from message parts.
|
|
55
|
+
* Looks for display_version in data parts under variables.systemVariables.display_version
|
|
56
|
+
* (same level as push_id).
|
|
57
|
+
*/
|
|
58
|
+
export declare function extractDisplayVersion(parts: A2AMessagePart[]): string | null;
|
|
47
59
|
/**
|
|
48
60
|
* Extract deviceType from message parts.
|
|
49
61
|
* Looks for deviceType in data parts under variables.systemVariables.deviceType
|
package/dist/src/parser.js
CHANGED
|
@@ -121,6 +121,38 @@ export function extractPushId(parts) {
|
|
|
121
121
|
}
|
|
122
122
|
return null;
|
|
123
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* Extract app_ver from message parts.
|
|
126
|
+
* Looks for app_ver in data parts under variables.systemVariables.app_ver
|
|
127
|
+
* (same level as push_id).
|
|
128
|
+
*/
|
|
129
|
+
export function extractAppVer(parts) {
|
|
130
|
+
for (const part of parts) {
|
|
131
|
+
if (part.kind === "data" && part.data) {
|
|
132
|
+
const appVer = part.data.variables?.systemVariables?.app_ver;
|
|
133
|
+
if (appVer && typeof appVer === "string") {
|
|
134
|
+
return appVer;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Extract display_version from message parts.
|
|
142
|
+
* Looks for display_version in data parts under variables.systemVariables.display_version
|
|
143
|
+
* (same level as push_id).
|
|
144
|
+
*/
|
|
145
|
+
export function extractDisplayVersion(parts) {
|
|
146
|
+
for (const part of parts) {
|
|
147
|
+
if (part.kind === "data" && part.data) {
|
|
148
|
+
const displayVersion = part.data.variables?.systemVariables?.display_version;
|
|
149
|
+
if (displayVersion && typeof displayVersion === "string") {
|
|
150
|
+
return displayVersion;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
124
156
|
/**
|
|
125
157
|
* Extract deviceType from message parts.
|
|
126
158
|
* Looks for deviceType in data parts under variables.systemVariables.deviceType
|
package/dist/src/provider.js
CHANGED
|
@@ -564,6 +564,15 @@ export const xiaoyiProvider = {
|
|
|
564
564
|
// then ALS fallback.
|
|
565
565
|
const deviceType = extractedDeviceType
|
|
566
566
|
?? getCurrentSessionContext()?.deviceType;
|
|
567
|
+
// app_ver and display_version from session context (ALS)
|
|
568
|
+
const appVer = sessionCtx?.appVer;
|
|
569
|
+
const displayVersion = sessionCtx?.displayVersion;
|
|
570
|
+
if (appVer) {
|
|
571
|
+
logger.log(`[xiaoyiprovider] app_ver: ${appVer}`);
|
|
572
|
+
}
|
|
573
|
+
if (displayVersion) {
|
|
574
|
+
logger.log(`[xiaoyiprovider] display_version: ${displayVersion}`);
|
|
575
|
+
}
|
|
567
576
|
// 在发送给模型前,优化 systemPrompt 结构
|
|
568
577
|
if (context.systemPrompt) {
|
|
569
578
|
let sp = context.systemPrompt;
|
|
@@ -599,9 +608,19 @@ export const xiaoyiProvider = {
|
|
|
599
608
|
logger.log(`[selfEvolution] selfEvolution flag: ${selfEvolutionEnabled}`);
|
|
600
609
|
context.systemPrompt = applySelfEvolutionPrompt(context.systemPrompt, selfEvolutionEnabled);
|
|
601
610
|
// Append device context to systemPrompt
|
|
602
|
-
if (deviceType) {
|
|
611
|
+
if (deviceType || appVer || displayVersion) {
|
|
603
612
|
const displayDevice = (deviceType === "2in1") ? "鸿蒙PC" : deviceType;
|
|
604
|
-
|
|
613
|
+
let deviceSection = `\n\n## Current User Device Context\n`;
|
|
614
|
+
if (deviceType) {
|
|
615
|
+
deviceSection += `The current user is using the following device: ${displayDevice}\n`;
|
|
616
|
+
}
|
|
617
|
+
if (appVer) {
|
|
618
|
+
deviceSection += `当前用户小艺APP版本是${appVer}\n`;
|
|
619
|
+
}
|
|
620
|
+
if (displayVersion) {
|
|
621
|
+
deviceSection += `当前用户系统Rom版本是${displayVersion}\n`;
|
|
622
|
+
}
|
|
623
|
+
deviceSection += `You need to be aware of the user's current device and provide guidance accordingly. If the response involves device-related tools or actions, you must tailor the reply based on the user's current device, using device-specific references such as "saved to the Notes/Calendar on your {deviceType}.\n"`;
|
|
605
624
|
context.systemPrompt = (context.systemPrompt ?? "") + deviceSection;
|
|
606
625
|
}
|
|
607
626
|
// ── Trim user message metadata ──────────────────────
|
|
@@ -8,6 +8,10 @@ export interface SessionContext {
|
|
|
8
8
|
messageId: string;
|
|
9
9
|
agentId: string;
|
|
10
10
|
deviceType?: string;
|
|
11
|
+
/** App version extracted from A2A systemVariables (variables.systemVariables.app_ver). */
|
|
12
|
+
appVer?: string;
|
|
13
|
+
/** Display version (ROM version) extracted from A2A systemVariables (variables.systemVariables.display_version). */
|
|
14
|
+
displayVersion?: string;
|
|
11
15
|
/** Model name extracted from A2A user variables (variables.clientVariables.modelName).
|
|
12
16
|
* When set, provider.ts replaces model.id in the OpenAI request body. */
|
|
13
17
|
modelName?: string;
|
package/dist/src/websocket.js
CHANGED
|
@@ -512,6 +512,7 @@ export class XYWebSocketManager extends EventEmitter {
|
|
|
512
512
|
? logger.withContext(sessionId, taskId)
|
|
513
513
|
: { log: (msg, ...args) => logger.log(msg, ...args) };
|
|
514
514
|
log.log(`[WS-RECV] Raw message frame, size: ${messageStr.length} characters`);
|
|
515
|
+
log.log(`[WS-RECV] Full message: ${messageStr}`);
|
|
515
516
|
// Handle direct cross-task requests (top-level networkId)
|
|
516
517
|
const directRunCrossTaskRequest = this.toRunCrossTaskA2ARequest(parsed);
|
|
517
518
|
if (directRunCrossTaskRequest) {
|