@ai-setting/roy-agent-core 1.7.35 → 1.7.36
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-
|
|
14
|
+
} from "../../shared/@ai-setting/roy-agent-core-tft0pa6h.js";
|
|
15
15
|
import"../../shared/@ai-setting/roy-agent-core-1dacps3n.js";
|
|
16
16
|
import {
|
|
17
17
|
BUILT_IN_EVENT_SOURCE_TYPES,
|
package/dist/env/index.js
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
EventSourceComponent,
|
|
16
16
|
builtInHandlers,
|
|
17
17
|
larkCliHandler
|
|
18
|
-
} from "../shared/@ai-setting/roy-agent-core-
|
|
18
|
+
} from "../shared/@ai-setting/roy-agent-core-tft0pa6h.js";
|
|
19
19
|
import"../shared/@ai-setting/roy-agent-core-1dacps3n.js";
|
|
20
20
|
import {
|
|
21
21
|
EventSourceInitHooks,
|
package/dist/index.js
CHANGED
|
@@ -864,55 +864,49 @@ function buildLarkRecommendedAction(opts) {
|
|
|
864
864
|
const profileFlag = profile ? `--profile ${profile} ` : "";
|
|
865
865
|
const profileWarn = profile ? `(⚠️ 必须用 profile="${profile}" 调 lark-cli;openId per-app 隔离,换 profile 会失败)` : "";
|
|
866
866
|
const isGroup = chatType === "group";
|
|
867
|
-
const scopeHint = isGroup ? `群聊消息;回复到 replyTo.chatId。如需
|
|
867
|
+
const scopeHint = isGroup ? `群聊消息;回复到 replyTo.chatId。如需 @发件人,用结构化 at 节点 {"tag":"at","user_id":"<senderId>"}(不要写 <at> 文本标签)` : "p2p 私聊消息;回复到 replyTo.chatId";
|
|
868
868
|
const scopeWord = isGroup ? "群聊" : "p2p 私聊";
|
|
869
869
|
const action = [
|
|
870
870
|
`处理飞书 ${scopeWord}消息并以机器人身份回复${profileWarn}。`,
|
|
871
871
|
`scope: ${scopeHint}。`,
|
|
872
872
|
``,
|
|
873
|
-
`## ⭐ 关键 1:
|
|
874
|
-
`lark-cli
|
|
875
|
-
|
|
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 默认值处理)`,
|
|
873
|
+
`## ⭐ 关键 1: 飞书回复必须用结构化 post content(--msg-type post --content)`,
|
|
874
|
+
`lark-cli 默认把消息当 plain text;而 @mention 只有在**结构化 at 节点**里才会被`,
|
|
875
|
+
`飞书识别为真实 @。所以回复统一走 post 的 --content JSON:`,
|
|
883
876
|
``,
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
877
|
+
` {"zh_cn":{"content":[`,
|
|
878
|
+
` [ {"tag":"at","user_id":"ou_xxx"} ], // @某人:结构化节点(可多个/多段)`,
|
|
879
|
+
` [ {"tag":"md","text":"正文 Markdown(标题/表格/加粗都支持)"} ] // 正文:单个 md 节点`,
|
|
880
|
+
` ]}}`,
|
|
888
881
|
``,
|
|
889
|
-
|
|
890
|
-
|
|
882
|
+
`- @mention:用 {"tag":"at","user_id":"ou_xxx"}(user_id 填对方 open_id;@所有人填 "all")`,
|
|
883
|
+
`- 正文:全部放进 {"tag":"md","text":"..."} 这一个节点里`,
|
|
884
|
+
`- 不需要 @ 时,content 里只放 md 节点:{"zh_cn":{"content":[[{"tag":"md","text":"..."}]]}}`,
|
|
885
|
+
`**严禁**: 用 --text(plain text,Markdown 全部失效)`,
|
|
886
|
+
` 用 --markdown(无法携带结构化 at 节点,@ 会退化成普通文本)`,
|
|
887
|
+
` 在正文里写 <at user_id="ou_xxx"/> 或 <at user_id="ou_xxx"></at> 文本标签`,
|
|
888
|
+
` (飞书不识别文本标签,只认结构化 at 节点;写文本标签会显示成原始字符)`,
|
|
891
889
|
``,
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
`**严禁**: 不用 <at> 直接 @userId 字符串 (飞书当成普通文本)`,
|
|
890
|
+
`## 关键 2: 安全构造 content(照抄,避免 JSON 转义地狱)`,
|
|
891
|
+
`把 Markdown 正文写进临时文件,再用 jq 组装(jq 会自动把换行转义为反斜杠+n):`,
|
|
895
892
|
``,
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
`推荐调用模板(4 步缺一不可,照抄):`,
|
|
901
|
-
` reply_file="$(mktemp /tmp/lark-reply.XXXXXX.md)" # 1. 唯一文件名(避免并发覆盖)`,
|
|
902
|
-
` trap 'rm -f "$reply_file"' EXIT # 2. 注册退出清理(无论成败都删,避免 /tmp 累积)`,
|
|
903
|
-
` cat > "$reply_file" <<'LARK_REPLY_EOF' # 3. 写入 Markdown(heredoc 单引号防 shell 展开)`,
|
|
904
|
-
` ...(这里是回复的 Markdown 内容,可以多行 / 含特殊字符)`,
|
|
893
|
+
` body_file="$(mktemp /tmp/lark-reply.XXXXXX.md)"`,
|
|
894
|
+
` trap 'rm -f "$body_file"' EXIT`,
|
|
895
|
+
` cat > "$body_file" <<'LARK_REPLY_EOF'`,
|
|
896
|
+
` ...(回复的 Markdown 正文,可多行 / 含表格 / 含特殊字符;不要写 <at> 标签)`,
|
|
905
897
|
` LARK_REPLY_EOF`,
|
|
906
|
-
`
|
|
898
|
+
` content="$(jq -nc --rawfile md "$body_file" --arg uid "<senderId>" '{zh_cn:{content:[[{tag:"at",user_id:$uid}],[{tag:"md",text:$md}]]}}')"`,
|
|
899
|
+
` lark-cli ${profileFlag}im +messages-reply --message-id <取自 replyTo.messageId> --as bot --msg-type post --content "$content"`,
|
|
900
|
+
``,
|
|
901
|
+
`不需要 @ 某人时,把 jq 表达式换成 '{zh_cn:{content:[[{tag:"md",text:$md}]]}}'。`,
|
|
907
902
|
``,
|
|
908
|
-
`##
|
|
909
|
-
`-
|
|
910
|
-
`- 禁止
|
|
903
|
+
`## 禁止`,
|
|
904
|
+
`- 禁止 --text / --msg-type text(plain text,Markdown 全部失效)`,
|
|
905
|
+
`- 禁止 --markdown(无法携带结构化 at 节点)`,
|
|
906
|
+
`- 禁止在正文里写 <at user_id=".."/> 或 <at user_id=".."></at> 文本标签`,
|
|
907
|
+
`- 禁止把多行 Markdown 直接拼进 --content 参数(必须走上面的 jq --rawfile)`,
|
|
911
908
|
`- 禁止字面反斜杠+n(即 \\n 两个字符,不是 0x0A 控制字符)`,
|
|
912
|
-
`- 禁止
|
|
913
|
-
`- 禁止 at-file 形式传 Markdown(--markdown 后接 @ 符号加文件名的写法)`,
|
|
914
|
-
`- 禁止 --text flag(让 lark-cli 把消息当 plain text, rich format 全部失效 — 见顶部说明)`,
|
|
915
|
-
`- 禁止 --msg-type text(同理, --msg-type post 可选但需对应结构, 仍不如 --markdown flag 稳)`,
|
|
909
|
+
`- 禁止 bash ANSI-C 引号语法(dollar 符号紧跟单引号)`,
|
|
916
910
|
``,
|
|
917
911
|
`## 必须使用 replyTo 里给定的值`,
|
|
918
912
|
`profile / chatId / messageId / --as bot 必须原样取自 recommendedAction.replyTo;不要凭印象自己拼接。`
|