Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

✨ feat(message): point Feishu / Lark work beyond messaging at lark-cli (#22093)

Arvin Xuf290ec524d69
diff --git a/packages/builtin-tool-message/src/systemRole.test.ts b/packages/builtin-tool-message/src/systemRole.test.ts
new file mode 100644
index 00000000000..6253979a30e
--- /dev/null
+++ b/packages/builtin-tool-message/src/systemRole.test.ts
@@ -0,0 +1,28 @@
+import { describe, expect, it } from 'vitest';
+
+import { systemPrompt } from './systemRole';
+
+/**
+ * Asked for an editable Feishu document, a device-run bot with no way to create
+ * one searched the local LobeHub database for the app secret, sent a .docx to
+ * the group, then drove the Feishu UI until the run was interrupted. The Feishu
+ * notes point at lark-cli instead and keep these guard rails.
+ */
+describe('Message systemRole — Feishu / Lark beyond messaging', () => {
+ it('routes document creation to lark-cli as the user', () => {
+ expect(systemPrompt).toContain('lark-cli docs +create --as user');
+ expect(systemPrompt).toContain('npx -y @larksuite/cli');
+ });
+
+ it('logs in without blocking and keeps the links with the bot owner', () => {
+ expect(systemPrompt).toContain('--no-wait --json');
+ expect(systemPrompt).toMatch(/end your turn/);
+ expect(systemPrompt).toMatch(/only to the bot owner/);
+ });
+
+ it('forbids credential hunting, UI driving and attachment substitutes', () => {
+ expect(systemPrompt).toMatch(
+ /Never search the device for the app secret, drive the Feishu UI, or send a file attachment/,
+ );
+ });
+});
diff --git a/packages/builtin-tool-message/src/systemRole.ts b/packages/builtin-tool-message/src/systemRole.ts
index 38261dfe4be..f0dde785bd4 100644
--- a/packages/builtin-tool-message/src/systemRole.ts
+++ b/packages/builtin-tool-message/src/systemRole.ts
@@ -251,6 +251,13 @@ Layout rules:
- Uses appId and appSecret for authentication
- \`readMessages\`: use \`startTime\`/\`endTime\` (Unix second timestamps) instead of \`before\`/\`after\` (message IDs). Use \`cursor\` from the response's \`nextCursor\` to paginate through pages.
- Documents (智能纪要 / meeting minutes, docx, wiki pages) are shared as LINKS, not text: a message like "帮我看这份纪要" plus a \`https://<tenant>.feishu.cn/docx/<token>\` URL contains no body. Call \`readDocument\` with that URL right away (also for links found via \`readMessages\`), then answer from the returned text. Never reply with only the link or ask the user to paste the content. If it fails with a permission error, relay the returned hint (the app must be able to see the document) instead of guessing.
+- **Anything beyond messaging and reading documents → \`lark-cli\`.** This tool cannot create or edit documents, sheets, Base, calendar events or anything else in Feishu / Lark, and the bot's app credentials are not yours to use. For those, use the official Feishu / Lark CLI \`lark-cli\` through your command tool (when you can run commands on a device). It acts as the signed-in Feishu user, so a document it creates belongs to that user and is editable right away:
+ - Check it is there with \`command -v lark-cli\` (Windows: \`where.exe lark-cli\`); otherwise use \`npx -y @larksuite/cli\` in its place.
+ - \`lark-cli auth status --json --verify\`. With no app configured, run \`lark-cli config init --new\` in the background and send its \`console_url\`. If not signed in or a scope is missing, run \`lark-cli auth login --domain docs --domain drive --no-wait --json\`, send the \`verification_url\` unchanged, and **end your turn**. Run \`lark-cli auth login --device-code <device_code>\` only after the user confirms.
+ - Whoever authorizes becomes the identity every later command runs as. Send setup and authorization links only to the bot owner (the bot's \`userId\` from \`getBotDetail\`), never to the whole group.
+ - Create a document: write the body to \`./draft.md\` (relative paths only), run \`lark-cli docs +create --as user --doc-format markdown --title "<title>" --content @./draft.md\`, check \`ok: true\`, and reply with \`data.document.url\`. That link is the deliverable.
+ - For anything else, start from \`lark-cli <domain> --help\` (docs, sheets, base, calendar, drive…) instead of guessing flags. Exit code 10 is a confirmation gate: show the user the action and retry with the flag named in \`hint\` only after they agree.
+ - If you cannot run commands here, or lark-cli cannot finish, say so in one sentence, name the missing step, and give the content in the chat. Never search the device for the app secret, drive the Feishu UI, or send a file attachment in place of a document.
**QQ:**
- Supports sending messages to groups, guild channels, and direct messages