@ynhcj/xiaoyi-channel 0.0.176-beta → 0.0.177-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 +29 -4
- package/dist/src/provider.js +26 -0
- package/dist/src/tools/create-all-tools.js +4 -8
- package/package.json +1 -1
package/dist/src/bot.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { updateSessionStoreEntry, resolveStorePath } from "openclaw/plugin-sdk/session-store-runtime";
|
|
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
4
|
import { parseA2AMessage, extractTextFromParts, extractFileParts, extractPushId, extractDeviceType, extractModelName, extractTriggerData, extractRunCrossTaskContext } from "./parser.js";
|
|
@@ -179,16 +179,41 @@ export async function handleXYMessage(params) {
|
|
|
179
179
|
// configured default model instead of the A2A-specified one.
|
|
180
180
|
if (modelName && modelName.trim() !== "" && modelName.toLowerCase() !== "none") {
|
|
181
181
|
try {
|
|
182
|
-
|
|
183
|
-
|
|
182
|
+
const storePath = resolveStorePath();
|
|
183
|
+
const result = await updateSessionStoreEntry({
|
|
184
|
+
storePath,
|
|
184
185
|
sessionKey: route.sessionKey,
|
|
185
186
|
update: async () => ({
|
|
186
187
|
providerOverride: "xiaoyiprovider",
|
|
187
188
|
modelOverride: modelName,
|
|
188
189
|
modelOverrideSource: "user",
|
|
190
|
+
model: "",
|
|
191
|
+
modelProvider: "",
|
|
189
192
|
}),
|
|
190
193
|
});
|
|
191
|
-
|
|
194
|
+
if (!result) {
|
|
195
|
+
// Session entry doesn't exist yet (first message, xy_channel
|
|
196
|
+
// bypasses the standard turn kernel). Create a minimal entry
|
|
197
|
+
// with the override via updateSessionStore.
|
|
198
|
+
await updateSessionStore(storePath, (store) => {
|
|
199
|
+
if (!store[route.sessionKey]) {
|
|
200
|
+
store[route.sessionKey] = {
|
|
201
|
+
// sessionId must pass validateSessionId regex /^[a-z0-9][a-z0-9._-]{0,127}$/i
|
|
202
|
+
// route.sessionKey like "agent:main:direct:xxx" contains colons which are invalid.
|
|
203
|
+
// Use parsed.sessionId (raw UUID from A2A) which is always safe.
|
|
204
|
+
sessionId: parsed.sessionId,
|
|
205
|
+
updatedAt: Date.now(),
|
|
206
|
+
providerOverride: "xiaoyiprovider",
|
|
207
|
+
modelOverride: modelName,
|
|
208
|
+
modelOverrideSource: "user",
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
log.log(`[BOT] Created session entry with model override: xiaoyiprovider/${modelName}`);
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
log.log(`[BOT] Patched session store model override: xiaoyiprovider/${modelName}`);
|
|
216
|
+
}
|
|
192
217
|
}
|
|
193
218
|
catch (patchErr) {
|
|
194
219
|
log.error(`[BOT] Failed to patch session model override:`, patchErr);
|
package/dist/src/provider.js
CHANGED
|
@@ -417,6 +417,32 @@ export const xiaoyiProvider = {
|
|
|
417
417
|
docsPath: "/providers/models",
|
|
418
418
|
auth: [],
|
|
419
419
|
isCacheTtlEligible: () => true,
|
|
420
|
+
/**
|
|
421
|
+
* Dynamic model resolution for A2A-specified model names.
|
|
422
|
+
* A2A messages carry a dynamic modelName that isn't in any static catalog.
|
|
423
|
+
* This hook lets OpenClaw's resolveModelAsync accept any model ID under
|
|
424
|
+
* xiaoyiprovider as long as the provider has a configured baseUrl.
|
|
425
|
+
*/
|
|
426
|
+
resolveDynamicModel: (ctx) => {
|
|
427
|
+
const baseUrl = ctx.providerConfig?.baseUrl;
|
|
428
|
+
if (!baseUrl || typeof baseUrl !== "string")
|
|
429
|
+
return null;
|
|
430
|
+
return {
|
|
431
|
+
id: ctx.modelId,
|
|
432
|
+
name: ctx.modelId,
|
|
433
|
+
api: ctx.providerConfig?.api ?? "openai-completions",
|
|
434
|
+
provider: "xiaoyiprovider",
|
|
435
|
+
baseUrl,
|
|
436
|
+
reasoning: false,
|
|
437
|
+
input: ["text"],
|
|
438
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
439
|
+
contextWindow: 128_000,
|
|
440
|
+
maxTokens: 8192,
|
|
441
|
+
...(ctx.providerConfig?.headers && typeof ctx.providerConfig.headers === "object"
|
|
442
|
+
? { headers: ctx.providerConfig.headers }
|
|
443
|
+
: {}),
|
|
444
|
+
};
|
|
445
|
+
},
|
|
420
446
|
/**
|
|
421
447
|
* Store uid-based fallback prefix for lazy timestamp generation in wrapStreamFn.
|
|
422
448
|
* Session-level headers (traceId / sessionId / interactionId) are resolved
|
|
@@ -17,10 +17,6 @@ import { createGetCollectionToolSchemaTool } from "./get-collection-tool-schema.
|
|
|
17
17
|
// import { createGetEmailToolSchemaTool } from "./get-email-tool-schema.js";
|
|
18
18
|
import { createLoginTokenTool } from "./login-token-tool.js";
|
|
19
19
|
import { createAgentAsSkillTool } from "./agent-as-skill-tool.js";
|
|
20
|
-
import { createDiscoverCrossDevicesTool } from "./discover-cross-devices-tool.js";
|
|
21
|
-
import { createSendCrossDeviceTaskTool } from "./send-cross-device-task-tool.js";
|
|
22
|
-
import { createDisplayA2UICardTool } from "./display-a2ui-card-tool.js";
|
|
23
|
-
import { createCheckPluginPrivilegeTool } from "./check-plugin-privilege-tool.js";
|
|
24
20
|
import { logger } from "../utils/logger.js";
|
|
25
21
|
/**
|
|
26
22
|
* Create all XY channel tools for the given session context.
|
|
@@ -36,9 +32,9 @@ export function createAllTools(ctx) {
|
|
|
36
32
|
logger.log(`[CREATE-ALL-TOOLS] creating tools`);
|
|
37
33
|
return [
|
|
38
34
|
createLocationTool(ctx),
|
|
39
|
-
createDiscoverCrossDevicesTool(ctx),
|
|
40
|
-
createSendCrossDeviceTaskTool(ctx),
|
|
41
|
-
createDisplayA2UICardTool(ctx),
|
|
35
|
+
// createDiscoverCrossDevicesTool(ctx),
|
|
36
|
+
// createSendCrossDeviceTaskTool(ctx),
|
|
37
|
+
// createDisplayA2UICardTool(ctx),
|
|
42
38
|
createCallDeviceTool(ctx),
|
|
43
39
|
createGetNoteToolSchemaTool(ctx),
|
|
44
40
|
createGetCalendarToolSchemaTool(ctx),
|
|
@@ -57,6 +53,6 @@ export function createAllTools(ctx) {
|
|
|
57
53
|
createSaveSelfEvolutionSkillTool(ctx),
|
|
58
54
|
createLoginTokenTool(ctx),
|
|
59
55
|
createAgentAsSkillTool(ctx),
|
|
60
|
-
createCheckPluginPrivilegeTool(ctx),
|
|
56
|
+
// createCheckPluginPrivilegeTool(ctx),
|
|
61
57
|
];
|
|
62
58
|
}
|