import { AgencyNode } from "./types.js";
import type { LogLevel } from "./logger.js";
import { z } from "zod";
export declare const TYPES_THAT_DONT_TRIGGER_NEW_PART: AgencyNode["type"][];
/**
 * Maps Agency built-in function names to TypeScript equivalents.
 * Most map to themselves; exceptions are names that shadow JS globals.
 */
export declare const BUILTIN_FUNCTIONS: Record<string, string>;
export declare const BUILTIN_TOOLS: string[];
export declare const BUILTIN_VARIABLES: string[];
/**
 * Configuration options for the Agency compiler
 */
export interface AgencyConfig {
    verbose?: boolean;
    logLevel?: LogLevel;
    outDir?: string;
    /**
     * Array of AST node types to exclude from code generation
     * Example: ["comment", "typeAlias"]
     */
    excludeNodeTypes?: string[];
    /**
     * Array of built-in function names to exclude from code generation
     * Example: ["fetch", "write"]
     */
    excludeBuiltinFunctions?: string[];
    /**
     * Array of domains allowed for fetch operations
     * If specified, only these domains can be fetched
     * Example: ["api.example.com", "data.mysite.com"]
     */
    allowedFetchDomains?: string[];
    /**
     * Array of domains disallowed for fetch operations
     * These domains will throw an error if fetch is attempted
     * If both allowed and disallowed are set, takes the intersection
     * (only allowed domains, minus disallowed ones)
     * Example: ["malicious.com", "blocked.site.com"]
     */
    disallowedFetchDomains?: string[];
    /**
     * Optionally specify a custom host for tarsec trace collection
     */
    tarsecTraceHost?: string;
    /**
     * Number of times the LLM can go back and forth between calling tools
     * and responding to their outputs before halting execution to prevent infinite loops.
     * Default 10.
     */
    maxToolCallRounds?: number;
    /**
     * Enable observability. When false (default), the StatelogClient is a
     * complete no-op — no events are emitted and no network calls are made.
     * Set to true to activate structured event logging via the `log` config.
     */
    observability?: boolean;
    /** Statelog config */
    log?: Partial<{
        host: string;
        projectId: string;
        debugMode: boolean;
        apiKey: string;
        /**
         * Local file sink. When set, each statelog event is appended as a
         * single JSON object per line. Intended for local development and
         * tests. Can be combined with `host` — both sinks receive events.
         */
        logFile: string;
        /**
         * Per-event remote-send timeout in milliseconds. Bounds how long
         * `agency` can wait on a slow/unreachable statelog host before
         * giving up — prevents the http POST at end-of-run from delaying
         * process exit. Default: 1500ms.
         */
        requestTimeoutMs: number;
        metadata: {
            tags?: string[];
            environment?: string;
            userId?: string;
            agentVersion?: string;
            custom?: Record<string, string>;
        };
    }>;
    /** Smoltalk client config */
    client?: Partial<{
        logLevel: "error" | "warn" | "info" | "debug";
        defaultModel: string;
        openAiApiKey: string;
        googleApiKey: string;
        statelog?: Partial<{
            host: string;
            projectId: string;
            apiKey: string;
        }>;
    }>;
    /**
     * Type checker configuration. Controls which checks run and their severity.
     */
    typechecker?: {
        /** If true, run type checking during compilation and print warnings. Default: false. */
        enabled?: boolean;
        /** If true, type errors are fatal during compilation (implies enabled: true). Default: false. */
        strict?: boolean;
        /** If true, untyped variables are errors. Default: false. */
        strictTypes?: boolean;
        /**
         * What to do when a function call cannot be resolved:
         * - "silent": ignore
         * - "warn": emit a warning (default)
         * - "error": emit an error
         */
        undefinedFunctions?: "silent" | "warn" | "error";
        /**
         * What to do when a variable reference cannot be resolved:
         * - "silent": ignore (default for the initial landing)
         * - "warn": emit a warning
         * - "error": emit an error
         */
        undefinedVariables?: "silent" | "warn" | "error";
    };
    /** Enable debugger mode — auto-inserts breakpoints before every step */
    debugger?: boolean;
    /** Whether to emit debugStep() instrumentation in compiled output (default: true).
     *  Set to false to eliminate per-step overhead when tracing/debugging is not needed. */
    instrument?: boolean;
    /** Checkpoint configuration */
    checkpoints?: {
        /** Maximum number of times a single checkpoint can be restored before throwing CheckpointError.
         * Prevents infinite restore loops. Default: 100. */
        maxRestores?: number;
    };
    /** Enable execution tracing — writes checkpoints to a .trace file */
    trace?: boolean;
    /** Custom path for the trace file (default: <program>.trace) */
    traceFile?: string;
    /** Directory for auto-generated trace files. Each execution creates a new file
     *  named <timestamp>_<id>.agencytrace. */
    traceDir?: string;
    /** Directory containing pre-compiled JS output (e.g., "dist").
     *  When set, the debugger imports compiled modules from this directory
     *  instead of compiling on the fly. Resolved relative to cwd. */
    distDir?: string;
    /** Test runner configuration */
    test?: {
        /** Number of test files to run in parallel. Default: 1 (sequential). */
        parallel?: number;
    };
    doc?: {
        /** Output directory for generated documentation (default: "docs") */
        outDir?: string;
        /** Base URL for source links in generated docs */
        baseUrl?: string;
    };
    /**
     * Enables the memory layer for this project. When set, every agent run
     * receives a `MemoryManager` on its RuntimeContext, std::memory becomes
     * usable, and `llm({ memory: true })` injects relevant facts.
     */
    memory?: {
        /** Directory where per-memoryId subdirectories of JSON files are stored. */
        dir: string;
        /** Default model used for extraction / compaction / LLM-tier recall. */
        model?: string;
        autoExtract?: {
            /** Number of LLM turns between auto-extraction passes. Default: 5. */
            interval?: number;
        };
        compaction?: {
            /** Trigger metric: "token" estimates or raw "messages" count. */
            trigger?: "token" | "messages";
            /** Threshold above which compaction runs. */
            threshold?: number;
        };
        embeddings?: {
            /** Embedding model name (forwarded to smoltalk.embed). */
            model?: string;
        };
    };
    /**
     * Visual thresholds used by `agency logs view`. Durations at or
     * above `slowMs` (default 5000) render bright-red; durations below
     * `fastMs` (default 100) render gray. Costs at or above
     * `expensiveUsd` (default 0.01) render bright-red.
     */
    viewer?: {
        slowMs?: number;
        fastMs?: number;
        expensiveUsd?: number;
    };
    pack?: {
        /**
         * Output module format. Default: "esm". CJS output is useful when
         * embedding the bundle in a project whose package.json sets
         * `"type": "commonjs"` and the surrounding tooling expects CommonJS.
         */
        format?: "esm" | "cjs";
        /**
         * esbuild `target` string (e.g. "node20", "node22"). Default: "node20".
         */
        target?: string;
        /**
         * Additional bare specifiers to keep external (in addition to Node
         * built-ins). Use sparingly — anything listed here must already be
         * installed wherever the bundle runs.
         */
        external?: string[];
    };
    coverage?: {
        /** Output directory for collected coverage data (default: ".coverage") */
        outDir?: string;
        /**
         * Minimum acceptable total coverage percentage (0–100).
         * `agency coverage report` exits with code 1 when total coverage falls
         * below this value. Overridden by the CLI `--threshold` flag.
         */
        threshold?: number;
        /**
         * Per-file minimum coverage percentage (0–100). Each individual file
         * must be at or above this value, in addition to the overall threshold.
         */
        perFileThreshold?: number;
        /**
         * Glob patterns of source files to exclude from coverage reports
         * (relative to the project root, picomatch syntax). Useful for
         * generated code, examples, or files you intentionally do not test.
         *
         * Example: ["examples/**", "stdlib/legacy/**"]
         */
        exclude?: string[];
    };
}
export declare const AgencyConfigSchema: z.ZodObject<{
    verbose: z.ZodOptional<z.ZodBoolean>;
    logLevel: z.ZodOptional<z.ZodEnum<{
        debug: "debug";
        info: "info";
        warn: "warn";
        error: "error";
    }>>;
    outDir: z.ZodOptional<z.ZodString>;
    excludeNodeTypes: z.ZodOptional<z.ZodArray<z.ZodString>>;
    excludeBuiltinFunctions: z.ZodOptional<z.ZodArray<z.ZodString>>;
    allowedFetchDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
    disallowedFetchDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
    tarsecTraceHost: z.ZodOptional<z.ZodString>;
    maxToolCallRounds: z.ZodOptional<z.ZodNumber>;
    observability: z.ZodOptional<z.ZodBoolean>;
    log: z.ZodOptional<z.ZodObject<{
        host: z.ZodOptional<z.ZodString>;
        projectId: z.ZodOptional<z.ZodString>;
        debugMode: z.ZodOptional<z.ZodBoolean>;
        apiKey: z.ZodOptional<z.ZodString>;
        logFile: z.ZodOptional<z.ZodString>;
        requestTimeoutMs: z.ZodOptional<z.ZodNumber>;
        metadata: z.ZodOptional<z.ZodObject<{
            tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
            environment: z.ZodOptional<z.ZodString>;
            userId: z.ZodOptional<z.ZodString>;
            agentVersion: z.ZodOptional<z.ZodString>;
            custom: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
        }, z.core.$strip>>;
    }, z.core.$strip>>;
    client: z.ZodOptional<z.ZodObject<{
        logLevel: z.ZodOptional<z.ZodEnum<{
            debug: "debug";
            info: "info";
            warn: "warn";
            error: "error";
        }>>;
        defaultModel: z.ZodOptional<z.ZodString>;
        openAiApiKey: z.ZodOptional<z.ZodString>;
        googleApiKey: z.ZodOptional<z.ZodString>;
        statelog: z.ZodOptional<z.ZodObject<{
            host: z.ZodOptional<z.ZodString>;
            projectId: z.ZodOptional<z.ZodString>;
            apiKey: z.ZodOptional<z.ZodString>;
        }, z.core.$strip>>;
    }, z.core.$strip>>;
    typechecker: z.ZodOptional<z.ZodObject<{
        enabled: z.ZodOptional<z.ZodBoolean>;
        strict: z.ZodOptional<z.ZodBoolean>;
        strictTypes: z.ZodOptional<z.ZodBoolean>;
        undefinedFunctions: z.ZodOptional<z.ZodEnum<{
            warn: "warn";
            error: "error";
            silent: "silent";
        }>>;
        undefinedVariables: z.ZodOptional<z.ZodEnum<{
            warn: "warn";
            error: "error";
            silent: "silent";
        }>>;
    }, z.core.$strip>>;
    debugger: z.ZodOptional<z.ZodBoolean>;
    instrument: z.ZodOptional<z.ZodBoolean>;
    checkpoints: z.ZodOptional<z.ZodObject<{
        maxRestores: z.ZodOptional<z.ZodNumber>;
    }, z.core.$strip>>;
    trace: z.ZodOptional<z.ZodBoolean>;
    traceFile: z.ZodOptional<z.ZodString>;
    traceDir: z.ZodOptional<z.ZodString>;
    distDir: z.ZodOptional<z.ZodString>;
    test: z.ZodOptional<z.ZodObject<{
        parallel: z.ZodOptional<z.ZodNumber>;
    }, z.core.$strip>>;
    doc: z.ZodOptional<z.ZodObject<{
        outDir: z.ZodOptional<z.ZodString>;
        baseUrl: z.ZodOptional<z.ZodString>;
    }, z.core.$strip>>;
    viewer: z.ZodOptional<z.ZodObject<{
        slowMs: z.ZodOptional<z.ZodNumber>;
        fastMs: z.ZodOptional<z.ZodNumber>;
        expensiveUsd: z.ZodOptional<z.ZodNumber>;
    }, z.core.$strip>>;
    coverage: z.ZodOptional<z.ZodObject<{
        outDir: z.ZodOptional<z.ZodString>;
        threshold: z.ZodOptional<z.ZodNumber>;
        perFileThreshold: z.ZodOptional<z.ZodNumber>;
        exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
    }, z.core.$strip>>;
    pack: z.ZodOptional<z.ZodObject<{
        format: z.ZodOptional<z.ZodEnum<{
            esm: "esm";
            cjs: "cjs";
        }>>;
        target: z.ZodOptional<z.ZodString>;
        external: z.ZodOptional<z.ZodArray<z.ZodString>>;
    }, z.core.$strip>>;
    memory: z.ZodOptional<z.ZodObject<{
        dir: z.ZodString;
        model: z.ZodOptional<z.ZodString>;
        autoExtract: z.ZodOptional<z.ZodObject<{
            interval: z.ZodOptional<z.ZodNumber>;
        }, z.core.$strip>>;
        compaction: z.ZodOptional<z.ZodObject<{
            trigger: z.ZodOptional<z.ZodEnum<{
                token: "token";
                messages: "messages";
            }>>;
            threshold: z.ZodOptional<z.ZodNumber>;
        }, z.core.$strip>>;
        embeddings: z.ZodOptional<z.ZodObject<{
            model: z.ZodOptional<z.ZodString>;
        }, z.core.$strip>>;
    }, z.core.$strip>>;
}, z.core.$loose>;
/**
 * Load agency.json at the given path without calling process.exit.
 * Returns the parsed config, or an error message if the file is invalid.
 * Returns an empty config if the file doesn't exist.
 */
export declare function loadConfigSafe(configPath: string): {
    config: AgencyConfig;
    error?: string;
};
/**
 * Find the agency.json for a given file path by searching upward.
 * Returns the directory containing agency.json, or null if not found.
 */
export declare function findProjectRoot(startPath: string): string | null;
