@ai-setting/roy-agent-core 1.7.32 → 1.7.34

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.
@@ -11,7 +11,7 @@ import {
11
11
  larkCliHandler,
12
12
  resolveBountyIMSystemPrompt,
13
13
  timerHandler
14
- } from "../../shared/@ai-setting/roy-agent-core-4csc7ars.js";
14
+ } from "../../shared/@ai-setting/roy-agent-core-ybg8sayk.js";
15
15
  import"../../shared/@ai-setting/roy-agent-core-0nz53t5v.js";
16
16
  import {
17
17
  BUILT_IN_EVENT_SOURCE_TYPES,
@@ -22,7 +22,7 @@ import {
22
22
  isValidEventSourceType,
23
23
  validateEventSourceConfig
24
24
  } from "../../shared/@ai-setting/roy-agent-core-ds5f75pg.js";
25
- import"../../shared/@ai-setting/roy-agent-core-9z6gcy77.js";
25
+ import"../../shared/@ai-setting/roy-agent-core-6f7cjzem.js";
26
26
  import"../../shared/@ai-setting/roy-agent-core-1pg0fepg.js";
27
27
  import"../../shared/@ai-setting/roy-agent-core-skqt40yy.js";
28
28
  import"../../shared/@ai-setting/roy-agent-core-1df0grva.js";
@@ -30,7 +30,7 @@ import"../../shared/@ai-setting/roy-agent-core-jdvgzf2y.js";
30
30
  import"../../shared/@ai-setting/roy-agent-core-jrj30vq3.js";
31
31
  import"../../shared/@ai-setting/roy-agent-core-jbc1t62x.js";
32
32
  import"../../shared/@ai-setting/roy-agent-core-e25xkv53.js";
33
- import"../../shared/@ai-setting/roy-agent-core-az13yzmc.js";
33
+ import"../../shared/@ai-setting/roy-agent-core-rmn29nrh.js";
34
34
  import"../../shared/@ai-setting/roy-agent-core-7hh0brvs.js";
35
35
  import"../../shared/@ai-setting/roy-agent-core-m725wp1x.js";
36
36
  import"../../shared/@ai-setting/roy-agent-core-sf4bjgwz.js";
package/dist/env/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BaseEnvironment
3
- } from "../shared/@ai-setting/roy-agent-core-4t6m600m.js";
3
+ } from "../shared/@ai-setting/roy-agent-core-mssk8f0g.js";
4
4
  import {
5
5
  TaskComponent
6
6
  } from "../shared/@ai-setting/roy-agent-core-m09a4xwh.js";
@@ -15,7 +15,7 @@ import {
15
15
  EventSourceComponent,
16
16
  builtInHandlers,
17
17
  larkCliHandler
18
- } from "../shared/@ai-setting/roy-agent-core-4csc7ars.js";
18
+ } from "../shared/@ai-setting/roy-agent-core-ybg8sayk.js";
19
19
  import"../shared/@ai-setting/roy-agent-core-0nz53t5v.js";
20
20
  import {
21
21
  EventSourceInitHooks,
@@ -24,7 +24,7 @@ import {
24
24
  isValidEventSourceType,
25
25
  validateEventSourceConfig
26
26
  } from "../shared/@ai-setting/roy-agent-core-ds5f75pg.js";
27
- import"../shared/@ai-setting/roy-agent-core-9z6gcy77.js";
27
+ import"../shared/@ai-setting/roy-agent-core-6f7cjzem.js";
28
28
  import"../shared/@ai-setting/roy-agent-core-1pg0fepg.js";
29
29
  import"../shared/@ai-setting/roy-agent-core-skqt40yy.js";
30
30
  import {
@@ -69,8 +69,8 @@ import"../shared/@ai-setting/roy-agent-core-c1v263jn.js";
69
69
  import"../shared/@ai-setting/roy-agent-core-e25xkv53.js";
70
70
  import {
71
71
  PluginComponent
72
- } from "../shared/@ai-setting/roy-agent-core-0ra1gtn9.js";
73
- import"../shared/@ai-setting/roy-agent-core-az13yzmc.js";
72
+ } from "../shared/@ai-setting/roy-agent-core-bt7mg8j5.js";
73
+ import"../shared/@ai-setting/roy-agent-core-rmn29nrh.js";
74
74
  import {
75
75
  McpComponent
76
76
  } from "../shared/@ai-setting/roy-agent-core-gjnhkemk.js";
@@ -1,10 +1,11 @@
1
1
  import {
2
2
  EventBusNotificationChannel,
3
3
  PluginComponent
4
- } from "../../shared/@ai-setting/roy-agent-core-0ra1gtn9.js";
4
+ } from "../../shared/@ai-setting/roy-agent-core-bt7mg8j5.js";
5
5
  import {
6
- BasePlugin
7
- } from "../../shared/@ai-setting/roy-agent-core-az13yzmc.js";
6
+ BasePlugin,
7
+ normalizeLarkAtMentions
8
+ } from "../../shared/@ai-setting/roy-agent-core-rmn29nrh.js";
8
9
  import"../../shared/@ai-setting/roy-agent-core-m725wp1x.js";
