/**
 * Resolve the model config a Tangle agent's sandbox/runtime runs on.
 *
 * Every Tangle agent product resolves the SAME thing from env: the Tangle Router
 * (OpenAI-compatible, metered at the platform markup against a single
 * `TANGLE_API_KEY`) by default, with a direct-Anthropic BYOK escape hatch. The
 * shape feeds the sandbox SDK's `backend.model`. Lifted here so no product
 * hand-rolls the env parsing + the router default.
 */
interface TangleModelConfig {
    /** The Tangle Router is OpenAI-compatible → driven via `openai-compat`.
     *  `anthropic` is the BYOK escape hatch. */
    provider: 'openai-compat' | 'anthropic';
    model: string;
    apiKey: string;
    baseUrl: string;
}
type TangleExecutionEnvironment = 'development' | 'staging' | 'production' | 'test';
type TangleExecutionKeySource = 'local-env' | 'user';
type TangleExecutionKeyErrorCode = 'local_tangle_api_key_required' | 'tangle_account_not_connected';
interface ResolveModelOptions {
    /** Env to read (defaults to process.env). */
    env?: Record<string, string | undefined>;
    /** Router base URL default when `TANGLE_ROUTER_BASE_URL` is unset. */
    defaultRouterBaseUrl?: string;
}
interface ResolveUserTangleExecutionKeyOptions {
    /** Deployment context. Only local development may fall back to env keys. */
    environment?: TangleExecutionEnvironment;
    /** Env to read for the local-development fallback. */
    env?: Record<string, string | undefined>;
    /** App-owned lookup for the caller's linked platform API key. */
    getUserApiKey: () => string | null | undefined | Promise<string | null | undefined>;
}
interface ResolveUserTangleExecutionKeyForUserOptions<UserId = string> {
    userId: UserId;
    environment?: TangleExecutionEnvironment;
    env?: Record<string, string | undefined>;
    getUserApiKey: (userId: UserId) => string | null | undefined | Promise<string | null | undefined>;
}
interface ResolvedTangleExecutionKey {
    apiKey: string;
    source: TangleExecutionKeySource;
}
interface ResolveTangleDevOrUserKeyOptions {
    /** Deployment context. Only local development may use the env key. */
    environment?: TangleExecutionEnvironment;
    /** Env to read for the local-development fallback. */
    env?: Record<string, string | undefined>;
    /** App-owned lookup for the caller's linked platform API key. */
    getUserApiKey: () => string | null | undefined | Promise<string | null | undefined>;
}
interface TangleExecutionKeyHttpError {
    status: number;
    body: {
        error: string;
        code: TangleExecutionKeyErrorCode;
    };
}
interface CreateTangleRouterModelConfigOptions {
    apiKey: string;
    model: string;
    baseUrl?: string;
}
interface TangleBillingEnforcementOptions {
    /** Env to read (defaults to process.env). */
    env?: Record<string, string | undefined>;
    /**
     * Optional app-specific override flag, e.g. `GTM_BILLING_ENFORCEMENT`.
     * Defaults to the shared `TANGLE_BILLING_ENFORCEMENT`.
     */
    enforcementEnvVar?: string;
}
declare const DEFAULT_TANGLE_ROUTER_BASE_URL = "https://router.tangle.tools/v1";
declare const DEFAULT_TANGLE_BILLING_ENFORCEMENT_ENV_VAR = "TANGLE_BILLING_ENFORCEMENT";
declare function trimOrNull(value: string | null | undefined): string | null;
declare class TangleExecutionKeyError extends Error {
    readonly code: TangleExecutionKeyErrorCode;
    readonly status: number;
    constructor(code: TangleExecutionKeyErrorCode, message: string, status: number);
}
declare function isTangleExecutionKeyError(error: unknown): error is TangleExecutionKeyError;
declare function resolveTangleExecutionEnvironment(env?: Record<string, string | undefined>): TangleExecutionEnvironment;
/**
 * Shared policy for agent products that bill through the Tangle Platform.
 *
 * Local development defaults billing enforcement off so apps can use a local
 * `TANGLE_API_KEY` without requiring a browser-linked platform account. Any
 * non-development environment defaults enforcement on. Apps may pass their own
 * override flag (`FOO_BILLING_ENFORCEMENT`) while new apps can use the shared
 * `TANGLE_BILLING_ENFORCEMENT`.
 */
