import { IncomingMessage, ServerResponse } from 'node:http';
import type { CacheProvider, AuthProvider, AuditSink, APIGroupConfig, ToolMetadata } from '@mondaydotcomorg/atp-protocol';
import type { ICompiler } from '@mondaydotcomorg/atp-compiler';
import { type DeclarativePolicyConfig, type SecurityPolicy } from '@mondaydotcomorg/atp-provenance';
import type { ServerConfig, Middleware, RequestContext } from './core/config.js';
import { ClientSessionManager } from './client-sessions.js';
import { SandboxExecutor } from './executor/index.js';
import { CodeValidator } from './validator/index.js';
import { SearchEngine } from './search/index.js';
import { ExecutionStateManager } from './execution-state/index.js';
import { ExplorerService } from './explorer/index.js';
export declare class AgentToolProtocolServer {
    private config;
    private middleware;
    private apiGroups;
    private httpServer;
    private responseHeaders;
    private isRunning;
    private policyRegistry;
    private initPromise;
    sessionManager?: ClientSessionManager;
    executor?: SandboxExecutor;
    validator?: CodeValidator;
    searchEngine?: SearchEngine;
    explorerService?: ExplorerService;
    stateManager?: ExecutionStateManager;
    approvalHandler?: (request: {
        message: string;
        context?: any;
    }) => Promise<{
        approved: boolean;
        data?: any;
    }>;
    cacheProvider?: CacheProvider;
    authProvider?: AuthProvider;
    auditSink?: AuditSink;
    compiler?: ICompiler;
    private customLogger?;
    private toolRulesProvider?;
    constructor(config?: ServerConfig);
    /**
     * Add a security policy (programmatic SecurityPolicy object)
     * @example
     * server.addPolicy(preventDataExfiltration);
     */
    addPolicy(policy: SecurityPolicy): this;
    /**
     * Add multiple security policies
     */
    addPolicies(policies: SecurityPolicy[]): this;
    /**
     * Load declarative policies from JSON configuration
     * @example
     * server.loadPolicies([{
     *   id: 'block-llm-payments',
     *   scope: { toolName: 'payment.*' },
     *   rules: [{ action: 'block', conditions: [...] }]
     * }]);
     */
    loadPolicies(configs: DeclarativePolicyConfig[], replace?: boolean): this;
    /**
     * Remove a policy by name
     */
    removePolicy(name: string): this;
    /**
     * Clear all policies
     */
    clearPolicies(): this;
    /**
     * Get all active policies
     */
    getPolicies(): SecurityPolicy[];
    /**
     * Register middleware or API groups.
     * Can be called before OR after server starts.
     * - Before start: Simply adds to configuration
     * - After start: Dynamically updates running server components
     *
     * Note: Middleware can only be added before server starts.
     * @throws {Error} If trying to add middleware after server has started
     */
    use(...items: (Middleware | APIGroupConfig | APIGroupConfig[])[]): this;
    /**
     * Register a tool/function with optional hierarchical grouping.
     * Supports hierarchical paths like 'github/readOnly' for better organization.
     * All functions registered here will be exposed as api.{group}.{name}()
     *
     * @param name - Function name
     * @param definition - Function definition including description, input schema, handler
     * @param definition.group - Optional hierarchical group path (e.g., 'github/readOnly'). Defaults to 'custom'
     *
     * @example
     * // Simple function in default 'custom' group -> api.custom.hello()
     * server.tool('hello', {
     *   description: 'Say hello',
     *   input: { name: 'string' },
     *   handler: async (input) => ({ message: `Hello ${input.name}` })
     * });
     *
     * // Hierarchical grouping -> api.github.readOnly.getUser()
     * server.tool('getUser', {
     *   group: 'github/readOnly',
     *   description: 'Get GitHub user',
     *   input: { username: 'string' },
     *   handler: async (input) => ({ username: input.username })
     * });
     */
    tool(name: string, definition: {
        group?: string;
        groupDescription?: string;
        description: string;
        input: Record<string, string>;
        output?: Record<string, string>;
        handler: (input: unknown) => Promise<unknown>;
        metadata?: ToolMetadata;
    }): this;
    /**
     * Configure approval handler for human-in-the-loop operations
     * The handler will be called when code requests approval via atp.approval.request()
     */
    onApproval(handler: (request: {
        message: string;
        context?: any;
    }) => Promise<{
        approved: boolean;
        data?: any;
    }>): this;
    /**
     * Initialize server components without starting HTTP server.
     * Call this when using handler(), toExpress() or toFastify().
     */
    start(): Promise<void>;
    listen(port: number): Promise<void>;
    stop(): Promise<void>;
    getInfo(): unknown;
    getDefinitions(ctx?: RequestContext): Promise<unknown>;
    getRuntimeDefinitions(ctx?: RequestContext): Promise<string>;
    handleInit(ctx: RequestContext): Promise<unknown>;
    handleSearch(ctx: RequestContext): Promise<unknown>;
    handleSearchQuery(ctx: RequestContext): Promise<unknown>;
    handleExplore(ctx: RequestContext): Promise<unknown>;
    handleExecute(ctx: RequestContext): Promise<unknown>;
    handleResume(ctx: RequestContext, executionId: string): Promise<unknown>;
    /**
     * Update server components with new API groups (internal method)
     * @private
     */
    private updateComponentsWithNewGroups;
    /**
     * Load an OpenAPI spec and add it to the server
     * Works both before and after server starts
     * @param source - URL or file path to OpenAPI spec
     * @param options - OpenAPI loading options
     */
    loadOpenAPI(source: string, options?: any): Promise<this>;
    /**
     * Load a GraphQL spec and add it to the server
     * Works both before and after server starts
     * @param source - URL or file path to GraphQL spec (SDL, introspection JSON, or endpoint URL)
     * @param options - GraphQL loading options
     */
    loadGraphQL(source: string, options?: any): Promise<this>;
    /**
     * Get raw Node.js request handler for framework integration
     * Use this to integrate ATP with Express, Fastify, or any Node.js framework
     * Components will be automatically initialized on first request if not already started.
     */
    handler(): (req: IncomingMessage, res: ServerResponse) => Promise<void>;
    /**
     * Get Express middleware
     * @example
     * const app = express();
     * app.use('/atp', server.toExpress());
     */
    toExpress(): (req: unknown, res: unknown, next: (err?: unknown) => void) => void;
    /**
     * Get Fastify handler
     * @example
     * fastify.all('/atp/*', server.toFastify());
     */
    toFastify(): (request: unknown, reply: unknown) => Promise<void>;
    /**
     * Parse OpenTelemetry headers from environment variable format
     * Format: "key1=value1,key2=value2"
     */
    private parseOtelHeaders;
}
export declare function createServer(config?: ServerConfig): AgentToolProtocolServer;
//# sourceMappingURL=create-server.d.ts.map