import { M as McpProtocolVersion } from './mcp-protocol-version-cf74324S.js';

/**
 * HostConfig v2 — portable type surface.
 *
 * SOURCE OF TRUTH. This module is the canonical home of the host-config
 * shape, canonicalizer, and hash. It is hand-mirrored (NOT imported) by the
 * Convex backend in `convex/lib/hostConfigV2.ts`, because Convex's isolate
 * bundling forbids importing `@mcpjam/sdk` (Node-only deps). Drift between
 * the two implementations is caught by a golden-vector parity test that runs
 * identical inputs through both canonicalizers and asserts byte-identical
 * canonical JSON + sha256 (see `sdk/tests/host-config-parity.test.ts` and
 * `mcpjam-backend/tests/convex/hostConfigV2Parity.test.ts`). When you change
 * a type or canonicalization rule here, update the backend mirror in the
 * same change set and regenerate both fixture copies.
 *
 * Pure + browser-safe: no `convex/values`, no `ctx.db`, no Node-only APIs.
 */

/**
 * Identifier of a host-config host style. Storage is a free-form string —
 * the canonical "what's a registered host" check lives in the inspector
 * client's `lib/host-styles` registry, not here. Treated as an opaque
 * pointer into that registry so users can register custom hosts (BYO)
 * without a backend deploy.
 */
type HostConfigStyle = string;
/**
 * Public alias of {@link HostConfigStyle}. **Intentionally `string`**, not a
 * closed union — the host registry is extensible (users can register custom
 * host styles via the client's `lib/host-styles` registry without an SDK or
 * backend deploy). Don't "tighten" this to `'mcpjam' | 'claude' | 'chatgpt'`;
 * it would break BYO hosts.
 */
type HostStyleId = HostConfigStyle;
/**
 * Opaque MCP server identifier. The backend brands this as `Id<'servers'>`;
 * the portable core treats it as a plain string because the canonicalizer
 * only sorts/dedupes serverIds — it never dereferences them.
 */
type ServerId = string;
declare const HOST_CONFIG_SCHEMA_VERSION_V2 = 2;
/**
 * Permissions Policy feature tokens corresponding to the four
 * SEP-1865 spec permissions. These are the KEBAB-CASE browser tokens
 * (as they appear in iframe `allow=` attributes), NOT the camelCase
 * mcpProfile.permissions.allow keys. The canonicalizer uses this list to
 * drop these features from `allowFeatures` (they belong in
 * `permissions.allow`).
 *
 * Naming gap (intentional): `permissions.allow.clipboardWrite` (camel,
 * spec field name) ↔ `allowFeatures["clipboard-write"]` (kebab,
 * Permissions Policy token). Do NOT normalize casing on either side.
 */
