import type { SqliteDatabase } from '../db/adapter.js'; import type { TaskProfile } from '../akinator/types.js'; import { listContextDeliveries } from './delivery.js'; import { type Recommendation } from './recommendations.js'; import { type RankedCandidate } from './ranking.js'; import { type FederatedOrigin } from '../memory/federated-retrieval.js'; import type { LedgerProjection } from '../ledger/projection.js'; import type { RunRecord } from '../ledger/types.js'; import type { EmbeddingRuntime } from '../embedding/types.js'; export declare const CONTEXT_BROKER_POLICY_VERSION: "context-ranking-v1+recommendations.v1"; export declare const CONTEXT_BROKER_DEFAULT_LIMIT = 20; export declare const CONTEXT_BROKER_MAX_LIMIT = 100; export declare const CONTEXT_BROKER_DEFAULT_CHARACTER_BUDGET = 8000; export declare const CONTEXT_BROKER_MAX_CHARACTER_BUDGET = 100000; export interface ContextBrokerQueryInput { workspace?: string; runId?: string; task?: string; taskProfile?: TaskProfile; recommendedTags?: string[]; changedPaths?: string[]; errorSignatures?: string[]; limit?: number; characterBudget?: number; } export interface ContextBrokerContextItem { entryId: string; entryRevision: number; rank: number; scoreComponents: RankedCandidate['scoreComponents']; selectionReasons: string[]; content: RankedCandidate['content']; untrusted: true; origin?: FederatedOrigin; } export interface ContextBrokerContext { deliveryId: string | null; runId: string | null; throughSequence: number; taskProfileHash: string; queryHash: string; policyVersion: typeof CONTEXT_BROKER_POLICY_VERSION; items: ContextBrokerContextItem[]; untrusted: true; } export interface ContextBrokerResult { status: 'needs_answer' | 'ready' | 'exhausted' | 'unbound'; taskProfile: TaskProfile; profileHash: string; acceptedThrough: number; intakeSessionId: string | null; recommendedTags: string[]; projection: LedgerProjection | null; context: ContextBrokerContext | null; recommendations: Recommendation[]; } export interface ContextBrokerPersistence { enqueueWrite?: (operation: () => T) => Promise | T; } export interface ContextBrokerGateDecision { persist: boolean; value: T; assertBeforePersist?: () => void; } export interface ContextBrokerGatedResult { broker: ContextBrokerResult; value: T; } export interface ContextBrokerRunState { run: RunRecord; taskProfile: TaskProfile; profileHash: string; recommendedTags: string[]; intakeSessionId: string; status: 'needs_answer' | 'ready' | 'exhausted'; } /** Read the same authoritative run/intake/profile snapshot used to rank broker context. */ export declare function readContextBrokerRunState(database: SqliteDatabase, runId: string): ContextBrokerRunState; export declare class ContextBroker { private readonly database; private readonly embeddingRuntime?; private readonly inFlight; constructor(database: SqliteDatabase, embeddingRuntime?: EmbeddingRuntime | undefined); listDeliveries(input: { runId: string; cursor?: string; limit?: number; }): ReturnType & { untrusted: true; }; query(rawInput: unknown, persistence?: ContextBrokerPersistence): Promise; queryGated(rawInput: unknown, decide: (candidate: ContextBrokerResult) => ContextBrokerGateDecision, persistence?: ContextBrokerPersistence): Promise>; private execute; private queryPrepared; private prepareResult; private persistPrepared; private validatePrepared; } //# sourceMappingURL=broker.d.ts.map