ClawScale Gateway is the platform layer that connects customer-facing channels to a business runtime. In this repository it is used by Coke/Kap: Gateway owns customer accounts, channel records, shared-channel provisioning, delivery-route state, and the web/API surfaces that sit between public channels and the Coke runtime.
The current architecture is not the old "generic AI backend dashboard" model. Gateway no longer presents itself as an OpenClaw wrapper, a multi-backend chat command system, or a CLI bridge product. Its live role is to provide a stable channel and customer platform for the Coke supervision runtime.
- Customer provisioning - create and authenticate customer accounts, resolve external identities, provision customer ownership, and expose customer account flows.
- Customer-owned channels - let a signed-in customer manage their own
personal channel, currently centered on
wechat_personal. - Shared channels - let an admin configure a shared channel once, then map inbound external users into Gateway customers through normalized external identities.
- Inbound routing - normalize channel webhooks into
routeInboundMessage()and forward business messages to the configured agent/runtime boundary. - Outbound delivery - receive Coke runtime output through
/api/outbound, resolve the exact delivery route, apply idempotency, and send the message through the owning channel adapter. - Admin operations - expose admin views for agents, customers, channels, shared channels, deliveries, and admin accounts.
External channel
-> Gateway channel adapter / webhook route
-> ExternalIdentity + Customer provisioning
-> Business conversation + delivery route
-> Agent/runtime endpoint
-> /api/outbound
-> Gateway outbound delivery
-> External channel
The web app runs on 4040. The API runs on 4041.
The Coke Python runtime and bridge are separate processes. Gateway owns the platform/channel side; Coke owns business memory, workflows, reminders, and the assistant turn pipeline.
wechat_personal is the current customer-facing personal channel flow.
Supported customer pages and APIs:
/channels/wechat-personalGET /api/customer/channels/wechat-personal/statusPOST /api/customer/channels/wechat-personalPOST /api/customer/channels/wechat-personal/connectPOST /api/customer/channels/wechat-personal/disconnectDELETE /api/customer/channels/wechat-personal
Gateway treats the channel row as the source of truth for ownership and lifecycle state.
Shared channels are admin-managed channels that many external users can enter through. On first inbound contact, Gateway:
- normalizes the external identity by provider, identity type, and value
- creates or reuses the matching
Customer - creates an unclaimed owner identity and agent binding when needed
- provisions the configured shared-channel agent
- parks the inbound event if provisioning is still pending
This README describes the Gateway-owned model. The current active shared-channel
kinds and provider webhook paths are canonicalized in
../docs/ARCHITECTURE.md and the route/API index in
../docs/product-specs/FEATURE_TREE.md.
Stable admin/API entrypoints:
/admin/shared-channels/api/admin/shared-channels
Shared-channel secrets stay server-side. Public/admin responses must not expose stored webhook tokens or provider credentials.
Gateway uses audience-first route namespaces:
/api/auth/*- customer authentication and session hydration/api/customer/*- signed-in customer resources and customer-triggered actions/api/public/*- unauthenticated tokenized or externally linked handoff endpoints/api/webhooks/*- third-party callbacks/api/admin/*- authenticated admin/operator interfaces/api/internal/*- bridge/runtime/internal operational calls
Do not add new public routes under /coke/*, /api/coke/*, or /user/*.
Those names are retired compatibility surfaces.
Prerequisites:
- Node.js 20+
- pnpm 9+
- PostgreSQL
Setup:
cp .env.example .env
pnpm install
pnpm db:pushRun API and web:
pnpm devOr run them separately:
pnpm --dir packages/api dev
pnpm --dir packages/web devUseful URLs:
- Web:
http://localhost:4040 - API health:
http://localhost:4041/health - Admin:
http://localhost:4040/admin/login - Customer login:
http://localhost:4040/auth/login - Personal channel setup:
http://localhost:4040/channels/wechat-personal
Core:
DATABASE_URLADMIN_JWT_SECRETCUSTOMER_JWT_SECRETCORS_ORIGINDOMAIN_CLIENTNEXT_PUBLIC_API_URLNEXT_PUBLIC_COKE_API_URL
Coke/ClawScale runtime boundary:
CLAWSCALE_OUTBOUND_API_KEYCLAWSCALE_IDENTITY_API_KEYCOKE_PLATFORM_TENANT_ID
Email and subscription flows:
RESEND_API_KEYEMAIL_FROMEMAIL_FROM_NAMESTRIPE_SECRET_KEYSTRIPE_WEBHOOK_SECRETSTRIPE_PRICE_ID
Shared-channel adapters may require additional provider-specific secrets.
Run all Gateway tests:
pnpm testRun focused package tests:
pnpm --dir packages/api test
pnpm --dir packages/web testUseful focused areas:
pnpm --dir packages/api test -- src/routes/admin-shared-channels.test.ts src/lib/shared-channel-provisioning.test.ts src/routes/outbound.test.ts
pnpm --dir packages/web test -- 'app/(admin)/admin/shared-channels/page.test.tsx' 'app/(customer)/channels/wechat-personal/page.test.tsx'packages/
api/ Hono API, Prisma schema, channel adapters, routing, delivery
web/ Next.js public, customer, and admin surfaces
shared/ shared TypeScript types
The following older README claims are no longer the current Gateway product positioning:
- OpenClaw wrapper or comparison-driven positioning
- end-user chat commands such as
/teamand/backendsas the main product - generic multi-AI-backend dashboard as the primary surface
- public
/coke/*or/api/coke/*compatibility routes - Coke-owned direct channel runtimes outside the Gateway/channel boundary