/** * Public package exports — pi-smart-router. * * Exposes the router factory (T022) and pi lifecycle hook registrar (T021). * Full pi integration uses `.pi/extensions/smart-router/`; library embedders * route via `dispatch.dispatch()` after calling `register(hooks)`. */ import type { ModelProfile, RoutingDecision } from './domain/types/index.js'; import { type FleetCatalog } from './config/models-loader.js'; import { loadRoutingClusters, clusterReasonCode, type TextEmbedder } from './config/routing-clusters-loader.js'; import { GatewayDispatch, type GatewayDispatchOptions } from './infrastructure/gateway/gateway-dispatch.js'; import { LifecycleHookState, type PiRouterMiddleware, type PiExtensionHooks } from './api/middleware/pi-router-middleware.js'; /** Package identifier for diagnostics and telemetry. */ export declare const PACKAGE_NAME: "pi-smart-router"; export interface RouterFactoryOptions { readonly modelsPath?: string; } export interface RouterHandle { readonly version: string; readonly middleware: PiRouterMiddleware; readonly dispatch: GatewayDispatch; readonly fleet: readonly ModelProfile[]; readonly register: (hooks: PiExtensionHooks) => void; } /** * Create a router handle from the default fleet catalog (T022). * * Composition root: **catalog / library path**. Loads YAML fleet and builds * `GatewayDispatch` with library defaults only (`costEstimator` + * `localRuntime`). Hardware probe and store-backed telemetry are **not** * wired here — pass them via `createRouterFromFleet(fleet, options)`, or use * the pi extension (`createDispatchOptions` in fleet-bootstrap) for the * supported full-product composition root. See `docs/migration-v1.md`. * * Concurrency contract (SP-230, #141): the underlying `RouterPipeline` * serializes concurrent `route()` calls (single-flight) because each route * owns one per-route `RoutingContext`. A shared handle is safe under * overlapping requests — a concurrent caller queues behind the in-flight * route for at most one routing latency, and routing policy outcomes are * unchanged. Create separate handles for parallel routing throughput. */ export declare function createRouter(options?: RouterFactoryOptions): RouterHandle; export declare function createRouterFromCatalog(catalog: FleetCatalog): RouterHandle; export interface CreateRouterFromFleetOptions extends GatewayDispatchOptions { readonly lifecycleHookState?: LifecycleHookState; } /** * Create a router handle from an in-memory fleet. * * Optional `options` are forwarded to `GatewayDispatch` (pipeline ports, * session pinner, HyDRA matcher, telemetry emitter, …). Omitting them keeps * the library catalog defaults — not the pi extension wiring. */ export declare function createRouterFromFleet(fleet: ModelProfile[], options?: CreateRouterFromFleetOptions): RouterHandle; export type { RoutingDecision, ModelProfile }; export { loadRoutingClusters, clusterReasonCode, }; export type { TextEmbedder }; export type { RoutingClusterCatalog } from './domain/types/index.js'; export type { PiRouterMiddleware, PiRouterMiddlewareOptions, PiExtensionHooks, PiExtensionContext, PiProviderRequestEvent, PiContextEvent, PiModelSelectEvent, PiSessionManager, LifecycleFlags, } from './api/middleware/pi-router-middleware.js'; export { createPiRouterMiddleware, LifecycleHookState } from './api/middleware/pi-router-middleware.js'; export { evictInMemorySessionState } from './api/session-eviction.js'; export type { SessionEvictionTargets } from './api/session-eviction.js'; export type { GatewayDispatchOptions } from './infrastructure/gateway/gateway-dispatch.js'; export type { PipelineOptions } from './domain/pipeline/router-pipeline.js'; export type { HardwareProbePort, SystemInfoPort, ThroughputMeter, } from './domain/ports/hardware-probe-port.js'; export type { HttpFetchPort, LocalRuntimePort, } from './domain/ports/local-runtime-port.js'; export type { PeakPricingTelemetryFields, RoutePathTelemetryExtras, RoutingCostEstimator, TelemetryEmitterPort, } from './domain/ports/telemetry-emitter-port.js'; export type { AdaptiveReasoningConfig, CompressedContextSpec, Message, PlanningDelegateConfig, PlanningDelegateObservability, PriceCatalog, RoutingDatasetRecord, RoutingFeatureSidecar, RoutingOutcomeRecord, RoutingReasoningTelemetry, RoutingRequest, RoutingTelemetry, RoutingUsageActuals, StorePort, TurnType, } from './domain/types/index.js'; export type { QuotaWindowPosition } from './domain/types/entities.js'; export type { OperatorConfig, TypedJudgmentConfig } from './domain/types/schemas.js'; export { DEFAULT_PLANNING_DELEGATE_CONFIG, DEFAULT_TYPED_JUDGMENT_CONFIG, resolveTypedJudgmentConfigFromEnv, } from './domain/types/schemas.js'; export { createTypedJudgmentPort, type CreateTypedJudgmentPortResult, } from './infrastructure/judgment/jev-typed-judgment-adapter.js'; export type { TypedJudgmentPort } from './domain/ports/typed-judgment-port.js'; export { DEFAULT_OPERATOR_CONFIG, resolveOperatorConfigFromEnv, } from './config/defaults.js'; export { mapFleetFromRegistry } from './config/pi-model-mapper.js'; export { applyConcisenessHint, resolveAdaptiveReasoning, type AdaptiveReasoningResult, type AdaptiveReasoningSignal, } from './domain/delegation/adaptive-reasoning.js'; export { isGoogleDelegationTarget, isCursorDelegationTarget, isCursorOriginAssistantMessage, normalizeDelegationContext, repairGeminiReplayContext, stripCursorLifecycleThinking, STRIP_CURSOR_LIFECYCLE_ENV, type CursorLifecycleStripResult, type StripCursorLifecycleOptions, } from './domain/delegation/delegation-context.js'; export { ExecutionLedger } from './domain/delegation/execution-ledger.js'; export { computeOutputHeadroom, type OutputHeadroomConfig, } from './domain/delegation/output-headroom.js'; export { DEGENERATE_OUTPUT, DEGENERATE_OUTPUT_ERROR_CODE, DEFAULT_DEGENERATE_OUTPUT_CONFIG, classifyDegenerateOutput, isDegenerateOutput, repeatedNgramRatio, type DegenerateOutputClassification, type DegenerateOutputConfig, type DegenerateOutputMessage, } from './domain/delegation/degenerate-output.js'; export { HydraMatcher, createOnnxEmbeddingProvider, } from './domain/matching/hydra-matcher.js'; export { SessionPinner } from './domain/pinning/session-pinner.js'; export { safeCloudDefault } from './domain/pipeline/safe-default.js'; export { resolvePeakPricingAdjustment } from './domain/pricing/peak-pricing.js'; export { collectPoolModelIds, resolveQuotaWindowEstimateConfigFromEnv, resolveQuotaWindowPosition, type QuotaWindowAdapter, type QuotaWindowEstimateConfig, } from './domain/pricing/quota-window-feed.js'; export { CONTEXT_OVERFLOW_NO_FIT, resolveContextOverflowFallback, } from './domain/routing/context-fit.js'; export { attachOutcomeLabelsToExport, indexOutcomesByRequestId, } from './domain/routing/p-success-classifier.js'; export { GEMINI_TOOL_HISTORY_EXCLUDED, assertRoutableFleetAfterGeminiToolHistoryGuard, hasToolCallHistory, hasToolCallHistoryFromContext, isGoogleGeminiProfile, resolveEffectiveFleet, type GeminiToolHistoryGuardResult, } from './domain/routing/tool-history-guard.js'; export { GEMINI_REPLAY_INCOMPATIBLE } from './infra/gemini-provider.js'; export { formatGeminiThoughtSignatureErrorMessage, formatProviderErrorMessage, isGeminiThoughtSignatureAssistantError, parseAssistantMessageError, sanitizeLengthStopMessage, type LengthStopHints, } from './infrastructure/delegation/provider-error.js'; export { shouldFailoverOnProviderError, type RateLimitPort, } from './infrastructure/gateway/gateway-dispatch.js'; export { getDefaultSystemInfo } from './infrastructure/hardware/hardware-probe.js'; export { collectPlacementPlan, type PlacementPlanReport, } from './infrastructure/hardware/placement-plan.js'; export { DEFAULT_LOCAL_CONFIG } from './infrastructure/local/local-zero-tier.js'; export { createResilientStore, SqliteStore, SqliteStoreError, } from './infrastructure/persistence/sqlite-store.js'; export { fetchLitellmPriceCatalog } from './infrastructure/pricing/litellm-fetch.js'; export { applyCatalogPricesToFleet } from './infrastructure/pricing/price-broker.js'; export { checkStaleness } from './infrastructure/pricing/pricing-monitor.js'; export { DATASET_MAX_ENTRIES } from './infrastructure/telemetry/dataset-limits.js'; export { DATASET_ENABLED_NOTIFY_MESSAGE, DatasetRecorder, } from './infrastructure/telemetry/dataset-recorder.js'; export { OutcomeRecorder, type SessionRoutingSnapshot, } from './infrastructure/telemetry/outcome-recorder.js'; export { PLANNING_DELEGATE, PLANNING_DELEGATE_TIMEOUT, PLANNING_DELEGATE_UNAVAILABLE, PLANNING_DIRECT_FRONTIER, RoutingTelemetryEmitter, createPlanningDelegateObservability, enrichRoutingDecisionWithPlanningDelegate, extractUsageActuals, } from './infrastructure/telemetry/routing-telemetry.js'; export { aggregateSessionStatsFromFleet, type SessionStatsSnapshot, } from './infrastructure/telemetry/session-stats.js'; export { DEFAULT_HISTORY_LIMIT, MAX_HISTORY_LIMIT, } from './infrastructure/telemetry/telemetry-limits.js'; export { DEFAULT_TELEMETRY_CONTRIB_EXPORT_LIMIT, exportTelemetryContrib, parseExportTelemetryContribArgs, } from './cli/smart-router-cli.js'; //# sourceMappingURL=index.d.ts.map