import type { EnvVarInput, McpServerUsageInput, ResourceRef } from "@stigmer/sdk";
export type { McpServerSetupEntry, McpServerSetupPhase, McpServerSetupState, } from "./mcpServerSetupReducer";
export { toServerKey } from "./mcpServerSetupReducer";
/** Options for {@link UseMcpServerSetupReturn.submitEnvVars}. */
export interface SubmitMcpEnvVarsOptions {
    /**
     * When `true` (default), the provided values are saved to the user's
     * personal environment. Subsequent sessions using the same MCP server
     * will reuse these credentials.
     *
     * When `false`, the values are collected as `pendingRuntimeEnv` for
     * this session only — no data is persisted and no network calls are
     * made. The runtime env is passed to execution creation.
     *
     * @default true
     */
    readonly saveForFuture?: boolean;
}
/** Return value of {@link useMcpServerSetup}. */
export interface UseMcpServerSetupReturn {
    /**
     * Per-server setup state, keyed by `"org/slug"` (see {@link toServerKey}).
     *
     * Each entry tracks an individual MCP server through the setup
     * lifecycle: `loading → needsSetup → submitting → ready` (or
     * `loading → ready` when no credentials are required).
     */
    readonly entries: Readonly<Record<string, import("./mcpServerSetupReducer").McpServerSetupEntry>>;
    /**
     * Add an MCP server to the setup flow.
     *
     * Fetches the full server resource, checks `env` declarations against
     * the personal environment, and resolves the entry to either `ready`
     * (no credentials needed or all present) or `needsSetup` (missing
     * variables). Also extracts discovered tools and approval policies
     * for the tool selector.
     *
     * If the server is already in entries, its entry is reset to
     * `loading` and re-evaluated.
     */
    readonly addServer: (ref: ResourceRef) => Promise<void>;
    /**
     * Remove an MCP server from the setup flow.
     *
     * Removes the entry from state. Safe to call for servers not in
     * entries (no-op).
     */
    readonly removeServer: (ref: ResourceRef) => void;
    /**
     * Complete credential collection for a server in `needsSetup` status.
     *
     * Behavior depends on `options.saveForFuture`:
     * - `true` (default) — Saves values to the personal environment via
     *   `addVariables`. The server transitions to `ready`.
     * - `false` — Accumulates values into {@link pendingRuntimeEnv}
     *   without API calls. The server transitions to `ready` immediately.
     *
     * Must only be called when the entry is in `needsSetup` status.
     */
    readonly submitEnvVars: (ref: ResourceRef, values: Record<string, EnvVarInput>, options?: SubmitMcpEnvVarsOptions) => Promise<void>;
    /**
     * Update the enabled tools for a server in `ready` status.
     *
     * Dispatches directly to the reducer. Safe to call frequently
     * (e.g., from tool selector checkboxes).
     */
    readonly setEnabledTools: (ref: ResourceRef, tools: string[]) => void;
    /** Clear the error on a specific server entry without changing its phase. */
    readonly clearError: (ref: ResourceRef) => void;
    /** Reset all entries and pending runtime env to initial state. */
    readonly reset: () => void;
    /**
     * `true` when every selected server is in `ready` status, or when
     * no servers are selected. `false` during `loading`, `needsSetup`,
     * or `submitting` for any entry.
     *
     * Use this for submission blocking in the session composer.
     */
    readonly allReady: boolean;
    /**
     * Count of entries in `needsSetup` status — servers that require
     * user-provided credentials before the session can be created.
     */
    readonly needsSetupCount: number;
    /**
     * Accumulated one-time env vars from servers whose credentials were
     * submitted with `saveForFuture: false`.
     *
     * Consumed imperatively at session creation time and merged into
     * the execution's `runtimeEnv`. Cleared on {@link reset}.
     */
    readonly pendingRuntimeEnv: Record<string, EnvVarInput>;
    /**
     * Ready servers as `McpServerUsageInput[]` for session creation.
     *
     * Derived from entries: only `ready` entries are included. When a
     * server's `enabledTools` matches all discovered tools, `enabledTools`
     * is omitted (API convention for "all tools").
     */
    readonly usageInputs: McpServerUsageInput[];
}
/**
 * Layer 2 behavior hook that orchestrates the setup flow for multiple
 * MCP servers selected in the {@link McpServerPicker}.
 *
 * When a user toggles an MCP server ON, this hook fetches the server's
 * full resource, checks its `env` declarations against the personal
 * environment (via {@link diffEnv}), and determines whether credentials are
 * needed. It also extracts discovered tools and approval policies for
 * the tool selector UI.
 *
 * The hook supports two credential delivery paths via the `saveForFuture`
 * option on {@link submitEnvVars}:
 * - **Saved** — secrets are persisted to the personal environment for
 *   reuse across sessions.
 * - **One-time** — secrets are collected as `pendingRuntimeEnv` for a
 *   single execution, with no data persisted.
 *
 * State is managed by `useReducer(mcpServerSetupReducer)` — a per-server
 * state machine with four phases:
 * `loading → needsSetup → submitting → ready`.
 *
 * Composes {@link usePersonalEnvironment} for credential persistence and
 * the Stigmer client for MCP server queries.
 *
 * Mirrors the architecture of {@link useAgentSetup} but adapted for
 * multi-server orchestration (N independent entries vs. single agent).
 *
 * Pass `null` as `org` to disable all operations (stable no-op).
 *
 * @param org - Organization slug. Pass `null` to disable.
 * @param poolKeys - Optional set of env-var keys already available
 *   from the session env pool (manual secrets, one-time env vars from
 *   other components). When provided, servers whose `env` keys
 *   are fully covered by `poolKeys` + personal env auto-resolve to
 *   `ready` without prompting. Reactive — when `poolKeys` changes,
 *   `needsSetup` entries are re-evaluated.
 *
 * @example
 * ```tsx
 * const {
 *   entries,
 *   addServer,
 *   submitEnvVars,
 *   setEnabledTools,
 *   allReady,
 *   usageInputs,
 * } = useMcpServerSetup("acme", pool.availableKeys);
 *
 * // When user toggles a server ON in the picker:
 * await addServer({ org: "acme", slug: "github", kind: ApiResourceKind.mcp_server });
 *
 * // If the entry resolves to "needsSetup":
 * await submitEnvVars(ref, { GITHUB_TOKEN: { value: "ghp_...", isSecret: true } });
 *
 * // Customize tools for a ready server:
 * setEnabledTools(ref, ["create_issue", "list_issues"]);
 *
 * // At session creation:
 * const session = await createSession({ mcpServerUsages: usageInputs });
 * ```
 */
export declare function useMcpServerSetup(org: string | null, poolKeys?: Set<string>): UseMcpServerSetupReturn;
//# sourceMappingURL=useMcpServerSetup.d.ts.map