import { b as HostConfigConnectionDefaults, c as HostConfigMcpProfileV1, e as HostStyleId, f as ServerId } from '../types-DCvvhNDX.js';
export { d as CspDomainSet, M as McpAppsCapabilities, O as OpenAiAppsCapabilities } from '../types-DCvvhNDX.js';
import { M as McpProtocolVersion } from '../mcp-protocol-version-cf74324S.js';

/**
 * `@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>;
}

/**
 * `Host` — the public, developer-facing host configuration builder.
 *
 * A thin, MCP-vocabulary facade over the internal canonicalizer. Configure a
 * host by mutating its public properties directly, then serialize:
 *
 * ```ts
 * import { Host } from "@mcpjam/sdk";
 *
 * const host = new Host({ style: "mcpjam", model: "anthropic/claude-sonnet-4-6" });
 * host.mcp.protocolVersion = "2025-11-25";
 * host.mcp.initialize = { clientInfo: { name: "my-app", version: "1.0" } };
 * host.mcp.apps = { sandbox: { csp: { mode: "declared" } } };
 * host.addServer("srv_abc");
 *
 * const json = host.toJSON(); // normalized public shape (clean vocab)
 * ```
 *
 * Public fields are mutable and use MCP vocabulary — `mcp`, `servers`,
 * `clientCapabilities`, … The storage-row vocabulary (`mcpProfile`,
 * `schemaVersion`, the canonicalizer) never crosses this boundary: input is
 * snapshotted at `toJSON()` time and projected through the canonicalizer to
 * the public shape.
 *
 * Convenience methods (`addServer`, `setServerOverride`, `clearMcp`, …) are
 * provided where they read more naturally than raw property mutation and
 * where enforcing invariants (e.g. server-id dedup) is helpful. All methods
 * return `this` for chaining.
 *
 * Content-addressed storage (canonical-form hashing for backend dedupe) is a
 * first-party concern handled at the SDK↔backend boundary via
 * `@mcpjam/sdk/host-config/internal`. Developers building hosts never call it.
 */

