@ynhcj/xiaoyi-channel 0.0.145-beta → 0.0.146-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.
@@ -495,15 +495,20 @@ export const xiaoyiProvider = {
495
495
  }
496
496
  }
497
497
  // ── Build dynamic headers ────────────────────────────
498
+ // Priority:
499
+ // 1. TaskId extracted from Conversation info in user messages (most reliable
500
+ // — based on message content, not mutable global state or cached values)
501
+ // 2. UID-based fallback: sha256(uid).hex[:32]_timestamp
502
+ // 3. Cached extraParams from prepareExtraParams (session keys)
498
503
  if (ctx.extraParams) {
499
504
  const fallbackPrefix = ctx.extraParams[FALLBACK_PREFIX_KEY];
500
- if (typeof fallbackPrefix === "string") {
501
- // Fallback mode: generate fresh timestamp per request
505
+ if (extractedTaskId) {
506
+ // Session mode: taskId extracted from Conversation info
507
+ const traceId = extractedTaskId;
508
+ const sessionId = traceId.split("&")[0];
509
+ const interactionId = traceId.split("&")[1] ?? "";
502
510
  const isCron = isCronTriggered(context.messages);
503
- const fallbackValue = `${fallbackPrefix}_${Date.now()}`;
504
- dynamicHeaders[HEADER_TRACE_ID] = isCron ? `cron_${fallbackValue}` : fallbackValue;
505
- dynamicHeaders[HEADER_SESSION_ID] = fallbackValue;
506
- dynamicHeaders[HEADER_INTERACTION_ID] = fallbackValue;
511
+ dynamicHeaders[HEADER_TRACE_ID] = isCron ? `cron_${traceId}_${Date.now()}` : traceId;
507
512
  if (isCron) {
508
513
  const cronTitle = extractCronTitle(context.messages);
509
514
  if (cronTitle)
@@ -511,14 +516,16 @@ export const xiaoyiProvider = {
511
516
  if (context.messages?.length === 1)
512
517
  dynamicHeaders["x-cron-flag"] = "begin";
513
518
  }
519
+ dynamicHeaders[HEADER_SESSION_ID] = sessionId;
520
+ dynamicHeaders[HEADER_INTERACTION_ID] = interactionId;
514
521
  }
515
- else if (extractedTaskId) {
516
- // Session mode: taskId extracted from Conversation info
517
- const traceId = extractedTaskId;
518
- const sessionId = traceId.split("&")[0];
519
- const interactionId = traceId.split("&")[1] ?? "";
522
+ else if (typeof fallbackPrefix === "string") {
523
+ // Fallback mode: generate fresh timestamp per request
520
524
  const isCron = isCronTriggered(context.messages);
521
- dynamicHeaders[HEADER_TRACE_ID] = isCron ? `cron_${traceId}_${Date.now()}` : traceId;
525
+ const fallbackValue = `${fallbackPrefix}_${Date.now()}`;
526
+ dynamicHeaders[HEADER_TRACE_ID] = isCron ? `cron_${fallbackValue}` : fallbackValue;
527
+ dynamicHeaders[HEADER_SESSION_ID] = fallbackValue;
528
+ dynamicHeaders[HEADER_INTERACTION_ID] = fallbackValue;
522
529
  if (isCron) {
523
530
  const cronTitle = extractCronTitle(context.messages);
524
531
  if (cronTitle)
@@ -526,8 +533,6 @@ export const xiaoyiProvider = {
526
533
  if (context.messages?.length === 1)
527
534
  dynamicHeaders["x-cron-flag"] = "begin";
528
535
  }
529
- dynamicHeaders[HEADER_SESSION_ID] = sessionId;
530
- dynamicHeaders[HEADER_INTERACTION_ID] = interactionId;
531
536
  }
532
537
  else {
533
538
  // Fallback: use extraParams cached values
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ynhcj/xiaoyi-channel",
3
- "version": "0.0.145-beta",
3
+ "version": "0.0.146-beta",
4
4
  "description": "OpenClaw Xiaoyi Channel plugin - Xiaoyi A2A protocol integration",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",