ylib-syim 0.0.39 → 0.0.41

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.
Files changed (2) hide show
  1. package/bridges/main.ts +19 -25
  2. package/package.json +1 -1
package/bridges/main.ts CHANGED
@@ -4053,9 +4053,9 @@ function formatRecentErrorContextLogHint(
4053
4053
  "recent_error_context_present=1",
4054
4054
  `context_lookup_hint=search_previous_lines_in_this_log platform=${platform}`,
4055
4055
  `account=${accountId}`,
4056
- "keywords=error|失败|异常|status_code",
4056
+ "match=error_level_same_platform_same_account",
4057
4057
  "exclude=derived_error|status_error|recent_error_context",
4058
- `中文提示=存在额外排障上下文,请在当前日志文件中向前查找同平台(${platform})、同账号(${accountId})、包含error/失败/异常/status_code的日志行,并排除derived_error/status_error/recent_error_context/context_lookup_hint行`,
4058
+ `中文提示=存在额外排障上下文,请在当前日志文件中向前查找同平台(${platform})、同账号(${accountId})error级别的日志行,并排除derived_error/status_error/recent_error_context/context_lookup_hint行`,
4059
4059
  ].join(" ");
4060
4060
  }
4061
4061
 
@@ -4074,7 +4074,8 @@ function readRecentBridgeErrorFromLog(
4074
4074
  if (!logFilePath || !fs.existsSync(logFilePath)) return null;
4075
4075
  const text = fs.readFileSync(logFilePath, "utf-8");
4076
4076
  if (!text) return null;
4077
- const lines = text.split("\n").slice(-800).reverse();
4077
+ // 全文件倒序扫描:先定位同平台 error 日志,再匹配账号,避免最后 N 行被其他账号刷掉。
4078
+ const lines = text.split("\n").reverse();
4078
4079
  const matched: string[] = [];
4079
4080
 
4080
4081
  const platformHints =
@@ -4086,13 +4087,20 @@ function readRecentBridgeErrorFromLog(
4086
4087
 
4087
4088
  for (const line of lines) {
4088
4089
  const lower = line.toLowerCase();
4090
+ const trimmed = line.trim();
4091
+ if (!trimmed) continue;
4092
+ if (!/^\[[^\]]+\] \[error\] /.test(trimmed)) continue;
4093
+ const content = trimmed.replace(/^\[[^\]]+\] \[[^\]]+\] /, "");
4094
+ const contentLower = content.toLowerCase();
4089
4095
  if (
4090
- lower.includes("recent_error_context=") ||
4091
- lower.includes("context_lookup_hint=") ||
4092
- lower.includes(" probeaccount derived_error ") ||
4093
- lower.includes(" probe derived_error ") ||
4094
- lower.includes(" probeaccount status_error ") ||
4095
- lower.includes(" probe status_error ")
4096
+ contentLower.includes("recent_error_context=") ||
4097
+ contentLower.includes("context_lookup_hint=") ||
4098
+ contentLower.includes(" probeaccount derived_error ") ||
4099
+ contentLower.includes(" probe derived_error ") ||
4100
+ contentLower.includes(" probeaccount status_error ") ||
4101
+ contentLower.includes(" probe status_error ") ||
4102
+ contentLower.includes(" probeaccount merged_error ") ||
4103
+ contentLower.includes(" probe merged_error ")
4096
4104
  ) {
4097
4105
  continue;
4098
4106
  }
@@ -4104,25 +4112,11 @@ function readRecentBridgeErrorFromLog(
4104
4112
  lower.includes(String(accountId || "").toLowerCase()) ||
4105
4113
  accountId === "__default__";
4106
4114
  if (!hasAccount) continue;
4107
- if (
4108
- !(
4109
- lower.includes("error") ||
4110
- lower.includes("失败") ||
4111
- lower.includes("异常") ||
4112
- lower.includes("status code")
4113
- )
4114
- ) {
4115
- continue;
4116
- }
4117
- const trimmed = line.trim();
4118
- if (!trimmed) continue;
4119
- matched.push(
4120
- trimmed.replace(/^\[[^\]]+\] \[[^\]]+\] /, "").replace(/\r?\n/g, "\\n"),
4121
- );
4115
+ matched.push(content.replace(/\r?\n/g, "\\n"));
4122
4116
  if (matched.length >= runtimeErrorLogFallbackLines) break;
4123
4117
  }
4124
4118
  if (matched.length > 0) {
4125
- return matched.join(" | ").slice(0, 1600);
4119
+ return matched.join("\n").slice(0, 1600);
4126
4120
  }
4127
4121
  } catch {}
4128
4122
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ylib-syim",
3
- "version": "0.0.39",
3
+ "version": "0.0.41",
4
4
  "description": "多 IM / 多 Agent 的会话路由与上下文管理(支持 /new)",
5
5
  "type": "module",
6
6
  "exports": {