{"openapi":"3.1.0","info":{"title":"SecretDaemon Gateway API","description":"SecretDaemon Gateway — search, project management, and agent orchestration","contact":{"name":"Delivery Boy Technologies"},"license":{"name":"Private","identifier":"Private"},"version":"1.0.0"},"paths":{"/api/admin/alerts":{"get":{"tags":["admin"],"summary":"GET /api/admin/alerts — active and recent alerts.","operationId":"alerts","responses":{"200":{"description":"Alerts list","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsResponse"}}}},"401":{"description":"Unauthorized"},"403":{"description":"Admin access required"}},"security":[{"bearer_auth":[]}]}},"/api/admin/collections/{project}/health":{"get":{"tags":["admin"],"summary":"GET /api/admin/collections/:project/health","operationId":"collection_health","parameters":[{"name":"project","in":"path","description":"Project ID","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Collection health","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CollectionHealthResponse"}}}},"401":{"description":"Unauthorized"},"403":{"description":"Admin access required"},"404":{"description":"Collection not found"}},"security":[{"bearer_auth":[]}]}},"/api/admin/cost/summary":{"get":{"tags":["admin"],"summary":"GET /api/admin/cost/summary — cost summary across all users (admin only).","operationId":"admin_cost_summary","parameters":[{"name":"since","in":"query","description":"Time period: \"1h\", \"24h\", \"7d\", \"30d\", or unix millis since","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Cost summary","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CostSummaryResponse"}}}},"401":{"description":"Unauthorized"},"403":{"description":"Admin access required"}},"security":[{"bearer_auth":[]}]}},"/api/admin/dashboard":{"get":{"tags":["admin"],"summary":"GET /api/admin/dashboard — system overview for operators.","operationId":"dashboard_overview","responses":{"200":{"description":"Dashboard overview","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DashboardOverview"}}}},"401":{"description":"Unauthorized"},"403":{"description":"Admin access required"}},"security":[{"bearer_auth":[]}]}},"/api/admin/executors":{"get":{"tags":["admin"],"summary":"GET /api/admin/executors — list all executors with status.","operationId":"list_executors","responses":{"200":{"description":"Executor list","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExecutorsResponse"}}}},"401":{"description":"Unauthorized"},"403":{"description":"Admin access required"}},"security":[{"bearer_auth":[]}]}},"/api/admin/health":{"get":{"tags":["admin"],"summary":"GET /api/admin/health — deep health check of all backend services.","operationId":"deep_health","responses":{"200":{"description":"Deep health check","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeepHealthResponse"}}}},"401":{"description":"Unauthorized"},"403":{"description":"Admin access required"}},"security":[{"bearer_auth":[]}]}},"/api/admin/incident/quarantine":{"post":{"tags":["admin"],"summary":"POST /api/admin/incident/quarantine — trigger incident response for an executor.","operationId":"quarantine_handler","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/QuarantineRequest"}}},"required":true},"responses":{"200":{"description":"Incident report","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IncidentReport"}}}},"401":{"description":"Unauthorized"},"403":{"description":"Admin access required"}},"security":[{"bearer_auth":[]}]}},"/api/admin/incidents":{"get":{"tags":["admin"],"summary":"GET /api/admin/incidents — list recent incident reports.","operationId":"list_incidents_handler","responses":{"200":{"description":"Incident list","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/IncidentReport"}}}}},"401":{"description":"Unauthorized"},"403":{"description":"Admin access required"}},"security":[{"bearer_auth":[]}]}},"/api/admin/metrics/{window}":{"get":{"tags":["admin"],"summary":"GET /api/admin/metrics/{window} — metrics with optional history.","operationId":"admin_get_metrics","parameters":[{"name":"window","in":"path","description":"Time window (1h, 24h, 7d, 30d)","required":true,"schema":{"type":"string"}},{"name":"history","in":"query","description":"Number of historical snapshots (0 = latest only).","required":false,"schema":{"type":"integer","format":"int32","minimum":0}}],"responses":{"200":{"description":"Metrics history","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MetricsHistoryResponse"}}}},"401":{"description":"Unauthorized"},"403":{"description":"Admin access required"}},"security":[{"bearer_auth":[]}]}},"/api/admin/sessions":{"get":{"tags":["admin"],"summary":"GET /api/admin/sessions — list all sessions (operator view).","operationId":"admin_list_sessions","parameters":[{"name":"limit","in":"query","required":false,"schema":{"type":["integer","null"],"format":"int32","minimum":0}}],"responses":{"200":{"description":"Admin session list","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminSessionListResponse"}}}},"401":{"description":"Unauthorized"},"403":{"description":"Admin access required"}},"security":[{"bearer_auth":[]}]}},"/api/admin/spans":{"get":{"tags":["admin"],"summary":"GET /api/admin/spans — query spans across traces (admin only).","operationId":"admin_query_spans","parameters":[{"name":"stage","in":"query","description":"Pipeline stage as integer (PipelineStage enum value).","required":false,"schema":{"type":["integer","null"],"format":"int32"}},{"name":"attestation","in":"query","description":"Attestation level as integer.","required":false,"schema":{"type":["integer","null"],"format":"int32"}},{"name":"origin","in":"query","description":"Origin as integer.","required":false,"schema":{"type":["integer","null"],"format":"int32"}},{"name":"after","in":"query","required":false,"schema":{"type":["integer","null"],"format":"int64"}},{"name":"before","in":"query","required":false,"schema":{"type":["integer","null"],"format":"int64"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","format":"int32","minimum":0}}],"responses":{"200":{"description":"Span query results","content":{"application/json":{"schema":{"$ref":"#/components/schemas/QuerySpansResponse"}}}},"401":{"description":"Unauthorized"},"403":{"description":"Admin access required"}},"security":[{"bearer_auth":[]}]}},"/api/admin/traces":{"get":{"tags":["admin"],"summary":"GET /api/admin/traces — search all traces (admin only).","operationId":"admin_search_traces","parameters":[{"name":"project_id","in":"query","required":false,"schema":{"type":["string","null"]}},{"name":"after","in":"query","required":false,"schema":{"type":["integer","null"],"format":"int64"}},{"name":"before","in":"query","required":false,"schema":{"type":["integer","null"],"format":"int64"}},{"name":"outcome","in":"query","description":"Outcome filter as integer (TraceOutcome enum value).","required":false,"schema":{"type":["integer","null"],"format":"int32"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","format":"int32","minimum":0}},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","format":"int32","minimum":0}}],"responses":{"200":{"description":"Search results","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SearchTracesResponse"}}}},"401":{"description":"Unauthorized"},"403":{"description":"Admin access required"}},"security":[{"bearer_auth":[]}]}},"/api/auth/jwks":{"get":{"tags":["auth"],"summary":"GET /api/auth/jwks — Public key in JWKS format for token verification.","description":"Services like brain-server can fetch this to verify ES256-signed tokens\nwithout needing the shared HMAC secret.","operationId":"jwks","responses":{"200":{"description":"JWKS public keys","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JwksResponse"}}}}}}},"/api/cache/clear":{"post":{"tags":["system"],"summary":"Clear all caches (Redis + LRU) - requires JWT auth","operationId":"clear_caches","responses":{"200":{"description":"Caches cleared","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ClearCachesResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]}},"/api/cost/summary":{"get":{"tags":["traces"],"summary":"GET /api/cost/summary — cost summary for the authenticated user's own usage.","operationId":"cost_summary","parameters":[{"name":"since","in":"query","description":"Time period: \"1h\", \"24h\", \"7d\", \"30d\", or unix millis since","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Cost summary","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CostSummaryResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]}},"/api/daemons":{"get":{"tags":["daemons"],"summary":"List all daemons registered for the authenticated user","description":"GET /api/daemons","operationId":"list_daemons","responses":{"200":{"description":"Daemon list","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListDaemonsResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]}},"/api/executors/deregister":{"post":{"tags":["executors"],"summary":"Executor deregister endpoint (v2 — JWT auth required)","description":"Validates ownership (claims.sub == daemon.user_id) before deregistering.\nPOST /api/executors/deregister","operationId":"executor_deregister","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExecutorDeregisterRequest"}}},"required":true},"responses":{"200":{"description":"Executor deregistered","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExecutorDeregisterResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]}},"/api/executors/heartbeat":{"post":{"tags":["executors"],"summary":"Executor heartbeat endpoint (v2 — JWT auth required)","description":"Validates executor_id from claims matches a registered daemon.\nPOST /api/executors/heartbeat","operationId":"executor_heartbeat","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExecutorHeartbeatRequest"}}},"required":true},"responses":{"200":{"description":"Heartbeat acknowledged","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExecutorHeartbeatResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]}},"/api/executors/register":{"post":{"tags":["executors"],"summary":"Executor register endpoint (v2 — optional JWT, Ed25519 fallback)","description":"If the request includes a `public_key`, this initiates challenge-response:\n1. Gateway issues a random nonce\n2. Executor must sign the nonce and POST to /api/executors/register/verify\n\nAuth modes:\n- Valid JWT → use claims (normal path)\n- No/expired JWT + `public_key` + known daemon → resolve identity from executor store\n- No/expired JWT + no `public_key` → 401 (legacy path requires JWT)\n\nPOST /api/executors/register","operationId":"executor_register","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExecutorRegisterRequest"}}},"required":true},"responses":{"200":{"description":"Executor registered or challenge issued","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExecutorRegisterResponse"}}}},"401":{"description":"Unauthorized"}}}},"/api/executors/register/verify":{"post":{"tags":["executors"],"summary":"Executor register verify endpoint — completes challenge-response registration.","description":"Auth is provided by the Ed25519 signature verification itself — no JWT required.\nThe `challenge.user_id` (set during the register step) is the identity authority.\n\nPOST /api/executors/register/verify","operationId":"executor_register_verify","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExecutorVerifyRequest"}}},"required":true},"responses":{"200":{"description":"Challenge verified, credentials issued","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExecutorRegisterResponse"}}}},"400":{"description":"Invalid challenge or signature"}}}},"/api/index":{"post":{"tags":["indexing"],"summary":"Index endpoint - starts background indexing, returns 202 Accepted","operationId":"index","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/IndexRequest"}}},"required":true},"responses":{"202":{"description":"Indexing started","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IndexAcceptedResponse"}}}},"401":{"description":"Unauthorized"},"409":{"description":"Indexing already in progress"}},"security":[{"bearer_auth":[]}]}},"/api/index/status":{"get":{"tags":["indexing"],"summary":"Get indexing status - combines in-memory job state with live data-server progress","description":"GET /api/index/status?project_id=xxx","operationId":"index_status","parameters":[{"name":"project_id","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Indexing status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IndexStatusResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]}},"/api/keys":{"get":{"tags":["keys"],"summary":"List provider API keys (requires JWT auth)","description":"GET /api/keys","operationId":"list_provider_keys","responses":{"200":{"description":"Key list","content":{"application/json":{"schema":{"$ref":"#/components/schemas/KeyOperationResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]},"post":{"tags":["keys"],"summary":"Add a provider API key (requires JWT auth)","description":"POST /api/keys","operationId":"add_provider_key","requestBody":{"content":{"application/json":{"schema":{"type":"object"}}},"required":true},"responses":{"200":{"description":"Key added","content":{"application/json":{"schema":{"$ref":"#/components/schemas/KeyOperationResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]},"delete":{"tags":["keys"],"summary":"Delete a provider API key (requires JWT auth)","description":"DELETE /api/keys?provider=anthropic","operationId":"delete_provider_key","parameters":[{"name":"provider","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Key deleted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/KeyOperationResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]}},"/api/keys/effective":{"get":{"tags":["keys"],"summary":"Get the effective LLM configuration (provider + key + model) for the user","description":"GET /api/keys/effective\n\nReturns the user's preferred provider, decrypted API key, and model.\nFalls back to first available provider if no preference is set.","operationId":"get_effective_key","responses":{"200":{"description":"Effective key config","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DecryptedKeyResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]}},"/api/keys/get":{"get":{"tags":["keys"],"summary":"Get decrypted API key for a provider (requires JWT auth)","description":"GET /api/keys/get?provider=anthropic\n\nThis endpoint is used by the daemon to retrieve user-specific API keys\nfor making LLM calls on behalf of the user.","operationId":"get_decrypted_key","parameters":[{"name":"provider","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Decrypted key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DecryptedKeyResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]}},"/api/llm/complete":{"post":{"tags":["llm"],"summary":"LLM completion endpoint - proxies to Brain Server","operationId":"llm_complete","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LlmCompleteRequest"}}},"required":true},"responses":{"200":{"description":"LLM completion result","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LlmCompleteResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]}},"/api/llm/status":{"get":{"tags":["llm"],"summary":"LLM status endpoint - proxies to Brain Server","operationId":"llm_status","responses":{"200":{"description":"LLM provider status","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/ProviderInfo"}}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]}},"/api/metrics/{window}":{"get":{"tags":["traces"],"summary":"GET /api/metrics/{window} — latest metrics for the given window.","operationId":"get_metrics","parameters":[{"name":"window","in":"path","description":"Time window (1h, 24h, 7d, 30d)","required":true,"schema":{"type":"string"}},{"name":"history","in":"query","description":"Number of historical snapshots (0 = latest only).","required":false,"schema":{"type":"integer","format":"int32","minimum":0}}],"responses":{"200":{"description":"Metrics history","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MetricsHistoryResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]}},"/api/preferences":{"get":{"tags":["preferences"],"summary":"Get model preferences (requires JWT auth)","description":"GET /api/preferences","operationId":"get_model_preferences","responses":{"200":{"description":"Model preferences","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PreferencesResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]},"put":{"tags":["preferences"],"summary":"Update model preferences (requires JWT auth)","description":"PUT /api/preferences","operationId":"set_model_preferences","requestBody":{"content":{"application/json":{"schema":{"type":"object"}}},"required":true},"responses":{"200":{"description":"Preferences updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PreferencesResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]}},"/api/project/create":{"post":{"tags":["crate::handlers"],"summary":"Create a new project","operationId":"create_project","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateProjectRequest"}}},"required":true},"responses":{"200":{"description":"Project created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateProjectResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]}},"/api/project/delete":{"post":{"tags":["projects"],"summary":"Delete project (requires JWT auth)","operationId":"delete_project","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeleteProjectRequest"}}},"required":true},"responses":{"200":{"description":"Project deleted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeleteProjectResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]}},"/api/project/get":{"post":{"tags":["crate::handlers"],"summary":"Get project by ID","operationId":"get_project","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetProjectRequest"}}},"required":true},"responses":{"200":{"description":"Project details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetProjectResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]}},"/api/project/index":{"post":{"tags":["indexing"],"summary":"Trigger project indexing (local orchestration via IndexingTool)","description":"POST /api/project/index","operationId":"index_project","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/IndexProjectRequest"}}},"required":true},"responses":{"200":{"description":"Indexing result","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IndexProjectResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]}},"/api/project/status":{"get":{"tags":["indexing"],"summary":"Get indexing status for a project (reads directly from data-server)","description":"GET /api/project/status?project_id=xxx","operationId":"get_indexing_status","parameters":[{"name":"project_id","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Indexing status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IndexingStatusResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]}},"/api/projects":{"get":{"tags":["crate::handlers"],"summary":"List projects endpoint - proxies to Brain Server with daemon status","operationId":"list_projects","responses":{"200":{"description":"List of projects","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListProjectsResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}],"x-mcp-name":"list_projects"}},"/api/projects/full":{"get":{"tags":["crate::handlers"],"summary":"List all projects with full details - for daemon use","operationId":"list_projects_full","responses":{"200":{"description":"Full project details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListProjectsFullResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]}},"/api/projects/resolve":{"get":{"tags":["crate::handlers"],"summary":"Resolve a project by filesystem path","description":"Maps a filesystem path to a SecretDaemon project by matching against\nregistered source paths. Used by the MCP server to correlate an editor's\nworking directory with an indexed project.","operationId":"resolve_project","parameters":[{"name":"path","in":"query","description":"Absolute filesystem path (e.g. /home/user/projects/my-app)","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Project found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResolveProjectResponse"}}}},"404":{"description":"No project matches this path"}},"security":[{"bearer_auth":[]}],"x-mcp-name":"resolve_project"}},"/api/query":{"post":{"tags":["crate::handlers"],"summary":"Query endpoint - proxies to Brain Server","operationId":"query","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/QueryRequest"}}},"required":true},"responses":{"200":{"description":"Query results","content":{"application/json":{"schema":{"$ref":"#/components/schemas/QueryResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}],"x-mcp-name":"search"}},"/api/sessions":{"get":{"tags":["sessions"],"summary":"GET /api/sessions — list current user's active sessions.","operationId":"get_sessions","responses":{"200":{"description":"Session list","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SessionListResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]}},"/api/sessions/{id}":{"delete":{"tags":["sessions"],"summary":"DELETE /api/sessions/{id} — revoke a specific session and trigger credential cascade.","operationId":"revoke_session","parameters":[{"name":"id","in":"path","description":"Session ID","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object"}}}},"401":{"description":"Unauthorized"},"404":{"description":"Session not found"}},"security":[{"bearer_auth":[]}]}},"/api/stats":{"get":{"tags":["system"],"summary":"Get stats endpoint - proxies to Brain Server","operationId":"get_stats","parameters":[{"name":"project_id","in":"query","required":false,"schema":{"type":["string","null"]}}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object"}}}}},"security":[{"bearer_auth":[]}]}},"/api/token/create":{"post":{"tags":["tokens"],"summary":"Create API token (requires JWT auth)","operationId":"create_token","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateTokenRequest"}}},"required":true},"responses":{"200":{"description":"Token created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateTokenResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]}},"/api/token/list":{"get":{"tags":["tokens"],"summary":"List API tokens (requires JWT auth)","operationId":"list_tokens","responses":{"200":{"description":"Token list","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListTokensResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]}},"/api/token/revoke":{"post":{"tags":["tokens"],"summary":"Revoke API token (requires JWT auth)","operationId":"revoke_token","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RevokeTokenRequest"}}},"required":true},"responses":{"200":{"description":"Token revoked","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RevokeTokenResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]}},"/api/traces":{"get":{"tags":["traces"],"summary":"GET /api/traces — search own traces.","operationId":"search_traces","parameters":[{"name":"project_id","in":"query","required":false,"schema":{"type":["string","null"]}},{"name":"after","in":"query","required":false,"schema":{"type":["integer","null"],"format":"int64"}},{"name":"before","in":"query","required":false,"schema":{"type":["integer","null"],"format":"int64"}},{"name":"outcome","in":"query","description":"Outcome filter as integer (TraceOutcome enum value).","required":false,"schema":{"type":["integer","null"],"format":"int32"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","format":"int32","minimum":0}},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","format":"int32","minimum":0}}],"responses":{"200":{"description":"Search results","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SearchTracesResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]}},"/api/traces/{trace_id}":{"get":{"tags":["traces"],"summary":"GET /api/traces/:trace_id — get a single trace (own only).","operationId":"get_trace","parameters":[{"name":"trace_id","in":"path","description":"Trace ID","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Trace details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetTraceResponse"}}}},"401":{"description":"Unauthorized"},"404":{"description":"Trace not found"}},"security":[{"bearer_auth":[]}]}},"/api/traces/{trace_id}/feedback":{"post":{"tags":["traces"],"summary":"POST /api/traces/{trace_id}/feedback — submit feedback for a trace.","operationId":"submit_feedback","parameters":[{"name":"trace_id","in":"path","description":"Trace ID","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FeedbackRequest"}}},"required":true},"responses":{"200":{"description":"Feedback submitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FeedbackResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]}},"/api/traces/{trace_id}/summary":{"get":{"tags":["traces"],"summary":"GET /api/traces/{trace_id}/summary","operationId":"show_work_summary","parameters":[{"name":"trace_id","in":"path","description":"Trace ID","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Show work summary","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ShowWorkSummary"}}}},"401":{"description":"Unauthorized"},"404":{"description":"Trace not found"}},"security":[{"bearer_auth":[]}]}},"/api/workflows":{"post":{"tags":["workflows"],"summary":"POST /api/workflows — Create a new workflow","operationId":"create_workflow","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateWorkflowRequest"}}},"required":true},"responses":{"200":{"description":"Workflow created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WorkflowCreatedResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]}},"/api/workflows/{id}":{"get":{"tags":["workflows"],"summary":"GET /api/workflows/:id — Get workflow state","operationId":"get_workflow","parameters":[{"name":"id","in":"path","description":"Workflow ID","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Workflow details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetWorkflowResponse"}}}},"401":{"description":"Unauthorized"},"404":{"description":"Workflow not found"}},"security":[{"bearer_auth":[]}]}},"/api/workflows/{id}/cancel":{"post":{"tags":["workflows"],"summary":"POST /api/workflows/:id/cancel — Cancel a workflow","operationId":"cancel_workflow","parameters":[{"name":"id","in":"path","description":"Workflow ID","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Workflow cancelled","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CancelWorkflowResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]}},"/api/workflows/{id}/dispatch":{"post":{"tags":["workflows"],"summary":"POST /api/workflows/:id/dispatch — Trigger dispatch of all READY steps","operationId":"dispatch_workflow","parameters":[{"name":"id","in":"path","description":"Workflow ID","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Steps dispatched","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DispatchWorkflowResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]}},"/api/workflows/{workflow_id}/steps/{step_id}/result":{"post":{"tags":["workflows"],"summary":"POST /api/workflows/:workflow_id/steps/:step_id/result","description":"Callback endpoint for executors to report step completion.\nAfter recording the result, advances dependent steps to READY\nand returns the list of newly-ready step IDs.","operationId":"step_result_callback","parameters":[{"name":"workflow_id","in":"path","description":"Workflow ID","required":true,"schema":{"type":"string"}},{"name":"step_id","in":"path","description":"Step ID","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/StepResultCallbackRequest"}}},"required":true},"responses":{"200":{"description":"Step result recorded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StepResultCallbackResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]}},"/auth/daemon":{"post":{"tags":["auth"],"summary":"Daemon authentication endpoint","description":"Called by the daemon to get scoped credentials for service access.\nRequires a valid user token obtained from /auth/login.","operationId":"daemon_auth","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DaemonAuthRequest"}}},"required":true},"responses":{"200":{"description":"Daemon credentials issued","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DaemonCredentials"}}}},"401":{"description":"Invalid token"}}}},"/auth/login":{"post":{"tags":["auth"],"summary":"Login endpoint","operationId":"login","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoginRequest"}}},"required":true},"responses":{"200":{"description":"Login successful","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthResult"}}}},"400":{"description":"Invalid credentials"}}}},"/auth/refresh":{"post":{"tags":["auth"],"summary":"Refresh token endpoint","operationId":"refresh_token","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RefreshRequest"}}},"required":true},"responses":{"200":{"description":"Token refreshed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthResult"}}}},"401":{"description":"Invalid token"}}}},"/auth/refresh/biometric":{"post":{"tags":["auth"],"summary":"Biometric refresh endpoint for iOS clients.","description":"Accepts a biometric attestation (Face ID / Touch ID) to refresh an expired\nor near-expiry client token. Issues a new short-lived JWT + rotated refresh token.\n\nPOST /auth/refresh/biometric","operationId":"biometric_refresh","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BiometricRefreshRequest"}}},"required":true},"responses":{"200":{"description":"Biometric refresh successful","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BiometricRefreshResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]}},"/auth/validate":{"post":{"tags":["auth"],"summary":"Validate a session token (used by daemons)","operationId":"validate_token","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidateTokenRequest"}}},"required":true},"responses":{"200":{"description":"Token validation result","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidateTokenResponse"}}}}}}},"/daemon/heartbeat":{"post":{"tags":["daemons"],"summary":"Daemon heartbeat endpoint","operationId":"daemon_heartbeat","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DaemonHeartbeatRequest"}}},"required":true},"responses":{"200":{"description":"Heartbeat acknowledged","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DaemonHeartbeatResponse"}}}},"404":{"description":"Daemon not found"}}}},"/daemon/register":{"post":{"tags":["daemons"],"summary":"Register a daemon with the gateway","description":"Two-step registration process with IPv6 priority:\n1. Daemon sends registration request with optional IPv6 address\n2. Gateway tries IPv6 callback first (if provided)\n3. Falls back to IPv4 callback using external IP from connection\n4. If any callback succeeds, daemon is marked as directly reachable\n5. If all callbacks fail, daemon is proxy-only","operationId":"daemon_register","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DaemonRegisterRequest"}}},"required":true},"responses":{"200":{"description":"Daemon registered","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DaemonRegisterResponse"}}}}}}},"/daemon/unregister":{"post":{"tags":["daemons"],"summary":"Unregister a daemon","operationId":"daemon_unregister","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DaemonUnregisterRequest"}}},"required":true},"responses":{"200":{"description":"Daemon unregistered","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DaemonUnregisterResponse"}}}}}}},"/daemon/update":{"post":{"tags":["daemons"],"summary":"Update daemon metadata (label, etc.)","operationId":"daemon_update","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DaemonUpdateRequest"}}},"required":true},"responses":{"200":{"description":"Daemon updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DaemonUpdateResponse"}}}}}}},"/health":{"get":{"tags":["system"],"summary":"Health check endpoint - comprehensive system status","operationId":"health","responses":{"200":{"description":"System health status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HealthResponse"}}}}}}},"/trace/client/confirm":{"post":{"tags":["traces"],"summary":"POST /trace/client/confirm","description":"Atomically records the client's confirmation decision and updates the step state.","operationId":"client_confirm","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TraceConfirmationRequest"}}},"required":true},"responses":{"200":{"description":"Confirmation recorded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TraceConfirmationResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]}},"/trace/client/event":{"post":{"tags":["traces"],"summary":"POST /trace/client/event","description":"Accepts client operational events and forwards them to TraceService.\nLighter validation than executor spans — no dispatch state checks.","operationId":"submit_client_events","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ClientEventRequest"}}},"required":true},"responses":{"200":{"description":"Events submitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ClientEventResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]}},"/trace/executor/spans":{"post":{"tags":["traces"],"summary":"POST /trace/executor/spans","description":"Authenticated endpoint for executor span submission. Validates, stamps, and\nforwards spans to TraceService.","operationId":"submit_executor_spans","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubmitSpansRequest"}}},"required":true},"responses":{"200":{"description":"Spans submitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubmitSpansResponse"}}}},"401":{"description":"Unauthorized"}},"security":[{"bearer_auth":[]}]}}},"components":{"schemas":{"ActionSummary":{"type":"object","required":["action_type","target","reversible"],"properties":{"action_type":{"type":"string"},"diff_summary":{"type":["string","null"]},"reversible":{"type":"boolean"},"target":{"type":"string"}}},"AdminSessionListResponse":{"type":"object","description":"Admin session listing response.","required":["sessions","total"],"properties":{"sessions":{"type":"array","items":{"type":"object"}},"total":{"type":"integer","minimum":0}}},"Alert":{"type":"object","required":["severity","event","occurred_at","resolved"],"properties":{"event":{"type":"string"},"executor_id":{"type":["string","null"]},"occurred_at":{"type":"integer","format":"int64"},"resolved":{"type":"boolean"},"severity":{"type":"string"}}},"AlertsResponse":{"type":"object","required":["active","recent"],"properties":{"active":{"type":"array","items":{"$ref":"#/components/schemas/Alert"}},"recent":{"type":"array","items":{"$ref":"#/components/schemas/Alert"}}}},"AuthResult":{"type":"object","description":"Authentication result","required":["token","expires_in","user_id"],"properties":{"daemon_info":{"oneOf":[{"type":"null"},{"$ref":"#/components/schemas/DaemonConnectionInfo","description":"Daemon connection info (if daemon is available)"}]},"expires_in":{"type":"integer","format":"int64"},"token":{"type":"string"},"user_id":{"type":"string"}}},"BiometricRefreshRequest":{"type":"object","description":"Biometric refresh request (iOS client).","required":["token","biometric_attestation"],"properties":{"biometric_attestation":{"type":"string","description":"Biometric attestation data (from Face ID / Touch ID)"},"token":{"type":"string","description":"The current JWT token (may be expired)"}}},"BiometricRefreshResponse":{"type":"object","description":"Biometric refresh response.","required":["token","expires_in","refresh_token"],"properties":{"expires_in":{"type":"integer","format":"int64"},"refresh_token":{"type":"string","description":"New refresh token (rotated)"},"token":{"type":"string"}}},"BudgetMetrics":{"type":"object","required":["avg_utilization","over_90_pct_count"],"properties":{"avg_utilization":{"type":"number","format":"double"},"over_90_pct_count":{"type":"integer","format":"int32","minimum":0}}},"CancelWorkflowResponse":{"type":"object","description":"Cancel workflow response","required":["success","message"],"properties":{"message":{"type":"string"},"success":{"type":"boolean"}}},"ClearCachesResponse":{"type":"object","required":["success","message","redis_keys_cleared","lru_cache_cleared"],"properties":{"lru_cache_cleared":{"type":"boolean"},"message":{"type":"string"},"redis_keys_cleared":{"type":"integer","format":"int32","minimum":0},"success":{"type":"boolean"}}},"ClientEvent":{"type":"object","description":"A single client event.","required":["event_type","timestamp"],"properties":{"data":{"type":"object","description":"Event-specific data (opaque JSON)."},"event_type":{"type":"string","description":"Event type — must be from the allowed set."},"timestamp":{"type":"integer","format":"int64","description":"Client-reported timestamp (unix ms)."},"trace_id":{"type":["string","null"],"description":"Optional trace_id for correlation with an execution trace."},"workflow_id":{"type":["string","null"],"description":"Optional workflow_id for correlation."}}},"ClientEventRequest":{"type":"object","description":"Request body for client event submission.","required":["events"],"properties":{"events":{"type":"array","items":{"$ref":"#/components/schemas/ClientEvent"}}}},"ClientEventResponse":{"type":"object","description":"Response from client event submission.","required":["accepted"],"properties":{"accepted":{"type":"integer","format":"int32","minimum":0}}},"ClientStepResult":{"oneOf":[{"type":"object","required":["status"],"properties":{"status":{"type":"string","enum":["approved"]}}},{"type":"object","required":["status"],"properties":{"reason":{"type":["string","null"]},"status":{"type":"string","enum":["rejected"]}}},{"type":"object","required":["status"],"properties":{"attestation":{"type":["string","null"]},"status":{"type":"string","enum":["biometric_success"]}}},{"type":"object","required":["status"],"properties":{"status":{"type":"string","enum":["biometric_failed"]}}},{"type":"object","required":["data","status"],"properties":{"data":{"type":"object"},"status":{"type":"string","enum":["user_input"]}}},{"type":"object","required":["status"],"properties":{"status":{"type":"string","enum":["timeout"]}}}],"description":"Result of a client-side step execution"},"CollectionHealthResponse":{"type":"object","required":["project_id","collection_name","vector_count","indexed_vector_count","status","checked_at"],"properties":{"checked_at":{"type":"integer","format":"int64"},"collection_name":{"type":"string"},"indexed_vector_count":{"type":"integer","format":"int64","minimum":0},"project_id":{"type":"string"},"status":{"type":"string"},"vector_count":{"type":"integer","format":"int64","minimum":0}}},"ConfirmationDecision":{"type":"string","description":"The client's decision on a pending confirmation.","enum":["approved","rejected","edited","timeout"]},"ConfirmationMetrics":{"type":"object","required":["approval_rate","avg_time_to_decision_ms","timeout_count"],"properties":{"approval_rate":{"type":"number","format":"double"},"avg_time_to_decision_ms":{"type":"number","format":"double"},"timeout_count":{"type":"integer","format":"int32","minimum":0}}},"ContextSummary":{"type":"object","required":["tokens_used","budget_total","utilization_pct"],"properties":{"budget_total":{"type":"integer","format":"int32","minimum":0},"tokens_used":{"type":"integer","format":"int32","minimum":0},"utilization_pct":{"type":"number","format":"float"}}},"CostMetrics":{"type":"object","required":["total_usd","by_model","by_project","avg_per_interaction"],"properties":{"avg_per_interaction":{"type":"number","format":"double"},"by_model":{"type":"object"},"by_project":{"type":"object"},"total_usd":{"type":"number","format":"double"}}},"CostSummaryResponse":{"type":"object","required":["period","total_cost_usd","interaction_count","avg_cost_per_interaction","by_model","by_project","by_day","trend"],"properties":{"avg_cost_per_interaction":{"type":"number","format":"double"},"by_day":{"type":"array","items":{"$ref":"#/components/schemas/DailyCost"}},"by_model":{"type":"array","items":{"$ref":"#/components/schemas/ModelCost"}},"by_project":{"type":"array","items":{"$ref":"#/components/schemas/ProjectCost"}},"interaction_count":{"type":"integer","format":"int32","minimum":0},"period":{"type":"string"},"total_cost_usd":{"type":"number","format":"double"},"trend":{"$ref":"#/components/schemas/CostTrend"}}},"CostTrend":{"type":"object","required":["direction","change_pct","projected_monthly"],"properties":{"change_pct":{"type":"number","format":"double"},"direction":{"type":"string"},"projected_monthly":{"type":"number","format":"double"}}},"CreateProjectRequest":{"type":"object","required":["id","name","sources"],"properties":{"agents_md_path":{"type":["string","null"]},"config":{"oneOf":[{"type":"null"},{"$ref":"#/components/schemas/ProjectConfigInput"}]},"daemon_id":{"type":["string","null"]},"description":{"type":["string","null"]},"id":{"type":"string"},"name":{"type":"string"},"sources":{"type":"array","items":{"$ref":"#/components/schemas/SourceLocationInput"}}}},"CreateProjectResponse":{"type":"object","required":["success"],"properties":{"message":{"type":["string","null"]},"project":{},"success":{"type":"boolean"}}},"CreateStepDependency":{"type":"object","description":"Dependency definition for workflow creation","required":["from_step_index","to_step_index"],"properties":{"condition":{"type":["string","null"]},"from_step_index":{"type":"integer","minimum":0},"to_step_index":{"type":"integer","minimum":0}}},"CreateTokenRequest":{"type":"object","required":["name","expiration"],"properties":{"description":{"type":["string","null"]},"expiration":{"type":"integer","format":"int32"},"name":{"type":"string"},"scoped_projects":{"type":["array","null"],"items":{"type":"string"}}}},"CreateTokenResponse":{"type":"object","required":["success","message"],"properties":{"message":{"type":"string"},"success":{"type":"boolean"},"token":{"type":["string","null"]}}},"CreateWorkflowRequest":{"type":"object","description":"Request to create a new workflow","required":["query","project_id","steps"],"properties":{"dependencies":{"type":["array","null"],"items":{"$ref":"#/components/schemas/CreateStepDependency"}},"project_id":{"type":"string"},"query":{"type":"string"},"steps":{"type":"array","items":{"$ref":"#/components/schemas/CreateWorkflowStep"}},"strategy":{"type":["integer","null"],"format":"int32"}}},"CreateWorkflowStep":{"type":"object","description":"Step definition for workflow creation","required":["description","type","origin","target_executor_type"],"properties":{"assigned_executor_id":{"type":["string","null"]},"confirmation_required":{"type":["boolean","null"]},"description":{"type":"string"},"origin":{"type":"integer","format":"int32"},"required_capabilities":{"type":["array","null"],"items":{"type":"string"}},"required_data_scopes":{"type":["array","null"],"items":{"type":"string"}},"target_executor_type":{"type":"integer","format":"int32"},"type":{"type":"integer","format":"int32"}}},"DaemonAuthRequest":{"type":"object","description":"Daemon authentication request","required":["token","daemon_id"],"properties":{"daemon_id":{"type":"string","description":"Daemon identifier (machine ID or similar)"},"token":{"type":"string","description":"User's login token (obtained from /auth/login)"}}},"DaemonConnectionInfo":{"type":"object","description":"Daemon connection information returned to client after login","required":["address","protocol","connection_mode","daemon_id","projects"],"properties":{"address":{"type":"string","description":"WebSocket address to connect to (e.g., \"ws://localhost:8081\")"},"connection_mode":{"type":"string","description":"Connection mode: \"direct\" or \"proxy\""},"daemon_id":{"type":"string","description":"Daemon ID"},"projects":{"type":"array","items":{"type":"string"},"description":"Projects this daemon has access to"},"protocol":{"type":"string","description":"Protocol version (e.g., \"v1\")"}}},"DaemonCredentials":{"type":"object","description":"Daemon credentials - what the daemon needs to connect to services","required":["token","user_id","projects","redis_prefix","expires_at","services"],"properties":{"executor_id":{"type":["string","null"],"description":"Executor instance ID (deterministic from daemon_id)"},"expires_at":{"type":"integer","format":"int64","description":"Credentials expiry (Unix timestamp)"},"projects":{"type":"array","items":{"type":"string"},"description":"Projects this daemon can access"},"qdrant_api_key":{"type":["string","null"],"description":"Qdrant read-only API key (scoped to user's collections)"},"redis_prefix":{"type":"string","description":"Redis key prefix for this user"},"services":{"type":"object","description":"Service configuration - URLs for all backend services"},"token":{"type":"string","description":"JWT token for API Gateway authentication"},"user_id":{"type":"string","description":"User ID"}}},"DaemonHeartbeatRequest":{"type":"object","description":"Daemon heartbeat request","required":["daemon_id"],"properties":{"daemon_id":{"type":"string"},"label":{"type":["string","null"],"description":"Optional label update"},"projects":{"type":["array","null"],"items":{"type":"string"},"description":"Optional updated project list (refreshed periodically)"}}},"DaemonHeartbeatResponse":{"type":"object","description":"Daemon heartbeat response","required":["success"],"properties":{"success":{"type":"boolean"}}},"DaemonInfoResponse":{"type":"object","description":"Info about a registered daemon","required":["daemon_id","address","connection_mode","directly_reachable","projects","last_heartbeat_secs","status"],"properties":{"address":{"type":"string"},"connection_mode":{"type":"string"},"daemon_id":{"type":"string"},"directly_reachable":{"type":"boolean"},"label":{"type":["string","null"]},"last_heartbeat_secs":{"type":"integer","format":"int64","minimum":0},"projects":{"type":"array","items":{"type":"string"}},"status":{"type":"string"},"version":{"type":["string","null"]}}},"DaemonRegisterRequest":{"type":"object","description":"Daemon registration request","required":["daemon_id","user_id","ws_address","projects"],"properties":{"connection_mode":{"type":["object","null"]},"daemon_id":{"type":"string"},"executor_id":{"type":["string","null"],"description":"Executor ID (from credentials, for v2-aware daemons)"},"ipv6_address":{"type":["string","null"],"description":"IPv6 WebSocket address (if available)"},"label":{"type":["string","null"],"description":"User-friendly label for this daemon"},"projects":{"type":"array","items":{"type":"string"}},"user_id":{"type":"string"},"version":{"type":["string","null"]},"ws_address":{"type":"string"}}},"DaemonRegisterResponse":{"type":"object","description":"Daemon registration response","required":["success","message","directly_reachable"],"properties":{"directly_reachable":{"type":"boolean"},"external_address":{"type":["string","null"]},"message":{"type":"string"},"success":{"type":"boolean"}}},"DaemonUnregisterRequest":{"type":"object","description":"Daemon unregister request","required":["daemon_id"],"properties":{"daemon_id":{"type":"string"}}},"DaemonUnregisterResponse":{"type":"object","description":"Daemon unregister response","required":["success","message"],"properties":{"message":{"type":"string"},"success":{"type":"boolean"}}},"DaemonUpdateRequest":{"type":"object","description":"Daemon update request (e.g. change label)","required":["daemon_id"],"properties":{"daemon_id":{"type":"string"},"label":{"type":["string","null"]}}},"DaemonUpdateResponse":{"type":"object","description":"Daemon update response","required":["success","message"],"properties":{"message":{"type":"string"},"success":{"type":"boolean"}}},"DailyCost":{"type":"object","required":["date","cost_usd","interactions"],"properties":{"cost_usd":{"type":"number","format":"double"},"date":{"type":"string"},"interactions":{"type":"integer","format":"int32","minimum":0}}},"DashboardOverview":{"type":"object","required":["executors_online","executors_degraded","executors_offline","traces_last_hour","success_rate","avg_latency_ms","cost_last_hour","active_workflows","pending_confirmations","retrieval_p95_ms","tool_failure_rate","budget_utilization_avg","active_alerts","top_errors"],"properties":{"active_alerts":{"type":"array","items":{"$ref":"#/components/schemas/Alert"}},"active_workflows":{"type":"integer","format":"int32","minimum":0},"avg_latency_ms":{"type":"number","format":"double"},"budget_utilization_avg":{"type":"number","format":"double"},"cost_last_hour":{"type":"number","format":"double"},"executors_degraded":{"type":"integer","minimum":0},"executors_offline":{"type":"integer","minimum":0},"executors_online":{"type":"integer","minimum":0},"pending_confirmations":{"type":"integer","format":"int32","minimum":0},"retrieval_p95_ms":{"type":"number","format":"double"},"success_rate":{"type":"number","format":"double"},"tool_failure_rate":{"type":"number","format":"double"},"top_errors":{"type":"array","items":{"$ref":"#/components/schemas/ErrorSummary"}},"traces_last_hour":{"type":"integer","format":"int32","minimum":0}}},"DecryptedKeyResponse":{"type":"object","description":"Response with decrypted API key","required":["success"],"properties":{"api_key":{"type":["string","null"]},"error":{"type":["string","null"]},"model":{"type":["string","null"]},"provider":{"type":["string","null"]},"success":{"type":"boolean"}}},"DeepHealthResponse":{"type":"object","required":["healthy","services","executors_online","checked_at"],"properties":{"checked_at":{"type":"integer","format":"int64"},"executors_online":{"type":"integer","minimum":0},"healthy":{"type":"boolean"},"services":{"type":"array","items":{"$ref":"#/components/schemas/ServiceHealth"}}}},"DeleteProjectRequest":{"type":"object","required":["project_id","delete_data"],"properties":{"delete_data":{"type":"boolean"},"project_id":{"type":"string"}}},"DeleteProjectResponse":{"type":"object","required":["success"],"properties":{"message":{"type":["string","null"]},"success":{"type":"boolean"}}},"DispatchWorkflowResponse":{"type":"object","description":"Response from workflow dispatch","required":["success","results"],"properties":{"results":{"type":"array","items":{"type":"object"}},"success":{"type":"boolean"}}},"ErrorSummary":{"type":"object","required":["error_type","count","last_seen"],"properties":{"count":{"type":"integer","format":"int32","minimum":0},"error_type":{"type":"string"},"example_trace_id":{"type":["string","null"]},"last_seen":{"type":"integer","format":"int64"}}},"ExecutorDeregisterRequest":{"type":"object","description":"Executor deregister request (v2)"},"ExecutorDeregisterResponse":{"type":"object","description":"Executor deregister response (v2)","required":["success","message"],"properties":{"message":{"type":"string"},"success":{"type":"boolean"}}},"ExecutorHeartbeatRequest":{"type":"object","description":"Executor heartbeat request (v2)","properties":{"label":{"type":["string","null"],"description":"Optional label update"},"projects":{"type":["array","null"],"items":{"type":"string"},"description":"Optional updated project list"}}},"ExecutorHeartbeatResponse":{"type":"object","description":"Executor heartbeat response (v2)","required":["success"],"properties":{"expires_in":{"type":["integer","null"],"format":"int64","description":"Seconds until the new token expires (only set when new_token is present)"},"new_token":{"type":["string","null"],"description":"New JWT token if auto-rotation triggered (Task 5.9)"},"success":{"type":"boolean"}}},"ExecutorInfo":{"type":"object","required":["executor_id","daemon_id","executor_type","user_id","status","capabilities","projects","registered_at"],"properties":{"capabilities":{"type":"array","items":{"type":"string"}},"daemon_id":{"type":"string"},"display_name":{"type":["string","null"]},"executor_id":{"type":"string"},"executor_type":{"type":"string"},"label":{"type":["string","null"]},"last_heartbeat_at":{"type":["integer","null"],"format":"int64"},"projects":{"type":"array","items":{"type":"string"}},"registered_at":{"type":"integer","format":"int64"},"status":{"type":"string"},"user_id":{"type":"string"},"version":{"type":["string","null"]}}},"ExecutorRegisterRequest":{"type":"object","description":"Executor registration request (v2 — JWT auth required)","required":["daemon_id","ws_address","projects"],"properties":{"capabilities":{"type":"array","items":{"type":"string"},"description":"Declared capabilities (validated against executor type's allowed set)"},"daemon_id":{"type":"string","description":"Daemon identifier (machine ID or similar)"},"data_scopes":{"type":"array","items":{"type":"string"},"description":"Declared data scopes"},"executor_type":{"type":"integer","format":"int32","description":"Executor type: 1=code_daemon (default), 2=cloud_daemon, 3=client"},"ipv6_address":{"type":["string","null"],"description":"IPv6 WebSocket address (if available)"},"label":{"type":["string","null"],"description":"User-friendly label (e.g. \"My MacBook\", \"Server\")"},"projects":{"type":"array","items":{"type":"string"},"description":"Projects this daemon has access to"},"public_key":{"type":["string","null"],"description":"Ed25519 public key (hex-encoded, 64 chars) for challenge-response auth"},"version":{"type":["string","null"],"description":"Daemon version string"},"ws_address":{"type":"string","description":"WebSocket address reported by daemon (usually localhost:port)"}}},"ExecutorRegisterResponse":{"type":"object","description":"Executor registration response (v2 — credentials + registration in one call)\n\nIf `public_key` was provided in the request, response includes a `challenge_nonce`\ninstead of credentials. The executor must call `/api/executors/register/verify`\nwith the signed nonce to complete registration.","required":["success","executor_id","directly_reachable"],"properties":{"challenge_nonce":{"type":["string","null"],"description":"Challenge nonce (hex, 64 chars) — present when public_key was provided.\nThe executor must sign this and POST to /api/executors/register/verify."},"credentials":{"oneOf":[{"type":"null"},{"$ref":"#/components/schemas/DaemonCredentials","description":"Scoped daemon credentials — present only after challenge-response verification,\nor when no public_key was provided (legacy mode)."}]},"directly_reachable":{"type":"boolean","description":"Whether the daemon is directly reachable from outside"},"executor_id":{"type":"string","description":"Deterministic executor ID (UUID v5 from daemon_id)"},"external_address":{"type":["string","null"],"description":"Verified external address (if directly reachable)"},"success":{"type":"boolean"}}},"ExecutorSpan":{"type":"object","description":"A single span as submitted by an executor.","required":["span_id","trace_id","stage","started_at","duration_ms"],"properties":{"duration_ms":{"type":"integer","format":"int64","minimum":0},"parent_span_id":{"type":["string","null"]},"payload":{"type":"object","description":"Stage-specific payload (opaque JSON — preserved as-is, parsed in future tasks)"},"span_id":{"type":"string"},"stage":{"type":"string","description":"Pipeline stage name: \"routing\", \"retrieval\", \"llm_call\", \"tool_execution\",\n\"action\", \"context_assembly\", \"decomposition\""},"started_at":{"type":"integer","format":"int64","description":"Executor-reported timestamp (preserved but not trusted for ordering)"},"step_id":{"type":["string","null"]},"trace_id":{"type":"string"},"workflow_id":{"type":["string","null"]}}},"ExecutorStepSummary":{"type":"object","required":["executor_type","steps_handled","total_duration_ms"],"properties":{"executor_type":{"type":"string"},"steps_handled":{"type":"integer","format":"int32","minimum":0},"total_duration_ms":{"type":"integer","format":"int64","minimum":0}}},"ExecutorVerifyRequest":{"type":"object","description":"Request to verify a challenge-response for executor registration","required":["executor_id","challenge_nonce","signature"],"properties":{"challenge_nonce":{"type":"string","description":"The challenge nonce (hex) that was issued"},"executor_id":{"type":"string","description":"The executor ID received from the initial register call"},"signature":{"type":"string","description":"Ed25519 signature of the nonce (hex, 128 chars)"}}},"ExecutorsResponse":{"type":"object","required":["total","online","degraded","offline","quarantined","executors"],"properties":{"degraded":{"type":"integer","minimum":0},"executors":{"type":"array","items":{"$ref":"#/components/schemas/ExecutorInfo"}},"offline":{"type":"integer","minimum":0},"online":{"type":"integer","minimum":0},"quarantined":{"type":"integer","minimum":0},"total":{"type":"integer","minimum":0}}},"FeedbackRequest":{"type":"object","required":["category"],"properties":{"category":{"type":"string","description":"Category: \"retrieval_missed\", \"wrong_action\", \"cost_excessive\", \"too_slow\", \"perfect\""},"detail":{"type":["object","null"],"description":"Optional detail (e.g. expected files for retrieval_missed)"}}},"FeedbackResponse":{"type":"object","required":["success","feedback_id"],"properties":{"feedback_id":{"type":"string"},"success":{"type":"boolean"}}},"FullProjectInfo":{"type":"object","description":"Full project data response (with all details)","required":["id","name","sources","total_files","total_chunks","daemon_online"],"properties":{"config":{},"daemon_id":{"type":["string","null"]},"daemon_online":{"type":"boolean"},"description":{"type":["string","null"]},"id":{"type":"string"},"last_indexed_at":{"type":["integer","null"],"format":"int64","minimum":0},"name":{"type":"string"},"sources":{"type":"array","items":{}},"total_chunks":{"type":"integer","format":"int32","minimum":0},"total_files":{"type":"integer","format":"int32","minimum":0}}},"GetProjectRequest":{"type":"object","required":["id"],"properties":{"id":{"type":"string"}}},"GetProjectResponse":{"type":"object","required":["success"],"properties":{"message":{"type":["string","null"]},"project":{},"success":{"type":"boolean"}}},"GetTraceResponse":{"type":"object","description":"Full trace response.","required":["trace_id","user_id","project_id","executor_id","query_redacted","started_at","completed_at","outcome","spans"],"properties":{"completed_at":{"type":"integer","format":"int64"},"executor_id":{"type":"string"},"outcome":{"type":"integer","format":"int32"},"project_id":{"type":"string"},"query_redacted":{"type":"string"},"spans":{"type":"array","items":{"$ref":"#/components/schemas/SpanSummary"}},"started_at":{"type":"integer","format":"int64"},"trace_id":{"type":"string"},"user_id":{"type":"string"}}},"GetWorkflowResponse":{"type":"object","description":"Response for getting a workflow","required":["workflow_id","state","strategy","steps","created_at"],"properties":{"created_at":{"type":"integer","format":"int64"},"state":{"type":"integer","format":"int32"},"steps":{"type":"array","items":{"$ref":"#/components/schemas/WorkflowStepInfo"}},"strategy":{"type":"integer","format":"int32"},"workflow_id":{"type":"string"}}},"HealthResponse":{"type":"object","description":"Health check response","required":["status","services"],"properties":{"daemon_count":{"type":["integer","null"],"minimum":0},"services":{"type":"array","items":{"$ref":"#/components/schemas/ServiceStatus"}},"status":{"type":"string"}}},"IncidentReport":{"type":"object","description":"Result of incident response execution.","required":["incident_id","executor_id","user_id","reason","triggered_by","executor_quarantined","tokens_revoked","cascade_summary","created_at"],"properties":{"cascade_summary":{"type":"string"},"created_at":{"type":"integer","format":"int64"},"executor_id":{"type":"string"},"executor_quarantined":{"type":"boolean"},"incident_id":{"type":"string"},"reason":{"type":"string"},"tokens_revoked":{"type":"integer","format":"int32","minimum":0},"triggered_by":{"type":"string"},"user_id":{"type":"string"}}},"IndexAcceptedResponse":{"type":"object","description":"Index accepted response (202)","required":["message","project_id"],"properties":{"message":{"type":"string"},"project_id":{"type":"string"}}},"IndexProjectRequest":{"type":"object","required":["project_id"],"properties":{"project_id":{"type":"string"}}},"IndexProjectResponse":{"type":"object","required":["success"],"properties":{"chunks_created":{"type":["integer","null"],"format":"int32","minimum":0},"duration_ms":{"type":["integer","null"],"format":"int64","minimum":0},"files_indexed":{"type":["integer","null"],"format":"int32","minimum":0},"message":{"type":["string","null"]},"success":{"type":"boolean"}}},"IndexRequest":{"type":"object","description":"Index request","required":["path"],"properties":{"force":{"type":"boolean"},"path":{"type":"string"},"project_id":{"type":["string","null"]}}},"IndexStatusResponse":{"type":"object","description":"Combined status response","required":["project_id","status"],"properties":{"completed_at":{"type":["string","null"],"format":"date-time"},"error":{"type":["string","null"]},"progress":{"oneOf":[{"type":"null"},{"$ref":"#/components/schemas/IndexingProgress"}]},"project_id":{"type":"string"},"result":{"oneOf":[{"type":"null"},{"$ref":"#/components/schemas/IndexingResult"}]},"started_at":{"type":["string","null"],"format":"date-time"},"status":{"type":"string"}}},"IndexingProgress":{"type":"object","description":"Live progress info","required":["state"],"properties":{"files_processed":{"type":["integer","null"],"format":"int32","minimum":0},"phase":{"type":["string","null"]},"progress_pct":{"type":["number","null"],"format":"float"},"state":{"type":"string"},"total_files":{"type":["integer","null"],"format":"int32","minimum":0}}},"IndexingResult":{"type":"object","description":"Result info when indexing completes","required":["files_indexed","chunks_created","duration_ms"],"properties":{"chunks_created":{"type":"integer","format":"int32","minimum":0},"duration_ms":{"type":"integer","format":"int64","minimum":0},"files_indexed":{"type":"integer","format":"int32","minimum":0}}},"IndexingStatusResponse":{"type":"object","required":["success"],"properties":{"message":{"type":["string","null"]},"phase":{"type":["string","null"]},"progress":{"type":["number","null"],"format":"float"},"status":{"type":["string","null"]},"success":{"type":"boolean"}}},"JwksResponse":{"type":"object","description":"JWKS response format","required":["keys"],"properties":{"keys":{"type":"array","items":{}}}},"KeyOperationResponse":{"type":"object","description":"Response for add/list key operations","required":["success"],"properties":{"key":{"type":["object","null"]},"keys":{"type":["array","null"],"items":{"type":"object"}},"message":{"type":["string","null"]},"success":{"type":"boolean"}}},"ListDaemonsResponse":{"type":"object","description":"Response listing all daemons for the user","required":["success","daemons","total"],"properties":{"daemons":{"type":"array","items":{"$ref":"#/components/schemas/DaemonInfoResponse"}},"success":{"type":"boolean"},"total":{"type":"integer","minimum":0}}},"ListProjectsFullResponse":{"type":"object","description":"List projects with full details","required":["success","projects"],"properties":{"projects":{"type":"array","items":{"$ref":"#/components/schemas/FullProjectInfo"}},"success":{"type":"boolean"}}},"ListProjectsResponse":{"type":"object","description":"List projects response","required":["projects"],"properties":{"projects":{"type":"array","items":{"$ref":"#/components/schemas/ProjectInfo"}}}},"ListSessionsResponse":{"type":"object","description":"Response for active sessions listing.","required":["sessions"],"properties":{"sessions":{"type":"array","items":{"type":"object"}}}},"ListTokensResponse":{"type":"object","required":["tokens"],"properties":{"tokens":{"type":"array","items":{"$ref":"#/components/schemas/TokenInfo"}}}},"LlmCompleteRequest":{"type":"object","description":"LLM completion request","required":["prompt"],"properties":{"complexity":{"type":["integer","null"],"format":"int32","description":"Query complexity: 0=simple, 1=moderate, 2=complex"},"max_tokens":{"type":["integer","null"],"format":"int32","minimum":0},"model":{"type":["string","null"]},"prompt":{"type":"string"},"temperature":{"type":["number","null"],"format":"float"}}},"LlmCompleteResponse":{"type":"object","description":"LLM completion response","required":["content","provider","model","prompt_tokens","completion_tokens","total_tokens","duration_ms"],"properties":{"completion_tokens":{"type":"integer","format":"int32","minimum":0},"content":{"type":"string"},"duration_ms":{"type":"integer","format":"int64","minimum":0},"model":{"type":"string"},"prompt_tokens":{"type":"integer","format":"int32","minimum":0},"provider":{"type":"string"},"total_tokens":{"type":"integer","format":"int32","minimum":0}}},"LlmConfigHttp":{"type":"object","description":"LLM config for HTTP requests","required":["provider","model"],"properties":{"api_key":{"type":["string","null"]},"base_url":{"type":["string","null"]},"model":{"type":"string"},"provider":{"type":"string"}}},"LlmSummary":{"type":"object","required":["model","output_tokens","cost_usd","latency_ms"],"properties":{"cost_usd":{"type":"number","format":"double"},"latency_ms":{"type":"integer","format":"int64","minimum":0},"model":{"type":"string"},"output_tokens":{"type":"integer","format":"int32","minimum":0}}},"LoginRequest":{"type":"object","description":"Login request","required":["username","password"],"properties":{"password":{"type":"string"},"username":{"type":"string"}}},"MetricsHistoryResponse":{"type":"object","description":"Multiple snapshots response (for history).","required":["window_name","snapshots"],"properties":{"snapshots":{"type":"array","items":{"$ref":"#/components/schemas/MetricsSnapshotResponse"}},"window_name":{"type":"string"}}},"MetricsSnapshotResponse":{"type":"object","description":"Metrics snapshot response.","required":["computed_at","window_name","window_start","window_end","retrieval","channel_contribution","cost","budget","tool_reliability","confirmations","routing","reranking"],"properties":{"budget":{"$ref":"#/components/schemas/BudgetMetrics"},"channel_contribution":{"type":"object"},"computed_at":{"type":"integer","format":"int64"},"confirmations":{"$ref":"#/components/schemas/ConfirmationMetrics"},"cost":{"$ref":"#/components/schemas/CostMetrics"},"reranking":{"$ref":"#/components/schemas/RerankingMetrics"},"retrieval":{"$ref":"#/components/schemas/RetrievalMetrics"},"routing":{"$ref":"#/components/schemas/RoutingMetrics"},"tool_reliability":{"$ref":"#/components/schemas/ToolMetrics"},"window_end":{"type":"integer","format":"int64"},"window_name":{"type":"string"},"window_start":{"type":"integer","format":"int64"}}},"ModelCost":{"type":"object","required":["model","cost_usd","interactions","avg_tokens_in","avg_tokens_out"],"properties":{"avg_tokens_in":{"type":"integer","format":"int32","minimum":0},"avg_tokens_out":{"type":"integer","format":"int32","minimum":0},"cost_usd":{"type":"number","format":"double"},"interactions":{"type":"integer","format":"int32","minimum":0},"model":{"type":"string"}}},"PreferencesResponse":{"type":"object","description":"Response for model preferences","required":["success"],"properties":{"message":{"type":["string","null"]},"preferences":{"type":["object","null"]},"success":{"type":"boolean"}}},"ProjectConfigInput":{"type":"object","properties":{"chunk_overlap":{"type":["integer","null"],"format":"int32","minimum":0},"chunk_size":{"type":["integer","null"],"format":"int32","minimum":0},"embedding_dimensions":{"type":["integer","null"],"format":"int32","minimum":0},"embedding_method":{"type":["string","null"],"description":"Embedding method: \"local\", \"openai\""},"embedding_model":{"type":["string","null"]},"excluded_patterns":{"type":["array","null"],"items":{"type":"string"}},"max_file_size":{"type":["integer","null"],"format":"int64","minimum":0}}},"ProjectCost":{"type":"object","required":["project_id","cost_usd","interactions"],"properties":{"cost_usd":{"type":"number","format":"double"},"interactions":{"type":"integer","format":"int32","minimum":0},"project_id":{"type":"string"}}},"ProjectInfo":{"type":"object","description":"Project info with daemon availability","required":["id","daemon_online","status"],"properties":{"daemon_id":{"type":["string","null"]},"daemon_online":{"type":"boolean"},"id":{"type":"string"},"last_error":{"type":["string","null"]},"status":{"type":"string"}}},"ProviderInfo":{"type":"object","description":"Provider info","required":["name","model","available"],"properties":{"available":{"type":"boolean"},"error":{"type":["string","null"]},"latency_ms":{"type":["integer","null"],"format":"int64","minimum":0},"model":{"type":"string"},"name":{"type":"string"}}},"QuarantineRequest":{"type":"object","required":["executor_id"],"properties":{"executor_id":{"type":"string"},"reason":{"type":["string","null"]}}},"QueryRequest":{"type":"object","description":"Query request","required":["question"],"properties":{"llm_config":{"oneOf":[{"type":"null"},{"$ref":"#/components/schemas/LlmConfigHttp","description":"Optional LLM configuration override"}]},"project_id":{"type":["string","null"],"description":"Project ID to search within"},"question":{"type":"string","description":"The search question or query"}}},"QueryResponse":{"type":"object","description":"Query response","required":["answer","sources","cached","duration_ms","input_tokens","output_tokens","cached_tokens","total_tokens"],"properties":{"answer":{"type":"string"},"cached":{"type":"boolean"},"cached_tokens":{"type":"integer","format":"int64","minimum":0},"duration_ms":{"type":"integer","format":"int64","minimum":0},"input_tokens":{"type":"integer","format":"int64","minimum":0},"output_tokens":{"type":"integer","format":"int64","minimum":0},"sources":{"type":"array","items":{"$ref":"#/components/schemas/QuerySourceRef"}},"total_tokens":{"type":"integer","format":"int64","minimum":0}}},"QuerySourceRef":{"type":"object","description":"Source reference in query response","required":["file_path"],"properties":{"chunk_id":{"type":"string"},"file_path":{"type":"string"}}},"QuerySpansResponse":{"type":"object","description":"Query spans response.","required":["spans"],"properties":{"spans":{"type":"array","items":{"$ref":"#/components/schemas/SpanSummary"}}}},"RefreshRequest":{"type":"object","description":"Refresh token request","required":["token"],"properties":{"token":{"type":"string"}}},"RerankingMetrics":{"type":"object","required":["applied_count","total_count","applied_rate"],"properties":{"applied_count":{"type":"integer","format":"int32","minimum":0},"applied_rate":{"type":"number","format":"double"},"total_count":{"type":"integer","format":"int32","minimum":0}}},"ResolveProjectResponse":{"type":"object","description":"Resolved project details","required":["project_id","name","indexed","daemon_online"],"properties":{"daemon_online":{"type":"boolean"},"indexed":{"type":"boolean"},"name":{"type":"string"},"project_id":{"type":"string"}}},"RetrievalMetrics":{"type":"object","required":["p50_ms","p95_ms","count"],"properties":{"count":{"type":"integer","format":"int32","minimum":0},"p50_ms":{"type":"number","format":"double"},"p95_ms":{"type":"number","format":"double"}}},"RetrievalSummary":{"type":"object","required":["files_searched","channels_used","top_files"],"properties":{"channels_used":{"type":"integer","format":"int32","minimum":0},"files_searched":{"type":"integer","format":"int32","minimum":0},"top_files":{"type":"array","items":{"type":"string"}}}},"RevokeTokenRequest":{"type":"object","required":["token_id"],"properties":{"token_id":{"type":"string"}}},"RevokeTokenResponse":{"type":"object","required":["success","message"],"properties":{"message":{"type":"string"},"success":{"type":"boolean"}}},"RoutingMetrics":{"type":"object","required":["avg_confidence"],"properties":{"avg_confidence":{"type":"number","format":"double"}}},"RoutingSummary":{"type":"object","required":["method","confidence"],"properties":{"confidence":{"type":"number","format":"float"},"method":{"type":"string"}}},"SearchTracesResponse":{"type":"object","description":"Search traces response.","required":["traces","total"],"properties":{"total":{"type":"integer","format":"int32","minimum":0},"traces":{"type":"array","items":{"$ref":"#/components/schemas/TraceSummary"}}}},"ServiceHealth":{"type":"object","required":["name","status"],"properties":{"error":{"type":["string","null"]},"latency_ms":{"type":["integer","null"],"format":"int64","minimum":0},"name":{"type":"string"},"status":{"type":"string"}}},"ServiceStatus":{"type":"object","description":"Service status","required":["name","status"],"properties":{"error":{"type":["string","null"]},"name":{"type":"string"},"status":{"type":"string"}}},"SessionListResponse":{"type":"object","description":"Response for session listing.","required":["sessions"],"properties":{"sessions":{"type":"array","items":{"type":"object"}}}},"ShowWorkSummary":{"type":"object","description":"Top-level \"Show Work\" summary.","required":["trace_id","query","outcome","total_duration_ms","total_cost_usd","actions"],"properties":{"actions":{"type":"array","items":{"$ref":"#/components/schemas/ActionSummary"}},"context":{"oneOf":[{"type":"null"},{"$ref":"#/components/schemas/ContextSummary"}]},"llm":{"oneOf":[{"type":"null"},{"$ref":"#/components/schemas/LlmSummary"}]},"outcome":{"type":"string"},"query":{"type":"string"},"retrieval":{"oneOf":[{"type":"null"},{"$ref":"#/components/schemas/RetrievalSummary"}]},"routing":{"oneOf":[{"type":"null"},{"$ref":"#/components/schemas/RoutingSummary"}]},"total_cost_usd":{"type":"number","format":"double"},"total_duration_ms":{"type":"integer","format":"int64","minimum":0},"trace_id":{"type":"string"},"workflow":{"oneOf":[{"type":"null"},{"$ref":"#/components/schemas/WorkflowSummary"}]}}},"SourceLocationInput":{"type":"object","required":["source_type","path"],"properties":{"enabled":{"type":["boolean","null"]},"exclude_patterns":{"type":["array","null"],"items":{"type":"string"}},"git_ref":{"type":["string","null"]},"include_patterns":{"type":["array","null"],"items":{"type":"string"}},"name":{"type":["string","null"]},"path":{"type":"string"},"source_type":{"type":"string","description":"Source type: \"local\", \"git\", or \"archive\""}}},"SpanRejection":{"type":"object","description":"Reason a span was rejected.","required":["span_id","reason"],"properties":{"reason":{"type":"string"},"span_id":{"type":"string"}}},"SpanSummary":{"type":"object","description":"A span in query results.","required":["span_id","trace_id","stage","executor_id","started_at","duration_ms","attestation","stage_name"],"properties":{"attestation":{"type":"integer","format":"int32"},"duration_ms":{"type":"integer","format":"int64","minimum":0},"executor_id":{"type":"string"},"parent_span_id":{"type":["string","null"]},"span_id":{"type":"string"},"stage":{"type":"integer","format":"int32"},"stage_name":{"type":"string"},"started_at":{"type":"integer","format":"int64"},"trace_id":{"type":"string"}}},"StepDispatchMessage":{"type":"object","description":"Step dispatched from daemon to iOS client for execution/approval","required":["workflow_id","step_id","step_type","description","timeout_seconds"],"properties":{"description":{"type":"string"},"payload":{"type":["object","null"]},"step_id":{"type":"string"},"step_type":{"type":"string"},"timeout_seconds":{"type":"integer","format":"int32","minimum":0},"workflow_id":{"type":"string"}}},"StepProgressMessage":{"type":"object","description":"Step progress update from daemon","required":["workflow_id","step_id","state"],"properties":{"state":{"type":"string"},"step_id":{"type":"string"},"summary":{"type":["string","null"]},"workflow_id":{"type":"string"}}},"StepResultCallbackRequest":{"type":"object","description":"Request body for step result callback from executors.","required":["workflow_id","step_id","success","output_summary"],"properties":{"files_affected":{"type":"array","items":{"type":"string"}},"output_data":{"type":["string","null"]},"output_summary":{"type":"string"},"side_effects":{"type":"array","items":{"type":"string"}},"step_id":{"type":"string"},"success":{"type":"boolean"},"workflow_id":{"type":"string"}}},"StepResultCallbackResponse":{"type":"object","description":"Response from step result callback.","required":["success","newly_ready_step_ids"],"properties":{"newly_ready_step_ids":{"type":"array","items":{"type":"string"}},"success":{"type":"boolean"}}},"StepResultMessage":{"type":"object","description":"Step result submitted by iOS client","required":["workflow_id","step_id","result"],"properties":{"result":{"$ref":"#/components/schemas/ClientStepResult"},"step_id":{"type":"string"},"workflow_id":{"type":"string"}}},"SubmitSpansRequest":{"type":"object","description":"Request body for span submission.","required":["spans"],"properties":{"spans":{"type":"array","items":{"$ref":"#/components/schemas/ExecutorSpan"}}}},"SubmitSpansResponse":{"type":"object","description":"Response from span submission.","required":["accepted","rejected"],"properties":{"accepted":{"type":"integer","format":"int32","minimum":0},"errors":{"type":"array","items":{"$ref":"#/components/schemas/SpanRejection"}},"rejected":{"type":"integer","format":"int32","minimum":0}}},"TokenInfo":{"type":"object","required":["id","name","token_prefix","revoked"],"properties":{"id":{"type":"string"},"last_used_at":{"type":["integer","null"],"format":"int64"},"name":{"type":"string"},"revoked":{"type":"boolean"},"token_prefix":{"type":"string"}}},"ToolMetrics":{"type":"object","required":["failure_rate","failures_by_name"],"properties":{"failure_rate":{"type":"number","format":"double"},"failures_by_name":{"type":"object"}}},"TraceConfirmationRequest":{"type":"object","description":"Confirmation request from the client.","required":["workflow_id","step_id","decision"],"properties":{"decision":{"$ref":"#/components/schemas/ConfirmationDecision"},"edited_fields":{"type":["array","null"],"items":{"type":"string"}},"reason":{"type":["string","null"]},"step_id":{"type":"string"},"workflow_id":{"type":"string"}}},"TraceConfirmationResponse":{"type":"object","description":"Response from the confirmation endpoint.","required":["success","step_state"],"properties":{"error":{"type":["string","null"]},"step_state":{"type":"string"},"success":{"type":"boolean"}}},"TraceSummary":{"type":"object","description":"A trace summary for search results.","required":["trace_id","user_id","project_id","executor_id","query_redacted","started_at","completed_at","outcome","span_count","operation_type","operation_summary"],"properties":{"completed_at":{"type":"integer","format":"int64"},"executor_id":{"type":"string"},"operation_summary":{"type":"string"},"operation_type":{"type":"string"},"outcome":{"type":"integer","format":"int32"},"project_id":{"type":"string"},"query_redacted":{"type":"string"},"span_count":{"type":"integer","format":"int32","minimum":0},"started_at":{"type":"integer","format":"int64"},"trace_id":{"type":"string"},"user_id":{"type":"string"}}},"ValidateTokenRequest":{"type":"object","description":"Token validation request (for daemons to validate client tokens)","required":["token"],"properties":{"token":{"type":"string"}}},"ValidateTokenResponse":{"type":"object","description":"Token validation response","required":["valid"],"properties":{"error":{"type":["string","null"]},"projects":{"type":["array","null"],"items":{"type":"string"}},"user_id":{"type":["string","null"]},"valid":{"type":"boolean"}}},"WorkflowCreatedResponse":{"type":"object","description":"Response from workflow creation","required":["success","workflow_id","steps_created"],"properties":{"steps_created":{"type":"integer","minimum":0},"success":{"type":"boolean"},"workflow_id":{"type":"string"}}},"WorkflowStepInfo":{"type":"object","description":"Step info in a workflow response","required":["step_id","sequence","description","type","state","assigned_executor_id","error_message"],"properties":{"assigned_executor_id":{"type":"string"},"description":{"type":"string"},"error_message":{"type":"string"},"sequence":{"type":"integer","format":"int32","minimum":0},"state":{"type":"integer","format":"int32"},"step_id":{"type":"string"},"type":{"type":"integer","format":"int32"}}},"WorkflowSummary":{"type":"object","required":["strategy","steps_total","steps_completed","steps_failed","executor_summary"],"properties":{"executor_summary":{"type":"array","items":{"$ref":"#/components/schemas/ExecutorStepSummary"}},"steps_completed":{"type":"integer","format":"int32","minimum":0},"steps_failed":{"type":"integer","format":"int32","minimum":0},"steps_total":{"type":"integer","format":"int32","minimum":0},"strategy":{"type":"string"}}},"WsClientMessage":{"oneOf":[{"type":"object","required":["token","type"],"properties":{"project_id":{"type":["string","null"]},"token":{"type":"string"},"type":{"type":"string","enum":["auth"]}}},{"type":"object","required":["id","message","type"],"properties":{"id":{"type":"string"},"message":{"type":"string"},"project_id":{"type":["string","null"]},"skip_cache":{"type":["boolean","null"]},"stream":{"type":["boolean","null"]},"type":{"type":"string","enum":["request"]}}},{"type":"object","required":["type"],"properties":{"type":{"type":"string","enum":["ping"]}}},{"type":"object","required":["id","type"],"properties":{"id":{"type":"string"},"type":{"type":"string","enum":["cancel"]}}},{"type":"object","required":["type"],"properties":{"type":{"type":"string","enum":["projects"]}}},{"type":"object","required":["type"],"properties":{"type":{"type":"string","enum":["health"]}}},{"type":"object","required":["id","message","type"],"properties":{"id":{"type":"string"},"message":{"type":"string"},"project_id":{"type":["string","null"]},"type":{"type":"string","enum":["agenticrequest"]}}},{"type":"object","required":["confirmation_id","approved","type"],"properties":{"approved":{"type":"boolean"},"confirmation_id":{"type":"string"},"type":{"type":"string","enum":["confirmationrespond"]}}},{"type":"object","required":["id","name","path","type"],"properties":{"description":{"type":["string","null"]},"id":{"type":"string"},"name":{"type":"string"},"path":{"type":"string"},"type":{"type":"string","enum":["createproject"]}}},{"type":"object","required":["id","type"],"properties":{"id":{"type":"string"},"type":{"type":"string","enum":["getproject"]}}},{"type":"object","required":["id","type"],"properties":{"id":{"type":"string"},"type":{"type":"string","enum":["indexproject"]}}},{"type":"object","required":["id","type"],"properties":{"id":{"type":"string"},"type":{"type":"string","enum":["deleteproject"]}}}],"description":"Client → Server WebSocket messages.\nDiscriminated on the `type` field."},"WsProjectInfo":{"type":"object","description":"Project info in WebSocket responses","required":["id","name"],"properties":{"id":{"type":"string"},"indexed_files":{"type":["integer","null"],"format":"int32","minimum":0},"last_indexed":{"type":["string","null"]},"name":{"type":"string"}}},"WsResponseMetadata":{"type":"object","description":"Response metadata attached to query responses","required":["routing","duration_ms"],"properties":{"cached":{"type":["boolean","null"]},"duration_ms":{"type":"integer","format":"int64","minimum":0},"routing":{"type":"string"}}},"WsServerMessage":{"oneOf":[{"type":"object","required":["success","type"],"properties":{"error":{"type":["string","null"]},"projects":{"type":["array","null"],"items":{"type":"string"}},"success":{"type":"boolean"},"type":{"type":"string","enum":["auth_response"]},"user_id":{"type":["string","null"]}}},{"type":"object","required":["id","success","type"],"properties":{"answer":{"type":["string","null"]},"error":{"type":["string","null"]},"id":{"type":"string"},"sources":{"type":["array","null"],"items":{"type":"string"}},"success":{"type":"boolean"},"trace_id":{"type":["string","null"]},"type":{"type":"string","enum":["response"]}}},{"type":"object","description":"Streaming data for queries with stream: true.\nstream_type is one of: \"progress\", \"partial\", \"complete\", \"error\".","required":["id","stream_type","data","type"],"properties":{"data":{"type":"object"},"id":{"type":"string"},"stream_type":{"type":"string"},"type":{"type":"string","enum":["stream"]}}},{"type":"object","required":["projects","type"],"properties":{"projects":{"type":"array","items":{"$ref":"#/components/schemas/WsProjectInfo"}},"type":{"type":"string","enum":["projects_response"]}}},{"type":"object","required":["status","brain_connected","uptime_seconds","memory_mb","type"],"properties":{"brain_connected":{"type":"boolean"},"memory_mb":{"type":"number","format":"double"},"status":{"type":"string"},"type":{"type":"string","enum":["health_response"]},"uptime_seconds":{"type":"integer","format":"int64","minimum":0}}},{"type":"object","required":["timestamp","type"],"properties":{"timestamp":{"type":"integer","format":"int64"},"type":{"type":"string","enum":["pong"]}}},{"type":"object","required":["request_id","event_type","type"],"properties":{"data":{"type":["object","null"]},"event_type":{"type":"string"},"request_id":{"type":"string"},"type":{"type":"string","enum":["agenticprogress"]}}},{"type":"object","required":["request_id","success","type"],"properties":{"error":{"type":["string","null"]},"request_id":{"type":"string"},"response":{"type":["string","null"]},"success":{"type":"boolean"},"trace_id":{"type":["string","null"]},"type":{"type":"string","enum":["agenticcomplete"]}}},{"type":"object","required":["confirmation_id","request_id","tool_name","description","timeout_seconds","type"],"properties":{"confirmation_id":{"type":"string"},"description":{"type":"string"},"details":{"type":["object","null"]},"request_id":{"type":"string"},"timeout_seconds":{"type":"integer","format":"int32","minimum":0},"tool_name":{"type":"string"},"type":{"type":"string","enum":["confirmationrequest"]}}},{"type":"object","required":["session_id","message_count","type"],"properties":{"active_request_id":{"type":["string","null"]},"context_summary":{"type":["string","null"]},"message_count":{"type":"integer","format":"int32","minimum":0},"session_id":{"type":"string"},"type":{"type":"string","enum":["sessionresumed"]}}}],"description":"Server → Client WebSocket messages.\nDiscriminated on the `type` field."}},"securitySchemes":{"bearer_auth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}}},"tags":[{"name":"auth","description":"Authentication and token management"},{"name":"system","description":"System health and administration"},{"name":"search","description":"Codebase search and query"},{"name":"projects","description":"Project management"},{"name":"indexing","description":"Code indexing operations"},{"name":"llm","description":"LLM completion and status"},{"name":"tokens","description":"API token management"},{"name":"daemons","description":"Daemon registration and lifecycle"},{"name":"executors","description":"Executor registration and lifecycle"},{"name":"keys","description":"Provider API key management"},{"name":"preferences","description":"Model preferences"},{"name":"sessions","description":"Session tracking"},{"name":"traces","description":"Trace collection and observability"},{"name":"admin","description":"Admin operations"},{"name":"workflows","description":"Workflow orchestration"},{"name":"websocket","description":"WebSocket message schemas"}]}