/**
 * Host execution policy extraction + iteration-metadata stamping.
 *
 * Pure — derived from a hostConfig snapshot. Used by both the live chat
 * runtime (via `prepareChatV2`'s `respectToolVisibility` gate) and the eval
 * runtime (via `applyVisibilityPolicyAndCountSignals` + `buildHostIterationMetadata`).
 *
 * `extractHostExecutionPolicy` accepts the dual progressiveToolDiscovery
 * shape because HostConfigV2 stores it as a plain boolean while chat-v2
 * wire payloads wrap it as `{ enabled, threshold }`. Both flow through here.
 */

type HostExecutionPolicy = {
    requireToolApproval: boolean;
    /** undefined = spec default (filter app-only tools from model). false = opt out. */
    respectToolVisibility: boolean | undefined;
    progressiveDiscoveryEnabled: boolean;
    hostStyle: string | undefined;
    namedHostId: string | undefined;
};
declare function extractHostExecutionPolicy(hostConfig: Record<string, unknown> | null, namedHostId?: string): HostExecutionPolicy;
/**
 * Builds the scalar host-policy metadata fields to merge into
 * `EvalIteration.metadata`. Only includes keys with meaningful values to
 * avoid inflating rows with zero-valued noise.
 *
 * The `approvalsWouldRequire` count is the number of tool calls that
 * actually occurred in this iteration and would have required approval
 * under the host's `requireToolApproval` policy. Evals do not block on
 * approval prompts — this is a "would prompt N times" signal only.
 */
/**
 * Snapshot-only host metadata for SDK eval reports. Subset of
 * {@link buildHostIterationMetadata} that needs no per-iteration counters
 * (signals / approvalsWouldRequire / injectOpenAiCompat) and can be
 * derived from `Host.toJSON()` alone.
 *
 * Used by SDK eval result mapping to stamp executor-derived host context
 * onto each iteration's metadata. Per-iteration signal counts (tools
 * exposed / dropped, approvals required) are added by callers that have
 * runtime access (inspector eval runner, future `HostRuntime` plumbing).
 */
declare function buildHostSnapshotMetadata(hostConfig: Record<string, unknown> | null): Record<string, string | number | boolean>;
declare function buildHostIterationMetadata(policy: HostExecutionPolicy, signals: ToolExposureSignals, approvalsWouldRequire: number, injectOpenAiCompat: boolean): Record<string, string | number | boolean>;

/**
 * SEP-1865 host visibility filter and exposure-signal counting.
 *
 * Structurally pure — depends only on `isAppOnlyTool` (a pure leaf) and the
 * `HostExecutionPolicy` type. Does NOT import `MCPClientManager` or any AI
 * SDK code, so this module can ship from `@mcpjam/sdk/host-config/internal`
 * (which the inspector client imports as source via Vite alias) without
 * dragging Node-heavy deps into the browser bundle.
 *
 * The `ToolMetadataSource` duck-type below is satisfied by
 * `MCPClientManager` (its `getAllToolsMetadata` signature matches), so
 * inspector callers pass their existing manager unchanged.
 */

/**
 * Structural type for anything that can supply per-server tool metadata.
 * `MCPClientManager.getAllToolsMetadata(serverId)` satisfies this.
 */
interface ToolMetadataSource {
    getAllToolsMetadata(serverId: string): Record<string, Record<string, unknown>>;
}
type ToolExposureSignals = {
    toolsTotalBefore: number;
    toolsExposed: number;
    toolsDroppedVisibility: number;
};
/**
 * Mutates `tools` in place, removing entries whose source MCP tool declares
 * SEP-1865 `_meta.ui.visibility` as exactly `["app"]`.
 *
 * Per SEP-1865, the visibility array defaults to `["model", "app"]` so a tool
 * with no visibility metadata is treated as visible to both.
 *
 * `tools` is expected to be the tool-set shape produced by
 * `MCPClientManager.getToolsForAiSdk(...)` — each entry carries a `_serverId`
 * string used to look up its source metadata. Tools without `_serverId` are
 * left untouched (they did not originate from an MCP server).
 */
declare function filterAppOnlyTools(tools: Record<string, unknown>, source: ToolMetadataSource): void;
/**
 * Applies the host visibility policy to `tools` (mutates in place, same as
 * `prepareChatV2`) and returns tool exposure counts for iteration metadata
 * stamping.
 *
 * Call this AFTER loading the full tool set so `toolsTotalBefore` is accurate.
 */
declare function applyVisibilityPolicyAndCountSignals(tools: Record<string, unknown>, source: ToolMetadataSource, policy: HostExecutionPolicy): ToolExposureSignals;

export { type HostExecutionPolicy as H, type ToolExposureSignals as T, type ToolMetadataSource as a, applyVisibilityPolicyAndCountSignals as b, buildHostIterationMetadata as c, buildHostSnapshotMetadata as d, extractHostExecutionPolicy as e, filterAppOnlyTools as f };