declare const SEP_1865_PERMISSION_FEATURES: readonly ["camera", "microphone", "geolocation", "clipboard-write"];
type HostConfigConnectionDefaults = {
    headers: Record<string, string>;
    requestTimeout: number;
};
type CspDomainSet = {
    connectDomains?: string[];
    resourceDomains?: string[];
    frameDomains?: string[];
    baseUriDomains?: string[];
};
type HostConfigMcpProfileV1 = {
    profileVersion: 1;
    mcpProtocolVersion?: McpProtocolVersion;
    initialize?: {
        supportedProtocolVersions?: string[];
        clientInfo?: Record<string, unknown>;
    };
    apps?: {
        sandbox?: {
            csp?: {
                mode?: "host-default" | "declared" | "relaxed";
                restrictTo?: CspDomainSet;
                cspDirectives?: Record<string, string[]>;
                extensions?: Record<string, unknown>;
            };
            permissions?: {
                mode?: "resource-declared" | "deny-all" | "custom";
                allow?: Record<string, boolean>;
                extensions?: Record<string, unknown>;
            };
            sandboxAttrs?: string[];
            allowFeatures?: Record<string, string>;
        };
        uiInitialize?: {
            hostInfo?: Record<string, unknown>;
        };
        compatRuntime?: {
            openaiApps?: boolean;
            openaiAppsOverrides?: OpenAiAppsCapabilities;
        };
        mcpAppsOverrides?: McpAppsCapabilities;
    };
    extensions?: Record<string, unknown>;
};
type OpenAiAppsCapabilities = {
    callTool?: boolean;
    sendFollowUpMessage?: boolean;
    setWidgetState?: boolean;
    requestDisplayMode?: "all" | "fullscreen-only" | "none";
    notifyIntrinsicHeight?: boolean;
    openExternal?: boolean;
    setOpenInAppUrl?: boolean;
    requestModal?: boolean;
    uploadFile?: boolean;
    selectFiles?: boolean;
    getFileDownloadUrl?: boolean;
    requestCheckout?: boolean;
    requestClose?: boolean;
};
type McpAppsCapabilities = {
    availableDisplayModes?: ("inline" | "fullscreen" | "pip")[];
    toolInputPartial?: boolean;
    toolCancelled?: boolean;
    hostContextChanged?: boolean;
    resourceTeardown?: boolean;
    toolInfo?: boolean;
    openLinks?: boolean;
    serverTools?: boolean;
    serverResources?: boolean;
    logging?: boolean;
    updateModelContext?: boolean;
    message?: boolean;
    sandboxPermissions?: boolean;
    cspFrameDomains?: boolean;
    cspBaseUriDomains?: boolean;
    resourcePrefersBorder?: boolean;
    downloadFile?: boolean;
    requestTeardown?: boolean;
    widgetDisplayModeRequests?: "accept" | "user-initiated-only" | "decline";
};
type HostConfigInputV2 = {
    hostStyle: HostConfigStyle;
    modelId: string;
    systemPrompt: string;
    temperature: number;
    requireToolApproval: boolean;
    progressiveToolDiscovery?: boolean;
    respectToolVisibility?: boolean;
    serverIds?: Array<ServerId>;
    optionalServerIds?: Array<ServerId>;
    connectionDefaults: HostConfigConnectionDefaults;
    clientCapabilities: Record<string, unknown>;
    hostContext: Record<string, unknown>;
    hostCapabilitiesOverride?: Record<string, unknown>;
    chatUiOverride?: Record<string, unknown>;
    mcpProfile?: HostConfigMcpProfileV1;
    serverConnectionOverrides?: Record<string, {
        headersOverride?: Record<string, string>;
        requestTimeoutOverride?: number;
        mcpProtocolVersionOverride?: McpProtocolVersion;
    }>;
};
type CanonicalHostConfigV2 = {
    schemaVersion: typeof HOST_CONFIG_SCHEMA_VERSION_V2;
    hostStyle: HostConfigStyle;
    modelId: string;
    systemPrompt: string;
    temperature: number;
    requireToolApproval: boolean;
    progressiveToolDiscovery?: boolean;
    respectToolVisibility?: boolean;
    serverIds: Array<ServerId>;
    optionalServerIds: Array<ServerId>;
    connectionDefaults: HostConfigConnectionDefaults;
    clientCapabilities: Record<string, unknown>;
    hostContext: Record<string, unknown>;
    hostCapabilitiesOverride?: Record<string, unknown>;
    chatUiOverride?: Record<string, unknown>;
    mcpProfile?: HostConfigMcpProfileV1;
    serverConnectionOverrides?: Record<string, {
        headersOverride?: Record<string, string>;
        requestTimeoutOverride?: number;
        mcpProtocolVersionOverride?: McpProtocolVersion;
    }>;
};

/**
 * `@mcpjam/sdk/host-config` — PUBLIC type surface.
 *
 * MCP-protocol vocabulary for the developer-facing `Host` API. These names are
 * what an external agent author sees; the internal storage-row vocabulary
 * (`HostConfigInputV2`, `mcpProfile`, schema versions) stays in `./types.ts`
 * and `./canonicalize.ts` and is reached only through `Host`.
 *
 * Wire compatibility (option b): the internal canonical shape keeps the
 * on-disk field name `mcpProfile`, but `HostJson` deliberately exposes public
 * vocabulary (`mcp`). A small mapper in `./host.ts` bridges the two so the
 * storage-row canonical JSON + hash stay stable.
 */

/** Per-host connection defaults (headers + request timeout in ms). */
type HostConnectionDefaults = HostConfigConnectionDefaults;
/**
 * A host's MCP settings — the host-facing rename of the internal `mcpProfile`.
 * Spec-aligned vocabulary: `protocolVersion`, `initialize` (clientInfo,
 * supported versions), and `apps` (sandbox, ui/initialize hostInfo, compat
 * runtime, MCP-Apps overrides). The internal schema-version marker
 * (`profileVersion`) is supplied by the SDK; authors never set it.
 */