declare class Host {
    /**
     * Host style id (e.g. "mcpjam", "claude", "chatgpt"). **Required** at
     * `toJSON()` time — there is no SDK default, so an external agent author
     * who forgets to set it gets a loud error rather than silently inheriting
     * MCPJam product chrome on a Claude-style flow.
     *
     * Note: `style` is a **product knob**, not part of SEP-1865 / the MCP base
     * spec. It selects which host-style preset (chrome, default capabilities,
     * compat-runtime shims) the inspector applies.
     */
    style: HostStyleId;
    /**
     * LLM model id, e.g. `"anthropic/claude-sonnet-4-6"`. **Required** at
     * `toJSON()` time — no SDK default.
     */
    model: string;
    systemPrompt: string;
    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
     * (filter); explicit `false` → show every tool (for hosts that don't
     * implement visibility).
     */
    respectToolVisibility?: boolean;
    /** Required servers. Mutable — `addServer`/`removeServer` are sugar. */
    servers: ServerId[];
    /** Optional (auto-connect-if-available) servers. */
    optionalServers: ServerId[];
    connectionDefaults: HostConnectionDefaults;
    /**
     * MCP `ClientCapabilities` the inspector advertises in `initialize`.
     * Untyped (`Record<string, unknown>`) so future spec additions and host
     * extensions (SEP-1724) can be added without an SDK release. The MCP Apps
     * extension lives at `clientCapabilities.extensions["io.modelcontextprotocol/ui"]`.
     */
    clientCapabilities: Record<string, unknown>;
    /** SEP-1865 `HostContext` (theme, displayMode, …) advertised via `ui/initialize`. */
    hostContext: Record<string, unknown>;
    /**
     * Override the SEP-1865 MCP-Apps `hostCapabilities` blob the inspector
     * advertises in `ui/initialize`.
     *
     * Semantics: `undefined` = "use the host-style preset" (the inspector
     * picks a sensible default per style). `{}` = "advertise nothing"
     * (distinct from `undefined`; hashes distinctly). Use this to *cap* what
     * a host advertises — e.g. force `serverTools: undefined` to block widget
     * → server tool proxying for a hardened host.
     */
    hostCapabilitiesOverride?: Record<string, unknown>;
    /** Override the chat-UI surface (logo, fonts, …). `undefined` vs `{}` semantics match `hostCapabilitiesOverride`. */
    chatUiOverride?: Record<string, unknown>;
    /**
     * The host's MCP settings.
     *
     * Spec-aligned shape (`protocolVersion`, `initialize`, `apps`, `extensions`)
     * is **mutable in place** — assign or mutate any leaf directly:
     *
     * ```ts
     * host.mcp.protocolVersion = "2025-11-25";
     * host.mcp.initialize = { clientInfo: { name: "my-app", version: "1.0" } };
     * host.mcp.apps = { sandbox: { csp: { mode: "declared" } } };
     * ```
     *
     * The SEP-1865 sandbox knobs at `mcp.apps.sandbox.csp` / `.permissions` are
     * **host enforcement caps**, not capability grants to the widget. The
     * widget *declares* what it needs via its resource metadata; the host MAY
     * further restrict but MUST NOT loosen (`restrictTo` intersects the
     * declared set; `mode: "declared"` honors the declared set as-is).
     *
     * A "freshly constructed, untouched" `host.mcp` (all fields undefined)
     * collapses to no `mcpProfile` in canonical, so it hashes identically to
     * `host.mcp = undefined`.
     */
    mcp: HostMcp;
    /** Per-server connection overrides keyed by server id. */
    serverOverrides: Record<string, HostServerOverride>;
    constructor(init?: HostInit);
    setStyle(style: HostStyleId): this;
    setModel(model: string): this;
    setSystemPrompt(systemPrompt: string): this;
    setTemperature(temperature: number): this;
    setRequireToolApproval(require?: boolean): this;
    setProgressiveToolDiscovery(enabled: boolean): this;
    setRespectToolVisibility(respect: boolean): this;
    /** Append a required server; no-op if `id` is already in the list. */
    addServer(id: ServerId): this;
    /** Remove a required server; no-op if absent. */
    removeServer(id: ServerId): this;
    /** Append an optional (auto-connect-if-available) server; deduped. */
    addOptionalServer(id: ServerId): this;
    removeOptionalServer(id: ServerId): this;
    /**
     * Replace the per-server override for `id`. Passing an empty `{}` is
     * preserved here but stripped from the canonical output (an override with
     * no fields adds no information).
     */
    setServerOverride(id: ServerId, override: HostServerOverride): this;
    removeServerOverride(id: ServerId): this;
    /**
     * Reset `mcp` to an empty object — equivalent to "use SDK defaults / no
     * host-level MCP profile." Collapses to no `mcpProfile` in canonical.
     */
    clearMcp(): this;
    /**
     * Throw a clear error if required fields (`style`, `model`) are still empty.
     * Called from `toJSON()` so the failure lands at the moment of use, not
     * deep inside the canonicalizer with a less obvious message.
     */
    private requireConfigured;
    /**
     * Build the internal canonicalizer input from the current public-shape
     * properties. Snapshotted (`structuredClone`) so the canonicalizer sees a
     * stable copy even if the caller is mid-mutation.
     */
    private toInternalInput;
    /**
     * Serialize to the normalized public `HostJson` shape (clean MCP
     * vocabulary — `mcp`, `servers`, `style`; no `mcpProfile`/`schemaVersion`).
     * Normalized and round-trippable: `new Host(host.toJSON())` reproduces an
     * equivalent host. Throws if the configuration is invalid (e.g.
     * `style`/`model` not set, a non-finite temperature, or a malformed MCP
     * profile).
     */
    toJSON(): HostJson;
}

export { Host, type HostConnectionDefaults, type HostInit, type HostJson, type HostMcp, type HostServerOverride, HostStyleId, McpProtocolVersion, ServerId };
