/**
 * Studiograph HTTP Server
 *
 * Hosts:
 *   - Graph API (read-only REST over WorkspaceManager)
 *   - Agent chat via POST /api/chat and SSE GET /api/chat/stream
 *   - Static web UI (SvelteKit build) with SPA fallback
 */
import { type FastifyInstance } from 'fastify';
import { WorkspaceManager } from '../core/workspace-manager.js';
import { GitUser } from '../services/git.js';
import { WorkspaceConfig } from '../core/types.js';
import { AuthService } from '../services/auth-service.js';
export interface ServerConfig {
    workspaceManager: WorkspaceManager;
    workspacePath: string;
    workspaceConfig: WorkspaceConfig;
    gitUser: GitUser;
    port: number;
    host: string;
    /**
     * Phase 8: master key + version for AuthService's per-user encryption
     * path (oauth_tokens.data_ciphertext, user_preferences.settings_ciphertext).
     * Caller is `serve.ts`. Absent in tests that don't boot the full
     * server (AuthService then stays on the legacy plaintext path).
     */
    authCryptoOptions?: {
        masterKey: Uint8Array;
        keyVersion?: string;
    };
    /**
     * Random per-boot id (set by serve.ts). Echoed by GET /api/server-info and
     * written to `.studiograph/server.json` so the stdio MCP proxy can confirm
     * it is talking to the server that owns this workspace before sending it a
     * Bearer token. Absent in tests / non-serve callers.
     */
    serverId?: string;
}
export declare function resolveStaticFilePath(webDir: string, urlPath: string): string | null;
export declare function buildAllowedCorsOrigins(workspaceConfig: WorkspaceConfig, port: number): Set<string>;
export declare function isCorsOriginAllowed(origin: string | undefined, allowedOrigins: Set<string>): boolean;
/**
 * Auth middleware — validates JWT cookie or Authorization: Bearer <key> header.
 * When users exist in the auth database, all routes require authentication
 * (except auth endpoints and static assets). When no users exist, everything
 * is open (backward compatible).
 */
export declare function createAuthHook(authService: AuthService, workspaceConfig: Record<string, unknown>): (req: any, reply: any) => Promise<any>;
export declare function createServer(config: ServerConfig): Promise<FastifyInstance>;