type HostMcp = Omit<HostConfigMcpProfileV1, "profileVersion" | "mcpProtocolVersion"> & {
    /** Host-default pinned MCP protocol version (e.g. "2025-11-25"). */
    protocolVersion?: McpProtocolVersion;
};
/**
 * The normalized host configuration returned by `Host.toJSON()`.
 *
 * Pure public vocabulary — no implementation names leak here: `mcp` (not
 * `mcpProfile`), `style`/`model`/`servers`, and no `schemaVersion`/
 * `profileVersion` markers. It is normalized (sorted, deduped, derived) and
 * round-trips: `new Host(host.toJSON())` reproduces an equivalent host. The
 * internal content-addressed wire form (which the backend stores) is
 * deliberately not exposed.
 */
interface HostJson {
    style: HostStyleId;
    model: string;
    systemPrompt: string;
    temperature: number;
    requireToolApproval: boolean;
    progressiveToolDiscovery?: boolean;
    respectToolVisibility?: boolean;
    servers: ServerId[];
    optionalServers: ServerId[];
    connectionDefaults: HostConnectionDefaults;
    clientCapabilities: Record<string, unknown>;
    hostContext: Record<string, unknown>;
    hostCapabilitiesOverride?: Record<string, unknown>;
    chatUiOverride?: Record<string, unknown>;
    mcp?: HostMcp;
    serverOverrides?: Record<string, HostServerOverride>;
}
/** Per-server connection override (host-facing field names). */
interface HostServerOverride {
    headers?: Record<string, string>;
    requestTimeout?: number;
    protocolVersion?: McpProtocolVersion;
}
/**
 * Optional initial configuration for `new Host(init?)`. Every field is
 * type-optional so the imperative pattern works (`new Host(); host.style =
 * "..."; host.model = "..."`), but `style` and `model` are **required at
 * use** — `toJSON()` throws if either is missing. The SDK deliberately ships
 * no default `style` (so an external author isn't silently opted into MCPJam
 * product chrome) and no default `model`. After construction every field is
 * also accessible as a mutable property on the `Host` instance (e.g.
 * `host.mcp.protocolVersion = "..."`, `host.servers.push(...)`).
 */
interface HostInit {
    /**
     * Host style id (e.g. "mcpjam", "claude", "chatgpt"). Required at
     * `toJSON()`; no SDK default. **Product knob, not SEP-1865** — selects
     * which host-style preset (chrome, capability defaults, compat-runtime
     * shims) the inspector applies.
     */
    style?: HostStyleId;
    /** LLM model id (e.g. "anthropic/claude-sonnet-4-6"). Required at `toJSON()`; no SDK default. */
    model?: string;
    systemPrompt?: string;
    /** Sampling temperature. Default: 0.7. */
    temperature?: number;
    requireToolApproval?: boolean;
    /** Opt into progressive MCP tool discovery (search/load meta-tools). */
    progressiveToolDiscovery?: boolean;
    /** SEP-1865 `_meta.ui.visibility` filtering. Undefined → spec default. */
    respectToolVisibility?: boolean;
    /** Required servers this host connects to. */
    servers?: ServerId[];
    /** Optional (auto-connect-if-available) servers. */
    optionalServers?: ServerId[];
    connectionDefaults?: Partial<HostConnectionDefaults>;
    clientCapabilities?: Record<string, unknown>;
    hostContext?: Record<string, unknown>;
    /**
     * Override the SEP-1865 MCP-Apps `hostCapabilities` blob advertised in
     * `ui/initialize`. `undefined` = use the host-style preset; `{}` =
     * advertise nothing (hashes distinctly from `undefined`). Used to *cap*
     * what a host advertises (e.g. drop `serverTools` to block widget→server
     * tool proxying), never to grant capabilities the preset doesn't already
     * support.
     */
    hostCapabilitiesOverride?: Record<string, unknown>;
    /** Override the chat-UI surface (logo, fonts, …). */
    chatUiOverride?: Record<string, unknown>;
    /** The host's MCP settings. */
    mcp?: HostMcp;
    /** Per-server connection overrides, keyed by server id. */
    serverOverrides?: Record<string, HostServerOverride>;
}

export { type CspDomainSet as C, type HostConnectionDefaults as H, type McpAppsCapabilities as M, type OpenAiAppsCapabilities as O, type ServerId as S, type HostInit as a, type HostJson as b, type HostMcp as c, type HostServerOverride as d, type HostStyleId as e, type HostConfigInputV2 as f, type CanonicalHostConfigV2 as g, HOST_CONFIG_SCHEMA_VERSION_V2 as h, type HostConfigConnectionDefaults as i, type HostConfigMcpProfileV1 as j, SEP_1865_PERMISSION_FEATURES as k };
