Khala Phase 2: Agent auth middleware & admin API #127
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Parent: #119
Objective
Bearer token auth for agents + admin routes for agent management.
Tasks
2.1 Auth Middleware
Create
packages/khala/src/auth.ts:agentstableagentIdin context on success, 401 on failure2.2 Admin Routes
Create
packages/khala/src/routes/admin.ts:POST /admin/agents— body{ id, token }→ hash token, insert. Protected byADMIN_SECRETenv var.DELETE /admin/agents/:id— remove agentGET /admin/agents— list agents (no tokens)Wire into main app in
src/index.ts.References
docs/plans/2026-04-25-khala-mvp.md(Task 2.1, 2.2)