declare function isTangleBillingEnforcementDisabled(opts?: TangleBillingEnforcementOptions): boolean;
declare function tangleExecutionKeyHttpError(error: unknown): TangleExecutionKeyHttpError | null;
/**
 * Shared dev-aware Tangle key resolution. Local development may use a server
 * `TANGLE_API_KEY`; otherwise the caller's linked platform key is used. Returns
 * null when neither resolves, so each caller can throw its own domain error
 * (e.g. model-execution 503/401 vs hub `tangle_link_required` 412).
 */
declare function resolveTangleDevOrUserKey(opts: ResolveTangleDevOrUserKeyOptions): Promise<ResolvedTangleExecutionKey | null>;
/**
 * Resolve the user-facing Tangle API key for model execution.
 *
 * Local development may use a server env key so apps remain easy to run.
 * Deployed contexts must use the caller's linked platform key; this keeps
 * model execution, billing, and account ownership aligned across products.
 */
declare function resolveUserTangleExecutionKey(opts: ResolveUserTangleExecutionKeyOptions): Promise<ResolvedTangleExecutionKey>;
declare function resolveUserTangleExecutionKeyForUser<UserId = string>(opts: ResolveUserTangleExecutionKeyForUserOptions<UserId>): Promise<ResolvedTangleExecutionKey>;
/**
 * Build an OpenAI-compatible Tangle Router model config from an already
 * resolved execution key. This intentionally does not read TANGLE_API_KEY.
 */
declare function createTangleRouterModelConfig(opts: CreateTangleRouterModelConfigOptions): TangleModelConfig;
/**
 * Resolve the model config from env. DEFAULT path (`MODEL_PROVIDER` unset or
 * `openai-compat`/`tangle-router`/`tcloud`): the Tangle Router, authenticated
 * with `TANGLE_API_KEY`, model from `MODEL_NAME`. BYOK path
 * (`MODEL_PROVIDER=anthropic`): direct Anthropic with `ANTHROPIC_API_KEY` +
 * `ANTHROPIC_BASE_URL`. Throws (fail-loud) on a missing required var so a
 * misconfigured deploy fails at boot, not mid-turn.
 */
declare function resolveTangleModelConfig(opts?: ResolveModelOptions): TangleModelConfig;

export { type CreateTangleRouterModelConfigOptions as C, DEFAULT_TANGLE_BILLING_ENFORCEMENT_ENV_VAR as D, type ResolveModelOptions as R, type TangleBillingEnforcementOptions as T, DEFAULT_TANGLE_ROUTER_BASE_URL as a, type ResolveTangleDevOrUserKeyOptions as b, type ResolveUserTangleExecutionKeyForUserOptions as c, type ResolveUserTangleExecutionKeyOptions as d, type ResolvedTangleExecutionKey as e, type TangleExecutionEnvironment as f, TangleExecutionKeyError as g, type TangleExecutionKeyErrorCode as h, type TangleExecutionKeyHttpError as i, type TangleExecutionKeySource as j, type TangleModelConfig as k, createTangleRouterModelConfig as l, isTangleBillingEnforcementDisabled as m, isTangleExecutionKeyError as n, resolveTangleExecutionEnvironment as o, resolveTangleModelConfig as p, resolveUserTangleExecutionKey as q, resolveTangleDevOrUserKey as r, resolveUserTangleExecutionKeyForUser as s, tangleExecutionKeyHttpError as t, trimOrNull as u };
