From 8d1cb6b4edb64b5f672fcf22411573366fa6afbe Mon Sep 17 00:00:00 2001 From: Brian Ketelsen Date: Sun, 19 Apr 2026 00:33:18 -0400 Subject: [PATCH 1/2] feat: add --api-key flag for persistent external API access Adds a static, non-expiring API key that enables external tools to access the Mesa API without relying on ephemeral per-run agent keys. Changes: - New --api-key CLI flag (also MESA_API_KEY_EXTERNAL env) - Auth middleware checks the external key before DB lookup - External key resolves to a synthetic 'external' agent in context - New GET /api/v1/issues endpoint for listing all issues (with ?status= and ?limit= filters) - 3 new tests covering external key auth (valid, wrong value, not set) The external key is intended for orchestration tools, CI/CD pipelines, and external agents that need to create issues, read status, or post comments without being part of the internal agent roster. Usage: mesa --api-key my-secret-key -t enterprise 3001 curl -H 'Authorization: Bearer my-secret-key' http://localhost:3001/api/v1/issues --- cmd/mesa/main.go | 26 ++++++++++- internal/handlers/api.go | 64 ++++++++++++++++++++++--- internal/handlers/handlers_test.go | 75 ++++++++++++++++++++++++++++++ 3 files changed, 156 insertions(+), 9 deletions(-) diff --git a/cmd/mesa/main.go b/cmd/mesa/main.go index 8ba8711..3271a69 100644 --- a/cmd/mesa/main.go +++ b/cmd/mesa/main.go @@ -58,17 +58,19 @@ func main() { verbosity := 0 dashboardAuth := false + externalAPIKey := "" - // CLI: mesa [-t