import { type McpServerUsageInput, type ResourceRef } from "@stigmer/sdk";
import type { AgentResolution } from "../agent/index.js";
import { type HarnessOption } from "../models/harness.js";
import { type UseWorkspaceEntriesReturn } from "../workspace/index.js";
import { type UseSessionVariablesReturn } from "../execution/useSessionVariables.js";
import type { SessionComposerSubmitContext } from "../composer/index.js";
import type { ExecutionTargetOption } from "./execution-target.js";
import { type RuntimeEnvProvider } from "./runtime-env.js";
/** Options for {@link useNewSessionFlow}. */
export interface UseNewSessionFlowOptions {
    /** Organization slug. Required for session and execution creation. */
    readonly org: string;
    /**
     * Called after a session and its first execution are created successfully.
     * The consumer is responsible for navigation (e.g. `router.push`).
     */
    readonly onSessionCreated: (sessionId: string) => void;
    /**
     * Called when an error occurs during session creation.
     * The consumer can use this for toast notifications or other UI feedback.
     * If not provided, errors are still available via {@link UseNewSessionFlowReturn.submitError}.
     */
    readonly onError?: (message: string) => void;
    /**
     * Where session activities should execute.
     *
     * @deprecated Prefer setting `executionTarget` on `StigmerProvider`
     * instead. The provider-level value is inherited by all hooks in the
     * tree automatically. This per-hook option is honored as an override
     * for backward compatibility but will be removed in a future major.
     *
     * When omitted, the hook reads from `StigmerProvider`'s
     * `executionTarget` prop via context. If that is also unset, the
     * server decides based on deployment context.
     */
    readonly executionTarget?: ExecutionTargetOption;
    /**
     * Supplies host-app environment variables for the session's first
     * execution. Evaluated once per submission, at submit time, so
     * short-lived credentials stay fresh; evaluated **before** the session
     * is created so a credential failure never strands an empty session.
     *
     * Host values win over composer-collected env on key collisions. If
     * the provider throws, the submission fails and the error surfaces
     * via {@link UseNewSessionFlowReturn.submitError} / {@link onError}.
     * See {@link RuntimeEnvProvider}.
     */
    readonly getRuntimeEnv?: RuntimeEnvProvider;
    /**
     * Harness pre-selected for new sessions when the user has not made an
     * explicit choice yet (e.g. an embedder whose agents primarily run
     * coding tasks defaults to `"cursor"`).
     *
     * Read once on mount. The user's own selection — persisted to
     * localStorage on explicit change — always takes precedence on
     * subsequent visits.
     *
     * @default DEFAULT_HARNESS ("native")
     */
    readonly defaultHarness?: HarnessOption;
}
/** Return value of {@link useNewSessionFlow}. */
export interface UseNewSessionFlowReturn {
    /** Currently selected harness (persisted to localStorage). */
    readonly harness: HarnessOption;
    /** Switch the harness. Resets the model if invalid for the new harness. */
    readonly setHarness: (harness: HarnessOption) => void;
    /** Currently selected model ID (persisted per-harness to localStorage). */
    readonly modelId: string | undefined;
    /** Update the selected model. Automatically persists to localStorage. */
    readonly setModelId: (id: string) => void;
    /** Currently selected agent reference, or `null` for the default agent. */
    readonly agentRef: ResourceRef | null;
    /** Update the selected agent reference. */
    readonly setAgentRef: (ref: ResourceRef | null) => void;
    /** Current agent resolution state (saved instance vs direct reference). */
    readonly resolution: AgentResolution | null;
    /** Update the agent resolution. */
    readonly setResolution: (r: AgentResolution | null) => void;
    /** Active MCP server configurations. */
    readonly mcpServerUsages: McpServerUsageInput[];
    /** Update MCP server configurations. */
    readonly setMcpServerUsages: (usages: McpServerUsageInput[]) => void;
    /** Active skill references. */
    readonly skillRefs: ResourceRef[];
    /** Update skill references. */
    readonly setSkillRefs: (refs: ResourceRef[]) => void;
    /** Workspace entries manager (git repos and local paths). */
    readonly workspace: UseWorkspaceEntriesReturn;
    /** Session variables (per-execution secrets) manager. */
    readonly sessionVariables: UseSessionVariablesReturn;
    /** `true` while the create session + execution flow is in flight. */
    readonly isSubmitting: boolean;
    /** Human-readable error from the last failed submission, or `null`. */
    readonly submitError: string | null;
    /**
     * Create a session with the first execution.
     *
     * Composes all managed state (agent, workspace, MCP servers, skills,
     * model, session variables) into the session and execution
     * creation RPCs, then calls `onSessionCreated` on success.
     *
     * The `model` parameter overrides `modelId` for this submission only
     * (used when SessionComposer passes a per-message model selection).
     */
    readonly submit: (message: string, model?: string, context?: SessionComposerSubmitContext) => Promise<void>;
}
/**
 * Orchestrates the "create a new session" flow.
 *
 * Manages all the state required to configure and submit a new session:
 * model selection (with localStorage persistence), agent resolution,
 * MCP server/skill selection, workspace entries, and session
 * variables. On submission, creates the session and its first execution
 * in sequence, then notifies the consumer via `onSessionCreated`.
 *
 * This hook is framework-agnostic — it works identically in Next.js,
 * Vite, Tauri, or any React environment. Navigation, toast notifications,
 * and draft-mode logic are the consumer's responsibility.
 *
 * @example
 * ```tsx
 * const flow = useNewSessionFlow({
 *   org: "acme",
 *   onSessionCreated: (id) => navigate(`/sessions/${id}`),
 *   onError: (msg) => toast.error(msg),
 * });
 *
 * <SessionComposer
 *   onSubmit={flow.submit}
 *   isSubmitting={flow.isSubmitting}
 *   org="acme"
 *   workspace={flow.workspace}
 *   agentRef={flow.agentRef}
 *   onAgentRefChange={flow.setAgentRef}
 *   onAgentResolutionChange={flow.setResolution}
 *   mcpServerUsages={flow.mcpServerUsages}
 *   onMcpServerUsagesChange={flow.setMcpServerUsages}
 *   skillRefs={flow.skillRefs}
 *   onSkillRefsChange={flow.setSkillRefs}
   *   sessionVariables={flow.sessionVariables}
 *   defaultModelId={flow.modelId}
 *   onModelChange={flow.setModelId}
 * />
 * ```
 */
export declare function useNewSessionFlow(options: UseNewSessionFlowOptions): UseNewSessionFlowReturn;
//# sourceMappingURL=useNewSessionFlow.d.ts.map