The local daemon authenticates writes to cockpitapp.vercel.app (patch_project_state, /api/orchestration/runs/<id>/finish, etc.) via the COCKPIT_DAEMON_TOKEN bearer. src/lib/session.ts:getApiUserId only honors that token when COCKPIT_ALLOW_LEGACY_DAEMON_TOKEN=1 is also set on the server — a safety gate to prevent accidental multi-tenant misuse. Verified by curl: PATCH /api/project-states/<tab> returns 401 without the flag, even with a valid token. With the flag, the daemon-side loop (state push + outcome finish) closes against the cloud deployment. Companion change: set COCKPIT_ALLOW_LEGACY_DAEMON_TOKEN=1 on Vercel production (via vercel env add, no commit). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Cockpit
Cockpit is a multi-user dashboard for running AI agent fleets across projects, with life-OS views layered into the same interface. Users sign in with GitHub, register projects, launch and monitor agents, and keep goals, people, habits, money, and events in one place.
Stack
- Next.js 16 (App Router, Server Components, Server Actions)
- TypeScript strict — schema is SSOT for types via Drizzle's
$inferSelect/$inferInsert - Tailwind CSS 4 + shadcn/ui
- NextAuth v5 beta with GitHub OAuth
- Drizzle ORM on PostgreSQL 17
- zod validation at API boundaries
Views
| Route | What's there |
|---|---|
/ |
Landing page with sign-in entry |
/setup |
Bootstrap flow when no users exist yet |
/sign-in |
GitHub sign-in |
/today |
Calendar, weather, commitments, bills, daily habit check-off |
/control |
Agent fleet command center and orchestration status |
/projects |
Projects, repo health, sync actions, inline editing |
/goals |
Hierarchical goals, milestones, inline target/progress edit |
/people |
Contacts, search, detail panel, inline name/notes edit |
/habits |
30-day heatmap per habit, streak indicator, summary stats |
/events |
Opportunities and deadlines, filter chips, archive flow |
/money |
Subscriptions and monthly burn |
/prompts |
Prompt library, run-now flow, scheduler |
/system |
Runtime health, uptime, autopilot jobs |
/thoughts |
Published essays on architecture and execution systems |
/settings |
Profile and team invite management |
/u/[username] |
Public user profile |
/invite/[token] |
Invitation acceptance flow |
Architecture
src/
├── app/ Pages, auth flows, and API routes
├── components/
│ ├── ui/ Shared primitives and layout helpers
│ ├── shell/ App shell, navigation, shared chrome
│ ├── control/ Agent fleet controls and project cards
│ └── <domain>/ today, people, projects, goals, money, habits, events,
│ prompts, settings, system
├── config/ SSOT for navigation, channels, prompt library, subscriptions
├── db/
│ ├── schema/ Drizzle tables and inferred types
│ └── queries/ Data access functions by domain
├── hooks/ useFetch, useCreateMutation, useInlineEdit
└── lib/ constants, auth/session helpers, dates, tools, utils
Setup
Set these required environment variables in .env.local:
DATABASE_URL=postgresql://localhost/cockpit
AUTH_SECRET=replace-me
AUTH_GITHUB_ID=replace-me
AUTH_GITHUB_SECRET=replace-me
Postgres needs a local cockpit database. Then push the schema:
DATABASE_URL=$YOUR_URL npx drizzle-kit push
On a fresh clone, visit /setup to create the first user. After that,
GitHub OAuth handles sign-in.
The seed script (scripts/seed.ts) reads from local personal data
sources under ~/.openclaw/*. A fresh clone will not have those
files, so schema-only setup is the default path. To populate with real
data, either:
- Provide the
~/.openclaw/*files yourself, then runDATABASE_URL=$YOUR_URL npx tsx scripts/seed.ts, or - Add rows directly via the Cockpit UI against an empty database.
Dev Commands
npm run dev # Start the dev server on :3000
npm run build # Production build (uses real DB connection)
npm run smoke # Curl every page + DB-backed GET API and assert 2xx/3xx
npm run lint # ESLint
A husky pre-commit hook runs tsc --noEmit and eslint src/
automatically. Smoke is opt-in (needs the dev server running) — run
before opening a PR. CI on push to main and every PR runs the same
type+lint checks; a daily Audit workflow surfaces new high-severity
CVEs in the dep graph.
Working in the repo
CLAUDE.md at the project root is the contract for AI agents and the
rule book for non-obvious decisions: SSOT rules, naming conventions,
data-flow boundaries, security patterns. Read it before making
substantive changes.
For orchestration architecture and migration direction, also read:
docs/architecture-first-principles.mddocs/debt-reduction-roadmap.mddocs/openclaw-orchestration-plan.md