π€― 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.
Cloud Project Workflow Configuration
How the cloud project serves workflows on top of the open-source submodule.
Table of Contents
- Overview
- Directory Structure β submodule + cloud layout
- Shared Workflows β served through the submodule catch-all
- Cloud-Only Workflows β separate
cloud/catch-all - Path Mappings
- Best Practices β decide cloud vs OSS
- Migration Guide β moving a workflow from cloud to lobehub
- Troubleshooting
Overview
Workflows live in one of two places:
- Lobehub (open-source) β available to every deployment
- 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.
Directory Structure
Lobehub Submodule (Open-source)
lobehub/
βββ 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)
lobehub-cloud/
βββ 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
Next.js routes the more specific cloud/ segment to the cloud catch-all, so the two routers never collide.
Shared Workflows
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.
// lobehub-cloud/src/app/(backend)/api/workflows/[[...route]]/route.ts
export { POST } from 'lobehub/src/app/(backend)/api/workflows/[[...route]]/route';
Do not add per-workflow re-export files in cloud. Import the submodule route through the lobehub/... path, not @/..., to avoid a circular alias.
Cloud-Only Workflows
Implement cloud-only workflows under apps/server/src/cloud-workflow/<name>/ and mount the sub-app in apps/server/src/cloud-workflow/index.ts:
// lobehub-cloud/apps/server/src/cloud-workflow/feature-name/index.ts
import { serve } from '@upstash/workflow/hono';
import { Hono } from 'hono';
import { createWorkflowQstashClient } from '@/server/router-hono/workflows/qstashClient';
const app = new Hono();
app.post(
'/process-items',
serve<ProcessItemsPayload>((context) => runProcessItems(context), {
flowControl: { key: 'feature-name.process-items', parallelism: 1, ratePerSecond: 1 },
qstashClient: createWorkflowQstashClient(),
}),
);
export default app;
// lobehub-cloud/apps/server/src/cloud-workflow/index.ts
app.route('/feature-name', featureNameApp);
Their endpoints live under /api/workflows/cloud/<name>/<layer>, so the workflow class must trigger that path.
Path Mappings
Cloud resolves @/server/* through cloud code first, then the submodule:
// lobehub-cloud/tsconfig.json
"@/server/*": ["./src/server/*", "./apps/server/src/*", "./lobehub/apps/server/src/*"]
Cloud-only workflows can therefore import shared helpers such as @/server/router-hono/workflows/qstashClient directly.
Best Practices
Implement in Lobehub if:
- The feature is useful for every deployment
- It contains no proprietary business logic
Implement in Cloud if:
- It depends on cloud-only services or data
- It contains proprietary business logic
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 a Workflow from Cloud to Lobehub
- Move the sub-app from
lobehub-cloud/apps/server/src/cloud-workflow/<name>/tolobehub/apps/server/src/router-hono/workflows/<name>/, and its class tolobehub/apps/server/src/workflows/<name>/. - Replace cloud-only services with generic interfaces and remove proprietary logic.
- Mount the sub-app in
lobehub/apps/server/src/router-hono/workflows/index.tsand remove it fromcloud-workflow/index.ts. - Update the class's trigger URLs from
/api/workflows/cloud/<name>/...to/api/workflows/<name>/....
Troubleshooting
Circular Import Error
Error: Circular definition of import alias
Cause: Cloud's catch-all re-export uses @/app/... instead of lobehub/src/app/....
Workflow Not Found (404)
- 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.tsand that the trigger URL includes the/cloudsegment.
Type Errors After Moving to 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.
Related Documentation
- SKILL.md - Standard workflow patterns