src/host/server-local.ts | HTTP server composition root (local mode): Unix socket + TCP lifecycle, channel connect/disconnect, legacy migration, file upload/download, OAuth callbacks, graceful drain. Delegates shared init to server-init.ts and shared handlers to server-request-handlers.ts |
src/host/server-init.ts | Shared initialization for both server-local.ts and server-k8s.ts: initHostCore() sets up storage, routing, taint budget, agent dirs, template seeding, skills seeding, admins, IPC, CompletionDeps, delegation, orchestrator, agent registry. Also loads plugin MCP servers on startup via reloadPluginMcpServers(), loads database MCP servers via loadDatabaseMcpServers(), and creates McpConnectionManager |
src/host/server-request-handlers.ts | Shared HTTP handlers: handleModels, handleCompletions (body parsing + streaming + non-streaming via runCompletion callback), handleEventsSSE (EventBus-based SSE), createSchedulerCallback factory |
src/host/server-admin-helpers.ts | Pure admin functions: isAgentBootstrapMode, isAdmin, addAdmin, claimBootstrapAdmin (used by server-local.ts, server-completions.ts, IPC handlers) |
src/host/server-webhook-admin.ts | Shared webhook + admin handler factories: setupWebhookHandler, setupAdminHandler |
src/host/server-completions.ts | Completion processing, workspace setup, history loading, image extraction, agent spawning, response parsing. Container sandboxes (Docker/Apple) use three-phase orchestration: provision (network) → run (no network) → cleanup (network) |
src/host/server-channels.ts | Channel ingestion, message deduplication, thread gating/backfill, emoji reactions, attachment handling, per-message agent routing (resolveAgentForMessage), thread ownership tracking (ThreadOwnershipMap), response prefix for personal agents in shared channels (maybeAddResponsePrefix) |
src/host/server-files.ts | File upload/download API, workspace file storage, MIME type handling |
src/host/server-http.ts | HTTP utilities, SSE chunking, body reading, error responses |
src/host/server-lifecycle.ts | Stub — lifecycle duties now distributed to server-local.ts and server-k8s.ts |
src/host/event-bus.ts | Typed pub/sub for real-time completion observability, global + per-request listeners |
src/host/chat-termination.ts | logChatTermination(reqLogger, { phase, reason, sandboxId?, exitCode?, details? }) — unified chat_terminated error-level event called from every host-side site where a chat turn dies abnormally. Plus logChatComplete(reqLogger, { sessionId, agentId?, durationMs, phases?, sandboxId?, tokens? }) — paired success-side chat_complete info-level event so every chat (happy or sad) produces exactly one canonical greppable line. Plus createWaitFailureTracker() for retry loops — emits chat_terminated EXACTLY ONCE per terminated chat (not per attempt). See ax-logging-errors skill for conventions |
src/host/router.ts | Inbound scan + taint-wrap + canary inject; outbound scan + canary check |
src/host/ipc-server.ts | Unix socket server, IPC action dispatch, Zod validation, taint budget gate, heartbeat, event emission. Concurrent IPC call fix (misrouted responses on shared socket). proxy.sock race prevention (await IPC server listen). agent_response timeout handling without crashing |
src/host/ipc-handlers/browser.ts | Browser automation IPC handlers |
src/host/ipc-handlers/delegation.ts | Agent delegation with depth/concurrency limits, zombie counter prevention |
src/host/ipc-handlers/governance.ts | Proposal list/review IPC handlers |
src/host/ipc-handlers/identity.ts | Identity read/write/propose IPC handlers (backed by DocumentStore) |
src/host/ipc-handlers/image.ts | Image generation handler, in-memory image storage per session |
src/host/ipc-handlers/llm.ts | LLM call IPC handler with event emission |
src/host/ipc-handlers/memory.ts | Memory CRUD IPC handlers |
src/host/ipc-handlers/orchestration.ts | Agent orchestration IPC handlers (status, list, tree, message, poll, interrupt, timeline) |
src/host/ipc-handlers/plugin.ts | Plugin status/list queries (host-internal actions) |
src/host/ipc-handlers/scheduler.ts | Scheduler job management IPC handlers |
src/host/ipc-handlers/sandbox-tools.ts | Sandbox tool IPC handlers (sandbox_bash, sandbox_read_file, sandbox_write_file, sandbox_edit_file) and audit gate protocol (sandbox_approve, sandbox_result) for in-container tool execution with host approval |
src/host/ipc-handlers/skills.ts | Skill read/list/propose/import/search IPC handlers + credential_request handler (backed by DocumentStore) |
src/host/skills/get-agent-skills.ts | Live per-agent skill state derivation. getAgentSkills() / getAgentSetupQueue() walk the workspace repo + diff frontmatter against stored creds / approved domains. Backed by the (agentId, HEAD-sha) snapshot cache |
src/host/skills/snapshot-cache.ts | Bounded LRU snapshot cache keyed on ${agentId}@${headSha}. Supports invalidateAgent(agentId) for post-push cache-bust |
src/host/skills/hook-endpoint.ts | HMAC-verified post-receive hook. On a signed push, invalidates the agent's cached snapshots so the next live read is fresh. No other side effects |
src/host/ipc-handlers/web.ts | Web fetch/search IPC handlers |
src/host/ipc-handlers/workspace.ts | Workspace read/write/list IPC handlers |
src/host/ipc-handlers/describe-tools.ts | describe_tools meta-tool handler — schema lookup by catalog name; names: [] returns the full directory |
src/host/ipc-handlers/call-tool.ts | call_tool meta-tool handler — dispatches MCP or OpenAPI by catalog entry, handles _select jq projection + auto-spill, returns structured {error, kind} on failure |
src/host/ipc-handlers/openapi-dispatcher.ts | Default HTTP dispatcher used by call_tool for dispatch.kind === 'openapi'. Path/query/header/body routing, 4 auth schemes (bearer/basic/api_key_header/api_key_query), URL rewrites, credential redaction in failure logs |
src/host/tool-catalog/ | Session-scoped tool catalog: registry, MCP adapter, OpenAPI adapter (pure, takes dereferenced spec), jq projection, per-(agentId,HEAD-sha) cache |
src/host/skills/catalog-population.ts | Walks the skill snapshot, builds the catalog from mcpServers[] + openapi[], pushes Diagnostic entries on failures and wide-surface advisories |
src/host/skills/openapi-spec-fetcher.ts | Default fetchOpenApiSpec factory — HTTPS URLs go direct to @apidevtools/swagger-parser, workspace-relative paths resolve through the bare git repo with traversal guards |
src/host/diagnostics.ts | Per-turn ring-buffered DiagnosticCollector — populate failures and wide-surface advisories emitted as event: diagnostic SSE frames at end-of-turn |
src/plugins/mcp-manager.ts | McpConnectionManager — unified MCP tool discovery and routing across all MCP sources |
src/host/inprocess.ts | In-process fast path — runs LLM orchestration loop directly in host process (no pods, no IPC, no proxy). Uses FastPathDeps (including McpConnectionManager), FastPathRequest, FastPathResult. AsyncLocalStorage for per-turn context isolation |
src/host/tool-router.ts | Tool router for in-process fast path — routes tool calls to MCP providers (unified via McpConnectionManager), lazy file I/O, or sandbox escalation. Unified MCP methods: resolveServer(), mcpCallTool(), resolveHeaders(). Per-turn limits (FAST_PATH_LIMITS). Exports routeToolCall(), ToolRouterContext, ToolResult |
src/host/sandbox-manager.ts | Sandbox session manager — tracks session-bound sandbox pods for cross-turn escalation from fast path. CRUD on DocumentStore with TTL (30min default, 1hr max) |
src/host/agent-registry.ts | Enterprise agent registry (registry.json), lifecycle management. AgentRegistryEntry has displayName, agentKind ('personal'/'shared'), admins[]. findByKind() filters by agent kind |
src/host/agent-registry-db.ts | Database-backed agent registry for PostgreSQL (Kysely, runs own migration). Migration 003 adds display_name and agent_kind columns |
src/host/server-admin.ts | Admin API endpoints (agent management, config, diagnostics). Includes admin API endpoints for MCP server management under /admin/api/agents/:id/mcp-servers and the phase-5 skill setup endpoints under /admin/api/skills/setup and /admin/api/credentials/requests |
src/host/server-admin-skills-helpers.ts | Helper for POST /admin/api/skills/setup/approve. Validates the request body against the live setup card (via getAgentSetupQueue), then writes credentials (legacy credentials.set + tuple-keyed skill_credentials), approves pending domains by writing skill_domain_approvals rows, invalidates the agent's snapshot cache, and reads the fresh SkillState via getAgentSkills. Narrow ApproveDeps interface avoids circular imports with server-admin.ts |
src/host/credential-request-queue.ts | Phase-5 in-memory queue of ad-hoc credential requests. Seeded by credential.required event-bus subscriptions; drained when POST /admin/api/credentials/provide succeeds. Exposed to the dashboard via GET /admin/api/credentials/requests |
src/host/server-k8s.ts | Unified host pod process for k8s deployment. Delegates shared init to server-init.ts. Keeps k8s-specific: NATS connection (work dispatch only), /internal/* routes (ipc, llm-proxy, workspace), web proxy with MITM CA, stagingStore, activeTokens registry. Uses server-request-handlers.ts for completions/models/scheduler. Use server-local.ts for local dev |
src/host/server-chat-api.ts | Chat API handler — serves /v1/chat/sessions endpoints for chat UI thread list and history |
src/host/server-chat-ui.ts | Chat UI static file serving — serves built chat UI from dist/chat-ui/ at root path |
src/host/session-title.ts | Auto-generate session titles from first user message using fast LLM model |
src/host/llm-proxy-core.ts | Shared LLM credential injection and forwarding — used by both Unix socket proxy (proxy.ts) and HTTP route (/internal/llm-proxy in server-k8s.ts) |
src/host/oauth-skills.ts | OAuth PKCE flow for skill credentials — manages pending flows (start → callback → token exchange → store), handles token refresh |
src/host/admin-oauth-providers.ts | AES-256-GCM encrypted admin-registered OAuth provider CRUD. Key derived from AX_OAUTH_SECRET_KEY (preferred, 32 hex bytes) or config.admin.token (fallback, requires ≥16 chars). clientSecret never returned on read. |
src/host/admin-oauth-flow.ts | PKCE pending-flow map (15-min TTL, single-use) + resolveCallback that exchanges code via AbortSignal.timeout(15s), writes access_token at declared credential scope, stores refresh blob at <envName>__oauth_blob, invalidates the agent's snapshot cache so the next live read picks up the new credential. Returns `{matched:false} |
src/migrations/admin-oauth-providers.ts | Kysely migration for admin_oauth_providers table (name PK, client_id, encrypted client_secret blob, metadata). |
src/host/web-proxy-approvals.ts | Web proxy approval coordination via event bus — replaces old in-memory promise map pattern. Works across stateless replicas (in-process for local, NATS for k8s) |
src/host/workspace-release-screener.ts | Release-time screening for skill files and binaries — inspects workspace changes before GCS commit |
src/host/delivery.ts | Delivery resolution for cron/heartbeat responses (CronDelivery handling) |
src/host/event-console.ts | Real-time event display with color-coded output |
src/host/history-summarizer.ts | Recursive conversation summarization with LLM |
src/host/memory-recall.ts | Memory recall integration with embeddings for context injection |
src/host/oauth.ts | OAuth token management (pre-flight + reactive 401 retry) |
src/host/server-webhooks.ts | Inbound webhook handler with LLM-powered transforms |
src/host/webhook-transform.ts | LLM-powered webhook payload transformation |
src/host/plugin-host.ts | Plugin lifecycle manager, integrity verification, process management, IPC proxy |
src/host/plugin-lock.ts | Plugin manifest pinning, SHA-512 integrity hashing, lock file I/O |
src/host/plugin-manifest.ts | Plugin capability schema, validation, human-readable formatting |
src/host/proxy.ts | Credential-injecting Anthropic forward proxy, OAuth 401 retry |
src/host/web-proxy.ts | HTTP forward proxy for agent outbound HTTP/HTTPS. HTTP forwarding + HTTPS CONNECT tunneling, private IP blocking (SSRF), canary token scanning on request bodies, audit logging. Listens on Unix socket (container sandboxes) or TCP port (subprocess/k8s). Opt-in via config.web_proxy |
src/host/taint-budget.ts | Per-session taint ratio tracking, action gating (SC-SEC-003) |
src/host/provider-map.ts | Static allowlist mapping config names to provider modules (SC-SEC-002), plugin registration runtime allowlist. mcp category has none and database entries |
src/host/registry.ts | Loads and assembles ProviderRegistry from config; three loading patterns (simple, manual-import with deps, custom); plugin host integration. MCP provider requires { database, credentials } deps |