import type { ThinkingLevel } from "@sheason/pi-agent-core";
import type { Api, Model } from "@sheason/pi-ai";
import type { AgentSession, AgentSessionRuntimeDiagnostic, AgentSessionServices, CompactionResult, CreateAgentSessionServicesOptions, LoadExtensionsResult, ModelCycleResult, ToolDefinition } from "@sheason/pi-coding-agent";
import type { AgentModelRef } from "../agents/types.js";
import type { PeerMcpIndexSnapshot } from "../config-aggregation/agent-config-services.js";
import type { PeerConfigJsonLayers } from "../config-aggregation/types.js";
import type { HubResourceLoader } from "../resources/hub-resource-loader.js";
import type { HubSessionService } from "../session/hub-session-service.js";
import type { LiveRenderEvent } from "../transport/live-events.js";
import type { QueueWriteImage } from "../transport/protocol.js";
import type { HubLogSink } from "../tui/hub-log.js";
export type MessageSourceKind = "peer" | "source" | "agent" | "host";
export interface MessageSourceContextHeader {
    label: string;
    value: string;
}
export interface MessageSource {
    kind: MessageSourceKind;
    name: string;
    sentAt?: string;
    contextHeaders?: MessageSourceContextHeader[];
    messageId?: string;
    responseIds?: string[];
}
export interface QueuedInputMessage {
    text: string;
    messageSource: MessageSource;
    responseTimeout?: number;
    images?: QueueWriteImage[];
    queueMode?: "steer" | "followUp";
}
export interface MessageSourceMetadata {
    sentAt?: string;
    authTokenName?: string;
    authTokenDescription?: string;
    authUser?: string;
    authPurpose?: string;
}
export declare const MESSAGE_SOURCE_SECURITY_NOTE = "\u6CE8\u610F\u533A\u5206\u6D88\u606F\u6765\u6E90\u548C\u4EBA\u5458\u6743\u9650\u8303\u56F4";
export interface InputQueueFlushResult {
    flushed: boolean;
    messages: number;
}
export declare function createPeerMessageSource(peerId: string, metadata?: MessageSourceMetadata): MessageSource;
export declare function createHostMessageSource(hostId?: string, metadata?: MessageSourceMetadata): MessageSource;
export declare function createSourceMessageSource(name: string): MessageSource;
export declare function createAgentMessageSource(agentId: string): MessageSource;
export declare function formatMessageSourceLabel(source: MessageSource): string;
export declare function messageSourceHeaderPrefix(source: MessageSource): string;
export interface CreateHubAgentAdapterOptions {
    agentId?: string;
    sessionService: HubSessionService;
    tools: ToolDefinition[];
    cwd?: string;
    agentDir?: string;
    configLayers?: PeerConfigJsonLayers[];
    getConfigLayers?: () => PeerConfigJsonLayers[];
    getPeerMcpSnapshots?: () => PeerMcpIndexSnapshot[];
    services?: AgentSessionServices;
    resourceLoaderOptions?: CreateAgentSessionServicesOptions["resourceLoaderOptions"];
    prepareServices?: (services: AgentSessionServices) => Promise<void> | void;
    model?: Model<Api>;
    thinkingLevel?: ThinkingLevel;
    scopedModels?: Array<{
        model: Model<Api>;
        thinkingLevel?: ThinkingLevel;
    }>;
    /**
     * Optional callback invoked from `reload()` so the hub can re-read external
     * runtime configuration (for example `.pi/sources.json`) alongside the agent
     * session reload.
     */
    refreshSources?: () => Promise<void>;
    /**
     * Optional callback invoked from `reload()` after sources refresh, to
     * restart the MCP host and refresh MCP-derived tools in `customTools`.
     */
    refreshMcp?: () => Promise<void>;
    /**
     * Called immediately before the automatic input queue pump consumes queued
     * messages. Return false when the adapter was replaced and this pump should
     * stop so the replacement can continue with the persisted queue.
     */
    beforeInputQueueDrain?: () => Promise<boolean | undefined> | boolean | undefined;
    logs?: HubLogSink;
    /** Persisted model reference from AgentRecord, used to restore model on adapter restart. */
    persistedModel?: AgentModelRef;
    /** Called when the model changes so the caller can persist it to AgentRecord. */
    onModelChange?: (modelRef: AgentModelRef) => void;
}
export interface HubAgentAdapterStatus {
    diagnostics: readonly AgentSessionRuntimeDiagnostic[];
}
export interface HubAgentAdapterBindings {
    session: AgentSession;
    services: AgentSessionServices;
    extensionsResult: LoadExtensionsResult;
    resourceLoader: HubResourceLoader;
}
export interface HubAgentAdapterApi extends HubAgentAdapterStatus, HubAgentAdapterBindings {
    enqueueFromPeer(peerId: string, text: string, metadata?: MessageSourceMetadata, images?: QueuedInputMessage["images"], queueMode?: "steer" | "followUp"): Promise<void>;
    enqueueFromHost(hostId: string, text: string, metadata?: MessageSourceMetadata, images?: QueuedInputMessage["images"], queueMode?: "steer" | "followUp"): Promise<void>;
    enqueueFromSource(sourceName: string, text: string): Promise<void>;
    enqueueFromAgent(agentId: string, text: string, options?: {
        messageId?: string;
        responseIds?: string[];
        responseTimeout?: number;
    }): Promise<void>;
    continueCurrentTranscript(): void;
    requestInputQueuePump(): void;
    flushInputQueue(): Promise<InputQueueFlushResult>;
    dequeue(): Promise<QueuedInputMessage[]>;
    abort(): Promise<void>;
    setModel(model: Model<Api>): Promise<void>;
    cycleModel(direction?: "forward" | "backward"): Promise<ModelCycleResult | undefined>;
    setThinkingLevel(level: ThinkingLevel): void;
    cycleThinkingLevel(): ThinkingLevel | undefined;
    compact(customInstructions?: string): Promise<CompactionResult>;
    reload(): Promise<void>;
    getAvailableModels(): Promise<Model<Api>[]>;
    subscribeLiveEvents(listener: (event: LiveRenderEvent) => void): () => void;
    dispose(): void;
}
//# sourceMappingURL=types.d.ts.map