9
10
  import"../../shared/@ai-setting/roy-agent-core-sf4bjgwz.js";
10
11
  import"../../shared/@ai-setting/roy-agent-core-g772q3gf.js";
@@ -64,6 +65,7 @@ ${options.content}`;
64
65
  return new Promise((resolve, reject) => {
65
66
  const { chatId, messageId, content, profile } = options;
66
67
  let args;
68
+ const normalizedContent = normalizeLarkAtMentions(content);
67
69
  if (messageId) {
68
70
  args = [
69
71
  "im",
@@ -71,7 +73,7 @@ ${options.content}`;
71
73
  "--message-id",
72
74
  messageId,
73
75
  "--markdown",
74
- content,
76
+ normalizedContent,
75
77
  "--as",
76
78
  "bot"
77
79
  ];
@@ -82,7 +84,7 @@ ${options.content}`;
82
84
  "--chat-id",
83
85
  chatId,
84
86
  "--markdown",
85
- content
87
+ normalizedContent
86
88
  ];
87
89
  }
88
90
  if (profile) {
@@ -10,7 +10,7 @@ import {
10
10
  formatExtractorInput,
11
11
  formatExtractorInputFromDescription,
12
12
  parseExtractorOutput
13
- } from "../../../shared/@ai-setting/roy-agent-core-9z6gcy77.js";
13
+ } from "../../../shared/@ai-setting/roy-agent-core-6f7cjzem.js";
14
14
  import"../../../shared/@ai-setting/roy-agent-core-1pg0fepg.js";
15
15
  import"../../../shared/@ai-setting/roy-agent-core-skqt40yy.js";
16
16
  import"../../../shared/@ai-setting/roy-agent-core-1df0grva.js";
@@ -18,7 +18,7 @@ import"../../../shared/@ai-setting/roy-agent-core-jdvgzf2y.js";
18
18
  import"../../../shared/@ai-setting/roy-agent-core-jrj30vq3.js";
19
19
  import"../../../shared/@ai-setting/roy-agent-core-jbc1t62x.js";
20
20
  import"../../../shared/@ai-setting/roy-agent-core-e25xkv53.js";
21
- import"../../../shared/@ai-setting/roy-agent-core-az13yzmc.js";
21
+ import"../../../shared/@ai-setting/roy-agent-core-rmn29nrh.js";
22
22
  import"../../../shared/@ai-setting/roy-agent-core-m2pxg5d8.js";
23
23
  import"../../../shared/@ai-setting/roy-agent-core-7p6rny5m.js";
24
24
  import"../../../shared/@ai-setting/roy-agent-core-38rtrpk3.js";
package/dist/index.js CHANGED
@@ -66,7 +66,7 @@ import {
66
66
  BaseEnvironment,
67
67
  generateDescendingId,
68
68
  generateId
69
- } from "./shared/@ai-setting/roy-agent-core-4t6m600m.js";
69
+ } from "./shared/@ai-setting/roy-agent-core-mssk8f0g.js";
70
70
  import {
71
71
  TaskComponent
72
72
  } from "./shared/@ai-setting/roy-agent-core-m09a4xwh.js";
@@ -92,7 +92,7 @@ import {
92
92
  larkCliHandler,
93
93
  resolveBountyIMSystemPrompt,
94
94
  timerHandler
95
- } from "./shared/@ai-setting/roy-agent-core-4csc7ars.js";
95
+ } from "./shared/@ai-setting/roy-agent-core-ybg8sayk.js";
96
96
  import {
97
97
  LogTraceComponent,
98
98
  LogTraceConfigSchema
@@ -109,7 +109,7 @@ import {
109
109
  import {
110
110
  TaskTagPlugin,
111
111
  createAutoTaskPlugin
112
- } from "./shared/@ai-setting/roy-agent-core-9z6gcy77.js";
112
+ } from "./shared/@ai-setting/roy-agent-core-6f7cjzem.js";
113
113
  import {
114
114
  TaskHookPoints
115
115
  } from "./shared/@ai-setting/roy-agent-core-1pg0fepg.js";
@@ -189,10 +189,10 @@ import {
189
189
  } from "./shared/@ai-setting/roy-agent-core-e25xkv53.js";
190
190
  import {
191
191
  PluginComponent
192
- } from "./shared/@ai-setting/roy-agent-core-0ra1gtn9.js";
192
+ } from "./shared/@ai-setting/roy-agent-core-bt7mg8j5.js";
193
193
  import {
194
194
  BasePlugin
195
- } from "./shared/@ai-setting/roy-agent-core-az13yzmc.js";
195
+ } from "./shared/@ai-setting/roy-agent-core-rmn29nrh.js";
196
196
  import {
197
197
  McpComponent
198
198
  } from "./shared/@ai-setting/roy-agent-core-gjnhkemk.js";
@@ -11,8 +11,9 @@ import {
11
11
  enqueueToAddFakeUserMessage
12
12
  } from "./roy-agent-core-jbc1t62x.js";
13
13
  import {
14
- BasePlugin
15
- } from "./roy-agent-core-az13yzmc.js";
14
+ BasePlugin,
15
+ normalizeLarkAtMentions
16
+ } from "./roy-agent-core-rmn29nrh.js";
16
17
  import {
17
18
  init_context
18
19
  } from "./roy-agent-core-m2pxg5d8.js";
@@ -556,6 +557,7 @@ ${content}`;
556
557
  return new Promise((resolve, reject) => {
557
558
  const { chatId, messageId, content, profile } = options;
558
559
  let args;
560
+ const normalizedContent = normalizeLarkAtMentions(content);
559
561
  if (messageId) {
560
562
  args = [
561
563
  "im",
@@ -563,7 +565,7 @@ ${content}`;
563
565
  "--message-id",
564
566
  messageId,
565
567
  "--markdown",
566
- content,
568
+ normalizedContent,
567
569
  "--as",
568
570
  "bot"
569
571
  ];
@@ -574,7 +576,7 @@ ${content}`;
574
576
  "--chat-id",
575
577
  chatId,
576
578
  "--markdown",
577
- content
579
+ normalizedContent
578
580
  ];
579
581
  }
580
582
  if (profile) {
@@ -1138,7 +1140,7 @@ class PerTaskGroupChatPlugin {
1138
1140
  "--chat-id",
1139
1141
  opts.chatId,
1140
1142
  "--markdown",
1141
- opts.content,
1143
+ normalizeLarkAtMentions(opts.content),
1142
1144
  "--as",
1143
1145
  "bot"
1144
1146
  ];
@@ -1175,9 +1177,9 @@ class PerTaskGroupChatPlugin {
1175
1177
  }
1176
1178
  sendToMain(replyChannel, opts) {
1177
1179
  return new Promise((resolve, reject) => {
1178
- const message = `${opts.title}
1180
+ const message = normalizeLarkAtMentions(`${opts.title}
1179
1181
 
1180
- ${opts.content}`;
1182
+ ${opts.content}`);
1181
1183
  const args = replyChannel.messageId ? ["im", "+messages-reply", "--message-id", replyChannel.messageId, "--markdown", message, "--as", "bot"] : ["im", "+messages-send", "--chat-id", replyChannel.chatId, "--markdown", message];
1182
1184
  if (opts.profile) {
1183
1185
  args.unshift("--profile", opts.profile);
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BasePlugin
3
- } from "./roy-agent-core-az13yzmc.js";
3
+ } from "./roy-agent-core-rmn29nrh.js";
4
4
  import {
5
5
  BaseComponent
6
6
  } from "./roy-agent-core-m725wp1x.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createAutoTaskPlugin
3
- } from "./roy-agent-core-9z6gcy77.js";
3
+ } from "./roy-agent-core-6f7cjzem.js";
4
4
  import {
5
5
  ContextError,
6
6
  ErrorCodes
@@ -0,0 +1,34 @@
1
+ // src/env/plugin/types.ts
2
+ class BasePlugin {
3
+ version = "1.0.0";
4
+ description;
5
+ priority = 0;
6
+ constructor() {}
7
+ init(env) {}
8
+ dispose() {}
9
+ }
10
+
11
+ // src/env/lark-mention-utils.ts
12
+ var SELF_CLOSING_AT_RE = /<at\s+user_id\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s>]+))\s*\/\s*>/g;
13
+ function normalizeLarkAtMentions(content, nameMap) {
14
+ if (!content)
15
+ return content;
16
+ return content.replace(SELF_CLOSING_AT_RE, (_match, dq, sq, bare) => {
17
+ const userId = dq ?? sq ?? bare ?? "";
18
+ if (!userId)
19
+ return _match;
20
+ const displayName = nameMap?.get(userId);
21
+ if (displayName) {
22
+ return `<at user_id="${escapeXmlAttr(userId)}">${escapeXmlText(displayName)}</at>`;
23
+ }
24
+ return `<at user_id="${escapeXmlAttr(userId)}"></at>`;
25
+ });
26
+ }
27
+ function escapeXmlAttr(value) {
28
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
29
+ }
30
+ function escapeXmlText(value) {
31
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
32
+ }
33
+
34
+ export { BasePlugin, normalizeLarkAtMentions };
@@ -2,7 +2,10 @@ import {
2
2
  TaskTagPlugin,
3
3
  createLarkCliTaskNotifyHook,
4
4
  createPerTaskGroupChatPlugin
5
- } from "./roy-agent-core-9z6gcy77.js";
5
+ } from "./roy-agent-core-6f7cjzem.js";
6
+ import {
7
+ normalizeLarkAtMentions
8
+ } from "./roy-agent-core-rmn29nrh.js";
6
9
  import {
7
10
  envKeyToConfigKey
8
11
  } from "./roy-agent-core-7hh0brvs.js";
