[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7BMEF8Q8XSC6DC9C92CF9PH":3,"skill-same:01M7BMEF8Q8XSC6DC9C92CF9PH":47},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":29,"ownerHtmlUrl":30,"ownerBlogUrl":6,"ownerDescription":31,"updatedAt":32,"install":33,"resources":46},"01M7BMEF8Q8XSC6DC9C92CF9PH","bot",null,"Bot platform architecture (Discord, Slack, Telegram, Feishu\u002FLark, QQ, WeChat). Use when working on inbound webhooks, Chat SDK message routing, agent execution from chat platforms, queue-mode callbacks, gateway lifecycle (websocket\u002Fpolling), bot provider CRUD\u002Fcredentials, or platform-specific clients\u002Fadapters\u002Fschemas. Triggers on bot, channel, webhook, mention, Chat SDK, agent bot provider, gateway, bot-callback, qstash bot.","YYC-Cube\u002FYYC3-Knowledge-Base","YYC-Cube","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F235006543?v=4","01M79J2PH4SWD2X0825X6PN748","yyc3","01M79J2PHVK3F6ZBYT8K2SCZCW",1,"MIT","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-AI-应用工具\u002FYYC3-AI-应用工具-lobehub\u002F.agents\u002Fskills\u002Fbot\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: bot\ndescription: 'Bot platform architecture (Discord, Slack, Telegram, Feishu\u002FLark, QQ, WeChat). Use when working on inbound webhooks, Chat SDK message routing, agent execution from chat platforms, queue-mode callbacks, gateway lifecycle (websocket\u002Fpolling), bot provider CRUD\u002Fcredentials, or platform-specific clients\u002Fadapters\u002Fschemas. Triggers on bot, channel, webhook, mention, Chat SDK, agent bot provider, gateway, bot-callback, qstash bot.'\n---\n\n# Bot System\n\n> **Last updated: 2026-04-08.** Implementation evolves quickly — this doc is a map, not the source of truth. Always read the key files below to verify behavior, especially per-platform quirks. Update this doc when the architecture changes.\n\nLobeChat agents can answer inside external chat platforms. Inbound messages flow through the Chat SDK (`chat` npm package), get routed to the right agent by `(platform, applicationId)`, executed via `AiAgentService`, and replied back through a per-platform `PlatformClient`. There are **two execution modes** (in-memory vs queue\u002FQStash) and **three connection modes** (`webhook`, `websocket`, `polling`).\n\n## Supported Platforms\n\n| Platform | id         | Default mode                    | Markdown          | Edit   | Notes                                                                                  |\n| -------- | ---------- | ------------------------------- | ----------------- | ------ | -------------------------------------------------------------------------------------- |\n| Discord  | `discord`  | `websocket`                     | yes               | yes    | Persistent gateway via Chat SDK adapter; reaction-thread quirks; native slash commands |\n| Slack    | `slack`    | `websocket` (Socket Mode)       | yes (mrkdwn)      | yes    | Multi-mode — user can pick `webhook` per provider                                      |\n| Telegram | `telegram` | `webhook`                       | yes (HTML)        | yes    | `setMyCommands` menu via `registerBotCommands`                                         |\n| Feishu   | `feishu`   | `websocket` (Lark SDK WSClient) | **no** (stripped) | yes    | Multi-mode; shared client with Lark                                                    |\n| Lark     | `lark`     | `websocket`                     | **no**            | yes    | Same client\u002Fschema as Feishu, different domain                                         |\n| QQ       | `qq`       | `websocket`                     | **no**            | **no** | All replies are final-only                                                             |\n| WeChat   | `wechat`   | `polling` (iLink long-poll)     | **no**            | **no** | 10-minute gateway window                                                               |\n\n`supportsMarkdown=false` ⇒ outbound markdown is stripped to plain text via `stripMarkdown` and the AI is told not to use markdown. `supportsMessageEdit=false` ⇒ no progress edits — only the final reply is sent.\n\n**Multi-mode connection** — Slack\u002FFeishu\u002FLark\u002FQQ shipped as websocket but support `webhook` per-provider via `settings.connectionMode`. Legacy rows without that field stay on `webhook` (see `LEGACY_WEBHOOK_PLATFORMS` in `platforms\u002Futils.ts`) — **never add new platforms to that list**.\n\n## Inbound Flow (one webhook → reply)\n\n```\nPlatform server\n   │  POST \u002Fapi\u002Fagent\u002Fwebhooks\u002F[platform]\u002F[appId]\n   ▼\nroute.ts ── catch-all `[[...appId]]` route\n   │\n   ▼\nBotMessageRouter (singleton)\n   │  • lazy-loads bot per `platform:applicationId`\n   │  • merges schema defaults + provider.settings (mergeWithDefaults)\n   │  • builds Chat SDK Chat\u003Cany> with createIoRedisState (if Redis available)\n   │  • registerHandlers: onNewMention \u002F onSubscribedMessage \u002F onNewMessage(\u002F.dm)\n   │  • registerCommands: \u002Fnew (reset topic), \u002Fstop (interrupt)\n   │\n   ▼\nchatBot.webhooks[platform](req)   ← Chat SDK parses → fires events\n   │\n   ▼\nAgentBridgeService.handleMention \u002F handleSubscribedMessage\n   │  • activeThreads guard (no duplicate runs per thread)\n   │  • adds 👀 reaction (eyes), startTyping\n   │  • merges debounced\u002Fqueued skipped messages (mergeSkippedMessages)\n   │  • extractFiles (buffer → fetchData → url)\n   │  • formatPrompt (sanitize mention + speaker tag + referenced_message)\n   │\n   ├── In-memory mode ──► AiAgentService.execAgent({ stepCallbacks })\n   │       → onAfterStep edits progress message live\n   │       → onComplete edits final reply, splits via splitMessage(charLimit)\n   │\n   └── Queue mode (isQueueAgentRuntimeEnabled) ──► execAgent({ stepWebhook, completionWebhook, webhookDelivery: 'qstash' })\n           → returns immediately, callbacks land at \u002Fapi\u002Fagent\u002Fwebhooks\u002Fbot-callback\n```\n\nThe router caches loaded bots in memory. Cache is **invalidated** by `BotMessageRouter.invalidateBot(platform, appId)` whenever the TRPC `update`\u002F`delete` mutations run, so new credentials\u002Fsettings take effect on the next webhook.\n\n## Execution Modes\n\n### In-memory (default)\n\n`AgentBridgeService.executeWithInMemoryCallbacks` wraps `execAgent` with `stepCallbacks`. Lives in one process — Promise-based wait, 30-min timeout, edits the same `progressMessage` after every step. Topic title is summarized inline via `SystemAgentService`.\n\n### Queue (`isQueueAgentRuntimeEnabled`)\n\n`AgentBridgeService.executeWithWebhooks`:\n\n1. Posts the `renderStart` placeholder, captures `progressMessageId`.\n2. Calls `execAgent` with `stepWebhook` and `completionWebhook` pointing at `${INTERNAL_APP_URL ?? APP_URL}\u002Fapi\u002Fagent\u002Fwebhooks\u002Fbot-callback`, plus `webhookDelivery: 'qstash'`.\n3. Returns immediately; the bridge `finally` block keeps the active-thread marker held until the `completion` callback fires.\n\n`\u002Fapi\u002Fagent\u002Fwebhooks\u002Fbot-callback\u002Froute.ts` verifies the QStash signature and hands off to `BotCallbackService.handleCallback`:\n\n- `type: 'step'` → `handleStep` re-renders `renderStepProgress`, edits `progressMessageId` (skipped if `displayToolCalls=false` or platform `supportsMessageEdit=false`).\n- `type: 'completion'` → `handleCompletion` writes the final reply (or error\u002Finterrupted message), removes the 👀 reaction, clears active-thread tracker, fires async `summarizeTopicTitle`.\n\n`BotCallbackService.createMessenger` reloads provider + credentials from DB and rebuilds a `PlatformClient` per call (no in-memory state).\n\n## Commands\n\nDefined in `BotMessageRouter.buildCommands` and registered via two paths:\n\n- **Native slash commands** (Slack\u002FDiscord): `bot.onSlashCommand('\u002F\u003Cname>', ...)`\n- **Text-based fallback** (Telegram\u002FFeishu\u002FQQ\u002FLark\u002FWeChat): `bot.onNewMessage(\u002F^\\\u002F(new|stop)(\\s|$|@)\u002F, ...)` plus a per-mention `tryDispatch` so commands work even before subscribe.\n\nBuilt-in commands:\n\n- `\u002Fnew` — clears `topicId` in thread state, next message starts a fresh topic.\n- `\u002Fstop` — interrupts the active execution (calls `AiAgentService.interruptTask` if `operationId` is known; otherwise queues a deferred stop via `requestStop`\u002F`pendingStopThreads`, also aborts the startup phase via `startupControllers`).\n\nTo add a command, append to `buildCommands` — it auto-registers everywhere; on Telegram it also surfaces in the `\u002F` menu via `client.registerBotCommands` → `setMyCommands`.\n\n## Active-thread State (statics on `AgentBridgeService`)\n\n- `activeThreads: Set\u003CthreadId>` — prevents duplicate runs per thread (must guard before stale-topic check, otherwise concurrent messages can drop).\n- `activeOperations: Map\u003CthreadId, operationId>` — needed by `\u002Fstop` once `execAgent` returns.\n- `startupControllers: Map\u003CthreadId, AbortController>` — cancels pre-`operationId` work (topic\u002Ftool prep).\n- `pendingStopThreads: Set\u003CthreadId>` — `\u002Fstop` arrived before `operationId` existed; consumed once available.\n\nIn **queue mode**, the bridge `finally` skips cleanup so the marker persists until `BotCallbackService.handleCompletion` calls `clearActiveThread`.\n\n## Topic Lifecycle in Threads\n\n- `handleMention` always treats the message as the start of a new conversation.\n- `handleSubscribedMessage` reads `topicId` from `thread.state`. If the topic is stale (`> 4 hours` since `updatedAt`), state is cleared and it retries as a fresh mention.\n- If `execAgent` fails with a Postgres FK violation on `topic_id` (cached topic was deleted), the bridge clears state and retries as a mention.\n- `subscribe()` is gated by `client.shouldSubscribe(threadId)` — Discord top-level channels return `false` so we don't follow up there.\n\n## Attachments\n\n`AgentBridgeService.extractFiles` resolves attachments in priority order:\n\n1. `att.buffer` — already downloaded by the adapter (WeChat\u002FFeishu inbound).\n2. `att.fetchData()` — adapter-provided lazy download with auth (Telegram, Slack, Feishu history). **Required** when URLs are token-protected — naive `fetch(url)` later in `ingestAttachment.ts` has no credentials.\n3. `att.url` — public CDN fallback (Discord, public QQ).\n\n`inferMimeType` \u002F `inferName` patch Telegram-style `photo` payloads (no `mimeType`\u002F`name` from Bot API → defaults to `image\u002Fjpeg`) so vision models actually see them. Quoted-message attachments are also pulled from `raw.referenced_message.attachments` (Discord).\n\n## Concurrency\n\n`settings.concurrency` is `'queue'` or `'debounce'`:\n\n- `debounce` → Chat SDK debounces inbound messages by `debounceMs`; `mergeSkippedMessages` joins skipped texts\u002Fattachments into the current message before handing to the agent.\n- `queue` → Chat SDK serializes per-thread; the bridge's own `activeThreads` set is still required because in queue mode the SDK lock releases before the agent finishes.\n\n## Gateway (persistent platforms)\n\nWebhook platforms run fine in serverless functions. Persistent platforms (`websocket`, `polling`) need a long-running listener — that's the **gateway**.\n\n**`GatewayService.startClient(platform, appId, userId)`** (`src\u002Fserver\u002Fservices\u002Fgateway\u002Findex.ts`):\n\n- On Vercel + persistent mode → `BotConnectQueue.push` (Redis hash) and mark runtime status `queued`. The cron picks it up.\n- On Vercel + webhook mode → start the client inline (one HTTP call).\n- Off-Vercel → `GatewayManager` singleton holds long-lived clients in process.\n\n**`GET \u002Fapi\u002Fagent\u002Fgateway\u002Froute.ts`** (cron, `Bearer ${CRON_SECRET}`):\n\n- Iterates registered platforms and starts every enabled persistent provider with `durationMs = 10min`, then in `after(...)` polls `BotConnectQueue` every 30s for new connect requests, until the window expires.\n- `getEffectiveConnectionMode(platform, settings)` is the only place that resolves per-provider mode — respect it everywhere.\n\n**`POST \u002Fapi\u002Fagent\u002Fgateway\u002Fstart\u002Froute.ts`** is the non-Vercel `ensureRunning` entry point (`Bearer ${KEY_VAULTS_SECRET}`).\n\n**Runtime status** is stored in Redis at `bot:runtime-status:platform:appId` with TTL ≈ `durationMs + 60s`. States: `starting | connected | disconnected | failed | queued`. Updated by each `PlatformClient.start\u002Fstop` and by the gateway service.\n\n## Platform Definitions\n\nEach platform exposes a `PlatformDefinition` registered in `platforms\u002Findex.ts`:\n\n```ts\n{\n  id: 'discord',\n  name: 'Discord',\n  connectionMode: 'websocket',          \u002F\u002F recommended default\n  schema: FieldSchema[],                 \u002F\u002F applicationId + credentials + settings\n  clientFactory: new DiscordClientFactory(),\n  supportsMarkdown?: boolean,            \u002F\u002F default true\n  supportsMessageEdit?: boolean,         \u002F\u002F default true\n  documentation?: { portalUrl, setupGuideUrl },\n}\n```\n\n`schema` drives both server validation (`mergeWithDefaults`, `extractDefaults`) **and** the auto-generated UI form. Top-level keys `applicationId` \u002F `credentials` \u002F `settings` map to DB columns. Common settings fields live in `platforms\u002Fconst.ts` (`displayToolCallsField`, `serverIdField`, `userIdField`).\n\nEach platform implements `PlatformClient` (see `platforms\u002Ftypes.ts`):\n\n- Lifecycle: `start(opts?)`, `stop()`\n- Inbound: `createAdapter()` → Chat SDK adapter map\n- Outbound: `getMessenger(platformThreadId)` → `{ createMessage, editMessage, removeReaction, triggerTyping, updateThreadName? }`\n- Formatting: `formatMarkdown?`, `formatReply?` (usage-stats footer when `showUsageStats`)\n- Helpers: `extractChatId`, `parseMessageId`, `sanitizeUserInput`, `shouldSubscribe`, `resolveReactionThreadId`\n- Optional patches: `applyChatPatches(chatBot)` (Discord uses this for `forwardedInteractions` + `threadRecovery`)\n- Optional menu: `registerBotCommands(commands)` (Telegram `setMyCommands`)\n\n`ClientFactory.validateCredentials` is called from the TRPC `testConnection` mutation — implement it to hit the platform API and return useful per-field errors.\n\n## Database\n\n**Schema** (`packages\u002Fdatabase\u002Fsrc\u002Fschemas\u002FagentBotProvider.ts`):\n\n```ts\nagent_bot_providers (\n  id uuid pk,\n  agent_id text fk → agents.id (cascade),\n  user_id text fk → users.id (cascade),\n  platform varchar(50),                  \u002F\u002F 'discord' | 'slack' | …\n  application_id varchar(255),\n  credentials text,                      \u002F\u002F KeyVaults-encrypted JSON\n  settings jsonb default '{}',\n  enabled boolean default true,\n  …timestamps\n)\nunique (platform, application_id)\n```\n\n**Model** (`packages\u002Fdatabase\u002Fsrc\u002Fmodels\u002FagentBotProvider.ts`):\n\n- User-scoped: `create \u002F update \u002F delete \u002F query \u002F findById \u002F findByAgentId \u002F findEnabledByApplicationId`. Credentials are encrypted\u002Fdecrypted via the injected `KeyVaultsGateKeeper`.\n- Static (system-wide): `findByPlatformAndAppId`, `findEnabledByPlatform` — used by webhook routing & gateway sync, since they don't have a user context yet.\n\n**TRPC router** (`src\u002Fserver\u002Frouters\u002Flambda\u002FagentBotProvider.ts`):\n\n| Procedure                                    | Notes                                                                                       |              |\n| -------------------------------------------- | ------------------------------------------------------------------------------------------- | ------------ |\n| `listPlatforms`                              | Returns `SerializedPlatformDefinition[]` (no `clientFactory`)                               |              |\n| `create` \u002F `update` \u002F `delete`               | Calls `BotMessageRouter.invalidateBot` + `GatewayService.stopClient` so changes take effect |              |\n| `list` \u002F `getByAgentId` \u002F `getRuntimeStatus` | Decorate rows with Redis runtime status                                                     |              |\n| `connectBot`                                 | Returns \\`{ status: 'started'                                                               | 'queued' }\\` |\n| `testConnection`                             | Calls `clientFactory.validateCredentials`                                                   |              |\n| `wechatGetQrCode` \u002F `wechatPollQrStatus`     | iLink onboarding flow                                                                       |              |\n\nClient service: `src\u002Fservices\u002FagentBotProvider.ts`. Store actions: `src\u002Fstore\u002Fagent\u002Fslices\u002Fbot\u002Faction.ts`. UI: `src\u002Froutes\u002F(main)\u002Fagent\u002Fchannel\u002F{list,detail}` — settings form is auto-generated from each platform's `schema`.\n\n## Reply Templates\n\n`src\u002Fserver\u002Fservices\u002Fbot\u002FreplyTemplate.ts` exports `renderStart`, `renderStepProgress`, `renderFinalReply`, `renderError`, `renderStopped`, `splitMessage`. Step progress carries elapsed time, last LLM content, last tools, totals; final reply uses `client.formatMarkdown` then `client.formatReply` (which optionally appends `formatUsageStats`). `splitMessage(text, charLimit)` chunks at paragraph → line → hard cut.\n\n`src\u002Fserver\u002Fservices\u002Fbot\u002FackPhrases\u002F` provides randomized ack phrases.\n\n## Key Files\n\n```plaintext\nWebhook routes:\n  src\u002Fapp\u002F(backend)\u002Fapi\u002Fagent\u002Fwebhooks\u002F[platform]\u002F[[...appId]]\u002Froute.ts  — inbound catch-all\n  src\u002Fapp\u002F(backend)\u002Fapi\u002Fagent\u002Fwebhooks\u002Fbot-callback\u002Froute.ts             — qstash bot callback\n  src\u002Fapp\u002F(backend)\u002Fapi\u002Fagent\u002Fgateway\u002Froute.ts                           — cron gateway (10min window)\n  src\u002Fapp\u002F(backend)\u002Fapi\u002Fagent\u002Fgateway\u002Fstart\u002Froute.ts                     — non-Vercel ensureRunning\n\nBot service:\n  src\u002Fserver\u002Fservices\u002Fbot\u002Findex.ts                          — barrel\n  src\u002Fserver\u002Fservices\u002Fbot\u002FBotMessageRouter.ts               — lazy bot loading + handler registration + commands\n  src\u002Fserver\u002Fservices\u002Fbot\u002FAgentBridgeService.ts             — Chat SDK ↔ AiAgentService bridge, both exec modes\n  src\u002Fserver\u002Fservices\u002Fbot\u002FBotCallbackService.ts             — qstash callback handler\n  src\u002Fserver\u002Fservices\u002Fbot\u002FformatPrompt.ts                   — speaker tag + referenced_message + sanitize\n  src\u002Fserver\u002Fservices\u002Fbot\u002FreplyTemplate.ts                  — render*\u002FsplitMessage\n  src\u002Fserver\u002Fservices\u002Fbot\u002FackPhrases\u002F                       — randomized acks\n  src\u002Fserver\u002Fservices\u002Fbot\u002F__tests__\u002F                        — unit tests for the above\n\nPlatform abstraction:\n  src\u002Fserver\u002Fservices\u002Fbot\u002Fplatforms\u002Findex.ts                — registry singleton + exports\n  src\u002Fserver\u002Fservices\u002Fbot\u002Fplatforms\u002Ftypes.ts                — PlatformClient\u002FDefinition\u002FFieldSchema\u002FClientFactory\n  src\u002Fserver\u002Fservices\u002Fbot\u002Fplatforms\u002Fregistry.ts             — PlatformRegistry class\n  src\u002Fserver\u002Fservices\u002Fbot\u002Fplatforms\u002Futils.ts                — mergeWithDefaults, getEffectiveConnectionMode, formatUsageStats, runtimeKey\n  src\u002Fserver\u002Fservices\u002Fbot\u002Fplatforms\u002Fconst.ts                — shared FieldSchema fragments (displayToolCalls, serverId, userId)\n  src\u002Fserver\u002Fservices\u002Fbot\u002Fplatforms\u002FstripMarkdown.ts        — used by no-markdown platforms\n\nPer-platform (each ships definition.ts, schema.ts, client.ts, const.ts, protocol-spec.md):\n  src\u002Fserver\u002Fservices\u002Fbot\u002Fplatforms\u002Fdiscord\u002F                — websocket gateway + chat patches\n  src\u002Fserver\u002Fservices\u002Fbot\u002Fplatforms\u002Fslack\u002F                  — multi-mode (Socket Mode \u002F webhook), markdownToMrkdwn\n  src\u002Fserver\u002Fservices\u002Fbot\u002Fplatforms\u002Ftelegram\u002F               — webhook, markdownToHTML, registerBotCommands\n  src\u002Fserver\u002Fservices\u002Fbot\u002Fplatforms\u002Ffeishu\u002F                 — feishu + lark share client\u002Fschema (definitions\u002F{feishu,lark,shared}.ts)\n  src\u002Fserver\u002Fservices\u002Fbot\u002Fplatforms\u002Fqq\u002F                     — websocket, no markdown, no edit\n  src\u002Fserver\u002Fservices\u002Fbot\u002Fplatforms\u002Fwechat\u002F                 — long-poll, no markdown, no edit\n\nGateway:\n  src\u002Fserver\u002Fservices\u002Fgateway\u002Findex.ts                      — GatewayService (Vercel-aware startClient\u002FstopClient)\n  src\u002Fserver\u002Fservices\u002Fgateway\u002FGatewayManager.ts             — long-running client registry (non-Vercel)\n  src\u002Fserver\u002Fservices\u002Fgateway\u002FbotConnectQueue.ts            — Redis hash queue with TTL\n  src\u002Fserver\u002Fservices\u002Fgateway\u002FruntimeStatus.ts              — Redis bot:runtime-status keys\n\nDatabase:\n  packages\u002Fdatabase\u002Fsrc\u002Fschemas\u002FagentBotProvider.ts         — agent_bot_providers table\n  packages\u002Fdatabase\u002Fsrc\u002Fmodels\u002FagentBotProvider.ts          — encrypted CRUD + system-wide finders\n\nTRPC + client:\n  src\u002Fserver\u002Frouters\u002Flambda\u002FagentBotProvider.ts             — TRPC router\n  src\u002Fservices\u002FagentBotProvider.ts                          — client wrapper\n  src\u002Fstore\u002Fagent\u002Fslices\u002Fbot\u002Faction.ts                      — Zustand actions\n\nUI:\n  src\u002Froutes\u002F(main)\u002Fagent\u002Fchannel\u002Flist.tsx                  — channel list\n  src\u002Froutes\u002F(main)\u002Fagent\u002Fchannel\u002Fdetail\u002F                   — auto-generated form (Header\u002FBody\u002FFooter)\n  src\u002Froutes\u002F(main)\u002Fagent\u002Fchannel\u002Fconst.ts                  — platform icons\n\nTypes & runtime status:\n  src\u002Ftypes\u002FbotRuntimeStatus.ts                             — BOT_RUNTIME_STATUSES enum + snapshot type\n```\n\n## Adding a New Platform\n\n1. Create `src\u002Fserver\u002Fservices\u002Fbot\u002Fplatforms\u002F\u003Cid>\u002F`:\n   - `definition.ts` — `PlatformDefinition` registered in `platforms\u002Findex.ts`\n   - `schema.ts` — `FieldSchema[]` (`applicationId` + `credentials` + `settings`); reuse fragments from `..\u002Fconst.ts`\n   - `client.ts` — `class XClientFactory extends ClientFactory` returning a `PlatformClient` (lifecycle + adapter + messenger + helpers)\n   - `const.ts` — `DEFAULT_X_CONNECTION_MODE`, history limits, etc.\n   - `protocol-spec.md` — protocol notes (every existing platform has one)\n2. Pick the right `connectionMode` — webhook is much simpler if the platform supports it.\n3. If the platform can't render markdown, set `supportsMarkdown: false` and implement `formatMarkdown` via `stripMarkdown`.\n4. If it can't edit messages, set `supportsMessageEdit: false` — `BotCallbackService` will skip step edits and only send the final reply.\n5. Implement `validateCredentials` so the UI's \"Test connection\" button gives useful errors.\n6. Add the platform icon in `src\u002Froutes\u002F(main)\u002Fagent\u002Fchannel\u002Fconst.ts` and register the platform in `src\u002Fserver\u002Fservices\u002Fbot\u002Fplatforms\u002Findex.ts`.\n7. Add i18n keys under `channel.*` in `src\u002Flocales\u002Fdefault\u002Fsetting.ts` (or wherever the channel namespace lives) — the schema's `label`\u002F`description`\u002F`placeholder`\u002F`enumLabels` are i18n keys.\n","# Bot System\n\n> **Last updated: 2026-04-08.** Implementation evolves quickly — this doc is a map, not the source of truth. Always read the key files below to verify behavior, especially per-platform quirks. Update this doc when the architecture changes.\n\nLobeChat agents can answer inside external chat platforms. Inbound messages flow through the Chat SDK (`chat` npm package), get routed to the right agent by `(platform, applicationId)`, executed via `AiAgentService`, and replied back through a per-platform `PlatformClient`. There are **two execution modes** (in-memory vs queue\u002FQStash) and **three connection modes** (`webhook`, `websocket`, `polling`).\n\n## Supported Platforms\n\n| Platform | id         | Default mode                    | Markdown          | Edit   | Notes                                                                                  |\n| -------- | ---------- | ------------------------------- | ----------------- | ------ | -------------------------------------------------------------------------------------- |\n| Discord  | `discord`  | `websocket`                     | yes               | yes    | Persistent gateway via Chat SDK adapter; reaction-thread quirks; native slash commands |\n| Slack    | `slack`    | `websocket` (Socket Mode)       | yes (mrkdwn)      | yes    | Multi-mode — user can pick `webhook` per provider                                      |\n| Telegram | `telegram` | `webhook`                       | yes (HTML)        | yes    | `setMyCommands` menu via `registerBotCommands`                                         |\n| Feishu   | `feishu`   | `websocket` (Lark SDK WSClient) | **no** (stripped) | yes    | Multi-mode; shared client with Lark                                                    |\n| Lark     | `lark`     | `websocket`                     | **no**            | yes    | Same client\u002Fschema as Feishu, different domain                                         |\n| QQ       | `qq`       | `websocket`                     | **no**            | **no** | All replies are final-only                                                             |\n| WeChat   | `wechat`   | `polling` (iLink long-poll)     | **no**            | **no** | 10-minute gateway window                                                               |\n\n`supportsMarkdown=false` ⇒ outbound markdown is stripped to plain text via `stripMarkdown` and the AI is told not to use markdown. `supportsMessageEdit=false` ⇒ no progress edits — only the final reply is sent.\n\n**Multi-mode connection** — Slack\u002FFeishu\u002FLark\u002FQQ shipped as websocket but support `webhook` per-provider via `settings.connectionMode`. Legacy rows without that field stay on `webhook` (see `LEGACY_WEBHOOK_PLATFORMS` in `platforms\u002Futils.ts`) — **never add new platforms to that list**.\n\n## Inbound Flow (one webhook → reply)\n\n```\nPlatform server\n   │  POST \u002Fapi\u002Fagent\u002Fwebhooks\u002F[platform]\u002F[appId]\n   ▼\nroute.ts ── catch-all `[[...appId]]` route\n   │\n   ▼\nBotMessageRouter (singleton)\n   │  • lazy-loads bot per `platform:applicationId`\n   │  • merges schema defaults + provider.settings (mergeWithDefaults)\n   │  • builds Chat SDK Chat\u003Cany> with createIoRedisState (if Redis available)\n   │  • registerHandlers: onNewMention \u002F onSubscribedMessage \u002F onNewMessage(\u002F.dm)\n   │  • registerCommands: \u002Fnew (reset topic), \u002Fstop (interrupt)\n   │\n   ▼\nchatBot.webhooks[platform](req)   ← Chat SDK parses → fires events\n   │\n   ▼\nAgentBridgeService.handleMention \u002F handleSubscribedMessage\n   │  • activeThreads guard (no duplicate runs per thread)\n   │  • adds 👀 reaction (eyes), startTyping\n   │  • merges debounced\u002Fqueued skipped messages (mergeSkippedMessages)\n   │  • extractFiles (buffer → fetchData → url)\n   │  • formatPrompt (sanitize mention + speaker tag + referenced_message)\n   │\n   ├── In-memory mode ──► AiAgentService.execAgent({ stepCallbacks })\n   │       → onAfterStep edits progress message live\n   │       → onComplete edits final reply, splits via splitMessage(charLimit)\n   │\n   └── Queue mode (isQueueAgentRuntimeEnabled) ──► execAgent({ stepWebhook, completionWebhook, webhookDelivery: 'qstash' })\n           → returns immediately, callbacks land at \u002Fapi\u002Fagent\u002Fwebhooks\u002Fbot-callback\n```\n\nThe router caches loaded bots in memory. Cache is **invalidated** by `BotMessageRouter.invalidateBot(platform, appId)` whenever the TRPC `update`\u002F`delete` mutations run, so new credentials\u002Fsettings take effect on the next webhook.\n\n## Execution Modes\n\n### In-memory (default)\n\n`AgentBridgeService.executeWithInMemoryCallbacks` wraps `execAgent` with `stepCallbacks`. Lives in one process — Promise-based wait, 30-min timeout, edits the same `progressMessage` after every step. Topic title is summarized inline via `SystemAgentService`.\n\n### Queue (`isQueueAgentRuntimeEnabled`)\n\n`AgentBridgeService.executeWithWebhooks`:\n\n1. Posts the `renderStart` placeholder, captures `progressMessageId`.\n2. Calls `execAgent` with `stepWebhook` and `completionWebhook` pointing at `${INTERNAL_APP_URL ?? APP_URL}\u002Fapi\u002Fagent\u002Fwebhooks\u002Fbot-callback`, plus `webhookDelivery: 'qstash'`.\n3. Returns immediately; the bridge `finally` block keeps the active-thread marker held until the `completion` callback fires.\n\n`\u002Fapi\u002Fagent\u002Fwebhooks\u002Fbot-callback\u002Froute.ts` verifies the QStash signature and hands off to `BotCallbackService.handleCallback`:\n\n- `type: 'step'` → `handleStep` re-renders `renderStepProgress`, edits `progressMessageId` (skipped if `displayToolCalls=false` or platform `supportsMessageEdit=false`).\n- `type: 'completion'` → `handleCompletion` writes the final reply (or error\u002Finterrupted message), removes the 👀 reaction, clears active-thread tracker, fires async `summarizeTopicTitle`.\n\n`BotCallbackService.createMessenger` reloads provider + credentials from DB and rebuilds a `PlatformClient` per call (no in-memory state).\n\n## Commands\n\nDefined in `BotMessageRouter.buildCommands` and registered via two paths:\n\n- **Native slash commands** (Slack\u002FDiscord): `bot.onSlashCommand('\u002F\u003Cname>', ...)`\n- **Text-based fallback** (Telegram\u002FFeishu\u002FQQ\u002FLark\u002FWeChat): `bot.onNewMessage(\u002F^\\\u002F(new|stop)(\\s|$|@)\u002F, ...)` plus a per-mention `tryDispatch` so commands work even before subscribe.\n\nBuilt-in commands:\n\n- `\u002Fnew` — clears `topicId` in thread state, next message starts a fresh topic.\n- `\u002Fstop` — interrupts the active execution (calls `AiAgentService.interruptTask` if `operationId` is known; otherwise queues a deferred stop via `requestStop`\u002F`pendingStopThreads`, also aborts the startup phase via `startupControllers`).\n\nTo add a command, append to `buildCommands` — it auto-registers everywhere; on Telegram it also surfaces in the `\u002F` menu via `client.registerBotCommands` → `setMyCommands`.\n\n## Active-thread State (statics on `AgentBridgeService`)\n\n- `activeThreads: Set\u003CthreadId>` — prevents duplicate runs per thread (must guard before stale-topic check, otherwise concurrent messages can drop).\n- `activeOperations: Map\u003CthreadId, operationId>` — needed by `\u002Fstop` once `execAgent` returns.\n- `startupControllers: Map\u003CthreadId, AbortController>` — cancels pre-`operationId` work (topic\u002Ftool prep).\n- `pendingStopThreads: Set\u003CthreadId>` — `\u002Fstop` arrived before `operationId` existed; consumed once available.\n\nIn **queue mode**, the bridge `finally` skips cleanup so the marker persists until `BotCallbackService.handleCompletion` calls `clearActiveThread`.\n\n## Topic Lifecycle in Threads\n\n- `handleMention` always treats the message as the start of a new conversation.\n- `handleSubscribedMessage` reads `topicId` from `thread.state`. If the topic is stale (`> 4 hours` since `updatedAt`), state is cleared and it retries as a fresh mention.\n- If `execAgent` fails with a Postgres FK violation on `topic_id` (cached topic was deleted), the bridge clears state and retries as a mention.\n- `subscribe()` is gated by `client.shouldSubscribe(threadId)` — Discord top-level channels return `false` so we don't follow up there.\n\n## Attachments\n\n`AgentBridgeService.extractFiles` resolves attachments in priority order:\n\n1. `att.buffer` — already downloaded by the adapter (WeChat\u002FFeishu inbound).\n2. `att.fetchData()` — adapter-provided lazy download with auth (Telegram, Slack, Feishu history). **Required** when URLs are token-protected — naive `fetch(url)` later in `ingestAttachment.ts` has no credentials.\n3. `att.url` — public CDN fallback (Discord, public QQ).\n\n`inferMimeType` \u002F `inferName` patch Telegram-style `photo` payloads (no `mimeType`\u002F`name` from Bot API → defaults to `image\u002Fjpeg`) so vision models actually see them. Quoted-message attachments are also pulled from `raw.referenced_message.attachments` (Discord).\n\n## Concurrency\n\n`settings.concurrency` is `'queue'` or `'debounce'`:\n\n- `debounce` → Chat SDK debounces inbound messages by `debounceMs`; `mergeSkippedMessages` joins skipped texts\u002Fattachments into the current message before handing to the agent.\n- `queue` → Chat SDK serializes per-thread; the bridge's own `activeThreads` set is still required because in queue mode the SDK lock releases before the agent finishes.\n\n## Gateway (persistent platforms)\n\nWebhook platforms run fine in serverless functions. Persistent platforms (`websocket`, `polling`) need a long-running listener — that's the **gateway**.\n\n**`GatewayService.startClient(platform, appId, userId)`** (`src\u002Fserver\u002Fservices\u002Fgateway\u002Findex.ts`):\n\n- On Vercel + persistent mode → `BotConnectQueue.push` (Redis hash) and mark runtime status `queued`. The cron picks it up.\n- On Vercel + webhook mode → start the client inline (one HTTP call).\n- Off-Vercel → `GatewayManager` singleton holds long-lived clients in process.\n\n**`GET \u002Fapi\u002Fagent\u002Fgateway\u002Froute.ts`** (cron, `Bearer ${CRON_SECRET}`):\n\n- Iterates registered platforms and starts every enabled persistent provider with `durationMs = 10min`, then in `after(...)` polls `BotConnectQueue` every 30s for new connect requests, until the window expires.\n- `getEffectiveConnectionMode(platform, settings)` is the only place that resolves per-provider mode — respect it everywhere.\n\n**`POST \u002Fapi\u002Fagent\u002Fgateway\u002Fstart\u002Froute.ts`** is the non-Vercel `ensureRunning` entry point (`Bearer ${KEY_VAULTS_SECRET}`).\n\n**Runtime status** is stored in Redis at `bot:runtime-status:platform:appId` with TTL ≈ `durationMs + 60s`. States: `starting | connected | disconnected | failed | queued`. Updated by each `PlatformClient.start\u002Fstop` and by the gateway service.\n\n## Platform Definitions\n\nEach platform exposes a `PlatformDefinition` registered in `platforms\u002Findex.ts`:\n\n```ts\n{\n  id: 'discord',\n  name: 'Discord',\n  connectionMode: 'websocket',          \u002F\u002F recommended default\n  schema: FieldSchema[],                 \u002F\u002F applicationId + credentials + settings\n  clientFactory: new DiscordClientFactory(),\n  supportsMarkdown?: boolean,            \u002F\u002F default true\n  supportsMessageEdit?: boolean,         \u002F\u002F default true\n  documentation?: { portalUrl, setupGuideUrl },\n}\n```\n\n`schema` drives both server validation (`mergeWithDefaults`, `extractDefaults`) **and** the auto-generated UI form. Top-level keys `applicationId` \u002F `credentials` \u002F `settings` map to DB columns. Common settings fields live in `platforms\u002Fconst.ts` (`displayToolCallsField`, `serverIdField`, `userIdField`).\n\nEach platform implements `PlatformClient` (see `platforms\u002Ftypes.ts`):\n\n- Lifecycle: `start(opts?)`, `stop()`\n- Inbound: `createAdapter()` → Chat SDK adapter map\n- Outbound: `getMessenger(platformThreadId)` → `{ createMessage, editMessage, removeReaction, triggerTyping, updateThreadName? }`\n- Formatting: `formatMarkdown?`, `formatReply?` (usage-stats footer when `showUsageStats`)\n- Helpers: `extractChatId`, `parseMessageId`, `sanitizeUserInput`, `shouldSubscribe`, `resolveReactionThreadId`\n- Optional patches: `applyChatPatches(chatBot)` (Discord uses this for `forwardedInteractions` + `threadRecovery`)\n- Optional menu: `registerBotCommands(commands)` (Telegram `setMyCommands`)\n\n`ClientFactory.validateCredentials` is called from the TRPC `testConnection` mutation — implement it to hit the platform API and return useful per-field errors.\n\n## Database\n\n**Schema** (`packages\u002Fdatabase\u002Fsrc\u002Fschemas\u002FagentBotProvider.ts`):\n\n```ts\nagent_bot_providers (\n  id uuid pk,\n  agent_id text fk → agents.id (cascade),\n  user_id text fk → users.id (cascade),\n  platform varchar(50),                  \u002F\u002F 'discord' | 'slack' | …\n  application_id varchar(255),\n  credentials text,                      \u002F\u002F KeyVaults-encrypted JSON\n  settings jsonb default '{}',\n  enabled boolean default true,\n  …timestamps\n)\nunique (platform, application_id)\n```\n\n**Model** (`packages\u002Fdatabase\u002Fsrc\u002Fmodels\u002FagentBotProvider.ts`):\n\n- User-scoped: `create \u002F update \u002F delete \u002F query \u002F findById \u002F findByAgentId \u002F findEnabledByApplicationId`. Credentials are encrypted\u002Fdecrypted via the injected `KeyVaultsGateKeeper`.\n- Static (system-wide): `findByPlatformAndAppId`, `findEnabledByPlatform` — used by webhook routing & gateway sync, since they don't have a user context yet.\n\n**TRPC router** (`src\u002Fserver\u002Frouters\u002Flambda\u002FagentBotProvider.ts`):\n\n| Procedure                                    | Notes                                                                                       |              |\n| -------------------------------------------- | ------------------------------------------------------------------------------------------- | ------------ |\n| `listPlatforms`                              | Returns `SerializedPlatformDefinition[]` (no `clientFactory`)                               |              |\n| `create` \u002F `update` \u002F `delete`               | Calls `BotMessageRouter.invalidateBot` + `GatewayService.stopClient` so changes take effect |              |\n| `list` \u002F `getByAgentId` \u002F `getRuntimeStatus` | Decorate rows with Redis runtime status                                                     |              |\n| `connectBot`                                 | Returns \\`{ status: 'started'                                                               | 'queued' }\\` |\n| `testConnection`                             | Calls `clientFactory.validateCredentials`                                                   |              |\n| `wechatGetQrCode` \u002F `wechatPollQrStatus`     | iLink onboarding flow                                                                       |              |\n\nClient service: `src\u002Fservices\u002FagentBotProvider.ts`. Store actions: `src\u002Fstore\u002Fagent\u002Fslices\u002Fbot\u002Faction.ts`. UI: `src\u002Froutes\u002F(main)\u002Fagent\u002Fchannel\u002F{list,detail}` — settings form is auto-generated from each platform's `schema`.\n\n## Reply Templates\n\n`src\u002Fserver\u002Fservices\u002Fbot\u002FreplyTemplate.ts` exports `renderStart`, `renderStepProgress`, `renderFinalReply`, `renderError`, `renderStopped`, `splitMessage`. Step progress carries elapsed time, last LLM content, last tools, totals; final reply uses `client.formatMarkdown` then `client.formatReply` (which optionally appends `formatUsageStats`). `splitMessage(text, charLimit)` chunks at paragraph → line → hard cut.\n\n`src\u002Fserver\u002Fservices\u002Fbot\u002FackPhrases\u002F` provides randomized ack phrases.\n\n## Key Files\n\n```plaintext\nWebhook routes:\n  src\u002Fapp\u002F(backend)\u002Fapi\u002Fagent\u002Fwebhooks\u002F[platform]\u002F[[...appId]]\u002Froute.ts  — inbound catch-all\n  src\u002Fapp\u002F(backend)\u002Fapi\u002Fagent\u002Fwebhooks\u002Fbot-callback\u002Froute.ts             — qstash bot callback\n  src\u002Fapp\u002F(backend)\u002Fapi\u002Fagent\u002Fgateway\u002Froute.ts                           — cron gateway (10min window)\n  src\u002Fapp\u002F(backend)\u002Fapi\u002Fagent\u002Fgateway\u002Fstart\u002Froute.ts                     — non-Vercel ensureRunning\n\nBot service:\n  src\u002Fserver\u002Fservices\u002Fbot\u002Findex.ts                          — barrel\n  src\u002Fserver\u002Fservices\u002Fbot\u002FBotMessageRouter.ts               — lazy bot loading + handler registration + commands\n  src\u002Fserver\u002Fservices\u002Fbot\u002FAgentBridgeService.ts             — Chat SDK ↔ AiAgentService bridge, both exec modes\n  src\u002Fserver\u002Fservices\u002Fbot\u002FBotCallbackService.ts             — qstash callback handler\n  src\u002Fserver\u002Fservices\u002Fbot\u002FformatPrompt.ts                   — speaker tag + referenced_message + sanitize\n  src\u002Fserver\u002Fservices\u002Fbot\u002FreplyTemplate.ts                  — render*\u002FsplitMessage\n  src\u002Fserver\u002Fservices\u002Fbot\u002FackPhrases\u002F                       — randomized acks\n  src\u002Fserver\u002Fservices\u002Fbot\u002F__tests__\u002F                        — unit tests for the above\n\nPlatform abstraction:\n  src\u002Fserver\u002Fservices\u002Fbot\u002Fplatforms\u002Findex.ts                — registry singleton + exports\n  src\u002Fserver\u002Fservices\u002Fbot\u002Fplatforms\u002Ftypes.ts                — PlatformClient\u002FDefinition\u002FFieldSchema\u002FClientFactory\n  src\u002Fserver\u002Fservices\u002Fbot\u002Fplatforms\u002Fregistry.ts             — PlatformRegistry class\n  src\u002Fserver\u002Fservices\u002Fbot\u002Fplatforms\u002Futils.ts                — mergeWithDefaults, getEffectiveConnectionMode, formatUsageStats, runtimeKey\n  src\u002Fserver\u002Fservices\u002Fbot\u002Fplatforms\u002Fconst.ts                — shared FieldSchema fragments (displayToolCalls, serverId, userId)\n  src\u002Fserver\u002Fservices\u002Fbot\u002Fplatforms\u002FstripMarkdown.ts        — used by no-markdown platforms\n\nPer-platform (each ships definition.ts, schema.ts, client.ts, const.ts, protocol-spec.md):\n  src\u002Fserver\u002Fservices\u002Fbot\u002Fplatforms\u002Fdiscord\u002F                — websocket gateway + chat patches\n  src\u002Fserver\u002Fservices\u002Fbot\u002Fplatforms\u002Fslack\u002F                  — multi-mode (Socket Mode \u002F webhook), markdownToMrkdwn\n  src\u002Fserver\u002Fservices\u002Fbot\u002Fplatforms\u002Ftelegram\u002F               — webhook, markdownToHTML, registerBotCommands\n  src\u002Fserver\u002Fservices\u002Fbot\u002Fplatforms\u002Ffeishu\u002F                 — feishu + lark share client\u002Fschema (definitions\u002F{feishu,lark,shared}.ts)\n  src\u002Fserver\u002Fservices\u002Fbot\u002Fplatforms\u002Fqq\u002F                     — websocket, no markdown, no edit\n  src\u002Fserver\u002Fservices\u002Fbot\u002Fplatforms\u002Fwechat\u002F                 — long-poll, no markdown, no edit\n\nGateway:\n  src\u002Fserver\u002Fservices\u002Fgateway\u002Findex.ts                      — GatewayService (Vercel-aware startClient\u002FstopClient)\n  src\u002Fserver\u002Fservices\u002Fgateway\u002FGatewayManager.ts             — long-running client registry (non-Vercel)\n  src\u002Fserver\u002Fservices\u002Fgateway\u002FbotConnectQueue.ts            — Redis hash queue with TTL\n  src\u002Fserver\u002Fservices\u002Fgateway\u002FruntimeStatus.ts              — Redis bot:runtime-status keys\n\nDatabase:\n  packages\u002Fdatabase\u002Fsrc\u002Fschemas\u002FagentBotProvider.ts         — agent_bot_providers table\n  packages\u002Fdatabase\u002Fsrc\u002Fmodels\u002FagentBotProvider.ts          — encrypted CRUD + system-wide finders\n\nTRPC + client:\n  src\u002Fserver\u002Frouters\u002Flambda\u002FagentBotProvider.ts             — TRPC router\n  src\u002Fservices\u002FagentBotProvider.ts                          — client wrapper\n  src\u002Fstore\u002Fagent\u002Fslices\u002Fbot\u002Faction.ts                      — Zustand actions\n\nUI:\n  src\u002Froutes\u002F(main)\u002Fagent\u002Fchannel\u002Flist.tsx                  — channel list\n  src\u002Froutes\u002F(main)\u002Fagent\u002Fchannel\u002Fdetail\u002F                   — auto-generated form (Header\u002FBody\u002FFooter)\n  src\u002Froutes\u002F(main)\u002Fagent\u002Fchannel\u002Fconst.ts                  — platform icons\n\nTypes & runtime status:\n  src\u002Ftypes\u002FbotRuntimeStatus.ts                             — BOT_RUNTIME_STATUSES enum + snapshot type\n```\n\n## Adding a New Platform\n\n1. Create `src\u002Fserver\u002Fservices\u002Fbot\u002Fplatforms\u002F\u003Cid>\u002F`:\n   - `definition.ts` — `PlatformDefinition` registered in `platforms\u002Findex.ts`\n   - `schema.ts` — `FieldSchema[]` (`applicationId` + `credentials` + `settings`); reuse fragments from `..\u002Fconst.ts`\n   - `client.ts` — `class XClientFactory extends ClientFactory` returning a `PlatformClient` (lifecycle + adapter + messenger + helpers)\n   - `const.ts` — `DEFAULT_X_CONNECTION_MODE`, history limits, etc.\n   - `protocol-spec.md` — protocol notes (every existing platform has one)\n2. Pick the right `connectionMode` — webhook is much simpler if the platform supports it.\n3. If the platform can't render markdown, set `supportsMarkdown: false` and implement `formatMarkdown` via `stripMarkdown`.\n4. If it can't edit messages, set `supportsMessageEdit: false` — `BotCallbackService` will skip step edits and only send the final reply.\n5. Implement `validateCredentials` so the UI's \"Test connection\" button gives useful errors.\n6. Add the platform icon in `src\u002Froutes\u002F(main)\u002Fagent\u002Fchannel\u002Fconst.ts` and register the platform in `src\u002Fserver\u002Fservices\u002Fbot\u002Fplatforms\u002Findex.ts`.\n7. Add i18n keys under `channel.*` in `src\u002Flocales\u002Fdefault\u002Fsetting.ts` (or wherever the channel namespace lives) — the schema's `label`\u002F`description`\u002F`placeholder`\u002F`enumLabels` are i18n keys.\n",{"name":5,"description":7},"main","87afe6ce96220accf50a345dea46784c8c9f210e","YYC3-AI-应用工具\u002FYYC3-AI-应用工具-lobehub\u002F.agents\u002Fskills\u002Fbot",0,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base","https:\u002F\u002Fkb.yyc3.top\u002F","https:\u002F\u002Fgithub.com\u002FYYC-Cube","万象归元于云枢 | 深栈智启新纪元","2026-11-10 10:37:32",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add YYC-Cube\u002FYYC3-Knowledge-Base --skill bot",{"tool":39,"command":40},"bunx","bunx skills add YYC-Cube\u002FYYC3-Knowledge-Base --skill bot",{"tool":42,"command":43},"pnpm","pnpm dlx skills add YYC-Cube\u002FYYC3-Knowledge-Base --skill bot","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-AI-应用工具\u002FYYC3-AI-应用工具-lobehub\u002F.agents\u002Fskills\u002Fbot\u002FSKILL.md",true,[],[48,55,62,69,76,83],{"skillNo":49,"name":50,"nameZh":6,"description":51,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":52,"categories":53,"keywords":54,"publishedAt":19},"01M7CTDWHERCXPQCP0K03A86AS","vercel-sandbox","Run agent-browser + Chrome inside Vercel Sandbox microVMs for browser automation from any Vercel-deployed app. Use when the user needs browser automation in a Vercel app (Next.js, SvelteKit, Nuxt, Remix, Astro, etc.), wants to run headless Chrome without binary size limits, needs persistent browser sessions across commands, or wants ephemeral isolated browser environments. Triggers include \"Vercel Sandbox browser\", \"microVM Chrome\", \"agent-browser in sandbox\", \"browser automation on Vercel\", or any task requiring Chrome in a Vercel Sandbox.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fvercel-sandbox\u002FSKILL.md",[],[],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":19},"01M7CTD8D2BNJY54S65M47HEJA","slack","Interact with Slack workspaces using browser automation. Use when the user needs to check unread channels, navigate Slack, send messages, extract data, find information, search conversations, or automate any Slack task. Triggers include \"check my Slack\", \"what channels have unreads\", \"send a message to\", \"search Slack for\", \"extract from Slack\", \"find who said\", or any task requiring programmatic Slack interaction.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fslack\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":19},"01M7CTCSSB8ZP3Q58C3YZDZK1W","electron","Automate Electron desktop apps (VS Code, Slack, Discord, Figma, Notion, Spotify, etc.) using agent-browser via Chrome DevTools Protocol. Use when the user needs to interact with an Electron app, automate a desktop app, connect to a running app, control a native app, or test an Electron application. Triggers include \"automate Slack app\", \"control VS Code\", \"interact with Discord app\", \"test this Electron app\", \"connect to desktop app\", or any task requiring automation of a native Electron application.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Felectron\u002FSKILL.md",[],[],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":19},"01M7CTCBJY76688V4DCZGWFHGQ","dogfood","Systematically explore and test a web application to find bugs, UX issues, and other problems. Use when asked to \"dogfood\", \"QA\", \"exploratory test\", \"find issues\", \"bug hunt\", \"test this app\u002Fsite\u002Fplatform\", or review the quality of a web application. Produces a structured report with full reproduction evidence -- step-by-step screenshots, repro videos, and detailed repro steps for every issue -- so findings can be handed directly to the responsible teams.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fdogfood\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M7CTC4H0FFGVEAQR9PA4GA1A","agent-browser","Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to \"open a website\", \"fill out a form\", \"click a button\", \"take a screenshot\", \"scrape data from a page\", \"test this web app\", \"login to a site\", \"automate browser actions\", or any task requiring programmatic web interaction.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fagent-browser\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":19},"01M7CTBKVFYBG78FDSABSDJTTQ","shadcn","Manages shadcn components and projects — adding, searching, fixing, debugging, styling, and composing UI, including chat interfaces. Provides project context, component docs, and usage examples. Applies when working with shadcn\u002Fui, component registries, presets, --preset codes, or any project with a components.json file. Also triggers for \"shadcn init\", \"create an app with --preset\", \"switch to --preset\", and for building a design system or applying a DESIGN.md or brand spec to shadcn\u002Fui.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-UI-界面组件\u002FYYC3-UI-界面组件-ui\u002Fskills\u002Fshadcn\u002FSKILL.md",[],[]]