import { Readable } from 'node:stream';
import type { StandardizedRequest, ProcessedRequest } from '../types/standardized.js';
import type { JsonObject } from '../types/json.js';
import type { VirtualRouterConfig, RoutingDecision, RoutingDiagnostics, TargetMetadata, VirtualRouterHealthStore, ProviderQuotaView } from '../../../router/virtual-router/types.js';
import { type HubProcessNodeResult } from '../process/chat-process.js';
import { type HubPolicyConfig } from '../policy/policy-engine.js';
import { type HubToolSurfaceConfig } from '../tool-surface/tool-surface-engine.js';
export interface HubPipelineConfig {
    virtualRouter: VirtualRouterConfig;
    /**
     * Optional: hub-level policy controls (observe-only in V1 Phase 0).
     * Must remain config-driven and default to off.
     */
    policy?: HubPolicyConfig;
    /**
     * Optional: tool surface rollout controls.
     * - shadow: compute & record diffs, do not modify outbound payload
     * - enforce: rewrite outbound payload to match canonical tool surface
     */
    toolSurface?: HubToolSurfaceConfig;
    /**
     * 可选：供 VirtualRouterEngine 使用的健康状态持久化存储。
     * 当提供时，VirtualRouterEngine 将在初始化时恢复上一次快照，并在 cooldown/熔断变化时调用 persistSnapshot。
     */
    healthStore?: VirtualRouterHealthStore;
    /**
     * 可选：路由状态存储，用于持久化 sticky routing / stopMessage 等指令状态。
     */
    routingStateStore?: {
        loadSync(key: string): unknown;
        saveAsync(key: string, state: unknown): void;
    };
    /**
     * 可选：配额视图。若提供，VirtualRouterEngine 将在路由过程中参考
     * provider 的 quota 状态（inPool/priorityTier/cooldownUntil/blacklistUntil）
     * 过滤目标并按优先级分层调度。
     */
    quotaView?: ProviderQuotaView;
}
export interface HubPipelineRequestMetadata extends Record<string, unknown> {
    entryEndpoint?: string;
    providerProtocol?: string;
    processMode?: 'chat' | 'passthrough';
    stage?: 'inbound' | 'outbound';
    direction?: 'request' | 'response';
    stream?: boolean;
    routeHint?: string;
}
export interface HubPipelineRequest {
    id?: string;
    endpoint: string;
    payload: Record<string, unknown> | {
        readable?: Readable;
    } | Readable;
    metadata?: HubPipelineRequestMetadata;
}
type HubPipelineNodeMetadata = HubProcessNodeResult['metadata'] | Record<string, unknown>;
export interface HubPipelineNodeResult {
    id: string;
    success: boolean;
    metadata: HubPipelineNodeMetadata;
    error?: JsonObject;
}
export interface HubPipelineResult {
    requestId: string;
    providerPayload?: Record<string, unknown>;
    standardizedRequest?: StandardizedRequest;
    processedRequest?: ProcessedRequest;
    routingDecision?: RoutingDecision;
    routingDiagnostics?: RoutingDiagnostics;
    target?: TargetMetadata;
    metadata: Record<string, unknown>;
    nodeResults: HubPipelineNodeResult[];
}
export declare class HubPipeline {
    private readonly routerEngine;
    private config;
    private unsubscribeProviderErrors?;
    private unsubscribeProviderSuccess?;
    constructor(config: HubPipelineConfig);
    updateRuntimeDeps(deps: {
        healthStore?: HubPipelineConfig['healthStore'] | null;
        routingStateStore?: HubPipelineConfig['routingStateStore'] | null;
        quotaView?: HubPipelineConfig['quotaView'] | null;
    }): void;
    updateVirtualRouterConfig(nextConfig: VirtualRouterConfig): void;
    dispose(): void;
    private executeRequestStagePipeline;
    private resolveClientProtocol;
    private coerceStandardizedRequestFromPayload;
    private executeChatProcessEntryPipeline;
    execute(request: HubPipelineRequest): Promise<HubPipelineResult>;
    private captureAnthropicAliasMap;
    private shouldCaptureAnthropicAlias;
    private resolveAliasMapFromSources;
    private resolveProtocolHooks;
    private buildAdapterContext;
    private applyMaxTokensPolicy;
    private maybeCreateStageRecorder;
    private asJsonObject;
    private normalizeRequest;
    private convertProcessNodeResult;
    private materializePayload;
    private unwrapReadable;
    private convertSsePayload;
    private resolveSseProtocol;
    private extractModelHint;
    private resolveOutboundStreamIntent;
    private applyOutboundStreamPreference;
}
export {};