@@ -867,6 +870,17 @@ function buildLarkRecommendedAction(opts) {
867
870
  `处理飞书 ${scopeWord}消息并以机器人身份回复${profileWarn}。`,
868
871
  `scope: ${scopeHint}。`,
869
872
  ``,
873
+ `## ⭐ 关键: 所有飞书回复必须用 --markdown flag (不要用 --text, 也不要裸调用)`,
874
+ `lark-cli 默认会让消息渲染成 plain text — 你的 Markdown 标签 (<at> mention、列表、`,
875
+ `**bold**、code block、表格等) 会被当成字面字符显示, 用户看到的就是`,
876
+ `一堆 raw 符号, 完全没法用。`,
877
+ `正确做法: 调 im +messages-{send,reply} 时必须显式加 --markdown <content>,`,
878
+ `飞书才会按 Markdown 渲染 rich format。`,
879
+ `**严禁**: 使用 --text flag (直接导致 rich format 失效, 是最常见的回归路径)`,
880
+ ` 使用 --msg-type text (同理, --msg-type post 也可以但需对应结构,`,
881
+ ` 最稳的仍然是 --markdown flag)`,
882
+ ` 不加任何 content flag (会按 plain text 默认值处理)`,
883
+ ``,
870
884
  `## 安全传 Markdown(必读,避免飞书收到字面 $ 和字面反斜杠+n)`,
871
885
  `多行 / 复杂 Markdown 必须先写入临时 .md 文件,再 cat 出来当 --markdown 的值。`,
872
886
  `原因:agent 工具调用层不做 shell 展开。`,
@@ -877,7 +891,7 @@ function buildLarkRecommendedAction(opts) {
877
891
  ` cat > "$reply_file" <<'LARK_REPLY_EOF' # 3. 写入 Markdown(heredoc 单引号防 shell 展开)`,
878
892
  ` ...(这里是回复的 Markdown 内容,可以多行 / 含特殊字符)`,
879
893
  ` LARK_REPLY_EOF`,
880
- ` lark-cli ${profileFlag}im +messages-reply --message-id <取自 replyTo.messageId> --as bot --markdown "$(cat "$reply_file")" # 4. 真正调用`,
894
+ ` lark-cli ${profileFlag}im +messages-reply --message-id <取自 replyTo.messageId> --as bot --markdown "$(cat "$reply_file")" # 4. 真正调用 (注意 --markdown flag, 不要用 --text)`,
881
895
  ``,
882
896
  `## 禁止(用 words 描述,避免被 LLM 当字面 trap 抄)`,
883
897
  `- 禁止把多行 Markdown 直接拼进 --markdown 参数`,
@@ -885,6 +899,8 @@ function buildLarkRecommendedAction(opts) {
885
899
  `- 禁止字面反斜杠+n(即 \\n 两个字符,不是 0x0A 控制字符)`,
886
900
  `- 禁止 stdin 形式传 Markdown(--markdown 后接一个短横线作为值的写法)`,
887
901
  `- 禁止 at-file 形式传 Markdown(--markdown 后接 @ 符号加文件名的写法)`,
902
+ `- 禁止 --text flag(让 lark-cli 把消息当 plain text, rich format 全部失效 — 见顶部说明)`,
903
+ `- 禁止 --msg-type text(同理, --msg-type post 可选但需对应结构, 仍不如 --markdown flag 稳)`,
888
904
  ``,
889
905
  `## 必须使用 replyTo 里给定的值`,
890
906
  `profile / chatId / messageId / --as bot 必须原样取自 recommendedAction.replyTo;不要凭印象自己拼接。`
@@ -1437,14 +1453,15 @@ class LarkCliInstance {
1437
1453
  async sendLarkMessage(options) {
1438
1454
  return new Promise((resolve, reject) => {
1439
1455
  const { chatId, userId, messageId, content, as: identity, format = "text", profile } = options;
1456
+ const normalizedContent = normalizeLarkAtMentions(content);
1440
1457
  const contentFlag = format === "markdown" ? "--markdown" : "--text";
1441
1458
  const args = ["im"];
1442
1459
  if (messageId) {
1443
- args.push("+messages-reply", "--message-id", messageId, "--as", identity, contentFlag, content);
1460
+ args.push("+messages-reply", "--message-id", messageId, "--as", identity, contentFlag, normalizedContent);
1444
1461
  } else if (chatId) {
1445
- args.push("+messages-send", "--chat-id", chatId, "--as", identity, contentFlag, content);
1462
+ args.push("+messages-send", "--chat-id", chatId, "--as", identity, contentFlag, normalizedContent);
1446
1463
  } else if (userId) {
1447
- args.push("+messages-send", "--user-id", userId, "--as", identity, contentFlag, content);
1464
+ args.push("+messages-send", "--user-id", userId, "--as", identity, contentFlag, normalizedContent);
1448
1465
  } else {
1449
1466
  reject(new Error("No target specified for sending message"));
1450
1467
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-setting/roy-agent-core",
3
- "version": "1.7.32",
3
+ "version": "1.7.34",
4
4
  "type": "module",
5
5
  "description": "Core SDK for roy-agent - Environment, Components, Tools, Sessions, Tasks",
6
6
  "main": "./dist/index.js",
@@ -1,11 +0,0 @@
1
- // src/env/plugin/types.ts
2
- class BasePlugin {
3
- version = "1.0.0";
4
- description;
5
- priority = 0;
6
- constructor() {}
7
- init(env) {}
8
- dispose() {}
9
- }
10
-
11
- export { BasePlugin };