import { type AttachmentInput, type EnvVarInput, type McpServerUsageInput, type ResourceRef } from "@stigmer/sdk";
import type { HarnessOption } from "../models/harness";
import { type AgentResolution } from "../agent/useAgentSetup";
import type { UseSessionVariablesReturn } from "../execution/useSessionVariables";
import type { UseWorkspaceEntriesReturn } from "../workspace/useWorkspaceEntries";
import type { UseGitHubConnectionReturn } from "../github/useGitHubConnection";
/**
 * Context provided to `onSubmit` at the moment of submission.
 *
 * Contains aggregated one-time environment variables from all setup
 * flows managed by the composer (agent, MCP servers, manual secrets).
 * The consumer passes `context.runtimeEnv` directly to execution
 * creation without needing to understand the individual sources.
 */
export interface SessionComposerSubmitContext {
    /**
     * Aggregated one-time environment variables from all setup flows.
     *
     * Merged from (in precedence order, last-write-wins):
     * 1. Agent one-time env vars (when agent resolution mode is `"oneTime"`)
     * 2. MCP server one-time env vars (collected with `saveForFuture: false`)
     * 3. Manual session variables (from {@link SessionVariablesInput})
     *
     * `undefined` when no runtime env vars were collected from any source.
     * Pass directly to execution creation as `runtimeEnv`.
     */
    readonly runtimeEnv?: Record<string, EnvVarInput>;
    /**
     * Pre-uploaded file attachments for the execution.
     *
     * Each entry contains a `storageKey` obtained from
     * `agentExecution.uploadAttachment()`. Only successfully uploaded
     * attachments are included. Pass directly to execution creation
     * as `attachments`.
     *
     * `undefined` when no files were attached.
     */
    readonly attachments?: AttachmentInput[];
}
/** Props for {@link SessionComposer}. */
export interface SessionComposerProps {
    /**
     * Called when the user submits a message.
     *
     * The optional `context` parameter carries aggregated runtime data
     * collected by the composer's setup flows. When present,
     * `context.runtimeEnv` should be passed to execution creation.
     */
    readonly onSubmit: (message: string, modelName?: string, context?: SessionComposerSubmitContext) => void;
    /** Shows loading indicator on the send button. */
    readonly isSubmitting?: boolean;
    /** Disables the entire composer (e.g., while an execution streams). */
    readonly disabled?: boolean;
    /**
     * Currently selected execution harness.
     *
     * Controls which models appear in the model selector and flows
     * through to session creation. When omitted, defaults to `"native"`.
     */
    readonly harness?: HarnessOption;
    /**
     * Called when the user switches the harness.
     *
     * Providing this callback enables the harness selector in the toolbar.
     */
    readonly onHarnessChange?: (harness: HarnessOption) => void;
    /** Show the harness selector in the toolbar. @default false */
    readonly showHarnessSelector?: boolean;
    /** Initial model ID for the model selector. */
    readonly defaultModelId?: string;
    /** Called when the user changes the selected model. */
    readonly onModelChange?: (modelId: string) => void;
    /** Show the model selector. @default true */
    readonly showModelSelector?: boolean;
    /**
     * Workspace state managed by {@link useWorkspaceEntries}.
     * When provided, renders a workspace trigger in the toolbar
     * that opens a popover with the workspace editor.
     */
    readonly workspace?: UseWorkspaceEntriesReturn;
    /** GitHub connection state for the repo picker. */
    readonly gitHubConnection?: UseGitHubConnectionReturn;
    /** Show the GitHub Repo source button. @default true */
    readonly enableGitHub?: boolean;
    /** Show the Local Folder source button. @default false */
    readonly enableLocal?: boolean;
    /**
     * Native folder picker callback passed through to {@link WorkspaceEditor}.
     * When provided, clicking "Local Folder" opens a native dialog instead
     * of the inline text input. See {@link WorkspaceEditorProps.onBrowseLocalFolder}.
     */
    readonly onBrowseLocalFolder?: () => Promise<string | null>;
    /**
     * Organization slug for agent, MCP server, and skill searches.
     * Required when agent, MCP, or skill pickers are enabled.
     */
    readonly org?: string;
    /**
     * Currently selected agent reference, or null if none.
     * When `onAgentRefChange` is provided, an agent trigger
     * appears in the toolbar (single-select).
     */
    readonly agentRef?: ResourceRef | null;
    /** Called when the agent selection changes. Providing this enables the agent trigger. */
    readonly onAgentRefChange?: (ref: ResourceRef | null) => void;
    /**
     * Called when the agent setup flow resolves how the agent should
     * be used for session creation.
     *
     * The {@link AgentResolution} discriminated union tells the caller
     * which session creation path to use:
     * - `"saved"` — use `agentInstanceId`
     * - `"oneTime"` — use `agentRef` + pass `runtimeEnv` to execution
     * - `"direct"` — use `agentRef` (no secrets needed)
     *
     * Set to `null` when the agent is deselected.
     */
    readonly onAgentResolutionChange?: (resolution: AgentResolution | null) => void;
    /**
     * Agent to auto-select when the composer mounts.
     *
     * When provided, the composer runs the full agent resolution flow
     * on mount — exactly as if the user had picked this agent in the
     * {@link AgentPicker}. If the agent requires credentials, the
     * environment form appears automatically.
     *
     * One-time: consumed on mount; subsequent changes are ignored.
     * To change the agent after mount, use the picker or
     * `onAgentRefChange` externally.
     *
     * Requires `org` and `onAgentRefChange` to be set (same
     * prerequisites as the agent picker).
     *
     * @example
     * ```tsx
     * <SessionComposer
     *   onSubmit={handleCreate}
     *   org="acme"
     *   agentRef={agentRef}
     *   onAgentRefChange={setAgentRef}
     *   onAgentResolutionChange={setResolution}
     *   initialAgentRef={{ org: "stigmer", slug: "agent-creator" }}
     * />
     * ```
     */
    readonly initialAgentRef?: ResourceRef;
    /**
     * Currently selected MCP server usages.
     * When `onMcpServerUsagesChange` is provided, a MCP server trigger
     * appears in the toolbar.
     */
    readonly mcpServerUsages?: McpServerUsageInput[];
    /** Called when the MCP server selection changes. Providing this enables the MCP trigger. */
    readonly onMcpServerUsagesChange?: (usages: McpServerUsageInput[]) => void;
    /**
     * Currently selected skill references.
     * When `onSkillRefsChange` is provided, a skill trigger
     * appears in the toolbar.
     */
    readonly skillRefs?: ResourceRef[];
    /** Called when the skill selection changes. Providing this enables the skill trigger. */
    readonly onSkillRefsChange?: (refs: ResourceRef[]) => void;
    /**
     * Currently selected runner ID, or `null` for "Auto" (backend decides).
     *
     * When `onRunnerIdChange` is provided and `org` is set, renders a
     * runner picker in the toolbar's Tier 1 (alongside Model Selector).
     *
     * The selected runner ID flows through to `session.create({ runnerId })`
     * so the session is bound to that runner's task queue.
     */
    readonly runnerId?: string | null;
    /**
     * Called when the user selects a different runner. `null` = "Auto".
     *
     * Providing this callback enables the runner picker in the toolbar.
     * Requires `org` to be set (same prerequisite as agent/MCP pickers).
     */
    readonly onRunnerIdChange?: (runnerId: string | null) => void;
    /**
     * Session variables state managed by {@link useSessionVariables}.
     * When provided, renders a "Session Variables" trigger in the toolbar
     * that opens a key-value editor for environment variables.
     *
     * Variables are ephemeral by default (single execution). Individual
     * entries can be marked `saveForFuture: true` to persist them to
     * the user's personal environment. The consumer should call
     * `sessionVariables.clear()` after submission.
     */
    readonly sessionVariables?: UseSessionVariablesReturn;
    /**
     * Enable file attachment support in the composer.
     *
     * When `true`, renders an attach button in the toolbar and enables
     * drag-and-drop file upload on the textarea. Attachments are uploaded
     * immediately via `agentExecution.uploadAttachment()` and included
     * in `context.attachments` on submit.
     *
     * @default true
     */
    readonly enableAttachments?: boolean;
    /**
     * Called when a file is rejected (e.g., exceeds the 10 MB limit).
     * Consumers can use this for toast notifications.
     */
    readonly onAttachmentValidationError?: (message: string) => void;
    /**
     * Files to attach programmatically when the composer mounts.
     *
     * When provided, the composer uploads these files via the same
     * attachment pipeline as user-selected files. Attachment chips
     * appear in the UI so the user sees what is attached.
     *
     * One-time: consumed when the value first becomes truthy.
     * Subsequent changes are ignored. This allows async resource
     * fetching — the effect waits for the files to be ready.
     *
     * Requires `enableAttachments` to be `true` (default).
     *
     * @example
     * ```tsx
     * const yaml = serializeAgentYaml(agent);
     * const file = new File([yaml], "my-agent.yaml", { type: "text/yaml" });
     *
     * <SessionComposer
     *   onSubmit={handleSubmit}
     *   initialAttachments={[file]}
     *   initialAgentRef={{ org: "stigmer", slug: "agent-creator" }}
     * />
     * ```
     */
    readonly initialAttachments?: File[];
    /** Placeholder text for the textarea. @default "Reply\u2026" */
    readonly placeholder?: string;
    /** Initial number of visible rows. @default 1 */
    readonly initialRows?: number;
    /** Auto-focus the textarea on mount. @default false */
    readonly autoFocus?: boolean;
    /** ARIA label for the composer region. @default "Send message" */
    readonly ariaLabel?: string;
    /** Additional CSS class names for the root container. */
    readonly className?: string;
}
/**
 * Unified message composer for Stigmer sessions.
 *
 * Combines a self-resizing textarea, model selector, and context pickers
 * (agent, workspace, MCP servers, skills) into a single input card.
 *
 * The toolbar uses a two-tier layout:
 * - **Tier 1** (always visible): Workspace, Attach, Model Selector
 * - **Tier 2** (behind Configure menu): Agent, MCP, Skills, Secrets
 *
 * Selected items render as removable chips between the textarea and toolbar.
 *
 * Used for both new session creation (launcher) and follow-up messages
 * within an existing session. Layout positioning is the consumer's
 * responsibility.
 *
 * Uses `<div role="form">` instead of `<form>` so it can be embedded
 * inside host application forms without nesting violations.
 *
 * All visual properties flow through `--stgm-*` tokens.
 *
 * @example
 * ```tsx
 * // Launcher with all context types
 * <SessionComposer
 *   onSubmit={handleCreate}
 *   org={org}
 *   agentRef={agentRef}
 *   onAgentRefChange={setAgentRef}
 *   onAgentResolutionChange={setResolution}
 *   workspace={workspace}
 *   enableGitHub
 *   mcpServerUsages={mcpUsages}
 *   onMcpServerUsagesChange={setMcpUsages}
 *   skillRefs={skillRefs}
 *   onSkillRefsChange={setSkillRefs}
 *   initialRows={3}
 *   placeholder="Describe what you need help with..."
 *   autoFocus
 * />
 *
 * // Pre-filled launcher (auto-selects agent on mount)
 * <SessionComposer
 *   onSubmit={handleCreate}
 *   org={org}
 *   agentRef={agentRef}
 *   onAgentRefChange={setAgentRef}
 *   onAgentResolutionChange={setResolution}
 *   initialAgentRef={{ org: "stigmer", slug: "agent-creator" }}
 *   placeholder="Describe the agent you want to create..."
 *   initialRows={3}
 *   autoFocus
 * />
 *
 * // Follow-up (compact, workspace only)
 * <SessionComposer
 *   onSubmit={(msg, model) => conv.sendFollowUp(msg, { modelName: model })}
 *   disabled={!conv.canSendFollowUp}
 *   isSubmitting={conv.isSending}
 *   workspace={workspace}
 * />
 * ```
 */
export declare const SessionComposer: import("react").NamedExoticComponent<SessionComposerProps>;
//# sourceMappingURL=SessionComposer.d.ts.map