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.

๐Ÿ“ docs(skills): fix stale code references found by skills audit (#19972)

YuTengjing1d4534210fe3
diff --git a/.agents/skills/builtin-tool/SKILL.md b/.agents/skills/builtin-tool/SKILL.md
index 73f95247d4f..b9d2180d992 100644
--- a/.agents/skills/builtin-tool/SKILL.md
+++ b/.agents/skills/builtin-tool/SKILL.md
@@ -39,7 +39,7 @@ A builtin tool is a package the agent runtime can call. It ships **five faces**:
## Top-Level Design Principles
-1. **`lobe-<domain>` identifier is permanent.** It's stored in message history. Renames need `@deprecated` aliases (see `packages/builtin-tools/src/inspectors.ts:88-89`). Get it right the first time.
+1. **`lobe-<domain>` identifier is permanent.** It's stored in message history. Renames need legacy aliases kept alongside the new name (see the `// Legacy aliases` entries in `packages/builtin-tool-local-system/src/client/Inspector/index.ts`, kept after `listLocalFiles`/`searchLocalFiles` were renamed to `listFiles`/`searchFiles`). Get it right the first time.
2. **ApiName is an `as const` object**, not a TS enum. It doubles as the runtime list `BaseExecutor` iterates over.
3. **Three result fields, three audiences:**
- `content: string` โ†’ the LLM reads it
diff --git a/.agents/skills/builtin-tool/references/architecture.md b/.agents/skills/builtin-tool/references/architecture.md
index 118f7d98e23..93ad86413a6 100644
--- a/.agents/skills/builtin-tool/references/architecture.md
+++ b/.agents/skills/builtin-tool/references/architecture.md
@@ -108,7 +108,7 @@ The `client/executor` instantiates it once with the real service:
```ts
import { localFileService } from '@/services/electron/localFileService';
-import { LocalSystemExecutionRuntime } from '../../ExecutionRuntime';
+import { LocalSystemExecutionRuntime } from '@lobechat/tool-runtime';
class LocalSystemExecutor extends BaseExecutor<typeof LocalSystemApiEnum> {
private runtime = new LocalSystemExecutionRuntime(localFileService);
diff --git a/.agents/skills/builtin-tool/references/tool-design.md b/.agents/skills/builtin-tool/references/tool-design.md
index 4fb15fdeb2d..86ae43b9d31 100644
--- a/.agents/skills/builtin-tool/references/tool-design.md
+++ b/.agents/skills/builtin-tool/references/tool-design.md
@@ -275,7 +275,7 @@ Use when the same logic runs in browser and Node (e.g. mathjs, nerdamer). The ru
### Pattern C: Extend a shared base
-When you're implementing a domain that already has a base runtime (file ops via `ComputerRuntime`), extend and only override `callService` + result normalization. See `builtin-tool-local-system/src/ExecutionRuntime/index.ts`.
+When you're implementing a domain that already has a base runtime (file ops via `ComputerRuntime`), extend and only override `callService` + result normalization. See `packages/tool-runtime/src/LocalSystemExecutionRuntime.ts`.
### Runtime contract
diff --git a/.agents/skills/builtin-tool/references/ui/render.md b/.agents/skills/builtin-tool/references/ui/render.md
index aaa40c11bdb..e7a6c7cfe64 100644
--- a/.agents/skills/builtin-tool/references/ui/render.md
+++ b/.agents/skills/builtin-tool/references/ui/render.md
@@ -98,4 +98,4 @@ export { default as RunTasksRender } from './RunTasks';
## Render display control (rare)
-If the Render should hide for certain results (e.g. ClaudeCode's TodoWrite hides when the agent is mid-stream), add a `RenderDisplayControl` to `packages/builtin-tools/src/displayControls.ts`. See `ClaudeCodeRenderDisplayControls` for the pattern.
+If the Render should hide for certain results (e.g. ClaudeCode's TodoWrite hides when the agent is mid-stream), add a `RenderDisplayControl` to `packages/builtin-tools/src/displayControls.ts`. See `resolveClaudeCodeRenderDisplayControl` (wired in via `getDynamicRenderDisplayControlResolvers`) for the pattern.
diff --git a/.agents/skills/builtin-tool/references/ui/shared-rules.md b/.agents/skills/builtin-tool/references/ui/shared-rules.md
index b96c20e1021..bf24609447e 100644
--- a/.agents/skills/builtin-tool/references/ui/shared-rules.md
+++ b/.agents/skills/builtin-tool/references/ui/shared-rules.md
@@ -84,6 +84,6 @@ previewBox: css`
`,
```
-For the common "icon + file/title header, then one content box" shape, reuse `ToolResultCard` from `@lobechat/shared-tool-ui/components` instead of rebuilding it โ€” it's already single-layer (flat wrapper, one `colorFillTertiary` content box) and is what CC `Read` / `Grep` / `Glob` / `Write` / `WebSearch` / `WebFetch` render through.
+For the common "icon + file/title header" shape, reuse a shared Inspector factory from `@lobechat/shared-tool-ui/inspectors` (`createReadLocalFileInspector`, `createGrepContentInspector`, `createGlobLocalFilesInspector`, `createWriteLocalFileInspector`, `createRunCommandInspector`, โ€ฆ) instead of rebuilding the header โ€” this is what CC `Read` / `Grep` / `Glob` / `Write` / `Bash` reuse (see `packages/builtin-tool-claude-code/src/client/Inspector/index.ts`). There's no equivalent shared component for the content box itself โ€” `Write` / `WebSearch` / `WebFetch` each render their own single `Highlighter`/`Markdown` block following the single-layer rules above.
The exception is a deliberate **panel** pattern โ€” an `<Block variant="outlined">` with a header bar + list rows (CC `TodoWrite` / `Task`). There the single outlined block is the panel and the header fill is a header bar, not a nested card. One structured panel is fine; stacked decorative fills are not.
diff --git a/.agents/skills/builtin-tool/references/ui/streaming.md b/.agents/skills/builtin-tool/references/ui/streaming.md
index 65f5e3eb730..9ea9af89dc0 100644
--- a/.agents/skills/builtin-tool/references/ui/streaming.md
+++ b/.agents/skills/builtin-tool/references/ui/streaming.md
@@ -78,6 +78,8 @@ import { WriteFileStreaming } from './WriteFile';
export const LocalSystemStreamings = {
[LocalSystemApiName.runCommand]: RunCommandStreaming,
- [LocalSystemApiName.writeLocalFile]: WriteFileStreaming,
+ [LocalSystemApiName.writeFile]: WriteFileStreaming,
+ // Legacy alias โ€” keeps historical messages rendering after the rename.
+ writeLocalFile: WriteFileStreaming,
};
```
diff --git a/.agents/skills/chat-sdk/SKILL.md b/.agents/skills/chat-sdk/SKILL.md
index 55092526567..19e9ef80ed3 100644
--- a/.agents/skills/chat-sdk/SKILL.md
+++ b/.agents/skills/chat-sdk/SKILL.md
@@ -116,31 +116,22 @@ await thread.post(
## Packages
-| Package | Purpose |
-| ----------------------------- | ----------------------------- |
-| `chat` | Core SDK |
-| `@chat-adapter/slack` | Slack |
-| `@chat-adapter/teams` | Microsoft Teams |
-| `@chat-adapter/gchat` | Google Chat |
-| `@chat-adapter/discord` | Discord |
-| `@chat-adapter/github` | GitHub Issues |
-| `@chat-adapter/linear` | Linear Issues |
-| `@chat-adapter/state-redis` | Redis state (production) |
-| `@chat-adapter/state-ioredis` | ioredis state (alternative) |
-| `@chat-adapter/state-memory` | In-memory state (development) |
-
-## Changesets (Release Flow)
-
-This monorepo uses [Changesets](https://github.com/changesets/changesets) for versioning and changelogs. Every PR that changes a package's behavior must include a changeset.
-
-```bash
-pnpm changeset
-# โ†’ select affected package(s) (e.g. @chat-adapter/slack, chat)
-# โ†’ choose bump type: patch (fixes), minor (features), major (breaking)
-# โ†’ write a short summary for the CHANGELOG
-```
-
-This creates a file in `.changeset/` โ€” commit it with the PR. When merged to `main`, the Changesets GitHub Action opens a "Version Packages" PR to bump versions and update CHANGELOGs. Merging that PR publishes to npm.
+`chat` and the `@chat-adapter/*` packages are an external SDK this repo
+consumes (pinned via semver range in `package.json`), not something built or
+versioned here โ€” there's no Changesets/release flow to document for them.
+
+| Package | Purpose |
+| --------------------------------- | --------------------------------------------------------------------------------------- |
+| `chat` | Core SDK |
+| `@chat-adapter/discord` | Discord |
+| `@chat-adapter/slack` | Slack |
+| `@chat-adapter/telegram` | Telegram |
+| `@chat-adapter/state-ioredis` | ioredis state |
+| `@lobechat/chat-adapter-feishu` | Lark/Feishu โ€” built in-repo (`packages/chat-adapter-feishu`), not from `@chat-adapter/` |
+| `@lobechat/chat-adapter-imessage` | iMessage via BlueBubbles โ€” built in-repo |
+| `@lobechat/chat-adapter-line` | LINE Messaging API โ€” built in-repo |
+| `@lobechat/chat-adapter-qq` | QQ Bot โ€” built in-repo |
+| `@lobechat/chat-adapter-wechat` | WeChat (iLink) โ€” built in-repo |
## Webhook setup
diff --git a/.agents/skills/cli/SKILL.md b/.agents/skills/cli/SKILL.md
index dc8a6d65670..82b895291a7 100644
--- a/.agents/skills/cli/SKILL.md
+++ b/.agents/skills/cli/SKILL.md
@@ -20,7 +20,8 @@ LobeHub CLI (`@lobehub/cli`) is a command-line tool for managing and interacting
```
apps/cli/src/
-โ”œโ”€โ”€ index.ts # Entry point, registers all commands
+โ”œโ”€โ”€ index.ts # Entry point โ€” parses argv, invokes program.ts
+โ”œโ”€โ”€ program.ts # Builds the Commander program, registers every command
โ”œโ”€โ”€ api/
โ”‚ โ”œโ”€โ”€ client.ts # tRPC client (type-safe backend API)
โ”‚ โ””โ”€โ”€ http.ts # Raw HTTP utilities
@@ -31,23 +32,45 @@ apps/cli/src/
โ”‚ โ””โ”€โ”€ resolveToken.ts # Token resolution (flag > stored)
โ”œโ”€โ”€ commands/ # All CLI commands (one file per command group)
โ”‚ โ”œโ”€โ”€ agent.ts # Agent CRUD + run
+โ”‚ โ”œโ”€โ”€ agent-group.ts # Agent group CRUD
+โ”‚ โ”œโ”€โ”€ agent-signal/ # Inspect and trigger Agent Signal source events
+โ”‚ โ”œโ”€โ”€ artifact.ts # Publish local HTML pages as artifacts
+โ”‚ โ”œโ”€โ”€ bot.ts # Bot integrations (channels, access policies, messengers)
+โ”‚ โ”œโ”€โ”€ completion.ts # Shell completion script output
โ”‚ โ”œโ”€โ”€ config.ts # whoami, usage
โ”‚ โ”œโ”€โ”€ connect.ts # Device gateway connection + daemon
+โ”‚ โ”œโ”€โ”€ device.ts # Manage connected devices
โ”‚ โ”œโ”€โ”€ doc.ts # Document management
+โ”‚ โ”œโ”€โ”€ doctor.ts # Machine diagnostics (runtime, endpoints, credentials, readiness)
+โ”‚ โ”œโ”€โ”€ eval.ts # Evaluation workflows & benchmarks
โ”‚ โ”œโ”€โ”€ file.ts # File management
โ”‚ โ”œโ”€โ”€ generate/ # Content generation (text/image/video/tts/asr)
+โ”‚ โ”œโ”€โ”€ goal.ts # Long-horizon Goal Graphs
+โ”‚ โ”œโ”€โ”€ hetero.ts # Run heterogeneous agent CLIs, stream their output
โ”‚ โ”œโ”€โ”€ kb.ts # Knowledge base management
-โ”‚ โ”œโ”€โ”€ login.ts # OIDC Device Code Flow auth
+โ”‚ โ”œโ”€โ”€ login.ts # OIDC Device Code Flow / API key auth
โ”‚ โ”œโ”€โ”€ logout.ts # Clear credentials
+โ”‚ โ”œโ”€โ”€ man.ts # CLI manual pages
โ”‚ โ”œโ”€โ”€ memory.ts # User memory management
โ”‚ โ”œโ”€โ”€ message.ts # Message management
+โ”‚ โ”œโ”€โ”€ migrate/ # Import data from external tools (OpenClaw, ChatGPT, Claude, etc.)
โ”‚ โ”œโ”€โ”€ model.ts # AI model management
+โ”‚ โ”œโ”€โ”€ notify.ts # Send a callback message to a topic to trigger the agent
โ”‚ โ”œโ”€โ”€ plugin.ts # Plugin management
+โ”‚ โ”œโ”€โ”€ project.ts # Goal-oriented project management
โ”‚ โ”œโ”€โ”€ provider.ts # AI provider management
โ”‚ โ”œโ”€โ”€ search.ts # Global search
+โ”‚ โ”œโ”€โ”€ session-group.ts # Agent session group management
โ”‚ โ”œโ”€โ”€ skill.ts # Agent skill management
โ”‚ โ”œโ”€โ”€ status.ts # Gateway connectivity check
+โ”‚ โ”œโ”€โ”€ task/ # Agent task management (assignees, checkpoints, deps, review)
+โ”‚ โ”œโ”€โ”€ thread.ts # Message thread management
โ”‚ โ”œโ”€โ”€ topic.ts # Conversation topic management
+โ”‚ โ”œโ”€โ”€ trace/ # Inspect and replay recorded agent execution traces
+โ”‚ โ”œโ”€โ”€ update.ts # Self-update to the latest published version
+โ”‚ โ”œโ”€โ”€ user.ts # User account & settings
+โ”‚ โ”œโ”€โ”€ verify.ts # Agent Run verification machinery (criteria, rubrics, check plans)
+โ”‚ โ”œโ”€โ”€ verifyAcceptance.ts # `lh acceptance`: cross-round delivery review loop
โ”‚ โ””โ”€โ”€ workspace.ts # Workspace list/scope/members/usage/audit
โ”œโ”€โ”€ daemon/
โ”‚ โ””โ”€โ”€ manager.ts # Background daemon process management
@@ -66,28 +89,50 @@ apps/cli/src/
## Command Groups
-| Command | Alias | Description |
-| -------------- | ----- | ----------------------------------------------------------- |
-| `lh login` | - | Authenticate via OIDC Device Code Flow |
-| `lh logout` | - | Clear stored credentials |
-| `lh connect` | - | Device gateway connection & daemon management |
-| `lh status` | - | Quick gateway connectivity check |
-| `lh agent` | - | Agent CRUD, run, status |
-| `lh generate` | `gen` | Content generation (text, image, video, tts, asr, download) |
-| `lh doc` | - | Document CRUD, batch-create, parse, topic linking |
-| `lh file` | - | File list, view, delete, recent |
-| `lh kb` | - | Knowledge base CRUD, folders, docs, upload, tree view |
-| `lh memory` | - | User memory CRUD + extraction |
-| `lh message` | - | Message list, search, delete, count, heatmap |
-| `lh topic` | - | Topic CRUD + search + recent |
-| `lh skill` | - | Skill CRUD + import (GitHub/URL/market) |
-| `lh model` | - | Model CRUD, toggle, batch-toggle, clear |
-| `lh provider` | - | Provider CRUD, config, test, toggle |
-| `lh plugin` | - | Plugin install, uninstall, update |
-| `lh search` | - | Global search across all types |
-| `lh workspace` | `ws` | Workspace list, scope switch, members, invites, usage |
-| `lh whoami` | - | Current user info (including the resolved workspace scope) |
-| `lh usage` | - | Monthly/daily usage statistics |
+| Command | Alias | Description |
+| ------------------ | ----- | ---------------------------------------------------------------------------------- |
+| `lh login` | - | Authenticate via OIDC Device Code Flow or API key |
+| `lh logout` | - | Clear stored credentials |
+| `lh connect` | - | Device gateway connection & daemon management |
+| `lh device` | - | Manage connected devices |
+| `lh status` | - | Quick gateway connectivity check |
+| `lh doctor` | - | Diagnose machine readiness (runtime, endpoints, credentials, scope, device, agent) |
+| `lh agent` | - | Agent CRUD, run, status |
+| `lh agent-group` | - | Agent group CRUD |
+| `lh agent-signal` | - | Inspect and trigger Agent Signal source events |
+| `lh hetero` | - | Run heterogeneous agent CLIs (Claude Code, Codex, etc.), stream their output |
+| `lh goal` | - | Run long-horizon Goal Graphs |
+| `lh project` | - | Manage goal-oriented projects |
+| `lh task` | - | Manage agent tasks (assignees, checkpoints, deps, review) |
+| `lh thread` | - | Manage message threads |
+| `lh trace` | - | Inspect and replay recorded agent execution traces |
+| `lh verify` | - | Agent Run verification machinery โ€” criteria, rubrics, per-run check plans |
+| `lh acceptance` | - | Delivery acceptances โ€” the cross-round review loop (checks, feedback, decision) |
+| `lh eval` | - | Manage evaluation workflows and benchmarks |
+| `lh generate` | `gen` | Content generation (text, image, video, tts, asr, download) |
+| `lh doc` | - | Document CRUD, batch-create, parse, topic linking |
+| `lh file` | - | File list, view, delete, recent |
+| `lh artifact` | - | Publish local HTML pages as artifacts |
+| `lh kb` | - | Knowledge base CRUD, folders, docs, upload, tree view |
+| `lh memory` | - | User memory CRUD + extraction |
+| `lh message` | - | Message list, search, delete, count, heatmap |
+| `lh topic` | - | Topic CRUD + search + recent |
+| `lh notify` | - | Send a callback message to a topic and trigger the agent to process it |
+| `lh migrate` | - | Import data from external tools (OpenClaw, ChatGPT, Claude, etc.) |
+| `lh bot` | - | Manage bot integrations (channels, access policies, messengers) |
+| `lh skill` | - | Skill CRUD + import (GitHub/URL/market) |
+| `lh model` | - | Model CRUD, toggle, batch-toggle, clear |
+| `lh provider` | - | Provider CRUD, config, test, toggle |
+| `lh plugin` | - | Plugin install, uninstall, update |
+| `lh search` | - | Global search across all types |
+| `lh session-group` | - | Manage agent session groups |
+| `lh workspace` | `ws` | Workspace list, scope switch, members, invites, usage |
+| `lh user` | - | Manage user account and settings |
+| `lh whoami` | - | Current user info (including the resolved workspace scope) |
+| `lh usage` | - | Monthly/daily usage statistics |
+| `lh man` | - | Show a manual page for the CLI or a subcommand |
+| `lh completion` | - | Output shell completion script |
+| `lh update` | - | Update the CLI to the latest published version |
### Workspace Scope
@@ -198,14 +243,14 @@ if (!options.yes) {
## Storage Locations
-| File | Path | Purpose |
-| ------------- | ----------------------------- | ------------------------------------------------ |
-| Credentials | `~/.lobehub/credentials.json` | Encrypted tokens (AES-256-GCM) |
-| Settings | `~/.lobehub/settings.json` | Custom server/gateway URLs |
-| Workspace | `~/.lobehub/active-workspace` | Active scope + the account/server it is bound to |
-| Daemon PID | `~/.lobehub/daemon.pid` | Background process PID |
-| Daemon Status | `~/.lobehub/daemon.status` | Connection status JSON |
-| Daemon Log | `~/.lobehub/daemon.log` | Daemon output log |
+| File | Path | Purpose |
+| ------------- | ------------------------------- | ------------------------------------------------ |
+| Credentials | `~/.lobehub/credentials.json` | Encrypted tokens (AES-256-GCM) |
+| Settings | `~/.lobehub/settings.json` | Custom server/gateway URLs |
+| Workspace | `~/.lobehub/active-workspace` | Active scope + the account/server it is bound to |
+| Daemon PID | `~/.lobehub/daemon.pid` | Background process PID |
+| Daemon Status | `~/.lobehub/daemon.status.json` | Connection status JSON |
+| Daemon Log | `~/.lobehub/daemon.log` | Daemon output log |
The base directory (`~/.lobehub/`) can be overridden with the `LOBEHUB_CLI_HOME` env var (e.g. `LOBEHUB_CLI_HOME=.lobehub-dev` for dev mode isolation).
diff --git a/.agents/skills/db-migrations/SKILL.md b/.agents/skills/db-migrations/SKILL.md
index dcace81a5e7..7fad976aaba 100644
--- a/.agents/skills/db-migrations/SKILL.md
+++ b/.agents/skills/db-migrations/SKILL.md
@@ -170,7 +170,6 @@ This generates:
And updates:
- `packages/database/migrations/meta/_journal.json`
-- `packages/database/src/core/migrations.json`
- `docs/development/database-schema.dbml`
## Custom Migrations (e.g. CREATE EXTENSION)
diff --git a/.agents/skills/debug-package/SKILL.md b/.agents/skills/debug-package/SKILL.md
index bb444f8e561..54c2bca6d7d 100644
--- a/.agents/skills/debug-package/SKILL.md
+++ b/.agents/skills/debug-package/SKILL.md
@@ -57,10 +57,10 @@ process.env.DEBUG = 'lobe-*';
## Example
```typescript
-// apps/server/src/routers/edge/market/index.ts
+// apps/server/src/routers/lambda/agentEval.ts
import debug from 'debug';
-const log = debug('lobe-edge-router:market');
+const log = debug('lobe-lambda-router:agent-eval');
log('getAgent input: %O', input);
```
diff --git a/.agents/skills/design-prototype/SKILL.md b/.agents/skills/design-prototype/SKILL.md
index 9b3991f6ab2..bd86ed84e7f 100644
--- a/.agents/skills/design-prototype/SKILL.md
+++ b/.agents/skills/design-prototype/SKILL.md
@@ -80,16 +80,18 @@ viewport if the surface has a mobile story.
See [`assets/entry.mjs`](assets/entry.mjs) โ€” the single source of truth. Currently:
+- `@lobehub/icons`: Amp, ClaudeCode, Codex, HermesAgent, OpenClaw, OpenCode
- `@lobehub/ui`: ActionIcon, Alert, Avatar, Block, Button, Center, Collapse,
- DraggablePanel, Drawer, DropdownMenu, Empty, Flexbox, Highlighter, Hotkey, Icon,
- Image, Input, InputNumber, Markdown, Modal, NeuralNetworkLoading, Popover,
+ ConfigProvider, DraggablePanel, Drawer, DropdownMenu, Empty, Flexbox, Highlighter, Hotkey, Icon,
+ Image, Input, InputNumber, Markdown, Modal, MotionProvider, NeuralNetworkLoading, Popover,
ScrollShadow, SearchBar, Segmented, Select, Skeleton, SortableList, Tabs, Tag,
Text, TextArea, ThemeProvider, Tooltip
- `@lobehub/ui/base-ui`: full namespace (Select, Modal, DropdownMenu, Switch, Toast,
FloatingSheet, โ€ฆ)
- `antd`: App, Badge, Checkbox, Divider, Dropdown, Progress, Radio, Slider, Space,
Steps, Table
-- `antd-style`, `lucide-react`, `react`, `react-dom/client`: full namespaces
+- `antd-style`, `lucide-react`, `motion/react`, `motion/react-m`, `react`,
+ `react/jsx-runtime`, `react-dom`, `react-dom/client`: full namespaces
Missing a component โ†’ add to `entry.mjs`, rerun the build script (\~2s). Sizes:
curated โ‰ˆ 16MB (fine from disk); a full `export * from '@lobehub/ui'` works too
diff --git a/.agents/skills/desktop/SKILL.md b/.agents/skills/desktop/SKILL.md
index c69afcd989c..b2c6d7f7d5c 100644
--- a/.agents/skills/desktop/SKILL.md
+++ b/.agents/skills/desktop/SKILL.md
@@ -38,7 +38,7 @@ Register in `apps/desktop/src/main/controllers/registry.ts`.
### 2. Define IPC Types
-Location: `packages/electron-client-ipc/src/types.ts`
+Location: `packages/electron-client-ipc/src/types/<domain>.ts`, re-exported from `types/index.ts`
```typescript
export interface SomeParams {
diff --git a/.agents/skills/desktop/references/feature-implementation.md b/.agents/skills/desktop/references/feature-implementation.md
index 1332950a33e..4da27eb042e 100644
--- a/.agents/skills/desktop/references/feature-implementation.md
+++ b/.agents/skills/desktop/references/feature-implementation.md
@@ -55,7 +55,7 @@ export default class NotificationCtr extends ControllerModule {
### 2. Define IPC Types
```typescript
-// packages/electron-client-ipc/src/types.ts
+// packages/electron-client-ipc/src/types/notification.ts (re-exported from types/index.ts)
export interface ShowDesktopNotificationParams {
title: string;
body: string;
diff --git a/.agents/skills/desktop/references/window-management.md b/.agents/skills/desktop/references/window-management.md
index 499e843b03e..b80a7d12b86 100644
--- a/.agents/skills/desktop/references/window-management.md
+++ b/.agents/skills/desktop/references/window-management.md
@@ -12,10 +12,8 @@
```plaintext
apps/desktop/src/main/
โ”œโ”€โ”€ appBrowsers.ts # Core window management
-โ”œโ”€โ”€ controllers/
-โ”‚ โ””โ”€โ”€ BrowserWindowsCtr.ts # Window controller
-โ””โ”€โ”€ modules/
- โ””โ”€โ”€ browserWindowManager.ts # Window manager module
+โ””โ”€โ”€ controllers/
+ โ””โ”€โ”€ BrowserWindowsCtr.ts # Window controller
```
## Window Creation
diff --git a/.agents/skills/drizzle/SKILL.md b/.agents/skills/drizzle/SKILL.md
index 022d9b9e730..14a571dcb5a 100644
--- a/.agents/skills/drizzle/SKILL.md
+++ b/.agents/skills/drizzle/SKILL.md
@@ -39,12 +39,13 @@ Location: `packages/database/src/schemas/_helpers.ts`
`workspace_xxx_logs`, not `workspace_xxx_records` or another new synonym.
```typescript
-// โœ… Good: follows the existing user/workspace table family.
-export const userSignupLogs = pgTable('user_signup_logs', { ... });
-export const workspaceSignupLogs = pgTable('workspace_signup_logs', { ... });
+// โœ… Good: follows the existing user/workspace table family (names are
+// illustrative โ€” swap `widget` for the real noun).
+export const userWidgetLogs = pgTable('user_widget_logs', { ... });
+export const workspaceWidgetLogs = pgTable('workspace_widget_logs', { ... });
// โŒ Bad: introduces a new suffix for the same concept.
-export const workspaceSignupRecords = pgTable('workspace_signup_records', { ... });
+export const workspaceWidgetRecords = pgTable('workspace_widget_records', { ... });
```
## Column Definitions
@@ -124,16 +125,19 @@ uses it consistently. Prefer nullable columns, optional TypeScript fields, or a
separate concrete status enum when the value is genuinely absent.
```typescript
-// โœ… Good: absent until the final stage writes a real decision.
-export type UserSignupLogFinalDecision = 'allow' | 'block' | 'error';
+// โœ… Good: absent until a custom-execution attempt actually runs
+// (packages/database/src/schemas/agentIntervention.ts).
+export const AGENT_INTERVENTION_CUSTOM_EXECUTION_STATES = ['pending', 'executing', 'completed'] as const;
+export type AgentInterventionCustomExecutionState =
+ (typeof AGENT_INTERVENTION_CUSTOM_EXECUTION_STATES)[number];
-finalDecision: varchar('final_decision', { length: 32 }).$type<UserSignupLogFinalDecision>(),
+customExecutionState: text('custom_execution_state').$type<AgentInterventionCustomExecutionState>(),
// โŒ Bad: invents a new state that callers now need to handle everywhere.
-export type UserSignupLogFinalDecision = 'allow' | 'block' | 'error' | 'unknown';
+export type AgentInterventionCustomExecutionState = 'pending' | 'executing' | 'completed' | 'unknown';
-finalDecision: varchar('final_decision', { length: 32 })
- .$type<UserSignupLogFinalDecision>()
+customExecutionState: text('custom_execution_state')
+ .$type<AgentInterventionCustomExecutionState>()
.notNull()
.default('unknown');
```
@@ -163,20 +167,22 @@ name could mean either a request ID or a persisted row ID.
```typescript
// โœ… Good: explain the table's business object first, then only document
-// non-obvious lifecycle or risk-control fields.
+// non-obvious lifecycle fields
+// (packages/database/src/schemas/agentIntervention.ts).
/**
- * User signup logs - one row per signup flow, collecting stage-level
- * risk-control decisions before and after the auth provider creates a user.
+ * Private resolution/outbox records. Unlike `agent_interventions`, this table
+ * may retain user-edited arguments so a claimed decision can be delivered
+ * reliably after the app disconnects. It is never a notification payload.
*/
-export const userSignupLogs = pgTable('user_signup_logs', {
- /** Final signup outcome reason, for example user_created, llm_block, or guard_error */
- finalReason: text('final_reason'),
+export const agentInterventionResolutions = pgTable('agent_intervention_resolutions', {
+ /** Owner of the durable operation, distinct from the resolving actor. */
+ userId: text('user_id').references(() => users.id, { onDelete: 'cascade' }).notNull(),
- /** Aggregated risk level derived from stage decisions, for example block -> high */
- riskLevel: varchar('risk_level', { length: 16 }).$type<UserSignupLogRiskLevel>(),
+ /** Private executor result; never selected into Review or notification DTOs. */
+ customExecutionResult: jsonb('custom_execution_result').$type<AgentInterventionCustomExecutionResult>(),
- /** Ordered stage-level decisions and metadata grouped by signup review stage */
- stageResults: jsonb('stage_results').$type<UserSignupLogStageResults>(),
+ /** Monotonic lease attempt, starting at zero while pending. */
+ customExecutionAttempt: integer('custom_execution_attempt'),
});
// โŒ Bad: comments restate obvious column names without adding domain meaning.
@@ -192,17 +198,19 @@ when most properties are optional. This keeps callers, migrations, and review
queries aligned on the same data contract.
```typescript
-interface UserSignupLogMetadata {
- payloadPath?: string;
- requestPath?: string;
+// packages/types/src/agent/agentIntervention.ts +
+// packages/database/src/schemas/agentIntervention.ts
+interface AgentInterventionCustomExecutionResult {
+ content: string;
+ pluginState: Record<string, unknown>;
}
-metadata: jsonb('metadata').$type<UserSignupLogMetadata>(),
+customExecutionResult: jsonb('custom_execution_result').$type<AgentInterventionCustomExecutionResult>(),
```
```typescript
// โŒ Bad: hides the contract and makes downstream access untyped.
-metadata: jsonb('metadata').$type<Record<string, unknown>>(),
+customExecutionResult: jsonb('custom_execution_result').$type<Record<string, unknown>>(),
```
A loosely-typed JSONB column is often a symptom of a deeper problem: the column
@@ -362,19 +370,20 @@ so the method reads as business intent, not SQL plumbing.
```typescript
// โœ… Scalars included only when present; SQL hidden behind a named helper.
+// (`userWidgetLogs` is illustrative โ€” swap for the real table.)
const updateValues = compactUndefined({
email: record.email ?? undefined,
ip: record.ip ?? undefined,
});
-await db.insert(userSignupLogs).values(values).onConflictDoUpdate({
- set: { ...updateValues, stageResults: appendStageResult(stage, result), updatedAt: now },
- target: userSignupLogs.id,
+await db.insert(userWidgetLogs).values(values).onConflictDoUpdate({
+ set: { ...updateValues, events: appendJsonbArray(userWidgetLogs.events, event), updatedAt: now },
+ target: userWidgetLogs.id,
});
// โŒ Every scalar becomes SQL plumbing.
set: {
- email: sql`COALESCE(excluded.email, ${userSignupLogs.email})`,
- ip: sql`COALESCE(excluded.ip, ${userSignupLogs.ip})`,
+ email: sql`COALESCE(excluded.email, ${userWidgetLogs.email})`,
+ ip: sql`COALESCE(excluded.ip, ${userWidgetLogs.ip})`,
}
```
diff --git a/.agents/skills/heterogeneous-agent/references/debug-workflow.md b/.agents/skills/heterogeneous-agent/references/debug-workflow.md
index e1dbe635848..bd0791fc218 100644
--- a/.agents/skills/heterogeneous-agent/references/debug-workflow.md
+++ b/.agents/skills/heterogeneous-agent/references/debug-workflow.md
@@ -35,7 +35,7 @@ faithful trace you can get, because it captures the **exact** spawn args, env
keys, cwd, `--resume`/`--mcp-config` flags, model, and stdin that the app used โ€”
things a hand-rolled `claude -p` / `codex exec` repro will not reproduce. Reach
for this before reproducing manually. The recorder lives in
-`apps/desktop/src/main/controllers/HeterogeneousAgentCtr.ts`
+`apps/desktop/src/main/controllers/HeterogeneousAgentImpl.ts`
(`createCliTraceSession`, `shouldTraceCliOutput`, `resolveTraceRootDir`).
When it records:
diff --git a/.agents/skills/hotkey/SKILL.md b/.agents/skills/hotkey/SKILL.md
index 2b8b4978003..441655f3451 100644
--- a/.agents/skills/hotkey/SKILL.md
+++ b/.agents/skills/hotkey/SKILL.md
@@ -10,27 +10,31 @@ user-invocable: false
### 1. Update Hotkey Constant
-In `src/types/hotkey.ts`:
+In `packages/types/src/hotkey.ts`, add the new id to the `HotkeyId` union โ€” it's the source of truth `HotkeyEnum` is typed against:
```typescript
-export const HotkeyEnum = {
+export type HotkeyId =
+ | 'addUserMessage'
// existing...
- ClearChat: 'clearChat', // Add new
-} as const;
+ | 'saveTopic';
```
### 2. Register Default Hotkey
-In `src/const/hotkeys.ts`:
+In `packages/const/src/hotkeys.ts`, `KeyEnum` and `combineKeys` are already defined locally in this file, so no import is needed โ€” add the entry to `HotkeyEnum` and to `HOTKEYS_REGISTRATION`:
```typescript
-import { KeyMapEnum as Key, combineKeys } from '@lobehub/ui';
+export const HotkeyEnum = {
+ // existing...
+ SaveTopic: 'saveTopic',
+} as const satisfies Record<string, HotkeyId>;
export const HOTKEYS_REGISTRATION: HotkeyRegistration = [
+ // existing...
{
group: HotkeyGroupEnum.Conversation,
- id: HotkeyEnum.ClearChat,
- keys: combineKeys([Key.Mod, Key.Shift, Key.Backspace]),
+ id: HotkeyEnum.SaveTopic,
+ keys: combineKeys([KeyEnum.Alt, 'n']),
scopes: [HotkeyScopeEnum.Chat],
},
];
@@ -42,9 +46,9 @@ In `packages/locales/src/default/hotkey.ts`:
```typescript
const hotkey: HotkeyI18nTranslations = {
- clearChat: {
- desc: 'ๆธ…็ฉบๅฝ“ๅ‰ไผš่ฏ็š„ๆ‰€ๆœ‰ๆถˆๆฏ่ฎฐๅฝ•',
- title: 'ๆธ…็ฉบ่Šๅคฉ่ฎฐๅฝ•',
+ saveTopic: {
+ desc: 'ไฟๅญ˜ๅฝ“ๅ‰่ฏ้ข˜ๅนถๆ–ฐๅปบไธ€ไธช่ฏ้ข˜',
+ title: 'ไฟๅญ˜่ฏ้ข˜',
},
};
```
@@ -54,13 +58,13 @@ const hotkey: HotkeyI18nTranslations = {
In `src/hooks/useHotkeys/chatScope.ts`:
```typescript
-export const useClearChatHotkey = () => {
- const clearMessages = useChatStore((s) => s.clearMessages);
- return useHotkeyById(HotkeyEnum.ClearChat, clearMessages);
+export const useSaveTopicHotkey = () => {
+ const openNewTopicOrSaveTopic = useChatStore((s) => s.openNewTopicOrSaveTopic);
+ return useHotkeyById(HotkeyEnum.SaveTopic, openNewTopicOrSaveTopic);
};
export const useRegisterChatHotkeys = () => {
- useClearChatHotkey();
+ useSaveTopicHotkey();
// ...other hotkeys
};
```
@@ -68,10 +72,10 @@ export const useRegisterChatHotkeys = () => {
### 5. Add Tooltip (Optional)
```tsx
-const clearChatHotkey = useUserStore(settingsSelectors.getHotkeyById(HotkeyEnum.ClearChat));
+const saveTopicHotkey = useUserStore(settingsSelectors.getHotkeyById(HotkeyEnum.SaveTopic));
-<Tooltip hotkey={clearChatHotkey} title={t('clearChat.title', { ns: 'hotkey' })}>
- <Button icon={<DeleteOutlined />} onClick={clearMessages} />
+<Tooltip hotkey={saveTopicHotkey} title={t('saveTopic.title', { ns: 'hotkey' })}>
+ <Button icon={<SaveOutlined />} onClick={openNewTopicOrSaveTopic} />
</Tooltip>;
```
@@ -80,7 +84,7 @@ const clearChatHotkey = useUserStore(settingsSelectors.getHotkeyById(HotkeyEnum.
1. **Scope**: Choose global or chat scope based on functionality
2. **Grouping**: Place in appropriate group (System/Layout/Conversation)
3. **Conflict check**: Ensure no conflict with system/browser shortcuts
-4. **Platform**: Use `Key.Mod` instead of hardcoded `Ctrl` or `Cmd`
+4. **Platform**: Use `KeyEnum.Mod` instead of hardcoded `Ctrl` or `Cmd`
5. **Clear description**: Provide title and description for users
## Troubleshooting
diff --git a/.agents/skills/modal/SKILL.md b/.agents/skills/modal/SKILL.md
index 2c150bbfc15..31c34a70fea 100644
--- a/.agents/skills/modal/SKILL.md
+++ b/.agents/skills/modal/SKILL.md
@@ -154,13 +154,11 @@ confirmModal({
## Legacy: `@lobehub/ui` (root)
-Older call sites use **`createModal` from `@lobehub/ui`**, which is typed as **antd `Modal` props** (`children`, `allowFullscreen`, `getContainer`, `destroyOnHidden`, `styles.body`, etc.). Prefer migrating new work to **`@lobehub/ui/base-ui`**.
-
-Examples (legacy): `src/features/SkillStore/index.tsx`, `src/features/LibraryModal/CreateNew/index.tsx`.
+`createModal` from the root `@lobehub/ui` entry is typed as **antd `Modal` props** (`children`, `allowFullscreen`, `getContainer`, `destroyOnHidden`, `styles.body`, etc.). App code no longer imports it; do not reintroduce it โ€” use **`@lobehub/ui/base-ui`**.
---
## Examples
- Base-ui (preferred): follow sections above; ensure **base-ui `ModalHost`** is mounted.
-- Legacy: `src/features/SkillStore/index.tsx`, `src/features/LibraryModal/CreateNew/index.tsx`
+- Base-ui call sites: `src/features/SkillStore/index.tsx`, `src/features/LibraryModal/CreateNew/index.tsx`
diff --git a/.agents/skills/model-bank-metadata/SKILL.md b/.agents/skills/model-bank-metadata/SKILL.md
index 0b936e6332f..e816fc2cbcf 100644
--- a/.agents/skills/model-bank-metadata/SKILL.md
+++ b/.agents/skills/model-bank-metadata/SKILL.md
@@ -46,7 +46,7 @@ Known per-vendor footguns:
## family/generation derivation
-Rule-based, no research needed: `scripts/derive-family.ts` holds the per-family regex rules. Traps already encoded there โ€” keep them when extending:
+Rule-based, no research needed: `.agents/skills/model-bank-metadata/scripts/derive-family.ts` holds the per-family regex rules. Traps already encoded there โ€” keep them when extending:
- Date suffixes are not versions: `claude-sonnet-4-20250514` is generation `claude-4`, not `claude-4.2`.
- Size suffixes are not versions: `llama-3-8b` โ†’ `llama-3` (not `llama-3.8`); `gemma-7b-it` is **gemma-1** (not gemma-7).
@@ -59,7 +59,7 @@ Rule-based, no research needed: `scripts/derive-family.ts` holds the per-family
1. **Extract ids**: `bun .agents/skills/model-bank-metadata/scripts/extract-model-ids.ts` โ†’ unique normalized chat-model ids (normalization = last path segment, lowercased). Non-chat types (image/video/embedding/tts) have no knowledge cutoff โ€” skip them.
2. **Research (multi-agent)**: chunk ids by family (โ‰ค50 per chunk) and fan out one research agent per chunk (Workflow tool), each returning `{id, cutoff, source}` with the sourcing rules above baked into the prompt, **plus** one adversarial verify agent per chunk that re-fetches cited sources and refutes unsupported claims. The verify pass is load-bearing: it caught the Cohere aggregator copy-paste and the AWS launch-date conflation.
3. **Policy filter**: before applying, drop entries whose only source is a rejected category (check the returned `sources` map โ€” e.g. drop everything sourced to aws.amazon.com).
-4. **Apply**: `bun scripts/apply-cutoffs.ts <map.json>` and `bun scripts/apply-family.ts <map.json>` (run from repo root). Both are idempotent codemods keyed on normalized id โ€” aggregator providers get the same values automatically; entries that already have the field are skipped. They rely on the uniform prettier formatting of the data files (entries start ` {` / end ` },`, fields at 4-space indent).
+4. **Apply**: `bun .agents/skills/model-bank-metadata/scripts/apply-cutoffs.ts <map.json>` and `bun .agents/skills/model-bank-metadata/scripts/apply-family.ts <map.json>` (run from repo root). Both are idempotent codemods keyed on normalized id โ€” aggregator providers get the same values automatically; entries that already have the field are skipped. They rely on the uniform prettier formatting of the data files (entries start ` {` / end ` },`, fields at 4-space indent).
5. **Verify**: `cd packages/model-bank && bunx vitest run src/aiModels/__tests__/index.test.ts && bunx tsc --noEmit`.
## Maintenance rules
diff --git a/.agents/skills/response-compliance/SKILL.md b/.agents/skills/response-compliance/SKILL.md
index bd40278e9dd..962449f4cc9 100644
--- a/.agents/skills/response-compliance/SKILL.md
+++ b/.agents/skills/response-compliance/SKILL.md
@@ -11,7 +11,7 @@ Run the official OpenResponses compliance test suite against the local (or remot
```bash
# From the openapi package directory
-cd lobehub/packages/openapi
+cd packages/openapi
# Run all tests (dev mode, localhost:3010)
APP_URL=http://localhost:3010 bun run test:response-compliance -- \
@@ -66,7 +66,7 @@ Available `--filter` values:
## How It Works
-The script (`lobehub/packages/openapi/scripts/compliance-test.sh`) clones the official [openresponses/openresponses](https://github.com/openresponses/openresponses) repo into `scripts/openresponses-compliance/` (gitignored) and runs its CLI test runner. First run clones; subsequent runs update from upstream.
+The script (`packages/openapi/scripts/compliance-test.sh`) clones the official [openresponses/openresponses](https://github.com/openresponses/openresponses) repo into `scripts/openresponses-compliance/` (gitignored) and runs its CLI test runner. First run clones; subsequent runs update from upstream.
## Debugging Failures
@@ -79,9 +79,9 @@ The script (`lobehub/packages/openapi/scripts/compliance-test.sh`) clones the of
## Key Files
-- **Types**: `lobehub/packages/openapi/src/types/responses.type.ts`
-- **Service**: `lobehub/packages/openapi/src/services/responses.service.ts`
-- **Controller**: `lobehub/packages/openapi/src/controllers/responses.controller.ts`
-- **Route**: `lobehub/packages/openapi/src/routes/responses.route.ts`
-- **Test script**: `lobehub/packages/openapi/scripts/compliance-test.sh`
+- **Types**: `packages/openapi/src/types/responses.type.ts`
+- **Service**: `packages/openapi/src/services/responses.service.ts`
+- **Controller**: `packages/openapi/src/controllers/responses.controller.ts`
+- **Route**: `packages/openapi/src/routes/responses.route.ts`
+- **Test script**: `packages/openapi/scripts/compliance-test.sh`
- **Cloud route**: `src/app/(backend)/api/v1/[[...route]]/route.ts`
diff --git a/.agents/skills/spa-routes/SKILL.md b/.agents/skills/spa-routes/SKILL.md
index 22b5749b08f..d18d231e373 100644
--- a/.agents/skills/spa-routes/SKILL.md
+++ b/.agents/skills/spa-routes/SKILL.md
@@ -85,7 +85,7 @@ Each feature should:
- Every lazy route inside the main area renders `RouteSegmentSkeleton` (`src/components/Skeleton/RouteSegment.tsx`) while its chunk loads. It resolves via `handle.meta.Skeleton` only (deepest match wins, walking up through parent routes). Omitting `Skeleton` renders a blank pane โ€” use `NoRouteSkeleton` when that is intentional.
- Pick the skeleton when adding or restructuring a route:
- A close-enough generic shape exists โ†’ `Skeleton: createSurfaceSkeleton('list' | 'form' | 'grid' | 'editor' | 'detail')` from `@/components/Skeleton/Surface`.
- - The page has a distinctive layout (dashboard, multi-panel, conversation) โ†’ author a bespoke component under `src/components/Skeleton/` and register it (see `Home.tsx`, `Generation.tsx`, `Conversation/`).
+ - The page has a distinctive layout (dashboard, multi-panel, conversation) โ†’ author a bespoke component under `src/components/Skeleton/` and register it (see `ResourceHome.tsx`, `Generation.tsx`, `Conversation/`).
- Where to put it: on the route's `routeMeta` (feature `routeMeta.ts` or inline in `desktopRouter.shared.tsx`). A whole subtree sharing one shape can register once on the parent/layout route's `handle` โ€” children with their own `Skeleton` still override.
- When changing a page's layout, update its registered skeleton in the same PR โ€” a stale skeleton that no longer matches the page is a regression.
- Skeleton-only parent handles are safe for titles: title/icon resolution also walks deepest-first, and leaf metas keep winning.
@@ -110,11 +110,11 @@ The thin router adapters are not duplicated trees. Other route modules may still
Known variants today:
-| Base file (web) | Desktop file (Electron) | Purpose |
-| ----------------------------------------------------- | ------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
-| `src/routes/(main)/settings/features/componentMap.ts` | `src/routes/(main)/settings/features/componentMap.desktop.ts` | Settings tab โ†’ component map. Web uses dynamic `import()`; desktop uses sync imports. `componentMap.sync.test.ts` enforces identical keys. |
-| `src/routes/(main)/agent/index.tsx` | `src/routes/(main)/agent/index.desktop.tsx` | Page entry. Desktop variant overrides the web page wholesale (e.g. extra popup guards). |
-| `src/routes/(main)/group/index.tsx` | `src/routes/(main)/group/index.desktop.tsx` | Same pattern as agent. |
+| Base file (web) | Desktop file (Electron) | Purpose |
+| ------------------------------------------------ | -------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
+| `src/features/Settings/features/componentMap.ts` | `src/features/Settings/features/componentMap.desktop.ts` | Settings tab โ†’ component map. Web uses dynamic `import()`; desktop uses sync imports. `componentMap.sync.test.ts` enforces identical keys. |
+| `src/routes/(main)/agent/index.tsx` | `src/routes/(main)/agent/index.desktop.tsx` | Page entry. Desktop variant overrides the web page wholesale (e.g. extra popup guards). |
+| `src/routes/(main)/group/index.tsx` | `src/routes/(main)/group/index.desktop.tsx` | Same pattern as agent. |
**Rules:**
diff --git a/.agents/skills/upstash-workflow/SKILL.md b/.agents/skills/upstash-workflow/SKILL.md
index a8dc01f10ab..e659bb9c722 100644
--- a/.agents/skills/upstash-workflow/SKILL.md
+++ b/.agents/skills/upstash-workflow/SKILL.md
@@ -40,7 +40,7 @@ Layer 3: Single Task Execution (execute-* / generate-*)
โ””โ”€ Performs actual business logic for ONE item
```
-**Real examples in this codebase:** `welcome-placeholder`, `agent-welcome` โ€” see [`references/examples.md`](./references/examples.md).
+**Real examples in this codebase:** `topicAutoSummary`, `agentEvalRun` โ€” see [`references/examples.md`](./references/examples.md).
---
@@ -88,20 +88,23 @@ Defaults: `PAGE_SIZE = 50` (items per page), `CHUNK_SIZE = 20` (items per fan-ou
Layer 3 always processes exactly one item per invocation. Parallelism comes from Layer 2 fanning out to many Layer 3 invocations, controlled by `flowControl`:
```typescript
-export const { POST } = serve<ExecutePayload>(
- async (context) => {
- const { itemId } = context.requestPayload ?? {};
- if (!itemId) return { success: false, error: 'Missing itemId' };
-
- const item = await context.run('workflow:get-item', () => getItem(itemId));
- const result = await context.run('workflow:execute', () => processItem(item));
- await context.run('workflow:save', () => saveResult(itemId, result));
-
- return { success: true, itemId, result };
- },
- {
- flowControl: { key: 'workflow.execute', parallelism: 10, ratePerSecond: 5 },
- },
+app.post(
+ '/execute-item',
+ serve<ExecutePayload>(
+ async (context) => {
+ const { itemId } = context.requestPayload ?? {};
+ if (!itemId) return { success: false, error: 'Missing itemId' };
+
+ const item = await context.run('workflow:get-item', () => getItem(itemId));
+ const result = await context.run('workflow:execute', () => processItem(item));
+ await context.run('workflow:save', () => saveResult(itemId, result));
+
+ return { success: true, itemId, result };
+ },
+ {
+ flowControl: { key: 'workflow.execute', parallelism: 10, ratePerSecond: 5 },
+ },
+ ),
);
```
@@ -110,18 +113,23 @@ export const { POST } = serve<ExecutePayload>(
## File Structure
```text
-src/
-โ”œโ”€โ”€ app/(backend)/api/workflows/
-โ”‚ โ””โ”€โ”€ {workflow-name}/
-โ”‚ โ”œโ”€โ”€ process-{entities}/route.ts # Layer 1
-โ”‚ โ”œโ”€โ”€ paginate-{entities}/route.ts # Layer 2
-โ”‚ โ””โ”€โ”€ execute-{entity}/route.ts # Layer 3
-โ”‚
-โ””โ”€โ”€ server/workflows/
- โ””โ”€โ”€ {workflowName}/
- โ””โ”€โ”€ index.ts # Workflow class
+src/app/(backend)/api/workflows/
+โ””โ”€โ”€ [[...route]]/route.ts # Single catch-all โ€” forwards every request to the Hono app below
+
+apps/server/src/router-hono/workflows/
+โ”œโ”€โ”€ index.ts # Mounts each workflow's Hono app at /api/workflows/{workflow-name}
+โ””โ”€โ”€ {workflow-name}/
+ โ”œโ”€โ”€ index.ts # Hono app โ€” one `app.post('/{layer}', serve(handler, options))` per layer
+ โ”œโ”€โ”€ dispatch.ts / paginate-*.ts # Layer 1 + 2 handler(s) โ€” entry point, dry-run, pagination, fan-out
+ โ””โ”€โ”€ execute.ts / execute-*.ts # Layer 3 handler โ€” single-task execution
+
+apps/server/src/workflows/
+โ””โ”€โ”€ {workflowName}/
+ โ””โ”€โ”€ index.ts # Workflow class โ€” static trigger*() methods that POST to the routes above
```
+Routes are no longer one `route.ts` file per layer under `src/app`; every layer is a handler mounted on a per-workflow Hono app under `apps/server/src/router-hono/workflows/`, and the Next.js route only dispatches into it.
+
---
## Where to Go Next
@@ -185,5 +193,5 @@ QSTASH_URL=https://custom-qstash.com
- [Upstash Workflow Documentation](https://upstash.com/docs/workflow)
- [QStash Documentation](https://upstash.com/docs/qstash)
-- [Example Workflows in Codebase](<../../src/app/(backend)/api/workflows/>)
-- [Workflow Classes](../../apps/server/src/workflows/)
+- [Example Workflows in Codebase](<../../../src/app/(backend)/api/workflows/>)
+- [Workflow Classes](../../../apps/server/src/workflows/)
diff --git a/.agents/skills/upstash-workflow/references/cloud.md b/.agents/skills/upstash-workflow/references/cloud.md
index c94c87df242..1866cd1cfa3 100644
--- a/.agents/skills/upstash-workflow/references/cloud.md
+++ b/.agents/skills/upstash-workflow/references/cloud.md
@@ -1,27 +1,26 @@
# Cloud Project Workflow Configuration
-Cloud-specific workflow configurations and patterns for the lobehub-cloud project.
+How the cloud project serves workflows on top of the open-source submodule.
## Table of Contents
1. [Overview](#overview)
2. [Directory Structure](#directory-structure) โ€” submodule + cloud layout
-3. [Cloud-Specific Patterns](#cloud-specific-patterns) โ€” cloud-only workflows + re-export pattern
-4. [TypeScript Path Mappings](#typescript-path-mappings)
-5. [Workflow Class Location](#workflow-class-location) โ€” cloud-only vs shared
-6. [Environment Variables](#environment-variables)
-7. [Best Practices](#best-practices) โ€” decide cloud vs OSS, re-export rules, naming
-8. [Migration Guide](#migration-guide) โ€” moving workflows from cloud to lobehub
-9. [Examples](#examples) โ€” `welcome-placeholder`, `agent-eval-run`
-10. [Troubleshooting](#troubleshooting) โ€” circular imports, 404s, type errors
-11. [Related Documentation](#related-documentation)
+3. [Shared Workflows](#shared-workflows) โ€” served through the submodule catch-all
+4. [Cloud-Only Workflows](#cloud-only-workflows) โ€” separate `cloud/` catch-all
+5. [Path Mappings](#path-mappings)
+6. [Best Practices](#best-practices) โ€” decide cloud vs OSS
+7. [Migration Guide](#migration-guide) โ€” moving a workflow from cloud to lobehub
+8. [Troubleshooting](#troubleshooting)
## Overview
-The lobehub-cloud project extends the open-source lobehub codebase with cloud-specific features. Workflows can be implemented in either:
+Workflows live in one of two places:
-1. **Lobehub (open-source)** - Available to all users
-2. **Lobehub-cloud (proprietary)** - Cloud-specific business logic
+1. **Lobehub (open-source)** โ€” available to every deployment
+2. **Lobehub-cloud (proprietary)** โ€” cloud-only business logic
+
+Both use the same building blocks: a Next.js catch-all route that forwards into a Hono router, and one Hono sub-app per workflow with one `serve(...)` endpoint per layer.
---
@@ -31,325 +30,120 @@ The lobehub-cloud project extends the open-source lobehub codebase with cloud-sp
```text
lobehub/
-โ””โ”€โ”€ src/
- โ”œโ”€โ”€ app/(backend)/api/workflows/
- โ”‚ โ”œโ”€โ”€ memory-user-memory/ # Memory extraction workflows
- โ”‚ โ””โ”€โ”€ agent-eval-run/ # Benchmark evaluation workflows
- โ””โ”€โ”€ server/workflows/
- โ”œโ”€โ”€ agentEvalRun/
- โ””โ”€โ”€ ...
+โ”œโ”€โ”€ src/app/(backend)/api/workflows/
+โ”‚ โ””โ”€โ”€ [[...route]]/route.ts # Catch-all โ€” forwards into the Hono router below
+โ””โ”€โ”€ apps/server/src/
+ โ”œโ”€โ”€ router-hono/workflows/
+ โ”‚ โ”œโ”€โ”€ index.ts # Mounts each workflow's sub-app at /api/workflows/{name}
+ โ”‚ โ”œโ”€โ”€ agent-eval-run/
+ โ”‚ โ””โ”€โ”€ memory-user-memory/
+ โ””โ”€โ”€ workflows/
+ โ”œโ”€โ”€ agentEvalRun/ # Workflow class (static trigger*() methods)
+ โ””โ”€โ”€ memoryUserMemory/
```
### Lobehub-cloud (Proprietary)
```text
lobehub-cloud/
-โ””โ”€โ”€ src/
- โ”œโ”€โ”€ app/(backend)/api/workflows/
- โ”‚ โ”œโ”€โ”€ welcome-placeholder/ # Cloud-only: AI placeholder generation
- โ”‚ โ”œโ”€โ”€ agent-welcome/ # Cloud-only: Agent welcome messages
- โ”‚ โ”œโ”€โ”€ agent-eval-run/ # Re-export from lobehub
- โ”‚ โ””โ”€โ”€ memory-user-memory/ # Re-export from lobehub
- โ””โ”€โ”€ server/workflows/
- โ”œโ”€โ”€ welcomePlaceholder/
- โ”œโ”€โ”€ agentWelcome/
- โ””โ”€โ”€ agentEvalRun/ # Re-export from lobehub
+โ”œโ”€โ”€ src/app/(backend)/api/workflows/
+โ”‚ โ”œโ”€โ”€ [[...route]]/route.ts # One-line re-export of the submodule catch-all
+โ”‚ โ””โ”€โ”€ cloud/[[...route]]/route.ts # Catch-all for cloud-only workflows
+โ””โ”€โ”€ apps/server/src/cloud-workflow/
+ โ”œโ”€โ”€ index.ts # Cloud Hono router, basePath /api/workflows/cloud
+ โ””โ”€โ”€ feature-name/
+ โ”œโ”€โ”€ index.ts # Sub-app โ€” one app.post('/{layer}', serve(...)) per layer
+ โ”œโ”€โ”€ handlers/ # One handler per layer
+ โ””โ”€โ”€ workflow.ts # Workflow class + payload types
```
----
-
-## Cloud-Specific Patterns
-
-### Pattern 1: Cloud-Only Workflows
+Next.js routes the more specific `cloud/` segment to the cloud catch-all, so the two routers never collide.
-**Use Case**: Features exclusive to cloud users (AI generation, premium features)
-
-**Example**: `welcome-placeholder`, `agent-welcome`
-
-**Implementation**:
+---
-- Implement directly in `lobehub-cloud/src/app/(backend)/api/workflows/`
-- No need for re-exports
-- Can use cloud-specific packages and services
+## Shared Workflows
-**Structure**:
+A workflow added to the submodule is served by cloud automatically: cloud's `[[...route]]/route.ts` re-exports the submodule catch-all, which already mounts every sub-app in `router-hono/workflows/index.ts`.
-```text
-lobehub-cloud/src/
-โ”œโ”€โ”€ app/(backend)/api/workflows/
-โ”‚ โ””โ”€โ”€ feature-name/
-โ”‚ โ”œโ”€โ”€ process-items/route.ts
-โ”‚ โ”œโ”€โ”€ paginate-items/route.ts
-โ”‚ โ””โ”€โ”€ execute-item/route.ts
-โ””โ”€โ”€ server/workflows/
- โ””โ”€โ”€ featureName/
- โ””โ”€โ”€ index.ts
+```typescript
+// lobehub-cloud/src/app/(backend)/api/workflows/[[...route]]/route.ts
+export { POST } from 'lobehub/src/app/(backend)/api/workflows/[[...route]]/route';
```
----
-
-### Pattern 2: Re-export from Lobehub
+Do not add per-workflow re-export files in cloud. Import the submodule route through the `lobehub/...` path, not `@/...`, to avoid a circular alias.
-**Use Case**: Workflows implemented in open-source but also used in cloud
+---
-**Example**: `agent-eval-run`, `memory-user-memory`
+## Cloud-Only Workflows
-**Why Re-export?**
+Implement cloud-only workflows under `apps/server/src/cloud-workflow/<name>/` and mount the sub-app in `apps/server/src/cloud-workflow/index.ts`:
-- Cloud deployment needs to serve these endpoints
-- Lobehub submodule code is not directly accessible in cloud routes
-- Allows cloud-specific overrides if needed in the future
+```typescript
+// lobehub-cloud/apps/server/src/cloud-workflow/feature-name/index.ts
+import { serve } from '@upstash/workflow/hono';
+import { Hono } from 'hono';
-#### Re-export Implementation
+import { createWorkflowQstashClient } from '@/server/router-hono/workflows/qstashClient';
-**Step 1**: Implement workflow in lobehub submodule
+const app = new Hono();
-```typescript
-// lobehub/src/app/(backend)/api/workflows/feature/layer/route.ts
-import { serve } from '@upstash/workflow/nextjs';
-
-export const { POST } = serve<Payload>(
- async (context) => {
- // Implementation
- },
- { flowControl: { ... } }
+app.post(
+ '/process-items',
+ serve<ProcessItemsPayload>((context) => runProcessItems(context), {
+ flowControl: { key: 'feature-name.process-items', parallelism: 1, ratePerSecond: 1 },
+ qstashClient: createWorkflowQstashClient(),
+ }),
);
-```
-**Step 2**: Create re-export in lobehub-cloud
+export default app;
+```
```typescript
-// lobehub-cloud/src/app/(backend)/api/workflows/feature/layer/route.ts
-export { POST } from 'lobehub/src/app/(backend)/api/workflows/feature/layer/route';
+// lobehub-cloud/apps/server/src/cloud-workflow/index.ts
+app.route('/feature-name', featureNameApp);
```
-**Important**: Use `lobehub/src/...` path, NOT `@/...` to avoid circular imports.
-
-#### Re-export Directory Structure
-
-```bash
-# Create directories
-mkdir -p lobehub-cloud/src/app/(backend)/api/workflows/feature-name/layer-1
-mkdir -p lobehub-cloud/src/app/(backend)/api/workflows/feature-name/layer-2
-mkdir -p lobehub-cloud/src/app/(backend)/api/workflows/feature-name/layer-3
-
-# Create re-export files
-echo "export { POST } from 'lobehub/src/app/(backend)/api/workflows/feature-name/layer-1/route';" > \
- lobehub-cloud/src/app/(backend)/api/workflows/feature-name/layer-1/route.ts
-
-echo "export { POST } from 'lobehub/src/app/(backend)/api/workflows/feature-name/layer-2/route';" > \
- lobehub-cloud/src/app/(backend)/api/workflows/feature-name/layer-2/route.ts
-
-echo "export { POST } from 'lobehub/src/app/(backend)/api/workflows/feature-name/layer-3/route';" > \
- lobehub-cloud/src/app/(backend)/api/workflows/feature-name/layer-3/route.ts
-```
+Their endpoints live under `/api/workflows/cloud/<name>/<layer>`, so the workflow class must trigger that path.
---
-## TypeScript Path Mappings
+## Path Mappings
-The cloud project uses tsconfig path mappings to override lobehub code:
+Cloud resolves `@/server/*` through cloud code first, then the submodule:
```json
// lobehub-cloud/tsconfig.json
-{
- "compilerOptions": {
- "paths": {
- "@/*": ["./src/*", "./lobehub/src/*"]
- }
- }
-}
+"@/server/*": ["./src/server/*", "./apps/server/src/*", "./lobehub/apps/server/src/*"]
```
-**Resolution Order**:
-
-1. `./src/*` (cloud code) - checked first
-2. `./lobehub/src/*` (open-source) - fallback
-
-This allows cloud to override specific modules while using lobehub defaults.
-
----
-
-## Workflow Class Location
-
-### Cloud-Only Workflows
-
-Place workflow class in cloud:
-
-```text
-lobehub-cloud/apps/server/src/workflows/featureName/index.ts
-```
-
-### Shared Workflows
-
-Place workflow class in lobehub, re-export in cloud if needed:
-
-```text
-lobehub/apps/server/src/workflows/featureName/index.ts
-```
-
----
-
-## Environment Variables
-
-Both lobehub and cloud workflows require:
-
-```bash
-# Required for all workflows
-APP_URL=https://your-app.com # Base URL for workflow endpoints
-QSTASH_TOKEN=qstash_xxx # QStash authentication token
-
-# Optional (for custom QStash URL)
-QSTASH_URL=https://custom-qstash.com # Custom QStash endpoint
-```
-
-**Cloud-Specific**:
-
-```bash
-# Cloud database (for monetization features)
-CLOUD_DATABASE_URL=postgresql://...
-
-# Cloud-specific services
-REDIS_URL=redis://...
-```
+Cloud-only workflows can therefore import shared helpers such as `@/server/router-hono/workflows/qstashClient` directly.
---
## Best Practices
-### 1. Decide: Cloud or Open-Source?
-
**Implement in Lobehub if**:
-- Feature is useful for all LobeHub users
-- No proprietary business logic
-- Can be open-sourced
+- The feature is useful for every deployment
+- It contains no proprietary business logic
**Implement in Cloud if**:
-- Premium/paid feature
-- Uses cloud-specific services
-- Contains proprietary algorithms
-
-### 2. Re-export Pattern
+- It depends on cloud-only services or data
+- It contains proprietary business logic
-โœ… **Do**:
-
-```typescript
-// Simple re-export
-export { POST } from 'lobehub/src/app/(backend)/api/workflows/feature/route';
-```
-
-โŒ **Don't**:
-
-```typescript
-// Avoid circular imports with @/ path
-export { POST } from '@/app/(backend)/api/workflows/feature/route'; // โŒ
-```
-
-### 3. Keep Workflow Logic in Lobehub
-
-For shared features:
-
-- Implement core logic in `lobehub/` (open-source)
-- Only override if cloud needs different behavior
-- Use re-exports for cloud deployment
-
-### 4. Directory Naming
-
-Follow consistent naming across lobehub and cloud:
-
-```text
-# Both should use same structure
-lobehub/src/app/(backend)/api/workflows/feature-name/
-lobehub-cloud/src/app/(backend)/api/workflows/feature-name/
-```
+Keep shared logic in `lobehub/` and let cloud consume it through the catch-all re-export; override only when cloud needs different behavior.
---
## Migration Guide
-### Moving Workflow from Cloud to Lobehub
-
-**Step 1**: Copy workflow to lobehub
-
-```bash
-cp -r lobehub-cloud/src/app/(backend)/api/workflows/feature \
- lobehub/src/app/(backend)/api/workflows/
-```
-
-**Step 2**: Remove cloud-specific dependencies
-
-- Replace cloud services with generic interfaces
-- Remove proprietary business logic
-- Update imports to use lobehub paths
-
-**Step 3**: Create re-exports in cloud
-
-```typescript
-// lobehub-cloud/src/app/(backend)/api/workflows/feature/*/route.ts
-export { POST } from 'lobehub/src/app/(backend)/api/workflows/feature/*/route';
-```
-
-**Step 4**: Move workflow class to lobehub
-
-```bash
-mv lobehub-cloud/apps/server/src/workflows/feature \
- lobehub/apps/server/src/workflows/
-```
-
-**Step 5**: Update cloud imports
-
-```typescript
-// Change from
-import { Workflow } from '@/server/workflows/feature';
-
-// To
-import { Workflow } from 'lobehub/apps/server/src/workflows/feature';
-```
-
----
-
-## Examples
+### Moving a Workflow from Cloud to Lobehub
-### Cloud-Only Workflow: welcome-placeholder
-
-**Location**: `lobehub-cloud/src/app/(backend)/api/workflows/welcome-placeholder/`
-
-**Why Cloud-Only**: Uses proprietary AI generation service and Redis caching
-
-**Structure**:
-
-```text
-lobehub-cloud/
-โ”œโ”€โ”€ src/app/(backend)/api/workflows/welcome-placeholder/
-โ”‚ โ”œโ”€โ”€ process-users/route.ts
-โ”‚ โ”œโ”€โ”€ paginate-users/route.ts
-โ”‚ โ””โ”€โ”€ generate-user/route.ts
-โ””โ”€โ”€ apps/server/src/workflows/welcomePlaceholder/
- โ””โ”€โ”€ index.ts
-```
-
-### Re-exported Workflow: agent-eval-run
-
-**Location**:
-
-- Implementation: `lobehub/src/app/(backend)/api/workflows/agent-eval-run/`
-- Re-export: `lobehub-cloud/src/app/(backend)/api/workflows/agent-eval-run/`
-
-**Why Re-export**: Core feature available in open-source, also used by cloud
-
-**Cloud Re-export Files**:
-
-```typescript
-// lobehub-cloud/src/app/(backend)/api/workflows/agent-eval-run/run-benchmark/route.ts
-export { POST } from 'lobehub/src/app/(backend)/api/workflows/agent-eval-run/run-benchmark/route';
-
-// lobehub-cloud/src/app/(backend)/api/workflows/agent-eval-run/paginate-test-cases/route.ts
-export { POST } from 'lobehub/src/app/(backend)/api/workflows/agent-eval-run/paginate-test-cases/route';
-
-// ... (all layers)
-```
+1. Move the sub-app from `lobehub-cloud/apps/server/src/cloud-workflow/<name>/` to `lobehub/apps/server/src/router-hono/workflows/<name>/`, and its class to `lobehub/apps/server/src/workflows/<name>/`.
+2. Replace cloud-only services with generic interfaces and remove proprietary logic.
+3. Mount the sub-app in `lobehub/apps/server/src/router-hono/workflows/index.ts` and remove it from `cloud-workflow/index.ts`.
+4. Update the class's trigger URLs from `/api/workflows/cloud/<name>/...` to `/api/workflows/<name>/...`.
---
@@ -357,44 +151,18 @@ export { POST } from 'lobehub/src/app/(backend)/api/workflows/agent-eval-run/pag
### Circular Import Error
-**Error**: `Circular definition of import alias 'POST'`
-
-**Cause**: Using `@/` path in re-export within cloud codebase
-
-**Solution**: Use `lobehub/src/` path instead
-
-```typescript
-// โŒ Wrong
-export { POST } from '@/app/(backend)/api/workflows/feature/route';
+**Error**: `Circular definition of import alias`
-// โœ… Correct
-export { POST } from 'lobehub/src/app/(backend)/api/workflows/feature/route';
-```
+**Cause**: Cloud's catch-all re-export uses `@/app/...` instead of `lobehub/src/app/...`.
### Workflow Not Found (404)
-**Cause**: Missing re-export in cloud
-
-**Solution**: Create re-export files for all workflow layers
-
-```bash
-# Check if re-export exists
-ls lobehub-cloud/src/app/\(backend\)/api/workflows/feature-name/
-
-# If missing, create re-exports
-mkdir -p lobehub-cloud/src/app/\(backend\)/api/workflows/feature-name/layer
-echo "export { POST } from 'lobehub/src/app/(backend)/api/workflows/feature-name/layer/route';" > lobehub-cloud/src/app/\(backend\)/api/workflows/feature-name/layer/route.ts
-```
+- Shared workflow: check that the sub-app is mounted in `lobehub/apps/server/src/router-hono/workflows/index.ts`.
+- Cloud-only workflow: check that it is mounted in `cloud-workflow/index.ts` and that the trigger URL includes the `/cloud` segment.
### Type Errors After Moving to Lobehub
-**Cause**: Cloud-specific types or services used in lobehub code
-
-**Solution**:
-
-1. Extract cloud-specific logic to cloud-only wrapper
-2. Use dependency injection for services
-3. Define generic interfaces in lobehub
+Cloud-only types or services leaked into the moved code. Keep them in a cloud-side wrapper or inject them through a generic interface.
---
diff --git a/.agents/skills/upstash-workflow/references/examples.md b/.agents/skills/upstash-workflow/references/examples.md
index 33deffb4bd9..e1ce4af8185 100644
--- a/.agents/skills/upstash-workflow/references/examples.md
+++ b/.agents/skills/upstash-workflow/references/examples.md
@@ -1,91 +1,156 @@
# Worked Examples
-Two real workflows already in the codebase that follow this skill's pattern verbatim. Skim them when you want to see the pattern applied to concrete entities.
+Two real workflows already in the codebase that follow this skill's pattern. Skim them when you want to see the pattern applied to concrete entities.
-## Example 1: Welcome Placeholder
+## Example 1: Topic Auto Summary
-**Use case:** Generate AI-powered welcome placeholders for users.
+**Use case:** Summarize idle conversation topics.
**Structure:**
-- Layer 1: `process-users` โ€” entry point, checks eligible users
-- Layer 2: `paginate-users` โ€” paginates through active users
-- Layer 3: `generate-user` โ€” generates placeholders for ONE user
+- `dispatch` โ€” combined Layer 1 + 2: validates the request, supports `dryRun`, paginates candidate topics with a cursor, and re-triggers itself for the next page
+- `execute` โ€” Layer 3: summarizes ONE topic
**Key features:**
-- Filters users who already have cached placeholders in Redis
-- `paidOnly` flag to scope to subscribed users
-- `dryRun` mode for statistics
-- Fan-out for large user batches (`CHUNK_SIZE=20`)
+- `dryRun` mode walks the same cursor loop without scheduling anything, returning a candidate count
+- Cursor-based pagination (`DEFAULT_PAGE_SIZE = 100`) instead of a separate fan-out chunk step โ€” each page is small enough to trigger directly with `Promise.all`
+- `flowControl` keyed per user on the execute layer (`topic-auto-summary.execute.user.${userId}`) so one user's backlog can't starve others
-**Layer 3 shape:**
+**Dispatch shape** (`apps/server/src/router-hono/workflows/topic-auto-summary/dispatch.ts`):
```typescript
-export const { POST } = serve<GenerateUserPlaceholderPayload>(async (context) => {
- const { userId } = context.requestPayload ?? {};
+export const dispatchTopicAutoSummary = async (
+ context: WorkflowContext<DispatchTopicAutoSummaryPayload>,
+) => {
+ const payload = context.requestPayload ?? {};
+ // ...bounds-check idleMinutes/lookbackHours/maxTopics/pageSize, short-circuit on dryRun...
+
+ const candidates = await listCandidates(payload.cursor, Math.min(pageSize, remaining));
+
+ await Promise.all(
+ candidates.map((candidate) =>
+ runStep(context, `topic-auto-summary:schedule:${candidate.id}`, () =>
+ TopicAutoSummaryWorkflow.triggerExecute({
+ force: payload.force,
+ topicId: candidate.id,
+ userId: candidate.userId,
+ workspaceId: candidate.workspaceId ?? undefined,
+ }),
+ ),
+ ),
+ );
+
+ // ...if there's a next page, `runStep` โ†’ `TopicAutoSummaryWorkflow.triggerDispatch(...)` with the new cursor...
+ return { hasNextPage, processed: nextProcessed, scheduled: candidates.length };
+};
+```
- const workflow = new WelcomePlaceholderWorkflow(db, userId);
- const placeholders = await context.run('generate', () => workflow.generate());
+**Execute shape** (`apps/server/src/router-hono/workflows/topic-auto-summary/execute.ts`):
- return { success: true, userId, placeholdersCount: placeholders.length };
-});
+```typescript
+export const executeTopicAutoSummary = async (
+ context: WorkflowContext<ExecuteTopicAutoSummaryPayload>,
+) => {
+ const { force, topicId, userId, workspaceId } = context.requestPayload ?? {};
+ if (!topicId || !userId) return { error: 'Missing topicId or userId', summarized: false };
+
+ return runStep(context, 'topic-auto-summary:generate-and-save', async () => {
+ const db = await getServerDB();
+ return new TopicAutoSummaryService(db, userId, workspaceId).summarize(topicId, { force });
+ });
+};
```
**Files:**
-- `/api/workflows/welcome-placeholder/process-users/route.ts`
-- `/api/workflows/welcome-placeholder/paginate-users/route.ts`
-- `/api/workflows/welcome-placeholder/generate-user/route.ts`
-- `/server/workflows/welcomePlaceholder/index.ts`
+- `apps/server/src/router-hono/workflows/topic-auto-summary/index.ts` โ€” Hono app, mounts `/dispatch` and `/execute` with `serve(...)`
+- `apps/server/src/router-hono/workflows/topic-auto-summary/dispatch.ts`
+- `apps/server/src/router-hono/workflows/topic-auto-summary/execute.ts`
+- `apps/server/src/workflows/topicAutoSummary/index.ts` โ€” `TopicAutoSummaryWorkflow` class (`triggerDispatch`, `triggerExecute`)
---
-## Example 2: Agent Welcome
+## Example 2: Agent Eval Run
-**Use case:** Generate welcome messages and open questions for AI agents.
+**Use case:** Run an evaluation benchmark's test cases against an agent.
**Structure:**
-- Layer 1: `process-agents` โ€” entry point, checks eligible agents
-- Layer 2: `paginate-agents` โ€” paginates through active agents
-- Layer 3: `generate-agent` โ€” generates welcome data for ONE agent
+- `run-benchmark` โ€” Layer 1: entry point, checks run status, supports `dryRun`
+- `paginate-test-cases` โ€” Layer 2: cursor pagination + fan-out
+- `execute-test-case` โ€” Layer 3: runs ONE test case (which itself triggers further per-attempt trajectory workflows โ€” out of scope for this pattern)
**Key features:**
-- Filters agents who already have cached data in Redis
-- `paidOnly` flag for subscribed users' agents only
-- `dryRun` mode for statistics
-- Fan-out for large agent batches (`CHUNK_SIZE=20`)
+- Filters test cases that already have results before scheduling work
+- `dryRun` mode for statistics only
+- Fan-out for large batches: `PAGE_SIZE = 50`, `CHUNK_SIZE = 20`
+
+**Layer 2 fan-out** (`apps/server/src/router-hono/workflows/agent-eval-run/workflows/paginateTestCases.ts`):
+
+```typescript
+const CHUNK_SIZE = 20; // Max items to process directly
+const PAGE_SIZE = 50; // Items per page
+
+export const paginateTestCasesHandler = async (
+ context: WorkflowContext<PaginateTestCasesPayload>,
+) => {
+ // ...resolve run, paginate test cases, filter ones that need execution...
+
+ if (testCaseIds.length > CHUNK_SIZE) {
+ const chunks = chunk(testCaseIds, CHUNK_SIZE);
+ await Promise.all(
+ chunks.map((ids, idx) =>
+ runStep(context, `agent-eval-run:fanout:${idx + 1}/${chunks.length}`, () =>
+ AgentEvalRunWorkflow.triggerPaginateTestCases({ runId, testCaseIds: ids, userId }),
+ ),
+ ),
+ );
+ } else {
+ await Promise.all(
+ testCaseIds.map((testCaseId) =>
+ runStep(context, `agent-eval-run:execute:${testCaseId}`, () =>
+ AgentEvalRunWorkflow.triggerExecuteTestCase({ runId, testCaseId, userId }),
+ ),
+ ),
+ );
+ }
+
+ // ...if there's a next page, `runStep` โ†’ `AgentEvalRunWorkflow.triggerPaginateTestCases(...)` with the new cursor...
+};
+```
-**Layer 3 shape:**
+**Layer 3 shape** (`apps/server/src/router-hono/workflows/agent-eval-run/workflows/executeTestCase.ts`):
```typescript
-export const { POST } = serve<GenerateAgentWelcomePayload>(async (context) => {
- const { agentId } = context.requestPayload ?? {};
+export const executeTestCaseHandler = async (context: WorkflowContext<ExecuteTestCasePayload>) => {
+ const { runId, testCaseId, userId } = context.requestPayload ?? {};
+ // ...load the run, bail out if aborted...
- const workflow = new AgentWelcomeWorkflow(db, agentId);
- const data = await context.run('generate', () => workflow.generate());
+ await runStep(context, `agent-eval-run:trajectory:${runId}:${testCaseId}`, () =>
+ AgentEvalRunWorkflow.triggerRunAgentTrajectory({ runId, testCaseId, userId }),
+ );
- return { success: true, agentId, data };
-});
+ return { k, success: true, testCaseId };
+};
```
**Files:**
-- `/api/workflows/agent-welcome/process-agents/route.ts`
-- `/api/workflows/agent-welcome/paginate-agents/route.ts`
-- `/api/workflows/agent-welcome/generate-agent/route.ts`
-- `/server/workflows/agentWelcome/index.ts`
+- `apps/server/src/router-hono/workflows/agent-eval-run/index.ts` โ€” Hono app, mounts one route per layer with `serve(...)`
+- `apps/server/src/router-hono/workflows/agent-eval-run/workflows/runBenchmark.ts`
+- `apps/server/src/router-hono/workflows/agent-eval-run/workflows/paginateTestCases.ts`
+- `apps/server/src/router-hono/workflows/agent-eval-run/workflows/executeTestCase.ts`
+- `apps/server/src/workflows/agentEvalRun/index.ts` โ€” `AgentEvalRunWorkflow` class (`triggerRunBenchmark`, `triggerPaginateTestCases`, `triggerExecuteTestCase`, โ€ฆ)
---
## What's identical, what differs
-Both workflows are the **same pattern** โ€” they only differ in:
+Both workflows share the same core ideas โ€” dry-run, cursor pagination, `flowControl` tuning, a workflow class with static `trigger*()` methods โ€” but apply them differently:
-- Entity type (users vs agents)
-- Business logic (placeholder generation vs welcome generation)
-- Data source (different database queries)
+- Agent Eval Run keeps the classic 3-layer split with an explicit fan-out chunk step (`CHUNK_SIZE`) once a page has more items than it wants to trigger directly.
+- Topic Auto Summary collapses Layers 1+2 into a single `dispatch` handler and triggers every candidate in a page directly, relying on a smaller page size instead of a separate chunking step.
-Everything else โ€” the 3-layer split, dry-run handling, fan-out, filter-existing, flowControl tuning โ€” is identical. That's the whole point: once you internalize the pattern, adding a new workflow is mostly entity-substitution.
+Pick whichever shape fits the entity: a chunked fan-out when pages can be large and bursty, a single dispatch loop when a page is already small enough to trigger directly.
diff --git a/.agents/skills/version-release/references/patch-release-scenarios.md b/.agents/skills/version-release/references/patch-release-scenarios.md
index 0ac97f7758d..e32e297d8e7 100644
--- a/.agents/skills/version-release/references/patch-release-scenarios.md
+++ b/.agents/skills/version-release/references/patch-release-scenarios.md
@@ -68,6 +68,7 @@ git push -u origin hotfix/v{version}-{short-hash}
- **Hotfix owner**: Use the actual PR author (retrieve via `gh pr view <number> --json author --jq '.author.login'`), never hardcode a username.
4. **While the PR is open**: `release-pr-version.yml` commits `package.json` to latest stable tag + patch.
+
5. **After merge**: auto-tag-release detects `hotfix/*` branch โ†’ tags latest stable tag +1.
### Script
@@ -110,7 +111,7 @@ git cherry-pick <migration-commit-hash>
git push -u origin release/db-migration-{name}
```
-2. **Write a migration-specific changelog** โ€” See `db-migration-changelog-example.md` for the format. This should explain:
+2. **Write a migration-specific changelog** โ€” See `changelog-example/db-migration.md` for the format. This should explain:
- What tables/columns are added, modified, or removed
- Whether the migration is backwards-compatible
- Any action required by self-hosted users